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