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