|
@@ -1233,6 +1233,20 @@ if (empty($reshook)) {
|
|
$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_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'));
|
|
$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'));
|
|
|
|
|
|
|
|
+ // Prepare a price equivalent for minimum price check
|
|
|
|
+ $pu_equivalent = $pu_ht;
|
|
|
|
+ $pu_equivalent_ttc = $pu_ttc;
|
|
|
|
+ $currency_tx = $object->multicurrency_tx;
|
|
|
|
+
|
|
|
|
+ // Check if we have a foreing currency
|
|
|
|
+ // If so, we update the pu_equiv as the equivalent price in base currency
|
|
|
|
+ if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') {
|
|
|
|
+ $pu_equivalent = $pu_ht_devise * $currency_tx;
|
|
|
|
+ }
|
|
|
|
+ if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
|
|
|
+ $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Local Taxes
|
|
// Local Taxes
|
|
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
|
|
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
|
|
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
|
|
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
|
|
@@ -1246,11 +1260,11 @@ if (empty($reshook)) {
|
|
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
|
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
|
|
|
|
|
if ($usermustrespectpricemin) {
|
|
if ($usermustrespectpricemin) {
|
|
- if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
|
|
|
|
|
+ if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
setEventMessages($mesg, null, 'errors');
|
|
setEventMessages($mesg, null, 'errors');
|
|
$error++;
|
|
$error++;
|
|
- } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
|
|
|
|
+ } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
setEventMessages($mesg, null, 'errors');
|
|
setEventMessages($mesg, null, 'errors');
|
|
$error++;
|
|
$error++;
|
|
@@ -1349,6 +1363,20 @@ if (empty($reshook)) {
|
|
|
|
|
|
$remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
|
$remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
|
|
|
|
|
|
|
+ // Prepare a price equivalent for minimum price check
|
|
|
|
+ $pu_equivalent = $pu_ht;
|
|
|
|
+ $pu_equivalent_ttc = $pu_ttc;
|
|
|
|
+ $currency_tx = $object->multicurrency_tx;
|
|
|
|
+
|
|
|
|
+ // Check if we have a foreing currency
|
|
|
|
+ // If so, we update the pu_equiv as the equivalent price in base currency
|
|
|
|
+ if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') {
|
|
|
|
+ $pu_equivalent = $pu_ht_devise * $currency_tx;
|
|
|
|
+ }
|
|
|
|
+ if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
|
|
|
+ $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Extrafields
|
|
// Extrafields
|
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
|
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
|
|
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
|
|
@@ -1388,12 +1416,12 @@ if (empty($reshook)) {
|
|
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
|
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
|
|
|
|
|
if ($usermustrespectpricemin) {
|
|
if ($usermustrespectpricemin) {
|
|
- if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
|
|
|
|
|
+ if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
setEventMessages($mesg, null, 'errors');
|
|
setEventMessages($mesg, null, 'errors');
|
|
$error++;
|
|
$error++;
|
|
$action = 'editline';
|
|
$action = 'editline';
|
|
- } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
|
|
|
|
+ } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
setEventMessages($mesg, null, 'errors');
|
|
setEventMessages($mesg, null, 'errors');
|
|
$error++;
|
|
$error++;
|