Fix: Debug of feature PRODUIT_CUSTOMER_PRICES_BY_QTY. Dev seems to not
be finished. We keep it as development status.
This commit is contained in:
parent
c6bb5904e7
commit
0b6ff8f9bc
@ -1749,7 +1749,7 @@ class Form
|
||||
}
|
||||
|
||||
// Price by quantity
|
||||
if (!empty($objp->quantity) && $objp->quantity >= 1 && $conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)
|
||||
if (!empty($objp->quantity) && $objp->quantity >= 1 && ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||
{
|
||||
$found = 1;
|
||||
$outqty=$objp->quantity;
|
||||
|
||||
@ -198,7 +198,7 @@ HelpAddThisServiceCard=This option allows you to create or clone a service if it
|
||||
CurrentProductPrice=Current price
|
||||
AlwaysUseNewPrice=Always use current price of product/service
|
||||
AlwaysUseFixedPrice=Use the fixed price
|
||||
PriceByQuantity=Price by quantity
|
||||
PriceByQuantity=Different prices by quantity
|
||||
PriceByQuantityRange=Quantity range
|
||||
ProductsDashboard=Products/Services summary
|
||||
UpdateOriginalProductLabel=Modify original label
|
||||
@ -234,9 +234,9 @@ DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar c
|
||||
BarCodeDataForProduct=Barcode information of product %s :
|
||||
BarCodeDataForThirdparty=Barcode information of thirdparty %s :
|
||||
ResetBarcodeForAllRecords=Define barcode value for all records (this will also reset barcode value already defined with new values)
|
||||
PriceByCustomer=Price by customer
|
||||
PriceByCustomer=Different price for each customer
|
||||
PriceCatalogue=Unique price per product/service
|
||||
PricingRule=Pricing Rules
|
||||
PricingRule=Rules for customer prices
|
||||
AddCustomerPrice=Add price by customers
|
||||
ForceUpdateChildPriceSoc=Set same price on customer subsidiaries
|
||||
PriceByCustomerLog=Price by customer log
|
||||
|
||||
@ -44,13 +44,13 @@ $value = GETPOST('value','alpha');
|
||||
|
||||
// Pricing Rules
|
||||
$select_pricing_rules=array(
|
||||
'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price
|
||||
'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level
|
||||
'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer') // Different price for each customer
|
||||
'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price
|
||||
'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level
|
||||
'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer'), // Different price for each customer
|
||||
);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL==2)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
||||
{
|
||||
$select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity');
|
||||
$select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY'] = $langs->trans('PriceByQuantity'); // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice
|
||||
$select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES'] = $langs->trans('MultiPricesAbility') . '+' . $langs->trans('PriceByQuantity');
|
||||
}
|
||||
|
||||
|
||||
@ -58,32 +58,32 @@ $price_by_qty_rowid = GETPOST('pbq', 'int');
|
||||
dol_syslog(join(',', $_GET));
|
||||
// print_r($_GET);
|
||||
|
||||
if (! empty($action) && $action == 'fetch' && ! empty($id)) {
|
||||
if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
{
|
||||
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
|
||||
$outjson = array();
|
||||
|
||||
|
||||
$object = new Product($db);
|
||||
$ret = $object->fetch($id);
|
||||
if ($ret > 0) {
|
||||
if ($ret > 0)
|
||||
{
|
||||
$outref = $object->ref;
|
||||
$outlabel = $object->label;
|
||||
$outdesc = $object->description;
|
||||
$outtype = $object->type;
|
||||
$outqty = 1;
|
||||
$outdiscount = 0;
|
||||
|
||||
|
||||
$found = false;
|
||||
|
||||
|
||||
// Price by qty
|
||||
if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a
|
||||
// particular price related
|
||||
// to qty
|
||||
if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty
|
||||
{
|
||||
$sql = "SELECT price, unitprice, quantity, remise_percent";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty ";
|
||||
$sql .= " WHERE rowid=" . $price_by_qty_rowid . "";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -98,7 +98,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Multiprice
|
||||
if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price
|
||||
// level (from 1 to 6)
|
||||
@ -110,7 +110,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
|
||||
$sql .= " AND price_level=" . $price_level;
|
||||
$sql .= " ORDER BY date_price";
|
||||
$sql .= " DESC LIMIT 1";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -123,16 +123,16 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Price by customer
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) {
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
|
||||
|
||||
|
||||
$prodcustprice = new Productcustomerprice($db);
|
||||
|
||||
|
||||
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid);
|
||||
|
||||
|
||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
@ -144,48 +144,48 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $found) {
|
||||
$outprice_ht = price($object->price);
|
||||
$outprice_ttc = price($object->price_ttc);
|
||||
$outpricebasetype = $object->price_base_type;
|
||||
$outtva_tx = $object->tva_tx;
|
||||
}
|
||||
|
||||
|
||||
$outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount);
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($outjson);
|
||||
} else {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
|
||||
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("main");
|
||||
|
||||
|
||||
top_httphead();
|
||||
|
||||
|
||||
if (empty($htmlname))
|
||||
return;
|
||||
|
||||
|
||||
$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
|
||||
sort($match);
|
||||
$idprod = (! empty($match [0]) ? $match [0] : '');
|
||||
|
||||
|
||||
if (! GETPOST($htmlname) && ! GETPOST($idprod))
|
||||
return;
|
||||
|
||||
|
||||
// When used from jQuery, the search term is added as GET param "term".
|
||||
$searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : ''));
|
||||
|
||||
|
||||
$form = new Form($db);
|
||||
if (empty($mode) || $mode == 1) {
|
||||
$arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid);
|
||||
} elseif ($mode == 2) {
|
||||
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid);
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
if ($outjson)
|
||||
print json_encode($arrayresult);
|
||||
}
|
||||
|
||||
@ -430,12 +430,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
print '</td></tr>';
|
||||
|
||||
// Price by quantity
|
||||
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans("PriceByQuantity") . ' ' . $i;
|
||||
print '</td><td>';
|
||||
|
||||
if ($object->prices_by_qty [$i] == 1) {
|
||||
print '<table width="50%" class="noborder">';
|
||||
print '<table width="50%" class="border" summary="List of quantities">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans("PriceByQuantityRange") . ' ' . $i . '</td>';
|
||||
@ -445,30 +446,30 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
foreach ($object->prices_by_qty_list [$i] as $ii => $prices) {
|
||||
if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
|
||||
print '<input type="hidden" name="action" value="update_price_by_qty">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id [$i] . '">';
|
||||
print '<input type="hidden" value="' . $prices ['rowid'] . '" name="rowid">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id[$i] . '">';
|
||||
print '<input type="hidden" value="' . $prices['rowid'] . '" name="rowid">';
|
||||
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
|
||||
print '<td><input size="5" type="text" value="' . $prices ['quantity'] . '" name="quantity"></td>';
|
||||
print '<td align="right" colspan="2"><input size="10" type="text" value="' . $prices ['price'] . '" name="price"> ' . $object->price_base_type . '</td>';
|
||||
print '<td><input size="5" type="text" value="' . $prices['quantity'] . '" name="quantity"></td>';
|
||||
print '<td align="right" colspan="2"><input size="10" type="text" value="' . price2num($prices['price'], 'MU') . '" name="price"> ' . $object->price_base_type . '</td>';
|
||||
// print '<td align="right"> </td>';
|
||||
print '<td align="right"><input size="5" type="text" value="' . $prices ['remise_percent'] . '" name="remise_percent"> %</td>';
|
||||
print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent"> %</td>';
|
||||
print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
|
||||
print '<td>' . $prices ['quantity'] . '</td>';
|
||||
print '<td align="right">' . price($prices ['price']) . '</td>';
|
||||
print '<td align="right">' . price($prices ['unitprice']) . '</td>';
|
||||
print '<td align="right">' . price($prices ['remise_percent']) . ' %</td>';
|
||||
print '<td align="right">' . price($prices['price']) . '</td>';
|
||||
print '<td align="right">' . price($prices['unitprice']) . '</td>';
|
||||
print '<td align="right">' . price($prices['remise_percent']) . ' %</td>';
|
||||
print '<td align="center">';
|
||||
if (($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit_price_by_qty&rowid=' . $prices ["rowid"] . '">';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit_price_by_qty&rowid=' . $prices["rowid"] . '">';
|
||||
print img_edit() . '</a>';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete_price_by_qty&rowid=' . $prices ["rowid"] . '">';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete_price_by_qty&rowid=' . $prices["rowid"] . '">';
|
||||
print img_delete() . '</a>';
|
||||
} else {
|
||||
print ' ';
|
||||
@ -480,7 +481,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
if ($action != 'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
|
||||
print '<input type="hidden" name="action" value="update_price_by_qty">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id [$i] . '">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id[$i] . '">';
|
||||
print '<input type="hidden" value="0" name="rowid">';
|
||||
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
|
||||
print '<td><input size="5" type="text" value="1" name="quantity"></td>';
|
||||
@ -524,7 +525,8 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
print '</td></tr>';
|
||||
|
||||
// Price by quantity
|
||||
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans("PriceByQuantity");
|
||||
if ($object->prices_by_qty [0] == 0) {
|
||||
print ' <a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=activate_price_by_qty&level=1">' . $langs->trans("Activate");
|
||||
@ -532,7 +534,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
print '</td><td>';
|
||||
|
||||
if ($object->prices_by_qty [0] == 1) {
|
||||
print '<table width="50%" class="noborder">';
|
||||
print '<table width="50%" class="border" summary="List of quantities">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>';
|
||||
print '<td align="right">' . $langs->trans("HT") . '</td>';
|
||||
@ -540,31 +542,33 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
print '<td align="right">' . $langs->trans("Discount") . '</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
foreach ($object->prices_by_qty_list [0] as $ii => $prices) {
|
||||
if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
foreach ($object->prices_by_qty_list [0] as $ii => $prices)
|
||||
{
|
||||
if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
|
||||
print '<input type="hidden" name="action" value="update_price_by_qty">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id [0] . '">';
|
||||
print '<input type="hidden" value="' . $prices ['rowid'] . '" name="rowid">';
|
||||
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id[0] . '">';
|
||||
print '<input type="hidden" value="' . $prices['rowid'] . '" name="rowid">';
|
||||
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
|
||||
print '<td><input size="5" type="text" value="' . $prices ['quantity'] . '" name="quantity"></td>';
|
||||
print '<td align="right" colspan="2"><input size="10" type="text" value="' . $prices ['price'] . '" name="price"> ' . $object->price_base_type . '</td>';
|
||||
print '<td><input size="5" type="text" value="' . $prices['quantity'] . '" name="quantity"></td>';
|
||||
print '<td align="right" colspan="2"><input size="10" type="text" value="' . price2num($prices['price'], 'MU') . '" name="price"> ' . $object->price_base_type . '</td>';
|
||||
// print '<td align="right"> </td>';
|
||||
print '<td align="right"><input size="5" type="text" value="' . $prices ['remise_percent'] . '" name="remise_percent"> %</td>';
|
||||
print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent"> %</td>';
|
||||
print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
|
||||
print '<td>' . $prices ['quantity'] . '</td>';
|
||||
print '<td align="right">' . price($prices ['price']) . '</td>';
|
||||
print '<td align="right">' . price($prices ['unitprice']) . '</td>';
|
||||
print '<td align="right">' . price($prices ['remise_percent']) . ' %</td>';
|
||||
print '<td>' . $prices['quantity'] . '</td>';
|
||||
print '<td align="right">' . price($prices['price']) . '</td>';
|
||||
print '<td align="right">' . price($prices['unitprice']) . '</td>';
|
||||
print '<td align="right">' . price($prices['remise_percent']) . ' %</td>';
|
||||
print '<td align="center">';
|
||||
if (($user->rights->produit->creer || $user->rights->service->creer)) {
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit_price_by_qty&rowid=' . $prices ["rowid"] . '">';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit_price_by_qty&rowid=' . $prices["rowid"] . '">';
|
||||
print img_edit() . '</a>';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete_price_by_qty&rowid=' . $prices ["rowid"] . '">';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete_price_by_qty&rowid=' . $prices["rowid"] . '">';
|
||||
print img_delete() . '</a>';
|
||||
} else {
|
||||
print ' ';
|
||||
@ -803,7 +807,8 @@ if ($result) {
|
||||
print '<td align="center">' . $objp->price_level . "</td>";
|
||||
}
|
||||
// Price by quantity
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||
{
|
||||
$type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard';
|
||||
print '<td align="center">' . $langs->trans($type) . "</td>";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user