dolibarr  18.0.0
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 '<tr class="oddeven">';
220 print '<td>'.$langs->trans("DeStockOnBill").'</td>';
221 print '<td class="right">';
222 if (isModEnabled('facture')) {
223  if ($conf->use_javascript_ajax) {
224  if ($disabled) {
225  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
226  } else {
227  print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition');
228  }
229  } else {
230  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
231  print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
232  }
233 } else {
234  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
235 }
236 print "</td>\n</tr>\n";
237 $found++;
238 
239 
240 print '<tr class="oddeven">';
241 print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
242 print '<td class="right">';
243 if (isModEnabled('commande')) {
244  if ($conf->use_javascript_ajax) {
245  if ($disabled) {
246  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
247  } else {
248  print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
249  }
250  } else {
251  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
252  print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
253  }
254 } else {
255  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name")).'</span>';
256 }
257 print "</td>\n</tr>\n";
258 $found++;
259 
260 //if (isModEnabled('expedition'))
261 //{
262 
263 print '<tr class="oddeven">';
264 print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
265 print '<td class="right">';
266 if (isModEnabled("expedition")) {
267  if ($conf->use_javascript_ajax) {
268  print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
269  } else {
270  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
271  print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
272  }
273 } else {
274  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).'</span>';
275 }
276 print "</td>\n</tr>\n";
277 $found++;
278 
279 
280 print '<tr class="oddeven">';
281 print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
282 print '<td class="right">';
283 if (isModEnabled("expedition")) {
284  if ($conf->use_javascript_ajax) {
285  print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
286  } else {
287  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
288  print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
289  }
290 } else {
291  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")).'</span>';
292 }
293 print "</td>\n</tr>\n";
294 $found++;
295 
296 print '</table>';
297 print '</div>';
298 
299 print '<br>';
300 
301 
302 // Title rule for stock increase
303 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
304 print '<table class="noborder centpercent">';
305 print '<tr class="liste_titre">';
306 print "<td>".$langs->trans("RuleForStockManagementIncrease")."</td>\n";
307 print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
308 print '</tr>'."\n";
309 
310 $found = 0;
311 
312 print '<tr class="oddeven">';
313 print '<td>'.$langs->trans("ReStockOnBill").'</td>';
314 print '<td class="right">';
315 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
316  if ($conf->use_javascript_ajax) {
317  if ($disabled) {
318  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
319  } else {
320  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
321  }
322  } else {
323  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
324  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
325  }
326 } else {
327  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
328 }
329 print "</td>\n</tr>\n";
330 $found++;
331 
332 
333 
334 print '<tr class="oddeven">';
335 print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
336 print '<td class="right">';
337 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
338  if ($conf->use_javascript_ajax) {
339  if ($disabled) {
340  print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
341  } else {
342  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
343  }
344  } else {
345  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
346  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
347  }
348 } else {
349  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
350 }
351 print "</td>\n</tr>\n";
352 $found++;
353 
354 if (isModEnabled("reception")) {
355  print '<tr class="oddeven">';
356  print '<td>'.$langs->trans("StockOnReception").'</td>';
357  print '<td class="right">';
358 
359  if ($conf->use_javascript_ajax) {
360  print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
361  } else {
362  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
363  print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
364  }
365 
366  print "</td>\n</tr>\n";
367  $found++;
368 
369 
370  print '<tr class="oddeven">';
371  print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>';
372  print '<td class="right">';
373 
374  if ($conf->use_javascript_ajax) {
375  print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
376  } else {
377  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
378  print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
379  }
380  print "</td>\n</tr>\n";
381  $found++;
382 } else {
383  print '<tr class="oddeven">';
384  print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
385  print '<td class="right">';
386  if (isModEnabled("supplier_order")) {
387  if ($conf->use_javascript_ajax) {
388  print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, '', '', 'reposition');
389  } else {
390  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
391  print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
392  }
393  } else {
394  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name")).'</span>';
395  }
396  print "</td>\n</tr>\n";
397  $found++;
398 }
399 
400 print '</table>';
401 print '</div>';
402 
403 print '<br>';
404 
405 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
406 print '<table class="noborder centpercent">';
407 print '<tr class="liste_titre">';
408 print "<td>".$langs->trans("RuleForStockAvailability")."</td>\n";
409 print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
410 print '</tr>'."\n";
411 
412 
413 print '<tr class="oddeven">';
414 print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
415 print '<td class="right">';
416 if ($conf->use_javascript_ajax) {
417  print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
418 } else {
419  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
420  print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
421 }
422 print "</td>\n";
423 print "</tr>\n";
424 
425 // Option to force stock to be enough before adding a line into document
426 if (isModEnabled('facture')) {
427  print '<tr class="oddeven">';
428  print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
429  print '<td class="right">';
430  if ($conf->use_javascript_ajax) {
431  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
432  } else {
433  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
434  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
435  }
436  print "</td>\n";
437  print "</tr>\n";
438 }
439 
440 if (isModEnabled('commande')) {
441  print '<tr class="oddeven">';
442  print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
443  print '<td class="right">';
444  if ($conf->use_javascript_ajax) {
445  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
446  } else {
447  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
448  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
449  }
450  print "</td>\n";
451  print "</tr>\n";
452 }
453 
454 if (isModEnabled("expedition")) {
455  print '<tr class="oddeven">';
456  print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
457  print '<td class="right">';
458  if ($conf->use_javascript_ajax) {
459  print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
460  } else {
461  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
462  print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
463  }
464  print "</td>\n";
465  print "</tr>\n";
466 }
467 print '</table>';
468 print '</div>';
469 
470 print '<br>';
471 
472 $virtualdiffersfromphysical = 0;
473 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
474  || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
475  || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
476  || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
477  || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
478  || isModEnabled('mrp')) {
479  $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
480 }
481 
482 if ($virtualdiffersfromphysical) {
483  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
484  print '<table class="noborder centpercent">';
485  print '<tr class="liste_titre">';
486  print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
487  print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
488  print '</tr>'."\n";
489 
490  print '<tr class="oddeven">';
491  print '<td>';
492  print $form->textwithpicto($langs->trans("UseRealStockByDefault"), $langs->trans("ReplenishmentCalculation"));
493  print '</td>';
494  print '<td class="right">';
495  if ($conf->use_javascript_ajax) {
496  print ajax_constantonoff('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT');
497  } else {
498  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
499  print $form->selectarray("STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT", $arrval, $conf->global->STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT);
500  }
501  print "</td>\n";
502  print "</tr>\n";
503  print '</table>';
504  print '</div>';
505 
506  print '<br>';
507 }
508 
509 print '<form>';
510 
511 
512 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
513 print '<input type="hidden" name="token" value="'.newToken().'">';
514 print '<input type="hidden" name="action" value="warehouse">';
515 
516 
517 /*
518  * Document templates generators
519  */
520 
521 print load_fiche_titre($langs->trans("WarehouseModelModules"), '', '');
522 
523 // Load array def with activated templates
524 $def = array();
525 $sql = "SELECT nom";
526 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
527 $sql .= " WHERE type = '".$db->escape($type)."'";
528 $sql .= " AND entity = ".$conf->entity;
529 $resql = $db->query($sql);
530 if ($resql) {
531  $i = 0;
532  $num_rows = $db->num_rows($resql);
533  while ($i < $num_rows) {
534  $array = $db->fetch_array($resql);
535  array_push($def, $array[0]);
536  $i++;
537  }
538 } else {
539  dol_print_error($db);
540 }
541 
542 
543 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
544 print '<table class="noborder centpercent">'."\n";
545 print '<tr class="liste_titre">'."\n";
546 print '<td>'.$langs->trans("Name").'</td>';
547 print '<td>'.$langs->trans("Description").'</td>';
548 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
549 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
550 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
551 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
552 print "</tr>\n";
553 
554 clearstatcache();
555 
556 foreach ($dirmodels as $reldir) {
557  foreach (array('', '/doc') as $valdir) {
558  $realpath = $reldir."core/modules/stock".$valdir;
559  $dir = dol_buildpath($realpath);
560 
561  if (is_dir($dir)) {
562  $handle = opendir($dir);
563  if (is_resource($handle)) {
564  while (($file = readdir($handle)) !== false) {
565  $filelist[] = $file;
566  }
567  closedir($handle);
568  arsort($filelist);
569 
570  foreach ($filelist as $file) {
571  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
572  if (file_exists($dir.'/'.$file)) {
573  $name = substr($file, 4, dol_strlen($file) - 16);
574  $classname = substr($file, 0, dol_strlen($file) - 12);
575 
576  require_once $dir.'/'.$file;
577  $module = new $classname($db);
578 
579  $modulequalified = 1;
580  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
581  $modulequalified = 0;
582  }
583  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
584  $modulequalified = 0;
585  }
586 
587  if ($modulequalified) {
588  print '<tr class="oddeven"><td width="100">';
589  print (empty($module->name) ? $name : $module->name);
590  print "</td><td>\n";
591  if (method_exists($module, 'info')) {
592  print $module->info($langs);
593  } else {
594  print $module->description;
595  }
596  print '</td>';
597 
598  // Active
599  if (in_array($name, $def)) {
600  print '<td class="center">'."\n";
601  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
602  print img_picto($langs->trans("Enabled"), 'switch_on');
603  print '</a>';
604  print '</td>';
605  } else {
606  print '<td class="center">'."\n";
607  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>';
608  print "</td>";
609  }
610 
611  // Default
612  print '<td class="center">';
613  if ($conf->global->STOCK_ADDON_PDF == $name) {
614  print img_picto($langs->trans("Default"), 'on');
615  } else {
616  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>';
617  }
618  print '</td>';
619 
620  // Info
621  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
622  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
623  if ($module->type == 'pdf') {
624  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
625  }
626  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
627 
628  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
629  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
630  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
631 
632 
633  print '<td class="center">';
634  print $form->textwithpicto('', $htmltooltip, 1, 0);
635  print '</td>';
636 
637  // Preview
638  print '<td class="center">';
639  if ($module->type == 'pdf') {
640  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
641  } else {
642  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
643  }
644  print '</td>';
645 
646  print "</tr>\n";
647  }
648  }
649  }
650  }
651  }
652  }
653  }
654 }
655 
656 print '</table>';
657 print '</div>';
658 
659 print '</form>';
660 
661 
662 // Other
663 
664 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
665 print '<input type="hidden" name="token" value="'.newToken().'">';
666 print '<input type="hidden" name="action" value="warehouse">';
667 
668 print load_fiche_titre($langs->trans("Other"), '', '');
669 
670 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
671 print '<table class="noborder centpercent">';
672 
673 print '<tr class="liste_titre">';
674 print "<td>".$langs->trans("Parameter")."</td>\n";
675 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
676 print '</tr>'."\n";
677 
678 print '<tr class="oddeven">';
679 print '<td>'.$langs->trans("MainDefaultWarehouse").'</td>';
680 print '<td class="right">';
681 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');
682 print '<input type="submit" class="button button-edit small" value="'.$langs->trans("Modify").'">';
683 print "</td>";
684 print "</tr>\n";
685 
686 print '<tr class="oddeven">';
687 print '<td>'.$langs->trans("UserDefaultWarehouse").'</td>';
688 print '<td class="right">';
689 if ($conf->use_javascript_ajax) {
690  print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1);
691 } else {
692  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
693  print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER);
694 }
695 print "</td>\n";
696 print "</tr>\n";
697 
698 if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
699  print '<tr class="oddeven">';
700  print '<td>'.$langs->trans("UserWarehouseAutoCreate").'</td>';
701  print '<td class="right">';
702  if ($conf->use_javascript_ajax) {
703  print ajax_constantonoff('STOCK_USERSTOCK_AUTOCREATE');
704  } else {
705  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
706  print $form->selectarray("STOCK_USERSTOCK_AUTOCREATE", $arrval, $conf->global->STOCK_USERSTOCK_AUTOCREATE);
707  }
708  print "</td>\n";
709  print "</tr>\n";
710 }
711 
712 print '<tr class="oddeven">';
713 print '<td>'.$langs->trans("WarehouseAskWarehouseOnThirparty").'</td>';
714 print '<td class="right">';
715 if ($conf->use_javascript_ajax) {
716  print ajax_constantonoff('SOCIETE_ASK_FOR_WAREHOUSE');
717 } else {
718  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
719  print $form->selectarray("SOCIETE_ASK_FOR_WAREHOUSE", $arrval, $conf->global->SOCIETE_ASK_FOR_WAREHOUSE);
720 }
721 print "</td>";
722 print "</tr>\n";
723 
724 print '<tr class="oddeven">';
725 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringPropal").'</td>';
726 print '<td class="right">';
727 if ($conf->use_javascript_ajax) {
728  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL');
729 } else {
730  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
731  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL);
732 }
733 print "</td>";
734 print "</tr>\n";
735 
736 print '<tr class="oddeven">';
737 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringOrder").'</td>';
738 print '<td class="right">';
739 if ($conf->use_javascript_ajax) {
740  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
741 } else {
742  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
743  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER);
744 }
745 print '</td>';
746 print "</tr>\n";
747 
748 /*
749 print '<tr class="oddeven">';
750 print '<td>'.$langs->trans("WarehouseAskWarehouseDuringProject").'</td>';
751 print '<td class="right">';
752 if ($conf->use_javascript_ajax) {
753  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT');
754 } else {
755  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
756  print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT);
757 }
758 print '</td>';
759 print "</tr>\n";
760 */
761 
762 print '<tr class="oddeven">';
763 print '<td>';
764 print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));
765 print '</td>';
766 print '<td class="right">';
767 if ($conf->use_javascript_ajax) {
768  print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
769 } else {
770  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
771  print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
772 }
773 print "</td>\n";
774 print "</tr>\n";
775 
776 print '<tr class="oddeven">';
777 print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
778 print '<td class="right">';
779 if ($conf->use_javascript_ajax) {
780  print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
781 } else {
782  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
783  print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
784 }
785 print "</td>\n";
786 print "</tr>\n";
787 
788 print '<tr class="oddeven">';
789 print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
790 print '<td class="right">';
791 if ($conf->use_javascript_ajax) {
792  print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
793 } else {
794  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
795  print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
796 }
797 print "</td>\n";
798 print "</tr>\n";
799 
800 /* Disabled. Would be better to be managed with a user cookie
801 if (isModEnabled('productbatch')) {
802  print '<tr class="oddeven">';
803  print '<td>' . $langs->trans("ShowAllBatchByDefault") . '</td>';
804  print '<td class="right">';
805  if ($conf->use_javascript_ajax) {
806  print ajax_constantonoff('STOCK_SHOW_ALL_BATCH_BY_DEFAULT');
807  } else {
808  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
809  print $form->selectarray("STOCK_SHOW_ALL_BATCH_BY_DEFAULT", $arrval, $conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT);
810  }
811  print "</td>\n";
812  print "</tr>\n";
813 }
814 */
815 
816 print '</table>';
817 print '</div>';
818 
819 print '</form>';
820 
821 // End of page
822 llxFooter();
823 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6824
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5107
img_help
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Definition: functions.lib.php:4744
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1158
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4135
llxHeader
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
ajax_constantonoff
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
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1949
stock_admin_prepare_head
stock_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: stock.lib.php:91
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
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
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3997
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:5063
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
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.
Definition: functions.lib.php:1979
dolibarr_set_const
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
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1918
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4473
Entrepot
Class to manage warehouses.
Definition: entrepot.class.php:35
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1164