dolibarr 24.0.3
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($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 } else {
1058 $type = 'dispatch';
1059 print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"');
1060 }
1061 print '</td>';
1062
1063 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
1064 if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) {
1065 // Price
1066 print '<td class="right">';
1067 print '<input id="pu'.$suffix.'" name="pu'.$suffix.'" type="text" size="8" value="'.price((GETPOST('pu'.$suffix) != '' ? price2num(GETPOST('pu'.$suffix)) : $up_ht_disc)).'">';
1068 print '</td>';
1069
1070 // Discount
1071 print '<td class="right">';
1072 print '<input id="dto'.$suffix.'" name="dto'.$suffix.'" type="text" size="8" value="'.(GETPOST('dto'.$suffix) != '' ? GETPOST('dto'.$suffix) : '').'">';
1073 print '</td>';
1074
1075 // Save price
1076 print '<td class="center">';
1077 print '<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.'" value="'.(GETPOST('saveprice'.$suffix) != '' ? GETPOST('saveprice'.$suffix) : '').'">';
1078 print '</td>';
1079 }
1080 }
1081
1082 // Warehouse
1083 print '<td class="right">';
1084 if (count($listwarehouses) > 1) {
1085 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);
1086 } elseif (count($listwarehouses) == 1) {
1087 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);
1088 } else {
1089 $langs->load("errors");
1090 print $langs->trans("ErrorNoWarehouseDefined");
1091 }
1092 print "</td>\n";
1093
1094 // Enable hooks to append additional columns
1095 $parameters = array(
1096 'is_information_row' => false, // this is a dispatch form row
1097 'i' => $i,
1098 'suffix' => $suffix,
1099 'objp' => $objp,
1100 );
1101 $reshook = $hookmanager->executeHooks(
1102 'printFieldListValue',
1103 $parameters,
1104 $object,
1105 $action
1106 );
1107 if ($reshook < 0) {
1108 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1109 }
1110 print $hookmanager->resPrint;
1111
1112 print "</tr>\n";
1113 }
1114 }
1115 $i++;
1116 }
1117 $db->free($resql);
1118 } else {
1119 dol_print_error($db);
1120 }
1121
1122 print "</table>\n";
1123 print '</div>';
1124
1125 if ($nbproduct) {
1126 $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1127
1128 print '<div class="center">';
1129 $parameters = array();
1130 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1131 // modified by hook
1132 if (empty($reshook)) {
1133 if (empty($conf->reception->enabled)) {
1134 print $langs->trans("Comment").' : ';
1135 print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
1136 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1137 // print ' / '.$object->ref_supplier; // Not yet available
1138 print '" class="flat"><br>';
1139
1140 print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
1141 }
1142
1143 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
1144
1145 print '<br>';
1146 print '<input type="hidden" name="backtopageforcancel" value="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
1147 print '<input type="submit" class="button" name="dispatch" value="'.dol_escape_htmltag($dispatchBt).'"';
1148 $disabled = 0;
1149 if (!$permissiontoreceive) {
1150 $disabled = 1;
1151 }
1152 if (count($listwarehouses) <= 0) {
1153 $disabled = 1;
1154 }
1155 if ($disabled) {
1156 print ' disabled';
1157 }
1158
1159 print '>';
1160 }
1161 print '</div>';
1162 }
1163
1164 // Message if nothing to dispatch
1165 if (!$nbproduct) {
1166 print "<br>\n";
1167 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1168 print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
1169 } else {
1170 print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
1171 }
1172 }
1173
1174 print '</form>';
1175 }
1176
1177 print dol_get_fiche_end();
1178
1179 // default warehouse processing
1180 print '<script type="text/javascript">
1181 $(document).ready(function () {
1182 $("select[name=fk_default_warehouse]").change(function() {
1183 var fk_default_warehouse = $("option:selected", this).val();
1184 $("select[name^=entrepot_]").val(fk_default_warehouse).change();
1185 });
1186
1187 $(".auto-fill-qty").on("click touchstart", function(e){
1188 e.preventDefault();
1189 $("input[name="+$(this).data("rowname")+"]").val($(this).data("value")).trigger("change");
1190 });
1191
1192 $("#autoreset").click(function() {
1193 $(".qtydispatchinput").each(function(){
1194 id = $(this).attr("id");
1195 idtab = id.split("_");
1196 if(idtab[1] == 0){
1197 console.log(idtab);
1198 $(this).val("");
1199 $("#qty_dispatched_0_"+idtab[2]).val("0");
1200 } else {
1201 obj = $(this).parent().parent();
1202 nameobj = obj.attr("name");
1203 nametab = nameobj.split("_");
1204 obj.remove();
1205 $("tr[name^=\'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show();
1206 }
1207 });
1208 });
1209
1210 $(".resetline").click(function(e){
1211 e.preventDefault();
1212 id = $(this).attr("id");
1213 id = id.split("reset_");
1214 console.log("Reset trigger for id = qty_"+id[1]);
1215 $("#qty_"+id[1]).val("");
1216 });
1217 });
1218 </script>';
1219
1220 // List of lines already dispatched
1221 $sql = "SELECT p.rowid as pid, p.ref, p.label,";
1222 $sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
1223 $sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
1224 $sql .= " ,cd.rowid, cd.subprice";
1225 if (isModEnabled('reception')) {
1226 $sql .= ", cfd.fk_reception, r.date_delivery";
1227 }
1228 $sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
1229 $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as cfd";
1230 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_elementdet";
1231 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
1232 if (isModEnabled('reception')) {
1233 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid";
1234 }
1235 $sql .= " WHERE cfd.fk_element = ".((int) $object->id);
1236 $sql .= " AND cfd.fk_product = p.rowid";
1237 $sql .= " ORDER BY cfd.rowid ASC";
1238
1239 $resql = $db->query($sql);
1240 if ($resql) {
1241 $num = $db->num_rows($resql);
1242 $i = 0;
1243
1244 if ($num > 0) {
1245 print "<br>\n";
1246
1247 print load_fiche_titre($langs->trans("ReceivingForSameOrder"));
1248
1249 print '<div class="div-table-responsive">';
1250 print '<table id="dispatch_received_products" class="noborder centpercent">';
1251
1252 print '<tr class="liste_titre">';
1253 // Reception ref
1254 if (isModEnabled("reception")) {
1255 print '<td>'.$langs->trans("Reception").'</td>';
1256 }
1257 // Product
1258 print '<td>'.$langs->trans("Product").'</td>';
1259 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
1260 print '<td class="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
1261 if (isModEnabled('productbatch')) {
1262 print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
1263 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1264 print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
1265 }
1266 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1267 print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
1268 }
1269 }
1270 print '<td class="right">'.$langs->trans("QtyDispatched").'</td>';
1271 print '<td>'.$langs->trans("Warehouse").'</td>';
1272 print '<td>'.$langs->trans("Comment").'</td>';
1273
1274 // Status
1275 if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && !isModEnabled("reception")) {
1276 print '<td class="center" colspan="2">'.$langs->trans("Status").'</td>';
1277 } elseif (isModEnabled("reception")) {
1278 print '<td class="center"></td>';
1279 }
1280
1281 print '<td class="center" colspan="2"></td>';
1282
1283 print "</tr>\n";
1284
1285
1286 while ($i < $num) {
1287 $objp = $db->fetch_object($resql);
1288
1289 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1290 print '<form name="editdispatchedlines" id="editdispatchedlines" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#line_'.GETPOSTINT('lineid').'" method="POST">
1291 <input type="hidden" name="token" value="'.newToken().'">
1292 <input type="hidden" name="action" value="updateline">
1293 <input type="hidden" name="mode" value="">
1294 <input type="hidden" name="lineid" value="'.$objp->dispatchlineid.'">';
1295 }
1296
1297 print '<tr class="oddeven" id="line_'.$objp->dispatchlineid.'" >';
1298
1299 // Reception ref
1300 $reception = null;
1301 if (isModEnabled("reception")) {
1302 print '<td class="nowraponall">';
1303 if (!empty($objp->fk_reception)) {
1304 $reception = new Reception($db);
1305 $reception->fetch($objp->fk_reception);
1306 print $reception->getNomUrl(1);
1307 }
1308
1309 print "</td>";
1310 }
1311
1312 // Product
1313 print '<td class="tdoverflowmax150">';
1314 if (empty($conf->cache['product'][$objp->fk_product])) {
1315 $tmpproduct = new Product($db);
1316 $tmpproduct->fetch($objp->fk_product);
1317 $conf->cache['product'][$objp->fk_product] = $tmpproduct;
1318 } else {
1319 $tmpproduct = $conf->cache['product'][$objp->fk_product];
1320 }
1321 print $tmpproduct->getNomUrl(1);
1322 print ' - '.$objp->label;
1323 print "</td>\n";
1324
1325 // Date creation
1326 print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'day').'</td>';
1327
1328 // Date delivery of reception
1329 if (isModEnabled('reception')) {
1330 print '<td class="center">';
1331 if (!empty($objp->date_delivery)) {
1332 print dol_print_date($db->jdate($objp->date_delivery), 'day');
1333 }
1334 print '</td>';
1335 } else {
1336 print '<td class="center"></td>';
1337 }
1338
1339 // Batch / Eat by / Sell by
1340 if (isModEnabled('productbatch')) {
1341 if ($objp->batch) {
1342 include_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
1343 $lot = new Productlot($db);
1344 $lot->fetch(0, $objp->pid, $objp->batch);
1345 print '<td class="dispatch_batch_number" data-col="batch" data-batch="' . dolPrintHTMLForAttribute($objp->batch) . '" data-productid="' . $objp->fk_product . '" >'.$lot->getNomUrl(1).'</td>';
1346 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1347 print '<td class="dispatch_dlc">'.dol_print_date($lot->sellby, 'day').'</td>';
1348 }
1349 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1350 print '<td class="dispatch_dluo">'.dol_print_date($lot->eatby, 'day').'</td>';
1351 }
1352 } else {
1353 print '<td class="dispatch_batch_number" data-col="batch" data-batch="" data-productid="' . $objp->fk_product . '" ></td>';
1354 if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
1355 print '<td class="dispatch_dlc"></td>';
1356 }
1357 if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
1358 print '<td class="dispatch_dluo"></td>';
1359 }
1360 }
1361 }
1362
1363 // Qty
1364 print '<td class="right">';
1365 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1366 print '<input style="width: 50px;" type="text" min="1" name="qty" value="'.$objp->qty.'" />';
1367 } else {
1368 print $objp->qty;
1369 }
1370 print '<input type="hidden" name="price" value="'.$objp->subprice.'" />';
1371 print '</td>';
1372 // Warehouse
1373 print '<td class="tdoverflowmax150">';
1374 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1375 $warehouse_id = GETPOSTINT("fk_entrepot") ? GETPOSTINT("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : '');
1376 if (count($listwarehouses) > 1) {
1377 print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse');
1378 } elseif (count($listwarehouses) == 1) {
1379 print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 0, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse');
1380 } else {
1381 $langs->load("errors");
1382 print $langs->trans("ErrorNoWarehouseDefined");
1383 }
1384 } else {
1385 $warehouse_static->id = $objp->warehouse_id;
1386 $warehouse_static->label = $objp->entrepot;
1387 print $warehouse_static->getNomUrl(1);
1388 }
1389 print '</td>';
1390
1391 // Comment
1392 print '<td class="tdoverflowmax300" style="white-space: pre;">'.$objp->comment.'</td>';
1393
1394 // Status
1395 if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && !isModEnabled("reception")) {
1396 print '<td class="right">';
1397 $supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
1398 // print $supplierorderdispatch->status;
1399 print $supplierorderdispatch->getLibStatut(5);
1400 print '</td>';
1401
1402 // Add button to check/uncheck dispatching
1403 print '<td class="center">';
1404 if (!$permissiontocontrol) {
1405 if (empty($objp->status)) {
1406 print '<a class="button buttonRefused" href="#">'.$langs->trans("Approve").'</a>';
1407 print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
1408 } else {
1409 print '<a class="button buttonRefused" href="#">'.$langs->trans("Disapprove").'</a>';
1410 print '<a class="button buttonRefused" href="#">'.$langs->trans("Deny").'</a>';
1411 }
1412 } else {
1413 $disabled = '';
1414 if ($object->status == $object::STATUS_RECEIVED_COMPLETELY) {
1415 $disabled = 1;
1416 }
1417 if (empty($objp->status)) {
1418 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
1419 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
1420 }
1421 if ($objp->status == 1) {
1422 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
1423 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=denydispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Deny").'</a>';
1424 }
1425 if ($objp->status == 2) {
1426 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Reinit").'</a>';
1427 print '<a class="button'.($disabled ? ' buttonRefused' : '').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&token=".newToken()."&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Approve").'</a>';
1428 }
1429 }
1430 print '</td>';
1431 } elseif (isModEnabled("reception")) {
1432 print '<td class="right">';
1433 if ($reception !== null && !empty($reception->id)) {
1434 print $reception->getLibStatut(5);
1435 }
1436 print '</td>';
1437 }
1438
1439 // Action
1440 if ($action != 'editline' || $lineid != $objp->dispatchlineid) {
1441 if (($reception === null) || empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { // only allow edit on draft reception
1442 print '<td class="linecoledit center">';
1443 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&lineid='.$objp->dispatchlineid.'#line_'.$objp->dispatchlineid.'">';
1444 print img_edit();
1445 print '</a>';
1446 print '</td>';
1447
1448 print '<td class="linecoldelete center">';
1449 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=ask_deleteline&token='.newToken().'&lineid='.$objp->dispatchlineid.'#dispatch_received_products">';
1450 print img_delete();
1451 print '</a>';
1452 print '</td>';
1453 } else {
1454 print '<td></td><td></td>';
1455 }
1456 } else {
1457 print '<td class="center valignmiddle">';
1458 print '<input type="submit" class="button button-save" id="savelinebutton" name="save" value="'.$langs->trans("Save").'" />';
1459 print '</td>';
1460 print '<td class="center valignmiddle">';
1461 print '<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'" />';
1462 print '</td>';
1463 }
1464
1465
1466 print "</tr>\n";
1467 if ($action == 'editline' && $lineid == $objp->dispatchlineid) {
1468 print '</form>';
1469 }
1470
1471 $i++;
1472 }
1473 $db->free($resql);
1474
1475 print "</table>\n";
1476 print '</div>';
1477 }
1478 } else {
1480 }
1481}
1482
1483// End of page
1484llxFooter();
1485$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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
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'.
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.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
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).
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.
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.
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
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.