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