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