Merge branch 'features/feature-discount-per-client-group-per-produit' into staging

This commit is contained in:
Tiavina 2025-01-07 10:31:31 +03:00
commit 8998a606fe
41 changed files with 820 additions and 57 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'],
@ -124,6 +126,12 @@ return [
//SQL
['name' => 'page#addDevisNumberColumn', 'url' => '/addDevisNumberColumn', 'verb' => 'POST'],
['name' => 'page#addFactureNumberColumn', 'url' => '/addFactureNumberColumn', 'verb' => 'POST'],
['name' => 'page#addClientGroupDiscountFeatureTables', 'url' => '/addClientGroupDiscountFeatureTables', '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

View File

@ -379,6 +379,7 @@ class PageController extends Controller {
public function getNavigationLink(){
return array(
"index" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.index"),
"clientGroups" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroups"),
"defunt" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.defunt"),
"devis" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.devis"),
"thanatopracteur" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.thanatopracteur"),
@ -386,6 +387,7 @@ class PageController extends Controller {
"lieu" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.lieu"),
"facture" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.facture"),
"produit" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.produit"),
"clientGroupDiscount" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.clientGroupDiscount"),
"article" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.article"),
"bibliotheque" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.bibliotheque"),
"config" => $this->urlGenerator->linkToRouteAbsolute("gestion.page.config"),
@ -2078,6 +2080,8 @@ class PageController extends Controller {
$res['produit'] = json_decode($this->myDb->numberProduit($this->idNextcloud))[0]->c;
$res['article'] = json_decode($this->myDb->numberArticle($this->idNextcloud))[0]->c;
$res['bibliotheque'] = json_decode($this->myDb->numberBibliotheque($this->idNextcloud))[0]->c;
$res['clientGroup'] = json_decode($this->myDb->getClientGroupCount())[0]->c;
$res['clientGroupDiscount'] = json_decode($this->myDb->getClientGroupDiscountCount())[0]->c;
return json_encode($res);
}
@ -2824,4 +2828,69 @@ class PageController extends Controller {
catch(\OCP\Files\NotFoundException $e) { }
}
/**
* @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->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->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 addClientGroupDiscountFeatureTables(){
try{
$this->myDb->addClientGroupDiscountFeatureTables();
return true;
}
catch(\OCP\Files\NotFoundException $e) { }
}
}

View File

@ -13,8 +13,9 @@ class Bdd {
private String $charset = 'utf8mb4';
public const DEFAULT_CALENDAR_UUID_FOR_DEVIS = "not-related";
public const CALENDAR_TABLE_PREFIX = "*PREFIX*";
public const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
private IDbConnection $pdo;
private array $whiteColumn;
private array $whiteTable;
@ -34,8 +35,11 @@ class Bdd {
"injection", "injection_diffusion", "injection_qte", "preinjection", "preinjection_qte", "coinjection", "coinjection_qte",
"drainage", "drainage_qte", "drainage_etat", "ponction", "ponction_qte", "cavite", "cavite_qte", "desinfection", "lavage",
"rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu",
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit");
$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");
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
"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",
"client_group_discount","client_group");
$this->tableprefix = '*PREFIX*' ."gestion_";
$this->pdo = $db;
$this->l = $l;
@ -62,7 +66,30 @@ 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'] : '';
}
}
return json_encode($clients);
}
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 getClientsName(){
@ -549,8 +576,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) {
@ -2136,18 +2180,53 @@ class Bdd {
produit.prix_unitaire as produit_price,
produit.reference as produit_reference,
produit.description as produit_description,
produit.vat as produit_vat
produit.vat as produit_vat,
devis.id_client as devis_client_id
FROM ".$this->tableprefix ."produit_devis as produit_devis
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
LEFT JOIN ".$this->tableprefix."devis as devis on produit_devis.devis_id = devis.id
WHERE produit_devis.devis_id = ?;";
$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;
}
private 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;
}
private function getProductPriceByClient($productId,$clientId,$productInitialPrice){
$client = $this->getClientById($clientId);
if($client != null){
$productDiscountPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$productId);
$productInitialPrice = $productDiscountPrice ?? $productInitialPrice;
}
return $productInitialPrice;
}
private function getDevisProductsQuantityByDevisListAndProductId($devisList,$productId){
if(empty($devisList)){
return 0;
@ -2245,7 +2324,8 @@ class Bdd {
client.id,
client.nom as client_nom,
client.prenom as client_prenom,
client.entreprise as client_entreprise
client.entreprise as client_entreprise,
client.fk_client_group_id as fk_client_group_id
FROM ".$this->tableprefix."client as client
WHERE client.id = ?;";
$clientList = $this->execSQLNoJsonReturn(
@ -2256,7 +2336,7 @@ class Bdd {
return $clientList[0];
}
return $clientList;
return null;
}
public function getClientsByClientsID(array $clientIds){
@ -2515,6 +2595,83 @@ class Bdd {
return null;
}
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(self::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 addClientGroupDiscountFeatureTables(){
$createTableClientGroupSQL = "CREATE TABLE oc_gestion_client_group (
id INT PRIMARY KEY AUTO_INCREMENT,
client_group_name VARCHAR(255) DEFAULT ''
);";
$this->execSQLNoData($createTableClientGroupSQL,[]);
$addColumnFkClientGroupIdIntoClientTableSQL= "ALTER TABLE oc_gestion_client
ADD fk_client_group_id INT NULL;";
$this->execSQLNoData($addColumnFkClientGroupIdIntoClientTableSQL,[]);
$createTableClientGroupDiscountSQL = "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
);";
$this->execSQLNoData($createTableClientGroupDiscountSQL,[]);
return true;
}
}

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

@ -14,6 +14,8 @@ import { Thanatopracteur } from "../objects/thanatopracteur.mjs";
import { Article } from "../objects/article.mjs";
import { Defunt } from "../objects/defunt.mjs";
import { Bibliotheque } from "../objects/bibliotheque.mjs";
import { ClientGroup } from '../objects/clientGroup.mjs';
import { ClientGroupDiscount } from "../objects/clientGroupDiscount.mjs";
var choose_folder = t('gestion', 'Choose work folder');
@ -52,7 +54,14 @@ document.body.addEventListener('click', e => {
Thanatopracteur.loadThanatoList_tid(e);
}else if(e.target.className.includes("loadSelect_listlieu")){
Lieu.loadLieuList_lid(e);
}else if(e.target.className.includes("loadSelect_listdevis")){
}
else if(e.target.className.includes("selectClientGroupList")){
ClientGroup.loadClientGroupListToSelect(e);
}
else if(e.target.className.includes("selectProductsList")){
Produit.loadProductListToSelect(e);
}
else if(e.target.className.includes("loadSelect_listdevis")){
Devis.loadDevisList_dnum(e);
}else if(e.target.className.includes("loadSelect_listalldevis")){
Devis.loadAllDevisList_dnum(e);
@ -81,6 +90,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) {
@ -209,6 +224,8 @@ $('body').on('click', '.deleteItem', function () {
if (modifier === "article") { Article.loadArticleDT(dt); }
if (modifier === "defunt") { Defunt.loadDefuntDT(dt); }
if (modifier === "bibliotheque") { Bibliotheque.loadBibliothequeDT(dt); }
if (modifier === "clientGroup") { ClientGroup.loadClientGroupDatatable(dt); }
if (modifier === "clientGroupDiscount") { ClientGroupDiscount.loadClientGroupDiscountDatatable(dt); }
});
$('body').on('change', '.listClient,.listDevis', function () {

View File

@ -79,6 +79,8 @@ export function getStats() {
$("#statsproduit").text(res.produit);
$("#statsarticles").text(res.article);
$("#statsbibliotheque").text(res.bibliotheque);
$("#clientGroupStat").text(res.clientGroup);
$("#clientGroupDiscountStat").text(res.clientGroupDiscount);
}).fail(function (response, code) {
showError(response);
});

View File

@ -16,6 +16,13 @@ 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;
}
/**
@ -32,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;
@ -128,32 +136,6 @@ export class Client {
});
}
/**
*
*/
// static loadClientList() {
// Client.getClients(function (response) {
// var listClients = document.querySelectorAll(".listClient");
// listClients.forEach(selectElement => {
// removeOptions(selectElement);
// var option = document.createElement("option");
// option.value = 0;
// option.text = t('gestion', 'Choose customer');
// selectElement.appendChild(option);
// JSON.parse(response).forEach(myresp => {
// var option = document.createElement("option");
// option.value = myresp.id;
// option.text = myresp.prenom + ' ' + myresp.nom;
// selectElement.appendChild(option);
// });
// checkSelectPurJs(selectElement);
// });
// });
// }
/**
*
* @param {*} cid
@ -203,4 +185,5 @@ export class Client {
e.target.appendChild(selectElement);
});
}
}

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

@ -1,5 +1,6 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { baseUrl, cur, checkSelectPurJs, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { updateDB } from "../modules/ajaxRequest.mjs";
export class Produit {
@ -63,4 +64,70 @@ export class Produit {
};
oReq.send();
}
static getProductsList(callback){
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getProduits', 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 loadProductListToSelect(e){
Produit.getProductsList(response => {
var selectElement = document.createElement("select");
selectElement.dataset.current = e.target.dataset.current;
selectElement.dataset.id = e.target.dataset.id;
selectElement.dataset.old = e.target.innerHTML;
selectElement.addEventListener("change", el=>{
if(el.target.value != 0){
updateDB(el.target.parentElement.dataset.table,
el.target.parentElement.dataset.column,
el.target.value,
el.target.parentElement.dataset.id
);
// location.reload();
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
parentElement.dataset.current = el.target.value;
}else{
var parentElement = el.target.parentElement
parentElement.innerHTML = el.target.dataset.old
}
});
var option = document.createElement("option");
option.value = 0;
option.text = t('gestion', 'Cancel');
selectElement.appendChild(option);
JSON.parse(response).forEach(myresp => {
var txt = document.createElement("textarea");
txt.innerHTML = myresp.reference;
var option = document.createElement("option");
option.value = myresp.id;
option.text = txt.value;
selectElement.appendChild(option);
});
checkSelectPurJs(selectElement);
e.target.innerHTML = ''
e.target.appendChild(selectElement);
});
}
}

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'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>
</thead>

View File

@ -39,6 +39,13 @@
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a class="a-entry" href="<?php echo($_['url']['clientGroups']); ?>"><?php p($l->t('Groupes'));?></a>
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-counter"><span id="clientGroupStat"><div class="loader"></div></span></li>
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a href="<?php echo($_['url']['thanatopracteur']); ?>">Thanatopracteurs</a>
<div class="app-navigation-entry-utils">
<ul>
@ -88,6 +95,13 @@
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-category-integration"></span><a href="<?php echo($_['url']['clientGroupDiscount']); ?>">Tarifs groupes</a>
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-counter"><span id="clientGroupDiscountStat"><div class="loader"></div></span></li>
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-category-integration"></span><a href="<?php echo($_['url']['article']); ?>">Produits</a>
<div class="app-navigation-entry-utils">
<ul>

View File

@ -27,6 +27,8 @@ module.exports =
legalnotice: './src/js/legalnotice.js',
adminSection: './src/js/adminSection.js',
configuration: './src/js/configuration.js',
clientGroupDiscount: './src/js/clientGroupDiscount.js',
clientGroup: './src/js/clientGroup.js',
pdf: './src/js/pdf.js',
},
output: {