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