From 15e1d3b45685e47705d52d2c58a63fea2b3537df Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 24 Jan 2019 09:40:58 +0100 Subject: [PATCH 1/4] Fix fetch test --- .../class/fournisseur.commande.class.php | 95 ++++++++++--------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d07c3347146..ef22d5bd8f8 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3016,49 +3016,58 @@ class CommandeFournisseurLigne extends CommonOrderLine $result = $this->db->query($sql); if ($result) { - $objp = $this->db->fetch_object($result); - - $this->rowid = $objp->rowid; - $this->id = $objp->rowid; - $this->fk_commande = $objp->fk_commande; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->ref_fourn = $objp->ref; - $this->ref_supplier = $objp->ref; - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->localtax1_type = $objp->localtax1_type; - $this->localtax2_type = $objp->localtax2_type; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_localtax1 = $objp->total_localtax1; - $this->total_localtax2 = $objp->total_localtax2; - $this->total_ttc = $objp->total_ttc; - $this->product_type = $objp->product_type; - $this->special_code = $objp->special_code; - - $this->ref = $objp->product_ref; - $this->product_ref = $objp->product_ref; - $this->product_libelle = $objp->product_libelle; - $this->product_desc = $objp->product_desc; - - $this->date_start = $this->db->jdate($objp->date_start); - $this->date_end = $this->db->jdate($objp->date_end); - $this->fk_unit = $objp->fk_unit; - - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - - $this->db->free($result); - return 1; + if ($this->db->num_rows($result)) + { + $objp = $this->db->fetch_object($result); + + $this->rowid = $objp->rowid; + $this->id = $objp->rowid; + $this->fk_commande = $objp->fk_commande; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->ref_fourn = $objp->ref; + $this->ref_supplier = $objp->ref; + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_localtax1 = $objp->total_localtax1; + $this->total_localtax2 = $objp->total_localtax2; + $this->total_ttc = $objp->total_ttc; + $this->product_type = $objp->product_type; + $this->special_code = $objp->special_code; + + $this->ref = $objp->product_ref; + $this->product_ref = $objp->product_ref; + $this->product_libelle = $objp->product_libelle; + $this->product_desc = $objp->product_desc; + + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->fk_unit = $objp->fk_unit; + + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + + $this->db->free($result); + return 1; + } + else + { + $this->error='Supplier order line with id='.$rowid.' not found'; + dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); + return 0; + } } else { From 9a666b265f922e28f8e23e8f895bdeca74b5a3d0 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 28 Jan 2019 11:53:19 +0100 Subject: [PATCH 2/4] Use an other test --- htdocs/fourn/class/fournisseur.commande.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ef22d5bd8f8..a4283ee5162 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3016,9 +3016,11 @@ class CommandeFournisseurLigne extends CommonOrderLine $result = $this->db->query($sql); if ($result) { - if ($this->db->num_rows($result)) + $objp = $this->db->fetch_object($result); + + if (!empty($objp)) { - $objp = $this->db->fetch_object($result); + $this->rowid = $objp->rowid; $this->id = $objp->rowid; From 09ba059c2198c0c59dcaa305283793fba3ae0de0 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 11:03:06 +0100 Subject: [PATCH 3/4] FIX : need an order by in case we found other invoice with same number but not same date --- htdocs/core/modules/facture/mod_facture_mars.php | 1 + htdocs/core/modules/facture/mod_facture_terre.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 831dce5d3e4..08edc1b6b90 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -178,6 +178,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 174d8314784..61a2f04c891 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -194,6 +194,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); From caa937660d4b26b7e6e04407e92610da34095c50 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 12:43:39 +0100 Subject: [PATCH 4/4] FIX : wrong test enabled --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8c2bfb8090a..7a56d73afff 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1725,7 +1725,7 @@ if ($action == 'create') } // Create an order - if (! empty($conf->commande->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { + if (! empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($user->rights->fournisseur->commande->creer) { print ''; }