diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index db88599f52d..b208cba1c7e 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
-
+
$prodcustprice = new Productcustomerprice($db);
}
@@ -58,18 +58,18 @@ $object = new Product($db);
if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$result = $object->fetch($id);
-
+
// MultiPrix
- if (! empty($conf->global->PRODUIT_MULTIPRICES))
+ if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
-
- for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
+
+ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
- if (isset($_POST ["price_" . $i]))
+ if (isset($_POST ["price_" . $i]))
{
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
@@ -92,7 +92,7 @@ if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit-
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
-
+
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) {
$action = '';
$mesg = '
' . $langs->trans("RecordSaved") . '
';
@@ -115,7 +115,7 @@ $error = 0;
if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity
$result = $object->fetch($id);
$level = GETPOST('level');
-
+
$object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
}
@@ -125,7 +125,7 @@ if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité
if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par quantité
$result = $object->fetch($id);
-
+
// Récupération des variables
$rowid = GETPOST('rowid');
$priceid = GETPOST('priceid');
@@ -148,10 +148,10 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
if ($object->price_base_type == 'TTC') {
$price = price2num($newprice) / (1 + ($object->tva_tx / 100));
}
-
+
$price = price2num($newprice, 'MU');
$unitPrice = price2num($price / $quantity, 'MU');
-
+
// Ajout / mise à jour
if ($rowid > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "product_price_by_qty SET";
@@ -161,12 +161,12 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
$sql .= " remise_percent=" . $remise_percent . ",";
$sql .= " remise=" . $remise;
$sql .= " WHERE rowid = " . GETPOST('rowid');
-
+
$result = $db->query($sql);
} else {
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
$sql .= $priceid . ',' . $price . ',' . $unitPrice . ',' . $quantity . ',' . $remise_percent . ',' . $remise . ')';
-
+
$result = $db->query($sql);
}
}
@@ -174,19 +174,19 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
if ($action == 'delete_price_by_qty') {
$rowid = GETPOST('rowid');
-
+
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE rowid = " . GETPOST('rowid');
-
+
$result = $db->query($sql);
}
if ($action == 'delete_all_price_by_qty') {
$priceid = GETPOST('priceid');
-
+
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE fk_product_price = " . $priceid;
-
+
$result = $db->query($sql);
}
@@ -196,11 +196,11 @@ if ($action == 'delete_all_price_by_qty') {
* ****************************************************
*/
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
-
+
$update_child_soc = GETPOST('updatechildprice');
-
+
$result = $object->fetch($id);
-
+
// add price by customer
$prodcustprice->fk_soc = GETPOST('socid', 'int');
$prodcustprice->fk_product = $object->id;
@@ -209,15 +209,15 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
-
+
$result = $prodcustprice->create($user, 0, $update_child_soc);
-
+
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
-
+
$action = '';
}
@@ -225,7 +225,7 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
-
+
if ($result < 0) {
setEventMessage($prodcustprice->error, 'mesgs');
} else {
@@ -235,26 +235,26 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
}
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
-
+
$update_child_soc = GETPOST('updatechildprice');
-
+
$prodcustprice->fetch(GETPOST('lineid', 'int'));
-
+
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
-
+
$result = $prodcustprice->update($user, 0, $update_child_soc);
-
+
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
-
+
$action = '';
}
@@ -304,22 +304,22 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch($socid);
-
+
print '' . $langs->trans("SellingPrice") . ' ';
-
+
if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
print '' . price($object->multiprices_ttc ["$soc->price_level"]);
} else {
print ' ' . price($object->multiprices ["$soc->price_level"]);
}
-
+
if ($object->multiprices_base_type ["$soc->price_level"]) {
print ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
} else {
print ' ' . $langs->trans($object->price_base_type);
}
print ' ';
-
+
// Prix mini
print '' . $langs->trans("MinPrice") . ' ';
if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
@@ -328,41 +328,41 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->multiprices_min ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
}
print ' ';
-
+
// TVA
print '' . $langs->trans("VATRate") . ' ' . vatrate($object->multiprices_tva_tx ["$soc->price_level"], true) . ' ';
- }
+ }
else
{
- for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
+ for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
// TVA
if ($i == 1) // We show only price for level 1
{
print '' . $langs->trans("VATRate") . ' ' . vatrate($object->multiprices_tva_tx [1], true) . ' ';
}
-
+
print '';
-
+
// Label of price
print '' . $langs->trans("SellingPrice") . ' ' . $i;
$keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
print ' ';
-
+
if ($object->multiprices_base_type ["$i"] == 'TTC') {
print '' . price($object->multiprices_ttc ["$i"]);
} else {
print ' ' . price($object->multiprices ["$i"]);
}
-
+
if ($object->multiprices_base_type ["$i"]) {
print ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
} else {
print ' ' . $langs->trans($object->price_base_type);
}
print ' ';
-
+
// Prix mini
print '' . $langs->trans("MinPrice") . ' ' . $i . ' ';
if ($object->multiprices_base_type ["$i"] == 'TTC') {
@@ -371,15 +371,15 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->multiprices_min ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
}
print ' ';
-
+
// Price by quantity
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
print '' . $langs->trans("PriceByQuantity") . ' ' . $i;
print ' ';
-
+
if ($object->prices_by_qty [$i] == 1) {
print '';
-
+
print '';
print '' . $langs->trans("PriceByQuantityRange") . ' ' . $i . ' ';
print '' . $langs->trans("HT") . ' ';
@@ -434,7 +434,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print ' ';
print '';
}
-
+
print '
';
} else {
print $langs->trans("No");
@@ -447,7 +447,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
} else {
// TVA
print ' ' . $langs->trans("VATRate") . ' ' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . ' ';
-
+
// Price
print '' . $langs->trans("SellingPrice") . ' ';
if ($object->price_base_type == 'TTC') {
@@ -456,7 +456,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
}
print ' ';
-
+
// Price minimum
print '' . $langs->trans("MinPrice") . ' ';
if ($object->price_base_type == 'TTC') {
@@ -465,7 +465,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
}
print ' ';
-
+
// Price by quantity
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
print '' . $langs->trans("PriceByQuantity");
@@ -473,7 +473,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print ' ' . $langs->trans("Activate");
}
print ' ';
-
+
if ($object->prices_by_qty [0] == 1) {
print '';
print '';
@@ -530,7 +530,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print ' ';
print '';
}
-
+
print '
';
} else {
print $langs->trans("No");
@@ -560,11 +560,11 @@ if (! empty($mesg)) {
if (! $action || $action == 'delete') {
print "\n" . '' . "\n";
-
+
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '
';
}
-
+
print "\n
\n";
}
@@ -573,19 +573,19 @@ if (! $action || $action == 'delete') {
*/
if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
print_fiche_titre($langs->trans("NewPrice"), '', '');
-
+
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print '';
} else {
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
@@ -631,7 +631,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print ' ';
print ' ';
print '';
@@ -691,33 +691,33 @@ dol_syslog("sql=" . $sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
-
+
if (! $num) {
$db->free($result);
-
+
// Il doit au moins y avoir la ligne de prix initial.
// On l'ajoute donc pour remettre a niveau (pb vieilles versions)
$object->updatePrice($object->price, $object->price_base_type, $user, $newprice_min);
-
+
$result = $db->query($sql);
$num = $db->num_rows($result);
}
-
+
if ($num > 0) {
print ' ';
-
+
print '';
-
+
print '';
print '' . $langs->trans("AppliedPricesFrom") . ' ';
-
+
if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '' . $langs->trans("MultiPriceLevelsName") . ' ';
}
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
print '' . $langs->trans("Type") . ' ';
}
-
+
print '' . $langs->trans("PriceBase") . ' ';
print '' . $langs->trans("VAT") . ' ';
print '' . $langs->trans("HT") . ' ';
@@ -728,7 +728,7 @@ if ($result) {
if ($user->rights->produit->supprimer)
print ' ';
print ' ';
-
+
$var = True;
$i = 0;
while ($i < $num) {
@@ -737,7 +737,7 @@ if ($result) {
print "";
// Date
print "" . dol_print_date($db->jdate($objp->dp), "dayhour") . " ";
-
+
// Price level
if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '' . $objp->price_level . " ";
@@ -747,17 +747,17 @@ if ($result) {
$type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard';
print '' . $langs->trans($type) . " ";
}
-
+
print '' . $langs->trans($objp->price_base_type) . " ";
print '' . vatrate($objp->tva_tx, true, $objp->recuperableonly) . " ";
print '' . price($objp->price) . " ";
print '' . price($objp->price_ttc) . " ";
print '' . price($objp->price_min) . ' ';
print '' . price($objp->price_min_ttc) . ' ';
-
+
// User
print '' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . ' ';
-
+
// Action
if ($user->rights->produit->supprimer) {
print '';
@@ -769,7 +769,7 @@ if ($result) {
print ' '; // Can not delete last price (it's current price)
print ' ';
}
-
+
print " \n";
$i ++;
}
@@ -782,9 +782,9 @@ if ($result) {
}
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
-
+
$prodcustprice = new Productcustomerprice($db);
-
+
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@@ -798,21 +798,21 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortorder = "ASC";
if (! $sortfield)
$sortfield = "soc.nom";
-
+
// Build filter to diplay only concerned lines
$filter = array('t.fk_product' => $object->id);
-
+
$search_soc = GETPOST('search_soc');
if (! empty($search_soc)) {
$filter ['soc.nom'] = $search_soc;
}
-
+
if ($action == 'add_customer_price') {
-
+
// Create mode
-
+
print_fiche_titre($langs->trans('PriceByCustomer'));
-
+
print '
';
-
+
print ' ';
print ' ';
-
+
print ' ';
} elseif ($action == 'edit_customer_price') {
-
+
// Edit mode
-
+
print_fiche_titre($langs->trans('PriceByCustomer'));
-
+
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
-
+
print ' ';
-
+
// VAT
print '' . $langs->trans("VATRate") . ' ';
print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly);
print ' ';
-
+
// Price base
print '';
print $langs->trans('PriceBase');
@@ -913,7 +913,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print ' ';
print ' ';
-
+
// Price
print '';
$text = $langs->trans('SellingPrice');
@@ -925,18 +925,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print ' ';
}
print ' ';
-
+
// Price minimum
print '';
$text = $langs->trans('MinPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
+ print ' ';
if ($prodcustprice->price_base_type == 'TTC') {
- print ' ';
+ print ' ';
} else {
- print ' ';
+ print ' ';
}
print ' ';
-
+
// Update all child soc
print '';
print $langs->trans('ForceUpdateChildPriceSoc');
@@ -945,39 +946,39 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print ' ';
print ' ';
print ' ';
-
+
print '';
-
+
print ' ';
print ' ';
-
+
print ' ';
} elseif ($action == 'showlog_customer_price') {
-
+
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
-
+
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
}
-
+
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
-
+
$option = '&socid=' . GETPOST('socid', 'int') . '&id=' . $object->id;
-
+
print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
-
+
if (count($prodcustprice->lines) > 0) {
-
+
print '