PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/stock.php

https://bitbucket.org/speedealing/speedealing
PHP | 234 lines | 166 code | 31 blank | 37 comment | 36 complexity | 1299d8e261c0b06c80a058b58d8382ce MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/admin/stock.php
  22. * \ingroup stock
  23. * \brief Page d'administration/configuration du module gestion de stock
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. $langs->load("admin");
  28. $langs->load("stocks");
  29. // Securit check
  30. if (!$user->admin) accessforbidden();
  31. $action = GETPOST('action','alpha');
  32. /*
  33. * Actions
  34. */
  35. if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
  36. {
  37. $db->begin();
  38. $res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
  39. }
  40. // Mode of stock decrease
  41. if ($action == 'STOCK_CALCULATE_ON_BILL'
  42. || $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
  43. || $action == 'STOCK_CALCULATE_ON_SHIPMENT')
  44. {
  45. $db->begin();
  46. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity);
  47. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
  48. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity);
  49. 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);
  50. 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);
  51. 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);
  52. }
  53. // Mode of stock increase
  54. if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
  55. || $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
  56. || $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
  57. {
  58. $db->begin();
  59. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
  60. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
  61. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
  62. 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);
  63. 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);
  64. 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);
  65. }
  66. if($action)
  67. {
  68. if (! $res > 0) $error++;
  69. if (! $error)
  70. {
  71. $db->commit();
  72. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  73. }
  74. else
  75. {
  76. $db->rollback();
  77. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  78. }
  79. }
  80. /*
  81. * View
  82. */
  83. llxHeader('',$langs->trans("StockSetup"));
  84. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  85. print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup');
  86. print '<br>';
  87. $form=new Form($db);
  88. $var=true;
  89. print '<table class="noborder" width="100%">';
  90. print '<tr class="liste_titre">';
  91. print " <td>".$langs->trans("Parameters")."</td>\n";
  92. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  93. print '</tr>'."\n";
  94. /*
  95. * Formulaire parametres divers
  96. */
  97. $var=!$var;
  98. print "<tr ".$bc[$var].">";
  99. print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
  100. print '<td width="160" align="right">';
  101. print "<form method=\"post\" action=\"stock.php\">";
  102. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  103. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
  104. print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
  105. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  106. print '</form>';
  107. print "</td>\n";
  108. print "</tr>\n";
  109. // Title rule for stock decrease
  110. print '<tr class="liste_titre">';
  111. print " <td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n";
  112. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  113. print '</tr>'."\n";
  114. $var=true;
  115. if (! empty($conf->facture->enabled))
  116. {
  117. $var=!$var;
  118. print "<tr ".$bc[$var].">";
  119. print '<td width="60%">'.$langs->trans("DeStockOnBill").'</td>';
  120. print '<td width="160" align="right">';
  121. print "<form method=\"post\" action=\"stock.php\">";
  122. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  123. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_BILL\">";
  124. print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1);
  125. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  126. print "</form>\n</td>\n</tr>\n";
  127. }
  128. if (! empty($conf->commande->enabled))
  129. {
  130. $var=!$var;
  131. print "<tr ".$bc[$var].">";
  132. print '<td width="60%">'.$langs->trans("DeStockOnValidateOrder").'</td>';
  133. print '<td width="160" align="right">';
  134. print "<form method=\"post\" action=\"stock.php\">";
  135. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  136. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_VALIDATE_ORDER\">";
  137. print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1);
  138. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  139. print "</form>\n</td>\n</tr>\n";
  140. }
  141. if (! empty($conf->expedition->enabled))
  142. {
  143. $var=!$var;
  144. print "<tr ".$bc[$var].">";
  145. print '<td width="60%">'.$langs->trans("DeStockOnShipment").'</td>';
  146. print '<td width="160" align="right">';
  147. print "<form method=\"post\" action=\"stock.php\">";
  148. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  149. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT\">";
  150. print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1);
  151. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  152. print "</form>\n</td>\n</tr>\n";
  153. }
  154. // Title rule for stock increase
  155. print '<tr class="liste_titre">';
  156. print " <td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
  157. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  158. print '</tr>'."\n";
  159. $var=true;
  160. if (! empty($conf->fournisseur->enabled))
  161. {
  162. $var=!$var;
  163. print "<tr ".$bc[$var].">";
  164. print '<td width="60%">'.$langs->trans("ReStockOnBill").'</td>';
  165. print '<td width="160" align="right">';
  166. print "<form method=\"post\" action=\"stock.php\">";
  167. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  168. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_BILL\">";
  169. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1);
  170. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  171. print "</form>\n</td>\n</tr>\n";
  172. }
  173. if (! empty($conf->fournisseur->enabled))
  174. {
  175. $var=!$var;
  176. print "<tr ".$bc[$var].">";
  177. print '<td width="60%">'.$langs->trans("ReStockOnValidateOrder").'</td>';
  178. print '<td width="160" align="right">';
  179. print "<form method=\"post\" action=\"stock.php\">";
  180. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  181. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER\">";
  182. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1);
  183. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  184. print "</form>\n</td>\n</tr>\n";
  185. }
  186. if (! empty($conf->fournisseur->enabled))
  187. {
  188. $var=!$var;
  189. print "<tr ".$bc[$var].">";
  190. print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
  191. print '<td width="160" align="right">';
  192. print "<form method=\"post\" action=\"stock.php\">";
  193. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  194. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
  195. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1);
  196. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  197. print "</form>\n</td>\n</tr>\n";
  198. }
  199. print '</table>';
  200. dol_htmloutput_mesg($mesg);
  201. $db->close();
  202. llxFooter();
  203. ?>