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