dolibarr/htdocs/admin/stock.php

278 lines
11 KiB
PHP
Raw Normal View History

2006-12-04 12:17:24 +01:00
<?php
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
2012-03-29 12:41:11 +02:00
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
2013-03-22 17:10:17 +01:00
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
2006-12-04 12:17:24 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2006-12-04 12:17:24 +01:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2006-12-04 12:17:24 +01:00
*/
/**
2009-11-18 00:05:00 +01:00
* \file htdocs/admin/stock.php
* \ingroup stock
* \brief Page d'administration/configuration du module gestion de stock
2008-10-23 23:54:30 +02:00
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
2006-12-04 12:17:24 +01:00
$langs->load("admin");
$langs->load("stocks");
2006-12-04 12:17:24 +01:00
2008-10-24 22:16:36 +02:00
// Securit check
2011-09-21 15:16:13 +02:00
if (!$user->admin) accessforbidden();
2006-12-04 12:17:24 +01:00
2012-03-29 12:41:11 +02:00
$action = GETPOST('action','alpha');
2011-09-02 16:31:53 +02:00
2008-10-24 22:16:36 +02:00
/*
2008-10-23 23:54:30 +02:00
* Actions
*/
2010-06-17 18:53:26 +02:00
2011-09-02 16:31:53 +02:00
if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
2006-12-04 12:17:24 +01:00
{
2011-09-02 16:31:53 +02:00
$db->begin();
2012-03-29 12:41:11 +02:00
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
2006-12-04 12:17:24 +01:00
}
2008-10-24 22:16:36 +02:00
// Mode of stock decrease
2011-09-02 16:31:53 +02:00
if ($action == 'STOCK_CALCULATE_ON_BILL'
|| $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|| $action == 'STOCK_CALCULATE_ON_SHIPMENT')
{
$db->begin();
2011-09-02 16:31:53 +02:00
$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_SHIPMENT", '','chaine',0,'',$conf->entity);
2012-03-29 12:41:11 +02:00
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_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
2008-10-23 23:54:30 +02:00
}
// Mode of stock increase
2011-09-02 16:31:53 +02:00
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
2013-04-20 00:10:20 +02:00
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
2008-10-24 22:16:36 +02:00
{
$db->begin();
2011-09-02 16:31:53 +02:00
$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_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
2012-03-29 12:41:11 +02:00
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_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);
2008-10-24 22:16:36 +02:00
}
if($action == 'USE_VIRTUAL_STOCK') {
$db->begin();
$res = dolibarr_set_const($db, "USE_VIRTUAL_STOCK", GETPOST('USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity);
}
2011-09-02 16:31:53 +02:00
if($action)
{
if (! $res > 0) $error++;
if (! $error)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
2006-12-04 12:17:24 +01:00
/*
* View
2006-12-04 12:17:24 +01:00
*/
2006-12-04 12:17:24 +01:00
llxHeader('',$langs->trans("StockSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup');
print '<br>';
2006-12-04 12:17:24 +01:00
2013-03-22 17:10:17 +01:00
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/stock.php";
2013-03-24 07:11:44 +01:00
$head[$h][1] = $langs->trans("Miscellaneous");
2013-03-22 17:10:17 +01:00
$head[$h][2] = 'general';
$hselected=$h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
$form=new Form($db);
2006-12-04 12:17:24 +01:00
$var=true;
print '<table class="noborder" width="100%">';
2006-12-04 12:17:24 +01:00
print '<tr class="liste_titre">';
print " <td>".$langs->trans("Parameters")."</td>\n";
2011-11-14 17:03:57 +01:00
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
2006-12-04 12:17:24 +01:00
/*
* Formulaire parametres divers
*/
2010-07-11 21:29:18 +02:00
2006-12-04 12:17:24 +01:00
$var=!$var;
2010-07-11 21:29:18 +02:00
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
2006-12-04 12:17:24 +01:00
print '<td width="160" align="right">';
2010-07-11 21:29:18 +02:00
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2010-07-11 21:29:18 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
2006-12-04 12:17:24 +01:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
2010-07-11 21:29:18 +02:00
print '</form>';
print "</td>\n";
print "</tr>\n";
2013-03-22 17:10:17 +01:00
print '<br>';
print '</table>';
print '<br>';
2008-10-23 23:54:30 +02:00
// Title rule for stock decrease
2013-03-22 17:10:17 +01:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
2008-10-23 23:54:30 +02:00
print " <td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n";
2011-11-14 17:03:57 +01:00
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
$var=true;
2012-09-15 10:01:35 +02:00
if (! empty($conf->facture->enabled))
{
$var=!$var;
2008-10-23 23:54:30 +02:00
print "<tr ".$bc[$var].">";
2008-10-24 22:16:36 +02:00
print '<td width="60%">'.$langs->trans("DeStockOnBill").'</td>';
2008-10-23 23:54:30 +02:00
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_BILL\">";
print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1);
2008-10-23 23:54:30 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}
2006-12-04 12:17:24 +01:00
2012-09-15 10:01:35 +02:00
if (! empty($conf->commande->enabled))
{
$var=!$var;
2008-10-23 23:54:30 +02:00
print "<tr ".$bc[$var].">";
2008-10-24 22:16:36 +02:00
print '<td width="60%">'.$langs->trans("DeStockOnValidateOrder").'</td>';
2008-10-23 23:54:30 +02:00
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_VALIDATE_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1);
2008-10-23 23:54:30 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}
2012-09-15 10:01:35 +02:00
if (! empty($conf->expedition->enabled))
{
$var=!$var;
2008-10-23 23:54:30 +02:00
print "<tr ".$bc[$var].">";
2008-10-24 22:16:36 +02:00
print '<td width="60%">'.$langs->trans("DeStockOnShipment").'</td>';
2008-10-23 23:54:30 +02:00
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1);
2008-10-23 23:54:30 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}
2013-03-22 17:10:17 +01:00
print '</table>';
print '<br>';
2008-10-23 23:54:30 +02:00
// Title rule for stock increase
2013-03-22 17:10:17 +01:00
print '<table class="noborder" width="100%">';
2008-10-23 23:54:30 +02:00
print '<tr class="liste_titre">';
print " <td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
2011-11-14 17:03:57 +01:00
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
2008-10-23 23:54:30 +02:00
print '</tr>'."\n";
$var=true;
2012-09-15 10:01:35 +02:00
if (! empty($conf->fournisseur->enabled))
2008-10-24 22:16:36 +02:00
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("ReStockOnBill").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_BILL\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1);
2008-10-24 22:16:36 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}
2008-10-23 23:54:30 +02:00
2012-09-15 10:01:35 +02:00
if (! empty($conf->fournisseur->enabled))
2008-10-24 22:16:36 +02:00
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("ReStockOnValidateOrder").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1);
2008-10-24 22:16:36 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
2010-07-11 21:29:18 +02:00
}
2012-09-15 10:01:35 +02:00
if (! empty($conf->fournisseur->enabled))
2010-07-11 21:29:18 +02:00
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
2008-10-24 22:16:36 +02:00
}
2008-10-23 23:54:30 +02:00
2006-12-04 12:17:24 +01:00
print '</table>';
2011-09-02 16:31:53 +02:00
2013-06-10 17:20:49 +02:00
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("RuleForStockReplenishment")."</td>\n";
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
2013-06-27 15:54:29 +02:00
$var = !$var;
2013-06-10 17:20:49 +02:00
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UseVirtualStock").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"USE_VIRTUAL_STOCK\">";
print $form->selectyesno("USE_VIRTUAL_STOCK",$conf->global->USE_VIRTUAL_STOCK,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '</table>';
2011-09-02 16:31:53 +02:00
dol_htmloutput_mesg($mesg);
2006-12-04 12:17:24 +01:00
$db->close();
llxFooter();
2006-12-04 12:17:24 +01:00
?>