Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW add sorting of product price list by customer #26483

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/products.lang
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ SoldAmount=Sold amount
PurchasedAmount=Purchased amount
NewPrice=New price
MinPrice=Min. selling price
MinPriceHT=Min. selling price (excl. tax)
MinPriceTTC=Prix de vente min (inc. tax)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MinPriceTTC=Prix de vente min (inc. tax)
MinPriceTTC=Min. selling price (inc. tax)

EditSellingPriceLabel=Edit selling price label
CantBeLessThanMinPrice=The selling price can't be lower than minimum allowed for this product (%s without tax). This message can also appears if you type a too important discount.
CantBeLessThanMinPriceInclTax=The selling price can't be lower than minimum allowed for this product (%s including taxes). This message can also appears if you type a too important discount.
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/fr_FR/products.lang
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ SoldAmount=Solde
PurchasedAmount=Montant des achats
NewPrice=Nouveau prix
MinPrice=Prix de vente min.
MinPriceHT=Prix de vente min. HT
MinPriceTTC=Prix de vente min. TTC
EditSellingPriceLabel=Modifier le libellé du prix de vente
CantBeLessThanMinPrice=Le prix de vente ne doit pas être inférieur au minimum pour ce produit (%s HT). Ce message peut aussi être provoqué par une remise trop importante.
CantBeLessThanMinPriceInclTax=Le prix de vente ne doit pas être inférieur au minimum pour ce produit (%s TTC). Ce message peut aussi être provoqué par une remise trop importante.
Expand Down
17 changes: 17 additions & 0 deletions htdocs/product/class/productcustomerprice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@
*/
class ProductCustomerPrice extends CommonObject
{
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array(
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'$conf->product->enabled', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'),
'ref_customer' => array('type'=>'varchar(128)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1,),
'datec' => array('type'=>'datetime', 'label'=>'AppliedPricesFrom', 'enabled'=>1, 'visible'=>1, 'position'=>500, 'notnull'=>1,),
'price_base_type' => array('type' => 'varchar(255)', 'label' => 'PriceBase', 'enabled' => 1, 'visible' => 1, 'position' => 11, 'notnull' => -1, 'comment' => 'Price Base Type'),
'tva_tx' => array('type' => 'decimal(20,6)', 'label' => 'VAT', 'enabled' => 1, 'visible' => 1, 'position' => 12, 'notnull' => -1, 'comment' => 'TVA Tax Rate'),
'price' => array('type' => 'decimal(20,6)', 'label' => 'HT', 'enabled' => 1, 'visible' => 1, 'position' => 8, 'notnull' => -1, 'comment' => 'Price HT'),
'price_ttc' => array('type' => 'decimal(20,6)', 'label' => 'TTC', 'enabled' => 1, 'visible' => 1, 'position' => 8, 'notnull' => -1, 'comment' => 'Price TTC'),
'price_min' => array('type' => 'decimal(20,6)', 'label' => 'MinPriceHT', 'enabled' => 1, 'visible' => 1, 'position' => 9, 'notnull' => -1, 'comment' => 'Minimum Price'),
'price_min_ttc' => array('type' => 'decimal(20,6)', 'label' => 'MinPriceTTC', 'enabled' => 1, 'visible' => 1, 'position' => 10, 'notnull' => -1, 'comment' => 'Minimum Price TTC'),
'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>1, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax100'),
);

/**
* @var string ID to identify managed object
*/
Expand Down
86 changes: 60 additions & 26 deletions htdocs/societe/price.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add_customer_price_confirm">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print '<table class="border centpercent">';
print '<tr>';
Expand Down Expand Up @@ -536,6 +538,22 @@
print "\n</div>\n";


$arrayfields = array();
foreach ($prodcustprice->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = (int) dol_eval($val['visible'], 1, 1, '1');
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
'position'=>$val['position'],
'help'=> isset($val['help']) ? $val['help'] : ''
);
}
}
$arrayfields = dol_sort_array($arrayfields, 'position');

// Count total nb of records
$nbtotalofrecords = '';
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
Expand All @@ -556,22 +574,38 @@
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';

if (!empty($sortfield)) {
print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
}
if (!empty($sortorder)) {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<table class="noborder centpercent liste">';

$param = 'socid='.$object->id.'&';
if ($search_prod) {
$param .= '&search_prod='.urlencode($search_prod);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_price) {
$param .= '&search_price='.urlencode($search_price);
}
if ($search_price) {
$param .= '&search_price='.urlencode($search_price);
}
if ($search_price_ttc) {
$param .= '&search_price_ttc='.urlencode($search_price_ttc);
}

print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans('RefCustomer').'</td>';
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
print '<td class="right">'.$langs->trans("VAT").'</td>';
print '<td class="right">'.$langs->trans("HT").'</td>';
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>';
foreach ($prodcustprice->fields as $key => $val) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, '', $sortfield, $sortorder)."\n";
}
}
print '<td></td>';
print '</tr>';

Expand All @@ -583,8 +617,8 @@
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre right"><input type="text" class="flat width75 right" name="search_price" value="'.$search_price.'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat width75 right" name="search_price_ttc" value="'.$search_price_ttc.'"></td>';
print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.'"></td>';
print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
Expand All @@ -606,18 +640,18 @@

print '<tr class="oddeven">';

print "<td>".$staticprod->getNomUrl(1)."</td>";
print "<td>".$staticprod->label."</td>";
print '<td>'.$line->ref_customer.'</td>';
print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
print '<td class="right">'.price($line->price)."</td>";
print '<td class="right">'.price($line->price_ttc)."</td>";
print '<td class="right">'.price($line->price_min).'</td>';
print '<td class="right">'.price($line->price_min_ttc).'</td>';
print '<td class="left">'.$staticprod->getNomUrl(1)."</td>";
print '<td class="left">'.$staticprod->label."</td>";
print '<td class="left">'.$line->ref_customer.'</td>';
print '<td class="left">'.dol_print_date($line->datec, "dayhour")."</td>";
print '<td class="left">'.$langs->trans($line->price_base_type)."</td>";
print '<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
print '<td class="left">'.price($line->price)."</td>";
print '<td class="left">'.price($line->price_ttc)."</td>";
print '<td class="left">'.price($line->price_min).'</td>';
print '<td class="left">'.price($line->price_min_ttc).'</td>';
// User
print '<td class="right">';
print '<td class="left">';
print $userstatic->getNomUrl(-1);
print '</td>';
// Action
Expand Down