Merge pull request #14659 from Tim-Otte/feature-filterable-purchase-price-table-columns
NEW Purchase price table: Added filterable table columns
This commit is contained in:
commit
c761b829b4
@ -858,6 +858,52 @@ SCRIPT;
|
||||
|
||||
print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1);
|
||||
|
||||
// Definition of fields for lists
|
||||
// Some fields are missing because they are not included in the database query
|
||||
$arrayfields = array(
|
||||
'pfp.datec'=>array('label'=>$langs->trans("AppliedPricesFrom"), 'checked'=>1, 'position'=>1),
|
||||
's.nom'=>array('label'=>$langs->trans("Suppliers"), 'checked'=>1, 'position'=>2),
|
||||
'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => !empty($conf->global->FOURN_PRODUCT_AVAILABILITY), 'checked'=>0, 'position'=>4),
|
||||
'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5),
|
||||
'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9),
|
||||
'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10),
|
||||
'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13),
|
||||
'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14),
|
||||
'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15),
|
||||
'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>16),
|
||||
'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => !empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING), 'checked'=>0, 'position'=>17),
|
||||
'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => $conf->barcode->enabled, 'checked'=>1, 'position'=>18),
|
||||
);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label("product_fournisseur_price");
|
||||
$extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
|
||||
|
||||
if (!empty($extralabels)) {
|
||||
foreach ($extralabels as $key => $value) {
|
||||
// Show field if not hidden
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
|
||||
else $extratitle = $langs->trans($value);
|
||||
$arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position']+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formulaire">';
|
||||
print '<input type="hidden" name="token" value="'. newToken() . '">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
// Suppliers list title
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="liste centpercent">';
|
||||
@ -865,42 +911,37 @@ SCRIPT;
|
||||
$param = "&id=".$object->id;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pfp.datec']['checked'])) print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['pfp.fk_availability']['checked'])) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pfp.quantity']['checked'])) print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if ($conf->multicurrency->enabled) {
|
||||
print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if ($conf->multicurrency->enabled) {
|
||||
print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
if ($conf->multicurrency->enabled) print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['pfp.unitprice']['checked'])) print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if ($conf->multicurrency->enabled) print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if ($conf->barcode->enabled) {
|
||||
print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['pfp.barcode']['checked'])) print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['pfp.packaging']['checked'])) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['pfp.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label("product_fournisseur_price");
|
||||
$extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
|
||||
|
||||
if (!empty($extralabels)) {
|
||||
foreach ($extralabels as $key => $value) {
|
||||
// Show field if not hidden
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
|
||||
else $extratitle = $langs->trans($value);
|
||||
print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
else $extratitle = $langs->trans($value);
|
||||
if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -910,7 +951,7 @@ SCRIPT;
|
||||
$parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action);
|
||||
}
|
||||
print_liste_field_titre('');
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
if (is_array($product_fourn_list))
|
||||
@ -920,10 +961,14 @@ SCRIPT;
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Date from
|
||||
print '<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').'</td>';
|
||||
if (!empty($arrayfields['pfp.datec']['checked'])) {
|
||||
print '<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').'</td>';
|
||||
}
|
||||
|
||||
// Supplier
|
||||
print '<td>'.$productfourn->getSocNomUrl(1, 'supplier').'</td>';
|
||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||
print '<td>'.$productfourn->getSocNomUrl(1, 'supplier').'</td>';
|
||||
}
|
||||
|
||||
// Supplier ref
|
||||
if ($usercancreate) // change required right here
|
||||
@ -934,7 +979,7 @@ SCRIPT;
|
||||
}
|
||||
|
||||
// Availability
|
||||
if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
|
||||
if (!empty($arrayfields['pfp.fk_availability']['checked']))
|
||||
{
|
||||
$form->load_cache_availability();
|
||||
$availability = $form->cache_availability[$productfourn->fk_availability]['label'];
|
||||
@ -942,16 +987,18 @@ SCRIPT;
|
||||
}
|
||||
|
||||
// Quantity
|
||||
print '<td class="right">';
|
||||
print $productfourn->fourn_qty;
|
||||
// Units
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$unit = $object->getLabelOfUnit();
|
||||
if ($unit !== '') {
|
||||
print ' '.$langs->trans($unit);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
if (!empty($arrayfields['pfp.quantity']['checked'])) {
|
||||
print '<td class="right">';
|
||||
print $productfourn->fourn_qty;
|
||||
// Units
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$unit = $object->getLabelOfUnit();
|
||||
if ($unit !== '') {
|
||||
print ' '.$langs->trans($unit);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT rate
|
||||
print '<td class="right">';
|
||||
@ -971,18 +1018,21 @@ SCRIPT;
|
||||
}
|
||||
|
||||
// Unit price
|
||||
print '<td class="right">';
|
||||
print price($productfourn->fourn_unitprice);
|
||||
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
|
||||
print '</td>';
|
||||
if (!empty($arrayfields['pfp.unitprice']['checked'])) {
|
||||
print '<td class="right">';
|
||||
print price($productfourn->fourn_unitprice);
|
||||
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if ($conf->multicurrency->enabled) {
|
||||
// Unit price in currency
|
||||
// Unit price in currency
|
||||
if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
|
||||
print '<td class="right">';
|
||||
print price($productfourn->fourn_multicurrency_unitprice);
|
||||
print '</td>';
|
||||
print '</td>';}
|
||||
|
||||
// Currency
|
||||
// Currency
|
||||
if ($conf->multicurrency->enabled) {
|
||||
print '<td class="right">';
|
||||
print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : '';
|
||||
print '</td>';
|
||||
@ -994,24 +1044,30 @@ SCRIPT;
|
||||
print '</td>';
|
||||
|
||||
// Delivery delay
|
||||
print '<td class="right">';
|
||||
print $productfourn->delivery_time_days;
|
||||
print '</td>';
|
||||
if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) {
|
||||
print '<td class="right">';
|
||||
print $productfourn->delivery_time_days;
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Reputation
|
||||
print '<td class="center">';
|
||||
if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) {
|
||||
print $object->reputations[$productfourn->supplier_reputation];
|
||||
if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) {
|
||||
print $object->reputations[$productfourn->supplier_reputation];
|
||||
}
|
||||
print'</td>';
|
||||
}
|
||||
print'</td>';
|
||||
|
||||
if ($conf->barcode->enabled) {
|
||||
// Barcode
|
||||
// Barcode
|
||||
if (!empty($arrayfields['pfp.barcode']['checked'])) {
|
||||
print '<td align="right">';
|
||||
print $productfourn->barcode;
|
||||
print '</td>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Barcode type
|
||||
// Barcode type
|
||||
if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
|
||||
print '<td class="center">';
|
||||
$productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0;
|
||||
$productfourn->fetch_barcode();
|
||||
@ -1020,17 +1076,18 @@ SCRIPT;
|
||||
}
|
||||
|
||||
// Packaging
|
||||
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
|
||||
{
|
||||
if (!empty($arrayfields['pfp.packaging']['checked'])) {
|
||||
print '<td align="center">';
|
||||
print price2num($productfourn->packaging);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Date
|
||||
print '<td align="right">';
|
||||
print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour");
|
||||
print '</td>';
|
||||
if (!empty($arrayfields['pfp.tms']['checked'])) {
|
||||
print '<td align="right">';
|
||||
print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour");
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Extrafields
|
||||
if (!empty($extralabels)) {
|
||||
@ -1045,14 +1102,14 @@ SCRIPT;
|
||||
if ($resql) {
|
||||
if ($db->num_rows($resql) != 1) {
|
||||
foreach ($extralabels as $key => $value) {
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
print "<td></td>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$obj = $db->fetch_object($resql);
|
||||
foreach ($extralabels as $key => $value) {
|
||||
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
|
||||
print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key})."</td>";
|
||||
}
|
||||
}
|
||||
@ -1087,6 +1144,7 @@ SCRIPT;
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user