dolibarr 25.0.0-alpha
sendings.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
26require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
27require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
28require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
29
30
41function shippingGetStandaloneDispatchSourceLine($object, $sourceLineId, $lineId, $productId)
42{
43 if (!getDolGlobalString('SHIPMENT_STANDALONE') || $object->id <= 0 || $object->origin_id > 0 || $object->status != Expedition::STATUS_DRAFT || $productId <= 0) {
44 return null;
45 }
46
47 $sourceLine = null;
48 $dispatchLine = null;
49 foreach ($object->lines as $line) {
50 if ((int) $line->fk_expedition !== (int) $object->id) {
51 continue;
52 }
53 if ((int) $line->id === $sourceLineId) {
54 $sourceLine = $line;
55 }
56 if ((int) $line->id === $lineId) {
57 $dispatchLine = $line;
58 }
59 }
60
61 if ($sourceLine === null || $sourceLine->fk_parent > 0 || (int) $sourceLine->fk_product !== $productId) {
62 return null;
63 }
64 if ($lineId > 0 && ($dispatchLine === null || (int) $dispatchLine->fk_product !== $productId
65 || ($lineId !== $sourceLineId && (int) $dispatchLine->fk_parent !== $sourceLineId))) {
66 return null;
67 }
68
69 return $sourceLine;
70}
71
81{
82 global $db, $mysoc;
83
84 if ($line->fk_product > 0) {
85 $tmpprod = new Product($db);
86 if ($tmpprod->fetch($line->fk_product) > 0) {
87 $datapriceofproduct = $tmpprod->getSellPrice($mysoc, $buyer);
88 $line->subprice = $datapriceofproduct['pu_ht'];
89 $line->tva_tx = $datapriceofproduct['tva_tx'];
90 $line->product_type = $tmpprod->type;
91 }
92 }
93 if (empty($line->desc)) {
94 $line->desc = $line->description;
95 }
96}
97
98
106{
107 global $db, $langs, $conf, $user;
108
109 // Load translation files required by the page
110 $langs->loadLangs(array("sendings"));
111
112 $h = 0;
113 $head = array();
114
115 $head[$h][0] = DOL_URL_ROOT . "/expedition/card.php?id=" . $object->id;
116 $head[$h][1] = $langs->trans("SendingCard");
117 $head[$h][2] = 'shipping';
118 $h++;
119
120 if ($object->status == Expedition::STATUS_DRAFT) {
121 $head[$h][0] = DOL_URL_ROOT . "/expedition/dispatch.php?id=" . $object->id;
122 $head[$h][1] = $langs->trans("ShipmentDistribution");
123 $head[$h][2] = 'dispatch';
124 $h++;
125 }
126
127 if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'lire')) {
128 // delivery link
129 $object->fetchObjectLinked($object->id, $object->element);
130 if (isset($object->linkedObjectsIds['delivery']) && is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) { // If there is a delivery
131 // Take first element of array
132 $tmp = reset($object->linkedObjectsIds['delivery']);
133
134 $head[$h][0] = DOL_URL_ROOT . "/delivery/card.php?id=" . ((int) $tmp);
135 $head[$h][1] = $langs->trans("DeliveryCard");
136 $head[$h][2] = 'delivery';
137 $h++;
138 }
139 }
140
141 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
142 $objectsrc = $object;
143 if (!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $object->origin_type == 'commande' && $object->origin_id > 0) {
144 $objectsrc = new Commande($db);
145 $objectsrc->fetch($object->origin_id);
146 }
147 $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
148 $head[$h][0] = DOL_URL_ROOT . "/expedition/contact.php?id=" . ((int) $object->id);
149 $head[$h][1] = $langs->trans("ContactsAddresses");
150 if ($nbContact > 0) {
151 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbContact . '</span>';
152 }
153 $head[$h][2] = 'contact';
154 $h++;
155 }
156
157 // Files
158 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
159 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
160 $upload_dir = $conf->expedition->dir_output . "/sending/" . dol_sanitizeFileName($object->ref);
161 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
162 $nbLinks = Link::count($db, $object->element, $object->id);
163 $head[$h][0] = DOL_URL_ROOT . '/expedition/document.php?id=' . $object->id;
164 $head[$h][1] = $langs->trans('Documents');
165 if (($nbFiles + $nbLinks) > 0) {
166 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
167 }
168 $head[$h][2] = 'documents';
169 $h++;
170
171 // Notes
172 $nbNote = 0;
173 if (!empty($object->note_private)) {
174 $nbNote++;
175 }
176 if (!empty($object->note_public)) {
177 $nbNote++;
178 }
179 $head[$h][0] = DOL_URL_ROOT . "/expedition/note.php?id=" . $object->id;
180 $head[$h][1] = $langs->trans("Notes");
181 if ($nbNote > 0) {
182 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
183 }
184 $head[$h][2] = 'note';
185 $h++;
186
187 // Events
188 $head[$h][0] = DOL_URL_ROOT . '/expedition/agenda.php?id=' . $object->id;
189 $head[$h][1] = $langs->trans("Events");
190 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
191 $nbEvent = 0;
192 // Enable caching of thirdparty count actioncomm
193 require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
194 $cachekey = 'count_events_expedition_' . $object->id;
195 $dataretrieved = dol_getcache($cachekey);
196 if (!is_null($dataretrieved)) {
197 $nbEvent = $dataretrieved;
198 } else {
199 $sql = "SELECT COUNT(id) as nb";
200 $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm";
201 $sql .= " WHERE fk_element = " . ((int) $object->id);
202 $sql .= " AND elementtype = 'shipping'";
203 $resql = $db->query($sql);
204 if ($resql) {
205 $obj = $db->fetch_object($resql);
206 $nbEvent = $obj->nb;
207 } else {
208 dol_syslog('Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
209 }
210 dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
211 }
212
213 $head[$h][1] .= '/';
214 $head[$h][1] .= $langs->trans("Agenda");
215 if ($nbEvent > 0) {
216 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbEvent . '</span>';
217 }
218 }
219 $head[$h][2] = 'agenda';
220 $h++;
221
222 // Show more tabs from modules
223 // Entries must be declared in modules descriptor with line
224 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
225 // $this->tabs = array('entity:-tabname); to remove a tab
226 complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery');
227
228 complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove');
229
230 return $head;
231}
232
233
241{
242 global $langs, $db, $conf, $user;
243
244 // Load translation files required by the page
245 $langs->loadLangs(array("sendings"));
246
247 $h = 0;
248 $head = array();
249
250 if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'lire')) {
251 $head[$h][0] = DOL_URL_ROOT . "/expedition/card.php?id=" . $object->origin_id;
252 $head[$h][1] = $langs->trans("SendingCard");
253 $head[$h][2] = 'shipping';
254 $h++;
255 }
256
257 $head[$h][0] = DOL_URL_ROOT . "/delivery/card.php?id=" . $object->id;
258 $head[$h][1] = $langs->trans("DeliveryCard");
259 $head[$h][2] = 'delivery';
260 $h++;
261
262 // Show more tabs from modules
263 // Entries must be declared in modules descriptor with line
264 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
265 // $this->tabs = array('entity:-tabname); to remove a tab
266 // complete_head_from_modules use $object->id for this link so we temporary change it
267
268 $savObjectId = $object->id;
269
270 // Get parent object
271 $tmpobject = null;
272 if ($object->origin_type) {
273 $tmpobject = new Expedition($db);
274 $tmpobject->fetch($object->origin_id);
275 } else {
276 $tmpobject = $object;
277 }
278
279 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
280 $objectsrc = $tmpobject;
281 if ($tmpobject->origin_type == 'commande' && $tmpobject->origin_id > 0) {
282 $objectsrc = new Commande($db);
283 $objectsrc->fetch($tmpobject->origin_id);
284 }
285 $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
286 $head[$h][0] = DOL_URL_ROOT . "/expedition/contact.php?id=" . $tmpobject->id;
287 $head[$h][1] = $langs->trans("ContactsAddresses");
288 if ($nbContact > 0) {
289 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbContact . '</span>';
290 }
291 $head[$h][2] = 'contact';
292 $h++;
293 }
294
295 // Files
296 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
297 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
298 $upload_dir = $conf->expedition->dir_output . "/sending/" . dol_sanitizeFileName($tmpobject->ref);
299 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
300 $nbLinks = Link::count($db, $tmpobject->element, $tmpobject->id);
301 $head[$h][0] = DOL_URL_ROOT . '/expedition/document.php?id=' . $tmpobject->id;
302 $head[$h][1] = $langs->trans('Documents');
303 if (($nbFiles + $nbLinks) > 0) {
304 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
305 }
306 $head[$h][2] = 'documents';
307 $h++;
308
309 // Notes
310 $nbNote = 0;
311 if (!empty($tmpobject->note_private)) {
312 $nbNote++;
313 }
314 if (!empty($tmpobject->note_public)) {
315 $nbNote++;
316 }
317 $head[$h][0] = DOL_URL_ROOT . "/expedition/note.php?id=" . $tmpobject->id;
318 $head[$h][1] = $langs->trans("Notes");
319 if ($nbNote > 0) {
320 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
321 }
322 $head[$h][2] = 'note';
323 $h++;
324
325 // Events
326 $head[$h][0] = DOL_URL_ROOT . '/expedition/agenda.php?id=' . $tmpobject->id;
327 $head[$h][1] = $langs->trans("Events");
328 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
329 $nbEvent = 0;
330 // Enable caching of thirdparty count actioncomm
331 require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
332 $cachekey = 'count_events_expedition_' . $tmpobject->id;
333 $dataretrieved = dol_getcache($cachekey);
334 if (!is_null($dataretrieved)) {
335 $nbEvent = $dataretrieved;
336 } else {
337 $sql = "SELECT COUNT(id) as nb";
338 $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm";
339 $sql .= " WHERE fk_element = " . ((int) $tmpobject->id);
340 $sql .= " AND elementtype = 'shipping'";
341 $resql = $db->query($sql);
342 if ($resql) {
343 $obj = $db->fetch_object($resql);
344 $nbEvent = $obj->nb;
345 } else {
346 dol_syslog('Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
347 }
348 dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
349 }
350
351 $head[$h][1] .= '/';
352 $head[$h][1] .= $langs->trans("Agenda");
353 if ($nbEvent > 0) {
354 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbEvent . '</span>';
355 }
356 }
357 $head[$h][2] = 'agenda';
358 $h++;
359
360
361 $object->id = $tmpobject->id;
362
363 complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery');
364
365 complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove');
366
367 $object->id = $savObjectId;
368 return $head;
369}
370
379function show_list_sending_receive($origin, $origin_id, $filter = '')
380{
381 global $db, $conf, $langs;
382 global $form;
383
384 $product_static = new Product($db);
385 $expedition = new Expedition($db);
386 $warehousestatic = new Entrepot($db);
387
388 $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end, obj.special_code,";
389 $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot as warehouse_id,";
390 $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, e.billed, e.fk_statut as status, e.signed_status,";
391 $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
392 $sql .= ' p.description as product_desc';
393 $sql .= " FROM " . MAIN_DB_PREFIX . "expeditiondet as ed,";
394 $sql .= " " . MAIN_DB_PREFIX . "expedition as e,";
395 $sql .= " " . MAIN_DB_PREFIX . $db->sanitize($origin) . "det as obj"; // for example llx_commandedet
396 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON obj.fk_product = p.rowid";
397 //TODO Add link to expeditiondet_batch
398 $sql .= " WHERE e.entity IN (" . getEntity('expedition') . ")";
399 $sql .= " AND obj.fk_" . $db->sanitize($origin) . " = " . ((int) $origin_id);
400 $sql .= " AND obj.rowid = ed.fk_elementdet";
401 if (isModEnabled('subtotals')) {
402 $sql .= " AND obj.special_code <> " . SUBTOTALS_SPECIAL_CODE;
403 }
404 $sql .= " AND ed.fk_expedition = e.rowid";
405 if ($filter) {
406 $sql .= $filter; // @phan-suppress-current-line SqlInjection
407 }
408 $sql .= " ORDER BY obj.rowid, obj.fk_product";
409
410 dol_syslog("show_list_sending_receive", LOG_DEBUG);
411 $resql = $db->query($sql);
412 if ($resql) {
413 $num = $db->num_rows($resql);
414 $i = 0;
415
416 if ($num) {
417 if ($filter) {
418 print load_fiche_titre($langs->trans("OtherSendingsForSameOrder"));
419 } else {
420 print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder"));
421 }
422
423 print '<div class="div-table-responsive-no-min">';
424 print '<table class="liste centpercent">';
425 print '<tr class="liste_titre">';
426 //print '<td class="left">'.$langs->trans("QtyOrdered").'</td>';
427 print '<td>' . $langs->trans("SendingSheet") . '</td>';
428 print '<td>' . $langs->trans("Description") . '</td>';
429 print '<td class="center">' . $langs->trans("DateCreation") . '</td>';
430 print '<td class="center">' . $langs->trans("DateDeliveryPlanned") . '</td>';
431 print '<td class="center">' . $langs->trans("QtyPreparedOrShipped") . '</td>';
432 if (isModEnabled('stock')) {
433 print '<td>' . $langs->trans("Warehouse") . '</td>';
434 }
435 /*TODO Add link to expeditiondet_batch
436 if (isModEnabled('productbatch'))
437 {
438 print '<td>';
439 print '</td>';
440 }*/
441 if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) {
442 print '<td>' . $langs->trans("DeliveryOrder") . '</td>';
443 //print '<td class="center">'.$langs->trans("QtyReceived").'</td>';
444 print '<td class="right">' . $langs->trans("DeliveryDate") . '</td>';
445 }
446 print "</tr>\n";
447
448 while ($i < $num) {
449 $objp = $db->fetch_object($resql);
450
451 $expedition->id = $objp->expedition_id;
452 $expedition->ref = $objp->exp_ref;
453 $expedition->billed = $objp->billed;
454 $expedition->statut = $objp->status;
455 $expedition->status = $objp->status;
456 $expedition->signed_status = $objp->signed_status;
457
458 print '<tr class="oddeven">';
459
460 // Sending id
461 print '<td class="tdoverflowmax125">';
462 print $expedition->getNomUrl(1);
463 //print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.'<a>';
464 print '</td>';
465
466 // Description
467 if ($objp->fk_product > 0) {
468 // Define output language
469 if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
470 $object = new $origin($db);
471 '@phan-var-force CommonObject $object';
472 $object->fetch($origin_id);
473 $object->fetch_thirdparty();
474
475 $prod = new Product($db);
476 $prod->id = $objp->fk_product;
477 $prod->getMultiLangs();
478
479 $outputlangs = $langs;
480 $newlang = '';
481 if (GETPOST('lang_id', 'aZ09')) {
482 $newlang = GETPOST('lang_id', 'aZ09');
483 }
484 if (empty($newlang)) {
485 $newlang = $object->thirdparty->default_lang;
486 }
487 if (!empty($newlang)) {
488 $outputlangs = new Translate("", $conf);
489 $outputlangs->setDefaultLang($newlang);
490 }
491
492 $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
493 } else {
494 $label = (!empty($objp->label) ? $objp->label : $objp->product_label);
495 }
496
497 print '<td>';
498
499 // Show product and description
500 $product_static->type = $objp->fk_product_type;
501 $product_static->id = $objp->fk_product;
502 $product_static->ref = $objp->ref;
503 $product_static->status_batch = $objp->product_tobatch;
504
505 $text = $product_static->getNomUrl(1);
506 $text .= ' - ' . $label;
507 $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description));
508 print $form->textwithtooltip($text, $description, 3, 0, '', (string) $i);
509
510 // Show range
511 print_date_range($objp->date_start, $objp->date_end);
512
513 // Add description in form
514 if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
515 print(!empty($objp->description) ? ((empty($objp->product) || $objp->description != $objp->product) ? '<br>' . dol_htmlentitiesbr($objp->description) : '') : '');
516 }
517
518 print '</td>';
519 } else {
520 print "<td>";
521 if ($objp->fk_product_type == 1) {
522 $text = img_object($langs->trans('Service'), 'service');
523 } else {
524 $text = img_object($langs->trans('Product'), 'product');
525 }
526
527 if (!empty($objp->label)) {
528 $text .= ' <strong>' . $objp->label . '</strong>';
529 print $form->textwithtooltip($text, $objp->description, 3, 0, '', (string) $i);
530 } else {
531 print $text . ' ' . nl2br($objp->description);
532 }
533
534 // Show range
535 print_date_range($objp->date_start, $objp->date_end);
536 print "</td>\n";
537 }
538
539 //print '<td class="center">'.$objp->qty_asked.'</td>';
540
541 // Date creation
542 print '<td class="nowrap center">' . dol_print_date($db->jdate($objp->date_creation), 'day') . '</td>';
543
544 // Date shipping creation
545 print '<td class="nowrap center">' . dol_print_date($db->jdate($objp->date_delivery), 'day') . '</td>';
546
547 // Qty shipped
548 print '<td class="center">' . $objp->qty_shipped . '</td>';
549
550 // Warehouse
551 if (isModEnabled('stock')) {
552 print '<td class="tdoverflowmax125">';
553 if ($objp->warehouse_id > 0) {
554 $warehousestatic->fetch($objp->warehouse_id);
555 print $warehousestatic->getNomUrl(1);
556 }
557 print '</td>';
558 }
559
560 // Batch number management
561 /*TODO Add link to expeditiondet_batch
562 if (isModEnabled('productbatch'))
563 {
564 //var_dump($objp->edrowid);
565 $lines[$i]->detail_batch
566 if (isset($lines[$i]->detail_batch))
567 {
568 print '<td>';
569 if ($lines[$i]->product_tobatch)
570 {
571 $detail = '';
572 foreach ($lines[$i]->detail_batch as $dbatch)
573 {
574 $detail.= $langs->trans("Batch").': '.$dbatch->batch;
575 $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
576 $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
577 $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
578 $detail.= '<br>';
579 }
580 print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
581 }
582 else
583 {
584 print $langs->trans("NA");
585 }
586 print '</td>';
587 } else {
588 print '<td></td>';
589 }
590 }*/
591
592 // Information on receipt
593 if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) {
594 include_once DOL_DOCUMENT_ROOT . '/delivery/class/delivery.class.php';
595 $expedition->fetchObjectLinked($expedition->id, $expedition->element, null, 'delivery');
596 //var_dump($expedition->linkedObjects);
597
598 $receiving = '';
599 if (!empty($expedition->linkedObjects['delivery'])) {
600 $receiving = reset($expedition->linkedObjects['delivery']); // Take first link
601 }
602
603 if (!empty($receiving)) {
605 '@phan-var-force Delivery $receiving';
606 // $expedition->fk_elementdet = id of det line of order
607 // $receiving->fk_origin_line = id of det line of order
608 // $receiving->origin may be 'shipping'
609 // $receiving->origin_id may be id of shipping
610
611 // Ref
612 print '<td>';
613 print $receiving->getNomUrl(1);
614 //print '<a href="'.DOL_URL_ROOT.'/delivery/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
615 print '</td>';
616 // Qty received
617 //print '<td class="center">';
618 // TODO No solution for the moment to link a line det of receipt with a line det of shipping,
619 // so no way to know the qty received for this line of shipping.
620 //print $langs->trans("FeatureNotYetAvailable");
621 //print '</td>';
622 // Date shipping real
623 print '<td class="right">';
624 print dol_print_date($receiving->date_delivery, 'day');
625 print '</td>';
626 } else {
627 //print '<td>&nbsp;</td>';
628 print '<td>&nbsp;</td>';
629 print '<td>&nbsp;</td>';
630 }
631 }
632 print '</tr>';
633 $i++;
634 }
635
636 print '</table>';
637 print '</div>';
638 }
639 $db->free($resql);
640 } else {
641 dol_print_error($db);
642 }
643
644 return 1;
645}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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 customers orders.
Class to manage warehouses.
const STATUS_DRAFT
Draft status.
Class to manage products or services.
Class to manage translations.
global $mysoc
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:66
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
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).
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
shippingSetStandaloneLineSellPrice($line, $buyer)
Complete a line of a standalone shipment (SHIPMENT_STANDALONE, no source order) before it is copied i...
delivery_prepare_head($object)
Prepare array with list of tabs.
shipping_prepare_head($object)
Prepare array with list of tabs.
shippingGetStandaloneDispatchSourceLine($object, $sourceLineId, $lineId, $productId)
Resolve a standalone dispatch group from the loaded shipment lines.