PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/expedition/shipment.php

https://github.com/asterix14/dolibarr
PHP | 670 lines | 492 code | 93 blank | 85 comment | 119 complexity | 6bb9e354c6f06b9ea10cdc89fc49c566 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. // Code identique a /expedition/fiche.php
  20. /**
  21. * \file htdocs/expedition/shipment.php
  22. * \ingroup expedition
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
  28. require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php");
  29. require_once(DOL_DOCUMENT_ROOT."/core/lib/sendings.lib.php");
  30. if ($conf->product->enabled || $conf->service->enabled) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
  31. if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  32. if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  33. if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
  34. if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php");
  35. $langs->load('orders');
  36. $langs->load("companies");
  37. $langs->load("bills");
  38. $langs->load('propal');
  39. $langs->load('deliveries');
  40. $langs->load('stocks');
  41. $id=empty($_GET['id']) ? 0 : intVal($_GET['id']);
  42. $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
  43. // Security check
  44. $socid=0;
  45. if ($user->societe_id) $socid=$user->societe_id;
  46. $result=restrictedArea($user,'commande',$id);
  47. /*
  48. * Actions
  49. */
  50. // Categorisation dans projet
  51. if ($_POST['action'] == 'classin')
  52. {
  53. $commande = new Commande($db);
  54. $commande->fetch($_GET['id']);
  55. $commande->setProject($_POST['projectid']);
  56. }
  57. if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
  58. {
  59. $commande = new Commande($db);
  60. $commande->fetch($_GET["id"]);
  61. $result = $commande->cloture($user);
  62. }
  63. // Positionne ref commande client
  64. if ($_POST['action'] == 'setrefcustomer' && $user->rights->commande->creer)
  65. {
  66. $commande = new Commande($db);
  67. $commande->fetch($_GET['id']);
  68. $commande->set_ref_client($user, $_POST['ref_customer']);
  69. }
  70. if ($_POST['action'] == 'setdatedelivery' && $user->rights->commande->creer)
  71. {
  72. //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
  73. $datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
  74. $commande = new Commande($db);
  75. $commande->fetch($_GET['id']);
  76. $result=$commande->set_date_livraison($user,$datelivraison);
  77. if ($result < 0)
  78. {
  79. $mesg='<div class="error">'.$commande->error.'</div>';
  80. }
  81. }
  82. if ($_POST['action'] == 'setdeliveryaddress' && $user->rights->commande->creer)
  83. {
  84. $commande = new Commande($db);
  85. $commande->fetch($_GET['id']);
  86. $commande->set_adresse_livraison($user,$_POST['delivery_address_id']);
  87. }
  88. if ($_POST['action'] == 'setmode' && $user->rights->commande->creer)
  89. {
  90. $commande = new Commande($db);
  91. $commande->fetch($_GET['id']);
  92. $result=$commande->mode_reglement($_POST['mode_reglement_id']);
  93. if ($result < 0) dol_print_error($db,$commande->error);
  94. }
  95. if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
  96. {
  97. $commande = new Commande($db);
  98. $commande->fetch($_GET['id']);
  99. $result=$commande->cond_reglement($_POST['cond_reglement_id']);
  100. if ($result < 0) dol_print_error($db,$commande->error);
  101. }
  102. $form = new Form($db);
  103. $formproduct = new FormProduct($db);
  104. $formfile = new FormFile($db);
  105. /* *************************************************************************** */
  106. /* */
  107. /* Mode vue et edition */
  108. /* */
  109. /* *************************************************************************** */
  110. llxHeader('',$langs->trans('OrderCard'),'');
  111. $id = $_GET['id'];
  112. $ref= $_GET['ref'];
  113. if ($id > 0 || ! empty($ref))
  114. {
  115. $commande = new Commande($db);
  116. if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
  117. {
  118. $commande->loadExpeditions(1);
  119. $product_static=new Product($db);
  120. $soc = new Societe($db);
  121. $soc->fetch($commande->socid);
  122. $author = new User($db);
  123. $author->fetch($commande->user_author_id);
  124. $head = commande_prepare_head($commande);
  125. dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order');
  126. /*
  127. * Confirmation de la validation
  128. */
  129. if ($_GET["action"] == 'cloture')
  130. {
  131. $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$_GET["id"],$langs->trans("CloseOrder"),$langs->trans("ConfirmCloseOrder"),"confirm_cloture");
  132. if ($ret == 'html') print '<br>';
  133. }
  134. // Onglet commande
  135. $nbrow=7;
  136. if ($conf->projet->enabled) $nbrow++;
  137. print '<table class="border" width="100%">';
  138. // Ref
  139. print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
  140. print '<td colspan="3">';
  141. print $form->showrefnav($commande,'ref','',1,'ref','ref');
  142. print '</td>';
  143. print '</tr>';
  144. // Ref commande client
  145. print '<tr><td>';
  146. print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
  147. print $langs->trans('RefCustomer').'</td><td align="left">';
  148. print '</td>';
  149. if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&amp;id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
  150. print '</tr></table>';
  151. print '</td><td colspan="3">';
  152. if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
  153. {
  154. print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
  155. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  156. print '<input type="hidden" name="action" value="setrefcustomer">';
  157. print '<input type="text" class="flat" size="20" name="ref_customer" value="'.$commande->ref_client.'">';
  158. print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
  159. print '</form>';
  160. }
  161. else
  162. {
  163. print $commande->ref_client;
  164. }
  165. print '</td>';
  166. print '</tr>';
  167. // Third party
  168. print '<tr><td>'.$langs->trans('Company').'</td>';
  169. print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
  170. print '</tr>';
  171. // Discounts for third party
  172. print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
  173. if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
  174. else print $langs->trans("CompanyHasNoRelativeDiscount");
  175. print '. ';
  176. $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
  177. $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
  178. $absolute_discount=price2num($absolute_discount,'MT');
  179. $absolute_creditnote=price2num($absolute_creditnote,'MT');
  180. if ($absolute_discount)
  181. {
  182. if ($commande->statut > 0)
  183. {
  184. print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
  185. }
  186. else
  187. {
  188. // Remise dispo de type non avoir
  189. $filter='fk_facture_source IS NULL';
  190. print '<br>';
  191. $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount,$filter);
  192. }
  193. }
  194. if ($absolute_creditnote)
  195. {
  196. print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)).'. ';
  197. }
  198. if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
  199. print '</td></tr>';
  200. // Date
  201. print '<tr><td>'.$langs->trans('Date').'</td>';
  202. print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>';
  203. print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
  204. if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id)
  205. {
  206. // Si source = propal
  207. $propal = new Propal($db);
  208. $propal->fetch($commande->propale_id);
  209. print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>';
  210. }
  211. print '</td>';
  212. print '</tr>';
  213. // Delivery date planned
  214. print '<tr><td height="10">';
  215. print '<table class="nobordernopadding" width="100%"><tr><td>';
  216. print $langs->trans('DateDeliveryPlanned');
  217. print '</td>';
  218. if ($_GET['action'] != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>';
  219. print '</tr></table>';
  220. print '</td><td colspan="2">';
  221. if ($_GET['action'] == 'editdate_livraison')
  222. {
  223. print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
  224. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  225. print '<input type="hidden" name="action" value="setdatedelivery">';
  226. $form->select_date($commande->date_livraison>0?$commande->date_livraison:-1,'liv_','','','',"setdatedelivery");
  227. print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
  228. print '</form>';
  229. }
  230. else
  231. {
  232. print dol_print_date($commande->date_livraison,'daytext');
  233. }
  234. print '</td>';
  235. print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
  236. print nl2br($commande->note_public);
  237. print '</td>';
  238. print '</tr>';
  239. // Delivery address
  240. if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
  241. {
  242. print '<tr><td height="10">';
  243. print '<table class="nobordernopadding" width="100%"><tr><td>';
  244. print $langs->trans('DeliveryAddress');
  245. print '</td>';
  246. if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->socid.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
  247. print '</tr></table>';
  248. print '</td><td colspan="2">';
  249. if ($_GET['action'] == 'editdelivery_adress')
  250. {
  251. $form->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'delivery_address_id','commande',$commande->id);
  252. }
  253. else
  254. {
  255. $form->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'none','commande',$commande->id);
  256. }
  257. print '</td></tr>';
  258. }
  259. // Terms of payment
  260. print '<tr><td height="10">';
  261. print '<table class="nobordernopadding" width="100%"><tr><td>';
  262. print $langs->trans('PaymentConditionsShort');
  263. print '</td>';
  264. if ($_GET['action'] != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
  265. print '</tr></table>';
  266. print '</td><td colspan="2">';
  267. if ($_GET['action'] == 'editconditions')
  268. {
  269. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id');
  270. }
  271. else
  272. {
  273. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none');
  274. }
  275. print '</td></tr>';
  276. // Mode of payment
  277. print '<tr><td height="10">';
  278. print '<table class="nobordernopadding" width="100%"><tr><td>';
  279. print $langs->trans('PaymentMode');
  280. print '</td>';
  281. if ($_GET['action'] != 'editmode' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
  282. print '</tr></table>';
  283. print '</td><td colspan="2">';
  284. if ($_GET['action'] == 'editmode')
  285. {
  286. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id');
  287. }
  288. else
  289. {
  290. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none');
  291. }
  292. print '</td></tr>';
  293. // Project
  294. if ($conf->projet->enabled)
  295. {
  296. $langs->load('projects');
  297. print '<tr><td height="10">';
  298. print '<table class="nobordernopadding" width="100%"><tr><td>';
  299. print $langs->trans('Project');
  300. print '</td>';
  301. if ($_GET['action'] != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
  302. print '</tr></table>';
  303. print '</td><td colspan="2">';
  304. if ($_GET['action'] == 'classify')
  305. {
  306. $form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'projectid');
  307. }
  308. else
  309. {
  310. $form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'none');
  311. }
  312. print '</td></tr>';
  313. }
  314. // Lignes de 3 colonnes
  315. // Total HT
  316. print '<tr><td>'.$langs->trans('AmountHT').'</td>';
  317. print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
  318. print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
  319. // Total TVA
  320. print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
  321. print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
  322. // Total TTC
  323. print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
  324. print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
  325. // Statut
  326. print '<tr><td>'.$langs->trans('Status').'</td>';
  327. print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
  328. print '</tr>';
  329. print '</table><br>';
  330. /**
  331. * Lignes de commandes avec quantite livrees et reste a livrer
  332. * Les quantites livrees sont stockees dans $commande->expeditions[fk_product]
  333. */
  334. print '<table class="liste" width="100%">';
  335. $sql = "SELECT cd.rowid, cd.fk_product, cd.product_type, cd.description,";
  336. $sql.= " cd.price, cd.tva_tx, cd.subprice,";
  337. $sql.= " cd.qty,";
  338. $sql.= ' cd.date_start,';
  339. $sql.= ' cd.date_end,';
  340. $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
  341. $sql.= ' p.description as product_desc, p.fk_product_type as product_type';
  342. $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
  343. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
  344. $sql.= " WHERE cd.fk_commande = ".$commande->id;
  345. // $sql.= " AND p.fk_product_type <> 1"; Why this line ?
  346. //$sql.= " GROUP by cd.rowid, cd.fk_product";
  347. $sql.= " ORDER BY cd.rang, cd.rowid";
  348. //print $sql;
  349. dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
  350. $resql = $db->query($sql);
  351. if ($resql)
  352. {
  353. $num = $db->num_rows($resql);
  354. $i = 0;
  355. print '<tr class="liste_titre">';
  356. print '<td>'.$langs->trans("Description").'</td>';
  357. print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
  358. print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
  359. print '<td align="center">'.$langs->trans("KeepToShip").'</td>';
  360. if ($conf->stock->enabled)
  361. {
  362. print '<td align="center">'.$langs->trans("Stock").'</td>';
  363. }
  364. else
  365. {
  366. print '<td>&nbsp;</td>';
  367. }
  368. print "</tr>\n";
  369. $var=true;
  370. $reste_a_livrer = array();
  371. while ($i < $num)
  372. {
  373. $objp = $db->fetch_object($resql);
  374. $var=!$var;
  375. // Show product and description
  376. $type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
  377. // Try to enhance type detection using date_start and date_end for free lines where type
  378. // was not saved.
  379. if (! empty($objp->date_start)) $type=1;
  380. if (! empty($objp->date_end)) $type=1;
  381. print "<tr ".$bc[$var].">";
  382. // Product label
  383. if ($objp->fk_product > 0)
  384. {
  385. print '<td>';
  386. print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
  387. // Show product and description
  388. $product_static->type=$objp->fk_product_type;
  389. $product_static->id=$objp->fk_product;
  390. $product_static->ref=$objp->ref;
  391. $product_static->libelle=$objp->product_label;
  392. $text=$product_static->getNomUrl(1);
  393. $text.= ' - '.$objp->product_label;
  394. $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
  395. print $form->textwithtooltip($text,$description,3,'','',$i);
  396. // Show range
  397. print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
  398. // Add description in form
  399. if ($conf->global->PRODUIT_DESC_IN_FORM)
  400. {
  401. print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
  402. }
  403. print '</td>';
  404. }
  405. else
  406. {
  407. print "<td>";
  408. if ($type==1) $text = img_object($langs->trans('Service'),'service');
  409. else $text = img_object($langs->trans('Product'),'product');
  410. print $text.' '.nl2br($objp->description);
  411. // Show range
  412. print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
  413. print "</td>\n";
  414. }
  415. // Qty ordered
  416. print '<td align="center">'.$objp->qty.'</td>';
  417. // Qty already shipped
  418. $qtyProdCom=$objp->qty;
  419. print '<td align="center">';
  420. // Nb of sending products for this line of order
  421. $quantite_livree = $commande->expeditions[$objp->rowid];
  422. print $quantite_livree;
  423. print '</td>';
  424. // Qty remains to ship
  425. print '<td align="center">';
  426. if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
  427. {
  428. $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
  429. $reste_a_livrer_total += $reste_a_livrer[$objp->fk_product];
  430. print $reste_a_livrer[$objp->fk_product];
  431. }
  432. else
  433. {
  434. print '0 ('.$langs->trans("Service").')';
  435. }
  436. print '</td>';
  437. if ($objp->fk_product > 0)
  438. {
  439. $product = new Product($db);
  440. $product->fetch($objp->fk_product);
  441. }
  442. if ($objp->fk_product > 0 && $type == 0 && $conf->stock->enabled)
  443. {
  444. print '<td align="center">';
  445. print $product->stock_reel;
  446. if ($product->stock_reel < $reste_a_livrer[$objp->fk_product])
  447. {
  448. print ' '.img_warning($langs->trans("StockTooLow"));
  449. }
  450. print '</td>';
  451. }
  452. else
  453. {
  454. print '<td>&nbsp;</td>';
  455. }
  456. print "</tr>\n";
  457. // Show subproducts details
  458. if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
  459. {
  460. // Set tree of subproducts in product->sousprods
  461. $product->get_sousproduits_arbo();
  462. //var_dump($product->sousprods);exit;
  463. // Define a new tree with quantiies recalculated
  464. $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
  465. //var_dump($prods_arbo);
  466. if(count($prods_arbo) > 0)
  467. {
  468. foreach($prods_arbo as $key => $value)
  469. {
  470. print '<tr><td colspan="4">';
  471. $img='';
  472. if ($value['stock'] < $value['stock_alert'])
  473. {
  474. $img=img_warning($langs->trans("StockTooLow"));
  475. }
  476. print "<tr><td>&nbsp; &nbsp; &nbsp; ->
  477. <a href=\"".DOL_URL_ROOT."/product/fiche.php?id=".$value['id']."\">".$value['fullpath']."
  478. </a> (".$value['nb'].")</td><td align=\"center\"> ".$value['nb_total']."</td><td>&nbsp</td><td>&nbsp</td>
  479. <td align=\"center\">".$value['stock']." ".$img."</td></tr>";
  480. print $value[0];
  481. print '</td></tr>'."\n";
  482. }
  483. }
  484. }
  485. $i++;
  486. }
  487. $db->free($resql);
  488. if (! $num)
  489. {
  490. print '<tr '.$bc[false].'><td colspan="5">'.$langs->trans("NoArticleOfTypeProduct").'<br>';
  491. }
  492. print "</table>";
  493. }
  494. else
  495. {
  496. dol_print_error($db);
  497. }
  498. print '</div>';
  499. /*
  500. * Boutons Actions
  501. */
  502. if ($user->societe_id == 0)
  503. {
  504. print '<div class="tabsAction">';
  505. // Bouton expedier sans gestion des stocks
  506. if (! $conf->stock->enabled && ($commande->statut > 0 && $commande->statut < 3))
  507. {
  508. if ($user->rights->expedition->creer)
  509. {
  510. print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;origin=commande&amp;object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
  511. if ($reste_a_livrer_total <= 0)
  512. {
  513. print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
  514. }
  515. }
  516. else
  517. {
  518. print '<a class="butActionRefused" href="#">'.$langs->trans("NewSending").'</a>';
  519. }
  520. }
  521. print "</div>";
  522. }
  523. // Bouton expedier avec gestion des stocks
  524. if ($conf->stock->enabled && ($commande->statut > 0 && $commande->statut < 3))
  525. {
  526. if ($user->rights->expedition->creer)
  527. {
  528. print_titre($langs->trans("NewSending"));
  529. print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/fiche.php">';
  530. print '<input type="hidden" name="action" value="create">';
  531. print '<input type="hidden" name="id" value="'.$commande->id.'">';
  532. print '<input type="hidden" name="origin" value="commande">';
  533. print '<input type="hidden" name="origin_id" value="'.$commande->id.'">';
  534. print '<table class="border" width="100%">';
  535. $langs->load("stocks");
  536. print '<tr>';
  537. if ($conf->stock->enabled)
  538. {
  539. print '<td>'.$langs->trans("WarehouseSource").'</td>';
  540. print '<td>';
  541. print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
  542. if (count($formproduct->cache_warehouses) <= 0)
  543. {
  544. print ' &nbsp; No warehouse defined, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">add one</a>';
  545. }
  546. print '</td>';
  547. }
  548. print '<td align="center">';
  549. print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
  550. if ($reste_a_livrer_total <= 0)
  551. {
  552. print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
  553. }
  554. print '</td></tr>';
  555. print "</table>";
  556. print "</form>\n";
  557. print '<br>';
  558. $somethingshown=1;
  559. }
  560. else
  561. {
  562. print '<div class="tabsAction">';
  563. print '<a class="butActionRefused" href="#">'.$langs->trans("NewSending").'</a>';
  564. print '</div>';
  565. }
  566. }
  567. show_list_sending_receive('commande',$commande->id);
  568. }
  569. else
  570. {
  571. /* Commande non trouvee */
  572. print "Commande inexistante";
  573. }
  574. }
  575. $db->close();
  576. llxFooter();
  577. ?>