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