parent
5259819fc5
commit
5b7d358c4e
1 changed files with 0 additions and 46 deletions
|
|
@ -519,52 +519,6 @@ if (empty($reshook)) {
|
|||
// If price has changed, we update it
|
||||
if (!array_key_exists($key, $object->multiprices) || $object->multiprices[$key] != $newprice || $object->multiprices_min[$key] != $newprice_min || $object->multiprices_base_type[$key] != $val['price_base_type'] || $object->multiprices_tva_tx[$key] != $newvattx) {
|
||||
$res = $object->updatePrice((float) $newprice, $val['price_base_type'], $user, (float) $val['vat_tx'], (float) $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array'], $val['default_vat_code'], $val['price_label']);
|
||||
if ($res > 0) {
|
||||
$extralabels = $extrafields->fetch_name_optionals_label("product");
|
||||
if (!getDolGlobalString('PRODUIT_MULTIPRICES') && !getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') && !empty($extralabels)) {
|
||||
// Default price
|
||||
$extrafield_values = $extrafields->getOptionalsFromPost("product");
|
||||
foreach ($extrafield_values as $efkey => $value) {
|
||||
$object->array_options[$efkey] = $value;
|
||||
}
|
||||
$result = $object->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
} elseif ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($extralabels)) {
|
||||
$price_extralabels = $extrafields->fetch_name_optionals_label("product_price");
|
||||
$sql = "SELECT rowid";
|
||||
$sql .= " FROM ".$object->db->prefix()."product_price";
|
||||
$sql .= " WHERE entity IN (".getEntity('productprice').")";
|
||||
$sql .= " AND price_level=".((int) $key); // $i
|
||||
$sql .= " AND fk_product = ".((int) $object->id);
|
||||
$sql .= " ORDER BY date_price DESC, rowid DESC";
|
||||
$sql .= " LIMIT 1";
|
||||
$resql = $object->db->query($sql);
|
||||
if ($resql) {
|
||||
$lineid = $object->db->fetch_object($resql);
|
||||
$db->free($resql);
|
||||
}
|
||||
if (!empty($lineid->rowid)) {
|
||||
if (!empty($price_extralabels) && is_array($price_extralabels)) {
|
||||
foreach ($price_extralabels as $code => $label) {
|
||||
$code_array = GETPOST($code, 'array');
|
||||
$object->array_options['options_'.$code] = $code_array[$key];
|
||||
}
|
||||
// We need to force table to update product_price and not product extrafields
|
||||
$object->id = $lineid->rowid;
|
||||
$object->table_element = 'product_price';
|
||||
$result = $object->insertExtraFields();
|
||||
}
|
||||
// Back to product table
|
||||
$object->id = $id;
|
||||
$object->table_element = 'product';
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue