Merge branch 'fixes/fix-num-devis-num-facture' into staging

This commit is contained in:
Tiavina 2025-01-01 17:33:38 +03:00
commit 801efcdc79
27 changed files with 123 additions and 42 deletions

View File

@ -34,6 +34,7 @@ return [
['name' => 'page#getDevis', 'url' => '/getDevis', 'verb' => 'PROPFIND'],
['name' => 'page#getDevisDelphine', 'url' => '/getDevisDelphine/{idtrajetdetails}', 'verb' => 'PROPFIND'],
['name' => 'page#getDevisWithProduits', 'url' => '/getDevisWithProduits', 'verb' => 'PROPFIND'],
['name' => 'page#devisshow', 'url' => '/devis/{numdevis}/show', 'verb' => 'GET'],
['name' => 'page#insertDevis', 'url' => '/devis/insert', 'verb' => 'POST'],
['name' => 'page#insertProduitDevis', 'url' => '/insertProduitDevis', 'verb' => 'POST'],
@ -59,6 +60,7 @@ return [
['name' => 'page#insertLieu', 'url' => '/lieu/insert', 'verb' => 'POST'],
['name' => 'page#getFactures', 'url' => '/getFactures', 'verb' => 'PROPFIND'],
['name' => 'page#getFacturesWithProduits', 'url' => '/getFacturesWithProduits', 'verb' => 'PROPFIND'],
['name' => 'page#factureshow', 'url' => '/facture/{numfacture}/show', 'verb' => 'GET'],
['name' => 'page#apercustoutesfactures', 'url' => '/factures/apercus', 'verb' => 'GET'],
['name' => 'page#apercustousdevis', 'url' => '/devis/apercus', 'verb' => 'GET'],

View File

@ -139,6 +139,11 @@
max-width: 300px;
}
.devisOrFactureInputDate{
min-width: 120px !important;
max-width: 120px !important;
}
.configuration-global{
margin-top:15px;
}

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

@ -1251,6 +1251,14 @@ class PageController extends Controller {
return $this->myDb->getDevis($this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getDevisWithProduits(){
return $this->myDb->getDevisWithProduits($this->idNextcloud);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
@ -1312,6 +1320,18 @@ class PageController extends Controller {
return $result;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getFacturesWithProduits() {
$result = $this->myDb->getFacturesWithProduits($this->idNextcloud);
$this->refreshFEC();
return $result;
}
private function synchronize_facture() {
$factures = json_decode($this->myDb->getFactures($this->idNextcloud));
foreach ($factures as $key => $facture) {

View File

@ -215,6 +215,16 @@ class Bdd {
return $this->execSQL($sql, array());
}
public function getDevisWithProduits($idNextcloud){
$devis = $this->getDevis($idNextcloud);
$devisList = json_decode($devis);
foreach($devisList as $currentDevis){
$produits = $this->getProduitsDevisByDevisId($currentDevis->devisid);
$currentDevis->produits = $produits;
}
return json_encode($devisList);
}
public function getDevisEmmanuelle($idNextcloud){
$sql = "SELECT ".$this->tableprefix."devis.id, ".$this->tableprefix."devis.id as devisid, ".$this->tableprefix."devis.user_id,".$this->tableprefix."devis.id_nextcloud ,".$this->tableprefix."devis.comment ,"
.$this->tableprefix."client.nom, ".$this->tableprefix."client.prenom, ".$this->tableprefix."client.id as cid, ".$this->tableprefix."client.id as id_client, "
@ -271,6 +281,16 @@ class Bdd {
return $result;
}
public function getFacturesWithProduits($idNextCloud){
$factures = $this->getFactures($idNextCloud);
$facturesList = json_decode($factures);
foreach($facturesList as $currentFacture){
$produits = $this->getProduitsDevisByDevisId($currentFacture->id_devis);
$currentFacture->produits = $produits;
}
return json_encode($facturesList);
}
public function getCurrentMonthFactures_byClient($idNextcloud, $date, $idclient) {
$sql = "SELECT YEAR(".$this->tableprefix."facture.date_paiement) AS year, MONTH(".$this->tableprefix."facture.date_paiement) AS month,"
.$this->tableprefix."facture.id, ".$this->tableprefix."facture.user_id, ".$this->tableprefix."facture.num, ".$this->tableprefix."facture.date, "
@ -1764,14 +1784,20 @@ class Bdd {
}
public function lastNumFacture($idNextcloud) {
$factures = json_decode($this->getFactures($idNextcloud));
$max = 5977;
foreach ($factures as $key => $facture) {
$numsplit = explode('/', $facture->num);
$num = (int) $numsplit[2];
$max = ($max<=$num)?$num:$max;
$lastFactureId = $this->getLastFactureId();
return $lastFactureId;
}
return $max;
private function getLastFactureId(){
$sql = "SELECT
max(facture.id) as LAST_FACTURE_ID FROM "
. $this->tableprefix."facture as facture;";
$res = $this->execSQLNoJsonReturn($sql,[]);
$lastId = 0;
if(!empty($res)){
$lastId = $res[0]['LAST_FACTURE_ID'];
}
return $lastId;
}
public function backup(){

View File

@ -23,9 +23,20 @@ export class Devis {
this.tid = ((myresp.tid == null || myresp.tid.length === 0) ? '-' : myresp.tid);
this.nom = ((myresp.nom == null || myresp.nom.length === 0) ? '-' : myresp.nom);
this.prenom = ((myresp.prenom == null || myresp.prenom.length === 0) ? '-' : myresp.prenom);
let thanatoPrenom = "";
let thanatoNom = "";
let thanatoFullName = "";
this.nomThanato = Devis.getDevisThanatoFullname(myresp);
this.version = ((myresp.version == null || myresp.version.length === 0) ? '-' : myresp.version);
this.lieu = ((myresp.lieu == null || myresp.lieu.length === 0) ? '-' : myresp.lieu);
this.mentions = ((myresp.mentions == null || myresp.mentions.length === 0) ? '-' : myresp.mentions);
this.baseUrl = generateUrl(`/apps/gestion/devis/${this.id}/show`);
this.devisFullNumber = ((myresp.devis_full_number != null && myresp.mentions.devis_full_number != 0) ? myresp.devis_full_number : '-');
this.devisProduits = Devis.getDevisProduitsString(myresp);
}
static getDevisThanatoFullname(myresp){
let thanatoPrenom = '';
let thanatoNom = '';
let thanatoFullName = '';
if(myresp.nom_thanato != null && myresp.nom_thanato.length != 0){
thanatoNom = myresp.nom_thanato;
thanatoFullName += thanatoNom;
@ -37,12 +48,22 @@ export class Devis {
}
thanatoFullName += thanatoPrenom;
}
this.nomThanato = (thanatoFullName.length === 0) ? '-' : thanatoFullName;
this.version = ((myresp.version == null || myresp.version.length === 0) ? '-' : myresp.version);
this.lieu = ((myresp.lieu == null || myresp.lieu.length === 0) ? '-' : myresp.lieu);
this.mentions = ((myresp.mentions == null || myresp.mentions.length === 0) ? '-' : myresp.mentions);
this.baseUrl = generateUrl(`/apps/gestion/devis/${this.id}/show`);
this.devisFullNumber = ((myresp.devis_full_number != null && myresp.mentions.devis_full_number != 0) ? myresp.devis_full_number : '-');
return (thanatoFullName.length === 0) ? '-' : thanatoFullName;
}
static getDevisProduitsString(myresp){
let devisProduitsAsString = '';
if(myresp.produits != null && myresp.produits.length > 0){
let devisProduits = myresp.produits;
let devisProduitsLength = devisProduits.length;
for (let i = 0; i < devisProduitsLength; i++) {
devisProduitsAsString += devisProduits[i].produit_reference;
if(i != devisProduitsLength - 1){
devisProduitsAsString += '-';
}
}
}
return devisProduitsAsString.length === 0 ? '-' : devisProduitsAsString;
}
/**undefined
@ -55,12 +76,13 @@ export class Devis {
'<input class="devisToFacture" data-id= '+ this.user_id + ' type="checkbox" name="devisToFacture" value="' + this.id + '"/>',
'<div>' + this.user_id + '</div>',
'<div>' + this.devisFullNumber + '</div>',
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' + this.date + ' data-table="devis" data-column="date" data-id="' + this.id + '"/>',
'<input style="margin:0;padding:0;" class="inputDate devisOrFactureInputDate" type="date" value=' + this.date + ' data-table="devis" data-column="date" data-id="' + this.id + '"/>',
// '<div class="editable" data-table="devis" data-column="num" data-id="' + this.id + '" style="display:inline">' + this.num + '</div>',
'<div class="loadSelect_listdefunt" data-table="devis" data-column="id_defunt" data-id="' + this.id + '" data-current="' + this.id_defunt + '">'+ this.id_defunt + ' (' + this.nom_defunt + ')</div>',
'<div class="loadSelect_listclient" data-table="devis" data-column="id_client" data-id="' + this.id + '" data-current="' + this.cid + '">'+ this.cid + ' (' + this.prenom + ' ' + this.nom + ')</div>',
'<div class="loadSelect_listthanato" data-table="devis" data-column="id_thanato" data-id="' + this.id + '" data-current="' + this.tid + '">'+ this.tid + ' (' + this.nomThanato+ ')</div>',
'<div class="loadSelect_listlieu" data-table="devis" data-column="id_lieu" data-id="' + this.id + '" data-current="' + this.lid + '">' + this.lieu + '</div>',
'<div>' + this.devisProduits + '</div>',
(this.mentions == "factur&eacute;")?('<div data-table="devis" data-column="mentions" data-id="' + this.id +'" style="display:inline; border-radius: 5px; padding: 8px;background-color:green !important; color: white">'+ this.mentions + '</div>'):('<div data-table="devis" data-column="mentions" data-id="' + this.id +'" style="display:inline; border-radius: 5px; padding: 8px;background-color:yellow !important">'+ this.mentions + '</div>'),
'<div style="display:inline-block;margin-right:0px;width:80%;"><a href="' + this.baseUrl + '"><button>' + t('gestion', 'Open') + '</button></a></div><div data-modifier="devis" data-id=' + this.id + ' data-table="devis" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
];
@ -91,10 +113,11 @@ export class Devis {
*/
static loadDevisDT(devisDT) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getDevis', true);
oReq.open('PROPFIND', baseUrl + '/getDevisWithProduits', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {
console.log(this.response);
// let devis_temp = (JSON.parse(JSON.parse(this.response))).filter((d)=>(d.mentions != "factur&eacute;"));
// devis_temp = JSON.stringify(JSON.stringify(devis_temp));
LoadDT(devisDT, JSON.parse(this.response), Devis);

View File

@ -1,6 +1,7 @@
import { showError } from "@nextcloud/dialogs";
import { generateUrl } from "@nextcloud/router";
import { baseUrl, LoadDT, showDone } from "../modules/mainFunction.mjs";
import { Devis } from "./devis.mjs";
export class Facture {
@ -24,6 +25,7 @@ export class Facture {
this.status_paiement = ((myresp.status_paiement == null || myresp.status_paiement.length === 0) ? '-' : myresp.status_paiement);
this.id_devis = ((myresp.id_devis == null || myresp.id_devis.length === 0) ? '-' : myresp.id_devis);
this.baseUrl = generateUrl(`/apps/gestion/facture/${this.id}/show`);
this.factureProduits = Devis.getDevisProduitsString(myresp);
}
/**
@ -33,11 +35,12 @@ export class Facture {
let myrow = [
'<div>' + this.user_id + '</div>',
'<div class="factureNum" data-table="facture" data-column="num" data-id="' + this.id + '">' + this.num + '</div>',
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' + this.date + ' data-table="facture" data-column="date" data-id="' + this.id + '"/>',
'<input style="margin:0;padding:0;" class="inputDate" type="date" value=' + this.date_paiement + ' data-table="facture" data-column="date_paiement" data-id="' + this.id + '"/>',
'<input style="margin:0;padding:0;" class="inputDate devisOrFactureInputDate" type="date" value=' + this.date + ' data-table="facture" data-column="date" data-id="' + this.id + '"/>',
'<input style="margin:0;padding:0;" class="inputDate devisOrFactureInputDate" type="date" value=' + this.date_paiement + ' data-table="facture" data-column="date_paiement" data-id="' + this.id + '"/>',
'<div class="editable" data-table="facture" data-column="type_paiement" data-id="' + this.id + '">' + this.type_paiement + '</div>',
'<div class="loadSelect_listdevis" data-table="facture" data-column="id_devis" data-id="' + this.id + '" data-current="' + this.id_devis + '">' + this.nom_defunt + ' | <span style="font-size: 0.7rem">' + this.prenom + ' ' + this.nom + '</span></div>',
'<div class="" data-table="facture" data-column="" data-id="' + this.id + '" style="display:inline">' + this.lieu + '</div>',
'<div>' + this.factureProduits + '</div>',
'<div class="editable" data-table="facture" data-column="status_paiement" data-id="' + this.id + '" style="display:inline">' + this.status_paiement + '</div>',
'<div style="display:inline-block;margin-right:0px;width:80%;"><a href="' + this.baseUrl +'"><button>' + t('gestion', 'Open') + '</button></a></div><div data-modifier="facture" data-id=' + this.id + ' data-table="facture" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>',
];
@ -46,7 +49,7 @@ export class Facture {
static loadFactureDT(factureDT) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getFactures', true);
oReq.open('PROPFIND', baseUrl + '/getFacturesWithProduits', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){
if (this.status == 200) {

View File

@ -32,14 +32,15 @@
<table id="devis" class="display tabledt devisDataTable">
<thead>
<tr>
<th><?php p($l->t('A facturer'));?></th>
<th></th>
<th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Num'));?></th>
<th><?php p($l->t('Numéro de devis'));?></th>
<th><?php p($l->t('Quote date'));?></th>
<th>Défunt</th>
<th><?php p($l->t('Customer quote'));?></th>
<th>Thanatopracteur</th>
<th>Lieu</th>
<th><?php p($l->t('Articles'));?></th>
<!-- <th>Chambre funéraire</th> -->
<th><?php p($l->t('Status'));?></th>
<th><?php p($l->t('Actions'));?></th>

View File

@ -32,6 +32,7 @@
<th><?php p($l->t('Means of payment'));?></th>
<th>Devis associé</th>
<th>Lieu</th>
<th><?php p($l->t('Articles'));?></th>
<th><?php p($l->t('Status'));?></th>
<th><?php p($l->t('Actions'));?></th>
</tr>