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

/htdocs/expedition/shipment.php

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