Merge branch 'features/feature-add-client-group-tarif' into features/feature-client-group-facturation-and-tarif

This commit is contained in:
Tiavina 2025-02-10 15:22:12 +03:00
commit b91373abde
44 changed files with 716 additions and 44 deletions

View File

@ -15,6 +15,8 @@ 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#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
@ -158,5 +160,11 @@ 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'],
]
];

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

View 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

View 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

View File

@ -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,8 @@ 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;
return json_encode($res);
}
@ -2807,4 +2823,54 @@ 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();
}
}

View File

@ -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;
@ -355,7 +357,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 +409,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 +568,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 +1504,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 +2321,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 +2696,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 +2871,71 @@ 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;
}
}

View File

@ -55,6 +55,8 @@ 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"),
);
}

View File

@ -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
);

View 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));
});

View 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));
});

View File

@ -17,6 +17,8 @@ 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";
var choose_folder = t('gestion', 'Choose work folder');
@ -75,6 +77,9 @@ 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("selectProductsList")){
Produit.loadProductListToSelect(e);
}
@ -106,6 +111,12 @@ 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("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 +249,8 @@ $('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); }
});
$('body').on('change', '.listClient,.listDevis', function () {

View File

@ -81,6 +81,8 @@ export function getStats() {
$("#statsbibliotheque").text(res.bibliotheque);
$("#thanatoProductFeeStat").text(res.thanatoProductFee);
$("#orderStat").text(res.order);
$("#clientGroupStat").text(res.clientGroup);
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
}).fail(function (response, code) {
showError(response);
});

View File

@ -17,6 +17,12 @@ 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);
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;
}
/**
@ -33,6 +39,7 @@ 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>',
'<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;

View 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();
}
}

View 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();
}
}

View 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>

View 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>

View 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>

View 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>

View File

@ -31,6 +31,7 @@
<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('Actions'));?></th>
</tr>
</thead>

View File

@ -84,13 +84,13 @@
</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>
@ -110,13 +110,13 @@
</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>

View File

@ -29,7 +29,9 @@ 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'
},
output: {
filename: '../js/[name].app.js',