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