Merge pull request #5011 from altatof/supplierorder_noprice

NEW hidden feature: SUPPLIERORDER_WITH_NOPRICEDEFINED
This commit is contained in:
Laurent Destailleur 2016-04-22 18:27:42 +02:00
commit 1de36d6501
4 changed files with 19 additions and 7 deletions

View File

@ -2060,14 +2060,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 '<input type="hidden" id="idprod" name="idprod" value="0" />';
}
// 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").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'">';
}
else
{
print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0);
if (!empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED))
{
print '<input type="hidden" id="idprod" name="idprod" value="0" />';
print '<script type="text/javascript">$("#'.$htmlname.'").change(function() { $("#idprod").val($(this).val());});</script>';
}
print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0);
}
}

View File

@ -183,7 +183,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'
);

View File

@ -1353,7 +1353,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)

View File

@ -344,11 +344,14 @@ 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') > 0)
{
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.