diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 3ed4673a95d..1d63964be1c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -103,6 +103,13 @@ if ($type=='0') $result=restrictedArea($user,'produit','','','','','',$objcanvas else if ($type=='1') $result=restrictedArea($user,'service','','','','','',$objcanvas); else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); +// Define virtualdiffersfromphysical +$virtualdiffersfromphysical=0; +if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) +{ + $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. +} + // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'p.ref'=>"Ref", @@ -143,6 +150,7 @@ $arrayfields=array( 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0), 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0), @@ -160,6 +168,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } + /* * Actions @@ -429,6 +438,7 @@ else if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); @@ -517,7 +527,9 @@ else } // Stock if (! empty($arrayfields['p.stock']['checked'])) print ' '; - // To batch + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) print ' '; + // To batch if (! empty($arrayfields['p.tobatch']['checked'])) print ''.$form->selectyesno($search_tobatch, '', '', '', 1).''; // Accountancy code sell if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; @@ -716,12 +728,23 @@ else print ''; if ($objp->fk_product_type != 1) { - if ($product_static->stock_reel < $objp->seuil_stock_alerte) print img_warning($langs->trans("StockTooLow")).' '; + if ($objp->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $objp->seuil_stock_alerte) print img_warning($langs->trans("StockTooLow")).' '; print $product_static->stock_reel; } print ''; } - // Lot/Serial + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) + { + print ''; + if ($objp->fk_product_type != 1) + { + if ($objp->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $objp->seuil_stock_alerte) print img_warning($langs->trans("StockTooLow")).' '; + print $product_static->stock_theorique; + } + print ''; + } + // Lot/Serial if (! empty($arrayfields['p.tobatch']['checked'])) { print ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 57ca1adff9d..2a487cbfa66 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -84,6 +84,13 @@ if (! empty($_POST["button_removefilter_x"])) $toolowstock=''; } +// Define virtualdiffersfromphysical +$virtualdiffersfromphysical=0; +if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) +{ + $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. +} + /* @@ -192,11 +199,11 @@ if ($resql) if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, 0, 'title_products'); } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"").(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"").(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, 0, 'title_products'); } if (! empty($catid)) @@ -251,9 +258,8 @@ if ($resql) if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); - // TODO Add info of running suppliers/customers orders - //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "",$param,"",'align="right"',$sortfield,$sortorder); + if ($virtualdiffersfromphysical) print_liste_field_titre($langs->trans("VirtualStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); @@ -267,16 +273,18 @@ if ($resql) print ''; print ''; print ''; + // Duration if (! empty($conf->service->enabled) && $type == 1) { print ''; print ' '; print ''; } - // Lot/Serial + // Stock limit print ' '; print ' '; print ' '; + if ($virtualdiffersfromphysical) print ' '; print ' '; print ' '; print ''; @@ -309,15 +317,23 @@ if ($resql) } } - $var=!$var; - print ''; $product_static->ref=$objp->ref; $product_static->id=$objp->rowid; - $product_static->label = $objp->label; + $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; $product_static->entity=$objp->entity; + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) // To optimize call of load_stock + { + if ($objp->fk_product_type != 1) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + } + } + + $var=!$var; + print ''; print $product_static->getNomUrl(1,'',24); - //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); + print ''; print ''.$objp->label.''; @@ -333,10 +349,19 @@ if ($resql) //print ''.$objp->stock_theorique.''; print ''.$objp->seuil_stock_alerte.''; print ''.$objp->desiredstock.''; + // Real stock print ''; - if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; print $objp->stock_physique; print ''; + // Virtual stock + if ($virtualdiffersfromphysical) + { + print ''; + if ($objp->seuil_stock_alerte != '' && ($product_static->stock_theorique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + print $product_static->stock_theorique; + print ''; + } print ''.$langs->trans("Movements").''; print ''.$product_static->LibStatut($objp->statut,5,0).''; print ''.$product_static->LibStatut($objp->tobuy,5,1).''; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 3b77f9c5ba7..b0e4904715e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -204,11 +204,11 @@ if ($resql) if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, 'title_products'); } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num, 0, 'title_products'); } if (! empty($catid)) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 8fe2a7acf17..7af08ee6575 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -69,6 +69,13 @@ if (!$sortorder) { $sortorder = 'ASC'; } +// Define virtualdiffersfromphysical +$virtualdiffersfromphysical=0; +if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) +{ + $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. +} + /* * Actions @@ -227,20 +234,6 @@ if ($action == 'order' && isset($_POST['valid'])) $form = new Form($db); -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) -{ - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. -} - -$usevirtualstock=-1; -if ($virtualdiffersfromphysical) -{ - $usevirtualstock=(! empty($conf->global->STOCK_USE_VIRTUAL_STOCK)?1:0); - if ($mode=='virtual') $usevirtualstock=1; - if ($mode=='physical') $usevirtualstock=0; -} - $title = $langs->trans('Status'); $sql = 'SELECT p.rowid, p.ref, p.label, p.price,';