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