PageRenderTime 48ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/compta/resultat/index.php

https://bitbucket.org/speedealing/speedealing
PHP | 566 lines | 431 code | 73 blank | 62 comment | 101 complexity | 240a7c82907ee5c1b106cab595819d00 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 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/resultat/index.php
  21. * \brief Page reporting resultat
  22. */
  23. require '../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
  25. $year_start=GETPOST('year_start');
  26. $year_current = strftime("%Y",time());
  27. $nbofyear=4;
  28. if (! $year_start) {
  29. $year_start = $year_current - ($nbofyear-1);
  30. $year_end = $year_current;
  31. }
  32. else {
  33. $year_end=$year_start + ($nbofyear-1);
  34. }
  35. // Security check
  36. $socid = GETPOST('socid','int');
  37. if ($user->societe_id > 0) $socid = $user->societe_id;
  38. if (! $user->rights->compta->resultat->lire && ! $user->rights->accounting->comptarapport->lire)
  39. accessforbidden();
  40. // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
  41. $modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->COMPTA_MODE);
  42. /*
  43. * View
  44. */
  45. llxHeader();
  46. $form=new Form($db);
  47. $nomlink='';
  48. $exportlink='';
  49. // Affiche en-tete du rapport
  50. if ($modecompta == 'CREANCES-DETTES')
  51. {
  52. $nom=$langs->trans("AnnualSummaryDueDebtMode");
  53. $nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
  54. $period="$year_start - $year_end";
  55. $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
  56. $description=$langs->trans("RulesResultDue");
  57. if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
  58. else $description.= $langs->trans("DepositsAreIncluded");
  59. $builddate=time();
  60. //$exportlink=$langs->trans("NotYetAvailable");
  61. }
  62. else {
  63. $nom=$langs->trans("AnnualSummaryInputOutputMode");
  64. $nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
  65. $period="$year_start - $year_end";
  66. $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
  67. $description=$langs->trans("RulesResultInOut");
  68. $builddate=time();
  69. //$exportlink=$langs->trans("NotYetAvailable");
  70. }
  71. report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta));
  72. /*
  73. * Factures clients
  74. */
  75. $subtotal_ht = 0;
  76. $subtotal_ttc = 0;
  77. if ($modecompta == 'CREANCES-DETTES')
  78. {
  79. $sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
  80. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  81. $sql.= ", ".MAIN_DB_PREFIX."facture as f";
  82. $sql.= " WHERE f.fk_soc = s.rowid";
  83. $sql.= " AND f.fk_statut IN (1,2)";
  84. if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
  85. else $sql.= " AND f.type IN (0,1,2,3)";
  86. }
  87. else
  88. {
  89. /*
  90. * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
  91. * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
  92. */
  93. $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
  94. $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
  95. $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
  96. $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
  97. $sql.= " WHERE p.rowid = pf.fk_paiement";
  98. $sql.= " AND pf.fk_facture = f.rowid";
  99. }
  100. $sql.= " AND f.entity = ".$conf->entity;
  101. if ($socid) $sql.= " AND f.fk_soc = $socid";
  102. $sql.= " GROUP BY dm";
  103. $sql.= " ORDER BY dm";
  104. //print $sql;
  105. dol_syslog("get customers invoices sql=".$sql);
  106. $result=$db->query($sql);
  107. if ($result)
  108. {
  109. $num = $db->num_rows($result);
  110. $i = 0;
  111. while ($i < $num)
  112. {
  113. $row = $db->fetch_object($result);
  114. $encaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
  115. $encaiss_ttc[$row->dm] = $row->amount_ttc;
  116. $i++;
  117. }
  118. $db->free($result);
  119. }
  120. else {
  121. dol_print_error($db);
  122. }
  123. // On ajoute les paiements clients anciennes version, non lies par paiement_facture
  124. if ($modecompta != 'CREANCES-DETTES')
  125. {
  126. $sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
  127. $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
  128. $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
  129. $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
  130. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  131. $sql.= " WHERE pf.rowid IS NULL";
  132. $sql.= " AND p.fk_bank = b.rowid";
  133. $sql.= " AND b.fk_account = ba.rowid";
  134. $sql.= " AND ba.entity = ".$conf->entity;
  135. $sql.= " GROUP BY dm";
  136. $sql.= " ORDER BY dm";
  137. dol_syslog("get old customers payments not linked to invoices sql=".$sql);
  138. $result = $db->query($sql);
  139. if ($result) {
  140. $num = $db->num_rows($result);
  141. $i = 0;
  142. while ($i < $num)
  143. {
  144. $row = $db->fetch_object($result);
  145. if (! isset($encaiss[$row->dm])) $encaiss[$row->dm]=0;
  146. $encaiss[$row->dm] += (isset($row->amount_ht)?$row->amount_ht:0);
  147. if (! isset($encaiss_ttc[$row->dm])) $encaiss_ttc[$row->dm]=0;
  148. $encaiss_ttc[$row->dm] += $row->amount_ttc;
  149. $i++;
  150. }
  151. }
  152. else {
  153. dol_print_error($db);
  154. }
  155. }
  156. /*
  157. * Frais, factures fournisseurs.
  158. */
  159. $subtotal_ht = 0;
  160. $subtotal_ttc = 0;
  161. if ($modecompta == 'CREANCES-DETTES')
  162. {
  163. $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
  164. $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
  165. $sql.= " WHERE f.fk_statut IN (1,2)";
  166. if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
  167. else $sql.= " AND f.type IN (0,1,2,3)";
  168. }
  169. else
  170. {
  171. $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
  172. $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
  173. $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
  174. $sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
  175. $sql.= " WHERE f.rowid = pf.fk_facturefourn";
  176. $sql.= " AND p.rowid = pf.fk_paiementfourn";
  177. }
  178. $sql.= " AND f.entity = ".$conf->entity;
  179. if ($socid) $sql.= " AND f.fk_soc = ".$socid;
  180. $sql.= " GROUP BY dm";
  181. dol_syslog("get suppliers invoices sql=".$sql);
  182. $result=$db->query($sql);
  183. if ($result)
  184. {
  185. $num = $db->num_rows($result);
  186. $i = 0;
  187. while ($i < $num)
  188. {
  189. $row = $db->fetch_object($result);
  190. if (! isset($decaiss[$row->dm])) $decaiss[$row->dm]=0;
  191. $decaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
  192. if (! isset($decaiss_ttc[$row->dm])) $decaiss_ttc[$row->dm]=0;
  193. $decaiss_ttc[$row->dm] = $row->amount_ttc;
  194. $i++;
  195. }
  196. $db->free($result);
  197. }
  198. else {
  199. dol_print_error($db);
  200. }
  201. /*
  202. * TVA
  203. */
  204. $subtotal_ht = 0;
  205. $subtotal_ttc = 0;
  206. if ($modecompta == 'CREANCES-DETTES')
  207. {
  208. // TVA a payer
  209. $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm";
  210. $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
  211. $sql.= " WHERE f.fk_statut IN (1,2)";
  212. if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
  213. else $sql.= " AND f.type IN (0,1,2,3)";
  214. $sql.= " AND f.entity = ".$conf->entity;
  215. $sql.= " GROUP BY dm";
  216. dol_syslog("get vat to pay sql=".$sql);
  217. $result=$db->query($sql);
  218. if ($result) {
  219. $num = $db->num_rows($result);
  220. $var=false;
  221. $i = 0;
  222. if ($num) {
  223. while ($i < $num) {
  224. $obj = $db->fetch_object($result);
  225. if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
  226. $decaiss[$obj->dm] += $obj->amount;
  227. if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
  228. $decaiss_ttc[$obj->dm] += $obj->amount;
  229. $i++;
  230. }
  231. }
  232. } else {
  233. dol_print_error($db);
  234. }
  235. // TVA a recuperer
  236. $sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm";
  237. $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
  238. $sql.= " WHERE f.fk_statut IN (1,2)";
  239. if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
  240. else $sql.= " AND f.type IN (0,1,2,3)";
  241. $sql.= " AND f.entity = ".$conf->entity;
  242. $sql.= " GROUP BY dm";
  243. dol_syslog("get vat to receive back sql=".$sql);
  244. $result=$db->query($sql);
  245. if ($result) {
  246. $num = $db->num_rows($result);
  247. $var=false;
  248. $i = 0;
  249. if ($num) {
  250. while ($i < $num) {
  251. $obj = $db->fetch_object($result);
  252. if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
  253. $encaiss[$obj->dm] += $obj->amount;
  254. if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
  255. $encaiss_ttc[$obj->dm] += $obj->amount;
  256. $i++;
  257. }
  258. }
  259. } else {
  260. dol_print_error($db);
  261. }
  262. }
  263. else {
  264. // TVA reellement deja payee
  265. $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
  266. $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
  267. $sql.= " WHERE amount > 0";
  268. $sql.= " AND t.entity = ".$conf->entity;
  269. $sql.= " GROUP BY dm";
  270. dol_syslog("get vat really paid sql=".$sql);
  271. $result=$db->query($sql);
  272. if ($result) {
  273. $num = $db->num_rows($result);
  274. $var=false;
  275. $i = 0;
  276. if ($num) {
  277. while ($i < $num) {
  278. $obj = $db->fetch_object($result);
  279. if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
  280. $decaiss[$obj->dm] += $obj->amount;
  281. if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
  282. $decaiss_ttc[$obj->dm] += $obj->amount;
  283. $i++;
  284. }
  285. }
  286. } else {
  287. dol_print_error($db);
  288. }
  289. // TVA recuperee
  290. $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
  291. $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
  292. $sql.= " WHERE amount < 0";
  293. $sql.= " AND t.entity = ".$conf->entity;
  294. $sql.= " GROUP BY dm";
  295. dol_syslog("get vat really received back sql=".$sql);
  296. $result=$db->query($sql);
  297. if ($result) {
  298. $num = $db->num_rows($result);
  299. $var=false;
  300. $i = 0;
  301. if ($num) {
  302. while ($i < $num) {
  303. $obj = $db->fetch_object($result);
  304. if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
  305. $encaiss[$obj->dm] += $obj->amount;
  306. if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
  307. $encaiss_ttc[$obj->dm] += $obj->amount;
  308. $i++;
  309. }
  310. }
  311. } else {
  312. dol_print_error($db);
  313. }
  314. }
  315. /*
  316. * Charges sociales non deductibles
  317. */
  318. $subtotal_ht = 0;
  319. $subtotal_ttc = 0;
  320. if ($modecompta == 'CREANCES-DETTES')
  321. {
  322. $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
  323. $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
  324. $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
  325. $sql.= " WHERE cs.fk_type = c.id";
  326. $sql.= " AND c.deductible = 0";
  327. }
  328. else
  329. {
  330. $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
  331. $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
  332. $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
  333. $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
  334. $sql.= " WHERE p.fk_charge = cs.rowid";
  335. $sql.= " AND cs.fk_type = c.id";
  336. $sql.= " AND c.deductible = 0";
  337. }
  338. $sql.= " AND cs.entity = ".$conf->entity;
  339. $sql.= " GROUP BY c.libelle, dm";
  340. dol_syslog("get social contributions deductible=0 sql=".$sql);
  341. $result=$db->query($sql);
  342. if ($result) {
  343. $num = $db->num_rows($result);
  344. $var=false;
  345. $i = 0;
  346. if ($num) {
  347. while ($i < $num) {
  348. $obj = $db->fetch_object($result);
  349. if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
  350. $decaiss[$obj->dm] += $obj->amount;
  351. if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
  352. $decaiss_ttc[$obj->dm] += $obj->amount;
  353. $i++;
  354. }
  355. }
  356. } else {
  357. dol_print_error($db);
  358. }
  359. /*
  360. * Charges sociales deductibles
  361. */
  362. $subtotal_ht = 0;
  363. $subtotal_ttc = 0;
  364. if ($modecompta == 'CREANCES-DETTES')
  365. {
  366. $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
  367. $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
  368. $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
  369. $sql.= " WHERE cs.fk_type = c.id";
  370. $sql.= " AND c.deductible = 1";
  371. }
  372. else
  373. {
  374. $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
  375. $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
  376. $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
  377. $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
  378. $sql.= " WHERE p.fk_charge = cs.rowid";
  379. $sql.= " AND cs.fk_type = c.id";
  380. $sql.= " AND c.deductible = 1";
  381. }
  382. $sql.= " AND cs.entity = ".$conf->entity;
  383. $sql.= " GROUP BY c.libelle, dm";
  384. dol_syslog("get social contributions paid deductible=1 sql=".$sql);
  385. $result=$db->query($sql);
  386. if ($result) {
  387. $num = $db->num_rows($result);
  388. $var=false;
  389. $i = 0;
  390. if ($num) {
  391. while ($i < $num) {
  392. $obj = $db->fetch_object($result);
  393. if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
  394. $decaiss[$obj->dm] += $obj->amount;
  395. if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
  396. $decaiss_ttc[$obj->dm] += $obj->amount;
  397. $i++;
  398. }
  399. }
  400. } else {
  401. dol_print_error($db);
  402. }
  403. /*
  404. * Show result array
  405. */
  406. $totentrees=array();
  407. $totsorties=array();
  408. print '<table class="noborder" width="100%">';
  409. print '<tr class="liste_titre"><td class="liste_titre">&nbsp;</td>';
  410. for ($annee = $year_start ; $annee <= $year_end ; $annee++)
  411. {
  412. print '<td align="center" colspan="2">';
  413. print '<a href="clientfourn.php?year='.$annee.'">';
  414. print $annee;
  415. if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
  416. print '</a></td>';
  417. }
  418. print '</tr>';
  419. print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
  420. for ($annee = $year_start ; $annee <= $year_end ; $annee++)
  421. {
  422. print '<td align="right">'.$langs->trans("Outcome").'</td>';
  423. print '<td align="right">'.$langs->trans("Income").'</td>';
  424. }
  425. print '</tr>';
  426. $var=True;
  427. // Loop on each month
  428. $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0;
  429. for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
  430. {
  431. $mois_modulo = $mois;
  432. if($mois>12) {$mois_modulo = $mois-12;}
  433. $var=!$var;
  434. print '<tr '.$bc[$var].'>';
  435. print "<td>".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,$annee),"%B")."</td>";
  436. for ($annee = $year_start ; $annee <= $year_end ; $annee++)
  437. {
  438. $annee_decalage=$annee;
  439. if($mois>12) {$annee_decalage=$annee+1;}
  440. $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage));
  441. print '<td align="right">&nbsp;';
  442. if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
  443. {
  444. print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
  445. if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
  446. $totsorties[$annee]+=$decaiss_ttc[$case];
  447. }
  448. print "</td>";
  449. print '<td align="right">&nbsp;';
  450. if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0)
  451. {
  452. print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($encaiss_ttc[$case],'MT')).'</a>';
  453. if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
  454. $totentrees[$annee]+=$encaiss_ttc[$case];
  455. }
  456. print "</td>";
  457. }
  458. print '</tr>';
  459. }
  460. // Total
  461. $var=!$var;
  462. $nbcols=0;
  463. print '<tr class="liste_total"><td>'.$langs->trans("TotalTTC").'</td>';
  464. for ($annee = $year_start ; $annee <= $year_end ; $annee++)
  465. {
  466. $nbcols+=2;
  467. print '<td align="right">'.(isset($totsorties[$annee])?price(price2num($totsorties[$annee],'MT')):'&nbsp;').'</td>';
  468. print '<td align="right">'.(isset($totentrees[$annee])?price(price2num($totentrees[$annee],'MT')):'&nbsp;').'</td>';
  469. }
  470. print "</tr>\n";
  471. // Empty line
  472. print '<tr><td>&nbsp;</td>';
  473. print '<td colspan="'.$nbcols.'">&nbsp;</td>';
  474. print "</tr>\n";
  475. // Balance
  476. $var=!$var;
  477. print '<tr class="liste_total"><td>'.$langs->trans("Profit").'</td>';
  478. for ($annee = $year_start ; $annee <= $year_end ; $annee++)
  479. {
  480. print '<td align="right" colspan="2"> ';
  481. if (isset($totentrees[$annee]) || isset($totsorties[$annee]))
  482. {
  483. $in=(isset($totentrees[$annee])?price2num($totentrees[$annee], 'MT'):0);
  484. $out=(isset($totsorties[$annee])?price2num($totsorties[$annee],' MT'):0);
  485. print price($in-$out).'</td>';
  486. // print '<td>&nbsp;</td>';
  487. }
  488. }
  489. print "</tr>\n";
  490. print "</table>";
  491. llxFooter();
  492. $db->close();
  493. ?>