From 53b48173f60972adc7a4e2197c1ea7b67a408c8b Mon Sep 17 00:00:00 2001 From: atm-sami <139965072+atm-sami@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:55:35 +0100 Subject: [PATCH] NEW add sorting of product price list by customer (#26483) * added sorting of product price list by customer * add search and sort in same time * Update price.php --------- Co-authored-by: Laurent Destailleur --- htdocs/langs/en_US/products.lang | 2 + htdocs/langs/fr_FR/products.lang | 2 + .../class/productcustomerprice.class.php | 17 ++++ htdocs/societe/price.php | 86 +++++++++++++------ 4 files changed, 81 insertions(+), 26 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 024262e24a1..b95733f9a2e 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -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) 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 appear if you type a significant 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. diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 1b1eb51af37..0438b46a111 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -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 peut pas être inférieur au minimum autorisé pour ce produit (%s taxes comprises). Ce message peut également apparaître si vous saisissez une remise trop importante. diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 066c7daa952..6015c074520 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -28,6 +28,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ 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 */ diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index b20efad45fe..a8e254ac61d 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -308,6 +308,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '
'; print ''; print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -536,6 +538,22 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "\n\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')) { @@ -556,22 +574,38 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; - + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } print '
'; - print '
'; + print '
'; + + $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 ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + 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 ''; print ''; @@ -583,8 +617,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -606,18 +640,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; - print ""; - print ""; - print ''; - print ""; - print '"; - print '"; - print '"; - print '"; - print ''; - print ''; + print '"; + print '"; + print ''; + print '"; + print '"; + print '"; + print '"; + print '"; + print ''; + print ''; // User - print ''; // Action
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans('RefCustomer').''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("VAT").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").'
".$staticprod->getNomUrl(1)."".$staticprod->label."'.$line->ref_customer.'".dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."'.price($line->price)."'.price($line->price_ttc)."'.price($line->price_min).''.price($line->price_min_ttc).''.$staticprod->getNomUrl(1)."'.$staticprod->label."'.$line->ref_customer.''.dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."'.price($line->price)."'.price($line->price_ttc)."'.price($line->price_min).''.price($line->price_min_ttc).''; + print ''; print $userstatic->getNomUrl(-1); print '