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