diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 19161ae1325..1c2a8e9cdb5 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -190,6 +190,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', 1, $invoice).")"; + $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 1c19d564486..f74213b32ef 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -205,6 +205,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', 1, $invoice).")"; + $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 38fa5b53699..4e3b275080b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3245,49 +3245,58 @@ class CommandeFournisseurLigne extends CommonOrderLine { $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; + if (!empty($objp)) + { + $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->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->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->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->fetch_optionals(); - $this->fetch_optionals(); - - $this->db->free($result); - return 1; + $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 { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 729899a8ff2..fe336187918 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -59,18 +59,18 @@ $search_deliveryday=GETPOST("search_deliveryday","int"); $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_product_category=GETPOST('search_product_category','int'); -$search_ref=GETPOST('search_ref'); -$search_refsupp=GETPOST('search_refsupp'); +$search_ref=GETPOST('search_ref','alpha'); +$search_refsupp=GETPOST('search_refsupp','alpha'); $search_company=GETPOST('search_company','alpha'); $search_town=GETPOST('search_town','alpha'); $search_zip=GETPOST('search_zip','alpha'); -$search_state=trim(GETPOST("search_state")); +$search_state=trim(GETPOST("search_state",'alpha')); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_user=GETPOST('search_user','int'); $search_request_author=GETPOST('search_request_author','alpha'); -$search_ht=GETPOST('search_ht'); -$search_ttc=GETPOST('search_ttc'); +$search_ht=GETPOST('search_ht','alpha'); +$search_ttc=GETPOST('search_ttc','alpha'); $search_status=(GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); // alpha and not intbecause it can be '6,7' $optioncss = GETPOST('optioncss','alpha'); $socid = GETPOST('socid','int'); diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 2f272b73059..26aac5c881e 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2014-2016 Charlie BENKE * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,12 +173,12 @@ $total=0; if ($type == '0') { print $statProducts; - $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2]); + $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2])+round($prodser[0][3]); } else if ($type == '1') { print $statServices; - $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2]); + $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[1][3]); } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 5ed5a10cfda..29a181985a9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1801,7 +1801,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 ''; }