stock.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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-2013 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
  7. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/admin/stock.php
  24. * \ingroup stock
  25. * \brief Page d'administration/configuration du module gestion de stock
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  29. $langs->load("admin");
  30. $langs->load("stocks");
  31. // Securit check
  32. if (!$user->admin) accessforbidden();
  33. $action = GETPOST('action','alpha');
  34. /*
  35. * Actions
  36. */
  37. if($action)
  38. {
  39. $db->begin();
  40. if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
  41. {
  42. $res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
  43. }
  44. if ($action == 'STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE') {
  45. $res = dolibarr_set_const($db, "STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", GETPOST('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE','alpha'),'chaine',0,'',$conf->entity);
  46. }
  47. if ($action == 'STOCK_ALLOW_NEGATIVE_TRANSFER')
  48. {
  49. $res = dolibarr_set_const($db, "STOCK_ALLOW_NEGATIVE_TRANSFER", GETPOST('STOCK_ALLOW_NEGATIVE_TRANSFER','alpha'),'chaine',0,'',$conf->entity);
  50. }
  51. // Mode of stock decrease
  52. if ($action == 'STOCK_CALCULATE_ON_BILL'
  53. || $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
  54. || $action == 'STOCK_CALCULATE_ON_SHIPMENT'
  55. || $action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE')
  56. {
  57. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity);
  58. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
  59. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity);
  60. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", '','chaine',0,'',$conf->entity);
  61. 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);
  62. 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);
  63. 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);
  64. if ($action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", GETPOST('STOCK_CALCULATE_ON_SHIPMENT_CLOSE','alpha'),'chaine',0,'',$conf->entity);
  65. }
  66. // Mode of stock increase
  67. if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
  68. || $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
  69. || $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
  70. {
  71. //Use variable cause empty(GETPOST()) do not work with php version < 5.4
  72. $valdispatch=GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha');
  73. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
  74. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
  75. $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
  76. 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);
  77. 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);
  78. if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $valdispatch,'chaine',0,'',$conf->entity);
  79. if (empty($valdispatch)) {
  80. $res=dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", '','chaine',0,'',$conf->entity);
  81. }
  82. }
  83. if($action == 'SUPPLIER_ORDER_USE_DISPATCH_STATUS') {
  84. $res = dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", GETPOST('SUPPLIER_ORDER_USE_DISPATCH_STATUS','alpha'),'chaine',0,'',$conf->entity);
  85. }
  86. if($action == 'STOCK_USE_VIRTUAL_STOCK') {
  87. $res = dolibarr_set_const($db, "STOCK_USE_VIRTUAL_STOCK", GETPOST('STOCK_USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity);
  88. }
  89. if($action == 'STOCK_MUST_BE_ENOUGH_FOR_INVOICE') {
  90. $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_INVOICE", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_INVOICE','alpha'),'chaine',0,'',$conf->entity);
  91. }
  92. if($action == 'STOCK_MUST_BE_ENOUGH_FOR_ORDER') {
  93. $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_ORDER", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_ORDER','alpha'),'chaine',0,'',$conf->entity);
  94. }
  95. if($action == 'STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT') {
  96. $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
  97. }
  98. if($action == 'INDEPENDANT_SUBPRODUCT_STOCK') {
  99. $res = dolibarr_set_const($db, "INDEPENDANT_SUBPRODUCT_STOCK", GETPOST('INDEPENDANT_SUBPRODUCT_STOCK','alpha'),'chaine',0,'',$conf->entity);
  100. }
  101. if (! $res > 0) $error++;
  102. if (! $error)
  103. {
  104. $db->commit();
  105. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  106. }
  107. else
  108. {
  109. $db->rollback();
  110. setEventMessages($langs->trans("Error"), null, 'errors');
  111. }
  112. }
  113. /*
  114. * View
  115. */
  116. llxHeader('',$langs->trans("StockSetup"));
  117. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  118. print load_fiche_titre($langs->trans("StockSetup"),$linkback,'title_setup');
  119. $form=new Form($db);
  120. $disabled='';
  121. if (! empty($conf->productbatch->enabled))
  122. {
  123. $langs->load("productbatch");
  124. $disabled=' disabled';
  125. print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced"));
  126. }
  127. //if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
  128. //{
  129. print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
  130. print '<br>';
  131. //}
  132. // Title rule for stock decrease
  133. print '<table class="noborder" width="100%">';
  134. print '<tr class="liste_titre">';
  135. print " <td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n";
  136. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  137. print '</tr>'."\n";
  138. $var=true;
  139. $found=0;
  140. print '<tr class="oddeven">';
  141. print '<td width="60%">'.$langs->trans("DeStockOnBill").'</td>';
  142. print '<td width="160" align="right">';
  143. if (! empty($conf->facture->enabled))
  144. {
  145. print "<form method=\"post\" action=\"stock.php\">";
  146. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  147. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_BILL\">";
  148. print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1,$disabled);
  149. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  150. print "</form>\n";
  151. }
  152. else
  153. {
  154. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
  155. }
  156. print "</td>\n</tr>\n";
  157. $found++;
  158. print '<tr class="oddeven">';
  159. print '<td width="60%">'.$langs->trans("DeStockOnValidateOrder").'</td>';
  160. print '<td width="160" align="right">';
  161. if (! empty($conf->commande->enabled))
  162. {
  163. print "<form method=\"post\" action=\"stock.php\">";
  164. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  165. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_VALIDATE_ORDER\">";
  166. print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1,$disabled);
  167. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  168. print "</form>\n";
  169. }
  170. else
  171. {
  172. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
  173. }
  174. print "</td>\n</tr>\n";
  175. $found++;
  176. //if (! empty($conf->expedition->enabled))
  177. //{
  178. print '<tr class="oddeven">';
  179. print '<td width="60%">'.$langs->trans("DeStockOnShipment").'</td>';
  180. print '<td width="160" align="right">';
  181. if (! empty($conf->expedition->enabled))
  182. {
  183. print "<form method=\"post\" action=\"stock.php\">";
  184. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  185. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT\">";
  186. print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1,$disabled);
  187. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  188. print "</form>\n";
  189. }
  190. else
  191. {
  192. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
  193. }
  194. print "</td>\n</tr>\n";
  195. $found++;
  196. print '<tr class="oddeven">';
  197. print '<td width="60%">'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
  198. print '<td width="160" align="right">';
  199. if (! empty($conf->expedition->enabled))
  200. {
  201. print "<form method=\"post\" action=\"stock.php\">";
  202. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  203. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT_CLOSE\">";
  204. print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT_CLOSE",$conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE,1,$disabled);
  205. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  206. print "</form>\n";
  207. }
  208. else
  209. {
  210. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
  211. }
  212. print "</td>\n</tr>\n";
  213. $found++;
  214. /*if (! $found)
  215. {
  216. print '<tr class="oddeven">';
  217. print '<td colspan="2">'.$langs->trans("NoModuleToManageStockDecrease").'</td>';
  218. print "</tr>\n";
  219. }*/
  220. print '</table>';
  221. print '<br>';
  222. // Title rule for stock increase
  223. print '<table class="noborder" width="100%">';
  224. print '<tr class="liste_titre">';
  225. print " <td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
  226. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  227. print '</tr>'."\n";
  228. $var=true;
  229. $found=0;
  230. print '<tr class="oddeven">';
  231. print '<td width="60%">'.$langs->trans("ReStockOnBill").'</td>';
  232. print '<td width="160" align="right">';
  233. if (! empty($conf->fournisseur->enabled))
  234. {
  235. print "<form method=\"post\" action=\"stock.php\">";
  236. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  237. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_BILL\">";
  238. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1,$disabled);
  239. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  240. print "</form>\n";
  241. }
  242. else
  243. {
  244. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
  245. }
  246. print "</td>\n</tr>\n";
  247. $found++;
  248. print '<tr class="oddeven">';
  249. print '<td width="60%">'.$langs->trans("ReStockOnValidateOrder").'</td>';
  250. print '<td width="160" align="right">';
  251. if (! empty($conf->fournisseur->enabled))
  252. {
  253. print "<form method=\"post\" action=\"stock.php\">";
  254. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  255. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER\">";
  256. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1,$disabled);
  257. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  258. print "</form>\n";
  259. }
  260. else
  261. {
  262. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
  263. }
  264. print "</td>\n</tr>\n";
  265. $found++;
  266. print '<tr class="oddeven">';
  267. print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
  268. print '<td width="160" align="right">';
  269. if (! empty($conf->fournisseur->enabled))
  270. {
  271. print "<form method=\"post\" action=\"stock.php\">";
  272. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  273. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
  274. print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled);
  275. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
  276. print "</form>\n";
  277. }
  278. else
  279. {
  280. print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
  281. }
  282. print "</td>\n</tr>\n";
  283. $found++;
  284. /*if (! $found)
  285. {
  286. print '<tr class="oddeven">';
  287. print '<td colspan="2">'.$langs->trans("NoModuleToManageStockIncrease").'</td>';
  288. print "</tr>\n";
  289. }*/
  290. print '</table>';
  291. print '<br>';
  292. print '<table class="noborder" width="100%">';
  293. print '<tr class="liste_titre">';
  294. print " <td>".$langs->trans("RuleForStockAvailability")."</td>\n";
  295. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  296. print '</tr>'."\n";
  297. print '<tr class="oddeven">';
  298. print '<td width="60%">'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
  299. print '<td width="160" align="right">';
  300. print "<form method=\"post\" action=\"stock.php\">";
  301. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  302. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_NEGATIVE_TRANSFER\">";
  303. print $form->selectyesno("STOCK_ALLOW_NEGATIVE_TRANSFER",$conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER,1);
  304. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  305. print '</form>';
  306. print "</td>\n";
  307. print "</tr>\n";
  308. // Option to force stock to be enough before adding a line into document
  309. if($conf->invoice->enabled) {
  310. $var = !$var;
  311. print '<tr class="oddeven">';
  312. print '<td width="60%">'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
  313. print '<td width="160" align="right">';
  314. print "<form method=\"post\" action=\"stock.php\">";
  315. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  316. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_INVOICE\">";
  317. print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_INVOICE",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE,1);
  318. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  319. print '</form>';
  320. print "</td>\n";
  321. print "</tr>\n";
  322. }
  323. if($conf->order->enabled) {
  324. $var = !$var;
  325. print '<tr class="oddeven">';
  326. print '<td width="60%">'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
  327. print '<td width="160" align="right">';
  328. print "<form method=\"post\" action=\"stock.php\">";
  329. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  330. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_ORDER\">";
  331. print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_ORDER",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER,1);
  332. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  333. print '</form>';
  334. print "</td>\n";
  335. print "</tr>\n";
  336. }
  337. if($conf->expedition->enabled) {
  338. $var = !$var;
  339. print '<tr class="oddeven">';
  340. print '<td width="60%">'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
  341. print '<td width="160" align="right">';
  342. print "<form method=\"post\" action=\"stock.php\">";
  343. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  344. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT\">";
  345. print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT,1);
  346. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  347. print '</form>';
  348. print "</td>\n";
  349. print "</tr>\n";
  350. }
  351. print '</table>';
  352. $virtualdiffersfromphysical=0;
  353. if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
  354. || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
  355. ) $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
  356. if ($virtualdiffersfromphysical)
  357. {
  358. print '<br>';
  359. print '<table class="noborder" width="100%">';
  360. print '<tr class="liste_titre">';
  361. print " <td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
  362. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  363. print '</tr>'."\n";
  364. $var = !$var;
  365. print '<tr class="oddeven">';
  366. print '<td width="60%">'.$langs->trans("UseVirtualStockByDefault").'</td>';
  367. print '<td width="160" align="right">';
  368. print "<form method=\"post\" action=\"stock.php\">";
  369. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  370. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USE_VIRTUAL_STOCK\">";
  371. print $form->selectyesno("STOCK_USE_VIRTUAL_STOCK",$conf->global->STOCK_USE_VIRTUAL_STOCK,1);
  372. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  373. print '</form>';
  374. print "</td>\n";
  375. print "</tr>\n";
  376. print '</table>';
  377. }
  378. print '<br />';
  379. if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
  380. {
  381. print '<table class="noborder" width="100%">';
  382. print '<tr class="liste_titre">';
  383. print '<td>'.$langs->trans("Inventory").'</td>'."\n";
  384. print '<td align="center" width="20">&nbsp;</td>';
  385. print '<td align="center" width="100">&nbsp;</td>'."\n";
  386. // Example with a yes / no select
  387. print '<tr class="oddeven">';
  388. print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
  389. print '<td align="center" width="20">&nbsp;</td>';
  390. print '<td align="right" width="300">';
  391. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  392. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  393. print '<input type="hidden" name="action" value="set_INVENTORY_DISABLE_VIRTUAL">';
  394. print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1);
  395. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  396. print '</form>';
  397. print '</td></tr>';
  398. // Example with a yes / no select
  399. print '<tr class="oddeven">';
  400. print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
  401. print '<td align="center" width="20">&nbsp;</td>';
  402. print '<td align="right" width="300">';
  403. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  404. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  405. print '<input type="hidden" name="action" value="set_INVENTORY_USE_MIN_PA_IF_NO_LAST_PA">';
  406. print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1);
  407. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  408. print '</form>';
  409. print '</td></tr>';
  410. // Example with a yes / no select
  411. print '<tr class="oddeven">';
  412. print '<td>'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'</td>';
  413. print '<td align="center" width="20">&nbsp;</td>';
  414. print '<td align="right" width="300">';
  415. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  416. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  417. print '<input type="hidden" name="action" value="set_INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT">';
  418. print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1);
  419. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  420. print '</form>';
  421. print '</td></tr>';
  422. print '</table>';
  423. }
  424. print '<table class="noborder" width="100%">';
  425. print '<tr class="liste_titre">';
  426. print " <td>".$langs->trans("Other")."</td>\n";
  427. print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
  428. print '</tr>'."\n";
  429. if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
  430. print '<tr class="oddeven">';
  431. print '<td width="60%">'.$langs->trans("UseDispatchStatus").'</td>';
  432. print '<td width="160" align="right">';
  433. print "<form method=\"post\" action=\"stock.php\">";
  434. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  435. print "<input type=\"hidden\" name=\"action\" value=\"SUPPLIER_ORDER_USE_DISPATCH_STATUS\">";
  436. print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1);
  437. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  438. print "</form>\n";
  439. print "</td>\n</tr>\n";
  440. }
  441. print '<tr class="oddeven">';
  442. print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
  443. print '<td width="160" align="right">';
  444. print "<form method=\"post\" action=\"stock.php\">";
  445. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  446. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
  447. print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
  448. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  449. print '</form>';
  450. print "</td>\n";
  451. print "</tr>\n";
  452. print '<tr class="oddeven">';
  453. print '<td width="60%">'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
  454. print '<td width="160" align="right">';
  455. print "<form method=\"post\" action=\"stock.php\">";
  456. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  457. print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE\">";
  458. print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1);
  459. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  460. print '</form>';
  461. print "</td>\n";
  462. print "</tr>\n";
  463. print '<br>';
  464. /* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it.
  465. If not used by a module, I still need to understand in which case user may need this now we can set rule on product page.
  466. if ($conf->global->PRODUIT_SOUSPRODUITS)
  467. {
  468. print '<tr class="oddeven">';
  469. print '<td width="60%">'.$langs->trans("IndependantSubProductStock").'</td>';
  470. print '<td width="160" align="right">';
  471. print "<form method=\"post\" action=\"stock.php\">";
  472. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  473. print "<input type=\"hidden\" name=\"action\" value=\"INDEPENDANT_SUBPRODUCT_STOCK\">";
  474. print $form->selectyesno("INDEPENDANT_SUBPRODUCT_STOCK",$conf->global->INDEPENDANT_SUBPRODUCT_STOCK,1);
  475. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  476. print '</form>';
  477. print "</td>\n";
  478. print "</tr>\n";
  479. }
  480. */
  481. print '</table>';
  482. llxFooter();
  483. $db->close();