From 5d7d21087d780fc722881eb4fb5dbd8e98bd53be Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 1 Jan 2025 16:42:26 +0300 Subject: [PATCH] devis numero devis table label , facture user_id --- gestion/lib/Db/Bdd.php | 20 +++++++++++++------- gestion/templates/content/devis.php | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index f8e6b4a..a7d36c4 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -1764,14 +1764,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; + } + + 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 $max; + return $lastId; } public function backup(){ diff --git a/gestion/templates/content/devis.php b/gestion/templates/content/devis.php index 5ce3ca3..e933fdb 100644 --- a/gestion/templates/content/devis.php +++ b/gestion/templates/content/devis.php @@ -34,7 +34,7 @@ t('A facturer'));?> t('ID'));?> - t('Num'));?> + t('Numéro de devis'));?> t('Quote date'));?> Défunt t('Customer quote'));?>