|
@@ -192,15 +192,50 @@ if (empty($reshook)) {
|
|
|
}
|
|
|
|
|
|
if (!$error) {
|
|
|
- // Force the update of the price of the product to 0 if error
|
|
|
+ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
|
|
|
+ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
|
|
+ // Force the update of the price of the product using the new VAT
|
|
|
+ if ($object->multiprices_base_type[$i] == 'HT') {
|
|
|
+ $oldprice = $object->multiprices[$i];
|
|
|
+ $oldminprice = $object->multiprices_min[$i];
|
|
|
+ } else {
|
|
|
+ $oldprice = $object->multiprices_ttc[$i];
|
|
|
+ $oldminprice = $object->multiprices_min_ttc[$i];
|
|
|
+ }
|
|
|
+ $oldpricebasetype = $object->multiprices_base_type[$i];
|
|
|
+ $oldnpr = $object->multiprices_recuperableonly[$i];
|
|
|
|
|
|
- //$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.
|
|
|
- $ret = $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode);
|
|
|
+ //$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.
|
|
|
+ $level = $i;
|
|
|
+ $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
|
|
|
|
|
|
- if ($ret < 0) {
|
|
|
- $error++;
|
|
|
- setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ if ($ret < 0) {
|
|
|
+ $error++;
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // Force the update of the price of the product using the new VAT
|
|
|
+ if ($object->price_base_type == 'HT') {
|
|
|
+ $oldprice = $object->price;
|
|
|
+ $oldminprice = $object->price_min;
|
|
|
+ } else {
|
|
|
+ $oldprice = $object->price_ttc;
|
|
|
+ $oldminprice = $object->price_min_ttc;
|
|
|
+ }
|
|
|
+ $oldpricebasetype = $object->price_base_type;
|
|
|
+ $oldnpr = $object->tva_npr;
|
|
|
+
|
|
|
+ //$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.
|
|
|
+ $level = 0;
|
|
|
+ $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
|
|
|
+
|
|
|
+ if ($ret < 0) {
|
|
|
+ $error++;
|
|
|
+ setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1602,6 +1637,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
}
|
|
|
$sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
|
|
|
// $sql .= $db->plimit();
|
|
|
+ //print $sql;
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
if ($result) {
|
|
@@ -1640,8 +1676,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png');
|
|
|
}
|
|
|
|
|
|
- print '<div class="div-table-responsive">';
|
|
|
- print '<table class="liste centpercent">';
|
|
|
+ print '<!-- List of log prices -->'."\n";
|
|
|
+ print '<div class="div-table-responsive">'."\n";
|
|
|
+ print '<table class="liste centpercent">'."\n";
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
|
@@ -1659,6 +1696,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
}
|
|
|
print '<td class="right">'.$langs->trans("HT").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("TTC").'</td>';
|
|
|
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
+ print '<td class="right">'.$langs->trans("INCT").'</td>';
|
|
|
+ }
|
|
|
if (!empty($conf->dynamicprices->enabled)) {
|
|
|
print '<td class="right">'.$langs->trans("PriceExpressionSelected").'</td>';
|
|
|
}
|
|
@@ -1725,6 +1765,24 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
print "</td>";
|
|
|
}
|
|
|
|
|
|
+ // Line for default price
|
|
|
+ if ($objp->price_base_type == 'HT') {
|
|
|
+ $pu = $objp->price;
|
|
|
+ } else {
|
|
|
+ $pu = $objp->price_ttc;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code.
|
|
|
+ $localtaxarray = getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc);
|
|
|
+ // Define part of HT, VAT, TTC
|
|
|
+ $resultarray = calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray);
|
|
|
+ // Calcul du total ht sans remise
|
|
|
+ $total_ht = $resultarray[0];
|
|
|
+ $total_vat = $resultarray[1];
|
|
|
+ $total_localtax1 = $resultarray[9];
|
|
|
+ $total_localtax2 = $resultarray[10];
|
|
|
+ $total_ttc = $resultarray[2];
|
|
|
+
|
|
|
// Price
|
|
|
if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
|
|
|
$price_expression = new PriceExpression($db);
|
|
@@ -1732,32 +1790,46 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
|
|
$title = $price_expression->title;
|
|
|
print '<td class="right"></td>';
|
|
|
print '<td class="right"></td>';
|
|
|
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
+ print '<td class="right"></td>';
|
|
|
+ }
|
|
|
print '<td class="right">'.$title."</td>";
|
|
|
} else {
|
|
|
+ // Price HT
|
|
|
print '<td class="right">';
|
|
|
if (empty($objp->price_by_qty)) {
|
|
|
print price($objp->price);
|
|
|
}
|
|
|
print "</td>";
|
|
|
+ // Price TTC
|
|
|
print '<td class="right">';
|
|
|
if (empty($objp->price_by_qty)) {
|
|
|
- print price($objp->price_ttc);
|
|
|
+ $price_ttc = $objp->price_ttc;
|
|
|
+ print price($price_ttc);
|
|
|
}
|
|
|
print "</td>";
|
|
|
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
+ print '<td class="right">';
|
|
|
+ print $resultarray[2];
|
|
|
+ print '</td>';
|
|
|
+ }
|
|
|
if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled
|
|
|
print '<td class="right"></td>';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Price min
|
|
|
print '<td class="right">';
|
|
|
if (empty($objp->price_by_qty)) {
|
|
|
print price($objp->price_min);
|
|
|
}
|
|
|
print '</td>';
|
|
|
|
|
|
+ // Price min inc tax
|
|
|
print '<td class="right">';
|
|
|
if (empty($objp->price_by_qty)) {
|
|
|
- print price($objp->price_min_ttc);
|
|
|
+ $price_min_ttc = $objp->price_min_ttc;
|
|
|
+ print price($price_min_ttc);
|
|
|
}
|
|
|
print '</td>';
|
|
|
|
|
@@ -2042,11 +2114,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("HT").'</td>';
|
|
|
+ print '<td class="right">'.$langs->trans("TTC").'</td>';
|
|
|
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
- //print '<td class="right">' . $langs->trans("INCVATONLY") . '</td>';
|
|
|
print '<td class="right">'.$langs->trans("INCT").'</td>';
|
|
|
- } else {
|
|
|
- print '<td class="right">'.$langs->trans("TTC").'</td>';
|
|
|
}
|
|
|
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
|
@@ -2107,11 +2177,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
print "</td>";
|
|
|
print '<td class="right">'.price($line->price)."</td>";
|
|
|
|
|
|
+ print '<td class="right">'.price($line->price_ttc)."</td>";
|
|
|
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
- //print '<td class="right">' . price($line->price_ttc) . "</td>";
|
|
|
print '<td class="right">'.price($resultarray[2]).'</td>';
|
|
|
- } else {
|
|
|
- print '<td class="right">'.price($line->price_ttc)."</td>";
|
|
|
}
|
|
|
|
|
|
print '<td class="right">'.price($line->price_min).'</td>';
|
|
@@ -2154,12 +2222,15 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
|
|
|
|
|
- print '<div class="div-table-responsive-no-min">';
|
|
|
- print '<table class="liste centpercent">';
|
|
|
+ print '<!-- List of prices per customer -->'."\n";
|
|
|
+ print '<div class="div-table-responsive-no-min">'."\n";
|
|
|
+ print '<table class="liste centpercent">'."\n";
|
|
|
|
|
|
if (count($prodcustprice->lines) > 0 || $search_soc) {
|
|
|
$colspan = 9;
|
|
|
- //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++;
|
|
|
+ if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
+ $colspan++;
|
|
|
+ }
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" name="search_soc" value="'.$search_soc.'" size="20"></td>';
|
|
@@ -2179,13 +2250,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("HT").'</td>';
|
|
|
+ print '<td class="right">'.$langs->trans("TTC").'</td>';
|
|
|
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
- //print '<td class="right">' . $langs->trans("INCVATONLY") . '</td>';
|
|
|
print '<td class="right">'.$langs->trans("INCT").'</td>';
|
|
|
- } else {
|
|
|
- print '<td class="right">'.$langs->trans("TTC").'</td>';
|
|
|
}
|
|
|
-
|
|
|
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
|
|
print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
|
|
@@ -2199,7 +2267,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
$pu = $object->price_ttc;
|
|
|
}
|
|
|
|
|
|
- // Local tax is not saved into table of product. We use value linked to VAT code.
|
|
|
+ // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code.
|
|
|
$localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc);
|
|
|
// Define part of HT, VAT, TTC
|
|
|
$resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
|
|
@@ -2237,14 +2305,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
|
|
|
print '<td class="right">'.price($object->price)."</td>";
|
|
|
|
|
|
+ print '<td class="right">'.price($object->price_ttc)."</td>";
|
|
|
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
//print '<td class="right">' . price($object->price_ttc) . "</td>";
|
|
|
print '<td class="right">'.price($resultarray[2]).'</td>';
|
|
|
- } else {
|
|
|
- print '<td class="right">'.price($object->price_ttc)."</td>";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
print '<td class="right">'.price($object->price_min).'</td>';
|
|
|
print '<td class="right">'.price($object->price_min_ttc).'</td>';
|
|
|
print '<td class="right">';
|
|
@@ -2315,11 +2381,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
|
|
print "</td>";
|
|
|
print '<td class="right">'.price($line->price)."</td>";
|
|
|
|
|
|
+ print '<td class="right">'.price($line->price_ttc)."</td>";
|
|
|
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
|
|
//print '<td class="right">' . price($line->price_ttc) . "</td>";
|
|
|
print '<td class="right">'.price($resultarray[2]).'</td>';
|
|
|
- } else {
|
|
|
- print '<td class="right">'.price($line->price_ttc)."</td>";
|
|
|
}
|
|
|
|
|
|
print '<td class="right">'.price($line->price_min).'</td>';
|