Merge branch 'features/feature-client-group-facturation-and-tarif' into releases/release-h2f
This commit is contained in:
commit
372ae08ca8
@ -15,6 +15,9 @@ return [
|
||||
['name' => 'page#isConfig', 'url' => '/isconfig', 'verb' => 'GET'],
|
||||
['name' => 'page#statistique', 'url' => '/statistique', 'verb' => 'GET'],
|
||||
['name' => 'page#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
|
||||
['name' => 'page#clientGroupDiscount', 'url' => '/clientGroupDiscount', 'verb' => 'GET'],
|
||||
['name' => 'page#clientGroups', 'url' => '/clientGroups', 'verb' => 'GET'],
|
||||
['name' => 'page#clientGroupFacturation', 'url' => '/clientGroupFacturation', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'page#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
|
||||
|
||||
@ -158,5 +161,15 @@ return [
|
||||
['name' => 'order#updateOrderDate','url' => '/order/{orderId}/updateDate', 'verb' => 'PUT'],
|
||||
['name' => 'order#getThanatoProductsFees','url' => '/thanatoProductFees/list', 'verb' => 'PROPFIND'],
|
||||
['name' => 'order#createDefaultThanatoProductFee','url' => '/thanatoProductFees/createDefaultThanatoProductFee', 'verb' => 'POST'],
|
||||
|
||||
//clients discount
|
||||
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#getClientGroups', 'url' => '/getClientGroups', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#createDefaultClientGroup', 'url' => '/clientGroup/createDefaultClientGroup', 'verb' => 'POST'],
|
||||
['name' => 'page#createDefaultClientGroupDiscount', 'url' => '/clientGroupDiscount/createDefaultClientGroupDiscount', 'verb' => 'POST'],
|
||||
|
||||
//client group facturation
|
||||
['name' => 'page#getClientGroupFacturations', 'url' => '/client/getClientGroupFacturations', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#createDefaultClientGroupFacturation', 'url' => '/client/createDefaultClientGroupFacturation', '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
2
gestion/js/clientGroup.app.js
Normal file
2
gestion/js/clientGroup.app.js
Normal file
File diff suppressed because one or more lines are too long
46
gestion/js/clientGroup.app.js.LICENSE.txt
Normal file
46
gestion/js/clientGroup.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
|
||||
*/
|
||||
2
gestion/js/clientGroupDiscount.app.js
Normal file
2
gestion/js/clientGroupDiscount.app.js
Normal file
File diff suppressed because one or more lines are too long
46
gestion/js/clientGroupDiscount.app.js.LICENSE.txt
Normal file
46
gestion/js/clientGroupDiscount.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
|
||||
*/
|
||||
2
gestion/js/clientGroupFacturation.app.js
Normal file
2
gestion/js/clientGroupFacturation.app.js
Normal file
File diff suppressed because one or more lines are too long
46
gestion/js/clientGroupFacturation.app.js.LICENSE.txt
Normal file
46
gestion/js/clientGroupFacturation.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
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
@ -7,6 +7,7 @@ abstract class BddConstant
|
||||
const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
|
||||
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||
public const DEFAULT_CLIENT_GROUP_FACTURATION_NAME = "Nom du groupe";
|
||||
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Emmanuelle";
|
||||
|
||||
|
||||
@ -486,7 +486,14 @@ class PageController extends Controller {
|
||||
);
|
||||
$produits = json_decode($this->getProduitsById($facture->id_devis));
|
||||
foreach ($produits as $key => $produit) {
|
||||
$facture_temp['montant_htc'] += $produit->prix_unitaire * $produit->quantite;
|
||||
$htPrice = $produit->prix_unitaire;
|
||||
if($facture->fk_client_group_id != null){
|
||||
$price = $this->myDb->getProductPriceByClientGroupId($facture->fk_client_group_id,$produit->id);
|
||||
if($price != null){
|
||||
$htPrice = $price;
|
||||
}
|
||||
}
|
||||
$facture_temp['montant_htc'] += $htPrice * $produit->quantite;
|
||||
};
|
||||
$facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva'])/100;
|
||||
$facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc'];
|
||||
@ -737,7 +744,14 @@ class PageController extends Controller {
|
||||
);
|
||||
$produits = json_decode($this->getProduitsById($facture->id_devis));
|
||||
foreach ($produits as $key => $produit) {
|
||||
$facture_temp['montant_htc'] += $produit->prix_unitaire * $produit->quantite;
|
||||
$htPrice = $produit->prix_unitaire;
|
||||
if($facture->fk_client_group_id != null){
|
||||
$price = $this->myDb->getProductPriceByClientGroupId($facture->fk_client_group_id,$produit->id);
|
||||
if($price != null){
|
||||
$htPrice = $price;
|
||||
}
|
||||
}
|
||||
$facture_temp['montant_htc'] += $htPrice * $produit->quantite;
|
||||
};
|
||||
$facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva'])/100;
|
||||
$facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc'];
|
||||
@ -1967,6 +1981,9 @@ class PageController extends Controller {
|
||||
$res['bibliotheque'] = json_decode($this->myDb->numberBibliotheque($this->idNextcloud))[0]->c;
|
||||
$res['order'] = $this->orderService->getOrderCount();
|
||||
$res['thanatoProductFee'] = $this->orderService->getThanatoProductFeeCount();
|
||||
$res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c;
|
||||
$res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c;
|
||||
$res['clientGroupFacturation'] = json_decode($this->myDb->getClientGroupFacturationCount())[0]->c;
|
||||
return json_encode($res);
|
||||
}
|
||||
|
||||
@ -2807,4 +2824,79 @@ class PageController extends Controller {
|
||||
return json_encode([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getClientGroupDiscounts() {
|
||||
return $this->myDb->getClientGroupDiscounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function clientGroupDiscount() {
|
||||
return new TemplateResponse('gestion', 'clientGroupDiscount', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/thanatopracteur.php
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function clientGroups() {
|
||||
return new TemplateResponse('gestion', 'clientGroup', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); // templates/thanatopracteur.php
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getClientGroups() {
|
||||
return $this->myDb->getClientGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function createDefaultClientGroup(){
|
||||
return $this->myDb->createDefaultClientGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function createDefaultClientGroupDiscount(){
|
||||
return $this->myDb->createDefaultClientGroupDiscount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function clientGroupFacturation() {
|
||||
return new TemplateResponse('gestion', 'clientGroupFacturation', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getClientGroupFacturations() {
|
||||
return $this->myDb->getClientGroupFacturations();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
public function createDefaultClientGroupFacturation(){
|
||||
return $this->myDb->createDefaultGroupFacturation();
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,11 +38,13 @@ class Bdd {
|
||||
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
|
||||
"fk_thanato_type_key","thanato_email","fk_user_uuid",
|
||||
"fk_defunt_id","fk_lieu_id","fk_client_id","fk_thanato_id",
|
||||
"fk_product_id","ht_price");
|
||||
"fk_product_id","ht_price",
|
||||
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name");
|
||||
$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");
|
||||
"orders","thanato_product_discount",
|
||||
"client_group_discount","client_group");
|
||||
$this->tableprefix = '*PREFIX*' ."gestion_";
|
||||
$this->pdo = $db;
|
||||
$this->l = $l;
|
||||
@ -84,7 +86,26 @@ class Bdd {
|
||||
|
||||
public function getClients($idNextcloud){
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."client;";
|
||||
return $this->execSQL($sql, array());
|
||||
|
||||
$clients = $this->execSQLNoJsonReturn($sql,[]);
|
||||
foreach($clients as &$client){
|
||||
if($client['fk_client_group_id'] == null){
|
||||
$client['client_group_name'] = '';
|
||||
}
|
||||
else{
|
||||
$clientGroup = $this->getClientGroupById($client['fk_client_group_id']);
|
||||
$client['client_group_name'] = $clientGroup != null ? $clientGroup['client_group_name'] : '';
|
||||
}
|
||||
|
||||
if($client['fk_client_group_facturation_id'] == null){
|
||||
$client['client_group_facturation_name'] = '';
|
||||
}
|
||||
else{
|
||||
$clientGroupFacturation = $this->getClientGroupFacturationById($client['fk_client_group_facturation_id']);
|
||||
$client['client_group_facturation_name'] = $clientGroupFacturation != null ? $clientGroupFacturation['group_facturation_name'] : '';
|
||||
}
|
||||
}
|
||||
return json_encode($clients);
|
||||
}
|
||||
|
||||
public function getClientsByDateDevis($idNextcloud, $date) {
|
||||
@ -355,7 +376,7 @@ class Bdd {
|
||||
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
|
||||
.$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, "
|
||||
.$this->tableprefix."client.adresse as adresse_client, ".$this->tableprefix."devis.date as date_soin, "
|
||||
.$this->tableprefix."client.mail as mail_client, "
|
||||
.$this->tableprefix."client.mail as mail_client, ".$this->tableprefix."client.entreprise as client_entreprise, ".$this->tableprefix."client.fk_client_group_id as fk_client_group_id, "
|
||||
.$this->tableprefix."devis.id_client as id_client, date_paiement, type_paiement, id_devis, ".$this->tableprefix."client.nom as nom, prenom, entreprise, "
|
||||
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,"
|
||||
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,"
|
||||
@ -407,6 +428,7 @@ class Bdd {
|
||||
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
|
||||
.$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, "
|
||||
.$this->tableprefix."client.adresse as adresse_client, ".$this->tableprefix."devis.date as date_soin, "
|
||||
.$this->tableprefix."client.entreprise as client_entreprise, ".$this->tableprefix."client.fk_client_group_id as fk_client_group_id, "
|
||||
.$this->tableprefix."devis.id_client as id_client, date_paiement, type_paiement, id_devis, ".$this->tableprefix."client.nom as nom, prenom, entreprise, "
|
||||
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,"
|
||||
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,"
|
||||
@ -565,8 +587,25 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getListProduit($numdevis, $idNextcloud){
|
||||
$sql = "SELECT ".$this->tableprefix."produit.id as pid,".$this->tableprefix."produit_devis.id as pdid, reference, description,".$this->tableprefix."produit_devis.comment, quantite, prix_unitaire FROM ".$this->tableprefix."produit, ".$this->tableprefix."devis, ".$this->tableprefix."produit_devis WHERE ".$this->tableprefix."produit.id = produit_id AND ".$this->tableprefix."devis.id = devis_id AND ".$this->tableprefix."devis.id = ?";
|
||||
return $this->execSQL($sql, array($numdevis));
|
||||
$sql = "SELECT ".
|
||||
$this->tableprefix."produit.id as pid,"
|
||||
.$this->tableprefix."produit_devis.id as pdid, reference, description,"
|
||||
.$this->tableprefix."produit_devis.comment, quantite, prix_unitaire, "
|
||||
.$this->tableprefix."devis.id_client
|
||||
FROM ".$this->tableprefix."produit, ".$this->tableprefix."devis, ".$this->tableprefix."produit_devis
|
||||
WHERE ".$this->tableprefix."produit.id = produit_id AND ".$this->tableprefix."devis.id = devis_id AND ".$this->tableprefix."devis.id = ?";
|
||||
|
||||
$produits = $this->execSQLNoJsonReturn($sql,[$numdevis]);
|
||||
|
||||
if(!empty($produits)){
|
||||
$clientId = $produits[0]["id_client"];
|
||||
$client = $this->getClientById($clientId);
|
||||
foreach($produits as &$produit){
|
||||
$productPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$produit['pid']);
|
||||
$produit['prix_unitaire'] = $productPrice ?? $produit['prix_unitaire'];
|
||||
}
|
||||
}
|
||||
return json_encode($produits);
|
||||
}
|
||||
|
||||
public function getListArticle($numdevis, $idNextcloud) {
|
||||
@ -1484,15 +1523,33 @@ class Bdd {
|
||||
* Annual turnover per month without VAT
|
||||
*/
|
||||
public function getAnnualTurnoverPerMonthNoVat($idNextcloud){
|
||||
$sql = "SELECT EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) as y,
|
||||
EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement) as m,
|
||||
sum(".$this->tableprefix."produit.prix_unitaire * ".$this->tableprefix."produit_devis.quantite) as total
|
||||
FROM `".$this->tableprefix."facture`, `".$this->tableprefix."produit_devis`, `".$this->tableprefix."produit`
|
||||
WHERE ".$this->tableprefix."facture.id_devis = ".$this->tableprefix."produit_devis.devis_id
|
||||
AND ".$this->tableprefix."produit_devis.produit_id = ".$this->tableprefix."produit.id
|
||||
GROUP BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement), EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement)
|
||||
ORDER BY EXTRACT(YEAR FROM ".$this->tableprefix."facture.date_paiement) DESC, EXTRACT(MONTH FROM ".$this->tableprefix."facture.date_paiement);";
|
||||
// return $this->execSQL($sql, array($idNextcloud));
|
||||
$sql = "SELECT
|
||||
EXTRACT(YEAR FROM facture.date_paiement) AS y,
|
||||
EXTRACT(MONTH FROM facture.date_paiement) AS m,
|
||||
SUM(
|
||||
COALESCE(client_group_discount.ht_amount,produit.prix_unitaire)
|
||||
* produit_devis.quantite
|
||||
) AS total
|
||||
FROM ".$this->tableprefix."facture AS facture
|
||||
JOIN ".$this->tableprefix."produit_devis AS produit_devis
|
||||
ON facture.id_devis = produit_devis.devis_id
|
||||
JOIN ".$this->tableprefix."produit AS produit
|
||||
ON produit_devis.produit_id = produit.id
|
||||
JOIN ".$this->tableprefix."devis AS devis
|
||||
ON facture.id_devis = devis.id
|
||||
JOIN ".$this->tableprefix."client AS client
|
||||
ON devis.id_client = client.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group AS client_group
|
||||
ON client.fk_client_group_id = client_group.id
|
||||
LEFT JOIN ".$this->tableprefix."client_group_discount AS client_group_discount
|
||||
ON client_group.id = client_group_discount.fk_client_group_id
|
||||
AND produit.id = client_group_discount.fk_produit_id
|
||||
GROUP BY
|
||||
EXTRACT(YEAR FROM facture.date_paiement),
|
||||
EXTRACT(MONTH FROM facture.date_paiement)
|
||||
ORDER BY
|
||||
EXTRACT(YEAR FROM facture.date_paiement) DESC,
|
||||
EXTRACT(MONTH FROM facture.date_paiement);";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
@ -2283,6 +2340,15 @@ class Bdd {
|
||||
$produitList = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$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'];
|
||||
}
|
||||
}
|
||||
|
||||
return $produitList;
|
||||
}
|
||||
@ -2649,7 +2715,7 @@ class Bdd {
|
||||
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
|
||||
.$this->tableprefix."devis.num as dnum,".$this->tableprefix."devis.version as adresse_devis,".$this->tableprefix."devis.comment as numero_commande, "
|
||||
.$this->tableprefix."client.adresse as adresse_client, ".$this->tableprefix."devis.date as date_soin, "
|
||||
.$this->tableprefix."client.mail as mail_client, "
|
||||
.$this->tableprefix."client.mail as mail_client, ".$this->tableprefix."client.entreprise as client_entreprise, ".$this->tableprefix."client.fk_client_group_id as fk_client_group_id, "
|
||||
.$this->tableprefix."devis.id_client as id_client, date_paiement, type_paiement, id_devis, ".$this->tableprefix."client.nom as nom, prenom, entreprise, "
|
||||
.$this->tableprefix."lieu.id as lid, ".$this->tableprefix."lieu.nom as lieu,".$this->tableprefix."lieu.adresse as adresse_soin,"
|
||||
.$this->tableprefix."defunt.id as id_defunt, ".$this->tableprefix."defunt.nom as nom_defunt,"
|
||||
@ -2824,4 +2890,112 @@ class Bdd {
|
||||
return $this->execSQL($sql,[$thanatoType]);
|
||||
}
|
||||
|
||||
public function getClientGroupDiscounts(){
|
||||
|
||||
$sql = "SELECT
|
||||
client_group_discount.id as id,
|
||||
client_group_discount.fk_client_group_id as fk_client_group_id,
|
||||
client_group_discount.fk_produit_id as fk_produit_id,
|
||||
client_group_discount.ht_amount as ht_amount,
|
||||
client_group.client_group_name as client_group_name,
|
||||
produit.id as produit_id,
|
||||
produit.reference as produit_reference,
|
||||
produit.prix_unitaire as prix_unitaire
|
||||
FROM ".$this->tableprefix."client_group_discount as client_group_discount
|
||||
LEFT JOIN ".$this->tableprefix."client_group as client_group on client_group_discount.fk_client_group_id = client_group.id
|
||||
LEFT JOIN ".$this->tableprefix."produit as produit on client_group_discount.fk_produit_id = produit.id
|
||||
ORDER BY client_group_discount.id DESC
|
||||
";
|
||||
|
||||
$clientGroupDiscounts = $this->execSQL(
|
||||
$sql,
|
||||
[]);
|
||||
|
||||
return $clientGroupDiscounts;
|
||||
}
|
||||
|
||||
public function getClientGroups(){
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."client_group as client_group ORDER BY client_group.id DESC;";
|
||||
$clientGroups = $this->execSQL($sql,[]);
|
||||
return $clientGroups;
|
||||
}
|
||||
|
||||
public function createDefaultClientGroup(){
|
||||
$sql = "INSERT INTO `".$this->tableprefix."client_group` (`client_group_name`) VALUES (?);";
|
||||
$this->execSQLNoData($sql, array(BddConstant::DEFAULT_CLIENT_GROUP_NAME));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createDefaultClientGroupDiscount(){
|
||||
$sql = "INSERT INTO `".$this->tableprefix."client_group_discount` (`fk_client_group_id`,`fk_produit_id`,`ht_amount`) VALUES (0,0,0);";
|
||||
$this->execSQLNoData($sql, array());
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getClientGroupCount(){
|
||||
$sql = "SELECT count(*) as c from ".$this->tableprefix."client_group;";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
public function getClientGroupDiscountCount(){
|
||||
$sql = "SELECT count(*) as c from ".$this->tableprefix."client_group_discount;";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
public function getProductPriceByClientGroupId($clientGroupId,$productId){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix ."client_group_discount as client_group_discount
|
||||
WHERE client_group_discount.fk_client_group_id = ? AND
|
||||
client_group_discount.fk_produit_id = ?;
|
||||
";
|
||||
$clientGroupDiscount = $this->execSQLNoJsonReturn(
|
||||
$sql,
|
||||
[$clientGroupId,$productId]);
|
||||
if(!empty($clientGroupDiscount)){
|
||||
return $clientGroupDiscount[0]['ht_amount'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getClientGroupFacturations(){
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."client_group_facturation as client_group_facturation ORDER BY client_group_facturation.id DESC;";
|
||||
$clientGroupFacturations = $this->execSQL($sql,[]);
|
||||
return $clientGroupFacturations;
|
||||
}
|
||||
|
||||
public function createDefaultGroupFacturation(){
|
||||
$sql = "INSERT INTO `".$this->tableprefix."client_group_facturation` (`group_facturation_name`) VALUES (?);";
|
||||
$this->execSQLNoData($sql, array(BddConstant::DEFAULT_CLIENT_GROUP_FACTURATION_NAME));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getClientGroupFacturationCount(){
|
||||
$sql = "SELECT count(*) as c from ".$this->tableprefix."client_group_facturation;";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
private function getClientGroupById($clientGroupId){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix."client_group as client_group
|
||||
WHERE client_group.id = ? ;";
|
||||
|
||||
$clientGroup = $this->execSQLNoJsonReturn($sql, array($clientGroupId));
|
||||
if(!empty($clientGroup)){
|
||||
return $clientGroup[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getClientGroupFacturationById($clientGroupFacturationId){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix."client_group_facturation as client_group_facturation
|
||||
WHERE client_group_facturation.id = ? ;";
|
||||
|
||||
$clientGroupFacturation = $this->execSQLNoJsonReturn($sql, array($clientGroupFacturationId));
|
||||
if(!empty($clientGroupFacturation)){
|
||||
return $clientGroupFacturation[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -55,6 +55,9 @@ class NavigationService {
|
||||
"france" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.france"),
|
||||
"orders" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.order"),
|
||||
"thanatoProductFees" => $this->urlGenerator->linkToRouteAbsolute("gestion.order.thanatoProductFee"),
|
||||
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
|
||||
"clientGroupDiscount" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupDiscount"),
|
||||
"clientGroupFacturation" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupFacturation"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
create table oc_gestion_client_group (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
client_group_name VARCHAR(255) DEFAULT ''
|
||||
);
|
||||
|
||||
alter table oc_gestion_client
|
||||
add column fk_client_group_id INT NULL;
|
||||
|
||||
create table oc_gestion_client_group_discount(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
fk_client_group_id INT NOT NULL,
|
||||
fk_produit_id INT NOT NULL,
|
||||
ht_amount FLOAT NOT NULL DEFAULT 0
|
||||
);
|
||||
@ -0,0 +1,6 @@
|
||||
create table oc_gestion_client_group_facturation(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
group_facturation_name VARCHAR(255) DEFAULT 'Nom du groupe'
|
||||
);
|
||||
|
||||
alter table oc_gestion_client ADD fk_client_group_facturation_id INT NULL;
|
||||
13
gestion/src/js/clientGroup.js
Normal file
13
gestion/src/js/clientGroup.js
Normal file
@ -0,0 +1,13 @@
|
||||
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 { ClientGroup} from "./objects/clientGroup.mjs"
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
ClientGroup.loadClientGroupDatatable(new DataTable(".tabledt",optionDatatable));
|
||||
});
|
||||
13
gestion/src/js/clientGroupDiscount.js
Normal file
13
gestion/src/js/clientGroupDiscount.js
Normal file
@ -0,0 +1,13 @@
|
||||
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 { ClientGroupDiscount} from "./objects/clientGroupDiscount.mjs"
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
ClientGroupDiscount.loadClientGroupDiscountDatatable(new DataTable(".tabledt",optionDatatable));
|
||||
});
|
||||
13
gestion/src/js/clientGroupFacturation.js
Normal file
13
gestion/src/js/clientGroupFacturation.js
Normal file
@ -0,0 +1,13 @@
|
||||
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 { ClientGroupFacturation } from "./objects/clientGroupFacturation.mjs";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
globalConfiguration();
|
||||
ClientGroupFacturation.loadClientGroupFacturationDatatable(new DataTable(".tabledt",optionDatatable));
|
||||
});
|
||||
@ -17,7 +17,9 @@ import { Bibliotheque } from "../objects/bibliotheque.mjs";
|
||||
import { Order } from "../objects/order.mjs";
|
||||
import { ThanatoEmployeeTypeKey,ThanatoSubcontractorTypeKey } from "../constants/thanatoTypeConstant";
|
||||
import { ThanatoProductFee } from "../objects/thanatoProductFee.mjs";
|
||||
|
||||
import { ClientGroup } from '../objects/clientGroup.mjs';
|
||||
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
|
||||
import { ClientGroupFacturation } from "../objects/clientGroupFacturation.mjs";
|
||||
var choose_folder = t('gestion', 'Choose work folder');
|
||||
|
||||
$('body').on('click', '#theFolder', function () {
|
||||
@ -75,6 +77,12 @@ document.body.addEventListener('click', e => {
|
||||
else if(e.target.className.includes("selectThanatoType")){
|
||||
Thanatopracteur.loadThanatoTypeIntoSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectClientGroupList")){
|
||||
ClientGroup.loadClientGroupListToSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectClientGroupFacturationList")){
|
||||
ClientGroupFacturation.loadClientGroupFacturationListToSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectProductsList")){
|
||||
Produit.loadProductListToSelect(e);
|
||||
}
|
||||
@ -106,6 +114,15 @@ document.body.addEventListener('click', e => {
|
||||
Facture.newFacture(new DataTable('.tabledt'));
|
||||
}else if("newProduit" === e.target.id){
|
||||
Produit.newProduct(new DataTable('.tabledt'));
|
||||
}
|
||||
else if("newClientGroup" === e.target.id){
|
||||
ClientGroup.createDefaultClientGroup(new DataTable('.tabledt'));
|
||||
}
|
||||
else if("newClientGroupFacturation" === e.target.id){
|
||||
ClientGroupFacturation.createDefaultClientGroupFacturation(new DataTable('.tabledt'));
|
||||
}
|
||||
else if("newClientGroupDiscount" === e.target.id){
|
||||
ClientGroupDiscount.createDefaultClientGroupDiscount(new DataTable('.tabledt'));
|
||||
} else if("saveIk" == e.target.id) {
|
||||
TrajetDetails.saveIkNextcloud();
|
||||
} else if("apercusFactures" === e.target.id) {
|
||||
@ -238,6 +255,9 @@ $('body').on('click', '.deleteItem', function () {
|
||||
if (modifier === "bibliotheque") { Bibliotheque.loadBibliothequeDT(dt); }
|
||||
if (modifier === "orders") { Order.loadOrderDatatable(dt); }
|
||||
if (modifier === "thanatoProductFee") { ThanatoProductFee.loadThanatoProductFeeDatatable(dt);}
|
||||
if (modifier === "clientGroup") { ClientGroup.loadClientGroupDatatable(dt); }
|
||||
if (modifier === "clientGroupDiscount") { ClientGroupDiscount.loadClientGroupDiscountDatatable(dt); }
|
||||
if (modifier === "clientGroupFacturation") { ClientGroupFacturation.loadClientGroupFacturationDatatable(dt); }
|
||||
});
|
||||
|
||||
$('body').on('change', '.listClient,.listDevis', function () {
|
||||
|
||||
@ -81,6 +81,9 @@ export function getStats() {
|
||||
$("#statsbibliotheque").text(res.bibliotheque);
|
||||
$("#thanatoProductFeeStat").text(res.thanatoProductFee);
|
||||
$("#orderStat").text(res.order);
|
||||
$("#clientGroupStat").text(res.clientGroup);
|
||||
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
|
||||
$("#clientGroupFacturationStat").text(res.clientGroupFacturation);
|
||||
}).fail(function (response, code) {
|
||||
showError(response);
|
||||
});
|
||||
|
||||
@ -17,6 +17,19 @@ export class Client {
|
||||
this.telephone = ((myresp.telephone.length === 0) ? '-' : myresp.telephone);
|
||||
this.mail = ((myresp.mail.length === 0) ? '-' : myresp.mail);
|
||||
this.adresse = ((myresp.adresse.length === 0) ? '-' : myresp.adresse);
|
||||
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name);
|
||||
this.clientGroupFacturationName = ((myresp.client_group_facturation_name.length === 0) ? '-' : myresp.client_group_facturation_name);
|
||||
let clientGroupId = 0;
|
||||
if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){
|
||||
clientGroupId = myresp.fk_client_group_id
|
||||
}
|
||||
this.clientGroupId = clientGroupId;
|
||||
|
||||
let clientGroupFacturationId = 0;
|
||||
if(myresp.fk_client_group_facturation_id != null && myresp.fk_client_group_facturation_id.length > 0){
|
||||
clientGroupFacturationId = myresp.fk_client_group_facturation_id
|
||||
}
|
||||
this.clientGroupFacturationId = clientGroupFacturationId;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,6 +46,8 @@ export class Client {
|
||||
'<div class="editable" data-table="client" data-column="telephone" data-id="' + this.id + '">' + this.telephone + '</div>',
|
||||
'<div class="editable" data-table="client" data-column="mail" data-id="' + this.id + '">' + this.mail + '</div>',
|
||||
'<div class="editable" data-table="client" data-column="adresse" data-id="' + this.id + '">' + this.adresse + '</div>',
|
||||
'<div class="selectClientGroupList" data-table="client" data-column="fk_client_group_id" data-id="' + this.id + '" data-current="' + this.clientGroupId + '">' + this.clientGroupName + '</div>',
|
||||
'<div class="selectClientGroupFacturationList" data-table="client" data-column="fk_client_group_facturation_id" data-id="' + this.id + '" data-current="' + this.clientGroupFacturationId + '">' + this.clientGroupFacturationName + '</div>',
|
||||
'<center><div data-modifier="client" data-id=' + this.id + ' data-table="client" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>'
|
||||
];
|
||||
return myrow;
|
||||
|
||||
148
gestion/src/js/objects/clientGroup.mjs
Normal file
148
gestion/src/js/objects/clientGroup.mjs
Normal file
@ -0,0 +1,148 @@
|
||||
import { showError } from "@nextcloud/dialogs";
|
||||
import { baseUrl, checkSelectPurJs, LoadDT, showDone } from "../modules/mainFunction.mjs";
|
||||
import { updateDB } from "../modules/ajaxRequest.mjs";
|
||||
|
||||
export class ClientGroup {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param myresp instantiate client group object
|
||||
*/
|
||||
constructor(myresp) {
|
||||
this.id = myresp.id;
|
||||
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get datatable row for a client group
|
||||
*/
|
||||
getDTRow() {
|
||||
let clientGroupRow = [
|
||||
'<div>' + this.id + '</div>',
|
||||
'<div class="editable" data-table="client_group" data-column="client_group_name" data-id="' + this.id + '">' + this.clientGroupName + '</div>',
|
||||
'<div data-modifier="clientGroup" data-id=' + this.id + ' data-table="client_group" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
|
||||
];
|
||||
|
||||
return clientGroupRow;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} clientGroupDatatable
|
||||
*/
|
||||
static loadClientGroupDatatable(clientGroupDatatable) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/getClientGroups', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
LoadDT(clientGroupDatatable, JSON.parse(this.response), ClientGroup);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} dt
|
||||
*/
|
||||
static newProduct(dt) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('POST', baseUrl + '/produit/insert', true);
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
showDone()
|
||||
Produit.loadProduitDT(dt);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
static getClientGroups(callback){
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/getClientGroups', 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 {*} lid
|
||||
*/
|
||||
static loadClientGroupListToSelect(e){
|
||||
ClientGroup.getClientGroups(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.client_group_name;
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} dt
|
||||
*/
|
||||
static createDefaultClientGroup(dt) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('POST', baseUrl + '/clientGroup/createDefaultClientGroup', true);
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
showDone()
|
||||
ClientGroup.loadClientGroupDatatable(dt);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
}
|
||||
85
gestion/src/js/objects/clientGroupDiscount.mjs
Normal file
85
gestion/src/js/objects/clientGroupDiscount.mjs
Normal file
@ -0,0 +1,85 @@
|
||||
import { showError } from "@nextcloud/dialogs";
|
||||
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
|
||||
|
||||
export class ClientGroupDiscount {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param myresp instantiate client group discount object
|
||||
*/
|
||||
constructor(myresp) {
|
||||
this.id = myresp.id;
|
||||
this.clientGroupName = ClientGroupDiscount.getClientGroupNameFromClientGroupResponse(myresp);
|
||||
this.productReference = ClientGroupDiscount.getProductReferenceFromClientGroupResponse(myresp);
|
||||
this.htAmount = myresp.ht_amount;
|
||||
this.clientGroupId = myresp.fk_client_group_id;
|
||||
this.productId = myresp.fk_produit_id;
|
||||
}
|
||||
|
||||
static getProductReferenceFromClientGroupResponse(myresp){
|
||||
let productReference = '-';
|
||||
if(myresp.produit_reference != null && myresp.produit_reference.length > 0){
|
||||
productReference = myresp.produit_reference;
|
||||
}
|
||||
return productReference;
|
||||
}
|
||||
|
||||
static getClientGroupNameFromClientGroupResponse(myresp){
|
||||
let clientGroupName = '-';
|
||||
if(myresp.client_group_name != null && myresp.client_group_name.length > 0){
|
||||
clientGroupName = myresp.client_group_name;
|
||||
}
|
||||
return clientGroupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get datatable row for a client group discount
|
||||
*/
|
||||
getDTRow() {
|
||||
let clientGroupDiscountRow = [
|
||||
'<div>' + this.id + '</div>',
|
||||
'<div class="selectClientGroupList" data-table="client_group_discount" data-column="fk_client_group_id" data-id="' + this.id + '" data-current="' + this.clientGroupId + '">' + this.clientGroupName + '</div>',
|
||||
'<div class="selectProductsList" data-table="client_group_discount" data-column="fk_produit_id" data-id="' + this.id + '" data-current="' + this.productId + '">' + this.productReference + '</div>',
|
||||
'<div class="editableNumeric" data-table="client_group_discount" data-column="ht_amount" data-id="' + this.id + '">' + cur.format(this.htAmount) + '</div>',
|
||||
'<div data-modifier="clientGroupDiscount" data-id=' + this.id + ' data-table="client_group_discount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
|
||||
];
|
||||
|
||||
return clientGroupDiscountRow;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} clientGroupDiscountDatatable
|
||||
*/
|
||||
static loadClientGroupDiscountDatatable(clientGroupDiscountDatatable) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/getClientGroupDiscounts', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
LoadDT(clientGroupDiscountDatatable, JSON.parse(this.response), ClientGroupDiscount);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} dt
|
||||
*/
|
||||
static createDefaultClientGroupDiscount(dt) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('POST', baseUrl + '/clientGroupDiscount/createDefaultClientGroupDiscount', true);
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
showDone()
|
||||
ClientGroupDiscount.loadClientGroupDiscountDatatable(dt);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
}
|
||||
144
gestion/src/js/objects/clientGroupFacturation.mjs
Normal file
144
gestion/src/js/objects/clientGroupFacturation.mjs
Normal file
@ -0,0 +1,144 @@
|
||||
import { showError } from "@nextcloud/dialogs";
|
||||
import { baseUrl, checkSelectPurJs, LoadDT, showDone } from "../modules/mainFunction.mjs";
|
||||
import { updateDB } from "../modules/ajaxRequest.mjs";
|
||||
|
||||
export class ClientGroupFacturation {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param myresp instantiate client group facturation object
|
||||
*/
|
||||
constructor(myresp) {
|
||||
this.id = myresp.id;
|
||||
this.clientGroupFacturationName = ((myresp.group_facturation_name.length === 0) ? '-' : myresp.group_facturation_name);
|
||||
this.phoneNumber = (myresp.phone_number != null && myresp.phone_number.length > 0) ? myresp.phone_number : '-';
|
||||
this.address = (myresp.address != null && myresp.address.length > 0) ? myresp.address : '-';
|
||||
this.postalCode = (myresp.postal_code != null && myresp.postal_code.length > 0) ? myresp.postal_code : '-';
|
||||
this.city = (myresp.city != null && myresp.city.length > 0) ? myresp.city : '-';
|
||||
this.email = (myresp.email != null && myresp.email.length > 0) ? myresp.email : '-';
|
||||
this.siretNumber = (myresp.siret_number != null && myresp.siret_number.length > 0) ? myresp.siret_number : '-';
|
||||
this.tvaIntraCommu = (myresp.tva_intracommu != null && myresp.tva_intracommu.length > 0) ? myresp.tva_intracommu : '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get datatable row for a client group facturation
|
||||
*/
|
||||
getDTRow() {
|
||||
let clientGroupFacturationRow = [
|
||||
'<div>' + this.id + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="group_facturation_name" data-id="' + this.id + '">' + this.clientGroupFacturationName + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="address" data-id="' + this.id + '">' + this.address + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="city" data-id="' + this.id + '">' + this.city + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="postal_code" data-id="' + this.id + '">' + this.postalCode + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="email" data-id="' + this.id + '">' + this.email + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="phone_number" data-id="' + this.id + '">' + this.phoneNumber + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="siret_number" data-id="' + this.id + '">' + this.siretNumber + '</div>',
|
||||
'<div class="editable" data-table="client_group_facturation" data-column="tva_intracommu" data-id="' + this.id + '">' + this.tvaIntraCommu + '</div>',
|
||||
'<div data-modifier="clientGroupFacturation" data-id=' + this.id + ' data-table="client_group_facturation" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
|
||||
];
|
||||
|
||||
return clientGroupFacturationRow;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} clientGroupFacturationDatatable
|
||||
*/
|
||||
static loadClientGroupFacturationDatatable(clientGroupFacturationDatatable) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/client/getClientGroupFacturations', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
LoadDT(clientGroupFacturationDatatable, JSON.parse(this.response), ClientGroupFacturation);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
static getClientGroupFacturations(callback){
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/client/getClientGroupFacturations', 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 {*} lid
|
||||
*/
|
||||
static loadClientGroupFacturationListToSelect(e){
|
||||
ClientGroupFacturation.getClientGroupFacturations(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.group_facturation_name;
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} dt
|
||||
*/
|
||||
static createDefaultClientGroupFacturation(dt) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('POST', baseUrl + '/client/createDefaultClientGroupFacturation', true);
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
showDone()
|
||||
ClientGroupFacturation.loadClientGroupFacturationDatatable(dt);
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
}
|
||||
18
gestion/templates/clientGroup.php
Normal file
18
gestion/templates/clientGroup.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
style('gestion', array('style'));
|
||||
script('gestion', array('clientGroup.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/clientGroup')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
18
gestion/templates/clientGroupDiscount.php
Normal file
18
gestion/templates/clientGroupDiscount.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
style('gestion', array('style'));
|
||||
script('gestion', array('clientGroupDiscount.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/clientGroupDiscount')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
18
gestion/templates/clientGroupFacturation.php
Normal file
18
gestion/templates/clientGroupFacturation.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
style('gestion', array('style'));
|
||||
script('gestion', array('clientGroupFacturation.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/clientGroupFacturation')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
25
gestion/templates/content/clientGroup.php
Normal file
25
gestion/templates/content/clientGroup.php
Normal file
@ -0,0 +1,25 @@
|
||||
<div id="contentTable">
|
||||
<div class="breadcrumb" data-html2canvas-ignore>
|
||||
<div class="crumb svg crumbhome">
|
||||
<a href="<?php echo($_['url']['index']); ?>" class="icon-home"></a>
|
||||
<span style="display: none;"></span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<span>Groupe de clients</span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<button style="margin-left:3px;" type="button" id="newClientGroup">Ajouter un groupe</button>
|
||||
</div>
|
||||
</div>
|
||||
<table id="clientGroup" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Groupe'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
27
gestion/templates/content/clientGroupDiscount.php
Normal file
27
gestion/templates/content/clientGroupDiscount.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']['index']); ?>" class="icon-home"></a>
|
||||
<span style="display: none;"></span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<span>Client remise</span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<button style="margin-left:3px;" type="button" id="newClientGroupDiscount">Ajouter un tarif</button>
|
||||
</div>
|
||||
</div>
|
||||
<table id="clientGroupDiscount" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Groupes'));?></th>
|
||||
<th><?php p($l->t('Articles'));?></th>
|
||||
<th><?php p($l->t('Unit price without VAT'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
32
gestion/templates/content/clientGroupFacturation.php
Normal file
32
gestion/templates/content/clientGroupFacturation.php
Normal file
@ -0,0 +1,32 @@
|
||||
<div id="contentTable">
|
||||
<div class="breadcrumb" data-html2canvas-ignore>
|
||||
<div class="crumb svg crumbhome">
|
||||
<a href="<?php echo($_['url']['index']); ?>" class="icon-home"></a>
|
||||
<span style="display: none;"></span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<span>Groupe facturation de clients</span>
|
||||
</div>
|
||||
<div class="crumb svg crumbhome">
|
||||
<button style="margin-left:3px;" type="button" id="newClientGroupFacturation">Ajouter un groupe de facturation</button>
|
||||
</div>
|
||||
</div>
|
||||
<table id="clientGroupFacturation" class="display tabledt">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('ID'));?></th>
|
||||
<th><?php p($l->t('Groupe'));?></th>
|
||||
<th><?php p($l->t('Adresse'));?></th>
|
||||
<th><?php p($l->t('Ville'));?></th>
|
||||
<th><?php p($l->t('Code postal'));?></th>
|
||||
<th><?php p($l->t('Email'));?></th>
|
||||
<th><?php p($l->t('Téléphone'));?></th>
|
||||
<th><?php p($l->t('Siret'));?></th>
|
||||
<th><?php p($l->t('Tva Intra-communautaire'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -31,6 +31,8 @@
|
||||
<th><?php p($l->t('Phone number'));?></th>
|
||||
<th><?php p($l->t('Email'));?></th>
|
||||
<th><?php p($l->t('Address'));?></th>
|
||||
<th><?php p($l->t('Groupes tarifaires'));?></th>
|
||||
<th><?php p($l->t('Groupes facturations'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -84,39 +84,39 @@
|
||||
</li>
|
||||
<li class="app-navigation-entry-submenu">
|
||||
<span class="navmarg icon-category-integration"></span>
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['produit']); ?>">
|
||||
<?php p($l->t('Groupe articles'));?>
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['clientGroupDiscount']); ?>">
|
||||
<?php p($l->t('Groupe Articles'));?>
|
||||
</a>
|
||||
<div class="app-navigation-entry-utils-submenu">
|
||||
<ul>
|
||||
<li class="app-navigation-entry-utils-counter">
|
||||
<span>5</span>
|
||||
<span id="clientGroupDiscountStat"><div class="loader"></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="app-navigation-entry-submenu">
|
||||
<span class="navmarg icon-category-integration"></span>
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['produit']); ?>">
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['clientGroupFacturation']); ?>">
|
||||
<?php p($l->t('Groupe clients'));?>
|
||||
</a>
|
||||
<div class="app-navigation-entry-utils-submenu">
|
||||
<ul>
|
||||
<li class="app-navigation-entry-utils-counter">
|
||||
<span>5</span>
|
||||
<span id="clientGroupFacturationStat"><div class="loader"></div></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="app-navigation-entry-submenu">
|
||||
<span class="navmarg icon-category-integration"></span>
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['produit']); ?>">
|
||||
<a class="a-entry-submenu" href="<?php echo($_['url']['clientGroups']); ?>">
|
||||
<?php p($l->t('Groupe tarifs'));?>
|
||||
</a>
|
||||
<div class="app-navigation-entry-utils-submenu">
|
||||
<ul>
|
||||
<li class="app-navigation-entry-utils-counter">
|
||||
<span>5</span>
|
||||
<span id="clientGroupStat"><div class="loader">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -29,7 +29,10 @@ module.exports =
|
||||
configuration: './src/js/configuration.js',
|
||||
pdf: './src/js/pdf.js',
|
||||
order: './src/js/order.js',
|
||||
thanatoProductFee: './src/js/thanatoProductFee.js'
|
||||
thanatoProductFee: './src/js/thanatoProductFee.js',
|
||||
clientGroupDiscount: './src/js/clientGroupDiscount.js',
|
||||
clientGroup: './src/js/clientGroup.js',
|
||||
clientGroupFacturation : './src/js/clientGroupFacturation.js'
|
||||
},
|
||||
output: {
|
||||
filename: '../js/[name].app.js',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user