Beautify select of products in vendor record

This commit is contained in:
Laurent Destailleur 2019-10-24 20:33:16 +02:00
parent 443ca85f43
commit 8d21144521
3 changed files with 51 additions and 47 deletions

View File

@ -2827,15 +2827,6 @@ class Form
} }
} }
$opt = '<option value="'.$outkey.'"';
if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected';
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt.=' disabled';
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
{
$opt.= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"';
}
$opt.= '>';
$objRef = $objp->ref; $objRef = $objp->ref;
if ($filterkey && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1); if ($filterkey && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
$objRefFourn = $objp->ref_fourn; $objRefFourn = $objp->ref_fourn;
@ -2843,19 +2834,17 @@ class Form
$label = $objp->label; $label = $objp->label;
if ($filterkey && $filterkey != '') $label=preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1); if ($filterkey && $filterkey != '') $label=preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1);
$opt.=$objp->ref; $optlabel = $objp->ref;
if (! empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) if (! empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn))
$opt.=' ('.$objp->ref_fourn.')'; $optlabel.=' <span class=\'opacitymedium\'>('.$objp->ref_fourn.')</span>';
$opt.=' - ';
$outval.=$objRef; $outvallabel = $objRef;
if (! empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) if (! empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn))
$outval.=' ('.$objRefFourn.')'; $outvallabel.=' ('.$objRefFourn.')';
$outval.=' - ';
$opt.=dol_trunc($label, 72);
$outval.=dol_trunc($label, 72);
// Units // Units
$opt .= $outvalUnits; $optlabel .= $outvalUnits;
$outval .= $outvalUnits; $outvallabel .= $outvalUnits;
if (! empty($objp->idprodfournprice)) if (! empty($objp->idprodfournprice))
{ {
@ -2880,66 +2869,81 @@ class Form
} }
if ($objp->quantity == 1) if ($objp->quantity == 1)
{ {
$opt.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; $optlabel.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/";
$outval.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/"; $outvallabel.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/";
$opt.= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding $optlabel.= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
$outval.=$langs->transnoentities("Unit"); $outvallabel.=$langs->transnoentities("Unit");
} }
else else
{ {
$opt.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; $optlabel.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$outval.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; $outvallabel.= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$opt.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding $optlabel.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
$outval.= ' '.$langs->transnoentities("Units"); $outvallabel.= ' '.$langs->transnoentities("Units");
} }
if ($objp->quantity >= 1) if ($objp->quantity > 1)
{ {
$opt.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding $optlabel.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
$outval.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding $outvallabel.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
} }
if ($objp->remise_percent >= 1) if ($objp->remise_percent >= 1)
{ {
$opt.=" - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %'; $optlabel.=" - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
$outval.=" - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %'; $outvallabel.=" - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
} }
if ($objp->duration) if ($objp->duration)
{ {
$opt .= " - ".$objp->duration; $optlabel .= " - ".$objp->duration;
$outval.=" - ".$objp->duration; $outvallabel.=" - ".$objp->duration;
} }
if (! $socid) if (! $socid)
{ {
$opt .= " - ".dol_trunc($objp->name, 8); $optlabel .= " - ".dol_trunc($objp->name, 8);
$outval.=" - ".dol_trunc($objp->name, 8); $outvallabel.=" - ".dol_trunc($objp->name, 8);
} }
if (! empty($conf->barcode->enabled) && !empty($objp->barcode)) if (! empty($conf->barcode->enabled) && !empty($objp->barcode))
{ {
$opt .= " - ".$objp->barcode; //$optlabel .= " - <span class='fa fa-barcode'></span>".$objp->barcode;
$outval.=" - ".$objp->barcode; $optlabel .= " - ".$objp->barcode;
$outvallabel.=" - ".$objp->barcode;
} }
if ($objp->supplier_reputation) if ($objp->supplier_reputation)
{ {
//TODO dictionary //TODO dictionary
$reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); $reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
$opt .= " - ".$reputations[$objp->supplier_reputation]; $optlabel .= " - ".$reputations[$objp->supplier_reputation];
$outval.=" - ".$reputations[$objp->supplier_reputation]; $outvallabel.=" - ".$reputations[$objp->supplier_reputation];
} }
} }
else else
{ {
if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier
{ {
$opt.= ' - '.$langs->trans("NoPriceDefinedForThisSupplier"); $optlabel.= " - <span class='opacitymedium'>".$langs->trans("NoPriceDefinedForThisSupplier").'</span>';
$outval.=' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier"); $outvallabel.=' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
} }
else // No supplier price defined for product, even on other suppliers else // No supplier price defined for product, even on other suppliers
{ {
$opt.= ' - '.$langs->trans("NoPriceDefinedForThisSupplier"); $optlabel.= " - <span class='opacitymedium'>".$langs->trans("NoPriceDefinedForThisSupplier").'</span>';
$outval.=' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier"); $outvallabel.=' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
} }
} }
$opt = '<option value="'.$outkey.'"';
if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected';
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt.=' disabled';
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
{
$opt.= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"';
}
$opt.= ' data-html="'.dol_escape_htmltag($optlabel).'"';
$opt.= '>';
$opt.=$optlabel;
$outval.=$outvallabel;
$opt .= "</option>\n"; $opt .= "</option>\n";

View File

@ -274,7 +274,7 @@ class FormProduct
$out.='<option value="'.$id.'"'; $out.='<option value="'.$id.'"';
if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out.=' selected'; if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out.=' selected';
$out.=' data-html="'.$label.'"'; $out.=' data-html="'.dol_escape_htmltag($label).'"';
$out.='>'; $out.='>';
$out.=$label; $out.=$label;
$out.='</option>'; $out.='</option>';
@ -479,7 +479,7 @@ class FormProduct
$out.='<option value="'.$id.'"'; $out.='<option value="'.$id.'"';
if ($selected == $id || ($selected == 'ifone' && $nboflot == 1)) $out.=' selected'; if ($selected == $id || ($selected == 'ifone' && $nboflot == 1)) $out.=' selected';
$out.=' data-html="'.$label.'"'; $out.=' data-html="'.dol_escape_htmltag($label).'"';
$out.='>'; $out.='>';
$out.=$label; $out.=$label;
$out.='</option>'; $out.='</option>';