dolibarr  18.0.6
stock.php
Go to the documentation of this file.
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@inodbox.com>
5  * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2013-2018 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 <https://www.gnu.org/licenses/>.
21  */
22 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("admin", "stocks"));
35 
36 // Securit check
37 if (!$user->admin) {
39 }
40 
41 $action = GETPOST('action', 'aZ09');
42 $value = GETPOST('value', 'alpha');
43 $label = GETPOST('label', 'alpha');
44 $scandir = GETPOST('scan_dir', 'alpha');
45 $type = 'stock';
46 
47 
48 /*
49  * Action
50  */
51 
52 $reg = array();
53 
54 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
55  $code = $reg[1];
56 
57  // If constant is for a unique choice, delete other choices
58  if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
59  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
60  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
61  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
62  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
63  }
64  if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
65  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
66  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
67  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
68  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
69  dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
70  }
71 
72  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
73  header("Location: ".$_SERVER["PHP_SELF"]);
74  exit;
75  } else {
76  dol_print_error($db);
77  }
78 }
79 
80 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
81  $code = $reg[1];
82  if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
83  header("Location: ".$_SERVER["PHP_SELF"]);
84  exit;
85  } else {
86  dol_print_error($db);
87  }
88 }
89 
90 if ($action == 'warehouse') {
91  $value = GETPOST('default_warehouse', 'alpha');
92  $res = dolibarr_set_const($db, "MAIN_DEFAULT_WAREHOUSE", $value, 'chaine', 0, '', $conf->entity);
93  if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) {
94  $res = dolibarr_del_const($db, "MAIN_DEFAULT_WAREHOUSE", $conf->entity);
95  }
96  if (!($res > 0)) {
97  $error++;
98  }
99 }
100 
101 if ($action == 'specimen') {
102  $modele = GETPOST('module', 'alpha');
103 
104  $object = new Entrepot($db);
105  $object->initAsSpecimen();
106 
107  // Search template files
108  $file = ''; $classname = ''; $filefound = 0;
109  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
110  foreach ($dirmodels as $reldir) {
111  $file = dol_buildpath($reldir."core/modules/stock/doc/pdf_".$modele.".modules.php", 0);
112  if (file_exists($file)) {
113  $filefound = 1;
114  $classname = "pdf_".$modele;
115  break;
116  }
117  }
118 
119  if ($filefound) {
120  require_once $file;
121 
122  $module = new $classname($db);
123 
124  if ($module->write_file($object, $langs) > 0) {
125  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=stock&file=SPECIMEN.pdf");
126  return;
127  } else {
128  setEventMessages($module->error, null, 'errors');
129  dol_syslog($module->error, LOG_ERR);
130  }
131  } else {
132  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
133  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
134  }
135 } elseif ($action == 'set') {
136  // Activate a model
137  $ret = addDocumentModel($value, $type, $label, $scandir);
138 } elseif ($action == 'del') {
139  $ret = delDocumentModel($value, $type);
140  if ($ret > 0) {
141  if ($conf->global->STOCK_ADDON_PDF == "$value") {
142  dolibarr_del_const($db, 'STOCK_ADDON_PDF', $conf->entity);
143  }
144  }
145 } elseif ($action == 'setdoc') {
146  // Set default model
147  if (dolibarr_set_const($db, "STOCK_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
148  // The constant that was read before the new set
149  // We therefore requires a variable to have a coherent view
150  $conf->global->STOCK_ADDON_PDF = $value;
151  }
152 
153  // On active le modele
154  $ret = delDocumentModel($value, $type);
155  if ($ret > 0) {
156  $ret = addDocumentModel($value, $type, $label, $scandir);
157  }
158 }
159 
160 
161 /*
162  * View
163  */
164 
165 $form = new Form($db);
166 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
167 
168 llxHeader('', $langs->trans("StockSetup"));
169 
170 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
171 print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup');
172 
173 $head = stock_admin_prepare_head();
174 
175 print dol_get_fiche_head($head, 'general', $langs->trans("StockSetup"), -1, 'stock');
176 
177 $form = new Form($db);
178 $formproduct = new FormProduct($db);
179 
180 
181 
182 $disabled = '';
183 if (isModEnabled('productbatch')) {
184  // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE
185  $langs->load("productbatch");
186  $disabled = ' disabled';
187 
188  // STOCK_CALCULATE_ON_SHIPMENT_CLOSE
189  $descmode = $langs->trans('DeStockOnShipmentOnClosing');
190  if (!isModEnabled('reception')) {
191  // STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER
192  $incmode = $langs->trans('ReStockOnDispatchOrder');
193  } else {
194  // STOCK_CALCULATE_ON_RECEPTION_CLOSE
195  $incmode = $langs->trans('StockOnReceptionOnClosing');
196  }
197  print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced", $descmode, $incmode));
198 }
199 
200 
201 print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
202 print '<br>';
203 
204 
205 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
206 print '<input type="hidden" name="token" value="'.newToken().'">';
207 print '<input type="hidden" name="action" value="warehouse">';
208 
209 // Title rule for stock decrease
210 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
211 print '<table class="noborder centpercent">';
212 print '<tr class="liste_titre">';
213 print "<td>".$langs->trans("RuleForStockManagementDecrease")."</td>\n";
214 print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
215 print '</tr>'."\n";
216 
217 $found = 0;
218 
219 print '<!-- STOCK_CALCULATE_ON_BILL -->';
220 print '<tr class="oddeven">';
221 print '<td>'.$langs->trans("DeStockOnBill").'</td>';
222 print '<td class="right">';
223 if (isModEnabled('facture')) {
224  if ($conf->use_javascript_ajax) {
225  if ($disabled) {
226  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
227  } else {
228  print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition');
229  }
230  } else {
231  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
232  print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
233  }
234 } else {
235  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
236 }
237 print "</td>\n</tr>\n";
238 $found++;
239 
240 
241 print '<!-- STOCK_CALCULATE_ON_VALIDATE_ORDER -->';
242 print '<tr class="oddeven">';
243 print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
244 print '<td class="right">';
245 if (isModEnabled('commande')) {
246  if ($conf->use_javascript_ajax) {
247  if ($disabled) {
248  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
249  } else {
250  print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
251  }
252  } else {
253  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
254  print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
255  }
256 } else {
257  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).'</span>';
258 }
259 print "</td>\n</tr>\n";
260 $found++;
261 
262 //if (isModEnabled('expedition'))
263 //{
264 
265 print '<!-- STOCK_CALCULATE_ON_SHIPMENT -->';
266 print '<tr class="oddeven">';
267 print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
268 print '<td class="right">';
269 if (isModEnabled("expedition")) {
270  if ($conf->use_javascript_ajax) {
271  print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
272  } else {
273  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
274  print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
275  }
276 } else {
277  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).'</span>';
278 }
279 print "</td>\n</tr>\n";
280 $found++;
281 
282 print '<!-- STOCK_CALCULATE_ON_SHIPMENT_CLOSE -->';
283 print '<tr class="oddeven">';
284 print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
285 print '<td class="right">';
286 if (isModEnabled("expedition")) {
287  if ($conf->use_javascript_ajax) {
288  print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
289  } else {
290  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
291  print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
292  }
293 } else {
294  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).'</span>';
295 }
296 print "</td>\n</tr>\n";
297 $found++;
298 
299 print '</table>';
300 print '</div>';
301 
302 print '<br>';
303 
304 
305 // Title rule for stock increase
306 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
307 print '<table class="noborder centpercent">';
308 print '<tr class="liste_titre">';
309 print "<td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
310 print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
311 print '</tr>'."\n";
312 
313 $found = 0;
314 
315 print '<!-- STOCK_CALCULATE_ON_SUPPLIER_BILL -->';
316 print '<tr class="oddeven">';
317 print '<td>'.$langs->trans("ReStockOnBill").'</td>';
318 print '<td class="right">';
319 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
320  if ($conf->use_javascript_ajax) {
321  if ($disabled) {
322  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
323  } else {
324  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
325  }
326  } else {
327  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
328  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
329  }
330 } else {
331  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
332 }
333 print "</td>\n</tr>\n";
334 $found++;
335 
336 
337 print '<!-- STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER -->';
338 print '<tr class="oddeven">';
339 print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
340 print '<td class="right">';
341 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
342  if ($conf->use_javascript_ajax) {
343  if ($disabled) {
344  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
345  } else {
346  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
347  }
348  } else {
349  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
350  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
351  }
352 } else {
353  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
354 }
355 print "</td>\n</tr>\n";
356 $found++;
357 
358 if (isModEnabled("reception")) {
359  print '<!-- STOCK_CALCULATE_ON_RECEPTION_CLOSE -->';
360  print '<tr class="oddeven">';
361  print '<td>'.$langs->trans("StockOnReception").'</td>';
362  print '<td class="right">';
363 
364  if ($conf->use_javascript_ajax) {
365  print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
366  } else {
367  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
368  print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
369  }
370 
371  print "</td>\n</tr>\n";
372  $found++;
373 
374 
375  print '<tr class="oddeven">';
376  print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>';
377  print '<td class="right">';
378 
379  if ($conf->use_javascript_ajax) {
380  print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
381  } else {
382  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
383  print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
384  }
385  print "</td>\n</tr>\n";
386  $found++;
387 } else {
388  print '<!-- STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER -->';
389  print '<tr class="oddeven">';
390  print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
391  print '<td class="right">';
392  if (isModEnabled("supplier_order")) {
393  if ($conf->use_javascript_ajax) {
394  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
395  } else {
396  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
397  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
398  }
399  } else {
400  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
401  }
402  print "</td>\n</tr>\n";
403  $found++;
404 }
405 
406 print '</table>';
407 print '</div>';
408 
409 print '<br>';
410 
411 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
412 print '<table class="noborder centpercent">';
413 print '<tr class="liste_titre">';
414 print "<td>".$langs->trans("RuleForStockAvailability")."</td>\n";
415 print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
416 print '</tr>'."\n";
417 
418 
419 print '<tr class="oddeven">';
420 print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
421 print '<td class="right">';
422 if ($conf->use_javascript_ajax) {
423  print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
424 } else {
425  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
426  print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
427 }
428 print "</td>\n";
429 print "</tr>\n";
430 
431 // Option to force stock to be enough before adding a line into document
432 if (isModEnabled('facture')) {
433  print '<tr class="oddeven">';
434  print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
435  print '<td class="right">';
436  if ($conf->use_javascript_ajax) {
437  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
438  } else {
439  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
440  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
441  }
442  print "</td>\n";
443  print "</tr>\n";
444 }
445 
446 if (isModEnabled('commande')) {
447  print '<tr class="oddeven">';
448  print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
449  print '<td class="right">';
450  if ($conf->use_javascript_ajax) {
451  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
452  } else {
453  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
454  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
455  }
456  print "</td>\n";
457  print "</tr>\n";
458 }
459 
460 if (isModEnabled("expedition")) {
461  print '<tr class="oddeven">';
462  print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
463  print '<td class="right">';
464  if ($conf->use_javascript_ajax) {
465  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
466  } else {
467  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
468  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
469  }
470  print "</td>\n";
471  print "</tr>\n";
472 }
473 print '</table>';
474 print '</div>';
475 
476 print '<br>';
477 
478 $virtualdiffersfromphysical = 0;
479 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
480  || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
481  || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
482  || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
483  || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
484  || isModEnabled('mrp')) {
485  $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
486 }
487 
488 if ($virtualdiffersfromphysical) {
489  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
490  print '<table class="noborder centpercent">';
491  print '<tr class="liste_titre">';
492  print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
493  print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
494  print '</tr>'."\n";
495 
496  print '<tr class="oddeven">';
497  print '<td>';
498  print $form->textwithpicto($langs->trans("UseRealStockByDefault"), $langs->trans("ReplenishmentCalculation"));
499  print '</td>';
500  print '<td class="right">';
501  if ($conf->use_javascript_ajax) {
502  print ajax_constantonoff('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT');
503  } else {
504  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
505  print $form->selectarray("STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT", $arrval, $conf->global->STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT);
506  }
507  print "</td>\n";
508  print "</tr>\n";
509  print '</table>';
510  print '</div>';
511 
512  print '<br>';
513 }
514 
515 print '<form>';
516 
517 
518 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
519 print '<input type="hidden" name="token" value="'.newToken().'">';
520 print '<input type="hidden" name="action" value="warehouse">';
521 
522 
523 /*
524  * Document templates generators
525  */
526 
527 print load_fiche_titre($langs->trans("WarehouseModelModules"), '', '');
528 
529 // Load array def with activated templates
530 $def = array();
531 $sql = "SELECT nom";
532 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
533 $sql .= " WHERE type = '".$db->escape($type)."'";
534 $sql .= " AND entity = ".$conf->entity;
535 $resql = $db->query($sql);
536 if ($resql) {
537  $i = 0;
538  $num_rows = $db->num_rows($resql);
539  while ($i < $num_rows) {
540  $array = $db->fetch_array($resql);
541  array_push($def, $array[0]);
542  $i++;
543  }
544 } else {
545  dol_print_error($db);
546 }
547 
548 
549 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
550 print '<table class="noborder centpercent">'."\n";
551 print '<tr class="liste_titre">'."\n";
552 print '<td>'.$langs->trans("Name").'</td>';
553 print '<td>'.$langs->trans("Description").'</td>';
554 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
555 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
556 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
557 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
558 print "</tr>\n";
559 
560 clearstatcache();
561 
562 foreach ($dirmodels as $reldir) {
563  foreach (array('', '/doc') as $valdir) {
564  $realpath = $reldir."core/modules/stock".$valdir;
565  $dir = dol_buildpath($realpath);
566 
567  if (is_dir($dir)) {
568  $handle = opendir($dir);
569  if (is_resource($handle)) {
570  while (($file = readdir($handle)) !== false) {
571  $filelist[] = $file;
572  }
573  closedir($handle);
574  arsort($filelist);
575 
576  foreach ($filelist as $file) {
577  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
578  if (file_exists($dir.'/'.$file)) {
579  $name = substr($file, 4, dol_strlen($file) - 16);
580  $classname = substr($file, 0, dol_strlen($file) - 12);
581 
582  require_once $dir.'/'.$file;
583  $module = new $classname($db);
584 
585  $modulequalified = 1;
586  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
587  $modulequalified = 0;
588  }
589  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
590  $modulequalified = 0;
591  }
592 
593  if ($modulequalified) {
594  print '<tr class="oddeven"><td width="100">';
595  print (empty($module->name) ? $name : $module->name);
596  print "</td><td>\n";
597  if (method_exists($module, 'info')) {
598  print $module->info($langs);
599  } else {
600  print $module->description;
601  }
602  print '</td>';
603 
604  // Active
605  if (in_array($name, $def)) {
606  print '<td class="center">'."\n";
607  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
608  print img_picto($langs->trans("Enabled"), 'switch_on');
609  print '</a>';
610  print '</td>';
611  } else {
612  print '<td class="center">'."\n";
613  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
614  print "</td>";
615  }
616 
617  // Default
618  print '<td class="center">';
619  if ($conf->global->STOCK_ADDON_PDF == $name) {
620  print img_picto($langs->trans("Default"), 'on');
621  } else {
622  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
623  }
624  print '</td>';
625 
626  // Info
627  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
628  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
629  if ($module->type == 'pdf') {
630  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
631  }
632  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
633 
634  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
635  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
636  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
637 
638 
639  print '<td class="center">';
640  print $form->textwithpicto('', $htmltooltip, 1, 0);
641  print '</td>';
642 
643  // Preview
644  print '<td class="center">';
645  if ($module->type == 'pdf') {
646  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
647  } else {
648  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
649  }
650  print '</td>';
651 
652  print "</tr>\n";
653  }
654  }
655  }
656  }
657  }
658  }
659  }
660 }
661 
662 print '</table>';
663 print '</div>';
664 
665 print '</form>';
666 
667 
668 // Other
669 
670 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
671 print '<input type="hidden" name="token" value="'.newToken().'">';
672 print '<input type="hidden" name="action" value="warehouse">';
673 
674 print load_fiche_titre($langs->trans("Other"), '', '');
675 
676 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
677 print '<table class="noborder centpercent">';
678 
679 print '<tr class="liste_titre">';
680 print "<td>".$langs->trans("Parameter")."</td>\n";
681 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
682 print '</tr>'."\n";
683 
684 print '<tr class="oddeven">';
685 print '<td>'.$langs->trans("MainDefaultWarehouse").'</td>';
686 print '<td class="right">';
687 print $formproduct->selectWarehouses(!empty($conf->global->MAIN_DEFAULT_WAREHOUSE) ? $conf->global->MAIN_DEFAULT_WAREHOUSE : -1, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
688 print '<input type="submit" class="button button-edit small" value="'.$langs->trans("Modify").'">';
689 print "</td>";
690 print "</tr>\n";
691 
692 print '<tr class="oddeven">';
693 print '<td>'.$langs->trans("UserDefaultWarehouse").'</td>';
694 print '<td class="right">';
695 if ($conf->use_javascript_ajax) {
696  print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1);
697 } else {
698  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
699  print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER);
700 }
701 print "</td>\n";
702 print "</tr>\n";
703 
704 if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
705  print '<tr class="oddeven">';
706  print '<td>'.$langs->trans("UserWarehouseAutoCreate").'</td>';
707  print '<td class="right">';
708  if ($conf->use_javascript_ajax) {
709  print ajax_constantonoff('STOCK_USERSTOCK_AUTOCREATE');
710  } else {
711  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
712  print $form->selectarray("STOCK_USERSTOCK_AUTOCREATE", $arrval, $conf->global->STOCK_USERSTOCK_AUTOCREATE);
713  }
714  print "</td>\n";
715  print "</tr>\n";
716 }
717 
718 print '<tr class="oddeven">';
719 print '<td>'.$langs->trans("WarehouseAskWarehouseOnThirparty").'</td>';
720 print '<td class="right">';
721 if ($conf->use_javascript_ajax) {
722  print ajax_constantonoff('SOCIETE_ASK_FOR_WAREHOUSE');
723 } else {
724  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
725  print $form->selectarray("SOCIETE_ASK_FOR_WAREHOUSE", $arrval, $conf->global->SOCIETE_ASK_FOR_WAREHOUSE);
726 }
727 print "</td>";
728 print "</tr>\n";
729 
730 print '<tr class="oddeven">';
731 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringPropal").'</td>';
732 print '<td class="right">';
733 if ($conf->use_javascript_ajax) {
734  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL');
735 } else {
736  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
737  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL);
738 }
739 print "</td>";
740 print "</tr>\n";
741 
742 print '<tr class="oddeven">';
743 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringOrder").'</td>';
744 print '<td class="right">';
745 if ($conf->use_javascript_ajax) {
746  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
747 } else {
748  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
749  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER);
750 }
751 print '</td>';
752 print "</tr>\n";
753 
754 /*
755 print '<tr class="oddeven">';
756 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringProject").'</td>';
757 print '<td class="right">';
758 if ($conf->use_javascript_ajax) {
759  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT');
760 } else {
761  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
762  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT);
763 }
764 print '</td>';
765 print "</tr>\n";
766 */
767 
768 print '<tr class="oddeven">';
769 print '<td>';
770 print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));
771 print '</td>';
772 print '<td class="right">';
773 if ($conf->use_javascript_ajax) {
774  print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
775 } else {
776  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
777  print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
778 }
779 print "</td>\n";
780 print "</tr>\n";
781 
782 print '<tr class="oddeven">';
783 print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
784 print '<td class="right">';
785 if ($conf->use_javascript_ajax) {
786  print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
787 } else {
788  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
789  print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
790 }
791 print "</td>\n";
792 print "</tr>\n";
793 
794 print '<tr class="oddeven">';
795 print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
796 print '<td class="right">';
797 if ($conf->use_javascript_ajax) {
798  print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
799 } else {
800  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
801  print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
802 }
803 print "</td>\n";
804 print "</tr>\n";
805 
806 /* Disabled. Would be better to be managed with a user cookie
807 if (isModEnabled('productbatch')) {
808  print '<tr class="oddeven">';
809  print '<td>' . $langs->trans("ShowAllBatchByDefault") . '</td>';
810  print '<td class="right">';
811  if ($conf->use_javascript_ajax) {
812  print ajax_constantonoff('STOCK_SHOW_ALL_BATCH_BY_DEFAULT');
813  } else {
814  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
815  print $form->selectarray("STOCK_SHOW_ALL_BATCH_BY_DEFAULT", $arrval, $conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT);
816  }
817  print "</td>\n";
818  print "</tr>\n";
819 }
820 */
821 
822 print '</table>';
823 print '</div>';
824 
825 print '</form>';
826 
827 // End of page
828 llxFooter();
829 $db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1918
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:638
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1949
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
Definition: ajax.lib.php:630
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage warehouses.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stock_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: stock.lib.php:91