dolibarr 22.0.5
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
5 * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
7 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8 * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
9 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/modules/delivery/modules_delivery.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
40if (isModEnabled("product") || isModEnabled("service")) {
41 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42}
43if (isModEnabled('shipping')) {
44 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
45}
46if (isModEnabled('stock')) {
47 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
48}
49if (isModEnabled('project')) {
50 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
52}
53
62// Load translation files required by the page
63$langs->loadLangs(array('bills', 'deliveries', 'orders', 'sendings'));
64
65if (isModEnabled('incoterm')) {
66 $langs->load('incoterm');
67}
68
69$action = GETPOST('action', 'aZ09');
70$confirm = GETPOST('confirm', 'alpha');
71$backtopage = GETPOST('backtopage', 'alpha');
72$id = GETPOSTINT('id');
73
74
75// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
76$hookmanager->initHooks(array('deliverycard', 'globalcard'));
77
78$object = new Delivery($db);
79$extrafields = new ExtraFields($db);
80
81// fetch optionals attributes and labels
82$extrafields->fetch_name_optionals_label($object->table_element);
83
84// fetch optionals attributes lines and labels
85$extrafields->fetch_name_optionals_label($object->table_element_line);
86
87// Load object. Make an object->fetch
88include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'
89
90$error = 0;
91
92// Security check
93if ($user->socid) {
94 $socid = $user->socid;
95}
96$result = restrictedArea($user, 'expedition', $id, 'delivery', 'delivery');
97
98$permissiontoread = $user->hasRight('expedition', 'delivery', 'read');
99$permissiontoadd = $user->hasRight('expedition', 'delivery', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
100$permissiontodelete = $user->hasRight('expedition', 'delivery', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
101$permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate')));
102$permissionnote = $user->hasRight('expedition', 'delivery', 'creer'); // Used by the include of actions_setnotes.inc.php
103$permissiondellink = $user->hasRight('expedition', 'delivery', 'creer'); // Used by the include of actions_dellink.inc.php
104$permissiontoeditextra = $permissiontoadd;
105if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
106 // For action 'update_extras', is there a specific permission set for the attribute to update
107 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
108}
109$permissiontoeditextraline = $permissiontoadd;
110if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element_line]['perms'][GETPOST('attribute', 'aZ09')])) {
111 // For action 'update_extras', is there a specific permission set for the attribute to update
112 $permissiontoeditextraline = dol_eval((string) $extrafields->attributes[$object->table_element_line]['perms'][GETPOST('attribute', 'aZ09')]);
113}
114
115
116/*
117 * Actions
118 */
119
120$parameters = array();
121$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
122// Delete Link
123$permissiondellink = $user->hasRight('expedition', 'delivery', 'supprimer'); // Used by the include of actions_dellink.inc.php
124include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once'
125
126if ($action == 'add' && $permissiontoadd) {
127 $array_options = array();
128 $db->begin();
129
130 $object->date_delivery = dol_now();
131 $object->note = GETPOST("note", 'restricthtml');
132 $object->note_private = GETPOST("note", 'restricthtml');
133 $object->commande_id = GETPOSTINT("commande_id");
134 $object->fk_incoterms = GETPOSTINT('incoterm_id');
135
136 /* ->entrepot_id seems to not exists
137 if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) {
138 $object->entrepot_id = GETPOST('entrepot_id', 'int');
139 }*/
140
141 // We loop on each line of order to complete object delivery with qty to delivery
142 $commande = new Commande($db);
143 $commande->fetch($object->commande_id);
144 $commande->fetch_lines();
145 $num = count($commande->lines);
146 for ($i = 0; $i < $num; $i++) {
147 $qty = "qtyl".$i;
148 $idl = "idl".$i;
149 $qtytouse = price2num(GETPOSTFLOAT($qty));
150 if ($qtytouse > 0) {
151 $object->addline(GETPOSTINT($idl), (float) price2num($qtytouse), $array_options);
152 }
153 }
154
155 $ret = $object->create($user);
156 if ($ret > 0) {
157 $db->commit();
158 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
159 exit;
160 } else {
161 setEventMessages($object->error, $object->errors, 'errors');
162 $db->rollback();
163
164 $action = 'create';
165 }
166} elseif ($action == 'confirm_valid' && $confirm == 'yes' && $permissiontovalidate) {
167 $result = $object->valid($user);
168
169 // Define output language
170 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
171 $outputlangs = $langs;
172 $newlang = '';
173 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
174 $newlang = GETPOST('lang_id', 'aZ09');
175 }
176 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
177 $newlang = $object->thirdparty->default_lang;
178 }
179 if (!empty($newlang)) {
180 $outputlangs = new Translate("", $conf);
181 $outputlangs->setDefaultLang($newlang);
182 }
183 $model = $object->model_pdf;
184 $ret = $object->fetch($id); // Reload to get new record
185
186 // Phan does not use suggested tyhpe for $hide*, ignore: @phan-suppress-next-line PhanTypeMismatchArgument
187 $result = $object->generateDocument($model, $outputlangs, 0, 0, 0);
188 if ($result < 0) {
189 dol_print_error($db, $object->error, $object->errors);
190 }
191 }
192}
193
194if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) {
195 $db->begin();
196 $result = $object->delete($user);
197
198 if ($result > 0) {
199 $db->commit();
200 if (!empty($backtopage)) {
201 header("Location: ".$backtopage);
202 } else {
203 header("Location: ".DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1');
204 }
205 exit;
206 } else {
207 $db->rollback();
208 }
209}
210
211if ($action == 'setdate_delivery' && $permissiontoadd) {
212 $datedelivery = dol_mktime(GETPOSTINT('liv_hour'), GETPOSTINT('liv_min'), 0, GETPOSTINT('liv_month'), GETPOSTINT('liv_day'), GETPOSTINT('liv_year'));
213 $result = $object->setDeliveryDate($user, $datedelivery);
214 if ($result < 0) {
215 $mesg = '<div class="error">'.$object->error.'</div>';
216 }
217} elseif ($action == 'set_incoterms' && isModEnabled('incoterm') && $permissiontoadd) {
218 // Set incoterm
219 $result = $object->setIncoterms(GETPOSTINT('incoterm_id'), GETPOST('location_incoterms'));
220}
221
222// Update extrafields
223if ($action == 'update_extras' && $permissiontoeditextra) {
224 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
225
226 $attribute_name = GETPOST('attribute', 'aZ09');
227
228 // Fill array 'array_options' with data from update form
229 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
230 if ($ret < 0) {
231 $error++;
232 }
233
234 if (!$error) {
235 $result = $object->updateExtraField($attribute_name, 'DELIVERY_MODIFY');
236 if ($result < 0) {
237 setEventMessages($object->error, $object->errors, 'errors');
238 $error++;
239 }
240 }
241
242 if ($error) {
243 $action = 'edit_extras';
244 }
245}
246
247// Extrafields line
248if ($action == 'update_extras_line' && $permissiontoeditextraline) {
249 $array_options = array();
250 $num = count($object->lines);
251
252 for ($i = 0; $i < $num; $i++) {
253 // Extrafields
254 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
255 $array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, (string) $i);
256 // Unset extrafield
257 if (is_array($extralabelsline)) {
258 // Get extra fields
259 foreach ($extralabelsline as $key => $value) {
260 unset($_POST["options_".$key]);
261 }
262 }
263
264 $ret = $object->update_line($object->lines[$i]->id, $array_options[$i]); // extrafields update
265 if ($ret < 0) {
266 $mesg = '<div class="error">'.$object->error.'</div>';
267 $error++;
268 }
269 }
270}
271
272
273// Actions to build doc
274$upload_dir = $conf->expedition->dir_output.'/receipt';
275include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
276// Provided by include of ...builddoc...:
277'
278@phan-var-force int<0,1> $hidedetails
279@phan-var-force int<0,1> $hidedesc
280@phan-var-force int<0,1> $hideref
281';
282
283include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
284
285
286/*
287 * View
288 */
289
290$title = $langs->trans('Delivery');
291
292llxHeader('', $title, 'Livraison', '', 0, 0, '', '', '', 'mod-delivery page-card');
293
294$form = new Form($db);
295$formfile = new FormFile($db);
296
297if ($action == 'create') {
298 // Create. Seems to no be used
299} else {
300 // View
301 if ($object->id > 0) {
302 // Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment).
303 // However, origin of shipment in future may differs (commande, proposal, ...)
304 $expedition = new Expedition($db);
305 $result = $expedition->fetch($object->origin_id);
306
307 $typeobject = $expedition->origin; // example: commande
308 if ($object->origin_id > 0) {
309 $object->fetch_origin();
310 }
311
312 if ($object->id > 0) {
313 $soc = new Societe($db);
314 $soc->fetch($object->socid);
315
317
318 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
319 print '<input type="hidden" name="token" value="'.newToken().'">';
320 print '<input type="hidden" name="action" value="update_extras_line">';
321 print '<input type="hidden" name="origin" value="'.$object->origin.'">';
322 print '<input type="hidden" name="id" value="'.$object->id.'">';
323 print '<input type="hidden" name="ref" value="'.$object->ref.'">';
324
325 print dol_get_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'dolly');
326
327 /*
328 * Confirmation de la suppression
329 *
330 */
331 if ($action == 'delete') {
332 $expedition_id = GETPOST("expid");
333 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&expid='.$expedition_id.'&backtopage='.urlencode($backtopage), $langs->trans("DeleteDeliveryReceipt"), $langs->trans("DeleteDeliveryReceiptConfirm", $object->ref), 'confirm_delete', '', '', 1);
334 }
335
336 /*
337 * Confirmation de la validation
338 */
339 if ($action == 'valid') {
340 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidateDeliveryReceipt"), $langs->trans("ValidateDeliveryReceiptConfirm", $object->ref), 'confirm_valid', '', '', 1);
341 }
342
343
344 /*
345 * Delivery
346 */
347
348 if ($typeobject == 'commande' && $expedition->origin_id > 0 && isModEnabled('order')) {
349 $objectsrc = new Commande($db);
350 $objectsrc->fetch($expedition->origin_id);
351 }
352 if ($typeobject == 'propal' && $expedition->origin_id > 0 && isModEnabled("propal")) {
353 $objectsrc = new Propal($db);
354 $objectsrc->fetch($expedition->origin_id);
355 }
356
357 // Shipment card
358 $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
359
360 $morehtmlref = '<div class="refidno">';
361 // Ref customer shipment
362 $morehtmlref .= $form->editfieldkey("RefCustomer", '', $expedition->ref_customer, $expedition, $user->hasRight('expedition', 'creer'), 'string', '', 0, 1);
363 $morehtmlref .= $form->editfieldval("RefCustomer", '', $expedition->ref_customer, $expedition, $user->hasRight('expedition', 'creer'), 'string'.(getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1);
364 $morehtmlref .= '<br>'.$langs->trans("RefDeliveryReceipt").' : '.$object->ref;
365 // Thirdparty
366 $morehtmlref .= '<br>'.$expedition->thirdparty->getNomUrl(1);
367 // Project
368 if (isModEnabled('project')) {
369 $langs->load("projects");
370 $morehtmlref .= '<br>';
371 if (0) { // Do not change on shipment
372 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
373 if ($action != 'classify') {
374 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
375 }
376 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, (string) $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
377 } else {
378 if (!empty($objectsrc->fk_project)) {
379 $proj = new Project($db);
380 $proj->fetch($objectsrc->fk_project);
381 $morehtmlref .= $proj->getNomUrl(1);
382 if ($proj->title) {
383 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
384 }
385 }
386 }
387 }
388 $morehtmlref .= '</div>';
389
390 $morehtmlstatus = $langs->trans("StatusReceipt").' : '.$object->getLibStatut(6).'<br><br class="small">';
391
392 dol_banner_tab($expedition, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
393
394
395 print '<div class="fichecenter">';
396 print '<div class="underbanner clearboth"></div>';
397
398 print '<table class="border tableforfield" width="100%">';
399
400 // Shipment
401 /*
402 if (($object->origin == 'shipment' || $object->origin == 'expedition') && $object->origin_id > 0)
403 {
404 $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
405
406 // Ref
407 print '<tr><td width="20%">'.$langs->trans("RefSending").'</td>';
408 print '<td colspan="3">';
409 // Nav is hidden because on a delivery receipt of a shipment, if we go on next shipment, we may find no tab (a shipment may not have delivery receipt yet)
410 //print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref');
411 print $form->showrefnav($expedition, 'refshipment', $linkback, 0, 'ref', 'ref');
412 print '</td></tr>';
413 }
414
415 // Ref
416 print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
417 print '<td colspan="3">';
418 print $object->ref;
419 print '</td></tr>';
420
421 // Client
422 print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
423 print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
424 print "</tr>";
425 */
426
427 // Document origine
428 if ($typeobject == 'commande' && $expedition->origin_id && isModEnabled('order')) {
429 print '<tr><td class="titlefield">'.$langs->trans("RefOrder").'</td>';
430 $order = new Commande($db);
431 $order->fetch($expedition->origin_id);
432 print '<td colspan="3">';
433 print $order->getNomUrl(1, 'commande');
434 print "</td>\n";
435 print '</tr>';
436 }
437 if ($typeobject == 'propal' && $expedition->origin_id && isModEnabled("propal")) {
438 $propal = new Propal($db);
439 $propal->fetch($expedition->origin_id);
440 print '<tr><td class="titlefield">'.$langs->trans("RefProposal").'</td>';
441 print '<td colspan="3">';
442 print $propal->getNomUrl(1, 'expedition');
443 print "</td>\n";
444 print '</tr>';
445 }
446
447 // Date
448 print '<tr><td class="titlefield">'.$langs->trans("DateCreation").'</td>';
449 print '<td colspan="3">'.dol_print_date($object->date_creation, 'dayhour')."</td>\n";
450 print '</tr>';
451
452 // Date delivery real / Received
453 print '<tr><td height="10">';
454 print '<table class="nobordernopadding" width="100%"><tr><td>';
455 print $langs->trans('DateReceived');
456 print '</td>';
457
458 if ($action != 'editdate_delivery') {
459 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_delivery&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>';
460 }
461 print '</tr></table>';
462 print '</td><td colspan="2">';
463 if ($action == 'editdate_delivery') {
464 print '<form name="setdate_delivery" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
465 print '<input type="hidden" name="token" value="'.newToken().'">';
466 print '<input type="hidden" name="action" value="setdate_delivery">';
467 print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, 0, "setdate_delivery", 1, 1);
468 print '<input type="submit" class="button smallpaddingimp button-edit" value="'.$langs->trans('Modify').'">';
469 print '</form>';
470 } else {
471 print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : '&nbsp;';
472 }
473 print '</td>';
474 print '</tr>';
475
476 // Incoterms
477 if (isModEnabled('incoterm')) {
478 print '<tr><td>';
479 print '<table class="centpercent nobordernopadding"><tr><td>';
480 print $langs->trans('IncotermLabel');
481 print '<td><td class="right">';
482 if ($user->hasRight('expedition', 'delivery', 'creer')) {
483 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/delivery/card.php?id='.$object->id.'&action=editincoterm&token='.newToken().'">'.img_edit().'</a>';
484 } else {
485 print '&nbsp;';
486 }
487 print '</td></tr></table>';
488 print '</td>';
489 print '<td colspan="3">';
490 if ($action != 'editincoterm') {
491 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
492 } else {
493 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id);
494 }
495 print '</td></tr>';
496 }
497
498 /* A delivery note should be just more properties of a shipment, so notes are on shipment
499 // Note Public
500 print '<tr><td>'.$langs->trans("NotePublic").'</td>';
501 print '<td colspan="3">';
502 print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_public));
503 print "</td></tr>";
504
505 // Note Private
506 print '<tr><td>'.$langs->trans("NotePrivate").'</td>';
507 print '<td colspan="3">';
508 print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private));
509 print "</td></tr>";
510 */
511
512 // Statut
513 /*print '<tr><td>'.$langs->trans("Status").'</td>';
514 print '<td colspan="3">'.$object->getLibStatut(4)."</td>\n";
515 print '</tr>';*/
516
517
518 if (!getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && isModEnabled('stock')) {
519 // Entrepot
520 $entrepot = new Entrepot($db);
521 $entrepot->fetch($expedition->entrepot_id);
522 print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
523 print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/product/stock/card.php?id='.$entrepot->id.'">'.$entrepot->label.'</a></td>';
524 print '</tr>';
525 }
526
527 // Other attributes
528 if ($action == 'create_delivery') {
529 // copy from expedition
530 $extrafields->fetch_name_optionals_label($expedition->table_element);
531 if ($expedition->fetch_optionals() > 0) {
532 $object->array_options = array_merge($object->array_options, $expedition->array_options);
533 }
534 }
535 $cols = 2;
536 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
537
538 print "</table><br>\n";
539
540 print '</div>';
541
542 /*
543 * Products lines
544 */
545
546 $num_prod = count($object->lines);
547 $i = 0;
548 $total = 0;
549
550 print '<table class="noborder centpercent">';
551
552 if ($num_prod) {
553 $i = 0;
554
555 print '<tr class="liste_titre">';
556 print '<td>'.$langs->trans("Products").'</td>';
557 print '<td class="center">'.$langs->trans("QtyOrdered").'</td>';
558 print '<td class="center">'.$langs->trans("QtyReceived").'</td>';
559 print "</tr>\n";
560 }
561 while ($i < $num_prod) {
562 $parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod);
563 $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
564 if ($reshook < 0) {
565 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
566 }
567
568 if (empty($reshook)) {
569 print '<tr class="oddeven">';
570 if ($object->lines[$i]->fk_product > 0) {
571 $product = new Product($db);
572 $product->fetch($object->lines[$i]->fk_product);
573
574 // Define output language
575 if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
576 $outputlangs = $langs;
577 $newlang = '';
578 if (/* empty($newlang) && */ GETPOST('lang_id', 'aZ09')) {
579 $newlang = GETPOST('lang_id', 'aZ09');
580 }
581 if (empty($newlang)) {
582 $newlang = $object->thirdparty->default_lang;
583 }
584 if (!empty($newlang)) {
585 $outputlangs = new Translate("", $conf);
586 $outputlangs->setDefaultLang($newlang);
587 }
588
589 $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
590 } else {
591 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
592 }
593
594 print '<td>';
595
596 // Affiche ligne produit
597 $text = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$object->lines[$i]->fk_product.'">';
598 if ($object->lines[$i]->fk_product_type == 1) {
599 $text .= img_object($langs->trans('ShowService'), 'service');
600 } else {
601 $text .= img_object($langs->trans('ShowProduct'), 'product');
602 }
603 $text .= ' '.$object->lines[$i]->product_ref.'</a>';
604 $text .= ' - '.$label;
605 $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($object->lines[$i]->description));
606 //print $description;
607 print $form->textwithtooltip($text, $description, 3, 0, '', (string) $i);
608 //print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
609 if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
610 print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '<br>'.dol_htmlentitiesbr($object->lines[$i]->description) : '';
611 }
612 } else {
613 print "<td>";
614 if ($object->lines[$i]->fk_product_type == 1) {
615 $text = img_object($langs->trans('Service'), 'service');
616 } else {
617 $text = img_object($langs->trans('Product'), 'product');
618 }
619
620 if (!empty($object->lines[$i]->label)) {
621 $text .= ' <strong>'.$object->lines[$i]->label.'</strong>';
622 print $form->textwithtooltip($text, $object->lines[$i]->description, 3, 0, '', (string) $i);
623 } else {
624 print $text.' '.nl2br($object->lines[$i]->description);
625 }
626
627 //print_date_range($objp->date_start, $objp->date_end);
628 print "</td>\n";
629 }
630
631 print '<td class="center">'.$object->lines[$i]->qty_asked.'</td>';
632 print '<td class="center">'.$object->lines[$i]->qty_shipped.'</td>';
633
634 print "</tr>";
635
636 // Display lines extrafields
637 //if (!empty($extrafields)) {
638 $colspan = 2;
639 $mode = ($object->statut == 0) ? 'edit' : 'view';
640
641 $object->lines[$i]->fetch_optionals();
642
643 if ($action == 'create_delivery') {
644 $srcLine = new ExpeditionLigne($db);
645
646 $extrafields->fetch_name_optionals_label($srcLine->table_element);
647 $srcLine->id = $expedition->lines[$i]->id;
648 $srcLine->fetch_optionals();
649
650 $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options);
651 } else {
652 $srcLine = new DeliveryLine($db);
653 $extrafields->fetch_name_optionals_label($srcLine->table_element);
654 }
655 print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), '');
656 //}
657 }
658
659 $i++;
660 }
661
662 print "</table>\n";
663
664 print dol_get_fiche_end();
665
666 //if ($object->statut == 0) // only if draft
667 // print $form->buttonsSaveCancel("Save", '');
668
669 print '</form>';
670
671
672 /*
673 * Boutons actions
674 */
675
676 if ($user->socid == 0) {
677 print '<div class="tabsAction">';
678
679 if ($object->statut == 0 && $num_prod > 0) {
680 if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery', 'creer'))
681 || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'delivery_advance', 'validate'))) {
682 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=valid&amp;token='.newToken().'&amp;id='.$object->id, '');
683 }
684 }
685
686 if ($user->hasRight('expedition', 'delivery', 'supprimer')) {
687 if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) {
688 print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;expid='.$object->origin_id.'&amp;action=delete&amp;token='.newToken().'&amp;backtopage='.urlencode(DOL_URL_ROOT.'/expedition/card.php?id='.$object->origin_id), '');
689 } else {
690 print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&amp;token='.newToken().'&amp;id='.$object->id, '');
691 }
692 }
693
694 print '</div>';
695 }
696 print "\n";
697
698 print '<div class="fichecenter"><div class="fichehalfleft">';
699
700 /*
701 * Documents generated
702 */
703
704 $objectref = dol_sanitizeFileName($object->ref);
705 $filedir = $conf->expedition->dir_output."/receipt/".$objectref;
706 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
707
708 $genallowed = $user->hasRight('expedition', 'delivery', 'lire');
709 $delallowed = $user->hasRight('expedition', 'delivery', 'creer');
710
711 print $formfile->showdocuments('delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
712
713 /*
714 * Linked object block (of linked shipment)
715 */
716 if ($object->origin == 'expedition') {
717 $shipment = new Expedition($db);
718 $shipment->fetch($object->origin_id);
719
720 // Show links to link elements
721 //$tmparray = $form->showLinkToObjectBlock($object, null, array('order'), 1);
722 $somethingshown = $form->showLinkedObjectBlock($object, '');
723 }
724
725
726 print '</div><div class="fichehalfright">';
727
728 // Nothing on right
729
730 print '</div></div>';
731 } else {
732 /* Expedition non trouvee */
733 print "Expedition inexistante ou access refuse";
734 }
735 } else {
736 /* Expedition non trouvee */
737 print "Expedition inexistante ou access refuse";
738 }
739}
740
741// End of page
742llxFooter();
743$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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 customers orders.
Class to manage receptions.
Management class of delivery note lines.
Class to manage warehouses.
Class to manage lines of shipment.
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
delivery_prepare_head($object)
Prepare array with list of tabs.