dolibarr 23.0.4
dispatch.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
8 * Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
9 * Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
12 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
37require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
40require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
41require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
43require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
44
45if (isModEnabled('project')) {
46 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
47}
48
57// Load translation files required by the page
58$langs->loadLangs(array("bills", "orders", "sendings", "companies", "products", "stocks", "receptions"));
59
60if (isModEnabled('productbatch')) {
61 $langs->load('productbatch');
62}
63
64// Security check
65$id = GETPOSTINT("id");
66$ref = GETPOST('ref');
67$lineid = GETPOSTINT('lineid');
68$action = GETPOST('action', 'aZ09');
69$fk_default_warehouse = GETPOSTINT('fk_default_warehouse');
70$cancel = GETPOST('cancel', 'alpha');
71$confirm = GETPOST('confirm', 'alpha');
72
73if ($user->socid) {
74 $socid = $user->socid;
75}
76
77$hookmanager->initHooks(array('ordersupplierdispatch'));
78
79// Recuperation de l'id de projet
80$projectid = 0;
81if (GETPOSTISSET("projectid")) {
82 $projectid = GETPOSTINT("projectid");
83}
84
86
87if ($id > 0 || !empty($ref)) {
88 $result = $object->fetch($id, $ref);
89 if ($result < 0) {
90 setEventMessages($object->error, $object->errors, 'errors');
91 }
92 $result = $object->fetch_thirdparty();
93 if ($result < 0) {
94 setEventMessages($object->error, $object->errors, 'errors');
95 }
96}
97
98if (empty($conf->reception->enabled)) {
99 $permissiontoreceive = $user->hasRight("fournisseur", "commande", "receptionner");
100 $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "commande", "receptionner")) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "commande_advance", "check")));
101} else {
102 $permissiontoreceive = $user->hasRight("reception", "creer");
103 $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("reception", "creer")) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("reception", "reception_advance", "validate")));
104}
105
106// $id is id of a purchase order.
107$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
108
109if (!isModEnabled('stock')) {
111}
112
113// A dispatched line linked to a reception can be updated or deleted only while the reception is a draft
114if (($action == 'confirm_deleteline' || ($action == 'updateline' && empty($cancel))) && $lineid > 0) {
115 $tmpdispatchline = new CommandeFournisseurDispatch($db);
116 if ($tmpdispatchline->fetch($lineid) > 0 && $tmpdispatchline->fk_reception > 0) {
117 require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
118 $tmpreception = new Reception($db);
119 if ($tmpreception->fetch($tmpdispatchline->fk_reception) > 0 && $tmpreception->status != Reception::STATUS_DRAFT) {
120 setEventMessages($langs->trans('StatusOfRefMustBe', $langs->transnoentitiesnoconv('Reception'), $langs->transnoentitiesnoconv('StatusReceptionDraftShort')), null, 'errors');
121 $action = '';
122 }
123 }
124}
125
126$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"));
127$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
128
129
130/*
131 * Actions
132 */
133
134$error = 0;
135$errors = [];
136$parameters = array();
137$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
138if ($reshook < 0) {
139 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140}
141
142// Actions on an existing dispatch line: the line must be a line of the purchase order of the page
143if (in_array($action, ['checkdispatchline', 'uncheckdispatchline', 'denydispatchline', 'confirm_deleteline', 'updateline'])) {
144 $tmpdispatchline = new CommandeFournisseurDispatch($db);
145 if ($tmpdispatchline->fetch($lineid) <= 0 || (int) $tmpdispatchline->fk_element !== (int) $object->id) {
146 setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
147 $action = '';
148 }
149}
150
151if ($action == 'checkdispatchline' && $permissiontocontrol) {
152 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
153
154 $db->begin();
155
156 $result = $supplierorderdispatch->fetch($lineid);
157 if (!$result) {
158 $error++;
159 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
160 $action = '';
161 }
162
163 if (!$error) {
164 $result = $supplierorderdispatch->setStatut(1);
165 if ($result < 0) {
166 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
167 $error++;
168 $action = '';
169 }
170 }
171
172 if (!$error) {
173 $result = $object->calcAndSetStatusDispatch($user);
174 if ($result < 0) {
175 setEventMessages($object->error, $object->errors, 'errors');
176 $error++;
177 $action = '';
178 }
179 }
180 if (!$error) {
181 $db->commit();
182 } else {
183 $db->rollback();
184 }
185}
186
187if ($action == 'uncheckdispatchline' && $permissiontocontrol) {
188 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
189
190 $db->begin();
191
192 $result = $supplierorderdispatch->fetch($lineid);
193 if (!$result) {
194 $error++;
195 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
196 $action = '';
197 }
198
199 if (!$error) {
200 $result = $supplierorderdispatch->setStatut(0);
201 if ($result < 0) {
202 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
203 $error++;
204 $action = '';
205 }
206 }
207 if (!$error) {
208 $result = $object->calcAndSetStatusDispatch($user);
209 if ($result < 0) {
210 setEventMessages($object->error, $object->errors, 'errors');
211 $error++;
212 $action = '';
213 }
214 }
215 if (!$error) {
216 $db->commit();
217 } else {
218 $db->rollback();
219 }
220}
221
222if ($action == 'denydispatchline' && $permissiontocontrol) {
223 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
224
225 $db->begin();
226
227 $result = $supplierorderdispatch->fetch($lineid);
228 if (!$result) {
229 $error++;
230 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
231 $action = '';
232 }
233
234 if (!$error) {
235 $result = $supplierorderdispatch->setStatut(2);
236 if ($result < 0) {
237 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
238 $error++;
239 $action = '';
240 }
241 }
242 if (!$error) {
243 $result = $object->calcAndSetStatusDispatch($user);
244 if ($result < 0) {
245 setEventMessages($object->error, $object->errors, 'errors');
246 $error++;
247 $action = '';
248 }
249 }
250 if (!$error) {
251 $db->commit();
252 } else {
253 $db->rollback();
254 }
255}
256
257$saveprice = "savepriceIsNotSet";
258if ($action == 'dispatch' && $permissiontoreceive) {
259 $notrigger = 0;
260
261 $db->begin();
262
263 $pos = 0;
264 foreach ($_POST as $key => $value) {
265 // without batch module enabled
266 $reg = array();
267 if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
268 $pos++;
269
270 // $numline=$reg[2] + 1; // line of product
271 $numline = $pos;
272 $prod = "product_".$reg[1].'_'.$reg[2];
273 $qty = "qty_".$reg[1].'_'.$reg[2];
274 $ent = "entrepot_".$reg[1].'_'.$reg[2];
275 if (empty(GETPOST($ent))) {
276 $ent = $fk_default_warehouse;
277 }
278 $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount
279 $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2];
280
281 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
282 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
283 $dto = GETPOSTINT("dto_".$reg[1].'_'.$reg[2]);
284 if (!empty($dto)) {
285 $unit_price = price2num((float) GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU');
286 }
287 $saveprice = "saveprice_".$reg[1].'_'.$reg[2];
288 }
289 }
290
291 // We ask to move a qty
292 $qtytomove = GETPOSTFLOAT($qty);
293 $puformove = GETPOSTFLOAT($pu);
294 if ($qtytomove != 0) {
295 if (!(GETPOSTINT($ent) > 0)) {
296 dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
297 $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
298 setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
299 $error++;
300 }
301
302 if (!$error) {
303 $result = $object->dispatchProduct($user, GETPOSTINT($prod), $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), '', '', '', GETPOSTINT($fk_commandefourndet), $notrigger);
304 if ($result < 0) {
305 setEventMessages($object->error, $object->errors, 'errors');
306 $error++;
307 }
308
309 if (!$error && getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
310 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
311 $dto = price2num(GETPOST("dto_".$reg[1].'_'.$reg[2]), '');
312 if (empty($dto)) {
313 $dto = 0;
314 }
315
316 //update supplier price
317 if (GETPOSTISSET($saveprice)) {
318 // TODO Use class
319 $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
320 $sql .= " SET unitprice='".price2num(GETPOST($pu), 'MU')."'";
321 $sql .= ", price=".price2num(GETPOST($pu), 'MU')."*quantity";
322 $sql .= ", remise_percent = ".((float) $dto);
323 $sql .= " WHERE fk_soc=".((int) $object->socid);
324 $sql .= " AND fk_product=".(GETPOSTINT($prod));
325
326 $resql = $db->query($sql);
327 }
328 }
329 }
330 }
331 }
332 }
333 // with batch module enabled
334 if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
335 $pos++;
336
337 // eat-by date dispatch
338 // $numline=$reg[2] + 1; // line of product
339 $numline = $pos;
340 $prod = 'product_batch_'.$reg[1].'_'.$reg[2];
341 $qty = 'qty_'.$reg[1].'_'.$reg[2];
342 $ent = 'entrepot_'.$reg[1].'_'.$reg[2];
343 $pu = 'pu_'.$reg[1].'_'.$reg[2];
344 $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
345 $lot = 'lot_number_'.$reg[1].'_'.$reg[2];
346 $dDLUO = dol_mktime(12, 0, 0, GETPOSTINT('dluo_'.$reg[1].'_'.$reg[2].'month'), GETPOSTINT('dluo_'.$reg[1].'_'.$reg[2].'day'), GETPOSTINT('dluo_'.$reg[1].'_'.$reg[2].'year'));
347 $dDLC = dol_mktime(12, 0, 0, GETPOSTINT('dlc_'.$reg[1].'_'.$reg[2].'month'), GETPOSTINT('dlc_'.$reg[1].'_'.$reg[2].'day'), GETPOSTINT('dlc_'.$reg[1].'_'.$reg[2].'year'));
348
349 $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
350
351 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
352 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
353 $dto = GETPOSTFLOAT("dto_".$reg[1].'_'.$reg[2]);
354 if (!empty($dto)) {
355 $unit_price = price2num((float) GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU');
356 }
357 $saveprice = "saveprice_".$reg[1].'_'.$reg[2];
358 }
359 }
360
361 // We ask to move a qty
362 $qtytomove = GETPOSTFLOAT($qty);
363 $puformove = GETPOSTFLOAT($pu);
364 if ($qtytomove > 0) {
365 $productId = GETPOSTINT($prod);
366
367 if (!(GETPOSTINT($ent) > 0)) {
368 dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
369 $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline).'-'.((int) $reg[1] + 1);
370 setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
371 $error++;
372 }
373
374 // check sell-by / eat-by date is mandatory
375 /* Not required. Mandatory is checked when we insert the lot. Once lot has been recorded and is known, user can just enter the lot/serial
376 $errorMsgArr = Productlot::checkSellOrEatByMandatoryFromProductIdAndDates($productId, $dDLC, $dDLUO);
377 if (!(GETPOST($lot, 'alpha')) || !empty($errorMsgArr)) {
378 dol_syslog('No dispatch for line '.$key.' as serial/eat-by/sellby date are not set');
379 $text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').' '.($numline).'-'.($reg[1] + 1);
380 setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
381 $error++;
382 }*/
383 if (!GETPOST($lot, 'alpha') && !$dDLUO && !$dDLC) {
384 dol_syslog('No dispatch for line '.$key.' as serial/eat-by/sellby date are not set');
385 $text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').' '.($numline).'-'.((int) $reg[1] + 1);
386 setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
387 $error++;
388 }
389
390 if (!$error) {
391 $result = $object->dispatchProduct($user, $productId, $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), $dDLUO, $dDLC, GETPOST($lot, 'alpha'), GETPOSTINT($fk_commandefourndet), $notrigger);
392 if ($result < 0) {
393 setEventMessages($object->error, $object->errors, 'errors');
394 $error++;
395 }
396
397 if (!$error && getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
398 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
399 $dto = GETPOSTFLOAT("dto_".$reg[1].'_'.$reg[2]);
400 //update supplier price
401 if (GETPOSTISSET($saveprice)) {
402 // TODO Use class
403 $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
404 $sql .= " SET unitprice = ".price2num(GETPOST($pu), 'MU', 2);
405 $sql .= ", price = ".price2num(GETPOST($pu), 'MU', 2)." * quantity";
406 $sql .= ", remise_percent = ".price2num((empty($dto) ? 0 : $dto), 3, 2);
407 $sql .= " WHERE fk_soc = ".((int) $object->socid);
408 $sql .= " AND fk_product=".((int) $productId);
409
410 $resql = $db->query($sql);
411 }
412 }
413 }
414 }
415 }
416 }
417 }
418
419 if (!$error) {
420 $result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder') ? 1 : 0, GETPOST('comment'));
421 if ($result < 0) {
422 setEventMessages($object->error, $object->errors, 'errors');
423 $error++;
424 }
425 }
426
427 if ($result >= 0 && !$error) {
428 $db->commit();
429
430 setEventMessages($langs->trans("ReceptionsRecorded"), null, 'mesgs');
431
432 header("Location: dispatch.php?id=".$id);
433 exit();
434 } else {
435 $db->rollback();
436 }
437}
438
439$batch = '';
440$eatby = null;
441$sellby = 0;
442$qty = 0;
443$price = '0';
444$entrepot = 0;
445
446// Remove a dispatched line
447if ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoreceive) {
448 $db->begin();
449
450 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
451 $result = $supplierorderdispatch->fetch($lineid);
452 if ($result > 0) {
453 $qty = $supplierorderdispatch->qty;
454 $entrepot = $supplierorderdispatch->fk_entrepot;
455 $product = $supplierorderdispatch->fk_product;
456 $price = price2num(GETPOST('price', 'alpha'), 'MU');
457 $comment = $supplierorderdispatch->comment;
458 $eatby = $supplierorderdispatch->eatby;
459 $sellby = $supplierorderdispatch->sellby;
460 $batch = $supplierorderdispatch->batch;
461
462 $result = $supplierorderdispatch->delete($user);
463 }
464 if ($result < 0) {
465 $errors = $object->errors;
466 $error++;
467 } else {
468 // If module stock is enabled and the stock increase is done on purchase order dispatching
469 if ($entrepot > 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') && empty($supplierorderdispatch->fk_reception)) {
470 $mouv = new MouvementStock($db);
471 if ($product > 0) {
472 $mouv->origin = &$object;
473 $mouv->setOrigin($object->element, $object->id);
474 $result = $mouv->livraison($user, $product, $entrepot, $qty, (float) $price, $comment, '', (int) $eatby, (int) $sellby, $batch);
475 if ($result < 0) {
476 $errors = $mouv->errors;
477 $error++;
478 }
479 }
480 }
481 }
482 if ($error > 0) {
483 $db->rollback();
484 setEventMessages(null, $errors, 'errors');
485 } else {
486 $db->commit();
487 }
488}
489
490// Update a dispatched line
491if ($action == 'updateline' && $permissiontoreceive && empty($cancel)) {
492 $db->begin();
493
494 $supplierorderdispatch = new CommandeFournisseurDispatch($db);
495 $result = $supplierorderdispatch->fetch($lineid);
496 if ($result > 0) {
497 $qty = $supplierorderdispatch->qty;
498 $entrepot = $supplierorderdispatch->fk_entrepot;
499 $product = $supplierorderdispatch->fk_product;
500 $price = GETPOSTFLOAT('price');
501 $comment = $supplierorderdispatch->comment;
502 // Dates are not given to the stock movements: those of the lot are used (the copy on the line may be outdated)
503 $eatby = '';
504 $sellby = '';
505 $batch = $supplierorderdispatch->batch;
506
507 $supplierorderdispatch->qty = GETPOSTFLOAT('qty', 'MS');
508 $supplierorderdispatch->fk_entrepot = GETPOSTINT('fk_entrepot');
509 $result = $supplierorderdispatch->update($user);
510 }
511 if ($result < 0) {
512 $error++;
513 $errors = $supplierorderdispatch->errors;
514 } else {
515 // If module stock is enabled and the stock increase is done on purchase order dispatching
516 if ($entrepot > 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) {
517 $mouv = new MouvementStock($db);
518 if ($product > 0) {
519 $mouv->origin = &$object;
520 $mouv->setOrigin($object->element, $object->id);
521 $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', (int) $eatby, (int) $sellby, $batch);
522 if ($result < 0) {
523 $errors = $mouv->errors;
524 $error++;
525 } else {
526 $mouv->origin = &$object;
527 $result = $mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, (int) $eatby, (int) $sellby, $batch);
528 if ($result < 0) {
529 $errors = $mouv->errors;
530 $error++;
531 }
532 }
533 }
534 }
535 }
536 if ($error > 0) {
537 $db->rollback();
538 setEventMessages($langs->trans("Error"), $errors, 'errors');
539 } else {
540 $db->commit();
541 }
542}
543
544
545/*
546 * View
547 */
548
549$now = dol_now();
550
551$form = new Form($db);
552$formproduct = new FormProduct($db);
553$warehouse_static = new Entrepot($db);
554$supplierorderdispatch = new CommandeFournisseurDispatch($db);
555
556$title = $object->ref." - ".$langs->trans('OrderDispatch');
557$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
558$morejs = array('/fourn/js/lib_dispatch.js.php');
559
560llxHeader('', $title, $help_url, '', 0, 0, $morejs, '', '', 'mod-supplier-order page-card_dispatch');
561
562if ($id > 0 || !empty($ref)) {
563 $soc = new Societe($db);
564 $soc->fetch($object->socid);
565
566 $author = new User($db);
567 $author->fetch($object->user_author_id);
568
569 $head = ordersupplier_prepare_head($object);
570
571 $title = $langs->trans("SupplierOrder");
572 print dol_get_fiche_head($head, 'dispatch', $title, -1, 'order');
573
574 $formconfirm = '';
575
576 // Confirmation to delete line
577 if ($action == 'ask_deleteline') {
578 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
579 }
580
581 // Call Hook formConfirm
582 $parameters = array('lineid' => $lineid);
583 // Note that $action and $object may be modified by hook
584 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action);
585 if (empty($reshook)) {
586 $formconfirm .= $hookmanager->resPrint;
587 } elseif ($reshook > 0) {
588 $formconfirm = $hookmanager->resPrint;
589 }
590
591 // Print form confirm
592 print $formconfirm;
593
594 // Supplier order card
595
596 $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
597
598 $morehtmlref = '<div class="refidno">';
599 // Ref supplier
600 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
601 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
602 // Thirdparty
603 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
604 // Project
605 if (isModEnabled('project')) {
606 $langs->load("projects");
607 $morehtmlref .= '<br>';
608 if (0) { // @phpstan-ignore-line
609 $caneditproject = false; // For static analysis
610 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
611 if ($action != 'classify' && $caneditproject) {
612 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
613 }
614 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
615 } else {
616 if (!empty($object->fk_project)) {
617 $proj = new Project($db);
618 $proj->fetch($object->fk_project);
619 $morehtmlref .= $proj->getNomUrl(1);
620 if ($proj->title) {
621 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
622 }
623 }
624 }
625 }
626 $morehtmlref .= '</div>';
627
628
629 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
630
631
632 print '<div class="fichecenter">';
633 print '<div class="underbanner clearboth"></div>';
634
635 print '<table class="border tableforfield" width="100%">';
636
637 // Date
638 if ($object->methode_commande_id > 0) {
639 print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>';
640 if ($object->date_commande) {
641 print dol_print_date($object->date_commande, "dayhour")."\n";
642 }
643 print "</td></tr>";
644
645 if ($object->methode_commande) {
646 print '<tr><td>'.$langs->trans("Method").'</td><td>'.$object->getInputMethod().'</td></tr>';
647 }
648 }
649
650 // Author
651 print '<tr><td class="titlefield">'.$langs->trans("AuthorRequest").'</td>';
652 print '<td>'.$author->getNomUrl(-1, '', 0, 0, 0).'</td>';
653 print '</tr>';
654
655 $parameters = array();
656 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
657
658 print "</table>";
659
660 print '</div>';
661
662 // if ($mesg) print $mesg;
663 print '<br>';
664
665 $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
666
667 // Line of orders
669 print '<br><span class="opacitymedium">'.$langs->trans("OrderStatusNotReadyToDispatch").'</span>';
670 }
671
672
673 print '<br>';
674
675 $listwarehouses = array();
676
680 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
681 $formproduct = new FormProduct($db);
682 $formproduct->loadWarehouses();
683 $entrepot = new Entrepot($db);
684 $listwarehouses = $entrepot->list_array(1);
685
686
687 if (empty($conf->reception->enabled)) {
688 print '<form method="POST" action="dispatch.php?id='.$object->id.'">';
689 } else {
690 print '<form method="post" action="'.dol_buildpath('/reception/card.php', 1).'?originid='.$object->id.'&origin=supplierorder">';
691 }
692
693 print '<input type="hidden" name="token" value="'.newToken().'">';
694 if (empty($conf->reception->enabled)) {
695 print '<input type="hidden" name="action" value="dispatch">';
696 } else {
697 print '<input type="hidden" name="action" value="create">';
698 }
699
700 print '<div class="div-table-responsive-no-min">';
701 print '<table class="noborder centpercent">';
702
703 // Set $products_dispatched with qty dispatched for each product id
704 $products_dispatched = array();
705 $sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
706 $sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
707 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_elementdet";
708 $sql .= " WHERE cfd.fk_element = ".((int) $object->id);
709 $sql .= " GROUP BY l.rowid, cfd.fk_product";
710
711 $resql = $db->query($sql);
712 if ($resql) {
713 $num = $db->num_rows($resql);
714 $i = 0;
715
716 if ($num) {
717 while ($i < $num) {
718 $objd = $db->fetch_object($resql);
719 $products_dispatched[$objd->rowid] = price2num($objd->qty, 'MS');
720 $i++;
721 }
722 }
723 $db->free($resql);
724 }
725
726 //$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
727 $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
728 $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
729
730 // Enable hooks to alter the SQL query (SELECT)
731 $parameters = array();
732 $reshook = $hookmanager->executeHooks(
733 'printFieldListSelect',
734 $parameters,
735 $object,
736 $action
737 );
738 if ($reshook < 0) {
739 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
740 }
741 $sql .= $hookmanager->resPrint;
742
743 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
744 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
745 $sql .= " WHERE l.fk_commande = ".((int) $object->id);
746 if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
747 $sql .= " AND l.product_type = 0";
748 }
749
750 // Enable hooks to alter the SQL query (WHERE)
751 $parameters = array();
752 $reshook = $hookmanager->executeHooks(
753 'printFieldListWhere',
754 $parameters,
755 $object,
756 $action
757 );
758 if ($reshook < 0) {
759 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
760 }
761 $sql .= $hookmanager->resPrint;
762
763 //$sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
764 $sql .= " ORDER BY l.rang, p.ref, p.label";
765
766 // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default)
767 // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on.
768 $nbproduct = 0;
769
770 $resql = $db->query($sql);
771 if ($resql) {
772 $num = $db->num_rows($resql);
773 $i = 0;
774
775 if ($num) {
776 print '<tr class="liste_titre">';
777
778 print '<td>'.$langs->trans("Description").'</td>';
779 if (isModEnabled('productbatch')) {
780 print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
781 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
782 print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
783 }
784 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
785 print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
786 }
787 } else {
788 print '<td></td>';
789 print '<td></td>';
790 print '<td></td>';
791 }
792 print '<td class="right">'.$langs->trans("SupplierRef").'</td>';
793 print '<td class="right">'.$langs->trans("QtyOrdered").'</td>';
794 print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
795 print ' <td class="right">'.$langs->trans("QtyToDispatchShort");
796 print '<br><a href="#" id="autoreset">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').$langs->trans("Reset").'</a></td>';
797 print '<td width="32"></td>';
798
799 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
800 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
801 print '<td class="right">'.$langs->trans("Price").'</td>';
802 print '<td class="right">'.$langs->trans("ReductionShort").' (%)</td>';
803 print '<td class="right">'.$langs->trans("UpdatePrice").'</td>';
804 }
805 }
806
807 print '<td align="right">'.$langs->trans("Warehouse");
808
809 // Select warehouse to force it everywhere
810 if (count($listwarehouses) > 1) {
811 print '<br>'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans("ForceTo"), 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1);
812 } elseif (count($listwarehouses) == 1) {
813 print '<br>'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1);
814 }
815
816 print '</td>';
817
818 // Enable hooks to append additional columns
819 $parameters = array();
820 $reshook = $hookmanager->executeHooks(
821 'printFieldListTitle',
822 $parameters,
823 $object,
824 $action
825 );
826 if ($reshook < 0) {
827 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
828 }
829 print $hookmanager->resPrint;
830
831 print "</tr>\n";
832 }
833
834 $nbfreeproduct = 0; // Nb of lines of free products/services
835
836 $conf->cache['product'] = array();
837
838 // Loop on each source order line (may be more or less than current number of lines in llx_commande_fournisseurdet)
839 while ($i < $num) {
840 $objp = $db->fetch_object($resql);
841
842 // On n'affiche pas les produits libres
843 if (!$objp->fk_product > 0) {
844 $nbfreeproduct++;
845 } else {
846 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
847 $remaintodispatch = price2num($objp->qty - ((float) $alreadydispatched), 5); // Calculation of dispatched
848 if ($remaintodispatch < 0 && !getDolGlobalString('SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
849 $remaintodispatch = 0;
850 }
851
852 if ($remaintodispatch || !getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
853 $nbproduct++;
854
855 // To show detail cref and description value, we must make calculation by cref
856 // print ($objp->cref?' ('.$objp->cref.')':'');
857 // if ($objp->description) print '<br>'.nl2br($objp->description);
858 $suffix = '_0_'.$i;
859
860 print "\n";
861 print '<!-- Line to dispatch '.$suffix.' -->'."\n";
862 // hidden fields for js function
863 print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$objp->qty.'">';
864 print '<input id="qty_dispatched'.$suffix.'" type="hidden" value="'.(float) $alreadydispatched.'">';
865 print '<tr class="oddeven">';
866
867 if (empty($conf->cache['product'][$objp->fk_product])) {
868 $tmpproduct = new Product($db);
869 $tmpproduct->fetch($objp->fk_product);
870 $conf->cache['product'][$objp->fk_product] = $tmpproduct;
871 } else {
872 $tmpproduct = $conf->cache['product'][$objp->fk_product];
873 }
874
875 $linktoprod = $tmpproduct->getNomUrl(1);
876 $linktoprod .= ' - '.$objp->label."\n";
877
878 if (isModEnabled('productbatch')) {
879 if ($objp->tobatch) {
880 // Product
881 print '<td>';
882 print $linktoprod;
883 print "</td>";
884 print '<td class="dispatch_batch_number"></td>';
885 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
886 print '<td class="dispatch_dlc"></td>';
887 }
888 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
889 print '<td class="dispatch_dluo"></td>';
890 }
891 } else {
892 // Product
893 print '<td>';
894 print $linktoprod;
895 print "</td>";
896 print '<td class="dispatch_batch_number">';
897 print '<span class="opacitymedium small">'.$langs->trans("ProductDoesNotUseBatchSerial").'</small>';
898 print '</td>';
899 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
900 print '<td class="dispatch_dlc"></td>';
901 }
902 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
903 print '<td class="dispatch_dluo"></td>';
904 }
905 }
906 } else {
907 print '<td colspan="4">';
908 print $linktoprod;
909 print "</td>";
910 }
911
912 // Define unit price for PMP calculation
913 $up_ht_disc = $objp->subprice;
914 if (!empty($objp->remise_percent) && !getDolGlobalString('STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
915 $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU');
916 }
917
918 // Supplier ref
919 print '<td class="right">'.$objp->sref.'</td>';
920
921 // Qty ordered
922 print '<td class="right">'.$objp->qty.'</td>';
923
924 // Already dispatched
925 print '<td class="right">'.$alreadydispatched.'</td>';
926
927 if (isModEnabled('productbatch') && $objp->tobatch > 0) {
928 $type = 'batch';
929 print '<td class="right">';
930 print '</td>'; // Qty to dispatch
931 print '<td>';
932 //print img_picto($langs->trans('AddDispatchBatchLine'), 'split', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
933 print '</td>'; // Dispatch column
934 print '<td></td>'; // Warehouse column
935
936 // Enable hooks to append additional columns
937 $parameters = array(
938 // allows hook to distinguish between the rows with information and the rows with dispatch form input
939 'is_information_row' => true,
940 'i' => $i,
941 'suffix' => $suffix,
942 'objp' => $objp,
943 );
944 $reshook = $hookmanager->executeHooks(
945 'printFieldListValue',
946 $parameters,
947 $object,
948 $action
949 );
950 if ($reshook < 0) {
951 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
952 }
953 print $hookmanager->resPrint;
954
955 print '</tr>';
956
957 print '<tr class="oddeven" name="'.$type.$suffix.'">';
958 print '<td>';
959 print '<input name="fk_commandefourndet'.$suffix.'" type="hidden" value="'.$objp->rowid.'">';
960 print '<input name="product_batch'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">';
961
962 print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
963 if (getDolGlobalString('SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT')) { // Not tested !
964 print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price($up_ht_disc).'">';
965 } else {
966 print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price($up_ht_disc).'">';
967 }
968
969 print '</td>';
970
971 print '<td>';
972 print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.GETPOST('lot_number'.$suffix).'">';
973 print '</td>';
974 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
975 print '<td class="nowraponall">';
976 $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOSTINT('dlc'.$suffix.'month'), GETPOSTINT('dlc'.$suffix.'day'), GETPOSTINT('dlc'.$suffix.'year'));
977 print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, 0, 0, 1, '');
978 print '</td>';
979 }
980 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
981 print '<td class="nowraponall">';
982 $dluodatesuffix = dol_mktime(0, 0, 0, GETPOSTINT('dluo'.$suffix.'month'), GETPOSTINT('dluo'.$suffix.'day'), GETPOSTINT('dluo'.$suffix.'year'));
983 print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, 0, 0, 1, '');
984 print '</td>';
985 }
986 print '<td colspan="3">&nbsp;</td>'; // Supplier ref + Qty ordered + qty already dispatched
987 } else {
988 $type = 'dispatch';
989 $colspan = 7;
990 $colspan = (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) ? --$colspan : $colspan;
991 $colspan = (getDolGlobalString('PRODUCT_DISABLE_EATBY')) ? --$colspan : $colspan;
992 print '<td class="right">';
993 print '</td>'; // Qty to dispatch
994 print '<td>';
995 //print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
996 print '</td>'; // Dispatch column
997 print '<td></td>'; // Warehouse column
998
999 // Enable hooks to append additional columns
1000 $parameters = array(
1001 // allows hook to distinguish between the rows with information and the rows with dispatch form input
1002 'is_information_row' => true,
1003 'i' => $i,
1004 'suffix' => $suffix,
1005 'objp' => $objp,
1006 );
1007 $reshook = $hookmanager->executeHooks(
1008 'printFieldListValue',
1009 $parameters,
1010 $object,
1011 $action
1012 );
1013 if ($reshook < 0) {
1014 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1015 }
1016 print $hookmanager->resPrint;
1017
1018 print '</tr>';
1019
1020 print '<tr class="oddeven" name="'.$type.$suffix.'">';
1021 print '<td colspan="'.$colspan.'">';
1022 print '<input name="fk_commandefourndet'.$suffix.'" type="hidden" value="'.$objp->rowid.'">';
1023 print '<input name="product'.$suffix.'" type="hidden" value="'.$objp->fk_product.'">';
1024
1025 print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
1026 if (getDolGlobalString('SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT')) { // Not tested !
1027 print $langs->trans("BuyingPrice").': <input class="maxwidth75" name="pu'.$suffix.'" type="text" value="'.price2num($up_ht_disc, 'MU').'">';
1028 } else {
1029 print '<input class="maxwidth75" name="pu'.$suffix.'" type="hidden" value="'.price2num($up_ht_disc, 'MU').'">';
1030 }
1031
1032 print '</td>';
1033 }
1034
1035 // Qty to dispatch
1036 print '<td class="right nowrap">';
1037 if ($remaintodispatch > 0) {
1038 $btnLabel = $langs->trans("Fill").' : '.$remaintodispatch;
1039 print '<button class="auto-fill-qty btn-low-emphasis --btn-icon" data-rowname="qty'.$suffix.'" data-value="'.$remaintodispatch.'" title="'.dol_escape_htmltag($btnLabel).'" aria-label="'.dol_escape_htmltag($btnLabel).'" >'.img_picto($btnLabel, 'fa-arrow-right', 'aria-hidden="true"', 0, 0, 1).'</button>';
1040 }
1041 print '<input id="qty'.$suffix.'" name="qty'.$suffix.'" type="number" step="any" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOSTINT('qty'.$suffix) : (!getDolGlobalString('SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO') ? $remaintodispatch : 0)).'">';
1042 print '<button class="resetline btn-low-emphasis --btn-icon" id="reset'.$suffix.'" title="'.dol_escape_htmltag($langs->trans("Reset")).'" >'.img_picto($langs->trans("Reset"), 'eraser', 'aria-hidden="true"', 0, 0, 1).'</button>';
1043 print '</td>';
1044
1045 print '<td>';
1046 if (isModEnabled('productbatch') && $objp->tobatch > 0) {
1047 $type = 'batch';
1048 print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"');
1049 } else {
1050 $type = 'dispatch';
1051 print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"');
1052 }
1053 print '</td>';
1054
1055 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
1056 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
1057 // Price
1058 print '<td class="right">';
1059 print '<input id="pu'.$suffix.'" name="pu'.$suffix.'" type="text" size="8" value="'.price((GETPOST('pu'.$suffix) != '' ? price2num(GETPOST('pu'.$suffix)) : $up_ht_disc)).'">';
1060 print '</td>';
1061
1062 // Discount
1063 print '<td class="right">';
1064 print '<input id="dto'.$suffix.'" name="dto'.$suffix.'" type="text" size="8" value="'.(GETPOST('dto'.$suffix) != '' ? GETPOST('dto'.$suffix) : '').'">';
1065 print '</td>';
1066
1067 // Save price
1068 print '<td class="center">';
1069 print '<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.'" value="'.(GETPOST('saveprice'.$suffix) != '' ? GETPOST('saveprice'.$suffix) : '').'">';
1070 print '</td>';
1071 }
1072 }
1073
1074 // Warehouse
1075 print '<td class="right">';
1076 if (count($listwarehouses) > 1) {
1077 print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix);
1078 } elseif (count($listwarehouses) == 1) {
1079 print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix);
1080 } else {
1081 $langs->load("errors");
1082 print $langs->trans("ErrorNoWarehouseDefined");
1083 }
1084 print "</td>\n";
1085
1086 // Enable hooks to append additional columns
1087 $parameters = array(
1088 'is_information_row' => false, // this is a dispatch form row
1089 'i' => $i,
1090 'suffix' => $suffix,
1091 'objp' => $objp,
1092 );
1093 $reshook = $hookmanager->executeHooks(
1094 'printFieldListValue',
1095 $parameters,
1096 $object,
1097 $action
1098 );
1099 if ($reshook < 0) {
1100 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1101 }
1102 print $hookmanager->resPrint;
1103
1104 print "</tr>\n";
1105 }
1106 }
1107 $i++;
1108 }
1109 $db->free($resql);
1110 } else {
1111 dol_print_error($db);
1112 }
1113
1114 print "</table>\n";
1115 print '</div>';
1116
1117 if ($nbproduct) {
1118 $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1119
1120 print '<div class="center">';
1121 $parameters = array();
1122 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1123 // modified by hook
1124 if (empty($reshook)) {
1125 if (empty($conf->reception->enabled)) {
1126 print $langs->trans("Comment").' : ';
1127 print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
1128 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1129 // print ' / '.$object->ref_supplier; // Not yet available
1130 print '" class="flat"><br>';
1131
1132 print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
1133 }
1134
1135 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
1136
1137 print '<br>';
1138 print '<input type="hidden" name="backtopageforcancel" value="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
1139 print '<input type="submit" class="button" name="dispatch" value="'.dol_escape_htmltag($dispatchBt).'"';
1140 $disabled = 0;
1141 if (!$permissiontoreceive) {
1142 $disabled = 1;
1143 }
1144 if (count($listwarehouses) <= 0) {
1145 $disabled = 1;
1146 }
1147 if ($disabled) {
1148 print ' disabled';
1149 }
1150
1151 print '>';
1152 }
1153 print '</div>';
1154 }
1155
1156 // Message if nothing to dispatch
1157 if (!$nbproduct) {
1158 print "<br>\n";
1159 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1160 print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
1161 } else {
1162 print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
1163 }
1164 }
1165
1166 print '</form>';
1167 }
1168
1169 print dol_get_fiche_end();
1170
1171 // traitement entrepot par défaut
1172 print '<script type="text/javascript">
1173 $(document).ready(function () {
1174 $("select[name=fk_default_warehouse]").change(function() {
1175 var fk_default_warehouse = $("option:selected", this).val();
1176 $("select[name^=entrepot_]").val(fk_default_warehouse).change();
1177 });
1178
1179 $(".auto-fill-qty").on("click touchstart", function(e){
1180 e.preventDefault();
1181 $("input[name="+$(this).data("rowname")+"]").val($(this).data("value")).trigger("change");
1182 });
1183
1184 $("#autoreset").click(function() {
1185 $(".qtydispatchinput").each(function(){
1186 id = $(this).attr("id");
1187 idtab = id.split("_");
1188 if(idtab[1] == 0){
1189 console.log(idtab);
1190 $(this).val("");
1191 $("#qty_dispatched_0_"+idtab[2]).val("0");
1192 } else {
1193 obj = $(this).parent().parent();
1194 nameobj = obj.attr("name");
1195 nametab = nameobj.split("_");
1196 obj.remove();
1197 $("tr[name^=\'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show();
1198 }
1199 });
1200 });
1201
1202 $(".resetline").click(function(e){
1203 e.preventDefault();
1204 id = $(this).attr("id");
1205 id = id.split("reset_");
1206 console.log("Reset trigger for id = qty_"+id[1]);
1207 $("#qty_"+id[1]).val("");
1208 });
1209 });
1210 </script>';
1211
1212 // List of lines already dispatched
1213 $sql = "SELECT p.rowid as pid, p.ref, p.label,";
1214 $sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
1215 $sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
1216 $sql .= " ,cd.rowid, cd.subprice";
1217 if (isModEnabled('reception')) {
1218 $sql .= ", cfd.fk_reception, r.date_delivery";
1219 }
1220 $sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
1221 $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
1222 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_elementdet";
1223 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
1224 if (isModEnabled('reception')) {
1225 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid";
1226 }
1227 $sql .= " WHERE cfd.fk_element = ".((int) $object->id);
1228 $sql .= " AND cfd.fk_product = p.rowid";
1229 $sql .= " ORDER BY cfd.rowid ASC";
1230
1231 $resql = $db->query($sql);
1232 if ($resql) {
1233 $num = $db->num_rows($resql);
1234 $i = 0;
1235
1236 if ($num > 0) {
1237 print "<br>\n";
1238
1239 print load_fiche_titre($langs->trans("ReceivingForSameOrder"));
1240
1241 print '<div class="div-table-responsive">';
1242 print '<table id="dispatch_received_products" class="noborder centpercent">';
1243
1244 print '<tr class="liste_titre">';
1245 // Reception ref
1246 if (isModEnabled("reception")) {
1247 print '<td>'.$langs->trans("Reception").'</td>';
1248 }
1249 // Product
1250 print '<td>'.$langs->trans("Product").'</td>';
1251 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
1252 print '<td class="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
1253 if (isModEnabled('productbatch')) {
1254 print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
1255 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1256 print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
1257 }
1258 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1259 print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
1260 }
1261 }
1262 print '<td class="right">'.$langs->trans("QtyDispatched").'</td>';
1263 print '<td>'.$langs->trans("Warehouse").'</td>';
1264 print '<td>'.$langs->trans("Comment").'</td>';
1265
1266 // Status
1267 if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && !isModEnabled("reception")) {
1268 print '<td class="center" colspan="2">'.$langs->trans("Status").'</td>';
1269 } elseif (isModEnabled("reception")) {
1270 print '<td class="center"></td>';
1271 }
1272
1273 print '<td class="center" colspan="2"></td>';
1274
1275 print "</tr>\n";
1276
1277
1278 while ($i < $num) {
1279 $objp = $db->fetch_object($resql);
1280
1281 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1282 print '<form name="editdispatchedlines" id="editdispatchedlines" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#line_'.GETPOSTINT('lineid').'" method="POST">
1283 <input type="hidden" name="token" value="'.newToken().'">
1284 <input type="hidden" name="action" value="updateline">
1285 <input type="hidden" name="mode" value="">
1286 <input type="hidden" name="lineid" value="'.$objp->dispatchlineid.'">';
1287 }
1288
1289 print '<tr class="oddeven" id="line_'.$objp->dispatchlineid.'" >';
1290
1291 // Reception ref
1292 $reception = null;
1293 if (isModEnabled("reception")) {
1294 print '<td class="nowraponall">';
1295 if (!empty($objp->fk_reception)) {
1296 $reception = new Reception($db);
1297 $reception->fetch($objp->fk_reception);
1298 print $reception->getNomUrl(1);
1299 }
1300
1301 print "</td>";
1302 }
1303
1304 // Product
1305 print '<td class="tdoverflowmax150">';
1306 if (empty($conf->cache['product'][$objp->fk_product])) {
1307 $tmpproduct = new Product($db);
1308 $tmpproduct->fetch($objp->fk_product);
1309 $conf->cache['product'][$objp->fk_product] = $tmpproduct;
1310 } else {
1311 $tmpproduct = $conf->cache['product'][$objp->fk_product];
1312 }
1313 print $tmpproduct->getNomUrl(1);
1314 print ' - '.$objp->label;
1315 print "</td>\n";
1316
1317 // Date creation
1318 print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'day').'</td>';
1319
1320 // Date delivery of reception
1321 if (isModEnabled('reception')) {
1322 print '<td class="center">';
1323 if (!empty($objp->date_delivery)) {
1324 print dol_print_date($db->jdate($objp->date_delivery), 'day');
1325 }
1326 print '</td>';
1327 } else {
1328 print '<td class="center"></td>';
1329 }
1330
1331 // Batch / Eat by / Sell by
1332 if (isModEnabled('productbatch')) {
1333 if ($objp->batch) {
1334 include_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
1335 $lot = new Productlot($db);
1336 $lot->fetch(0, $objp->pid, $objp->batch);
1337 print '<td class="dispatch_batch_number">'.$lot->getNomUrl(1).'</td>';
1338 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1339 print '<td class="dispatch_dlc">'.dol_print_date($lot->sellby, 'day').'</td>';
1340 }
1341 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1342 print '<td class="dispatch_dluo">'.dol_print_date($lot->eatby, 'day').'</td>';
1343 }
1344 } else {
1345 print '<td class="dispatch_batch_number"></td>';
1346 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1347 print '<td class="dispatch_dlc"></td>';
1348 }
1349 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1350 print '<td class="dispatch_dluo"></td>';
1351 }
1352 }
1353 }
1354
1355 // Qty
1356 print '<td class="right">';
1357 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1358 print '<input style="width: 50px;" type="text" min="1" name="qty" value="'.$objp->qty.'" />';
1359 } else {
1360 print $objp->qty;
1361 }
1362 print '<input type="hidden" name="price" value="'.$objp->subprice.'" />';
1363 print '</td>';
1364 // Warehouse
1365 print '<td class="tdoverflowmax150">';
1366 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1367 $warehouse_id = GETPOSTINT("fk_entrepot") ? GETPOSTINT("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : '');
1368 if (count($listwarehouses) > 1) {
1369 print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse');
1370 } elseif (count($listwarehouses) == 1) {
1371 print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 0, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse');
1372 } else {
1373 $langs->load("errors");
1374 print $langs->trans("ErrorNoWarehouseDefined");
1375 }
1376 } else {
1377 $warehouse_static->id = $objp->warehouse_id;
1378 $warehouse_static->label = $objp->entrepot;
1379 print $warehouse_static->getNomUrl(1);
1380 }
1381 print '</td>';
1382
1383 // Comment
1384 print '<td class="tdoverflowmax300" style="white-space: pre;">'.$objp->comment.'</td>';
1385
1386 // Status
1387 if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && !isModEnabled("reception")) {
1388 print '<td class="right">';
1389 $supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
1390 // print $supplierorderdispatch->status;
1391 print $supplierorderdispatch->getLibStatut(5);
1392 print '</td>';
1393
1394 // Add button to check/uncheck disaptching
1395 print '<td class="center">';
1396 if (!$permissiontocontrol) {
1397 if (empty($objp->status)) {
1398 print '<a class="button buttonRefused" href="#">'.$langs->trans("Approve").'</a>';
1399 print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
1400 } else {
1401 print '<a class="button buttonRefused" href="#">'.$langs->trans("Disapprove").'</a>';
1402 print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
1403 }
1404 } else {
1405 $disabled = '';
1406 if ($object->status == $object::STATUS_RECEIVED_COMPLETELY) {
1407 $disabled = 1;
1408 }
1409 if (empty($objp->status)) {
1410 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
1411 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
1412 }
1413 if ($objp->status == 1) {
1414 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
1415 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
1416 }
1417 if ($objp->status == 2) {
1418 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
1419 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
1420 }
1421 }
1422 print '</td>';
1423 } elseif (isModEnabled("reception")) {
1424 print '<td class="right">';
1425 if ($reception !== null && !empty($reception->id)) {
1426 print $reception->getLibStatut(5);
1427 }
1428 print '</td>';
1429 }
1430
1431 // Action
1432 if ($action != 'editline' || $lineid != $objp->dispatchlineid) {
1433 if (($reception === null) || empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { // only allow edit on draft reception
1434 print '<td class="linecoledit center">';
1435 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&lineid='.$objp->dispatchlineid.'#line_'.$objp->dispatchlineid.'">';
1436 print img_edit();
1437 print '</a>';
1438 print '</td>';
1439
1440 print '<td class="linecoldelete center">';
1441 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=ask_deleteline&token='.newToken().'&lineid='.$objp->dispatchlineid.'#dispatch_received_products">';
1442 print img_delete();
1443 print '</a>';
1444 print '</td>';
1445 } else {
1446 print '<td></td><td></td>';
1447 }
1448 } else {
1449 print '<td class="center valignmiddle">';
1450 print '<input type="submit" class="button button-save" id="savelinebutton" name="save" value="'.$langs->trans("Save").'" />';
1451 print '</td>';
1452 print '<td class="center valignmiddle">';
1453 print '<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'" />';
1454 print '</td>';
1455 }
1456
1457
1458 print "</tr>\n";
1459 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1460 print '</form>';
1461 }
1462
1463 $i++;
1464 }
1465 $db->free($resql);
1466
1467 print "</table>\n";
1468 print '</div>';
1469 }
1470 } else {
1471 dol_print_error($db);
1472 }
1473}
1474
1475// End of page
1476llxFooter();
1477$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage table ReceptionLineBatch.
Class to manage predefined suppliers products.
const STATUS_RECEIVED_PARTIALLY
Received partially.
const STATUS_CANCELED
Order canceled.
const STATUS_RECEIVED_COMPLETELY
Received completely.
const STATUS_ORDERSENT
Order sent, shipment on process.
Class to manage comment.
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 ...
Class to manage stock movements.
Class to manage products or services.
Class with list of lots and properties.
Class to manage projects.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
ordersupplier_prepare_head(CommandeFournisseur $object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:135
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.