From c3d4cd85f17f4c223112573979763bef78fdb05d Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 15 Apr 2016 12:28:35 +0200 Subject: [PATCH 1/2] NEW hidden feature: SUPPLIERORDER_WITH_NOPRICEDEFINED allow supplier order even if no supplier price defined --- htdocs/core/class/html.form.class.php | 13 +++++++++++-- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 9 +++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 393560b4640..702b44c468e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1968,14 +1968,23 @@ class Form if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - // mode=2 means suppliers products + if (!empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED)) + { + print ''; + } + // mode=2 means suppliers products $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished; print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; } else { - print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0); + if (!empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED)) + { + print ''; + print ''; + } + print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0); } } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c757efa23b4..3cab39b0d0b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -176,7 +176,7 @@ else { else { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key + 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' ); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e988893dbb4..39858256ced 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1268,7 +1268,7 @@ class CommandeFournisseur extends CommonOrder { $this->db->begin(); - if ($fk_product > 0) + if ($fk_prod_fourn_price > 0) { $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 904cd5b3133..d114e9c06fc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -306,10 +306,15 @@ if (empty($reshook)) // Ecrase $txtva par celui du produit if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { - $idprod=0; $productsupplier = new ProductFournisseur($db); - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + if (empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED)) + { + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } + + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { From ec5e0e5290b250a92643e72a41a3ad21d753bebd Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 15 Apr 2016 12:32:36 +0200 Subject: [PATCH 2/2] forgot one line --- htdocs/fourn/commande/card.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index d114e9c06fc..91f6aa9041b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -314,8 +314,6 @@ if (empty($reshook)) if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) } - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - if (GETPOST('idprodfournprice') > 0) { $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.