PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/compta/index.php

https://bitbucket.org/speedealing/speedealing
PHP | 1044 lines | 854 code | 117 blank | 73 comment | 147 complexity | 1ed3e924093968fc2a9f05ef08a1a78d MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  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 3 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. /**
  20. * \file htdocs/compta/index.php
  21. * \ingroup compta
  22. * \brief Main page of accountancy area
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  28. if (! empty($conf->commande->enabled))
  29. require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  30. if (! empty($conf->commande->enabled))
  31. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  32. if (! empty($conf->tax->enabled))
  33. require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
  34. // L'espace compta/treso doit toujours etre actif car c'est un espace partage
  35. // par de nombreux modules (banque, facture, commande a facturer, etc...) independamment
  36. // de l'utilisation de la compta ou non. C'est au sein de cet espace que chaque sous fonction
  37. // est protegee par le droit qui va bien du module concerne.
  38. //if (!$user->rights->compta->general->lire)
  39. // accessforbidden();
  40. $langs->load("compta");
  41. $langs->load("bills");
  42. if (! empty($conf->commande->enabled))
  43. $langs->load("orders");
  44. $action=GETPOST('action', 'alpha');
  45. $bid=GETPOST('bid', 'int');
  46. // Security check
  47. $socid='';
  48. if ($user->societe_id > 0)
  49. {
  50. $action = '';
  51. $socid = $user->societe_id;
  52. }
  53. /*
  54. * Actions
  55. */
  56. if ($action == 'add_bookmark')
  57. {
  58. $now=dol_now();
  59. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socid." AND fk_user=".$user->id;
  60. if (! $db->query($sql) )
  61. {
  62. dol_print_error($db);
  63. }
  64. $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate($now).",".$user->id.");";
  65. if (! $db->query($sql) )
  66. {
  67. dol_print_error($db);
  68. }
  69. }
  70. if ($action == 'del_bookmark' && ! empty($bid))
  71. {
  72. $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$db->escape($bid);
  73. $result = $db->query($sql);
  74. }
  75. /*
  76. * View
  77. */
  78. $now=dol_now();
  79. $facturestatic=new Facture($db);
  80. $facturesupplierstatic=new FactureFournisseur($db);
  81. $form = new Form($db);
  82. $formfile = new FormFile($db);
  83. $thirdpartystatic = new Societe($db);
  84. llxHeader("",$langs->trans("AccountancyTreasuryArea"));
  85. print_fiche_titre($langs->trans("AccountancyTreasuryArea"));
  86. print '<table border="0" width="100%" class="notopnoleftnoright">';
  87. print '<tr>';
  88. print '<td valign="top" width="30%" class="notopnoleft">';
  89. $max=3;
  90. /*
  91. * Search invoices
  92. */
  93. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  94. {
  95. print '<form method="post" action="'.DOL_URL_ROOT.'/compta/facture/list.php">';
  96. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  97. print '<table class="noborder nohover" width="100%">';
  98. print "<tr class=\"liste_titre\">";
  99. print '<td colspan="3">'.$langs->trans("SearchACustomerInvoice").'</td></tr>';
  100. print "<tr $bc[0]><td>".$langs->trans("Ref").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>';
  101. print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
  102. print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
  103. print '</tr>';
  104. print "</table></form><br>";
  105. }
  106. /*
  107. * Search supplier invoices
  108. */
  109. if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
  110. {
  111. print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/facture/index.php">';
  112. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  113. print '<table class="noborder nohover" width="100%">';
  114. print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASupplierInvoice").'</td></tr>';
  115. print "<tr ".$bc[0].">";
  116. print "<td>".$langs->trans("Ref").':</td><td><input type="text" name="search_ref" class="flat" size="18"></td>';
  117. print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
  118. print "<tr $bc[0]><td>".$langs->trans("RefSupplier").':</td><td><input type="text" name="search_ref_supplier" class="flat" size="18"></td>';
  119. print '</tr>';
  120. print "</table></form><br>";
  121. }
  122. /*
  123. * Search donations
  124. */
  125. if (! empty($conf->don->enabled) && $user->rights->don->lire)
  126. {
  127. print '<form method="post" action="'.DOL_URL_ROOT.'/compta/dons/liste.php">';
  128. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  129. print '<table class="noborder nohover" width="100%">';
  130. print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchADonation").'</td></tr>';
  131. print "<tr ".$bc[0].">";
  132. print "<td>".$langs->trans("Ref").':</td><td><input type="text" name="search_ref" class="flat" size="18"></td>';
  133. print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  134. //print "<tr ".$bc[0]."><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
  135. print '</tr>';
  136. print "</table></form><br>";
  137. }
  138. /*
  139. * Search expenses
  140. */
  141. if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
  142. {
  143. print '<form method="post" action="'.DOL_URL_ROOT.'/compta/deplacement/list.php">';
  144. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  145. print '<table class="noborder nohover" width="100%">';
  146. print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchATripAndExpense").'</td></tr>';
  147. print "<tr ".$bc[0].">";
  148. print "<td>".$langs->trans("Ref").':</td><td><input type="text" name="search_ref" class="flat" size="18"></td>';
  149. print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  150. //print "<tr ".$bc[0]."><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
  151. print '</tr>';
  152. print "</table></form><br>";
  153. }
  154. /**
  155. * Draft customers invoices
  156. */
  157. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  158. {
  159. $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
  160. $sql.= " s.nom, s.rowid as socid";
  161. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
  162. $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
  163. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  164. $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
  165. $sql.= " AND f.entity = ".$conf->entity;
  166. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  167. if ($socid)
  168. {
  169. $sql .= " AND f.fk_soc = $socid";
  170. }
  171. $resql = $db->query($sql);
  172. if ( $resql )
  173. {
  174. $var = false;
  175. $num = $db->num_rows($resql);
  176. print '<table class="noborder" width="100%">';
  177. print '<tr class="liste_titre">';
  178. print '<td colspan="3">'.$langs->trans("CustomersDraftInvoices").($num?' ('.$num.')':'').'</td></tr>';
  179. if ($num)
  180. {
  181. $companystatic=new Societe($db);
  182. $i = 0;
  183. $tot_ttc = 0;
  184. while ($i < $num && $i < 20)
  185. {
  186. $obj = $db->fetch_object($resql);
  187. print '<tr '.$bc[$var].'><td nowrap="nowrap">';
  188. $facturestatic->ref=$obj->facnumber;
  189. $facturestatic->id=$obj->rowid;
  190. $facturestatic->type=$obj->type;
  191. print $facturestatic->getNomUrl(1,'');
  192. print '</td>';
  193. print '<td nowrap="nowrap">';
  194. $companystatic->id=$obj->socid;
  195. $companystatic->nom=$obj->nom;
  196. $companystatic->client=1;
  197. print $companystatic->getNomUrl(1,'',16);
  198. print '</td>';
  199. print '<td align="right" nowrap="nowrap">'.price($obj->total_ttc).'</td>';
  200. print '</tr>';
  201. $tot_ttc+=$obj->total_ttc;
  202. $i++;
  203. $var=!$var;
  204. }
  205. print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
  206. print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
  207. print '</tr>';
  208. }
  209. else
  210. {
  211. print '<tr colspan="3" '.$bc[$var].'><td>'.$langs->trans("NoInvoice").'</td></tr>';
  212. }
  213. print "</table><br>";
  214. $db->free($resql);
  215. }
  216. else
  217. {
  218. dol_print_error($db);
  219. }
  220. }
  221. /**
  222. * Draft suppliers invoices
  223. */
  224. if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
  225. {
  226. $sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
  227. $sql.= " s.nom, s.rowid as socid";
  228. $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
  229. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  230. $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
  231. $sql.= " AND f.entity = ".$conf->entity;
  232. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  233. if ($socid) $sql.= " AND f.fk_soc = ".$socid;
  234. $resql = $db->query($sql);
  235. if ( $resql )
  236. {
  237. $var = false;
  238. $num = $db->num_rows($resql);
  239. print '<table class="noborder" width="100%">';
  240. print '<tr class="liste_titre">';
  241. print '<td colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num?' ('.$num.')':'').'</td></tr>';
  242. if ($num)
  243. {
  244. $companystatic=new Societe($db);
  245. $i = 0;
  246. $tot_ttc = 0;
  247. while ($i < $num && $i < 20)
  248. {
  249. $obj = $db->fetch_object($resql);
  250. print '<tr '.$bc[$var].'><td nowrap>';
  251. $facturesupplierstatic->ref=$obj->facnumber;
  252. $facturesupplierstatic->id=$obj->rowid;
  253. $facturesupplierstatic->type=$obj->type;
  254. print $facturesupplierstatic->getNomUrl(1,'',16);
  255. print '</td>';
  256. print '<td>';
  257. $companystatic->id=$obj->socid;
  258. $companystatic->nom=$obj->nom;
  259. $companystatic->client=1;
  260. print $companystatic->getNomUrl(1,'',16);
  261. print '</td>';
  262. print '<td align="right">'.price($obj->total_ttc).'</td>';
  263. print '</tr>';
  264. $tot_ttc+=$obj->total_ttc;
  265. $i++;
  266. $var=!$var;
  267. }
  268. print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
  269. print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
  270. print '</tr>';
  271. }
  272. else
  273. {
  274. print '<tr colspan="3" '.$bc[$var].'><td>'.$langs->trans("NoInvoice").'</td></tr>';
  275. }
  276. print "</table><br>";
  277. $db->free($resql);
  278. }
  279. else
  280. {
  281. dol_print_error($db);
  282. }
  283. }
  284. print '</td>';
  285. print '<td valign="top" width="70%" class="notopnoleftnoright">';
  286. // Last modified customer invoices
  287. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  288. {
  289. $langs->load("boxes");
  290. $facstatic=new Facture($db);
  291. $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.total_ttc, f.paye, f.tms,";
  292. $sql.= " f.date_lim_reglement as datelimite,";
  293. $sql.= " s.nom, s.rowid as socid,";
  294. $sql.= " sum(pf.amount) as am";
  295. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
  296. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
  297. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  298. $sql.= " WHERE s.rowid = f.fk_soc";
  299. $sql.= " AND f.entity = ".$conf->entity;
  300. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  301. if ($socid) $sql.= " AND f.fk_soc = ".$socid;
  302. $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid";
  303. $sql.= " ORDER BY f.tms DESC ";
  304. $sql.= $db->plimit($max, 0);
  305. $resql = $db->query($sql);
  306. if ($resql)
  307. {
  308. $var=false;
  309. $num = $db->num_rows($resql);
  310. $i = 0;
  311. print '<table class="noborder" width="100%">';
  312. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BoxTitleLastCustomerBills",$max).'</td>';
  313. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
  314. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  315. print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
  316. print '<td width="16">&nbsp;</td>';
  317. print '</tr>';
  318. if ($num)
  319. {
  320. $total_ttc = $totalam = $total = 0;
  321. while ($i < $num && $i < $conf->liste_limit)
  322. {
  323. $obj = $db->fetch_object($resql);
  324. print '<tr '.$bc[$var].'>';
  325. print '<td nowrap="nowrap">';
  326. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  327. print '<td width="100" class="nobordernopadding" nowrap="nowrap">';
  328. $facturestatic->ref=$obj->facnumber;
  329. $facturestatic->id=$obj->rowid;
  330. $facturestatic->type=$obj->type;
  331. print $facturestatic->getNomUrl(1,'');
  332. print '</td>';
  333. print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
  334. if ($obj->fk_statut == 1 && ! $obj->paye && $db->jdate($obj->datelimite) < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
  335. print '</td>';
  336. print '<td width="16" align="right" class="nobordernopadding">';
  337. $filename=dol_sanitizeFileName($obj->facnumber);
  338. $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
  339. $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid;
  340. print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
  341. print '</td></tr></table>';
  342. print '</td>';
  343. print '<td align="left">';
  344. $thirdpartystatic->id=$obj->socid;
  345. $thirdpartystatic->nom=$obj->nom;
  346. $thirdpartystatic->client=1;
  347. print $thirdpartystatic->getNomUrl(1,'customer',44);
  348. print '</td>';
  349. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total).'</td>';
  350. print '<td align="right">'.price($obj->total_ttc).'</td>';
  351. print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
  352. print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
  353. print '</tr>';
  354. $total_ttc += $obj->total_ttc;
  355. $total += $obj->total;
  356. $totalam += $obj->am;
  357. $var=!$var;
  358. $i++;
  359. }
  360. }
  361. else
  362. {
  363. $colspan=5;
  364. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
  365. print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">'.$langs->trans("NoInvoice").'</td></tr>';
  366. }
  367. print '</table><br>';
  368. $db->free($resql);
  369. }
  370. else
  371. {
  372. dol_print_error($db);
  373. }
  374. }
  375. // Last modified supplier invoices
  376. if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
  377. {
  378. $langs->load("boxes");
  379. $facstatic=new FactureFournisseur($db);
  380. $sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.tms, ff.paye";
  381. $sql.= ", s.nom, s.rowid as socid";
  382. $sql.= ", SUM(pf.amount) as am";
  383. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
  384. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
  385. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  386. $sql.= " WHERE s.rowid = ff.fk_soc";
  387. $sql.= " AND ff.entity = ".$conf->entity;
  388. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
  389. if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
  390. $sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid";
  391. $sql.= " ORDER BY ff.tms DESC ";
  392. $sql.= $db->plimit($max, 0);
  393. $resql=$db->query($sql);
  394. if ($resql)
  395. {
  396. $var=false;
  397. $num = $db->num_rows($resql);
  398. print '<table class="noborder" width="100%">';
  399. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BoxTitleLastSupplierBills",$max).'</td>';
  400. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
  401. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  402. print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
  403. print '<td width="16">&nbsp;</td>';
  404. print "</tr>\n";
  405. if ($num)
  406. {
  407. $i = 0;
  408. $total = $total_ttc = $totalam = 0;
  409. while ($i < $num)
  410. {
  411. $obj = $db->fetch_object($resql);
  412. print '<tr '.$bc[$var].'><td>';
  413. $facstatic->ref=$obj->facnumber;
  414. $facstatic->id=$obj->rowid;
  415. print $facstatic->getNomUrl(1,'');
  416. print '</td>';
  417. print '<td>';
  418. $thirdpartystatic->id=$obj->socid;
  419. $thirdpartystatic->nom=$obj->nom;
  420. $thirdpartystatic->fournisseur=1;
  421. print $thirdpartystatic->getNomUrl(1,'supplier',44);
  422. print '</td>';
  423. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
  424. print '<td align="right">'.price($obj->total_ttc).'</td>';
  425. print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
  426. print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3).'</td>';
  427. print '</tr>';
  428. $total += $obj->total_ht;
  429. $total_ttc += $obj->total_ttc;
  430. $totalam += $obj->am;
  431. $i++;
  432. $var = !$var;
  433. }
  434. }
  435. else
  436. {
  437. $colspan=5;
  438. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
  439. print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">'.$langs->trans("NoInvoice").'</td></tr>';
  440. }
  441. print '</table><br>';
  442. }
  443. else
  444. {
  445. dol_print_error($db);
  446. }
  447. }
  448. // Last donations
  449. if (! empty($conf->don->enabled) && $user->rights->societe->lire)
  450. {
  451. include_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
  452. $langs->load("boxes");
  453. $donationstatic=new Don($db);
  454. $sql = "SELECT d.rowid, d.nom, d.prenom, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut";
  455. $sql.= " FROM ".MAIN_DB_PREFIX."don as d";
  456. $sql.= " WHERE d.entity = ".$conf->entity;
  457. $sql.= $db->order("d.tms","DESC");
  458. $sql.= $db->plimit($max, 0);
  459. $result = $db->query($sql);
  460. if ($result)
  461. {
  462. $var=false;
  463. $num = $db->num_rows($result);
  464. $i = 0;
  465. print '<table class="noborder" width="100%">';
  466. print '<tr class="liste_titre"><td>'.$langs->trans("BoxTitleLastModifiedDonations",$max).'</td>';
  467. print '<td class="liste_titre" align="right">'.$langs->trans("AmountTTC").'</td>';
  468. print '<td class="liste_titre" align="right">'.$langs->trans("DateModificationShort").'</td>';
  469. print '<td class="liste_titre" width="16">&nbsp;</td>';
  470. print '</tr>';
  471. if ($num)
  472. {
  473. $var = True;
  474. $total_ttc = $totalam = $total = 0;
  475. $var=true;
  476. while ($i < $num && $i < $max)
  477. {
  478. $objp = $db->fetch_object($result);
  479. $var=!$var;
  480. print '<tr '.$bc[$var].'>';
  481. $donationstatic->id=$objp->rowid;
  482. $donationstatic->nom=$objp->nom;
  483. $donationstatic->prenom=$objp->prenom;
  484. $label=$donationstatic->getFullName($langs);
  485. if ($objp->societe) $label.=($label?' - ':'').$objp->societe;
  486. $donationstatic->ref=$label;
  487. print '<td>'.$donationstatic->getNomUrl(1).'</td>';
  488. print '<td align="right">'.price($objp->amount).'</td>';
  489. print '<td align="right">'.dol_print_date($db->jdate($objp->dm),'day').'</td>';
  490. print '<td>'.$donationstatic->LibStatut($objp->fk_statut,3).'</td>';
  491. print '</tr>';
  492. $i++;
  493. }
  494. }
  495. else
  496. {
  497. print '<tr '.$bc[$var].'><td colspan="4">'.$langs->trans("None").'</td></tr>';
  498. }
  499. print '</table><br>';
  500. }
  501. else dol_print_error($db);
  502. }
  503. // Last trips and expenses
  504. if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
  505. {
  506. include_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
  507. $langs->load("boxes");
  508. $sql = "SELECT u.rowid as uid, u.name, u.firstname, d.fk_statut, d.rowid, d.dated as date, d.tms as dm, d.km";
  509. $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u";
  510. if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  511. $sql.= " WHERE u.rowid = d.fk_user";
  512. $sql.= " AND d.entity = ".$conf->entity;
  513. if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  514. if ($socid) $sql.= " AND d.fk_soc = ".$socid;
  515. $sql.= $db->order("d.tms","DESC");
  516. $sql.= $db->plimit($max, 0);
  517. $result = $db->query($sql);
  518. if ($result)
  519. {
  520. $var=false;
  521. $num = $db->num_rows($result);
  522. $i = 0;
  523. print '<table class="noborder" width="100%">';
  524. print '<tr class="liste_titre">';
  525. print '<td colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses",$max).'</td>';
  526. print '<td align="right">'.$langs->trans("FeesKilometersOrAmout").'</td>';
  527. print '<td align="right">'.$langs->trans("DateModificationShort").'</td>';
  528. print '<td width="16">&nbsp;</td>';
  529. print '</tr>';
  530. if ($num)
  531. {
  532. $total_ttc = $totalam = $total = 0;
  533. $deplacementstatic=new Deplacement($db);
  534. $userstatic=new User($db);
  535. while ($i < $num && $i < $max)
  536. {
  537. $objp = $db->fetch_object($result);
  538. $deplacementstatic->ref=$objp->rowid;
  539. $deplacementstatic->id=$objp->rowid;
  540. $userstatic->id=$objp->uid;
  541. $userstatic->lastname=$objp->name;
  542. $userstatic->firstname=$objp->firstname;
  543. print '<tr '.$bc[$var].'>';
  544. print '<td>'.$deplacementstatic->getNomUrl(1).'</td>';
  545. print '<td>'.$userstatic->getNomUrl(1).'</td>';
  546. print '<td align="right">'.$objp->km.'</td>';
  547. print '<td align="right">'.dol_print_date($db->jdate($objp->dm),'day').'</td>';
  548. print '<td>'.$deplacementstatic->LibStatut($objp->fk_statut,3).'</td>';
  549. print '</tr>';
  550. $var=!$var;
  551. $i++;
  552. }
  553. }
  554. else
  555. {
  556. print '<tr '.$bc[$var].'><td colspan="5">'.$langs->trans("None").'</td></tr>';
  557. }
  558. print '</table><br>';
  559. }
  560. else dol_print_error($db);
  561. }
  562. /**
  563. * Social contributions to pay
  564. */
  565. if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
  566. {
  567. if (!$socid)
  568. {
  569. $chargestatic=new ChargeSociales($db);
  570. $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,";
  571. $sql.= " cc.libelle,";
  572. $sql.= " SUM(pc.amount) as sumpaid";
  573. $sql.= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)";
  574. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid";
  575. $sql.= " WHERE c.fk_type = cc.id";
  576. $sql.= " AND c.entity = ".$conf->entity;
  577. $sql.= " AND c.paye = 0";
  578. $sql.= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle";
  579. $resql = $db->query($sql);
  580. if ( $resql )
  581. {
  582. $var = false;
  583. $num = $db->num_rows($resql);
  584. print '<table class="noborder" width="100%">';
  585. print '<tr class="liste_titre">';
  586. print '<td>'.$langs->trans("ContributionsToPay").($num?' ('.$num.')':'').'</td>';
  587. print '<td align="center">'.$langs->trans("DateDue").'</td>';
  588. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  589. print '<td align="right">'.$langs->trans("Paid").'</td>';
  590. print '<td>&nbsp;</td>';
  591. print '</tr>';
  592. if ($num)
  593. {
  594. $i = 0;
  595. $tot_ttc=0;
  596. while ($i < $num)
  597. {
  598. $obj = $db->fetch_object($resql);
  599. print "<tr $bc[$var]>";
  600. $chargestatic->id=$obj->rowid;
  601. $chargestatic->ref=$obj->libelle;
  602. $chargestatic->lib=$obj->libelle;
  603. $chargestatic->paye=$obj->paye;
  604. print '<td>'.$chargestatic->getNomUrl(1).'</td>';
  605. print '<td align="center">'.dol_print_date($obj->date_ech,'day').'</td>';
  606. print '<td align="right">'.price($obj->amount).'</td>';
  607. print '<td align="right">'.price($obj->sumpaid).'</td>';
  608. print '<td align="center">'.$chargestatic->getLibStatut(3).'</td>';
  609. print '</tr>';
  610. $tot_ttc+=$obj->amount;
  611. $var = !$var;
  612. $i++;
  613. }
  614. print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("Total").'</td>';
  615. print '<td align="right">'.price($tot_ttc).'</td>';
  616. print '<td align="right"></td>';
  617. print '<td align="right">&nbsp</td>';
  618. print '</tr>';
  619. }
  620. else
  621. {
  622. print '<tr '.$bc[$var].'><td colspan="5">'.$langs->trans("None").'</td></tr>';
  623. }
  624. print "</table><br>";
  625. $db->free($resql);
  626. }
  627. else
  628. {
  629. dol_print_error($db);
  630. }
  631. }
  632. }
  633. /*
  634. * Customers orders to be billed
  635. */
  636. if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $user->rights->commande->lire)
  637. {
  638. $commandestatic=new Commande($db);
  639. $langs->load("orders");
  640. $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc,";
  641. $sql.= " s.nom, s.rowid as socid,";
  642. $sql.= " c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_ttc";
  643. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  644. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  645. $sql.= ", ".MAIN_DB_PREFIX."commande as c";
  646. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
  647. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'";
  648. $sql.= " WHERE c.fk_soc = s.rowid";
  649. $sql.= " AND c.entity = ".$conf->entity;
  650. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  651. if ($socid) $sql.= " AND c.fk_soc = ".$socid;
  652. $sql.= " AND c.fk_statut = 3";
  653. $sql.= " AND c.facture = 0";
  654. $sql.= " GROUP BY s.nom, s.rowid, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_ttc";
  655. $resql = $db->query($sql);
  656. if ( $resql )
  657. {
  658. $var=false;
  659. $num = $db->num_rows($resql);
  660. if ($num)
  661. {
  662. $i = 0;
  663. print '<table class="noborder" width="100%">';
  664. print "<tr class=\"liste_titre\">";
  665. print '<td colspan="2">'.$langs->trans("OrdersToBill").' <a href="'.DOL_URL_ROOT.'/commande/liste.php?status=3&afacturer=1">('.$num.')</a></td>';
  666. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
  667. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  668. print '<td align="right">'.$langs->trans("ToBill").'</td>';
  669. print '<td align="center" width="16">&nbsp;</td>';
  670. print '</tr>';
  671. $tot_ht=$tot_ttc=$tot_tobill=0;
  672. $societestatic = new Societe($db);
  673. while ($i < $num)
  674. {
  675. $obj = $db->fetch_object($resql);
  676. print "<tr $bc[$var]>";
  677. print '<td nowrap="nowrap">';
  678. $commandestatic->id=$obj->rowid;
  679. $commandestatic->ref=$obj->ref;
  680. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  681. print '<td width="100" class="nobordernopadding" nowrap="nowrap">';
  682. print $commandestatic->getNomUrl(1);
  683. print '</td>';
  684. print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
  685. print '&nbsp;';
  686. print '</td>';
  687. print '<td width="16" align="right" class="nobordernopadding">';
  688. $filename=dol_sanitizeFileName($obj->ref);
  689. $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
  690. $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
  691. print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
  692. print '</td></tr></table>';
  693. print '</td>';
  694. print '<td align="left">';
  695. $societestatic->id=$obj->socid;
  696. $societestatic->nom=$obj->nom;
  697. $societestatic->client=1;
  698. print $societestatic->getNomUrl(1,'customer',44);
  699. print '</a></td>';
  700. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
  701. print '<td align="right">'.price($obj->total_ttc).'</td>';
  702. print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td>';
  703. print '<td>'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,3).'</td>';
  704. print '</tr>';
  705. $tot_ht += $obj->total_ht;
  706. $tot_ttc += $obj->total_ttc;
  707. //print "x".$tot_ttc."z".$obj->tot_fttc;
  708. $tot_tobill += ($obj->total_ttc-$obj->tot_fttc);
  709. $i++;
  710. $var=!$var;
  711. }
  712. print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>';
  713. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($tot_ht).'</td>';
  714. print '<td align="right">'.price($tot_ttc).'</td>';
  715. print '<td align="right">'.price($tot_tobill).'</td>';
  716. print '<td>&nbsp;</td>';
  717. print '</tr>';
  718. print '</table><br>';
  719. }
  720. $db->free($resql);
  721. }
  722. else
  723. {
  724. dol_print_error($db);
  725. }
  726. }
  727. /*
  728. * Unpaid customers invoices
  729. */
  730. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  731. {
  732. $facstatic=new Facture($db);
  733. $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.total_ttc, f.paye, f.tms,";
  734. $sql.= " f.date_lim_reglement as datelimite,";
  735. $sql.= " s.nom, s.rowid as socid,";
  736. $sql.= " sum(pf.amount) as am";
  737. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
  738. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
  739. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  740. $sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
  741. $sql.= " AND f.entity = ".$conf->entity;
  742. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  743. if ($socid) $sql.= " AND f.fk_soc = ".$socid;
  744. $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid";
  745. $sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
  746. $resql = $db->query($sql);
  747. if ($resql)
  748. {
  749. $var=false;
  750. $num = $db->num_rows($resql);
  751. $i = 0;
  752. print '<table class="noborder" width="100%">';
  753. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/compta/facture/impayees.php">('.$num.')</a></td>';
  754. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
  755. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  756. print '<td align="right">'.$langs->trans("Received").'</td>';
  757. print '<td width="16">&nbsp;</td>';
  758. print '</tr>';
  759. if ($num)
  760. {
  761. $societestatic = new Societe($db);
  762. $total_ttc = $totalam = $total = 0;
  763. while ($i < $num && $i < $conf->liste_limit)
  764. {
  765. $obj = $db->fetch_object($resql);
  766. print '<tr '.$bc[$var].'>';
  767. print '<td nowrap="nowrap">';
  768. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  769. print '<td width="100" class="nobordernopadding" nowrap="nowrap">';
  770. $facturestatic->ref=$obj->facnumber;
  771. $facturestatic->id=$obj->rowid;
  772. $facturestatic->type=$obj->type;
  773. print $facturestatic->getNomUrl(1,'');
  774. print '</td>';
  775. print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
  776. if ($db->jdate($obj->datelimite) < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
  777. print '</td>';
  778. print '<td width="16" align="right" class="nobordernopadding">';
  779. $filename=dol_sanitizeFileName($obj->facnumber);
  780. $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
  781. $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid;
  782. print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
  783. print '</td></tr></table>';
  784. print '</td>';
  785. print '<td align="left">' ;
  786. $societestatic->id=$obj->socid;
  787. $societestatic->nom=$obj->nom;
  788. $societestatic->client=1;
  789. print $societestatic->getNomUrl(1,'customer',44);
  790. print '</a></td>';
  791. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total).'</td>';
  792. print '<td align="right">'.price($obj->total_ttc).'</td>';
  793. print '<td align="right">'.price($obj->am).'</td>';
  794. print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
  795. print '</tr>';
  796. $total_ttc += $obj->total_ttc;
  797. $total += $obj->total;
  798. $totalam += $obj->am;
  799. $var=!$var;
  800. $i++;
  801. }
  802. print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</font> </td>';
  803. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($total).'</td>';
  804. print '<td align="right">'.price($total_ttc).'</td>';
  805. print '<td align="right">'.price($totalam).'</td>';
  806. print '<td>&nbsp;</td>';
  807. print '</tr>';
  808. }
  809. else
  810. {
  811. $colspan=5;
  812. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
  813. print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">'.$langs->trans("NoInvoice").'</td></tr>';
  814. }
  815. print '</table><br>';
  816. $db->free($resql);
  817. }
  818. else
  819. {
  820. dol_print_error($db);
  821. }
  822. }
  823. /*
  824. * Unpayed supplier invoices
  825. */
  826. if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
  827. {
  828. $facstatic=new FactureFournisseur($db);
  829. $sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.paye,";
  830. $sql.= " s.nom, s.rowid as socid,";
  831. $sql.= " sum(pf.amount) as am";
  832. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
  833. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
  834. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  835. $sql.= " WHERE s.rowid = ff.fk_soc";
  836. $sql.= " AND ff.entity = ".$conf->entity;
  837. $sql.= " AND ff.paye = 0";
  838. $sql.= " AND ff.fk_statut = 1";
  839. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
  840. if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
  841. $sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.rowid";
  842. $resql=$db->query($sql);
  843. if ($resql)
  844. {
  845. $var=false;
  846. $num = $db->num_rows($resql);
  847. print '<table class="noborder" width="100%">';
  848. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsSuppliersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/fourn/facture/impayees.php">('.$num.')</a></td>';
  849. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
  850. print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
  851. print '<td align="right">'.$langs->trans("Paid").'</td>';
  852. print '<td width="16">&nbsp;</td>';
  853. print "</tr>\n";
  854. $societestatic = new Societe($db);
  855. if ($num)
  856. {
  857. $i = 0;
  858. $total = $total_ttc = $totalam = 0;
  859. while ($i < $num)
  860. {
  861. $obj = $db->fetch_object($resql);
  862. print '<tr '.$bc[$var].'><td>';
  863. $facstatic->ref=$obj->facnumber;
  864. $facstatic->id=$obj->rowid;
  865. print $facstatic->getNomUrl(1,'');
  866. print '</td>';
  867. $societestatic->id=$obj->socid;
  868. $societestatic->nom=$obj->nom;
  869. $societestatic->client=0;
  870. print '<td>'.$societestatic->getNomUrl(1, 'supplier', 44).'</td>';
  871. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
  872. print '<td align="right">'.price($obj->total_ttc).'</td>';
  873. print '<td align="right">'.price($obj->am).'</td>';
  874. print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3).'</td>';
  875. print '</tr>';
  876. $total += $obj->total_ht;
  877. $total_ttc += $obj->total_ttc;
  878. $totalam += $obj->am;
  879. $i++;
  880. $var = !$var;
  881. }
  882. print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</font> </td>';
  883. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($total).'</td>';
  884. print '<td align="right">'.price($total_ttc).'</td>';
  885. print '<td align="right">'.price($totalam).'</td>';
  886. print '<td>&nbsp;</td>';
  887. print '</tr>';
  888. }
  889. else
  890. {
  891. $colspan=5;
  892. if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
  893. print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">'.$langs->trans("NoInvoice").'</td></tr>';
  894. }
  895. print '</table><br>';
  896. }
  897. else
  898. {
  899. dol_print_error($db);
  900. }
  901. }
  902. // TODO Mettre ici recup des actions en rapport avec la compta
  903. $resql = 0;
  904. if ($resql)
  905. {
  906. print '<table class="noborder" width="100%">';
  907. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TasksToDo").'</td>';
  908. print "</tr>\n";
  909. $var = True;
  910. $i = 0;
  911. while ($i < $db->num_rows($resql))
  912. {
  913. $obj = $db->fetch_object($resql);
  914. $var=!$var;
  915. print "<tr $bc[$var]><td>".dol_print_date($obj->da,"day")."</td>";
  916. print "<td><a href=\"action/fiche.php\">$obj->libelle $obj->label</a></td></tr>";
  917. $i++;
  918. }
  919. $db->free($resql);
  920. print "</table><br>";
  921. }
  922. print '</td></tr>';
  923. print '</table>';
  924. dol_fiche_end();
  925. llxFooter();
  926. $db->close();
  927. ?>