';
-*/
-
/*
// Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
// Ask for payment bank during order
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 652e7a72d4a..e3b2c64c92a 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')
@@ -2010,9 +2015,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)
{
@@ -2207,9 +2212,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) : '';
}