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