New: Make difference between virtual and physical stock easier to
understand.
This commit is contained in:
parent
57153e4de4
commit
7e3c2d40ba
@ -41,45 +41,43 @@ $action = GETPOST('action','alpha');
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
|
if($action)
|
||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
|
||||||
|
{
|
||||||
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
|
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
|
||||||
}
|
}
|
||||||
// Mode of stock decrease
|
// Mode of stock decrease
|
||||||
if ($action == 'STOCK_CALCULATE_ON_BILL'
|
if ($action == 'STOCK_CALCULATE_ON_BILL'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|
|| $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_SHIPMENT')
|
|| $action == 'STOCK_CALCULATE_ON_SHIPMENT')
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity);
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", GETPOST('STOCK_CALCULATE_ON_BILL','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", GETPOST('STOCK_CALCULATE_ON_BILL','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
|
||||||
}
|
}
|
||||||
// Mode of stock increase
|
// Mode of stock increase
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
|
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
|
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action == 'USE_VIRTUAL_STOCK') {
|
if($action == 'STOCK_USE_VIRTUAL_STOCK') {
|
||||||
$db->begin();
|
$res = dolibarr_set_const($db, "STOCK_USE_VIRTUAL_STOCK", GETPOST('STOCK_USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity);
|
||||||
$res = dolibarr_set_const($db, "USE_VIRTUAL_STOCK", GETPOST('USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($action)
|
|
||||||
{
|
|
||||||
if (! $res > 0) $error++;
|
if (! $res > 0) $error++;
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -249,25 +247,34 @@ if (! empty($conf->fournisseur->enabled))
|
|||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
print '<table class="noborder" width="100%">';
|
$virtualdiffersfromphysical=0;
|
||||||
print '<tr class="liste_titre">';
|
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|
||||||
print " <td>".$langs->trans("RuleForStockReplenishment")."</td>\n";
|
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
|
||||||
print " <td align=\"right\" width=\"160\"> </td>\n";
|
) $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
|
||||||
print '</tr>'."\n";
|
|
||||||
$var = !$var;
|
if ($virtualdiffersfromphysical)
|
||||||
print "<tr ".$bc[$var].">";
|
{
|
||||||
print '<td width="60%">'.$langs->trans("UseVirtualStock").'</td>';
|
print '<br>';
|
||||||
print '<td width="160" align="right">';
|
print '<table class="noborder" width="100%">';
|
||||||
print "<form method=\"post\" action=\"stock.php\">";
|
print '<tr class="liste_titre">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print " <td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
|
||||||
print "<input type=\"hidden\" name=\"action\" value=\"USE_VIRTUAL_STOCK\">";
|
print " <td align=\"right\" width=\"160\"> </td>\n";
|
||||||
print $form->selectyesno("USE_VIRTUAL_STOCK",$conf->global->USE_VIRTUAL_STOCK,1);
|
print '</tr>'."\n";
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
$var = !$var;
|
||||||
print '</form>';
|
print "<tr ".$bc[$var].">";
|
||||||
print "</td>\n";
|
print '<td width="60%">'.$langs->trans("UseVirtualStockByDefault").'</td>';
|
||||||
print "</tr>\n";
|
print '<td width="160" align="right">';
|
||||||
print '</table>';
|
print "<form method=\"post\" action=\"stock.php\">";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USE_VIRTUAL_STOCK\">";
|
||||||
|
print $form->selectyesno("STOCK_USE_VIRTUAL_STOCK",$conf->global->STOCK_USE_VIRTUAL_STOCK,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</form>';
|
||||||
|
print "</td>\n";
|
||||||
|
print "</tr>\n";
|
||||||
|
print '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -94,14 +94,20 @@ DesiredStock=Desired stock
|
|||||||
StockToBuy=To order
|
StockToBuy=To order
|
||||||
Replenishment=Replenishment
|
Replenishment=Replenishment
|
||||||
ReplenishmentOrders=Replenishment orders
|
ReplenishmentOrders=Replenishment orders
|
||||||
UseVirtualStock=Use virtual stock instead of physical stock
|
VirtualDiffersFromPhysical=According to increase/decrease stock options, physical stock and virtual stock (physical + current orders) may differs
|
||||||
|
UseVirtualStockByDefault=Use virtual stock by default, instead of physical stock, for replenishment feature
|
||||||
|
UseVirtualStock=Use virtual stock
|
||||||
|
UsePhysicalStock=Use physical stock
|
||||||
|
CurentSelectionMode=Curent selection mode
|
||||||
|
CurentlyUsingVirtualStock=Virtual stock
|
||||||
|
CurentlyUsingPhysicalStock=Physical stock
|
||||||
RuleForStockReplenishment=Rule for stocks replenishment
|
RuleForStockReplenishment=Rule for stocks replenishment
|
||||||
SelectProductWithNotNullQty=Select at least one product with a qty not null and a supplier
|
SelectProductWithNotNullQty=Select at least one product with a qty not null and a supplier
|
||||||
AlertOnly= Alerts only
|
AlertOnly= Alerts only
|
||||||
WarehouseForStockDecrease=The warehouse <b>%s</b> will be used for stock decrease
|
WarehouseForStockDecrease=The warehouse <b>%s</b> will be used for stock decrease
|
||||||
WarehouseForStockIncrease=The warehouse <b>%s</b> will be used for stock increase
|
WarehouseForStockIncrease=The warehouse <b>%s</b> will be used for stock increase
|
||||||
ForThisWarehouse=For this warehouse
|
ForThisWarehouse=For this warehouse
|
||||||
ReplenishmentStatusDesc=This is list of all product with a physical stock lower than desired stock (or alert value if checkbox "alert only" is checked) and suggest you to create supplier orders to fill the difference.
|
ReplenishmentStatusDesc=This is list of all product with a stock lower than desired stock (or lower than alert value if checkbox "alert only" is checked), and suggest you to create supplier orders to fill the difference.
|
||||||
ReplenishmentOrdersDesc=This is list of all opened supplier orders
|
ReplenishmentOrdersDesc=This is list of all opened supplier orders
|
||||||
Replenishments=Replenishments
|
Replenishments=Replenishments
|
||||||
NbOfProductBeforePeriod=Quantity of product %s in stock before selected period (< %s)
|
NbOfProductBeforePeriod=Quantity of product %s in stock before selected period (< %s)
|
||||||
|
|||||||
@ -170,6 +170,19 @@ if ($action == 'order' && isset($_POST['valid']))
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$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=($conf->global->STOCK_USE_VIRTUAL_STOCK?1:0);
|
||||||
|
if (GETPOST('mode')=='virtual') $usevirtualstock=1;
|
||||||
|
if (GETPOST('mode')=='physical') $usevirtualstock=0;
|
||||||
|
}
|
||||||
|
|
||||||
$title = $langs->trans('Status');
|
$title = $langs->trans('Status');
|
||||||
|
|
||||||
$sql = 'SELECT p.rowid, p.ref, p.label, p.price,';
|
$sql = 'SELECT p.rowid, p.ref, p.label, p.price,';
|
||||||
@ -251,7 +264,20 @@ $head[1][2] = 'replenishorders';
|
|||||||
|
|
||||||
dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock');
|
dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock');
|
||||||
|
|
||||||
print $langs->trans("ReplenishmentStatusDesc").'<br><br>';
|
print $langs->trans("ReplenishmentStatusDesc").'<br>'."\n";
|
||||||
|
if ($usevirtualstock == 1)
|
||||||
|
{
|
||||||
|
print $langs->trans("CurentSelectionMode").': ';
|
||||||
|
print $langs->trans("CurentlyUsingVirtualStock").' - ';
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=physical">'.$langs->trans("UsePhysicalStock").'</a><br>';
|
||||||
|
}
|
||||||
|
if ($usevirtualstock == 0)
|
||||||
|
{
|
||||||
|
print $langs->trans("CurentSelectionMode").': ';
|
||||||
|
print $langs->trans("CurentlyUsingPhysicalStock").' - ';
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=virtual">'.$langs->trans("UseVirtualStock").'</a><br>';
|
||||||
|
}
|
||||||
|
print '<br>'."\n";
|
||||||
|
|
||||||
if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
|
if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) {
|
||||||
$filters = '&sref=' . $sref . '&snom=' . $snom;
|
$filters = '&sref=' . $sref . '&snom=' . $snom;
|
||||||
@ -344,14 +370,11 @@ print_liste_field_titre(
|
|||||||
$sortfield,
|
$sortfield,
|
||||||
$sortorder
|
$sortorder
|
||||||
);
|
);
|
||||||
if ($conf->global->USE_VIRTUAL_STOCK)
|
|
||||||
{
|
$stocklabel = $langs->trans('Stock');
|
||||||
$stocklabel = $langs->trans('VirtualStock');
|
if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock');
|
||||||
}
|
if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock');
|
||||||
else
|
|
||||||
{
|
|
||||||
$stocklabel = $langs->trans('PhysicalStock');
|
|
||||||
}
|
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
$stocklabel,
|
$stocklabel,
|
||||||
$_SERVER["PHP_SELF"],
|
$_SERVER["PHP_SELF"],
|
||||||
@ -449,9 +472,9 @@ while ($i < min($num, $limit))
|
|||||||
$prod->type = $objp->fk_product_type;
|
$prod->type = $objp->fk_product_type;
|
||||||
$ordered = ordered($prod->id);
|
$ordered = ordered($prod->id);
|
||||||
|
|
||||||
if ($conf->global->USE_VIRTUAL_STOCK)
|
if ($usevirtualstock)
|
||||||
{
|
{
|
||||||
//compute virtual stock
|
// If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.
|
||||||
$prod->fetch($prod->id);
|
$prod->fetch($prod->id);
|
||||||
$result=$prod->load_stats_commande(0, '1,2');
|
$result=$prod->load_stats_commande(0, '1,2');
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user