|
@@ -191,12 +191,17 @@ if (empty($reshook)) {
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
}
|
|
|
|
|
|
- if ($error) {
|
|
|
+ if (!$error) {
|
|
|
// Force the update of the price of the product to 0 if error
|
|
|
|
|
|
//$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2);
|
|
|
$localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them.
|
|
|
- $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode);
|
|
|
+ $ret = $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode);
|
|
|
+
|
|
|
+ if ($ret < 0) {
|
|
|
+ $error++;
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!$error) {
|
|
@@ -463,13 +468,21 @@ if (empty($reshook)) {
|
|
|
if ($action == 'activate_price_by_qty') {
|
|
|
// Activating product price by quantity add a new price line with price_by_qty set to 1
|
|
|
$level = GETPOST('level', 'int');
|
|
|
- $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
|
|
|
+ $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
|
|
|
+
|
|
|
+ if ($ret < 0) {
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
// Unset Price by quantity
|
|
|
if ($action == 'disable_price_by_qty') {
|
|
|
// Disabling product price by quantity add a new price line with price_by_qty set to 0
|
|
|
$level = GETPOST('level', 'int');
|
|
|
- $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0);
|
|
|
+ $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0);
|
|
|
+
|
|
|
+ if ($ret < 0) {
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité
|
|
@@ -1603,13 +1616,17 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
// On l'ajoute donc pour remettre a niveau (pb vieilles versions)
|
|
|
// We emulate the change of the price from interface with the same value than the one into table llx_product
|
|
|
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
|
|
|
- $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1);
|
|
|
+ $ret = $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1);
|
|
|
} else {
|
|
|
- $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min));
|
|
|
+ $ret = $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min));
|
|
|
}
|
|
|
|
|
|
- $result = $db->query($sql);
|
|
|
- $num = $db->num_rows($result);
|
|
|
+ if ($ret < 0) {
|
|
|
+ dol_print_error($db, $object->error, $object->errors);
|
|
|
+ } else {
|
|
|
+ $result = $db->query($sql);
|
|
|
+ $num = $db->num_rows($result);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($num > 0) {
|