fiche-rec.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <?php
  2. /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  6. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
  9. * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/compta/facture/fiche-rec.php
  26. * \ingroup facture
  27. * \brief Page to show predefined invoice
  28. */
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  33. $langs->load('bills');
  34. $langs->load('compta');
  35. // Security check
  36. $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
  37. $action=GETPOST('action', 'alpha');
  38. if ($user->societe_id) $socid=$user->societe_id;
  39. $objecttype = 'facture_rec';
  40. if ($action == "create" || $action == "add") $objecttype = '';
  41. $result = restrictedArea($user, 'facture', $id, $objecttype);
  42. if ($page == -1)
  43. {
  44. $page = 0 ;
  45. }
  46. $limit = $conf->liste_limit;
  47. $offset = $limit * $page ;
  48. if ($sortorder == "")
  49. $sortorder="DESC";
  50. if ($sortfield == "")
  51. $sortfield="f.datef";
  52. $object = new FactureRec($db);
  53. /*
  54. * Actions
  55. */
  56. // Create predefined invoice
  57. if ($action == 'add')
  58. {
  59. if (! GETPOST('titre'))
  60. {
  61. setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), 'errors');
  62. $action = "create";
  63. $error++;
  64. }
  65. if (! $error)
  66. {
  67. $object->titre = GETPOST('titre', 'alpha');
  68. $object->note_private = GETPOST('note_private');
  69. $object->usenewprice = GETPOST('usenewprice');
  70. if ($object->create($user, $id) > 0)
  71. {
  72. $id = $object->id;
  73. $action = '';
  74. }
  75. else
  76. {
  77. setEventMessage($object->error, 'errors');
  78. $action = "create";
  79. }
  80. }
  81. }
  82. // Suppression
  83. if ($action == 'delete' && $user->rights->facture->supprimer)
  84. {
  85. $object->fetch($id);
  86. $object->delete();
  87. $id = 0 ;
  88. }
  89. /*
  90. * View
  91. */
  92. llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
  93. $form = new Form($db);
  94. $companystatic = new Societe($db);
  95. /*
  96. * Create mode
  97. */
  98. if ($action == 'create')
  99. {
  100. print_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png');
  101. $object = new Facture($db); // Source invoice
  102. $product_static = new Product($db);
  103. if ($object->fetch($id) > 0)
  104. {
  105. print '<form action="fiche-rec.php" method="post">';
  106. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  107. print '<input type="hidden" name="action" value="add">';
  108. print '<input type="hidden" name="facid" value="'.$object->id.'">';
  109. dol_fiche_head();
  110. $rowspan=4;
  111. if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
  112. print '<table class="border" width="100%">';
  113. $object->fetch_thirdparty();
  114. // Third party
  115. print '<tr><td>'.$langs->trans("Customer").'</td><td>'.$object->client->getNomUrl(1,'customer').'</td>';
  116. print '<td>';
  117. print $langs->trans("Comment");
  118. print '</td></tr>';
  119. // Title
  120. print '<tr><td class="fieldrequired">'.$langs->trans("Title").'</td><td>';
  121. print '<input class="flat" type="text" name="titre" size="24" value="'.$_POST["titre"].'">';
  122. print '</td>';
  123. // Note
  124. print '<td rowspan="'.$rowspan.'" valign="top">';
  125. print '<textarea class="flat" name="note_private" wrap="soft" cols="60" rows="'.ROWS_4.'"></textarea>';
  126. print '</td></tr>';
  127. // Author
  128. print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
  129. // Payment term
  130. print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
  131. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
  132. print "</td></tr>";
  133. // Payment mode
  134. print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
  135. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
  136. print "</td></tr>";
  137. // Project
  138. if (! empty($conf->projet->enabled) && $object->fk_project > 0)
  139. {
  140. print "<tr><td>".$langs->trans("Project")."</td><td>";
  141. if ($object->fk_project > 0)
  142. {
  143. $project = new Project($db);
  144. $project->fetch($object->fk_project);
  145. print $project->title;
  146. }
  147. print "</td></tr>";
  148. }
  149. print "</table>";
  150. print '<br>';
  151. $title = $langs->trans("ProductsAndServices");
  152. if (empty($conf->service->enabled))
  153. $title = $langs->trans("Products");
  154. else if (empty($conf->product->enabled))
  155. $title = $langs->trans("Services");
  156. print_titre($title);
  157. /*
  158. * Invoice lines
  159. */
  160. print '<table class="notopnoleftnoright" width="100%">';
  161. print '<tr><td colspan="3">';
  162. $sql = 'SELECT l.fk_product, l.product_type, l.label as custom_label, l.description, l.qty, l.rowid, l.tva_tx,';
  163. $sql.= ' l.fk_remise_except,';
  164. $sql.= ' l.remise_percent, l.subprice, l.info_bits,';
  165. $sql.= ' l.total_ht, l.total_tva as total_vat, l.total_ttc,';
  166. $sql.= ' l.date_start,';
  167. $sql.= ' l.date_end,';
  168. $sql.= ' l.product_type,';
  169. $sql.= ' l.fk_unit,';
  170. $sql.= ' p.ref, p.fk_product_type, p.label as product_label,';
  171. $sql.= ' p.description as product_desc';
  172. $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as l";
  173. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
  174. $sql.= " WHERE l.fk_facture = ".$object->id;
  175. $sql.= " ORDER BY l.rowid";
  176. $result = $db->query($sql);
  177. if ($result)
  178. {
  179. $num = $db->num_rows($result);
  180. $i = 0; $total = 0;
  181. echo '<table class="noborder" width="100%">';
  182. if ($num)
  183. {
  184. print '<tr class="liste_titre">';
  185. print '<td>'.$langs->trans("Description").'</td>';
  186. print '<td align="center">'.$langs->trans("VAT").'</td>';
  187. print '<td align="center">'.$langs->trans("Qty").'</td>';
  188. if ($conf->global->PRODUCT_USE_UNITS) {
  189. print '<td width="8%" align="left">'.$langs->trans("Unit").'</td>';
  190. }
  191. print '<td>'.$langs->trans("ReductionShort").'</td>';
  192. print '<td align="right">'.$langs->trans("TotalHT").'</td>';
  193. print '<td align="right">'.$langs->trans("TotalVAT").'</td>';
  194. print '<td align="right">'.$langs->trans("TotalTTC").'</td>';
  195. print '<td align="right">'.$langs->trans("PriceUHT").'</td>';
  196. if (empty($conf->global->PRODUIT_MULTIPRICES)) print '<td align="right">'.$langs->trans("CurrentProductPrice").'</td>';
  197. print "</tr>\n";
  198. }
  199. $var=true;
  200. while ($i < $num)
  201. {
  202. $objp = $db->fetch_object($result);
  203. if ($objp->fk_product > 0)
  204. {
  205. $product = New Product($db);
  206. $product->fetch($objp->fk_product);
  207. }
  208. $var=!$var;
  209. print "<tr ".$bc[$var].">";
  210. // Show product and description
  211. $type=(isset($objp->product_type)?$objp->product_type:$objp->fk_product_type);
  212. $product_static->fk_unit=$objp->fk_unit;
  213. if ($objp->fk_product > 0)
  214. {
  215. print '<td>';
  216. print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
  217. // Show product and description
  218. $product_static->fetch($objp->fk_product); // We need all information later
  219. $text=$product_static->getNomUrl(1);
  220. $text.= ' - '.(! empty($objp->custom_label)?$objp->custom_label:$objp->product_label);
  221. $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
  222. print $form->textwithtooltip($text,$description,3,'','',$i);
  223. // Show range
  224. print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
  225. // Add description in form
  226. if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
  227. print (! empty($objp->description) && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
  228. print '</td>';
  229. }
  230. else
  231. {
  232. print '<td>';
  233. print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
  234. if ($type==1) $text = img_object($langs->trans('Service'),'service');
  235. else $text = img_object($langs->trans('Product'),'product');
  236. if (! empty($objp->custom_label)) {
  237. $text.= ' <strong>'.$objp->custom_label.'</strong>';
  238. print $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i);
  239. } else {
  240. print $text.' '.nl2br($objp->description);
  241. }
  242. // Show range
  243. print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
  244. print "</td>\n";
  245. }
  246. // Vat rate
  247. print '<td align="center">'.vatrate($objp->tva_tx).'%</td>';
  248. // Qty
  249. print '<td align="center">'.$objp->qty.'</td>';
  250. if ($conf->global->PRODUCT_USE_UNITS) {
  251. print '<td align="left">'.$product_static->getLabelOfUnit().'</td>';
  252. }
  253. // Percent
  254. if ($objp->remise_percent > 0)
  255. {
  256. print '<td align="right">'.$objp->remise_percent." %</td>\n";
  257. }
  258. else
  259. {
  260. print '<td>&nbsp;</td>';
  261. }
  262. // Total HT
  263. print '<td align="right">'.price($objp->total_ht)."</td>\n";
  264. // Total VAT
  265. print '<td align="right">'.price($objp->total_vat)."</td>\n";
  266. // Total TTC
  267. print '<td align="right">'.price($objp->total_ttc)."</td>\n";
  268. // Total Unit price
  269. print '<td align="right">'.price($objp->subprice)."</td>\n";
  270. // Current price of product
  271. if (empty($conf->global->PRODUIT_MULTIPRICES))
  272. {
  273. if ($objp->fk_product > 0)
  274. {
  275. $flag_price_may_change++;
  276. $prodprice=$product_static->price; // price HT
  277. print '<td align="right">'.price($prodprice)."</td>\n";
  278. }
  279. else
  280. {
  281. print '<td>&nbsp;</td>';
  282. }
  283. }
  284. print "</tr>";
  285. $i++;
  286. }
  287. $db->free($result);
  288. }
  289. else
  290. {
  291. print $db->error();
  292. }
  293. print "</table>";
  294. print '</td></tr>';
  295. if ($flag_price_may_change)
  296. {
  297. print '<tr><td colspan="3" align="left">';
  298. print '<select name="usenewprice" class="flat">';
  299. print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>';
  300. print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>';
  301. print '</select>';
  302. print '</td></tr>';
  303. }
  304. print "</table>\n";
  305. dol_fiche_end();
  306. print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">';
  307. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  308. print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
  309. print '</div>';
  310. print "</form>\n";
  311. }
  312. else
  313. {
  314. dol_print_error('',"Error, no invoice ".$object->id);
  315. }
  316. }
  317. else
  318. {
  319. /*
  320. * View mode
  321. */
  322. if ($id > 0)
  323. {
  324. if ($object->fetch($id) > 0)
  325. {
  326. $object->fetch_thirdparty();
  327. $author = new User($db);
  328. $author->fetch($object->user_author);
  329. $head=array();
  330. $h=0;
  331. $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
  332. $head[$h][1] = $langs->trans("CardBill");
  333. $head[$h][2] = 'card';
  334. dol_fiche_head($head, 'card', $langs->trans("PredefinedInvoices"),0,'bill'); // Add a div
  335. print '<table class="border" width="100%">';
  336. print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
  337. print '<td colspan="4">'.$object->titre.'</td>';
  338. print '<tr><td>'.$langs->trans("Customer").'</td>';
  339. print '<td colspan="3">'.$object->thirdparty->getNomUrl(1,'customer').'</td></tr>';
  340. print "<tr><td>".$langs->trans("Author").'</td><td colspan="3">'.$author->getFullName($langs)."</td></tr>";
  341. print '<tr><td>'.$langs->trans("AmountHT").'</td>';
  342. print '<td colspan="3"><b>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</b></td>';
  343. print '</tr>';
  344. print '<tr><td>'.$langs->trans("AmountVAT").'</td><td colspan="3">'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>';
  345. print '</tr>';
  346. print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>';
  347. print '</tr>';
  348. // Payment term
  349. print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">';
  350. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none');
  351. print "</td></tr>";
  352. // Payment mode
  353. print '<tr><td>'.$langs->trans("PaymentMode").'</td><td colspan="3">';
  354. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none');
  355. print "</td></tr>";
  356. print '<tr><td>'.$langs->trans("Comment").'</td><td colspan="3">'.nl2br($object->note_private)."</td></tr>";
  357. print "</table>";
  358. print '</div>';
  359. /*
  360. * Lines
  361. */
  362. $title = $langs->trans("ProductsAndServices");
  363. if (empty($conf->service->enabled))
  364. $title = $langs->trans("Products");
  365. else if (empty($conf->product->enabled))
  366. $title = $langs->trans("Services");
  367. print_titre($title);
  368. print '<table class="noborder" width="100%">';
  369. print '<tr class="liste_titre">';
  370. print '<td>'.$langs->trans("Description").'</td>';
  371. print '<td align="right">'.$langs->trans("Price").'</td>';
  372. print '<td align="center">'.$langs->trans("ReductionShort").'</td>';
  373. print '<td align="center">'.$langs->trans("Qty").'</td>';
  374. if ($conf->global->PRODUCT_USE_UNITS) {
  375. print '<td align="left">'.$langs->trans("Unit").'</td>';
  376. }
  377. print '</tr>';
  378. $num = count($object->lines);
  379. $i = 0;
  380. $var=true;
  381. while ($i < $num)
  382. {
  383. $var=!$var;
  384. $product_static=new Product($db);
  385. // Show product and description
  386. $type=(isset($object->lines[$i]->product_type)?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type);
  387. // Try to enhance type detection using date_start and date_end for free lines when type
  388. // was not saved.
  389. if (! empty($objp->date_start)) $type=1;
  390. if (! empty($objp->date_end)) $type=1;
  391. // Show line
  392. print "<tr ".$bc[$var].">";
  393. if ($object->lines[$i]->fk_product > 0)
  394. {
  395. print '<td>';
  396. print '<a name="'.$object->lines[$i]->id.'"></a>'; // ancre pour retourner sur la ligne
  397. // Show product and description
  398. $product_static->type=$object->lines[$i]->fk_product_type;
  399. $product_static->id=$object->lines[$i]->fk_product;
  400. $product_static->ref=$object->lines[$i]->product_ref;
  401. $text=$product_static->getNomUrl(1);
  402. $text.= ' - '.(! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
  403. $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->desc));
  404. print $form->textwithtooltip($text,$description,3,'','',$i);
  405. // Show range
  406. print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
  407. // Add description in form
  408. if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
  409. print (! empty($object->lines[$i]->desc) && $object->lines[$i]->desc!=$fac->lines[$i]->product_label)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->desc):'';
  410. print '</td>';
  411. }
  412. else
  413. {
  414. print '<td>';
  415. if ($type==1) $text = img_object($langs->trans('Service'),'service');
  416. else $text = img_object($langs->trans('Product'),'product');
  417. if (! empty($object->lines[$i]->label)) {
  418. $text.= ' <strong>'.$object->lines[$i]->label.'</strong>';
  419. print $form->textwithtooltip($text,dol_htmlentitiesbr($object->lines[$i]->desc),3,'','',$i);
  420. } else {
  421. print $text.' '.nl2br($object->lines[$i]->desc);
  422. }
  423. // Show range
  424. print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
  425. print '</td>';
  426. }
  427. print '<td align="right">'.price($object->lines[$i]->price).'</td>';
  428. print '<td align="center">'.$object->lines[$i]->remise_percent.' %</td>';
  429. print '<td align="center">'.$object->lines[$i]->qty.'</td>';
  430. if ($conf->global->PRODUCT_USE_UNITS) {
  431. print "<td align=\"left\">".$object->lines[$i]->getLabelOfUnit()."</td>";
  432. }
  433. print "</tr>\n";
  434. $i++;
  435. }
  436. print '</table>';
  437. /**
  438. * Barre d'actions
  439. */
  440. print '<div class="tabsAction">';
  441. if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
  442. {
  443. echo '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;socid='.$object->thirdparty->id.'&amp;fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
  444. }
  445. if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
  446. {
  447. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
  448. }
  449. print '</div>';
  450. }
  451. else
  452. {
  453. print $langs->trans("ErrorRecordNotFound");
  454. }
  455. }
  456. else
  457. {
  458. /*
  459. * List mode
  460. */
  461. $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc";
  462. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
  463. $sql.= " WHERE f.fk_soc = s.rowid";
  464. $sql.= " AND f.entity = ".$conf->entity;
  465. if ($socid) $sql .= " AND s.rowid = ".$socid;
  466. //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
  467. // $sql .= $db->plimit($limit + 1,$offset);
  468. $resql = $db->query($sql);
  469. if ($resql)
  470. {
  471. $num = $db->num_rows($resql);
  472. print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],"&socid=$socid",$sortfield,$sortorder,'',$num,'','title_accountancy.png');
  473. print $langs->trans("ToCreateAPredefinedInvoice").'<br><br>';
  474. $i = 0;
  475. print '<table class="noborder" width="100%">';
  476. print '<tr class="liste_titre">';
  477. print_liste_field_titre($langs->trans("Ref"));
  478. print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"s.nom","","&socid=$socid","",$sortfiled,$sortorder);
  479. print_liste_field_titre($langs->trans("AmountHT"),'','','','','align="right"');
  480. print_liste_field_titre($langs->trans("AmountVAT"),'','','','','align="right"');
  481. print_liste_field_titre($langs->trans("AmountTTC"),'','','','','align="right"');
  482. print_liste_field_titre(''); // Field may contains ling text
  483. print "</tr>\n";
  484. if ($num > 0)
  485. {
  486. $var=true;
  487. while ($i < min($num,$limit))
  488. {
  489. $objp = $db->fetch_object($resql);
  490. $var=!$var;
  491. print "<tr ".$bc[$var].">";
  492. print '<td><a href="'.$_SERVER['PHP_SELF'].'?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
  493. print "</a></td>\n";
  494. $companystatic->id=$objp->socid;
  495. $companystatic->name=$objp->name;
  496. print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
  497. print '<td align="right">'.price($objp->total).'</td>'."\n";
  498. print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
  499. print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
  500. print '<td align="center">';
  501. if ($user->rights->facture->creer)
  502. {
  503. print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
  504. print $langs->trans("CreateBill").'</a>';
  505. }
  506. else
  507. {
  508. print "&nbsp;";
  509. }
  510. print "</td>";
  511. print "</tr>\n";
  512. $i++;
  513. }
  514. }
  515. else print '<tr><td>'.$langs->trans("NoneF").'</td></tr>';
  516. print "</table>";
  517. $db->free($resql);
  518. }
  519. else
  520. {
  521. dol_print_error($db);
  522. }
  523. }
  524. }
  525. llxFooter();
  526. $db->close();