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:
Laurent Destailleur 2014-12-14 20:41:11 +01:00
parent c6bb5904e7
commit 0b6ff8f9bc
5 changed files with 73 additions and 68 deletions

View File

@ -1749,7 +1749,7 @@ class Form
} }
// Price by quantity // 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; $found = 1;
$outqty=$objp->quantity; $outqty=$objp->quantity;

View File

@ -198,7 +198,7 @@ HelpAddThisServiceCard=This option allows you to create or clone a service if it
CurrentProductPrice=Current price CurrentProductPrice=Current price
AlwaysUseNewPrice=Always use current price of product/service AlwaysUseNewPrice=Always use current price of product/service
AlwaysUseFixedPrice=Use the fixed price AlwaysUseFixedPrice=Use the fixed price
PriceByQuantity=Price by quantity PriceByQuantity=Different prices by quantity
PriceByQuantityRange=Quantity range PriceByQuantityRange=Quantity range
ProductsDashboard=Products/Services summary ProductsDashboard=Products/Services summary
UpdateOriginalProductLabel=Modify original label UpdateOriginalProductLabel=Modify original label
@ -234,9 +234,9 @@ DefinitionOfBarCodeForThirdpartyNotComplete=Definition of type or value of bar c
BarCodeDataForProduct=Barcode information of product %s : BarCodeDataForProduct=Barcode information of product %s :
BarCodeDataForThirdparty=Barcode information of thirdparty %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) 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 PriceCatalogue=Unique price per product/service
PricingRule=Pricing Rules PricingRule=Rules for customer prices
AddCustomerPrice=Add price by customers AddCustomerPrice=Add price by customers
ForceUpdateChildPriceSoc=Set same price on customer subsidiaries ForceUpdateChildPriceSoc=Set same price on customer subsidiaries
PriceByCustomerLog=Price by customer log PriceByCustomerLog=Price by customer log

View File

@ -46,11 +46,11 @@ $value = GETPOST('value','alpha');
$select_pricing_rules=array( $select_pricing_rules=array(
'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price 'PRODUCT_PRICE_UNIQ'=>$langs->trans('PriceCatalogue'), // Unique price
'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level 'PRODUIT_MULTIPRICES'=>$langs->trans('MultiPricesAbility'), // Several prices according to a customer level
'PRODUIT_CUSTOMER_PRICES'=>$langs->trans('PriceByCustomer') // Different price for each customer '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'); $select_pricing_rules['PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES'] = $langs->trans('MultiPricesAbility') . '+' . $langs->trans('PriceByQuantity');
} }

View File

@ -58,14 +58,16 @@ $price_by_qty_rowid = GETPOST('pbq', 'int');
dol_syslog(join(',', $_GET)); dol_syslog(join(',', $_GET));
// print_r($_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'; require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
$outjson = array(); $outjson = array();
$object = new Product($db); $object = new Product($db);
$ret = $object->fetch($id); $ret = $object->fetch($id);
if ($ret > 0) { if ($ret > 0)
{
$outref = $object->ref; $outref = $object->ref;
$outlabel = $object->label; $outlabel = $object->label;
$outdesc = $object->description; $outdesc = $object->description;
@ -76,9 +78,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) {
$found = false; $found = false;
// Price by qty // 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 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
// particular price related
// to qty
{ {
$sql = "SELECT price, unitprice, quantity, remise_percent"; $sql = "SELECT price, unitprice, quantity, remise_percent";
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty ";

View File

@ -430,12 +430,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '</td></tr>'; print '</td></tr>';
// Price by quantity // 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 '<tr><td>' . $langs->trans("PriceByQuantity") . ' ' . $i;
print '</td><td>'; print '</td><td>';
if ($object->prices_by_qty [$i] == 1) { 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 '<tr class="liste_titre">';
print '<td>' . $langs->trans("PriceByQuantityRange") . ' ' . $i . '</td>'; print '<td>' . $langs->trans("PriceByQuantityRange") . ' ' . $i . '</td>';
@ -452,7 +453,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '<input type="hidden" value="' . $prices['rowid'] . '" name="rowid">'; print '<input type="hidden" value="' . $prices['rowid'] . '" name="rowid">';
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">'; print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
print '<td><input size="5" type="text" value="' . $prices['quantity'] . '" name="quantity"></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="' . $prices ['price'] . '" name="price">&nbsp;' . $object->price_base_type . '</td>'; print '<td align="right" colspan="2"><input size="10" type="text" value="' . price2num($prices['price'], 'MU') . '" name="price">&nbsp;' . $object->price_base_type . '</td>';
// print '<td align="right">&nbsp;</td>'; // print '<td align="right">&nbsp;</td>';
print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent">&nbsp;%</td>'; print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent">&nbsp;%</td>';
print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>'; print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>';
@ -524,7 +525,8 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '</td></tr>'; print '</td></tr>';
// Price by quantity // 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"); print '<tr><td>' . $langs->trans("PriceByQuantity");
if ($object->prices_by_qty [0] == 0) { if ($object->prices_by_qty [0] == 0) {
print '&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=activate_price_by_qty&level=1">' . $langs->trans("Activate"); print '&nbsp;<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>'; print '</td><td>';
if ($object->prices_by_qty [0] == 1) { 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 '<tr class="liste_titre">';
print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>'; print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>'; print '<td align="right">' . $langs->trans("HT") . '</td>';
@ -540,15 +542,17 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '<td align="right">' . $langs->trans("Discount") . '</td>'; print '<td align="right">' . $langs->trans("Discount") . '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
foreach ($object->prices_by_qty_list [0] as $ii => $prices) { 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)) { {
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 '<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="action" value="update_price_by_qty">';
print '<input type="hidden" name="priceid" value="' . $object->prices_by_qty_id[0] . '">'; 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" value="' . $prices['rowid'] . '" name="rowid">';
print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">'; print '<tr class="' . ($ii % 2 == 0 ? 'pair' : 'impair') . '">';
print '<td><input size="5" type="text" value="' . $prices['quantity'] . '" name="quantity"></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="' . $prices ['price'] . '" name="price">&nbsp;' . $object->price_base_type . '</td>'; print '<td align="right" colspan="2"><input size="10" type="text" value="' . price2num($prices['price'], 'MU') . '" name="price">&nbsp;' . $object->price_base_type . '</td>';
// print '<td align="right">&nbsp;</td>'; // print '<td align="right">&nbsp;</td>';
print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent">&nbsp;%</td>'; print '<td align="right"><input size="5" type="text" value="' . $prices['remise_percent'] . '" name="remise_percent">&nbsp;%</td>';
print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>'; print '<td align="center"><input type="submit" value="' . $langs->trans("Modify") . '" class="button"></td>';
@ -803,7 +807,8 @@ if ($result) {
print '<td align="center">' . $objp->price_level . "</td>"; print '<td align="center">' . $objp->price_level . "</td>";
} }
// Price by quantity // 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'; $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard';
print '<td align="center">' . $langs->trans($type) . "</td>"; print '<td align="center">' . $langs->trans($type) . "</td>";
} }