finish command detail

This commit is contained in:
Tiavina 2025-02-11 14:41:37 +03:00
parent 69385a37c7
commit c209f3c251
6 changed files with 37 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ use Exception;
use OCA\Gestion\Service\ConfigurationService; use OCA\Gestion\Service\ConfigurationService;
use OCA\Gestion\Service\NavigationService; use OCA\Gestion\Service\NavigationService;
use OCA\Gestion\Service\Order\OrderService; use OCA\Gestion\Service\Order\OrderService;
use Psr\Log\LoggerInterface;
defined("TAB1") or define("TAB1", "\t"); defined("TAB1") or define("TAB1", "\t");
use OCP\IGroupManager; use OCP\IGroupManager;
@ -45,6 +46,8 @@ class OrderController extends Controller {
private $navigationService; private $navigationService;
private $configurationService; private $configurationService;
private $logger;
/** /**
* Constructor * Constructor
*/ */
@ -60,7 +63,8 @@ class OrderController extends Controller {
IGroupManager $groupManager, IGroupManager $groupManager,
OrderService $orderService, OrderService $orderService,
NavigationService $navigationService, NavigationService $navigationService,
ConfigurationService $configurationService ConfigurationService $configurationService,
LoggerInterface $logger
){ ){
parent::__construct($AppName, $request); parent::__construct($AppName, $request);
@ -73,6 +77,7 @@ class OrderController extends Controller {
$this->orderService = $orderService; $this->orderService = $orderService;
$this->navigationService = $navigationService; $this->navigationService = $navigationService;
$this->configurationService = $configurationService; $this->configurationService = $configurationService;
$this->logger = $logger;
if ($userSession->isLoggedIn()) { if ($userSession->isLoggedIn()) {
$this->user = $userSession->getUser(); $this->user = $userSession->getUser();
@ -148,7 +153,6 @@ class OrderController extends Controller {
return true; return true;
} }
catch(Exception $e){ catch(Exception $e){
var_dump($e->getMessage());
return null; return null;
} }
} }
@ -190,15 +194,17 @@ class OrderController extends Controller {
* @param string $orderId * @param string $orderId
*/ */
public function orderDetails($orderId) { public function orderDetails($orderId) {
$this->logger->debug("logId");
$this->logger->debug("$orderId");
$orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId); $orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId);
return new TemplateResponse( return new TemplateResponse(
'gestion', 'gestion',
'orderDetails', 'orderDetails',
array( array(
'groups' => $this->groups, 'groups' => $this->groups,
'user' => $this->user, 'user' => $this->user,
"configuration" => $this->configurationService->getDefaultConfiguration(), "configuration" => json_decode(json_encode($this->configurationService->getDefaultConfiguration())),
'order'=>json_decode($orderWithDetail), 'order'=>json_decode(json_encode($orderWithDetail)),
'path' => $this->idNextcloud, 'path' => $this->idNextcloud,
'url' => $this->navigationService->getNavigationLink(), 'url' => $this->navigationService->getNavigationLink(),
'logo' => $this->getLogo() 'logo' => $this->getLogo()
@ -222,8 +228,7 @@ class OrderController extends Controller {
*/ */
public function getOrderTotalAmount($orderId) { public function getOrderTotalAmount($orderId) {
$configuration = $this->configurationService->getDefaultConfiguration(); $configuration = $this->configurationService->getDefaultConfiguration();
$configuration = json_decode($configuration); $orderTotalAmount = $this->orderService->getOrderTotalAmount($orderId,$configuration["tva_default"] ?? 0);
$orderTotalAmount = $this->orderService->getOrderTotalAmount($orderId,$configuration->tva_default ?? 0);
return json_encode($orderTotalAmount); return json_encode($orderTotalAmount);
} }
} }

View File

@ -73,7 +73,7 @@ class Bdd {
public function getConfigurationByIdNextcloud($idNextcloud){ public function getConfigurationByIdNextcloud($idNextcloud){
$sql = "SELECT * FROM `".$this->tableprefix."configuration` WHERE id_nextcloud = ?"; $sql = "SELECT * FROM `".$this->tableprefix."configuration` WHERE id_nextcloud = ?";
$result = $this->execSQL($sql, array($idNextcloud)); $result = $this->execSQLNoJsonReturn($sql, array($idNextcloud));
if(!empty($result)){ if(!empty($result)){
return $result[0]; return $result[0];
} }

View File

@ -354,7 +354,7 @@ class OrderBdd {
" "
; ;
$result = $this->execSQL($sql,[$orderId]); $result = $this->execSQLNoJsonReturn($sql,[$orderId]);
if(!empty($result)){ if(!empty($result)){
return $result[0]; return $result[0];
} }
@ -368,8 +368,8 @@ class OrderBdd {
$totalTvaAmount = 0; $totalTvaAmount = 0;
$orderProducts = $this->getOrderProductsByOrderId($orderId); $orderProducts = $this->getOrderProductsByOrderId($orderId);
foreach($orderProducts as $orderProduct){ foreach($orderProducts as $orderProduct){
$totalHt += $orderProduct["produit_ht_price"]; $totalHt += $orderProduct["produit_ht_price"] * $orderProduct["order_product_quantity"];
$totalTvaAmount += $orderProduct["produit_ht_price"] * $tva; $totalTvaAmount += $orderProduct["produit_ht_price"] * $tva / 100;
$totalTtc += ($totalHt * ($tva + 100)) / 100; $totalTtc += ($totalHt * ($tva + 100)) / 100;
} }

View File

@ -1,6 +1,6 @@
import { showSuccess, showError } from "@nextcloud/dialogs"; import { showSuccess, showError } from "@nextcloud/dialogs";
import { translate as t, translatePlural as n } from '@nextcloud/l10n' import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { baseUrl, showLoader } from "../mainFunction.mjs"; import { baseUrl, showLoader , cur} from "../mainFunction.mjs";
/** /**
* Update order date * Update order date
@ -61,13 +61,15 @@ export function getTotalAmountOfOrder(orderId) {
$.ajax({ $.ajax({
url: baseUrl + '/order/'+orderId+'/totalAmount', url: baseUrl + '/order/'+orderId+'/totalAmount',
type: 'PROPFIND', type: 'PROPFIND',
contentType: 'application/json', contentType: 'application/json'
data: JSON.stringify({
numdevis: id_devis
})
}).done((function (totalAmountResult) { }).done((function (totalAmountResult) {
var totalAmount = JSON.parse(totalAmountResult); var totalAmount = JSON.parse(totalAmountResult);
$('#totalOrderProducts tbody').empty(); $('#totalOrderProducts tbody').empty();
$('#totalOrderProducts tbody').append('<tr><td>' + cur.format(totalAmount.totalHt) + '</td><td id="tva">' + totalAmount.tva + ' %</td><td id="totaltva">' + cur.format(Math.round(totalAmount.totalTvaAmount)) + '</td><td>' + cur.format(Math.round(totalAmount.totalTtc)) + '</td></tr>'); $('#totalOrderProducts tbody').append(
'<tr>'+
'<td style="text-align:center;">' + cur.format(totalAmount.totalHt)+'</td>'+
'<td id="tva" style="text-align:center;">' + totalAmount.tva + ' %</td>'+
'<td id="totaltva" style="text-align:center;">' + cur.format(Math.round((totalAmount.totalHt * totalAmount.tva)) / 100) + '</td>'+
'<td style="text-align:center;">' + cur.format(Math.round((totalAmount.totalHt * (totalAmount.tva + 100))) / 100) + '</td></tr>');
})); }));
} }

View File

@ -1,6 +1,7 @@
<?php <?php
$order = $_['order']; $order = $_['order'];
$configuration = json_decode($_['configuration']); $configuration = $_['configuration'];
$orderComment = $order->order_comment == null || $order->order_comment == "" ? "-": $order->order_comment;
?> ?>
<div class="bootstrap-iso"> <div class="bootstrap-iso">
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Commande'));?> <h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Commande'));?>
@ -46,13 +47,19 @@
<span>Lieu : <b><?php echo $order->lieu_nom;?> (<?php echo $order->lieu_adresse;?>)</b> <span>Lieu : <b><?php echo $order->lieu_nom;?> (<?php echo $order->lieu_adresse;?>)</b>
</div> </div>
</div> </div>
<hr/>
</div> </div>
<div class="row"> <div class="row">
<div class="col col-md"> <div class="col col-md">
<hr /> <label class="fw-bold">Commentaires :</label>
<div class="col col-xl mb-3 text-center editable" style="display:inline" data-table="orders" data-column="order_comment" data-id="<?php echo $order->id; ?>"><?php echo ($order->order_comment ?? "-"); ?></div> <div class="col col-xl mb-3 text-center editable"
<hr /> style="display:inline"
data-table="orders" data-column="order_comment"
data-id="<?php echo $order->id;?>">
<?php echo $orderComment; ?>
</div>
</div> </div>
<hr />
</div> </div>
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div><h2>Articles</h2></div> <div><h2>Articles</h2></div>
@ -65,7 +72,6 @@
<tr> <tr>
<th><?php p($l->t('Reference'));?></th> <th><?php p($l->t('Reference'));?></th>
<th><?php p($l->t('Designation'));?></th> <th><?php p($l->t('Designation'));?></th>
<th><?php p($l->t('Comment'));?></th>
<th><?php p($l->t('Quantity'));?></th> <th><?php p($l->t('Quantity'));?></th>
<th><?php p($l->t('Unit price without VAT'));?></th> <th><?php p($l->t('Unit price without VAT'));?></th>
<th><?php p($l->t('Total without VAT'));?></th> <th><?php p($l->t('Total without VAT'));?></th>