diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a64a166d7af..6b6faa5732f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -680,6 +680,24 @@ else if ($action == "addline" && $user->rights->propale->creer) $price_base_type = $prod->price_base_type; } + // Update if prices fields are defined + if (GETPOST('dp_price_ht') || GETPOST('dp_price_ttc')) + { + $price_ht=price2num(GETPOST('dp_price_ht'), 'MU'); + $price_ttc=price2num(GETPOST('dp_price_ttc'), 'MU'); + + if ($price_base_type == 'TTC' && $price_ttc != $pu_ttc) + { + $pu_ttc = $price_ttc; + $pu_ht = price2num($price_ttc / (1 + ($prod->tva_tx / 100)),'MU'); + } + else if ($price_base_type != 'TTC' && $price_ht != $pu_ht) + { + $pu_ht = $price_ht; + $pu_ttc = price2num($price_ht * (1 + ($prod->tva_tx / 100)),'MU'); + } + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($tva_tx != $prod->tva_tx) @@ -714,19 +732,23 @@ else if ($action == "addline" && $user->rights->propale->creer) $desc = $prod->description; } - $desc.= ($desc && GETPOST('np_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('np_desc')))?"
\n":"\n") : ""; - $desc.= GETPOST('np_desc'); + $desc.= ($desc && GETPOST('dp_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('dp_desc')))?"
\n":"\n") : ""; + $desc.= GETPOST('dp_desc'); $type = $prod->type; + $fournprice=(GETPOST('dp_fournprice')?GETPOST('dp_fournprice'):''); + $buyingprice=(GETPOST('dp_buying_price')?GETPOST('dp_buying_price'):''); } else { $pu_ht=GETPOST('np_price'); $tva_tx=str_replace('*','',GETPOST('np_tva_tx')); $tva_npr=preg_match('/\*/',GETPOST('np_tva_tx'))?1:0; - $desc=GETPOST('dp_desc'); + $desc=GETPOST('np_desc'); $type=GETPOST('type'); $localtax1_tx=get_localtax($tva_tx,1,$object->client); $localtax2_tx=get_localtax($tva_tx,2,$object->client); + $fournprice=(GETPOST('np_fournprice')?GETPOST('np_fournprice'):''); + $buyingprice=(GETPOST('np_buying_price')?GETPOST('np_buying_price'):''); } $info_bits=0; @@ -757,8 +779,8 @@ else if ($action == "addline" && $user->rights->propale->creer) -1, 0, GETPOST('fk_parent_line'), - GETPOST('np_fournprice'), - GETPOST('np_buying_price') + $fournprice, + $buyingprice ); if ($result > 0) @@ -781,11 +803,17 @@ else if ($action == "addline" && $user->rights->propale->creer) unset($_POST['qty']); unset($_POST['type']); + unset($_POST['np_price']); - unset($_POST['dp_desc']); unset($_POST['np_tva_tx']); unset($_POST['np_desc']); + unset($_POST['np_fournprice']); unset($_POST['np_buying_price']); + + unset($_POST['dp_desc']); + unset($_POST['dp_price']); + unset($_POST['dp_fournprice']); + unset($_POST['dp_buying_price']); } else { @@ -914,8 +942,8 @@ else if ($action == 'remove_file' && $user->rights->propale->creer) $upload_dir = $conf->propal->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3d62245868f..69efb5ea5b2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1080,15 +1080,16 @@ class Form * @param int $finished 2=all, 1=finished, 0=raw material * @param string $selected_input_value Value of preselected input text (with ajax) * @param int $hidelabel Hide label + * @param array $ajaxoptions Options for ajax_autocompleter * @return void */ - function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0) + function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array()) { global $langs,$conf; $price_level = (! empty($price_level) ? $price_level : 0); - if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { if ($selected && empty($selected_input_value)) { @@ -1098,7 +1099,8 @@ class Form $selected_input_value=$product->ref; } // mode=1 means customers products - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); + $urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished; + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); if (! $hidelabel) print $langs->trans("RefOrLabel").' : '; print ''; } @@ -1131,13 +1133,13 @@ class Form $sql = "SELECT "; $sql.= " p.rowid, p.label, p.ref, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.duration, p.stock"; // Multilang : we add translation - if ($conf->global->MAIN_MULTILANGS) + if (! empty($conf->global->MAIN_MULTILANGS)) { $sql.= ", pl.label as label_translated"; } $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; // Multilang : we add translation - if ($conf->global->MAIN_MULTILANGS) + if (! empty($conf->global->MAIN_MULTILANGS)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'"; } @@ -1162,13 +1164,13 @@ class Form if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index { $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'"; + if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$filterkey."%'"; $sql.=")"; } else { $sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'"; - if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; + if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '%".$filterkey."%'"; $sql.=")"; } } @@ -1194,6 +1196,9 @@ class Form $outkey=''; $outval=''; $outref=''; + $outprice_ht=''; + $outprice_ttc=''; + $outpricebasetype=''; $objp = $this->db->fetch_object($result); @@ -1206,7 +1211,7 @@ class Form $opt = '