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