PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/livraison/fiche.php

https://bitbucket.org/speedealing/speedealing
PHP | 729 lines | 508 code | 117 blank | 104 comment | 124 complexity | 77d3c74832d03bb4f83b0abcc4a5314b MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/livraison/fiche.php
  23. * \ingroup livraison
  24. * \brief Fiche descriptive d'un bon de livraison=reception
  25. */
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
  31. if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
  32. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  33. if (! empty($conf->expedition_bon->enabled))
  34. require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
  35. if (! empty($conf->stock->enabled))
  36. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
  37. $langs->load("sendings");
  38. $langs->load("bills");
  39. $langs->load('deliveries');
  40. $action=GETPOST('action', 'alpha');
  41. $confirm=GETPOST('confirm', 'alpha');
  42. // Security check
  43. $id = GETPOST('id', 'int');
  44. if ($user->societe_id) $socid=$user->societe_id;
  45. $result=restrictedArea($user,'expedition',$id,'livraison','livraison');
  46. /*
  47. * Actions
  48. */
  49. if ($action == 'add')
  50. {
  51. $db->begin();
  52. // Creation de l'objet livraison
  53. $delivery = new Livraison($db);
  54. $delivery->date_livraison = time();
  55. $delivery->note = $_POST["note"];
  56. $delivery->commande_id = $_POST["commande_id"];
  57. if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
  58. {
  59. $expedition->entrepot_id = $_POST["entrepot_id"];
  60. }
  61. // On boucle sur chaque ligne de commande pour completer objet livraison
  62. // avec qte a livrer
  63. $commande = new Commande($db);
  64. $commande->fetch($delivery->commande_id);
  65. $commande->fetch_lines();
  66. $num=count($commande->lines);
  67. for ($i = 0; $i < $num; $i++)
  68. {
  69. $qty = "qtyl".$i;
  70. $idl = "idl".$i;
  71. if ($_POST[$qty] > 0)
  72. {
  73. $delivery->addline($_POST[$idl],$_POST[$qty]);
  74. }
  75. }
  76. $ret=$delivery->create($user);
  77. if ($ret > 0)
  78. {
  79. $db->commit();
  80. header("Location: ".$_SERVER['PHP_SELF']."?id=".$delivery->id);
  81. exit;
  82. }
  83. else
  84. {
  85. setEventMessage($delivery->error, 'errors');
  86. $db->rollback();
  87. $_GET["commande_id"]=$_POST["commande_id"];
  88. $action='create';
  89. }
  90. }
  91. else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->livraison->valider)
  92. {
  93. $object = new Livraison($db);
  94. $object->fetch($id);
  95. $object->fetch_thirdparty();
  96. $result = $object->valid($user);
  97. // Define output language
  98. $outputlangs = $langs;
  99. $newlang='';
  100. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  101. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
  102. if (! empty($newlang))
  103. {
  104. $outputlangs = new Translate();
  105. $outputlangs->setDefaultLang($newlang);
  106. }
  107. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
  108. {
  109. $ret=$object->fetch($id); // Reload to get new records
  110. $result=delivery_order_pdf_create($db, $object,$_REQUEST['model'],$outputlangs);
  111. }
  112. if ($result < 0)
  113. {
  114. dol_print_error($db,$result);
  115. exit;
  116. }
  117. }
  118. if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->livraison->supprimer)
  119. {
  120. $object = new Livraison($db);
  121. $object->fetch($id);
  122. $object->fetch_thirdparty();
  123. $db->begin();
  124. $result=$object->delete();
  125. if ($result > 0)
  126. {
  127. $db->commit();
  128. header("Location: ".DOL_URL_ROOT.'/expedition/index.php');
  129. exit;
  130. }
  131. else
  132. {
  133. $db->rollback();
  134. }
  135. }
  136. /*
  137. * Build document
  138. */
  139. if ($action == 'builddoc') // En get ou en post
  140. {
  141. $object = new Livraison($db);
  142. $object->fetch($id);
  143. $object->fetch_thirdparty();
  144. if ($_REQUEST['model'])
  145. {
  146. $object->setDocModel($user, $_REQUEST['model']);
  147. }
  148. // Define output language
  149. $outputlangs = $langs;
  150. $newlang='';
  151. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  152. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
  153. if (! empty($newlang))
  154. {
  155. $outputlangs = new Translate();
  156. $outputlangs->setDefaultLang($newlang);
  157. }
  158. if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
  159. {
  160. $ret=$object->fetch($id); // Reload to get new records
  161. $result=delivery_order_pdf_create($db, $object, $object->modelpdf, $outputlangs);
  162. }
  163. if ($result < 0)
  164. {
  165. dol_print_error($db,$result);
  166. exit;
  167. }
  168. }
  169. // Delete file in doc form
  170. elseif ($action == 'remove_file')
  171. {
  172. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  173. $object = new Livraison($db);
  174. if ($object->fetch($id))
  175. {
  176. $object->fetch_thirdparty();
  177. $upload_dir = $conf->expedition->dir_output . "/receipt";
  178. $file = $upload_dir . '/' . GETPOST('file');
  179. $ret=dol_delete_file($file,0,0,0,$object);
  180. if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
  181. else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
  182. }
  183. }
  184. /*
  185. * View
  186. */
  187. llxHeader('',$langs->trans('Delivery'),'Livraison');
  188. $form = new Form($db);
  189. $formfile = new FormFile($db);
  190. /*********************************************************************
  191. *
  192. * Mode creation
  193. *
  194. *********************************************************************/
  195. if ($action == 'create')
  196. {
  197. print_fiche_titre($langs->trans("CreateADeliveryOrder"));
  198. if ($mesg)
  199. {
  200. print $mesg.'<br>';
  201. }
  202. $commande = new Commande($db);
  203. $commande->livraison_array();
  204. if ($commande->fetch($_GET["commande_id"]))
  205. {
  206. $soc = new Societe($db);
  207. $soc->fetch($commande->socid);
  208. $author = new User($db);
  209. $author->fetch($commande->user_author_id);
  210. if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
  211. {
  212. $entrepot = new Entrepot($db);
  213. }
  214. /*
  215. * Commande
  216. */
  217. print '<form action="fiche.php" method="post">';
  218. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  219. print '<input type="hidden" name="action" value="add">';
  220. print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
  221. if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
  222. {
  223. print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
  224. }
  225. print '<table class="border" width="100%">';
  226. print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
  227. print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
  228. print '<td width="50%" colspan="2">';
  229. print "</td></tr>";
  230. print "<tr><td>".$langs->trans("Date")."</td>";
  231. print "<td>".dol_print_date($commande->date,'dayhourtext')."</td>\n";
  232. print '<td>'.$langs->trans("Order").'</td><td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a>';
  233. print "</td></tr>\n";
  234. print '<tr>';
  235. if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
  236. {
  237. print '<td>'.$langs->trans("Warehouse").'</td>';
  238. print '<td>';
  239. $ents = $entrepot->list_array();
  240. print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
  241. print '</td>';
  242. }
  243. print "<td>".$langs->trans("Author")."</td><td>".$author->getFullName($langs)."</td>\n";
  244. if ($commande->note)
  245. {
  246. print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
  247. }
  248. print "</table>";
  249. /*
  250. * Lignes de commandes
  251. *
  252. */
  253. print '<br><table class="noborder" width="100%">';
  254. $lines = $commande->fetch_lines(1);
  255. // Lecture des livraisons deja effectuees
  256. $commande->livraison_array();
  257. $num = count($commande->lines);
  258. $i = 0;
  259. if ($num)
  260. {
  261. print '<tr class="liste_titre">';
  262. print '<td width="54%">'.$langs->trans("Description").'</td>';
  263. print '<td align="center">Quan. commandee</td>';
  264. print '<td align="center">Quan. livree</td>';
  265. print '<td align="center">Quan. a livrer</td>';
  266. if (! empty($conf->stock->enabled))
  267. {
  268. print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
  269. }
  270. print "</tr>\n";
  271. }
  272. $var=true;
  273. while ($i < $num)
  274. {
  275. $product = new Product($db);
  276. $line = $commande->lines[$i];
  277. $var=!$var;
  278. print "<tr $bc[$var]>\n";
  279. if ($line->fk_product > 0)
  280. {
  281. $product->fetch($line->fk_product);
  282. $product->load_stock();
  283. // Define output language
  284. if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
  285. {
  286. $commande->fetch_thirdparty();
  287. $outputlangs = $langs;
  288. $newlang='';
  289. if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  290. if (empty($newlang)) $newlang=$commande->client->default_lang;
  291. if (! empty($newlang))
  292. {
  293. $outputlangs = new Translate();
  294. $outputlangs->setDefaultLang($newlang);
  295. }
  296. $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $product->label;
  297. }
  298. else
  299. $label = (! empty($line->label)?$line->label:$product->label);
  300. print '<td>';
  301. print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$label;
  302. if ($line->description) print nl2br($line->description);
  303. print '</td>';
  304. }
  305. else
  306. {
  307. print "<td>";
  308. if ($line->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
  309. else $text = img_object($langs->trans('Product'),'product');
  310. if (! empty($line->label)) {
  311. $text.= ' <strong>'.$line->label.'</strong>';
  312. print $form->textwithtooltip($text,$line->description,3,'','',$i);
  313. } else {
  314. print $text.' '.nl2br($line->description);
  315. }
  316. print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
  317. print "</td>\n";
  318. }
  319. print '<td align="center">'.$line->qty.'</td>';
  320. /*
  321. *
  322. */
  323. print '<td align="center">';
  324. $quantite_livree = $commande->livraisons[$line->id];
  325. print $quantite_livree;;
  326. print '</td>';
  327. $quantite_commandee = $line->qty;
  328. $quantite_a_livrer = $quantite_commandee - $quantite_livree;
  329. if (! empty($conf->stock->enabled))
  330. {
  331. $stock = $product->stock_warehouse[$_GET["entrepot_id"]]->real;
  332. $stock+=0; // Convertit en numerique
  333. // Quantite a livrer
  334. print '<td align="center">';
  335. print '<input name="idl'.$i.'" type="hidden" value="'.$line->id.'">';
  336. print '<input name="qtyl'.$i.'" type="text" size="6" value="'.min($quantite_a_livrer, $stock).'">';
  337. print '</td>';
  338. // Stock
  339. if ($stock < $quantite_a_livrer)
  340. {
  341. print '<td align="center">'.$stock.' '.img_warning().'</td>';
  342. }
  343. else
  344. {
  345. print '<td align="center">'.$stock.'</td>';
  346. }
  347. }
  348. else
  349. {
  350. // Quantite a livrer
  351. print '<td align="center">';
  352. print '<input name="idl'.$i.'" type="hidden" value="'.$line->id.'">';
  353. print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
  354. print '</td>';
  355. }
  356. print "</tr>\n";
  357. $i++;
  358. $var=!$var;
  359. }
  360. /*
  361. *
  362. */
  363. print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
  364. print "</table>";
  365. print '</form>';
  366. }
  367. else
  368. {
  369. dol_print_error($db);
  370. }
  371. }
  372. else
  373. /* *************************************************************************** */
  374. /* */
  375. /* Mode vue et edition */
  376. /* */
  377. /* *************************************************************************** */
  378. {
  379. if ($id > 0)
  380. {
  381. $delivery = new Livraison($db);
  382. $result = $delivery->fetch($id);
  383. $delivery->fetch_thirdparty();
  384. $expedition=new Expedition($db);
  385. $result = $expedition->fetch($delivery->origin_id);
  386. $typeobject = $expedition->origin;
  387. if ($delivery->origin_id)
  388. {
  389. $delivery->fetch_origin();
  390. }
  391. if ($delivery->id > 0)
  392. {
  393. $soc = new Societe($db);
  394. $soc->fetch($delivery->socid);
  395. $head=delivery_prepare_head($delivery);
  396. dol_fiche_head($head, 'delivery', $langs->trans("Sending"), 0, 'sending');
  397. /*
  398. * Confirmation de la suppression
  399. *
  400. */
  401. if ($action == 'delete')
  402. {
  403. $expedition_id = $_GET["expid"];
  404. $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$delivery->id.'&amp;expid='.$expedition_id,$langs->trans("DeleteDeliveryReceipt"),$langs->trans("DeleteDeliveryReceiptConfirm",$delivery->ref),'confirm_delete','','',1);
  405. if ($ret == 'html') print '<br>';
  406. }
  407. /*
  408. * Confirmation de la validation
  409. *
  410. */
  411. if ($action == 'valid')
  412. {
  413. $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$delivery->id,$langs->trans("ValidateDeliveryReceipt"),$langs->trans("ValidateDeliveryReceiptConfirm",$delivery->ref),'confirm_valid','','',1);
  414. if ($ret == 'html') print '<br>';
  415. }
  416. /*
  417. * Livraison
  418. */
  419. print '<table class="border" width="100%">';
  420. // Ref
  421. print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
  422. print '<td colspan="3">'.$delivery->ref.'</td></tr>';
  423. // Client
  424. print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
  425. print '<td align="3">'.$soc->getNomUrl(1).'</td>';
  426. print "</tr>";
  427. // Document origine
  428. if ($typeobject == 'commande' && $expedition->origin_id && ! empty($conf->commande->enabled))
  429. {
  430. print '<tr><td>'.$langs->trans("RefOrder").'</td>';
  431. $order=new Commande($db);
  432. $order->fetch($expedition->origin_id);
  433. print '<td colspan="3">';
  434. print $order->getNomUrl(1,'commande');
  435. print "</td>\n";
  436. print '</tr>';
  437. }
  438. if ($typeobject == 'propal' && $expedition->origin_id && ! empty($conf->propal->enabled))
  439. {
  440. $propal=new Propal($db);
  441. $propal->fetch($expedition->origin_id);
  442. print '<tr><td>'.$langs->trans("RefProposal").'</td>';
  443. print '<td colspan="3">';
  444. print $propal->getNomUrl(1,'expedition');
  445. print "</td>\n";
  446. print '</tr>';
  447. }
  448. // Ref client
  449. print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
  450. print '<td colspan="3">'.$delivery->ref_customer."</a></td>\n";
  451. print '</tr>';
  452. // Date
  453. print '<tr><td>'.$langs->trans("DateCreation").'</td>';
  454. print '<td colspan="3">'.dol_print_date($delivery->date_creation,'daytext')."</td>\n";
  455. print '</tr>';
  456. // Date delivery real / Received
  457. // TODO Can edit this date, even if delivery validated.
  458. print '<tr><td>'.$langs->trans("DateReceived").'</td>';
  459. print '<td colspan="3">'.dol_print_date($delivery->date_delivery,'daytext')."</td>\n";
  460. print '</tr>';
  461. // Statut
  462. print '<tr><td>'.$langs->trans("Status").'</td>';
  463. print '<td colspan="3">'.$delivery->getLibStatut(4)."</td>\n";
  464. print '</tr>';
  465. if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
  466. {
  467. // Entrepot
  468. $entrepot = new Entrepot($db);
  469. $entrepot->fetch($delivery->entrepot_id);
  470. print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
  471. print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td>';
  472. print '</tr>';
  473. }
  474. print "</table><br>\n";
  475. /*
  476. * Lignes produits
  477. */
  478. $num_prod = count($delivery->lines);
  479. $i = 0; $total = 0;
  480. print '<table class="noborder" width="100%">';
  481. if ($num_prod)
  482. {
  483. $i = 0;
  484. print '<tr class="liste_titre">';
  485. print '<td>'.$langs->trans("Products").'</td>';
  486. print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
  487. print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
  488. print "</tr>\n";
  489. }
  490. $var=true;
  491. while ($i < $num_prod)
  492. {
  493. $var=!$var;
  494. print "<tr $bc[$var]>";
  495. if ($delivery->lines[$i]->fk_product > 0)
  496. {
  497. $product = new Product($db);
  498. $product->fetch($delivery->lines[$i]->fk_product);
  499. // Define output language
  500. if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
  501. {
  502. $delivery->fetch_thirdparty();
  503. $outputlangs = $langs;
  504. $newlang='';
  505. if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
  506. if (empty($newlang)) $newlang=$delivery->client->default_lang;
  507. if (! empty($newlang))
  508. {
  509. $outputlangs = new Translate();
  510. $outputlangs->setDefaultLang($newlang);
  511. }
  512. $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $delivery->lines[$i]->product_label;
  513. }
  514. else
  515. $label = ( ! empty($delivery->lines[$i]->label)?$delivery->lines[$i]->label:$delivery->lines[$i]->product_label);
  516. print '<td>';
  517. // Affiche ligne produit
  518. $text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$delivery->lines[$i]->fk_product.'">';
  519. if ($delivery->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
  520. else $text.= img_object($langs->trans('ShowProduct'),'product');
  521. $text.= ' '.$delivery->lines[$i]->product_ref.'</a>';
  522. $text.= ' - '.$label;
  523. $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($delivery->lines[$i]->description));
  524. //print $description;
  525. print $form->textwithtooltip($text,$description,3,'','',$i);
  526. print_date_range($delivery->lines[$i]->date_start,$delivery->lines[$i]->date_end);
  527. if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
  528. {
  529. print (! empty($delivery->lines[$i]->description) && $delivery->lines[$i]->description!=$delivery->lines[$i]->product_label)?'<br>'.dol_htmlentitiesbr($delivery->lines[$i]->description):'';
  530. }
  531. }
  532. else
  533. {
  534. print "<td>";
  535. if ($delivery->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
  536. else $text = img_object($langs->trans('Product'),'product');
  537. if (! empty($delivery->lines[$i]->label)) {
  538. $text.= ' <strong>'.$delivery->lines[$i]->label.'</strong>';
  539. print $form->textwithtooltip($text,$delivery->lines[$i]->description,3,'','',$i);
  540. } else {
  541. print $text.' '.nl2br($delivery->lines[$i]->description);
  542. }
  543. print_date_range($objp->date_start,$objp->date_end);
  544. print "</td>\n";
  545. }
  546. print '<td align="center">'.$delivery->lines[$i]->qty_asked.'</td>';
  547. print '<td align="center">'.$delivery->lines[$i]->qty_shipped.'</td>';
  548. print "</tr>";
  549. $i++;
  550. }
  551. print "</table>\n";
  552. print "\n</div>\n";
  553. /*
  554. * Boutons actions
  555. */
  556. if ($user->societe_id == 0)
  557. {
  558. print '<div class="tabsAction">';
  559. if ($delivery->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0)
  560. {
  561. print '<a class="butAction" href="fiche.php?id='.$delivery->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
  562. }
  563. if ($user->rights->expedition->livraison->supprimer)
  564. {
  565. if ($conf->expedition_bon->enabled)
  566. {
  567. print '<a class="butActionDelete" href="fiche.php?id='.$delivery->id.'&amp;expid='.$delivery->expedition_id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
  568. }
  569. else
  570. {
  571. print '<a class="butActionDelete" href="fiche.php?id='.$delivery->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
  572. }
  573. }
  574. print '</div>';
  575. }
  576. print "\n";
  577. print '<table width="100%" cellspacing="2"><tr><td width="50%" valign="top">';
  578. /*
  579. * Documents generated
  580. */
  581. $deliveryref = dol_sanitizeFileName($delivery->ref);
  582. $filedir = $conf->expedition->dir_output . "/receipt/" . $deliveryref;
  583. $urlsource = $_SERVER["PHP_SELF"]."?id=".$delivery->id;
  584. $genallowed=$user->rights->expedition->livraison->creer;
  585. $delallowed=$user->rights->expedition->livraison->supprimer;
  586. $somethingshown=$formfile->show_documents('livraison',$deliveryref,$filedir,$urlsource,$genallowed,$delallowed,$delivery->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
  587. if ($genallowed && ! $somethingshown) $somethingshown=1;
  588. print '</td><td valign="top" width="50%">';
  589. // Rien a droite
  590. print '</td></tr></table>';
  591. if ($expedition->origin_id)
  592. {
  593. print '<br>';
  594. //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
  595. show_list_sending_receive($expedition->origin,$expedition->origin_id);
  596. }
  597. }
  598. else
  599. {
  600. /* Expedition non trouvee */
  601. print "Expedition inexistante ou acces refuse";
  602. }
  603. }
  604. else
  605. {
  606. /* Expedition non trouvee */
  607. print "Expedition inexistante ou acces refuse";
  608. }
  609. }
  610. llxFooter();
  611. $db->close();
  612. ?>