This commit is contained in:
Laurent Destailleur 2021-03-02 23:09:55 +01:00
parent 8fc89b9ef1
commit 7eb3e324c7
12 changed files with 56 additions and 57 deletions

View File

@ -796,9 +796,9 @@ if (empty($reshook))
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ?GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'));
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
@ -1153,10 +1153,11 @@ if (empty($reshook))
{
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', GETPOST('tva_tx')))
if (preg_match('/\*/', GETPOST('tva_tx'))) {
$info_bits |= 0x01;
}
// Clean parameters
// Clean parameters
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
// Define vat_rate
@ -1164,13 +1165,13 @@ if (empty($reshook))
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
// 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');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
$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'));

View File

@ -632,8 +632,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
@ -989,14 +989,15 @@ if (empty($reshook))
$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'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
if (preg_match('/\*/', $vat_rate)) {
$info_bits |= 0x01;
}
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);

View File

@ -438,8 +438,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -724,10 +724,10 @@ if (empty($reshook))
//$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'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;

View File

@ -1895,8 +1895,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'));
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -2216,10 +2216,10 @@ if (empty($reshook))
$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'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;

View File

@ -384,8 +384,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU'));
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
if (GETPOST('prod_entry_mode', 'alpha') == 'free')
{
$idprod = 0;
@ -638,8 +638,9 @@ if (empty($reshook))
$vat_rate = GETPOST('eltva_tx');
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
if (preg_match('/\*/', $vat_rate)) {
$info_bits |= 0x01;
}
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);
@ -658,10 +659,12 @@ if (empty($reshook))
}
// ajout prix d'achat
$fk_fournprice = $_POST['fournprice'];
if (!empty($_POST['buying_price']))
$pa_ht = $_POST['buying_price'];
else $pa_ht = null;
$fk_fournprice = GETPOST('fournprice');
if (GETPOST('buying_price')) {
$pa_ht = price2num(GETPOST('buying_price'), '', 2);
} else {
$pa_ht = null;
}
$fk_unit = GETPOST('unit', 'alpha');

View File

@ -4871,7 +4871,7 @@ function price2num($amount, $rounding = '', $option = 0)
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
}
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come from input data, so 1.123 is 1123
$amount = str_replace($thousand, '', $amount);
}

View File

@ -576,14 +576,12 @@ if (empty($reshook))
*/
elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) {
$objectline = new FichinterLigne($db);
if ($objectline->fetch($lineid) <= 0)
{
if ($objectline->fetch($lineid) <= 0) {
dol_print_error($db);
exit;
}
if ($object->fetch($objectline->fk_fichinter) <= 0)
{
if ($object->fetch($objectline->fk_fichinter) <= 0) {
dol_print_error($db);
exit;
}
@ -603,8 +601,7 @@ if (empty($reshook))
$objectline->array_options = $array_options;
$result = $objectline->update($user);
if ($result < 0)
{
if ($result < 0) {
dol_print_error($db);
exit;
}
@ -614,8 +611,7 @@ if (empty($reshook))
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}

View File

@ -363,17 +363,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -689,7 +689,7 @@ if (empty($reshook))
if (GETPOST('price_ht') != '')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
$ht = price2num(GETPOST('price_ht'), '', 2);
} else {
$vatratecleaned = $vat_rate;
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)"
@ -698,12 +698,12 @@ if (empty($reshook))
$vatratecode = $reg[2];
}
$ttc = price2num(GETPOST('price_ttc'));
$ttc = price2num(GETPOST('price_ttc'), '', 2);
$ht = $ttc / (1 + ($vatratecleaned / 100));
$price_base_type = 'HT';
}
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Extrafields Lines
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -462,13 +462,13 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne
$qty = $supplierorderdispatch->qty;
$entrepot = $supplierorderdispatch->fk_entrepot;
$product = $supplierorderdispatch->fk_product;
$price = GETPOST('price');
$price = price2num(GETPOST('price'), '', 2);
$comment = $supplierorderdispatch->comment;
$eatby = $supplierorderdispatch->fk_product;
$sellby = $supplierorderdispatch->sellby;
$batch = $supplierorderdispatch->batch;
$supplierorderdispatch->qty = GETPOST('qty', 'int');
$supplierorderdispatch->qty = price2num(GETPOST('qty', 'alpha'), 'MS', 2);
$supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot');
$result = $supplierorderdispatch->update($user);
}

View File

@ -1079,12 +1079,11 @@ if (empty($reshook))
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '')
{
$up = price2num(GETPOST('price_ht'));
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') {
$up = price2num(GETPOST('price_ht'), '', 2);
$price_base_type = 'HT';
} else {
$up = price2num(GETPOST('price_ttc'));
$up = price2num(GETPOST('price_ttc'), '', 2);
$price_base_type = 'TTC';
}
@ -1183,17 +1182,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -423,7 +423,6 @@ if ($object->id > 0)
print '</tr>';
// Line to add a new line in inventory
//if ($action == 'addline') {
if ($object->status == $object::STATUS_VALIDATED) {
print '<tr>';
print '<td>';

View File

@ -547,17 +547,17 @@ if (empty($reshook))
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') {
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -853,7 +853,7 @@ if (empty($reshook))
if (GETPOST('price_ht') != '')
{
$ht = price2num(GETPOST('price_ht'));
$ht = price2num(GETPOST('price_ht'), '', 2);
}
if (GETPOST('price_ttc') != '')
@ -866,7 +866,7 @@ if (empty($reshook))
$vatratecode = $reg[2];
}
$ttc = price2num(GETPOST('price_ttc'));
$ttc = price2num(GETPOST('price_ttc'), '', 2);
$ht = $ttc / (1 + ($vatratecleaned / 100));
}