dolibarr/htdocs/admin/stock.php

246 lines
8.6 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 Laurent Destailleur <eldy@users.sourceforge.net>
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 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
\file htdocs/admin/stock.php
2008-10-23 23:54:30 +02:00
\ingroup stock
\brief Page d'administration/configuration du module gestion de stock
\version $Id$
*/
2006-12-04 12:17:24 +01:00
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/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
2006-12-04 12:17:24 +01:00
if (!$user->admin)
2008-10-23 23:54:30 +02:00
accessforbidden();
2006-12-04 12:17:24 +01:00
2008-10-24 22:16:36 +02:00
/*
2008-10-23 23:54:30 +02:00
* Actions
*/
2008-10-24 22:16:36 +02:00
if ($_POST["action"] == 'STOCK_USERSTOCK')
2006-12-04 12:17:24 +01:00
{
2008-10-24 22:16:36 +02:00
dolibarr_set_const($db, "STOCK_USERSTOCK", $_POST["STOCK_USERSTOCK"]);
//On desactive l'autocreation si l'option "stock personnel" est desactivee
if ($_POST["STOCK_USERSTOCK"] == 0)
2008-10-23 23:54:30 +02:00
{
dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", 0);
}
Header("Location: stock.php");
exit;
2006-12-04 12:17:24 +01:00
}
2008-10-24 22:16:36 +02:00
elseif ($_POST["action"] == 'STOCK_USERSTOCK_AUTOCREATE')
2006-12-04 12:17:24 +01:00
{
2008-10-24 22:16:36 +02:00
dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", $_POST["STOCK_USERSTOCK_AUTOCREATE"]);
2008-10-23 23:54:30 +02:00
Header("Location: stock.php");
exit;
2006-12-04 12:17:24 +01:00
}
2008-10-24 22:16:36 +02:00
// Mode of stock decrease
if ($_POST["action"] == 'STOCK_CALCULATE_ON_BILL'
|| $_POST["action"] == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|| $_POST["action"] == 'STOCK_CALCULATE_ON_SHIPMENT')
{
$count=0;
$db->begin();
$count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '');
$count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '');
$count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '');
2008-10-24 22:16:36 +02:00
if ($_POST["action"] == 'STOCK_CALCULATE_ON_BILL') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", $_POST["STOCK_CALCULATE_ON_BILL"]);
if ($_POST["action"] == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", $_POST["STOCK_CALCULATE_ON_VALIDATE_ORDER"]);
if ($_POST["action"] == 'STOCK_CALCULATE_ON_SHIPMENT') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", $_POST["STOCK_CALCULATE_ON_SHIPMENT"]);
if ($count == 4)
{
$db->commit();
2008-10-23 23:54:30 +02:00
Header("Location: stock.php");
exit;
}
else
2008-10-23 23:54:30 +02:00
{
$db->rollback();
dol_print_error("Error in some requests", LOG_ERR);
}
2008-10-23 23:54:30 +02:00
}
2008-10-24 22:16:36 +02:00
// Mode of stock decrease
if ($_POST["action"] == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|| $_POST["action"] == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')
{
$count=0;
$db->begin();
$count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '');
$count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '');
if ($_POST["action"] == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", $_POST["STOCK_CALCULATE_ON_SUPPLIER_BILL"]);
if ($_POST["action"] == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $count+=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $_POST["STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER"]);
if ($count == 3)
{
$db->commit();
Header("Location: stock.php");
exit;
}
else
{
$db->rollback();
dol_print_error("Error in some requests", LOG_ERR);
2008-10-24 22:16:36 +02:00
}
}
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
$html=new Form($db);
$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";
print " <td align=\"right\" width=\"160\">".$langs->trans("Value")."</td>\n";
print '</tr>'."\n";
2006-12-04 12:17:24 +01:00
/*
* Formulaire parametres divers
*/
// sousproduits activation/desactivation
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UserWarehouse").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK\">";
print $html->selectyesno("STOCK_USERSTOCK",$conf->global->STOCK_USERSTOCK,1);
2006-12-04 12:17:24 +01: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
if ($conf->global->STOCK_USERSTOCK == 1)
{
2008-10-23 23:54:30 +02:00
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $html->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
2008-10-23 23:54:30 +02:00
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
2006-12-04 12:17:24 +01:00
}
2008-10-23 23:54:30 +02:00
// Title rule for stock decrease
print '<tr class="liste_titre">';
2008-10-23 23:54:30 +02:00
print " <td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n";
print " <td align=\"right\" width=\"160\">".$langs->trans("Value")."</td>\n";
print '</tr>'."\n";
$var=true;
if ($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\">";
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_BILL\">";
print $html->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
if ($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\">";
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_VALIDATE_ORDER\">";
print $html->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";
}
if ($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\">";
2008-10-24 22:16:36 +02:00
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT\">";
print $html->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";
}
2008-10-23 23:54:30 +02:00
// Title rule for stock increase
print '<tr class="liste_titre">';
print " <td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
print " <td align=\"right\" width=\"160\">".$langs->trans("Value")."</td>\n";
print '</tr>'."\n";
$var=true;
2008-10-24 22:16:36 +02:00
if ($conf->fournisseur->enabled)
{
$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=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_BILL\">";
print $html->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1);
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
2008-10-24 22:16:36 +02:00
if ($conf->commande->enabled)
{
$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=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER\">";
print $html->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1);
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
2006-12-04 12:17:24 +01:00
print '</table>';
$db->close();
llxFooter('$Date$ - $Revision$');
2006-12-04 12:17:24 +01:00
?>