Merge branch 'fixes/fix-relation-of-devis-and-order' into releases/release-h2f
This commit is contained in:
commit
2c8174d99d
@ -163,8 +163,10 @@ return [
|
||||
['name' => 'order#createDefaultThanatoProductFee','url' => '/thanatoProductFees/createDefaultThanatoProductFee', 'verb' => 'POST'],
|
||||
['name' => 'order#orderDetails', 'url' => '/order/{orderId}/details', 'verb' => 'GET'],
|
||||
['name' => 'order#getOrderProductsById', 'url' => '/order/{orderId}/products', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#getOrderItemsByOrderId', 'url' => '/order/{orderId}/items', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#getOrderTotalAmount', 'url' => '/order/{orderId}/totalAmount', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#exportOrderToPdf', 'url' => '/order/{orderId}/exportToPdf', 'verb' => 'POST'],
|
||||
['name' => 'order#addOrderItems', 'url' => '/order/{orderId}/addItems', 'verb' => 'POST'],
|
||||
|
||||
//clients discount
|
||||
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
|
||||
@ -180,5 +182,11 @@ return [
|
||||
['name' => 'provider#provider', 'url' => '/provider', 'verb' => 'GET'],
|
||||
['name' => 'provider#getProviders','url' => '/provider/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'provider#createDefaultProvider','url' => '/provider/createDefaultProvider', 'verb' => 'POST'],
|
||||
['name' => 'provider#exportProvidersStatistic','url' => '/provider/exportStat', 'verb' => 'POST'],
|
||||
|
||||
//orderProduct
|
||||
['name' => 'order#orderProduct', 'url' => '/orderProduct', 'verb' => 'GET'],
|
||||
['name' => 'order#getOrderProducts','url' => '/orderProduct/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#createDefaultOrderProduct','url' => '/orderProduct/createDefaultOrderProduct', 'verb' => 'POST'],
|
||||
]
|
||||
];
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
gestion/js/orderProduct.app.js
Normal file
2
gestion/js/orderProduct.app.js
Normal file
File diff suppressed because one or more lines are too long
46
gestion/js/orderProduct.app.js.LICENSE.txt
Normal file
46
gestion/js/orderProduct.app.js.LICENSE.txt
Normal file
@ -0,0 +1,46 @@
|
||||
/*!
|
||||
* Sizzle CSS Selector Engine v2.3.9
|
||||
* https://sizzlejs.com/
|
||||
*
|
||||
* Copyright JS Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* https://js.foundation/
|
||||
*
|
||||
* Date: 2022-12-19
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Toastify js 1.12.0
|
||||
* https://github.com/apvarun/toastify-js
|
||||
* @license MIT licensed
|
||||
*
|
||||
* Copyright (C) 2018 Varun A P
|
||||
*/
|
||||
|
||||
/*!
|
||||
* escape-html
|
||||
* Copyright(c) 2012-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2015 Andreas Lubbe
|
||||
* Copyright(c) 2015 Tiancheng "Timothy" Gu
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* jQuery JavaScript Library v3.6.3
|
||||
* https://jquery.com/
|
||||
*
|
||||
* Includes Sizzle.js
|
||||
* https://sizzlejs.com/
|
||||
*
|
||||
* Copyright OpenJS Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* https://jquery.org/license
|
||||
*
|
||||
* Date: 2022-12-20T21:28Z
|
||||
*/
|
||||
|
||||
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
|
||||
|
||||
/*! DataTables 1.13.2
|
||||
* ©2008-2023 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
9
gestion/lib/Constants/OrderPdfConstant.php
Normal file
9
gestion/lib/Constants/OrderPdfConstant.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Constants;
|
||||
abstract class OrderPdfConstant
|
||||
{
|
||||
const SUBCONTRACTOR_TYPE = "SOUS TRAITANT";
|
||||
const PROVIDER_TYPE = "FOURNISSEUR";
|
||||
}
|
||||
9
gestion/lib/Constants/OrderTypeConstant.php
Normal file
9
gestion/lib/Constants/OrderTypeConstant.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Constants;
|
||||
abstract class OrderTypeConstant
|
||||
{
|
||||
const ORDER_TYPE_DEVIS = "DEVIS";
|
||||
const ORDER_TYPE_PURCHASE = "PURCHASE";
|
||||
}
|
||||
@ -198,8 +198,6 @@ class OrderController extends Controller {
|
||||
* @param string $orderId
|
||||
*/
|
||||
public function orderDetails($orderId) {
|
||||
$this->logger->debug("logId");
|
||||
$this->logger->debug("$orderId");
|
||||
$orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId);
|
||||
return new TemplateResponse(
|
||||
'gestion',
|
||||
@ -220,8 +218,8 @@ class OrderController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
* @param string $orderId
|
||||
*/
|
||||
public function getOrderProductsById($orderId) {
|
||||
$orderProducts = $this->orderService->getOrderProductsById($orderId);
|
||||
public function getOrderItemsByOrderId($orderId) {
|
||||
$orderProducts = $this->orderService->getOrderItemsByOrderId($orderId);
|
||||
return json_encode($orderProducts);
|
||||
}
|
||||
|
||||
@ -248,4 +246,51 @@ class OrderController extends Controller {
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function orderProduct() {
|
||||
return new TemplateResponse('gestion', 'orderProduct', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function createDefaultOrderProduct() {
|
||||
try{
|
||||
$this->orderService->createDefaultOrderProduct($this->idNextcloud);
|
||||
return true;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function addOrderItems($orderId) {
|
||||
try{
|
||||
$this->orderService->addDefaultOrderItem($orderId);
|
||||
return true;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getOrderProducts() {
|
||||
$orderProducts = $this->orderService->getOrderProducts();
|
||||
return $orderProducts;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1663,6 +1663,10 @@ class PageController extends Controller {
|
||||
$result = $this->myDb->gestion_update($table, $column, $data, $id, $this->idNextcloud);
|
||||
|
||||
} else {
|
||||
$isUpdateDevisThanato = (strcmp($table, 'devis')== 0) && (strcmp($column, 'id_thanato') ==0);
|
||||
if($isUpdateDevisThanato){
|
||||
$this->orderService->createOrUpdateOrderByDevisAndThanato($id, $data);
|
||||
}
|
||||
$facturecourant = json_decode($this->myDb->getOneFacture($id, $this->idNextcloud))[0];
|
||||
if(strcmp($column, 'date_paiement')==0) {
|
||||
$datecourant = $facturecourant->date_paiement;
|
||||
@ -2588,25 +2592,33 @@ class PageController extends Controller {
|
||||
if(empty($thanatoIdsToExport)){
|
||||
return "";
|
||||
}
|
||||
$exportData = $this->myDb->getExportThanatoStatisticData($thanatoIdsToExport);
|
||||
$month = $month ?? date('m');
|
||||
$year = $year ?? date('Y');
|
||||
$exportData = $this->myDb->getExportThanatoStatisticData($thanatoIdsToExport,$month,$year);
|
||||
try{
|
||||
$current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud));
|
||||
$clean_folder = html_entity_decode($current_config[0]->path).'/';
|
||||
$_clean_folder = $clean_folder.'STATISTIQUES/THANATOS/';
|
||||
try {
|
||||
$this->storage->newFolder($_clean_folder);
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$thanatoList = $this->myDb->getThanatoByIds($thanatoIdsToExport);
|
||||
$thanatoFolders = $this->exportThanatoStatisticService->getThanatoStatisticFolders($thanatoList,$year);
|
||||
$fileHeader = $this->exportThanatoStatisticService->getExportThanatoFileHeader();
|
||||
$fileContent = $this->exportThanatoStatisticService->populateExportDataIntoFileContent($exportData,$fileHeader);
|
||||
$filename = $this->exportThanatoStatisticService->getFilename($thanatoIdsToExport);
|
||||
$fileNamePath = $_clean_folder."STAT-THANATOS-" . $filename . '.csv';
|
||||
$this->storage->newFile($fileNamePath);
|
||||
$file = $this->storage->get($fileNamePath);
|
||||
$file->putContent($fileContent);
|
||||
return $fileNamePath;
|
||||
$filename = $this->exportThanatoStatisticService->getFilename($thanatoList,$month,$year);
|
||||
$filenames = [];
|
||||
foreach($thanatoFolders as $thanatoFolder){
|
||||
$fullPath = $clean_folder.$thanatoFolder;
|
||||
try {
|
||||
$this->storage->newFolder($fullPath);
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$fileNamePath = $fullPath."STAT-THANATOS-" . $filename . '.csv';
|
||||
$this->storage->newFile($fileNamePath);
|
||||
$file = $this->storage->get($fileNamePath);
|
||||
$file->putContent($fileContent);
|
||||
$filenames[] = $fileNamePath;
|
||||
}
|
||||
return $filenames;
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
|
||||
@ -4,9 +4,8 @@ namespace OCA\Gestion\Controller;
|
||||
use Exception;
|
||||
use OCA\Gestion\Service\ConfigurationService;
|
||||
use OCA\Gestion\Service\NavigationService;
|
||||
use OCA\Gestion\Service\Order\OrderPdfService;
|
||||
use OCA\Gestion\Service\Order\OrderService;
|
||||
use OCA\Gestion\Service\Provider\ProviderService;
|
||||
use OCA\Gestion\Service\Provider\Statistic\ProviderStatisticService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
defined("TAB1") or define("TAB1", "\t");
|
||||
|
||||
@ -41,6 +40,8 @@ class ProviderController extends Controller {
|
||||
|
||||
private $providerService;
|
||||
|
||||
private $providerStatisticService;
|
||||
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
@ -59,7 +60,8 @@ class ProviderController extends Controller {
|
||||
NavigationService $navigationService,
|
||||
ConfigurationService $configurationService,
|
||||
LoggerInterface $logger,
|
||||
ProviderService $providerService
|
||||
ProviderService $providerService,
|
||||
ProviderStatisticService $providerStatisticService
|
||||
){
|
||||
|
||||
parent::__construct($AppName, $request);
|
||||
@ -73,6 +75,7 @@ class ProviderController extends Controller {
|
||||
$this->configurationService = $configurationService;
|
||||
$this->logger = $logger;
|
||||
$this->providerService = $providerService;
|
||||
$this->providerStatisticService = $providerStatisticService;
|
||||
|
||||
if ($userSession->isLoggedIn()) {
|
||||
$this->user = $userSession->getUser();
|
||||
@ -123,4 +126,18 @@ class ProviderController extends Controller {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function exportProvidersStatistic(array $providerIds,$year){
|
||||
try{
|
||||
$filenames = $this->providerStatisticService->exportProvidersStatisticByYear($providerIds,$year,$this->idNextcloud);
|
||||
return $filenames;
|
||||
}
|
||||
catch(Exception $e){
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,12 +40,15 @@ class Bdd {
|
||||
"fk_defunt_id","fk_lieu_id","fk_client_id","fk_thanato_id",
|
||||
"fk_product_id","ht_price",
|
||||
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
|
||||
"provider_name","provider_last_name","provider_company_name","provider_siret_number","provider_phone","provider_email","provider_address","provider_city","fk_provider_id");
|
||||
"provider_name","provider_last_name","provider_company_name","provider_siret_number","provider_phone","provider_email",
|
||||
"provider_address","provider_city","fk_provider_id",
|
||||
"label","fk_order_id","fk_order_item_id","quantity");
|
||||
$this->whiteTable = array("client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit",
|
||||
"configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis",
|
||||
"bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
|
||||
"orders","thanato_product_discount",
|
||||
"client_group_discount","client_group","provider");
|
||||
"client_group_discount","client_group","provider",
|
||||
"order_product","order_item");
|
||||
$this->tableprefix = '*PREFIX*' ."gestion_";
|
||||
$this->pdo = $db;
|
||||
$this->l = $l;
|
||||
@ -1751,7 +1754,8 @@ class Bdd {
|
||||
$sql = "SELECT
|
||||
thanato.id,
|
||||
thanato.nom as thanato_nom,
|
||||
thanato.prenom as thanato_prenom
|
||||
thanato.prenom as thanato_prenom,
|
||||
thanato.fk_thanato_type_key as fk_thanato_type_key
|
||||
FROM ".$this->tableprefix."thanato as thanato
|
||||
WHERE thanato.id IN ($sqlConditionsPlaceholder)";
|
||||
$thanatoList = $this->execSQLNoJsonReturn(
|
||||
@ -2016,18 +2020,16 @@ class Bdd {
|
||||
$this->calculer_distance_trajet($ligne_trajet->id_trajet, $idNextcloud);
|
||||
}
|
||||
|
||||
public function getExportThanatoStatisticData(array $thanatoIds){
|
||||
$devisList = $this->getDevisListByThanatoIds($thanatoIds);
|
||||
public function getExportThanatoStatisticData(array $thanatoIds,$month,$year){
|
||||
$devisList = $this->getDevisListByThanatoIds($thanatoIds,$month,$year);
|
||||
$devisListGroupedByDateAndThenByThanato = $this->getDevisListGroupedByDateAndThenByThanato($devisList);
|
||||
return $devisListGroupedByDateAndThenByThanato;
|
||||
}
|
||||
|
||||
private function getDevisListByThanatoIds(array $thanatoIds){
|
||||
private function getDevisListByThanatoIds(array $thanatoIds,$month,$year){
|
||||
if(empty($thanatoIds)){
|
||||
return [];
|
||||
}
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count($thanatoIds), '?'));
|
||||
$sql = "SELECT
|
||||
@ -2041,6 +2043,7 @@ class Bdd {
|
||||
devis.id_thanato as id_thanato,
|
||||
thanato.nom as nom_thanato,
|
||||
thanato.prenom as prenom_thanato,
|
||||
thanato.fk_thanato_type_key as fk_thanato_type_key,
|
||||
defunt.nom as nom_defunt,
|
||||
lieu.nom as nom_lieu,
|
||||
lieu.latitude as lieu_latitude,
|
||||
@ -2048,21 +2051,26 @@ class Bdd {
|
||||
client.nom as nom_client,
|
||||
client.entreprise as client_entreprise,
|
||||
client.adresse as client_adresse,
|
||||
facture.num as facture_num
|
||||
facture.num as facture_num,
|
||||
orders.id as order_id,
|
||||
orders.order_full_number,
|
||||
orders.fk_order_status_key,
|
||||
orders.fk_order_type_key
|
||||
FROM ".$this->tableprefix."devis as devis
|
||||
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||
LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
|
||||
LEFT JOIN ".$this->tableprefix."facture as facture on devis.id = facture.id_devis
|
||||
LEFT JOIN ".$this->tableprefix."orders as orders on devis.id = orders.fk_devis_id
|
||||
WHERE YEAR(devis.date) = ? AND
|
||||
MONTH(devis.date) = ? AND
|
||||
devis.id_thanato IN ($sqlConditionsPlaceholder) AND
|
||||
devis.mentions = ?
|
||||
(devis.mentions = ? OR devis.mentions = ?)
|
||||
ORDER BY devis.date ASC;";
|
||||
$devisList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
array_merge([$currentYear, $currentMonth],$thanatoIds,["facturé"]));
|
||||
array_merge([$year, $month],$thanatoIds,[DevisMentionConstant::FACTURED,DevisMentionConstant::FACTURED_FORMATTED]));
|
||||
return $devisList;
|
||||
}
|
||||
|
||||
@ -2082,7 +2090,7 @@ class Bdd {
|
||||
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate] = [
|
||||
'total_distance' => 0,
|
||||
"devis" => [],
|
||||
"devisId" => []
|
||||
"devisId" => [],
|
||||
];
|
||||
}
|
||||
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis;
|
||||
@ -2092,13 +2100,16 @@ class Bdd {
|
||||
}
|
||||
|
||||
private function setDevisProduitsList($devis){
|
||||
$produitsList = $this->getProduitsDevisByDevisId($devis['id']);
|
||||
$produitsList = $this->getDevisProduits($devis['id']);
|
||||
$totalPrice = 0;
|
||||
foreach($produitsList as $produit){
|
||||
if (!isset($devis['produits'])) {
|
||||
$devis['produits'] = [];
|
||||
}
|
||||
$devis['produits'][] = $produit;
|
||||
$totalPrice += $produit['produit_price'];
|
||||
}
|
||||
$devis['total_price'] = $totalPrice;
|
||||
return $devis;
|
||||
}
|
||||
|
||||
@ -2330,6 +2341,30 @@ class Bdd {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDevisProduitsReferences($devisId){
|
||||
$sql = "SELECT
|
||||
produit_devis.id,
|
||||
produit_devis.devis_id,
|
||||
produit_devis.produit_id,
|
||||
produit.reference as produit_reference
|
||||
FROM ".$this->tableprefix ."produit_devis as produit_devis
|
||||
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||
WHERE produit_devis.devis_id = ?;";
|
||||
|
||||
$produitList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$devisId]);
|
||||
|
||||
$produitReferences = [];
|
||||
foreach($produitList as $produit){
|
||||
if($produit["produit_reference"] != null){
|
||||
$produitReferences[] = $produit["produit_reference"];
|
||||
}
|
||||
}
|
||||
$produitReferences = array_unique($produitReferences);
|
||||
return $produitReferences;
|
||||
}
|
||||
|
||||
public function getDevisProduits($devisId){
|
||||
$sql = "SELECT
|
||||
produit_devis.id,
|
||||
@ -2341,10 +2376,13 @@ class Bdd {
|
||||
produit.reference as produit_reference,
|
||||
produit.description as produit_description,
|
||||
produit.vat as produit_vat,
|
||||
devis.id_client as devis_client_id
|
||||
devis.id_client as devis_client_id,
|
||||
thanato.id as fk_thanato_id,
|
||||
thanato.fk_thanato_type_key as fk_thanato_type_key
|
||||
FROM ".$this->tableprefix ."produit_devis as produit_devis
|
||||
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||
LEFT JOIN ".$this->tableprefix."devis as devis on produit_devis.devis_id = devis.id
|
||||
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||
WHERE produit_devis.devis_id = ?;";
|
||||
|
||||
$produitList = $this->execSQLNoJsonReturn(
|
||||
@ -2352,11 +2390,24 @@ class Bdd {
|
||||
[$devisId]);
|
||||
|
||||
if(!empty($produitList)){
|
||||
$clientId = $produitList[0]["devis_client_id"];
|
||||
$client = $this->getClientById($clientId);
|
||||
foreach($produitList as &$produit){
|
||||
$productPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$produit['produit_id']);
|
||||
$produit['produit_price'] = $productPrice ?? $produit['produit_price'];
|
||||
$thanatoTypeKey = $produitList[0]["thanato_type_key"];
|
||||
$thanatoId = $produitList[0]["fk_thanato_id"];
|
||||
$needToApplyThanatoFee = $thanatoTypeKey == ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
if($needToApplyThanatoFee && $thanatoId != null){
|
||||
foreach($produitList as &$produit){
|
||||
$productPrice = $this->getProductPriceByThanatoId($thanatoId,$produit['id']);
|
||||
$productPrice = $productPrice ?? $produit['produit_price'];
|
||||
$produit['produit_price'] = $productPrice * $produit["quantite"];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$clientId = $produitList[0]["devis_client_id"];
|
||||
$client = $this->getClientById($clientId);
|
||||
foreach($produitList as &$produit){
|
||||
$productPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$produit['produit_id']);
|
||||
$productPrice = $productPrice ?? $produit['produit_price'];
|
||||
$produit['produit_price'] = $productPrice * $produit["quantite"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2509,7 +2560,7 @@ class Bdd {
|
||||
}
|
||||
return $invoices;
|
||||
}
|
||||
public function getDevisPdfDataByDevisId($devisId){
|
||||
public function getDevisByDevisId($devisId){
|
||||
$sql = "SELECT
|
||||
devis.id as devis_id,
|
||||
devis.date as devis_date,
|
||||
@ -3008,4 +3059,30 @@ class Bdd {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getProductPriceByThanatoId($thanatoId,$productId){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix ."thanato_product_discount as thanato_product_discount
|
||||
WHERE thanato_product_discount.fk_thanato_id = ? AND
|
||||
thanato_product_discount.fk_product_id = ?;
|
||||
";
|
||||
$thanatoProductDiscount = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$thanatoId,$productId]);
|
||||
if(!empty($thanatoProductDiscount)){
|
||||
return $thanatoProductDiscount[0]['ht_price'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getThanatoByThanatoId($thanatoId){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix."thanato as thanato
|
||||
WHERE thanato.id = ?";
|
||||
$res = $this->execSQLNoJsonReturn($sql,array($thanatoId));
|
||||
if($res){
|
||||
return $res[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
namespace OCA\Gestion\Db;
|
||||
|
||||
use OCA\Gestion\Constants\OrderStatusConstant;
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||
use OCA\Gestion\Helpers\OrderHelpers;
|
||||
use OCP\IDBConnection;
|
||||
@ -96,6 +97,15 @@ class OrderBdd {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getLastOrderProductId(){
|
||||
$sql = "SELECT max(order_product.id) as MAX_ORDER_PRODUCT_ID FROM ".$this->orderTablePrefix."order_product as order_product;";
|
||||
$result = $this->execSQLNoJsonReturn($sql,[]);
|
||||
if(!empty($result)){
|
||||
return $result[0]['MAX_ORDER_PRODUCT_ID'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getOrderByCalendarUuid($calendarUuid){
|
||||
$sql = "SELECT * FROM ".$this->orderTablePrefix."orders as orders
|
||||
WHERE orders.fk_calendar_uuid = ? LIMIT 1";
|
||||
@ -162,6 +172,52 @@ class OrderBdd {
|
||||
|
||||
$this->execSQLNoData($sql,[$statusKey,$orderId]);
|
||||
}
|
||||
|
||||
public function getOrderItemsReferenceByOrderId($orderId){
|
||||
$sql = "SELECT
|
||||
order_item.id as order_item_id,
|
||||
order_product.reference as order_product_reference
|
||||
FROM ".$this->orderTablePrefix."order_item as order_item
|
||||
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
||||
WHERE order_item.fk_order_id = ?
|
||||
GROUP BY order_product.reference;";
|
||||
$itemList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$orderId]);
|
||||
|
||||
$itemReferences = [];
|
||||
foreach($itemList as &$item){
|
||||
if($item['order_product_reference'] != null){
|
||||
$itemReferences[] = $item['order_product_reference'];
|
||||
}
|
||||
}
|
||||
return $itemReferences;
|
||||
}
|
||||
|
||||
public function getOrderItemsByOrderId($orderId){
|
||||
$sql = "SELECT
|
||||
order_item.id as order_item_id,
|
||||
order_item.quantity as order_item_quantity,
|
||||
order_item.fk_order_id as fk_order_id,
|
||||
order_product.id as order_product_id,
|
||||
order_product.reference as order_product_reference,
|
||||
order_product.label as order_product_label,
|
||||
order_product.ht_amount as order_product_ht_amount
|
||||
FROM ".$this->orderTablePrefix."order_item as order_item
|
||||
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
||||
WHERE order_item.fk_order_id = ?;";
|
||||
$itemList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$orderId]);
|
||||
|
||||
$finalItemList = [];
|
||||
foreach($itemList as &$item){
|
||||
if($item['order_product_id'] != null){
|
||||
$finalItemList[] = $item;
|
||||
}
|
||||
}
|
||||
return $finalItemList;
|
||||
}
|
||||
public function getOrderProductsByOrderId($orderId){
|
||||
$sql = "SELECT
|
||||
order_product.id as order_product_id,
|
||||
@ -202,10 +258,12 @@ class OrderBdd {
|
||||
orders.order_number,
|
||||
orders.order_full_number,
|
||||
orders.order_comment,
|
||||
orders.fk_defunt_id,
|
||||
orders.fk_lieu_id,
|
||||
orders.fk_client_id,
|
||||
orders.fk_thanato_id,
|
||||
orders.fk_order_type_key,
|
||||
orders.fk_devis_id,
|
||||
devis.id_defunt as fk_defunt_id,
|
||||
devis.id_lieu as fk_lieu_id,
|
||||
devis.id_client as fk_client_id,
|
||||
devis.id_thanato as fk_thanato_id,
|
||||
orders.fk_order_status_key,
|
||||
orders.fk_provider_id,
|
||||
thanato.id as thanato_id,
|
||||
@ -226,10 +284,11 @@ class OrderBdd {
|
||||
provider.provider_company_name as provider_company_name
|
||||
FROM "
|
||||
.$this->orderTablePrefix."orders as orders
|
||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on orders.fk_thanato_id = thanato.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."client as client on orders.fk_client_id = client.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on orders.fk_defunt_id = defunt.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on orders.fk_lieu_id = lieu.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."devis as devis on orders.fk_devis_id = devis.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."client as client on devis.id_client = client.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
||||
ORDER BY orders.id DESC;
|
||||
@ -251,15 +310,17 @@ class OrderBdd {
|
||||
`order_number`,
|
||||
`order_full_number`,
|
||||
`fk_order_status_key`,
|
||||
`id_nextcloud`
|
||||
`id_nextcloud`,
|
||||
`fk_order_type_key`
|
||||
)
|
||||
VALUES (?,?,?,?,?);";
|
||||
VALUES (?,?,?,?,?,?);";
|
||||
$this->execSQLNoData($sql, array(
|
||||
$currentDate,
|
||||
$currentOrderNumber,
|
||||
$currentOrderFullNumber,
|
||||
OrderStatusConstant::NEW_KEY,
|
||||
$idNextCloud
|
||||
$idNextCloud,
|
||||
OrderTypeConstant::ORDER_TYPE_PURCHASE
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -325,11 +386,9 @@ class OrderBdd {
|
||||
orders.order_number,
|
||||
orders.order_full_number,
|
||||
orders.order_comment,
|
||||
orders.fk_defunt_id,
|
||||
orders.fk_lieu_id,
|
||||
orders.fk_client_id,
|
||||
orders.fk_thanato_id,
|
||||
orders.fk_order_status_key,
|
||||
orders.fk_order_type_key,
|
||||
orders.fk_devis_id,
|
||||
thanato.id as thanato_id,
|
||||
thanato.nom as thanato_nom,
|
||||
thanato.prenom as thanato_prenom,
|
||||
@ -347,14 +406,25 @@ class OrderBdd {
|
||||
lieu.id as lieu_id,
|
||||
lieu.adresse as lieu_adresse,
|
||||
lieu.nom as lieu_nom,
|
||||
order_status.status_label as order_status_label
|
||||
order_status.status_label as order_status_label,
|
||||
provider.provider_name,
|
||||
provider.provider_last_name,
|
||||
provider.provider_company_name,
|
||||
provider.provider_siret_number,
|
||||
provider.provider_phone,
|
||||
provider.provider_email,
|
||||
provider.provider_address,
|
||||
provider.provider_city,
|
||||
devis.date as devis_date
|
||||
FROM "
|
||||
.$this->orderTablePrefix."orders as orders
|
||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on orders.fk_thanato_id = thanato.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."client as client on orders.fk_client_id = client.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on orders.fk_defunt_id = defunt.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on orders.fk_lieu_id = lieu.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."devis as devis on orders.fk_devis_id = devis.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."client as client on devis.id_client = client.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
||||
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
|
||||
WHERE orders.id = ?
|
||||
LIMIT 1;
|
||||
"
|
||||
@ -372,10 +442,10 @@ class OrderBdd {
|
||||
$totalHt = 0;
|
||||
$totalTtc = 0;
|
||||
$totalTvaAmount = 0;
|
||||
$orderProducts = $this->getOrderProductsByOrderId($orderId);
|
||||
foreach($orderProducts as $orderProduct){
|
||||
$totalHt += $orderProduct["produit_ht_price"] * $orderProduct["order_product_quantity"];
|
||||
$totalTvaAmount += $orderProduct["produit_ht_price"] * $tva / 100;
|
||||
$orderItems = $this->getOrderItemsByOrderId($orderId);
|
||||
foreach($orderItems as $orderItem){
|
||||
$totalHt += $orderItem["order_product_ht_amount"] * $orderItem["order_item_quantity"];
|
||||
$totalTvaAmount += $orderItem["order_product_ht_amount"] * $tva / 100;
|
||||
$totalTtc += ($totalHt * ($tva + 100)) / 100;
|
||||
}
|
||||
|
||||
@ -387,4 +457,121 @@ class OrderBdd {
|
||||
];
|
||||
}
|
||||
|
||||
public function createOrderFromDevisIdAndDate(int $devisId,Datetime $devisDate,string $idNextCloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD){
|
||||
$lastOrderNumber = $this->getLastOrderNumber();
|
||||
$currentOrderNumber = $lastOrderNumber + 1;
|
||||
$currentOrderFullNumber = OrderHelpers::GetFullOrderNumberByDateAndOrderNumber($devisDate,$currentOrderNumber);
|
||||
$orderDate = $devisDate->format("Y-m-d");
|
||||
$sql = "INSERT INTO `".$this->orderTablePrefix."orders` (
|
||||
`order_date`,
|
||||
`order_number`,
|
||||
`order_full_number`,
|
||||
`fk_order_status_key`,
|
||||
`id_nextcloud`,
|
||||
`fk_devis_id`,
|
||||
`fk_order_type_key`
|
||||
)
|
||||
VALUES (?,?,?,?,?,?,?);";
|
||||
$this->execSQLNoData($sql, array(
|
||||
$orderDate,
|
||||
$currentOrderNumber,
|
||||
$currentOrderFullNumber,
|
||||
OrderStatusConstant::ORDERED_KEY,
|
||||
$idNextCloud,
|
||||
$devisId,
|
||||
OrderTypeConstant::ORDER_TYPE_DEVIS
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getOrderProducts(){
|
||||
$sql = "SELECT * FROM ".$this->orderTablePrefix."order_product as order_product;";
|
||||
return $this->execSQL($sql,[]);
|
||||
}
|
||||
|
||||
public function createDefaultOrderProduct($idNextCloud){
|
||||
$sql = "INSERT INTO `".$this->orderTablePrefix."order_product` (`reference`,`label`,`ht_amount`,`id_nextcloud`)
|
||||
VALUES ('','',0,?);";
|
||||
$this->execSQLNoData($sql, [$idNextCloud]);
|
||||
}
|
||||
|
||||
public function getOrderProductCount(){
|
||||
$count = 0;
|
||||
$sql = "SELECT COUNT(order_product.id) as order_product_count
|
||||
FROM ".$this->orderTablePrefix."order_product as order_product;";
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql,[]);
|
||||
if(!empty($result)){
|
||||
$count = $result[0]["order_product_count"];
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function addOrderItem($orderId,$orderProductId,$quantity){
|
||||
$sql = "INSERT INTO `".$this->orderTablePrefix."order_item` (`fk_order_id`,`fk_order_item_id`,`quantity`) VALUES (?,?,?);";
|
||||
$this->execSQLNoData($sql, array($orderId,$orderProductId,$quantity));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addDefaultOrderItem($orderId){
|
||||
$lastOrderProductId = $this->getLastOrderProductId();
|
||||
$defaultQuantity = 1;
|
||||
$this->addOrderItem($orderId,$lastOrderProductId,$defaultQuantity);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProviderOrdersByMonthAndYear($providerId,$month,$year){
|
||||
$sql =
|
||||
"SELECT
|
||||
orders.id,
|
||||
orders.order_date,
|
||||
orders.order_number,
|
||||
orders.order_full_number,
|
||||
orders.fk_order_status_key,
|
||||
orders.fk_order_type_key,
|
||||
orders.fk_provider_id
|
||||
FROM ".$this->orderTablePrefix."orders as orders
|
||||
WHERE
|
||||
orders.fk_provider_id = ? AND
|
||||
MONTH(orders.order_date) = ? AND
|
||||
YEAR(orders.order_date) = ? AND
|
||||
orders.fk_order_type_key = ? AND
|
||||
orders.fk_order_status_key != ?
|
||||
ORDER BY orders.order_date ASC;";
|
||||
|
||||
$orders = $this->execSQLNoJsonReturn($sql,[ $providerId,$month,$year,OrderTypeConstant::ORDER_TYPE_PURCHASE,OrderStatusConstant::CANCELED_KEY]);
|
||||
return $orders;
|
||||
}
|
||||
|
||||
public function getItemCountByOrderIdListAndOrderProductId($orderIdsList,$orderProductId){
|
||||
if(empty($orderIdsList)){
|
||||
return 0;
|
||||
}
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count($orderIdsList), '?'));
|
||||
$sql = "SELECT
|
||||
SUM(order_item.quantity) as total_quantity
|
||||
FROM ".$this->orderTablePrefix ."order_item as order_item
|
||||
WHERE order_item.fk_order_id IN ($sqlConditionsPlaceholder) AND
|
||||
order_item.fk_order_item_id = ?;";
|
||||
|
||||
$produitList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
array_merge($orderIdsList,array($orderProductId)));
|
||||
|
||||
if(!empty($produitList)){
|
||||
return $produitList[0]['total_quantity'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getOrderByDevisId($devisId){
|
||||
$sql = "SELECT * FROM ".$this->orderTablePrefix."orders as orders
|
||||
WHERE orders.fk_devis_id = ? LIMIT 1";
|
||||
|
||||
$result = $this->execSQLNoJsonReturn($sql,[$devisId]);
|
||||
if(!empty($result)){
|
||||
return $result[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -71,4 +71,13 @@ class ProviderRepository {
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getProviderById($providerId){
|
||||
$sql = "SELECT * FROM ".$this->gestionTablePrefix."provider as provider WHERE provider.id = ?;";
|
||||
$result = $this->execSQLNoJsonReturn($sql,[$providerId]);
|
||||
if(!empty($result)){
|
||||
return $result[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -107,7 +107,7 @@ class DevisPdfService {
|
||||
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_H2F_ADMIN));
|
||||
$currentConfig = $configs[0];
|
||||
$logo = $this->getLogo();
|
||||
$devisPdfData = $this->gestionBdd->getDevisPdfDataByDevisId($devisId);
|
||||
$devisPdfData = $this->gestionBdd->getDevisByDevisId($devisId);
|
||||
if($devisPdfData == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -26,6 +26,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Service;
|
||||
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -44,11 +46,19 @@ class ExportThanatoStatisticService {
|
||||
$this->gestionBdd = $gestionBdd;
|
||||
}
|
||||
|
||||
public function getFilename(array $thanatoIds){
|
||||
$thanatoList = $this->gestionBdd->getThanatoByIds($thanatoIds);
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
$filename = "$currentYear-$currentMonth-";
|
||||
public function getThanatoStatisticFolders($thanatoList,$year){
|
||||
$thanatoStatFolders = ['STATISTIQUES/THANATOS/'];
|
||||
foreach($thanatoList as $thanato){
|
||||
if($thanato['fk_thanato_type_key'] == ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR){
|
||||
$thanatoStatFolders[] = 'STATISTIQUES/FOURNISSEURS/'.$year.'/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $thanatoStatFolders;
|
||||
}
|
||||
|
||||
public function getFilename(array $thanatoList,$month,$year){
|
||||
$filename = "$year-$month-";
|
||||
foreach($thanatoList as $thanato){
|
||||
$filename .= $thanato['thanato_nom'] . '-' . $thanato['thanato_prenom'] . '--';
|
||||
}
|
||||
@ -71,6 +81,8 @@ class ExportThanatoStatisticService {
|
||||
'LIEU'.';'.
|
||||
'POMPES FUNEBRES'.';'.
|
||||
'ADRESSE'.';'.
|
||||
'BON DE COMMANDE'.';'.
|
||||
'TOTAL ACHAT'.';'.
|
||||
'DISTANCE TOTALE KM'.';'.
|
||||
"\n";
|
||||
return $fileHeader;
|
||||
@ -105,6 +117,8 @@ class ExportThanatoStatisticService {
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
''.';'.
|
||||
utf8_decode(html_entity_decode("$distance"))."\n";
|
||||
return $fileContent;
|
||||
}
|
||||
@ -121,6 +135,15 @@ class ExportThanatoStatisticService {
|
||||
|
||||
private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){
|
||||
$produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]);
|
||||
$orderFullNumber = "";
|
||||
$totalOrderPrice = "";
|
||||
$isDevisDoneBySubContractor = $devis['fk_order_type_key'] == OrderTypeConstant::ORDER_TYPE_DEVIS &&
|
||||
$devis['order_id'] != null && $devis["fk_thanato_type_key"] == ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
|
||||
if($isDevisDoneBySubContractor){
|
||||
$orderFullNumber = $devis["order_full_number"];
|
||||
$totalOrderPrice = $devis["total_price"];
|
||||
}
|
||||
$fileContent = $fileContent.
|
||||
FileExportHelpers::FormatTextForExport($devis["facture_num"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho']).';'.
|
||||
@ -132,7 +155,10 @@ class ExportThanatoStatisticService {
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_defunt"]).';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_lieu"] ?? "").';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["nom_client"] ?? "").';'.
|
||||
FileExportHelpers::FormatTextForExport($devis["client_adresse"] ?? "")."\n";
|
||||
FileExportHelpers::FormatTextForExport($devis["client_adresse"] ?? "").';'.
|
||||
FileExportHelpers::FormatTextForExport($orderFullNumber).';'.
|
||||
"$totalOrderPrice".';'.
|
||||
''.';'."\n";
|
||||
|
||||
return $fileContent;
|
||||
|
||||
|
||||
@ -142,52 +142,13 @@ class GestionService {
|
||||
|
||||
private function GetCalendarDateFromVCalendarString(string $vCalendarString){
|
||||
$calendarStartDate = VCalendarHelpers::GetDateStartOrDateEndFromVCalendarString('DTSTART',$vCalendarString);
|
||||
$calendarStartDate = $calendarStartDate->format('Y-m-d');
|
||||
return $calendarStartDate;
|
||||
}
|
||||
|
||||
private function IsOrderAlreadyCreated($calendarUuid){
|
||||
$order = $this->orderBdd->getOrderByCalendarUuid($calendarUuid);
|
||||
return $order != null;
|
||||
}
|
||||
|
||||
private function CreateOrderFromVCalendarString($vCalendarString,$thanatoId){
|
||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||
$orderAlreadyCreated = $this->IsOrderAlreadyCreated($calendarUuid);
|
||||
if($orderAlreadyCreated){
|
||||
return;
|
||||
}
|
||||
$nextcloudUser = $this->GetThanatoNameFromVCalendarString($vCalendarString);
|
||||
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
|
||||
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
|
||||
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
|
||||
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
||||
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
||||
$orderId = $this->orderBdd->insertOrderFromVCalendarPropertyAndReturnId(
|
||||
$thanatoId,
|
||||
$clientId,
|
||||
$locationId,
|
||||
$defuntId,
|
||||
$calendarUuid,
|
||||
$calendarStartDate,
|
||||
$nextcloudUser);
|
||||
$productsValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
||||
if(!empty($productsValue)){
|
||||
$productIds = $this->gestionBdd->getArticleIdsByArticleReferences($productsValue);
|
||||
$this->orderBdd->insertOrderProductsByProductIds($orderId, $productIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function HandleCreatedCalendarObject(string $vCalendarString){
|
||||
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
||||
if($thanato != null){
|
||||
$thanatoId = $thanato["id"];
|
||||
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
if($thanatoIsSubcontractor){
|
||||
$this->CreateOrderFromVCalendarString($vCalendarString,$thanatoId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$thanatoId = 0;
|
||||
@ -203,7 +164,12 @@ class GestionService {
|
||||
}
|
||||
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
||||
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
||||
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$calendarStartDate,$userName);
|
||||
$devisDate = $calendarStartDate->format('Y-m-d');
|
||||
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$devisDate,$userName);
|
||||
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
if($thanatoIsSubcontractor){
|
||||
$this->orderBdd->createOrderFromDevisIdAndDate($devisId,$calendarStartDate,$userName);
|
||||
}
|
||||
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
||||
if(!empty($articlesValue)){
|
||||
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
|
||||
|
||||
@ -72,6 +72,7 @@ class MenuStatisticService {
|
||||
$res['clientGroup'] = json_decode($this->gestionBdd->getClientGroupCount())[0]->c;
|
||||
$res['clientGroupDiscount'] = json_decode($this->gestionBdd->getClientGroupDiscountCount())[0]->c;
|
||||
$res['clientGroupFacturation'] = json_decode($this->gestionBdd->getClientGroupFacturationCount())[0]->c;
|
||||
$res['orderProduct'] = $this->orderBdd->getOrderProductCount();
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ class NavigationService {
|
||||
"clientGroupDiscount" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupDiscount"),
|
||||
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
|
||||
"provider" => $this->urlGenerator->linkToRouteAbsolute("gestion.provider.provider"),
|
||||
"orderProduct" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.orderProduct"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ namespace OCA\Gestion\Service\Order;
|
||||
|
||||
use DateTime;
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Db\OrderBdd;
|
||||
use OCA\Gestion\Helpers\DateHelpers;
|
||||
@ -80,28 +81,52 @@ class OrderPdfService {
|
||||
$orderDate = DateTime::createFromFormat('Y-m-d',$orderDate);
|
||||
$orderDate = $orderDate->format('d-m-Y');
|
||||
$orderPdfData['order_date'] = $orderDate;
|
||||
$devisDate = $orderPdfData['devis_date'];
|
||||
$devisDate = DateTime::createFromFormat('Y-m-d',$devisDate);
|
||||
$devisDate = $devisDate->format('d-m-Y');
|
||||
$orderPdfData['devis_date'] = $devisDate;
|
||||
return $orderPdfData;
|
||||
}
|
||||
|
||||
private function getCommandeFolders($orderPdfData,$racinePath){
|
||||
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($orderPdfData["client_entreprise"],'UTF-8').'/';
|
||||
$defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($orderPdfData['defunt_nom'],'UTF-8').'/'.'FOURNISSEUR'.'/';
|
||||
$orderDate = $orderPdfData['order_date'];
|
||||
$orderDatetime = new DateTime($orderDate);
|
||||
$orderYear = $orderDatetime->format('Y');
|
||||
$orderMonth = DateHelpers::GetDateWithFormatDayAndMonthPlainString($orderPdfData['order_date']);
|
||||
$orderByYearFolder = $clientRacineFolder."$orderYear".'/'.$orderMonth.'/'.'FOURNISSEUR'.'/';
|
||||
return [
|
||||
$defuntsFolder,
|
||||
$orderByYearFolder
|
||||
];
|
||||
if($orderPdfData["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($orderPdfData["client_entreprise"],'UTF-8').'/';
|
||||
$defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($orderPdfData['defunt_nom'],'UTF-8').'/'.'FOURNISSEUR'.'/';
|
||||
$orderDate = $orderPdfData['order_date'];
|
||||
$orderDatetime = new DateTime($orderDate);
|
||||
$orderYear = $orderDatetime->format('Y');
|
||||
$orderMonth = DateHelpers::GetDateWithFormatDayAndMonthPlainString($orderPdfData['order_date']);
|
||||
$orderByYearFolder = $clientRacineFolder."$orderYear".'/'.$orderMonth.'/'.'FOURNISSEUR'.'/';
|
||||
return [
|
||||
$defuntsFolder,
|
||||
$orderByYearFolder
|
||||
];
|
||||
}
|
||||
else{
|
||||
$providerRacineFolder = $racinePath.'FOURNISSEURS/'.mb_strtoupper($orderPdfData["provider_name"],'UTF-8').'/';
|
||||
$orderDate = $orderPdfData['order_date'];
|
||||
$orderDatetime = new DateTime($orderDate);
|
||||
$orderYear = $orderDatetime->format('Y');
|
||||
$orderMonth = DateHelpers::GetDateWithFormatDayAndMonthPlainString($orderPdfData['order_date']);
|
||||
$orderByYearFolder = $providerRacineFolder."$orderYear".'/'.$orderMonth.'/';
|
||||
return [
|
||||
$orderByYearFolder
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
private function GetOrderFilename($orderPdfData){
|
||||
$orderFullNumber = $orderPdfData['order_full_number'];
|
||||
$orderFullNumber = str_replace('/','-',$orderFullNumber);
|
||||
$defuntNom = str_replace(' ',' ',$orderPdfData['defunt_nom']);
|
||||
return "BDC".'_'.$orderFullNumber.'_'.mb_strtoupper($defuntNom,'UTF-8');
|
||||
$filename = "BDC_".$orderFullNumber."_";
|
||||
if($orderPdfData["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||
$defuntNom = str_replace(' ',' ',$orderPdfData['defunt_nom']);
|
||||
$filename .= mb_strtoupper($defuntNom,'UTF-8');
|
||||
}
|
||||
else{
|
||||
$filename .= mb_strtoupper($orderPdfData['provider_name'],'UTF-8');
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
||||
public function generateOrderPdfByOrderId($orderId,$idNextCloud){
|
||||
|
||||
@ -26,6 +26,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Gestion\Service\Order;
|
||||
|
||||
use DateTime;
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Constants\OrderPdfConstant;
|
||||
use OCA\Gestion\Constants\OrderStatusConstant;
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Db\OrderBdd;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -33,30 +40,40 @@ use Psr\Log\LoggerInterface;
|
||||
class OrderService {
|
||||
/** @var \OCA\Gestion\Db\OrderBdd */
|
||||
private $orderBdd;
|
||||
private $gestionBdd;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(
|
||||
OrderBdd $orderBdd,
|
||||
LoggerInterface $logger) {
|
||||
LoggerInterface $logger,
|
||||
Bdd $gestionBdd) {
|
||||
$this->logger = $logger;
|
||||
$this->orderBdd = $orderBdd;
|
||||
$this->gestionBdd = $gestionBdd;
|
||||
}
|
||||
|
||||
public function getOrdersWithDetailsAsArray(){
|
||||
$orders = $this->orderBdd->getOrdersWithDetails();
|
||||
foreach($orders as &$order){
|
||||
$currentOrderProductsReferenceAsString = "";
|
||||
$currentOrderProductsReferences = [];
|
||||
$currentOrderProducts = $this->orderBdd->getOrderProductsByOrderId($order['id']);
|
||||
foreach($currentOrderProducts as $currentProduct){
|
||||
$currentOrderProductsReferences[] = $currentProduct["produit_reference"];
|
||||
if($order["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||
if($order["fk_devis_id"] != null){
|
||||
$produitReferences = $this->gestionBdd->getDevisProduitsReferences($order["fk_devis_id"]);
|
||||
}
|
||||
if(!empty($produitReferences)){
|
||||
$currentOrderProductsReferenceAsString = implode('-',$produitReferences);
|
||||
}
|
||||
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
||||
}
|
||||
if(!empty($currentOrderProductsReferences)){
|
||||
$currentOrderProductsReferenceAsString = implode('-',$currentOrderProductsReferences);
|
||||
else{
|
||||
$orderItemReferences = $this->orderBdd->getOrderItemsReferenceByOrderId($order['id']);
|
||||
if(!empty($orderItemReferences)){
|
||||
$currentOrderProductsReferenceAsString = implode('-',$orderItemReferences);
|
||||
}
|
||||
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
||||
}
|
||||
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
||||
}
|
||||
return $orders;
|
||||
}
|
||||
@ -93,6 +110,10 @@ class OrderService {
|
||||
return $this->orderBdd->getOrderProductsByOrderId($orderId);
|
||||
}
|
||||
|
||||
public function getOrderItemsByOrderId($orderId){
|
||||
return $this->orderBdd->getOrderItemsByOrderId($orderId);
|
||||
}
|
||||
|
||||
public function getOrderTotalAmount($orderId,$tva){
|
||||
return $this->orderBdd->getOrderTotalAmount($orderId,$tva);
|
||||
}
|
||||
@ -102,11 +123,79 @@ class OrderService {
|
||||
if($orderDetails == null){
|
||||
return null;
|
||||
}
|
||||
$orderProducts = $this->orderBdd->getOrderProductsByOrderId($orderId);
|
||||
$orderProducts = [];
|
||||
if($orderDetails["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||
$orderProducts = $this->gestionBdd->getDevisProduits($orderDetails["fk_devis_id"]);
|
||||
$clientAdresses = FileExportHelpers::GetAddressAndCityFromAddress($orderDetails["client_adresse"]);
|
||||
$orderDetails["client_real_adress"] = $clientAdresses["address"];
|
||||
$orderDetails["client_adress_city"] = $clientAdresses["city"];
|
||||
$orderDetails["type"] = OrderPdfConstant::SUBCONTRACTOR_TYPE;
|
||||
$orderDetails["defunt_name_with_sexe"] = FileExportHelpers::GetSexeLabel($orderDetails['defunt_sexe']) . ' '. $orderDetails["defunt_nom"];
|
||||
}
|
||||
else{
|
||||
$orderItems = $this->orderBdd->getOrderItemsByOrderId($orderId);
|
||||
foreach($orderItems as $orderItem){
|
||||
$orderProducts[] = [
|
||||
"produit_id" => $orderItem["order_product_id"],
|
||||
"quantite" => $orderItem["order_item_quantity"],
|
||||
"produit_price" => $orderItem["order_product_ht_amount"],
|
||||
"produit_reference" => $orderItem["order_product_reference"],
|
||||
"description" => $orderItem["order_product_label"],
|
||||
];
|
||||
}
|
||||
$orderDetails["client_real_adress"] = $orderDetails["provider_address"];
|
||||
$orderDetails["client_adress_city"] = $orderDetails["provider_city"];
|
||||
$orderDetails["client_legal_one"] = $orderDetails["provider_siret_number"];;
|
||||
$orderDetails["client_mail"] = $orderDetails["provider_email"];
|
||||
$orderDetails["type"] = OrderPdfConstant::PROVIDER_TYPE;
|
||||
$orderDetails["devis_date"] = $orderDetails["order_date"];
|
||||
}
|
||||
$orderDetails["products"] = $orderProducts;
|
||||
$clientAdresses = FileExportHelpers::GetAddressAndCityFromAddress($orderDetails["client_adresse"]);
|
||||
$orderDetails["client_real_adress"] = $clientAdresses["address"];
|
||||
$orderDetails["client_adress_city"] = $clientAdresses["city"];
|
||||
|
||||
return $orderDetails;
|
||||
}
|
||||
|
||||
public function createOrderFromDevisIdAndDate(int $devisId,Datetime $devisDate,string $idNextCloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD ){
|
||||
$this->orderBdd->createOrderFromDevisIdAndDate($devisId,$devisDate,$idNextCloud);
|
||||
}
|
||||
|
||||
public function getOrderProducts(){
|
||||
return $this->orderBdd->getOrderProducts();
|
||||
}
|
||||
|
||||
public function createDefaultOrderProduct($idNextCloud){
|
||||
$this->orderBdd->createDefaultOrderProduct($idNextCloud);
|
||||
}
|
||||
|
||||
public function addDefaultOrderItem($orderId){
|
||||
$this->orderBdd->addDefaultOrderItem($orderId);
|
||||
}
|
||||
|
||||
public function createOrUpdateOrderByDevisAndThanato($devisId,$thanatoId){
|
||||
$thanato = $this->gestionBdd->getThanatoByThanatoId($thanatoId);
|
||||
if($thanato == null){
|
||||
return null;
|
||||
}
|
||||
$thanatoIsSubContractor = $thanato['fk_thanato_type_key'] == ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
$devis = $this->gestionBdd->getDevisByDevisId($devisId);
|
||||
if($devis == null){
|
||||
return null;
|
||||
}
|
||||
$devisOrder = $this->orderBdd->getOrderByDevisId($devisId);
|
||||
$thereIsAnOrderRelatedToThisDevis = $devisOrder != null && $devisOrder["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS;
|
||||
if($thereIsAnOrderRelatedToThisDevis){
|
||||
$orderStatusForUpdate = OrderStatusConstant::ORDERED_KEY;
|
||||
if(!$thanatoIsSubContractor){
|
||||
$orderStatusForUpdate = OrderStatusConstant::CANCELED_KEY;
|
||||
}
|
||||
$this->orderBdd->updateOrderStatus($devisOrder['id'],$orderStatusForUpdate);
|
||||
}
|
||||
else{
|
||||
if($thanatoIsSubContractor){
|
||||
$devisDate = new DateTime($devis['devis_date']);
|
||||
$this->createOrderFromDevisIdAndDate((int)$devisId,$devisDate);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ namespace OCA\Gestion\Service\Order\PdfHandler;
|
||||
|
||||
use DateTime;
|
||||
use \FPDF;
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use OCA\Gestion\Helpers\PriceHelpers;
|
||||
|
||||
@ -70,7 +71,7 @@ class OrderPdfHandler extends FPDF {
|
||||
$this->SetFont('Arial', '', 12);
|
||||
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->orderData['configuration']->entreprise), 0, 0);
|
||||
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport(
|
||||
self::DEFAULT_SUBCONTRACTOR_NAME),
|
||||
$this->orderData['type']),
|
||||
0, 1,'R');
|
||||
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->orderData['configuration_adresse']), 0, 0);
|
||||
$this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->orderData['client_real_adress'])), 0, 1,'R');
|
||||
@ -93,9 +94,9 @@ class OrderPdfHandler extends FPDF {
|
||||
|
||||
$this->SetFont('Arial', '', 10);
|
||||
$this->Cell(45, 7, $this->orderData["order_date"], 1, 0, 'C');
|
||||
$this->Cell(65, 7, utf8_decode(html_entity_decode($this->orderData['lieu_nom'])), 1, 0, 'C');
|
||||
$this->Cell(65, 7, FileExportHelpers::FormatTextForExport($this->orderData['lieu_nom'] ?? ""), 1, 0, 'C');
|
||||
$this->Cell(40, 7, $this->orderData['order_full_number'], 1, 0, 'C');
|
||||
$this->Cell(40, 7, $this->orderData["order_date"], 1, 1, 'C');
|
||||
$this->Cell(40, 7, $this->orderData["devis_date"], 1, 1, 'C');
|
||||
|
||||
$this->Ln(4);
|
||||
}
|
||||
@ -141,22 +142,22 @@ class OrderPdfHandler extends FPDF {
|
||||
$products = $this->orderData["products"];
|
||||
$yValue = 116;
|
||||
foreach($products as $product){
|
||||
$valueHt = $product['produit_ht_price'];
|
||||
$valueHt = $product['produit_price'] * $product['quantite'];
|
||||
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue);
|
||||
$totalHt+=$valueHt;
|
||||
$totalTtc+=$valueTtc;
|
||||
$productDescription = $product["produit_description"];
|
||||
$productDescription = $product["produit_reference"];
|
||||
$dateValue = "";
|
||||
if($product === end($products)){
|
||||
if($product === end($products) && $this->orderData["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||
$dateValue = $this->orderData["order_date"];
|
||||
$productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->orderData['defunt_sexe']) . ' '. $this->orderData["defunt_nom"];
|
||||
$productDescription .= " de " . $this->orderData["defunt_name_with_sexe"];
|
||||
}
|
||||
$tvaAmount = $valueTtc - $valueHt;
|
||||
$this->SetXY( 10,$yValue );
|
||||
$this->Cell(20, 6, $dateValue, 0,0);
|
||||
|
||||
$this->SetXY( 35,$yValue );
|
||||
$this->MultiAlignCell(100, 6, utf8_decode(html_entity_decode($productDescription)),0,'0',);
|
||||
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($productDescription),0);
|
||||
|
||||
$this->SetXY( 135,$yValue );
|
||||
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
|
||||
|
||||
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Gestion\Service\Provider\Statistic;
|
||||
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Db\OrderBdd;
|
||||
use OCA\Gestion\Db\ProviderRepository;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use OCP\Files\IRootFolder;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ProviderStatisticService {
|
||||
private $providerRepository;
|
||||
|
||||
private $providerStatisticService;
|
||||
|
||||
private $orderRepository;
|
||||
private $gestionRepository;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var \OCP\Files\IRootFolder */
|
||||
private $rootFolder;
|
||||
|
||||
public function __construct(
|
||||
ProviderRepository $providerRepository,
|
||||
LoggerInterface $logger,
|
||||
OrderBdd $orderBdd,
|
||||
Bdd $gestionRepository,
|
||||
IRootFolder $rootFolder) {
|
||||
$this->logger = $logger;
|
||||
$this->providerRepository = $providerRepository;
|
||||
$this->orderRepository = $orderBdd;
|
||||
$this->gestionRepository = $gestionRepository;
|
||||
$this->rootFolder = $rootFolder;
|
||||
}
|
||||
|
||||
private function getProviderOrdersStatisticDataByYear($providerId,$year,$orderProducts){
|
||||
$monthLists = range(1,12);
|
||||
$data = [];
|
||||
$provider = $this->providerRepository->getProviderById($providerId);
|
||||
if($provider == null){
|
||||
return [];
|
||||
}
|
||||
foreach($monthLists as $monthValue){
|
||||
if(!isset($data[$monthValue])){
|
||||
$data[$monthValue] = [];
|
||||
}
|
||||
$providerOrders = $this->orderRepository->getProviderOrdersByMonthAndYear($providerId,$monthValue,$year);
|
||||
$providerOrderIds = [];
|
||||
$statisticForeachProductPerMonth = [];
|
||||
foreach($providerOrders as $currentOrder){
|
||||
$providerOrderIds[] = $currentOrder['id'];
|
||||
}
|
||||
$productTotalPrices = 0;
|
||||
foreach($orderProducts as $currentProduct){
|
||||
if(!isset($statisticForeachProductPerMonth[$currentProduct->id])){
|
||||
$statisticForeachProductPerMonth[$currentProduct->id] = 0;
|
||||
}
|
||||
$productTotalCount = $this->orderRepository->getItemCountByOrderIdListAndOrderProductId($providerOrderIds,$currentProduct->id);
|
||||
$totalWithoutVat = $productTotalCount * $currentProduct->ht_amount;
|
||||
$statisticForeachProductPerMonth[$currentProduct->id] += $productTotalCount;
|
||||
$productTotalPrices += $totalWithoutVat;
|
||||
}
|
||||
$data[$monthValue] = [
|
||||
'products' => $statisticForeachProductPerMonth,
|
||||
'year' => $year,
|
||||
'total_price' => $productTotalPrices,
|
||||
'provider_name' => $provider['provider_name']
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getExportProviderStatisticFileHeader(array $orderProducts){
|
||||
$fileHeader =
|
||||
'FOURNISSEUR'.';'.
|
||||
'MOIS'.';'.
|
||||
'ANNEE'.';';
|
||||
|
||||
foreach($orderProducts as $currentProduct){
|
||||
$fileHeader .= FileExportHelpers::FormatTextForExport($currentProduct->reference).';';
|
||||
}
|
||||
$fileHeader .= 'TOTAL HT'.';'."\n";
|
||||
return $fileHeader;
|
||||
}
|
||||
|
||||
private function exportProviderStatisticData($providerStatisticData,$orderProducts,$idNextCloud){
|
||||
if(empty($providerStatisticData)){
|
||||
return null;
|
||||
}
|
||||
$defaultConfig = $this->gestionRepository->getConfigurationByIdNextcloud(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||
$racineFolder = html_entity_decode($defaultConfig['path']).'/';
|
||||
$statFolder = $racineFolder.'STATISTIQUES/FOURNISSEURS/'.$providerStatisticData[1]['year'].'/';
|
||||
$storage = $this->rootFolder->getUserFolder($idNextCloud);
|
||||
try {
|
||||
$storage->newFolder($statFolder);
|
||||
}
|
||||
catch(\OCP\Files\NotPermittedException $e) {
|
||||
|
||||
}
|
||||
$fileContent = $this->getExportProviderStatisticFileHeader($orderProducts);
|
||||
$fileContent = $this->populateProviderStatisticDataIntoFileContent($providerStatisticData,$fileContent);
|
||||
$filename = $providerStatisticData[1]['year'].'-'.$providerStatisticData[1]['provider_name'];
|
||||
$filenamePath = $statFolder."STAT-FOURNISSEUR-".$filename.'.csv';
|
||||
$storage->newFile($filenamePath);
|
||||
$file = $storage->get($filenamePath);
|
||||
$file->putContent($fileContent);
|
||||
return $filenamePath;
|
||||
}
|
||||
|
||||
private function populateProviderStatisticDataIntoFileContent(array $providerStatisticData,$fileContent){
|
||||
foreach($providerStatisticData as $monthValue => $currentMonthData){
|
||||
$fileContent .= FileExportHelpers::FormatTextForExport($currentMonthData['provider_name']).';';
|
||||
$fileContent .= $monthValue.';';
|
||||
$fileContent .= $currentMonthData['year'].';';
|
||||
foreach($currentMonthData['products'] as $currentProduct){
|
||||
$fileContent .= $currentProduct.';';
|
||||
}
|
||||
$totalPrice = $currentMonthData['total_price'];
|
||||
$fileContent .= "$totalPrice".";"."\n";
|
||||
}
|
||||
return $fileContent;
|
||||
}
|
||||
|
||||
|
||||
public function exportProvidersStatisticByYear($providerIds,$year,$idNextCloud){
|
||||
$year = $year ?? date('Y');
|
||||
$filenames = [];
|
||||
$orderProducts = $this->orderRepository->getOrderProducts();
|
||||
$orderProducts = json_decode($orderProducts);
|
||||
foreach($providerIds as $providerId){
|
||||
$providerOrdersPerMonthInAYear = $this->getProviderOrdersStatisticDataByYear($providerId,$year,$orderProducts);
|
||||
$filename = $this->exportProviderStatisticData($providerOrdersPerMonthInAYear,$orderProducts,$idNextCloud);
|
||||
if($filename != null){
|
||||
$filenames[] = $filename;
|
||||
}
|
||||
}
|
||||
return $filenames;
|
||||
}
|
||||
}
|
||||
@ -25,9 +25,17 @@ CREATE TABLE IF NOT EXISTS oc_gestion_orders(
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS oc_gestion_order_product(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
reference VARCHAR(255) DEFAULT '',
|
||||
label VARCHAR(255) DEFAULT '',
|
||||
ht_amount FLOAT NOT NULL DEFAULT 0,
|
||||
id_nextcloud VARCHAR(100)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS oc_gestion_order_item(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_order_id INT NOT NULL,
|
||||
fk_product_id INT NOT NULL,
|
||||
fk_order_item_id INT NOT NULL,
|
||||
quantity INT NOT NULL,
|
||||
id_nextcloud VARCHAR(100)
|
||||
);
|
||||
|
||||
14
gestion/lib/Sql/20250221-ORDER_RELATED_TO_DEVIS.sql
Normal file
14
gestion/lib/Sql/20250221-ORDER_RELATED_TO_DEVIS.sql
Normal file
@ -0,0 +1,14 @@
|
||||
create table oc_gestion_order_type (
|
||||
order_type_key VARCHAR(255) PRIMARY KEY NOT NULL,
|
||||
order_type_label VARCHAR(255) DEFAULT ''
|
||||
);
|
||||
|
||||
insert into oc_gestion_order_type(order_type_key,order_type_label) VALUES
|
||||
('DEVIS','Devis commande'),
|
||||
('PURCHASE','Achat de produit');
|
||||
|
||||
alter table oc_gestion_orders
|
||||
add column fk_order_type_key VARCHAR(255) NOT NULL DEFAULT 'DEVIS';
|
||||
|
||||
alter table oc_gestion_orders
|
||||
add column fk_devis_id INT DEFAULT NULL;
|
||||
2
gestion/src/js/constants/orderTypeConstant.js
Normal file
2
gestion/src/js/constants/orderTypeConstant.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const OrderTypeDevis = "DEVIS";
|
||||
export const OrderTypePurchase = "PURCHASE";
|
||||
@ -21,6 +21,7 @@ import { ClientGroup } from '../objects/clientGroup.mjs';
|
||||
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
|
||||
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
|
||||
import { Provider } from "../objects/provider.mjs";
|
||||
import { OrderProduct } from "../objects/orderProduct.mjs";
|
||||
var choose_folder = t('gestion', 'Choose work folder');
|
||||
|
||||
$('body').on('click', '#theFolder', function () {
|
||||
@ -260,6 +261,8 @@ $('body').on('click', '.deleteItem', function () {
|
||||
if (modifier === "clientGroupDiscount") { ClientGroupDiscount.loadClientGroupDiscountDatatable(dt); }
|
||||
if (modifier === "clientGroupFacturation") { ClientGroupFacturation.loadClientGroupFacturationDatatable(dt); }
|
||||
if (modifier === "provider") { Provider.loadProviderDatatable(dt); }
|
||||
if (modifier === "orderProduct") { OrderProduct.loadOrderProductDatatable(dt); }
|
||||
|
||||
});
|
||||
|
||||
$('body').on('change', '.listClient,.listDevis', function () {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import DataTable from "datatables.net";
|
||||
import { Order } from "../objects/order.mjs";
|
||||
import { updateOrderDate } from "../modules/order/orderAjaxRequest.mjs";
|
||||
import { getOrderItemsByOrderId, loadOrderProductIntoSelect, updateOrderDate } from "../modules/order/orderAjaxRequest.mjs";
|
||||
import { Thanatopracteur } from "../objects/thanatopracteur.mjs";
|
||||
import { ThanatoSubcontractorTypeKey } from "../constants/thanatoTypeConstant";
|
||||
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
|
||||
import { showError, showSuccess } from "@nextcloud/dialogs";
|
||||
import { OrderProduct } from "../objects/orderProduct.mjs";
|
||||
import { updateDB } from "../modules/ajaxRequest.mjs";
|
||||
|
||||
$('body').on('change', '.orderInputDate', function () {
|
||||
var dt = new DataTable('.tabledt');
|
||||
@ -23,6 +25,10 @@ document.body.addEventListener('click', e => {
|
||||
Order.createDefaultOrder(new DataTable('.tabledt'));
|
||||
return;
|
||||
}
|
||||
if("createDefaultOrderProduct"=== e.target.id){
|
||||
OrderProduct.createDefaultOrderProduct(new DataTable('.tabledt'));
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('click', '#exportOrderToPdf', function () {
|
||||
@ -51,3 +57,41 @@ $('body').on('click', '#exportOrderToPdf', function () {
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('body').on('click', '#addOrderItems', function () {
|
||||
var orderId = $('#orderId').data('id');
|
||||
$.ajax({
|
||||
url: baseUrl + '/order/'+orderId+'/addItems',
|
||||
type: 'POST',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response) {
|
||||
getOrderItemsByOrderId(orderId);
|
||||
}).fail(function (response, code) {
|
||||
showError(t('gestion', "Please create a new product"));
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('dblclick', '.selectableOrderItem', function () {
|
||||
var orderItemId = $(this).data('order-item-id');
|
||||
var orderProductId = $(this).data('data-order-product-id');
|
||||
var orderId = $(this).data('order-id');
|
||||
$(this).text("");
|
||||
$(this).html('<select id="orderProductList">');
|
||||
loadOrderProductIntoSelect($('#orderProductList'), orderItemId, orderProductId,orderId);
|
||||
});
|
||||
|
||||
$('body').on('change', '#orderProductList', function () {
|
||||
var orderItemId = $(this).find(':selected').data('id')
|
||||
var orderId = $(this).find(':selected').data('order-id')
|
||||
var orderProductId = $(this).find(':selected').data('val')
|
||||
var column = $(this).find(':selected').data('column')
|
||||
var table = $(this).find(':selected').data('table')
|
||||
var el = $(this).parent();
|
||||
|
||||
updateDB(table, column, orderProductId, orderItemId);
|
||||
getOrderItemsByOrderId(orderId);
|
||||
|
||||
el.text($(this).val());
|
||||
el.attr('data-val', orderProductId);
|
||||
|
||||
});
|
||||
@ -3,6 +3,12 @@ import { Provider } from "../objects/provider.mjs";
|
||||
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
|
||||
import { showError, showSuccess } from "@nextcloud/dialogs";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const today = new Date();
|
||||
const currentYear = today.getFullYear();
|
||||
this.document.getElementById("yearSelect").value = currentYear;
|
||||
});
|
||||
document.body.addEventListener('click', e => {
|
||||
if(e.target.className.includes("selectProviders")){
|
||||
Provider.loadProvidersIntoSelect(e);
|
||||
@ -13,3 +19,69 @@ document.body.addEventListener('click', e => {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('click', '#showExportProviderStatModal', function () {
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".providerToExport:checked", {"page": "all"});
|
||||
let providerIdsToExport = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
providerIdsToExport.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(providerIdsToExport.length == 0){
|
||||
showError(t('gestion', "Veuillez choisir au moins une ligne de fournisseur"));
|
||||
return;
|
||||
}
|
||||
$('#exportProviderStatModal').show();
|
||||
});
|
||||
|
||||
$('body').on('click', '#closeProviderStatModal', function () {
|
||||
$('#exportProviderStatModal').hide();
|
||||
});
|
||||
|
||||
$('body').on('click', '#exportProviderStat', function () {
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".providerToExport:checked", {"page": "all"});
|
||||
let providerIdsToExport = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
providerIdsToExport.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(providerIdsToExport.length == 0){
|
||||
$('#exportProviderStatModal').hide();
|
||||
showError(t('gestion', "Veuillez choisir au moins une ligne de fournisseur"));
|
||||
return;
|
||||
}
|
||||
|
||||
var today = new Date();
|
||||
var yearValue = document.getElementById("yearSelect").value ?? today.getFullYear();
|
||||
let exportProviderPayload = {
|
||||
providerIds: providerIdsToExport,
|
||||
year: yearValue
|
||||
}
|
||||
|
||||
showLoader();
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/provider/exportStat',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(exportProviderPayload)
|
||||
}).done(function (response) {
|
||||
if(response.length == 0){
|
||||
showError(t('gestion', "Erreur lors de l'exportation de statistique"));
|
||||
}
|
||||
else{
|
||||
$('#exportProviderStatModal').hide();
|
||||
let datatable = new DataTable('.tabledt');
|
||||
Provider.loadProviderDatatable(datatable);
|
||||
response.forEach(fileName => {
|
||||
showSuccess('Sauvegardé dans' + fileName);
|
||||
});
|
||||
}
|
||||
}).always(function () {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
|
||||
81
gestion/src/js/listener/thanatoListener.js
Normal file
81
gestion/src/js/listener/thanatoListener.js
Normal file
@ -0,0 +1,81 @@
|
||||
import {showError, showSuccess } from "@nextcloud/dialogs";
|
||||
import {baseUrl,showLoader,hideLoader} from "../modules/mainFunction.mjs";
|
||||
import { Devis } from "../objects/devis.mjs";
|
||||
import DataTable from "datatables.net";
|
||||
import { Thanatopracteur } from "../objects/thanatopracteur.mjs";
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const today = new Date();
|
||||
const currentMonth = today.getMonth() + 1;
|
||||
const currentYear = today.getFullYear();
|
||||
this.document.getElementById("monthSelect").value = currentMonth;
|
||||
this.document.getElementById("yearSelect").value = currentYear;
|
||||
});
|
||||
|
||||
$('body').on('click', '#showExportThanatoModal', function () {
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".thanatoToExport:checked", {"page": "all"});
|
||||
let thanatoIdsToExport = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
thanatoIdsToExport.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(thanatoIdsToExport.length == 0){
|
||||
showError(t('gestion', "Veuillez choisir au moins une ligne de thanato"));
|
||||
return;
|
||||
}
|
||||
$('#exportThanatoModal').show();
|
||||
});
|
||||
|
||||
$('body').on('click', '#closeExportThanatoModal', function () {
|
||||
$('#exportThanatoModal').hide();
|
||||
});
|
||||
|
||||
$('body').on('click', '#exportThanatosStat', function () {
|
||||
var oTable = $('.tabledt').dataTable();
|
||||
var rowcollection = oTable.$(".thanatoToExport:checked", {"page": "all"});
|
||||
let thanatoIdsToExport = [];
|
||||
rowcollection.each(function(index,elem){
|
||||
var checkbox_value = $(elem).val();
|
||||
thanatoIdsToExport.push(checkbox_value);
|
||||
});
|
||||
|
||||
if(thanatoIdsToExport.length == 0){
|
||||
$('#exportThanatoModal').hide();
|
||||
showError(t('gestion', "Veuillez choisir au moins une ligne de thanato"));
|
||||
return;
|
||||
}
|
||||
|
||||
var today = new Date();
|
||||
var monthValue = document.getElementById("monthSelect").value ?? today.getMonth() + 1;
|
||||
var yearValue = document.getElementById("yearSelect").value ?? today.getFullYear();
|
||||
let exportThanatoPayload = {
|
||||
thanatoIdsToExport: thanatoIdsToExport,
|
||||
month: monthValue,
|
||||
year: yearValue
|
||||
}
|
||||
|
||||
showLoader();
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/thanatopracteur/exportThanatoStatistic',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(exportThanatoPayload)
|
||||
}).done(function (response) {
|
||||
$('#exportThanatoModal').hide();
|
||||
let datatable = new DataTable('.tabledt');
|
||||
Thanatopracteur.loadThanatoDT(datatable);
|
||||
if(response.length == 0){
|
||||
showError(t('gestion', "Erreur dans l'export des statistiques"));
|
||||
}
|
||||
else{
|
||||
response.forEach(fileName => {
|
||||
showSuccess('Sauvegardé dans' + fileName);
|
||||
});
|
||||
}
|
||||
}).always(function () {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
@ -1,6 +1,7 @@
|
||||
import { showMessage, showSuccess, showError } from "@nextcloud/dialogs";
|
||||
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
|
||||
import { baseUrl, cur, getGlobal, insertCell, insertRow, insertRowWeekendRow, modifyCell } from "./mainFunction.mjs";
|
||||
import { getOrderItemsByOrderId } from "./order/orderAjaxRequest.mjs";
|
||||
|
||||
/**
|
||||
* Update data
|
||||
@ -85,6 +86,7 @@ export function getStats() {
|
||||
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
|
||||
$("#clientGroupFacturationStat").text(res.clientGroupFacturation);
|
||||
$("#providerStat").text(res.provider);
|
||||
$("#orerProductStat").text(res.orderProduct);
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
});
|
||||
@ -289,6 +291,11 @@ export function updateEditable(myCase) {
|
||||
if(myCase.dataset.table == "lieu" && (myCase.dataset.column == "depart" || myCase.dataset.column == "arrivee")) { location.reload(); }
|
||||
if (myCase.dataset.modifier === "getProduitsById") {getProduitsById();}
|
||||
if (myCase.dataset.modifier === "getArticlesById") {getArticlesById();}
|
||||
if (myCase.dataset.modifier === "getOrderItemsByOrderId")
|
||||
{
|
||||
const orderId = myCase.dataset.orderId;
|
||||
getOrderItemsByOrderId(orderId);
|
||||
}
|
||||
myCase.removeAttribute('contenteditable');
|
||||
}
|
||||
|
||||
@ -823,4 +830,40 @@ export function exportCareCertificate(defuntIdPayload) {
|
||||
error(response);
|
||||
});
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a product in database using devisId
|
||||
*/
|
||||
export function getProduitsByDevisId(devisId) {
|
||||
var myData = { numdevis: devisId };
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/getProduitsById',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(myData)
|
||||
}).done(function (response, code) {
|
||||
$('#produits tbody').empty();
|
||||
var total = 0;
|
||||
var deleteDisable = "";
|
||||
if ($('#produits').data("type") === "facture") {
|
||||
deleteDisable = "d-none";
|
||||
}
|
||||
|
||||
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||
$('#produits tbody').append('<tr><td><div data-modifier="getProduitsById" data-id="' + myresp.pdid + '" data-table="produit_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.pid + '" data-id="' + myresp.pdid + '" class="selectable">' + myresp.reference + '</div></td>' +
|
||||
'<td>' + myresp.description + '</td>' +
|
||||
'<td><div class="editableNumber getProduitsById" style="display:inline;" data-modifier="getProduitsById" data-table="produit_devis" data-column="quantite" data-id=' + myresp.pdid + '>' + myresp.quantite + '</div> </td>' +
|
||||
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
|
||||
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
|
||||
total += (myresp.quantite * myresp.prix_unitaire);
|
||||
});
|
||||
|
||||
$("#totaldevis tbody").empty();
|
||||
getGlobal(devisId);
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
});
|
||||
}
|
||||
@ -28,25 +28,28 @@ export function updateOrderDate(orderId,dateValue) {
|
||||
/**
|
||||
* Get order products
|
||||
*/
|
||||
export function getOrderProductsByOrderId(orderId) {
|
||||
export function getOrderItemsByOrderId(orderId) {
|
||||
$.ajax({
|
||||
url: baseUrl + '/order/'+orderId+'/products',
|
||||
url: baseUrl + '/order/'+orderId+'/items',
|
||||
type: 'PROPFIND',
|
||||
async: false,
|
||||
contentType: 'application/json'
|
||||
}).done(function (response, code) {
|
||||
$('#orderProducts tbody').empty();
|
||||
$('#orderItems tbody').empty();
|
||||
|
||||
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||
$('#orderProducts tbody').append(
|
||||
'<tr><td><div data-modifier="getOrderProductsByOrderId" data-id="' + myresp.order_product_id + '" data-table="order_product" class="deleteItem icon-delete"></div><div style="display:inline;">' + myresp.produit_reference + '</div></td>' +
|
||||
'<td>' + myresp.produit_description + '</td>' +
|
||||
'<td><div style="display:inline;" data-modifier="getProduitsById">' + myresp.order_product_quantity + '</div> </td>' +
|
||||
'<td>' + cur.format(myresp.produit_ht_price) + '</td>' +
|
||||
'<td>' + cur.format((myresp.order_product_quantity * myresp.produit_ht_price)) + '</td></tr>');
|
||||
$('#orderItems tbody').append(
|
||||
'<tr>' +
|
||||
'<td>'+
|
||||
'<div data-modifier="getOrderItemsByOrderId" data-id="' + myresp.order_item_id + '" data-table="order_item" class="deleteItem icon-delete"></div>'+
|
||||
'<div class="selectableOrderItem" data-order-item-id="' + myresp.order_item_id +'" data-order-product-id="' + myresp.order_product_id + '" data-order-id="' + orderId + '" style="display:inline;">' + myresp.order_product_reference + '</div></td>' +
|
||||
'<td>' + myresp.order_product_label + '</td>' +
|
||||
'<td><div class="editableNumber" data-order-id="' + orderId + '" style="display:inline;" data-modifier="getOrderItemsByOrderId" data-table="order_item" data-column="quantity" data-id="'+ myresp.order_item_id + '">' + myresp.order_item_quantity + '</div> </td>' +
|
||||
'<td>' + cur.format(myresp.order_product_ht_amount) + '</td>' +
|
||||
'<td>' + cur.format((myresp.order_item_quantity * myresp.order_product_ht_amount)) + '</td></tr>');
|
||||
});
|
||||
|
||||
$("#totalOrderProducts tbody").empty();
|
||||
$("#totalOrderItems tbody").empty();
|
||||
getTotalAmountOfOrder(orderId);
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
@ -64,12 +67,37 @@ export function getTotalAmountOfOrder(orderId) {
|
||||
contentType: 'application/json'
|
||||
}).done((function (totalAmountResult) {
|
||||
var totalAmount = JSON.parse(totalAmountResult);
|
||||
$('#totalOrderProducts tbody').empty();
|
||||
$('#totalOrderProducts tbody').append(
|
||||
$('#totalOrderItems tbody').empty();
|
||||
$('#totalOrderItems 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>');
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} select
|
||||
* @param {*} orderItemId
|
||||
* @param {*} orderProductId
|
||||
*/
|
||||
export function loadOrderProductIntoSelect(selectSelector, orderItemId, orderProductId,orderId) {
|
||||
$.ajax({
|
||||
url: baseUrl + '/orderProduct/list',
|
||||
type: 'PROPFIND',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response) {
|
||||
selectSelector.append('<option data-table="order_item" data-column="fk_order_item_id" data-val="' + orderProductId + '" data-id="' + orderItemId + '">'+t('gestion','Cancel')+'</option>');
|
||||
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||
var selected = "";
|
||||
if (orderProductId == myresp.id) {
|
||||
selected = "selected";
|
||||
}
|
||||
selectSelector.append('<option ' + selected + ' data-table="order_item" data-column="fk_order_item_id" data-order-id="' + orderId + '" data-val="' + myresp.id + '" data-id="' + orderItemId + '">' + myresp.reference + '</option>');
|
||||
});
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
});
|
||||
}
|
||||
@ -2,6 +2,7 @@ import { showError } from "@nextcloud/dialogs";
|
||||
import { baseUrl, checkSelectPurJs, LoadDT, showDone } from "../modules/mainFunction.mjs";
|
||||
import { OrderStatusOrdered,OrderStatusNew,OrderStatusCanceled } from "../constants/orderConstant.js";
|
||||
import { generateUrl } from "@nextcloud/router";
|
||||
import { OrderTypeDevis,OrderTypePurchase } from "../constants/orderTypeConstant.js";
|
||||
export class Order {
|
||||
|
||||
/**
|
||||
@ -26,8 +27,12 @@ export class Order {
|
||||
this.orderDetailsUrl = generateUrl(`/apps/gestion/order/${this.id}/details`);
|
||||
this.fkProviderId = myresp.fk_provider_id;
|
||||
this.providerName = ((myresp.provider_name == null || myresp.provider_name.length === 0) ? '-' : myresp.provider_name);
|
||||
this.orderType = myresp.fk_order_type_key;
|
||||
this.thanatoColumnClass = myresp.fk_order_type_key == OrderTypeDevis ? "" : "getThanatosSubcontractor";
|
||||
}
|
||||
|
||||
|
||||
|
||||
static getClientFullname(myresp){
|
||||
let clientPrenom = '';
|
||||
let clientNom = '';
|
||||
@ -87,10 +92,10 @@ export class Order {
|
||||
'<div>' + this.id + '</div>',
|
||||
'<input style="margin:0;padding:0;" class="orderInputDate" type="date" value=' + this.orderDate + ' data-id="' + this.id + '"/>',
|
||||
'<div>' + this.orderFullNumber + '</div>',
|
||||
'<div class="loadSelect_listdefunt" data-table="orders" data-column="fk_defunt_id" data-id="' + this.id + '" data-current="' + this.defuntId + '">'+ this.defuntName + '</div>',
|
||||
'<div class="loadSelect_listclient" data-table="orders" data-column="fk_client_id" data-id="' + this.id + '" data-current="' + this.clientId + '">'+ this.clientFullName + '</div>',
|
||||
'<div class="getThanatosSubcontractor" data-table="orders" data-column="fk_thanato_id" data-id="' + this.id + '" data-current="' + this.thanatoId + '">'+ this.thanatoFullName + '</div>',
|
||||
'<div class="loadSelect_listlieu" data-table="orders" data-column="fk_lieu_id" data-id="' + this.id + '" data-current="' + this.locationId + '">'+ this.locationName + '</div>',
|
||||
'<div>'+ this.defuntName + '</div>',
|
||||
'<div>'+ this.clientFullName + '</div>',
|
||||
'<div class="'+this.thanatoColumnClass+'" data-table="orders" data-column="fk_thanato_id" data-id="' + this.id + '" data-current="' + this.thanatoId + '">'+ this.thanatoFullName + '</div>',
|
||||
'<div>'+ this.locationName + '</div>',
|
||||
'<div>' + this.productReferences + '</div>',
|
||||
'<div class="selectProviders" data-table="orders" data-column="fk_provider_id" data-id="' + this.id + '" data-current="' + this.fkProviderId + '">'+ this.providerName + '</div>',
|
||||
'<div style="'+ Order.getComandStatusCssSytle(this.statusKey) +'">' + this.statusLabel + '</div>',
|
||||
|
||||
132
gestion/src/js/objects/orderProduct.mjs
Normal file
132
gestion/src/js/objects/orderProduct.mjs
Normal file
@ -0,0 +1,132 @@
|
||||
import { showError } from "@nextcloud/dialogs";
|
||||
import { baseUrl, cur, LoadDT, showDone,checkSelectPurJs} from "../modules/mainFunction.mjs";
|
||||
import { updateDB } from "../modules/ajaxRequest.mjs";
|
||||
export class OrderProduct {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param myresp instantiate orderProduct object
|
||||
*/
|
||||
constructor(myresp) {
|
||||
this.id = myresp.id;
|
||||
this.reference = ((myresp.reference.length === 0) ? '-' : myresp.reference);
|
||||
this.label = ((myresp.label.length === 0) ? '-' : myresp.label);
|
||||
this.ht_amount = ((myresp.ht_amount.length === 0) ? '-' : myresp.ht_amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get datatable row for a orderProduct
|
||||
*/
|
||||
getDTRow() {
|
||||
let myrow = [
|
||||
'<div>' + this.id + '</div>',
|
||||
'<div class="editable" data-table="order_product" data-column="reference" data-id="' + this.id + '">' + this.reference + '</div>',
|
||||
'<div class="editable" data-table="order_product" data-column="label" data-id="' + this.id + '">' + this.label + '</div>',
|
||||
'<div class="editableNumeric" data-table="order_product" data-column="ht_amount" data-id="' + this.id + '">' + cur.format(this.ht_amount) + '</div>',
|
||||
'<div data-modifier="orderProduct" data-id=' + this.id + ' data-table="order_product" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
|
||||
];
|
||||
return myrow;
|
||||
}
|
||||
|
||||
static getOrderProductsList(callback){
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/orderProduct/list', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
callback(JSON.parse(this.response));
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} orderProductDatatable
|
||||
*/
|
||||
static loadOrderProductDatatable(orderProductDatatable) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/orderProduct/list', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
LoadDT(orderProductDatatable, JSON.parse(this.response), OrderProduct);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} dt
|
||||
*/
|
||||
static createDefaultOrderProduct(dt) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('POST', baseUrl + '/orderProduct/createDefaultOrderProduct', true);
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
showDone()
|
||||
OrderProduct.loadOrderProductDatatable(dt);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} lid
|
||||
*/
|
||||
static loadOrderProductListToSelect(e){
|
||||
OrderProduct.getOrderProductsList(response => {
|
||||
|
||||
var selectElement = document.createElement("select");
|
||||
selectElement.dataset.current = e.target.dataset.current;
|
||||
selectElement.dataset.id = e.target.dataset.id;
|
||||
selectElement.dataset.old = e.target.innerHTML;
|
||||
|
||||
selectElement.addEventListener("change", el=>{
|
||||
if(el.target.value != 0){
|
||||
updateDB(el.target.parentElement.dataset.table,
|
||||
el.target.parentElement.dataset.column,
|
||||
el.target.value,
|
||||
el.target.parentElement.dataset.id
|
||||
);
|
||||
|
||||
// location.reload();
|
||||
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
|
||||
parentElement.dataset.current = el.target.value;
|
||||
}else{
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.dataset.old
|
||||
}
|
||||
});
|
||||
|
||||
var option = document.createElement("option");
|
||||
option.value = 0;
|
||||
option.text = t('gestion', 'Cancel');
|
||||
selectElement.appendChild(option);
|
||||
|
||||
JSON.parse(response).forEach(myresp => {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = myresp.reference;
|
||||
var option = document.createElement("option");
|
||||
option.value = myresp.id;
|
||||
option.text = txt.value;
|
||||
selectElement.appendChild(option);
|
||||
});
|
||||
|
||||
checkSelectPurJs(selectElement);
|
||||
|
||||
e.target.innerHTML = ''
|
||||
e.target.appendChild(selectElement);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -44,6 +44,7 @@ export class Provider {
|
||||
*/
|
||||
getDTRow() {
|
||||
let myrow = [
|
||||
'<input class="providerToExport" data-id= '+ this.id + ' type="checkbox" name="providerToExport" value="' + this.id + '"/>',
|
||||
"<div>" + this.id + "</div>",
|
||||
'<div class="editable" data-table="provider" data-column="provider_name" data-id="' +
|
||||
this.id +
|
||||
|
||||
@ -4,11 +4,21 @@ import "../css/mycss.css";
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/orderListener";
|
||||
import { getOrderProductsByOrderId } from "./modules/order/orderAjaxRequest.mjs";
|
||||
import { getProduitsByDevisId } from "./modules/ajaxRequest.mjs";
|
||||
import { getOrderItemsByOrderId } from "./modules/order/orderAjaxRequest.mjs";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
|
||||
const orderId = $("#orderId").data("id");
|
||||
getOrderProductsByOrderId(orderId);
|
||||
const devisId = $("#devisId").data("id");
|
||||
console.log(devisId);
|
||||
const isOrderDevis = devisId != null;
|
||||
|
||||
if(isOrderDevis){
|
||||
getProduitsByDevisId(devisId);
|
||||
}
|
||||
else{
|
||||
getOrderItemsByOrderId(orderId);
|
||||
}
|
||||
});
|
||||
14
gestion/src/js/orderProduct.js
Normal file
14
gestion/src/js/orderProduct.js
Normal file
@ -0,0 +1,14 @@
|
||||
import "@nextcloud/dialogs/dist/index.css";
|
||||
import "datatables.net-dt/css/jquery.dataTables.css";
|
||||
import "../css/mycss.css";
|
||||
|
||||
import DataTable from "datatables.net";
|
||||
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import "./listener/orderListener";
|
||||
import { OrderProduct } from "./objects/orderProduct.mjs";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
OrderProduct.loadOrderProductDatatable(new DataTable(".tabledt",optionDatatable));
|
||||
});
|
||||
@ -2,7 +2,7 @@ import "@nextcloud/dialogs/dist/index.css";
|
||||
import "datatables.net-dt/css/jquery.dataTables.css";
|
||||
import "../css/mycss.css";
|
||||
import "./listener/main_listener";
|
||||
|
||||
import "./listener/thanatoListener";
|
||||
import DataTable from "datatables.net";
|
||||
import { globalConfiguration, optionDatatable } from "./modules/mainFunction.mjs";
|
||||
import { Thanatopracteur } from "./objects/thanatopracteur.mjs";
|
||||
|
||||
@ -1,12 +1,48 @@
|
||||
<?php
|
||||
|
||||
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||
$order = $_['order'];
|
||||
$configuration = $_['configuration'];
|
||||
$isOrderDevis = $order->fk_order_type_key == OrderTypeConstant::ORDER_TYPE_DEVIS;
|
||||
$isOrderPurchase = $order->fk_order_type_key == OrderTypeConstant::ORDER_TYPE_PURCHASE;
|
||||
$orderComment = $order->order_comment == null || $order->order_comment == "" ? "-": $order->order_comment;
|
||||
|
||||
$clientCompany = $isOrderDevis ?
|
||||
$order->client_entreprise :
|
||||
"FOURNISSEUR";
|
||||
|
||||
$clientFullName = $isOrderDevis ?
|
||||
$order->client_prenom . " " . $order->client_nom :
|
||||
$order->provider_name . " " . $order->provider_last_name;
|
||||
|
||||
$clientAddress = $isOrderDevis ?
|
||||
$order->client_adresse :
|
||||
$order->provider_address.' '.$order->provider_city;
|
||||
|
||||
$clientEmail = $isOrderDevis ?
|
||||
$order->client_mail :
|
||||
$order->provider_email;
|
||||
|
||||
$clientPhone = $isOrderDevis ?
|
||||
$order->client_phone :
|
||||
$order->provider_phone;
|
||||
|
||||
$clientSiret = $isOrderDevis ?
|
||||
$order->client_legal_one :
|
||||
$order->provider_company_name;
|
||||
?>
|
||||
<div class="bootstrap-iso">
|
||||
<div id="orderId" data-id="<?php echo $order->id; ?>"></div>
|
||||
<?php if($isOrderDevis){
|
||||
?>
|
||||
<div id="devisId" style="display:none;" data-id="<?php echo $order->fk_devis_id; ?>"></div>
|
||||
<?php } ?>
|
||||
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Commande'));?>
|
||||
<div id="orderId" style="display:inline" data-id="<?php echo $order->id; ?>">sur le defunt <?php echo $order->defunt_nom; ?></div>
|
||||
<span>(</span> <div style="display:inline"><?php echo $order->lieu_nom; ?>)</div>
|
||||
<?php if($isOrderDevis) {
|
||||
?>
|
||||
<div style="display:inline">sur le defunt <?php echo $order->defunt_nom; ?></div>
|
||||
<span>(</span> <div style="display:inline"><?php echo $order->lieu_nom; ?>)</div>
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<hr />
|
||||
<div class="row">
|
||||
@ -30,16 +66,18 @@
|
||||
?>
|
||||
</div>
|
||||
<div class="col-5 h-100 m-0" style="min-height:250px;">
|
||||
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span><?php echo $order->client_entreprise; ?></span></h5>
|
||||
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span><?php echo $clientCompany; ?></span></h5>
|
||||
<p style="min-height:180px;" class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
|
||||
<span><?php echo $order->client_prenom . " " . $order->client_nom; ?></span><br/>
|
||||
<span><?php echo $order->client_adresse; ?></span><br/>
|
||||
<span><?php echo $order->client_mail; ?></span><br/>
|
||||
<span><?php echo $order->client_phone; ?></span><br/>
|
||||
<span><?php echo $order->client_legal_one; ?></span><br/>
|
||||
<span><?php echo $clientFullName; ?></span><br/>
|
||||
<span><?php echo $clientAddress; ?></span><br/>
|
||||
<span><?php echo $clientEmail; ?></span><br/>
|
||||
<span><?php echo $clientPhone; ?></span><br/>
|
||||
<span><?php echo $clientSiret; ?></span><br/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php if($isOrderDevis){
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col col-md">
|
||||
<div class="col col-xl text-center">
|
||||
@ -47,8 +85,9 @@
|
||||
<span>Lieu : <b><?php echo $order->lieu_nom;?> (<?php echo $order->lieu_adresse;?>)</b>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col col-md">
|
||||
<label class="fw-bold">Commentaires :</label>
|
||||
@ -63,11 +102,20 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div><h2>Articles</h2></div>
|
||||
<button id="addProductToOrder" type="button" class="mb-2 btn btn-outline-success">Ajouter un article</button>
|
||||
<?php if($isOrderPurchase){?>
|
||||
<button id="addOrderItems" type="button" class="mb-2 btn btn-outline-success">Ajouter un article</button>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table id="orderProducts" class="table table-striped">
|
||||
<?php
|
||||
$tableProductId = $isOrderDevis ?
|
||||
"produits" :
|
||||
"orderItems";
|
||||
?>
|
||||
<table id="<?php echo $tableProductId ?>" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('Reference'));?></th>
|
||||
@ -86,7 +134,12 @@
|
||||
<button id="exportOrderToPdf" type="button" class="mb-2 btn btn-outline-success"><?php p($l->t('Save in Nextcloud'));?></button>
|
||||
</div>
|
||||
<div class="mt-0 table-responsive">
|
||||
<table id="totalOrderProducts" class="table table-striped table-xl">
|
||||
<?php
|
||||
$tableTotalProductAmountId = $isOrderDevis?
|
||||
"totaldevis" :
|
||||
"totalOrderItems";
|
||||
?>
|
||||
<table id="<?php echo $tableTotalProductAmountId ?>" class="table table-striped table-xl">
|
||||
<thead class="bg-dark text-white">
|
||||
<tr>
|
||||
<th class="text-center"><?php p($l->t('Total without VAT'));?></th>
|
||||
|
||||
27
gestion/templates/content/orderProduct.php
Normal file
27
gestion/templates/content/orderProduct.php
Normal file
@ -0,0 +1,27 @@
|
||||
<div id="contentTable">
|
||||
<div class="breadcrumb" data-html2canvas-ignore>
|
||||
<div class="crumb svg crumbhome">
|
||||
<a href="<?php echo($_['url']['orderProduct']); ?>" class="icon-home"></a>
|
||||
<span style="display: none;"></span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<span>Article</span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<button style="margin-left:3px;" type="button" id="createDefaultOrderProduct">Ajout article</button>
|
||||
</div>
|
||||
</div>
|
||||
<table id="orderProductTable" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Reference'));?></th>
|
||||
<th><?php p($l->t('Designation'));?></th>
|
||||
<th><?php p($l->t('Unit price without VAT'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -10,10 +10,16 @@
|
||||
<div class="crumb svg crumbhome">
|
||||
<button style="margin-left:3px;" type="button" id="createDefaultProvider">Ajouter un fournisseur</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button id="showExportProviderStatModal" class="btn btn-secondary" data-toggle="modal" data-target="#exportProviderStatModal">
|
||||
Export stat
|
||||
</button>
|
||||
</div>
|
||||
<table id="tableProviderList" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Nom'));?></th>
|
||||
<th><?php p($l->t('Prénom'));?></th>
|
||||
@ -29,4 +35,30 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="modal" id="exportProviderStatModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Choisir l'année pour l'export</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<select class="form-select w-auto" name="year" id="yearSelect">
|
||||
<?php
|
||||
$currentYear = date('Y');
|
||||
for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
|
||||
echo '<option value="' . $year . '"';
|
||||
echo '>' . $year . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="closeProviderStatModal" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="exportProviderStat" type="button" class="btn btn-primary">Exporter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -13,8 +13,10 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex jsutify-content-end">
|
||||
<button class="btn btn-secondary" id="exportThanatoData">Export thanato stat</button>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button id="showExportThanatoModal" class="btn btn-secondary" data-toggle="modal" data-target="#exportThanatoModal">
|
||||
Export stat
|
||||
</button>
|
||||
</div>
|
||||
<table id="client" class="display tabledt" style="font-size:11px;">
|
||||
<thead>
|
||||
@ -33,4 +35,44 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="modal" id="exportThanatoModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Choisir le mois et l'année pour l'export</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<select class="form-select w-auto" name="month" id="monthSelect">
|
||||
<option value="1">Janvier</option>
|
||||
<option value="2">Février</option>
|
||||
<option value="3">Mars</option>
|
||||
<option value="4">Avril</option>
|
||||
<option value="5">Mai</option>
|
||||
<option value="6">Juin</option>
|
||||
<option value="7">Juillet</option>
|
||||
<option value="8">Août</option>
|
||||
<option value="9">Septembre</option>
|
||||
<option value="10">Octobre</option>
|
||||
<option value="11">Novembre</option>
|
||||
<option value="12">Décembre</option>
|
||||
</select>
|
||||
<select class="form-select w-auto" name="year" id="yearSelect">
|
||||
<?php
|
||||
$currentYear = date('Y');
|
||||
for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
|
||||
echo '<option value="' . $year . '"';
|
||||
echo '>' . $year . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="closeExportThanatoModal" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="exportThanatosStat" type="button" class="btn btn-primary">Exporter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -174,13 +174,13 @@
|
||||
</li>
|
||||
<li class="app-navigation-entry-submenu">
|
||||
<span class="navmarg icon-category-integration"></span>
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['index']); ?>">
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['orderProduct']); ?>">
|
||||
<?php p($l->t('Articles'));?>
|
||||
</a>
|
||||
<div class="app-navigation-entry-utils-submenu">
|
||||
<ul>
|
||||
<li class="app-navigation-entry-utils-counter">
|
||||
<span>5</span>
|
||||
<span id="orerProductStat"><div class="loader"></div></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
19
gestion/templates/orderProduct.php
Normal file
19
gestion/templates/orderProduct.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
style('gestion', array('style'));
|
||||
script('gestion', array('orderProduct.app', '814.app', '856.app'));
|
||||
?>
|
||||
<div id="app">
|
||||
<div id="app-navigation">
|
||||
<?php print_unescaped($this->inc('navigation/index')); ?>
|
||||
<?php print_unescaped($this->inc('settings/index')); ?>
|
||||
</div>
|
||||
|
||||
<div id="app-content">
|
||||
<div id="app-content-wrapper">
|
||||
<?php print_unescaped($this->inc('content/changelog')); ?>
|
||||
<?php print_unescaped($this->inc('content/orderProduct')); ?>
|
||||
<?php print_unescaped($this->inc('loader')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
<div id="app-content-wrapper">
|
||||
<?php print_unescaped($this->inc('content/changelog')); ?>
|
||||
<?php print_unescaped($this->inc('content/thanatopracteur')); ?>
|
||||
<?php print_unescaped($this->inc('loader')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,7 +34,8 @@ module.exports =
|
||||
clientGroup: './src/js/clientGroup.js',
|
||||
clientGroupFacturation : './src/js/clientGroupFacturation.js',
|
||||
orderDetails : './src/js/orderDetails.js',
|
||||
provider : './src/js/provider.js'
|
||||
provider : './src/js/provider.js',
|
||||
orderProduct : './src/js/orderProduct.js'
|
||||
},
|
||||
output: {
|
||||
filename: '../js/[name].app.js',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user