diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 37a60507d015946fba1a4a7715ad415e4762e7e0..0a4ff814ec8b2b46448587a8e807c12f637bf9dd 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -681,6 +681,7 @@ if (empty($reshook)) $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); + $price_ht_devise = GETPOST('multicurrency_price_ht'); if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -712,7 +713,7 @@ if (empty($reshook)) $error ++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error ++; @@ -858,6 +859,7 @@ if (empty($reshook)) $type = GETPOST('type'); $fk_unit = GETPOST('units', 'alpha'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); } // Margin @@ -880,7 +882,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $db->commit(); @@ -959,6 +961,8 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + + $pu_ht_devise = GETPOST('multicurrency_subprice'); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); @@ -1011,7 +1015,7 @@ if (empty($reshook)) if (! $error) { $db->begin(); - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"]); + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); if ($result >= 0) { $db->commit(); @@ -2002,10 +2006,18 @@ if ($action == 'create') print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '</tr></table>'; print '</td><td>'; - if ($action == 'editmulticurrencyrate') { + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == 0) { + print '<div class="inline-block"> '; + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; + print '</div>'; + } } print '</td></tr>'; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b9f5e3be6ebe16fd326f2e5e1bf5367055cad5fa..f10d82fdbfa4b1f1aa2a00b0d580aeabe56a160c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -392,10 +392,10 @@ class Propal extends CommonObject * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @return int >0 if OK, <0 if KO - * + * @param double $pu_ht_devise Unit price in currency * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0) { global $mysoc, $conf, $langs; @@ -463,18 +463,22 @@ class Propal extends CommonObject $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; // Rang to use $rangtouse = $rang; @@ -537,7 +541,7 @@ class Propal extends CommonObject // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -607,9 +611,10 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0) { global $mysoc; @@ -647,17 +652,21 @@ class Propal extends CommonObject $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; @@ -696,7 +705,7 @@ class Propal extends CommonObject $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu; + $this->line->subprice = $pu_ht; $this->line->info_bits = $info_bits; $this->line->vat_src_code = $vat_src_code; @@ -725,7 +734,7 @@ class Propal extends CommonObject } // Multicurrency - $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d4f6b1caca477fcc4224df2aed36276de568dd2b..a535675948c124ea0e3709cbf4a5b0ed12116955 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -636,6 +636,7 @@ if (empty($reshook)) $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); + $price_ht_devise = GETPOST('multicurrency_price_ht'); if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -670,7 +671,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && (! ($price_ht_devise >= 0) || $price_ht_devise == '')) // Unit price can be 0 but not '' { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; @@ -810,6 +811,7 @@ if (empty($reshook)) $desc = $product_desc; $type = GETPOST('type'); $fk_unit=GETPOST('units', 'alpha'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); } // Margin @@ -831,7 +833,7 @@ if (empty($reshook)) setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -902,6 +904,7 @@ if (empty($reshook)) $description=dol_htmlcleanlastbr(GETPOST('product_desc')); $pu_ht=GETPOST('price_ht'); $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $pu_ht_devise = GETPOST('multicurrency_subprice'); // Define info_bits $info_bits = 0; @@ -962,7 +965,7 @@ if (empty($reshook)) } if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units')); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'),$pu_ht_devise); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -2193,10 +2196,18 @@ if ($action == 'create' && $user->rights->commande->creer) print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '</tr></table>'; print '</td><td>'; - if ($action == 'editmulticurrencyrate') { + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == 0) { + print '<div class="inline-block"> '; + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; + print '</div>'; + } } print '</td></tr>'; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 10ca4018ff529099b13df37e74ee8f17e263f1dc..e9f909564e549899c064e991c7e8dd6e5b540a85 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1225,6 +1225,7 @@ class Commande extends CommonOrder * @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $origin 'order', ... * @param int $origin_id Id of origin object + * @param double $pu_ht_devise Unit price in currency * @return int >0 if OK, <0 if KO * * @see add_product @@ -1234,7 +1235,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0) { global $mysoc, $conf, $langs, $user; @@ -1310,18 +1311,20 @@ class Commande extends CommonOrder $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; // Rang to use $rangtouse = $rang; @@ -1385,7 +1388,7 @@ class Commande extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -2767,7 +2770,7 @@ class Commande extends CommonOrder * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0) { global $conf, $mysoc, $langs, $user; @@ -2811,28 +2814,32 @@ class Commande extends CommonOrder $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; // Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser) - $price = $pu; + $price = $pu_ht; if ($price_base_type == 'TTC') { - $subprice = $tabprice[5]; + $subprice = $pu_ttc; } else { - $subprice = $pu; + $subprice = $pu_ht; } $remise = 0; if ($remise_percent > 0) @@ -2910,7 +2917,7 @@ class Commande extends CommonOrder $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->multicurrency_subprice = price2num($subprice * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0228b6a2f1f5fb038c7785448742443cdf1b459a..196c14b285e825bd295cb8fc172ea16e5882ebcf 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1349,7 +1349,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error ++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && empty($price_ht_devise)) // Unit price can be 0 but not '' + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not '' { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error ++; @@ -3244,9 +3244,11 @@ else if ($id > 0 || ! empty($ref)) $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - print '<div class="inline-block"> '; - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; - print '</div>'; + if($object->statut == 0) { + print '<div class="inline-block"> '; + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; + print '</div>'; + } } print '</td></tr>'; //} diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c3b3d97d202c08a30040167925d474f085a7193e..1afae6875ae2a9442df12211369910d428799ff4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1520,19 +1520,22 @@ abstract class CommonObject switch ($this->element) { case 'propal': - $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit); + $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); break; case 'commande': - $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit); + $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); break; case 'facture': $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); break; case 'supplier_proposal': - $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn); + $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->multicurrency_subprice); break; case 'order_supplier': - $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit); + $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + break; + case 'invoice_supplier': + $this->updateline($line->id, $line->desc, $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); break; default: dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b9619c278bd2da6cb364bd77881aa88077acbb60..85de900725e1ded3e65c4ef26a94fa7e62ecc483 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -135,6 +135,7 @@ function societe_prepare_head(Societe $object) // Bank accounrs if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { + $langs->load('banks'); $nbBankAccount=0; $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$object->id; $head[$h][1] = $langs->trans("BankAccounts"); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 80445f6d55ea5d78668033ebb2ec08860ca94105..4bbc427a525444cd5c8fdd73c65f41fafdb507ab 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1333,9 +1333,10 @@ class CommandeFournisseur extends CommonOrder * @param int $date_end Date end of service * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param string $pu_ht_devise Amount in currency * @return int <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0) { global $langs,$mysoc,$conf; @@ -1441,17 +1442,19 @@ class CommandeFournisseur extends CommonOrder $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; $localtax1_type=$localtaxes_type[0]; $localtax2_type=$localtaxes_type[2]; @@ -1498,12 +1501,12 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $this->line->subprice=$pu; + $this->line->subprice=$pu_ht; $this->line->price=$this->line->subprice; $this->line->remise_percent=$remise_percent; @@ -2247,9 +2250,10 @@ class CommandeFournisseur extends CommonOrder * @param timestamp $date_end Date end of service * @param array $array_options Extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Unit price in currency * @return int < 0 if error, > 0 if ok */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0) { global $mysoc, $conf; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); @@ -2296,22 +2300,26 @@ class CommandeFournisseur extends CommonOrder $vatrate = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; $localtax1_type=$localtaxes_type[0]; $localtax2_type=$localtaxes_type[2]; - $subprice = price2num($pu,'MU'); + $subprice = price2num($pu_ht,'MU'); $this->line=new CommandeFournisseurLigne($this->db); $this->line->fetch($rowid); @@ -2330,7 +2338,7 @@ class CommandeFournisseur extends CommonOrder $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu; + $this->line->subprice = $pu_ht; $this->line->rang = $this->rang; $this->line->info_bits = $info_bits; $this->line->total_ht = $total_ht; @@ -2349,12 +2357,12 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $this->line->subprice=$pu; + $this->line->subprice=$pu_ht; $this->line->price=$this->line->subprice; $this->line->remise_percent=$remise_percent; @@ -2367,9 +2375,11 @@ class CommandeFournisseur extends CommonOrder // Mise a jour info denormalisees au niveau facture - if (! $error) + if ($result > 0) { $this->update_price('','auto'); + $this->db->commit(); + return $result; } else { @@ -3087,10 +3097,10 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'":"null"); $sql.= ", ".($this->fk_multicurrency ? $this->fk_multicurrency : "null"); $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($this->pu_ht * $this->multicurrency_tx); - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; + $sql.= ", ".price2num($this->multicurrency_subprice); + $sql.= ", ".price2num($this->multicurrency_total_ht); + $sql.= ", ".price2num($this->multicurrency_total_tva); + $sql.= ", ".price2num($this->multicurrency_total_ttc); $sql.= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -3176,7 +3186,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ($this->fk_unit ? ", fk_unit='".$this->db->escape($this->fk_unit)."'":", fk_unit=null"); // Multicurrency - $sql.= ", multicurrency_subprice=".price2num($this->subprice * $this->multicurrency_tx).""; + $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 05148517c23ea26f032694b353e84119937af09a..8137592b41d71ae420647acf06ab60e07802a516 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1310,11 +1310,12 @@ class FactureFournisseur extends CommonInvoice * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param int $origin_id id origin document + * @param double $pu_ht_devise Amount in currency * @return int >0 if OK, <0 if KO * * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0) + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0) { dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1347,17 +1348,19 @@ class FactureFournisseur extends CommonInvoice $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; // Check parameters if ($type < 0) return -1; @@ -1379,7 +1382,7 @@ class FactureFournisseur extends CommonInvoice $this->line->fk_product=$fk_product; $this->line->product_type=$type; $this->line->remise_percent=$remise_percent; - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu):$pu); // For credit note, unit price always negative, always positive otherwise + $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->date_start=$date_start; $this->line->date_end=$date_end; $this->line->ventil=$ventil; @@ -1401,7 +1404,7 @@ class FactureFournisseur extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx); + $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -1458,9 +1461,10 @@ class FactureFournisseur extends CommonInvoice * @param timestamp $date_end Date end of service * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param double $pu_ht_devise Amount in currency * @return int <0 if KO, >0 if OK */ - public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null) + public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null, $pu_ht_devise=0) { global $mysoc; dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG); @@ -1469,9 +1473,10 @@ class FactureFournisseur extends CommonInvoice $pu = price2num($pu); $qty = price2num($qty); $remise_percent=price2num($remise_percent); + $pu_ht_devise = price2num($pu_ht_devise); // Check parameters - if (! is_numeric($pu) || ! is_numeric($qty)) return -1; + //if (! is_numeric($pu) || ! is_numeric($qty)) return -1; if ($type < 0) return -1; // Clean parameters @@ -1499,7 +1504,7 @@ class FactureFournisseur extends CommonInvoice $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -1513,6 +1518,7 @@ class FactureFournisseur extends CommonInvoice $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; if (empty($info_bits)) $info_bits=0; @@ -1558,7 +1564,7 @@ class FactureFournisseur extends CommonInvoice $line->array_options = $array_options; // Multicurrency - $line->multicurrency_subprice = price2num($line->subprice * $this->multicurrency_tx); + $line->multicurrency_subprice = $pu_ht_devise; $line->multicurrency_total_ht = $multicurrency_total_ht; $line->multicurrency_total_tva = $multicurrency_total_tva; $line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -2493,9 +2499,7 @@ class SupplierInvoiceLine extends CommonObjectLine $qty = price2num($this->qty); // Check parameters - if (! is_numeric($pu) || ! is_numeric($qty)) { - return -1; - } + if (empty($this->qty)) $this->qty=0; if ($this->product_type < 0) { return -1; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8f5d59d382e29457d884ae4f2b31b6594adb9628..ca6c2d5c885217c5949c352df5875d15ecc9e932 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -299,6 +299,7 @@ if (empty($reshook)) $qty = GETPOST('qty'.$predef); $remise_percent=GETPOST('remise_percent'.$predef); + $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields $extrafieldsline = new ExtraFields($db); @@ -322,7 +323,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='') // Unit price can be 0 but not '' + if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise === '') // Unit price can be 0 but not '' { setEventMessages($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), null, 'errors'); $error++; @@ -410,7 +411,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if ((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) + else if (empty($error)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -440,8 +441,10 @@ if (empty($reshook)) $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } + + $pu_ht_devise = price2num($price_ht_devise, 'MU'); - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); + $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise); } //print "xx".$tva_tx; exit; @@ -540,6 +543,8 @@ if (empty($reshook)) $localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty); $localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty); + + $pu_ht_devise = GETPOST('multicurrency_subprice'); // Extrafields Lines $extrafieldsline = new ExtraFields($db); @@ -568,7 +573,8 @@ if (empty($reshook)) $date_start, $date_end, $array_options, - $_POST['units'] + $_POST['units'], + $pu_ht_devise ); unset($_POST['qty']); unset($_POST['type']); @@ -1401,7 +1407,7 @@ if ($action=='create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; - if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; + if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; $note_private = $object->getDefaultCreateValueFor('note_private'); $note_public = $object->getDefaultCreateValueFor('note_public'); @@ -1594,6 +1600,8 @@ if ($action=='create') } elseif (! empty($object->id)) { + $result = $object->fetch($id, $ref); + $societe = new Fournisseur($db); $result=$societe->fetch($object->socid); if ($result < 0) dol_print_error($db); @@ -1885,10 +1893,18 @@ elseif (! empty($object->id)) print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '</tr></table>'; print '</td><td>'; - if ($action == 'editmulticurrencyrate') { + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == 0) { + print '<div class="inline-block"> '; + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; + print '</div>'; + } } print '</td></tr>'; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 12e4013a11ff8660414df4d36ec1432d2238d462..861893d1900ca29be509dfbad27ee313f4c260cd 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -804,6 +804,7 @@ if (empty($reshook)) $localtax1_tx= get_localtax($_POST['tauxtva'], 1, $mysoc,$object->thirdparty); $localtax2_tx= get_localtax($_POST['tauxtva'], 2, $mysoc,$object->thirdparty); $remise_percent=GETPOST('remise_percent'); + $pu_ht_devise = GETPOST('multicurrency_subprice'); // Extrafields Lines $extrafieldsline = new ExtraFields($db); @@ -816,7 +817,7 @@ if (empty($reshook)) } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units']); + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise); if ($result >= 0) { unset($_POST['label']); @@ -875,6 +876,7 @@ if (empty($reshook)) $qty = GETPOST('qty'.$predef); $remise_percent=GETPOST('remise_percent'.$predef); + $price_ht_devise = GETPOST('multicurrency_price_ht'); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -901,7 +903,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='') // Unit price can be 0 but not '' + if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise==='') // Unit price can be 0 but not '' { setEventMessages($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), null, 'errors'); $error++; @@ -917,7 +919,7 @@ if (empty($reshook)) $error++; } - if (GETPOST('prod_entry_mode') != 'free') // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + 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); @@ -966,7 +968,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if ($price_ht !== '' || GETPOST('price_ttc') !== '') // $price_ht is already set + else if (empty($error)) // $price_ht is already set { $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); @@ -992,8 +994,9 @@ 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_ht_devise = price2num($price_ht_devise, 'MU'); - $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); + $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_ht_devise); } //print "xx".$tva_tx; exit; @@ -2142,10 +2145,18 @@ else print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; - if ($action == 'editmulticurrencyrate') { + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if($object->statut == 0) { + print '<div class="inline-block"> '; + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; + print '</div>'; + } } print '</td></tr>'; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 72df0a27dc8f2abf6c9c3c4ac1d6fa3bc31328ab..ade5916792d71982060fec7dbe41dcae7ad0fe56 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1454,8 +1454,9 @@ else $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); - $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>'; - + $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>'; + $object->next_prev_filter=" fk_product_type = ".$object->type; + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3df1393628a602f05afedd28098a92e50cdbb12e..bf87a32f3c9f01bbb9c995355da05479711c4304 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3230,7 +3230,7 @@ class Product extends CommonObject $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; $linkclose.=' class="classfortooltip"'; if (! is_object($hookmanager)) diff --git a/htdocs/user/document.php b/htdocs/user/document.php index d19223719094c5a3e77d0843a9a97d6dad93b696..a9162767bea55acf652c6aa39d981bbf488ad5bc 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -87,7 +87,7 @@ $object = new User($db); if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - + $object->getrights(); $entitytouseforuserdir = $object->entity; if (empty($entitytouseforuserdir)) $entitytouseforuserdir=1; $upload_dir = $conf->user->multidir_output[$entitytouseforuserdir] . "/" . $object->id ; diff --git a/htdocs/user/info.php b/htdocs/user/info.php index e27fcf562667c684f41dcb2f0abd9273ef782320..5ea7200a0f7f0857c5cad79ef31fc13a5f6d506a 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -35,6 +35,7 @@ $object = new User($db); if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); + $object->getrights(); } // Security check diff --git a/htdocs/user/note.php b/htdocs/user/note.php index e2feb378f3ca92626ae15e7206e3a38cce5286a9..38aef489b87b698d33b03e5f744d93a3fa37bd94 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -37,6 +37,7 @@ $langs->load("users"); $object = new User($db); $object->fetch($id); +$object->getrights(); // If user is not user read and no permission to read other users, we stop if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden();