diff --git a/ChangeLog b/ChangeLog index c90df6510fe..4de2b1fc745 100644 --- a/ChangeLog +++ b/ChangeLog @@ -283,7 +283,7 @@ The following changes may create regressions for some external modules, but were * Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT * The delete() method of AdherentType, Contact, Delivery, MultiCurrency, CurrencyRate now need $user as first parameter. * A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english. - +* The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases. ***** ChangeLog for 18.0.4 compared to 18.0.3 ***** FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 02dd3b8ea30..a0a2a5a4c5f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1190,6 +1190,10 @@ if (empty($reshook)) { if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 76bc245fd4d..64d2f2637ae 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2218,6 +2218,10 @@ if (empty($reshook)) { if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); @@ -2309,8 +2313,10 @@ if (empty($reshook)) { $type = $prod->type; $fk_unit = $prod->fk_unit; } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($price_ttc, 'MU'); + if (!empty($price_ht)) $pu_ht = price2num($price_ht, 'MU'); + else $pu_ht = ''; + if (!empty($price_ttc)) $pu_ttc = price2num($price_ttc, 'MU'); + else $pu_ttc = ''; $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); if (empty($tva_tx)) { @@ -2336,8 +2342,8 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); - $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + $pu_ht_devise = price2num($price_ht_devise, '', 2); + $pu_ttc_devise = price2num($price_ttc_devise, '', 2); // Prepare a price equivalent for minimum price check $pu_equivalent = $pu_ht; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 4d2c36a0fb5..40e8c0178ec 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1116,7 +1116,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Check if Extrafields is totalizable if (!empty($extrafields->attributes['projet_task']['totalizable'])) { foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { - if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { + if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) { print ''; if ($value == 1) { print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c3647f5f316..0441eee03f4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -692,6 +692,7 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { jQuery("#price_ttc").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#price_ttc").keyup(function(event) { @@ -699,11 +700,19 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) { if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#multicurrency_subprice").keyup(function(event) { // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_subprice").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } + }); + jQuery("#multicurrency_price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_price_ht").val() != '') { jQuery("#price_ht").val(''); jQuery("#price_ttc").val(''); } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b0fd9dfe7d6..01ddb66dc6e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1791,7 +1791,7 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_devise = price2num($price_devise, 'CU'); + $pu_devise = price2num($price_ht_devise, 'CU'); $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 33a549c7e18..45da3187671 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2213,17 +2213,18 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $key => $value) { + $key = preg_replace('/[^a-z0-9_\.\-\[\]]/i', '', $key); if (in_array($key, array('action', 'massaction', 'password'))) { continue; } if (!is_array($value)) { if ($value !== '') { - $qs .= '&'.$key.'='.urlencode($value); + $qs .= '&'.urlencode($key).'='.urlencode($value); } } else { foreach ($value as $value2) { if (($value2 !== '') && (!is_array($value2))) { - $qs .= '&'.$key.'[]='.urlencode($value2); + $qs .= '&'.urlencode($key).'[]='.urlencode($value2); } } } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index cbf0c406139..a67f3b2edbe 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -68,7 +68,7 @@ class FormProduct * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true * @param array $exclude warehouses ids to exclude - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @throws Exception @@ -276,7 +276,7 @@ class FormProduct * @param string $morecss Add more css classes to HTML select * @param array $exclude Warehouses ids to exclude * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @param int $multiselect 1=Allow multiselect * @return string HTML select diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 15763089bcf..3e0d45f75f4 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5924,7 +5924,6 @@ class Product extends CommonObject $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } - $hookmanager->initHooks(array('productdao')); $parameters = array('id'=>$this->id, 'includedraftpoforvirtual' => $includedraftpoforvirtual); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index df69727b960..a7a44ed2861 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -504,8 +504,11 @@ if (empty($reshook)) { $newobject->fetch_optionals(); $newobject->fetch_thirdparty(); // Load new object $object = $newobject; - $action = 'edit'; + $action = 'view'; $comefromclone = true; + + setEventMessages($langs->trans("ProjectCreatedInDolibarr", $newobject->ref), "", 'mesgs'); + //var_dump($newobject); exit; } }