finish tarifs features, WIP tarfis stat and group stat

This commit is contained in:
Tiavina 2025-01-07 09:48:48 +03:00
parent 16d9430140
commit 668d55ac79
32 changed files with 122 additions and 43 deletions

View File

@ -130,5 +130,7 @@ return [
//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

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

@ -2858,4 +2858,22 @@ class PageController extends Controller {
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

@ -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","fk_client_group_id","fk_produit_id");
$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");
"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;
@ -2606,6 +2610,7 @@ class Bdd {
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(
@ -2616,10 +2621,22 @@ class Bdd {
}
public function getClientGroups(){
$sql = "SELECT * FROM ".$this->tableprefix."client_group as client_group;";
$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;
}
}

View File

@ -15,6 +15,7 @@ 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');
@ -89,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) {

View File

@ -19,8 +19,8 @@ export class ClientGroup {
getDTRow() {
let clientGroupRow = [
'<div>' + this.id + '</div>',
'<div data-id="' + this.id + '">' + this.clientGroupName + '</div>',
'<div data-id=' + this.id + ' data-table="clientGroupDiscount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
'<div class="editable" data-table="client_group" data-column="client_group_name" data-id="' + this.id + '">' + this.clientGroupName + '</div>',
'<div data-id=' + this.id + ' data-table="client_group" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
return clientGroupRow;
@ -127,4 +127,22 @@ export class ClientGroup {
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

@ -1,5 +1,6 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, cur, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { ClientGroup } from "./clientGroup.mjs";
export class ClientGroupDiscount {
@ -9,11 +10,27 @@ export class ClientGroupDiscount {
*/
constructor(myresp) {
this.id = myresp.id;
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name);
this.productReference = ((myresp.produit_reference.length === 0) ? '-' : myresp.produit_reference);
this.htAmount = ((myresp.ht_amount.length === 0) ? '-' : myresp.ht_amount);
this.clientGroupId = myresp.produit_reference.fk_client_group_id;
this.productId = myresp.produit_reference.fk_produit_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;
}
/**
@ -24,8 +41,8 @@ export class ClientGroupDiscount {
'<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 data-id="' + this.id + '">' + this.htAmount + '</div>',
'<div data-id=' + this.id + ' data-table="clientGroupDiscount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
'<div class="editableNumeric" data-table="client_group_discount" data-column="ht_amount" data-id="' + this.id + '">' + cur.format(this.htAmount) + '</div>',
'<div data-id=' + this.id + ' data-table="client_group_discount" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
return clientGroupDiscountRow;
@ -53,13 +70,13 @@ export class ClientGroupDiscount {
*
* @param {*} dt
*/
static newProduct(dt) {
static createDefaultClientGroupDiscount(dt) {
var oReq = new XMLHttpRequest();
oReq.open('POST', baseUrl + '/produit/insert', true);
oReq.open('POST', baseUrl + '/clientGroupDiscount/createDefaultClientGroupDiscount', true);
oReq.onload = function(e){
if (this.status == 200) {
showDone()
Produit.loadProduitDT(dt);
ClientGroupDiscount.loadClientGroupDiscountDatatable(dt);
}else{
showError(this.response);
}

View File

@ -1,5 +1,5 @@
import { showError } from "@nextcloud/dialogs";
import { baseUrl, checkSelectPurJs, 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 {

View File

@ -8,7 +8,7 @@
<span>Groupe de clients</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="addClientGroupDiscount">Ajouter un groupe</button>
<button style="margin-left:3px;" type="button" id="newClientGroup">Ajouter un groupe</button>
</div>
</div>
<table id="clientGroup" class="display tabledt">

View File

@ -8,14 +8,14 @@
<span>Client remise</span>
</div>
<div class="crumb svg crumbhome">
<button style="margin-left:3px;" type="button" id="addClientGroupDiscount">Ajouter une ligne</button>
<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('Client'));?></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>

View File

@ -95,7 +95,7 @@
</ul>
</div>
</li>
<li class="app-navigation-entry"><span class="navmarg icon-category-integration"></span><a href="<?php echo($_['url']['clientGroupDiscount']); ?>">Remise clients</a>
<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="statsclient"><div class="loader"></div></span></li>