From 1eb4d7625333d653a735b3cf6c1efb6571635491 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Jan 2022 13:15:32 +0100 Subject: [PATCH 1/2] Clean code --- htdocs/admin/commande.php | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 1e977fb48df..24a45bb413a 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -158,18 +158,6 @@ if ($action == 'updateMask') { $error++; } - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} elseif ($action == "setshippableiconinlist") { - // Activate Set Shippable Icon In List - $setshippableiconinlist = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -646,25 +634,6 @@ print '\n"; print ''; -// Shippable Icon in List -/* Kept as hidden feature for the moment, result seems bugged. -Where is definition of "shippable" according to all different STOCK_CALCULATE_... options ? - -print ''; -print ''.$langs->trans("ShippableOrderIconInList").''; -print ' '; -print ''; -if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); -} else { - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); -} -print ''; -print ''; -*/ - /* // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation. // Ask for payment bank during order From 6b5c0769b843c8de8f0d57f1460d438e2398bde4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Jan 2022 14:09:53 +0100 Subject: [PATCH 2/2] FIX #19786 --- htdocs/commande/class/commande.class.php | 12 +++++++--- htdocs/commande/list.php | 30 +++++++++++++----------- htdocs/expedition/card.php | 7 ++++-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f60a91ae3df..48b7e499dbb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -261,6 +261,11 @@ class Commande extends CommonOrder //! key of pos source ('0', '1', ...) public $pos_source; + /** + * @var array Array with line of all shipments + */ + public $expeditions; + /** * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') @@ -2004,9 +2009,9 @@ class Commande extends CommonOrder /** * Load array lines * - * @param int $only_product Return only physical products, not services + * @param int $only_product Return only physical products, not services * @param int $loadalsotranslation Return translation for products - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function fetch_lines($only_product = 0, $loadalsotranslation = 0) { @@ -2201,9 +2206,10 @@ class Commande extends CommonOrder * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order * * @param int $filtre_statut Filter on shipment status + * @param int $fk_product Add a filter on a product * @return int <0 if KO, Nb of lines found if OK */ - public function loadExpeditions($filtre_statut = -1) + public function loadExpeditions($filtre_statut = -1, $fk_product = 0) { $this->expeditions = array(); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8fc93a233c2..717b57ae8b1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1854,10 +1854,13 @@ if ($resql) { print ''; if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { - $generic_commande->getLinesArray(); // This set ->lines + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions $numlines = count($generic_commande->lines); // Loop on each line of order for ($lig = 0; $lig < $numlines; $lig++) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service $nbprod++; // order contains real products $generic_product->id = $generic_commande->lines[$lig]->fk_product; @@ -1872,15 +1875,15 @@ if ($resql) { $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. - $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); $text_info .= '
'; - - if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) { - $notshippable++; - } } else { // BUGGED CODE. // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE @@ -1908,32 +1911,31 @@ if ($resql) { $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } - $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { - $notshippable++; + if ($reliquat > $generic_product->stock_reel) { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } else { $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { - $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; - } else { - $text_info .= '
'; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; } } } if ($notshippable == 0) { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $langs->trans('Shippable').'
'.$text_info; + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; } else { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $langs->trans('NonShippable').'
'.$text_info; + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; } } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 064dfc3a52c..f835e293f5f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1126,16 +1126,19 @@ if ($action == 'create') { $product_static->status_buy = $line->product_tobuy; $product_static->status_batch = $line->product_tobatch; + $showdescinproductdesc = (getDolGlobalString('PRODUIT_DESC_IN_FORM') == 2 ? 1 : 0); + $text = $product_static->getNomUrl(1); $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); - $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); + $description = ($showdescinproductdesc ? '' : dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); // Add description in form - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + if ($showdescinproductdesc) { print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; }