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