dolibarr 20.0.0
supplier_turnover.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23// Load Dolibarr environment
24require '../../main.inc.php';
25require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
27
28// Load translation files required by the page
29$langs->loadLangs(array('compta', 'bills'));
30
31$date_startday = GETPOSTINT('date_startday');
32$date_startmonth = GETPOSTINT('date_startmonth');
33$date_startyear = GETPOSTINT('date_startyear');
34$date_endday = GETPOSTINT('date_endday');
35$date_endmonth = GETPOSTINT('date_endmonth');
36$date_endyear = GETPOSTINT('date_endyear');
37
38$nbofyear = 4;
39
40// Date range
41$year = GETPOSTINT('year');
42if (empty($year)) {
43 $year_current = (int) dol_print_date(dol_now(), "%Y");
44 $month_current = (int) dol_print_date(dol_now(), "%m");
45 $year_start = $year_current - ($nbofyear - 1);
46} else {
47 $year_current = $year;
48 $month_current = (int) dol_print_date(dol_now(), "%m");
49 $year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
50}
51$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
52$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzserver'); // We use timezone of server so report is same from everywhere
53
54// We define date_start and date_end
55if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
56 $q = GETPOSTINT("q");
57 if (empty($q)) {
58 // We define date_start and date_end
59 $year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
60 $month_start = GETPOSTISSET("month") ? GETPOSTINT("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
61 if (!GETPOST('month')) { // If month not forced
62 if (!$year && $month_start > $month_current) {
63 $year_start--;
64 $year_end--;
65 }
66 $month_end = $month_start - 1;
67 if ($month_end < 1) {
68 $month_end = 12;
69 }
70 } else {
71 $month_end = $month_start;
72 }
73 $date_start = dol_get_first_day($year_start, $month_start, false);
74 $date_end = dol_get_last_day($year_end, $month_end, false);
75 }
76 if ($q == 1) {
77 $date_start = dol_get_first_day($year_start, 1, false);
78 $date_end = dol_get_last_day($year_start, 3, false);
79 }
80 if ($q == 2) {
81 $date_start = dol_get_first_day($year_start, 4, false);
82 $date_end = dol_get_last_day($year_start, 6, false);
83 }
84 if ($q == 3) {
85 $date_start = dol_get_first_day($year_start, 7, false);
86 $date_end = dol_get_last_day($year_start, 9, false);
87 }
88 if ($q == 4) {
89 $date_start = dol_get_first_day($year_start, 10, false);
90 $date_end = dol_get_last_day($year_start, 12, false);
91 }
92}
93
94$userid = GETPOSTINT('userid');
95$socid = GETPOSTINT('socid');
96
97$tmps = dol_getdate($date_start);
98$month_start = $tmps['mon'];
99$year_start = $tmps['year'];
100$tmpe = dol_getdate($date_end);
101$month_end = $tmpe['mon'];
102$year_end = $tmpe['year'];
103$nbofyear = ($year_end - $year_start) + 1;
104
105// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
106$modecompta = getDolGlobalString('ACCOUNTING_MODE');
107if (isModEnabled('accounting')) {
108 $modecompta = 'BOOKKEEPING';
109}
110if (GETPOST("modecompta", 'alpha')) {
111 $modecompta = GETPOST("modecompta", 'alpha');
112}
113
114// Security check
115if ($user->socid > 0) {
116 $socid = $user->socid;
117}
118if (isModEnabled('comptabilite')) {
119 $result = restrictedArea($user, 'compta', '', '', 'resultat');
120}
121if (isModEnabled('accounting')) {
122 $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
123}
124
125
126/*
127 * View
128 */
129
130llxHeader();
131
132$form = new Form($db);
133
134$exportlink = '';
135$namelink = '';
136$builddate = dol_now();
137
138// TODO Report from bookkeeping not yet available, so we switch on report on business events
139/*if ($modecompta == "BOOKKEEPING") {
140 $modecompta = "CREANCES-DETTES";
141}*/
142if ($modecompta == "BOOKKEEPINGCOLLECTED") {
143 $modecompta = "RECETTES-DEPENSES";
144}
145
146// Affiche en-tete du rapport
147if ($modecompta == "CREANCES-DETTES") {
148 $name = $langs->trans("PurchaseTurnover");
149 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
150 $description = $langs->trans("RulesPurchaseTurnoverDue");
151 //$exportlink=$langs->trans("NotYetAvailable");
152} elseif ($modecompta == "RECETTES-DEPENSES") {
153 $name = $langs->trans("PurchaseTurnoverCollected");
154 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
155 $description = $langs->trans("RulesPurchaseTurnoverIn");
156 //$exportlink=$langs->trans("NotYetAvailable");
157} elseif ($modecompta == "BOOKKEEPING") {
158 $name = $langs->trans("PurchaseTurnover");
159 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
160 $description = $langs->trans("RulesPurchaseTurnoverOfExpenseAccounts");
161 //$exportlink=$langs->trans("NotYetAvailable");
162} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
163 $name = $langs->trans("PurchaseTurnoverCollected");
164 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
165 $description = $langs->trans("RulesPurchaseTurnoverCollectedOfExpenseAccounts");
166 //$exportlink=$langs->trans("NotYetAvailable");
167}
168
169$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
170$period .= ' - ';
171$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
172
173$moreparam = array();
174if (!empty($modecompta)) {
175 $moreparam['modecompta'] = $modecompta;
176}
177
178// Define $calcmode line
179$calcmode = '';
180if ($modecompta == "RECETTES-DEPENSES" || $modecompta == "BOOKKEEPINGCOLLECTED") {
181 /*if (isModEnabled('accounting')) {
182 $calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPINGCOLLECTED"'.($modecompta == 'BOOKKEEPINGCOLLECTED' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
183 $calcmode .= '<br>';
184 }*/
185 $calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModePayment");
186 if (isModEnabled('accounting')) {
187 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
188 }
189 $calcmode .= '</label>';
190} else {
191 if (isModEnabled('accounting')) {
192 $calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
193 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("DataMustHaveBeenTransferredInAccounting").')</span>';
194 $calcmode .= '<br>';
195 }
196 $calcmode .= '<input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeDebt");
197 if (isModEnabled('accounting')) {
198 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
199 }
200 $calcmode .= '</label>';
201}
202
203
204report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam, $calcmode);
205
206if (isModEnabled('accounting')) {
207 if ($modecompta != 'BOOKKEEPING') {
208 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
209 } else {
210 // Test if there is at least one line in bookkeeping
211 $pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
212 $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
213 if (empty($pcgvercode)) {
214 $pcgvercode = $pcgverid;
215 }
216
217 $sql = "SELECT b.rowid ";
218 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
219 $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
220 $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
221 $sql .= " AND b.numero_compte = aa.account_number";
222 $sql .= " AND aa.entity = ".$conf->entity;
223 $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
224 $sql .= $db->plimit(1);
225
226 $resql = $db->query($sql);
227 $nb = $db->num_rows($resql);
228 if ($nb == 0) {
229 $langs->load("errors");
230 print info_admin($langs->trans("WarningNoDataTransferedInAccountancyYet"), 0, 0, 1);
231 }
232 }
233}
234
235
236if ($modecompta == 'CREANCES-DETTES') {
237 $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
238 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
239 $sql .= " WHERE f.fk_statut in (1,2)";
240 $sql .= " AND f.type IN (0,2)";
241 $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
242 if ($socid) {
243 $sql .= " AND f.fk_soc = ".((int) $socid);
244 }
245} elseif ($modecompta == "RECETTES-DEPENSES") {
246 $sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
247 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
248 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
249 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
250 $sql .= " WHERE p.rowid = pf.fk_paiementfourn";
251 $sql .= " AND pf.fk_facturefourn = f.rowid";
252 $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
253 if ($socid) {
254 $sql .= " AND f.fk_soc = ".((int) $socid);
255 }
256} elseif ($modecompta == "BOOKKEEPING") {
257 $pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
258 $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
259 if (empty($pcgvercode)) {
260 $pcgvercode = $pcgverid;
261 }
262
263 $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit - b.credit) as amount_ttc";
264 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
265 $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
266 $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
267 $sql .= " AND b.doc_type = 'supplier_invoice'";
268 $sql .= " AND b.numero_compte = aa.account_number";
269 $sql .= " AND aa.entity = ".$conf->entity;
270 $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
271 $sql .= " AND aa.pcg_type = 'EXPENSE'"; // TODO Be able to use a custom group
272}
273$sql .= " GROUP BY dm";
274$sql .= " ORDER BY dm";
275// TODO Add a filter on $date_start and $date_end to reduce quantity on data
276//print $sql;
277
278$minyearmonth = $maxyearmonth = 0;
279
280$cumulative = array();
281$cumulative_ht = array();
282$total_ht = array();
283$total = array();
284
285$result = $db->query($sql);
286if ($result) {
287 $num = $db->num_rows($result);
288 $i = 0;
289 while ($i < $num) {
290 $obj = $db->fetch_object($result);
291 $cumulative_ht[$obj->dm] = empty($obj->amount) ? 0 : $obj->amount;
292 $cumulative[$obj->dm] = empty($obj->amount_ttc) ? 0 : $obj->amount_ttc;
293 if ($obj->amount_ttc) {
294 $minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm);
295 $maxyearmonth = max($maxyearmonth, $obj->dm);
296 }
297 $i++;
298 }
299 $db->free($result);
300} else {
301 dol_print_error($db);
302}
303
304$moreforfilter = '';
305
306print '<div class="div-table-responsive">';
307print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
308
309print '<tr class="liste_titre"><td>&nbsp;</td>';
310
311for ($annee = $year_start; $annee <= $year_end; $annee++) {
312 if ($modecompta == 'CREANCES-DETTES') {
313 print '<td align="center" width="10%" colspan="3">';
314 } else {
315 print '<td align="center" width="10%" colspan="2" class="borderrightlight">';
316 }
317 if ($modecompta != 'BOOKKEEPING') {
318 print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee.($modecompta ? '&modecompta='.$modecompta : '').'">';
319 }
320 print $annee;
321 if (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1) {
322 print '-'.($annee + 1);
323 }
324 if ($modecompta != 'BOOKKEEPING') {
325 print '</a>';
326 }
327 print '</td>';
328 if ($annee != $year_end) {
329 print '<td width="15">&nbsp;</td>';
330 }
331}
332print '</tr>';
333
334print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
335for ($annee = $year_start; $annee <= $year_end; $annee++) {
336 if ($modecompta == 'CREANCES-DETTES') {
337 print '<td class="liste_titre right">'.$langs->trans("AmountHT").'</td>';
338 }
339 print '<td class="liste_titre right">';
340 if ($modecompta == "BOOKKEEPING") {
341 print $langs->trans("Amount");
342 } else {
343 print $langs->trans("AmountTTC");
344 }
345 print '</td>';
346 print '<td class="liste_titre right borderrightlight">'.$langs->trans("Delta").'</td>';
347 if ($annee != $year_end) {
348 print '<td class="liste_titre" width="15">&nbsp;</td>';
349 }
350}
351print '</tr>';
352
353$now_show_delta = 0;
354$minyear = substr($minyearmonth, 0, 4);
355$maxyear = substr($maxyearmonth, 0, 4);
356$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
357$nowyearmonth = dol_print_date(dol_now(), "%Y-%m");
358$maxyearmonth = max($maxyearmonth, $nowyearmonth);
359$now = dol_now();
360$casenow = dol_print_date($now, "%Y-%m");
361
362// Loop on each month
363$nb_mois_decalage = GETPOSTISSET('date_startmonth') ? (GETPOSTINT('date_startmonth') - 1) : (!getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') ? 0 : (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') - 1));
364for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) {
365 $mois_modulo = $mois; // ajout
366 if ($mois > 12) {
367 $mois_modulo = $mois - 12;
368 } // ajout
369
370 if ($year_start == $year_end) {
371 if ($mois > $date_endmonth && $year_end >= $date_endyear) {
372 break;
373 }
374 }
375
376 print '<tr class="oddeven">';
377
378 // Month
379 print "<td>".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, 2000), "%B")."</td>";
380
381 for ($annee = $year_start - 1; $annee <= $year_end; $annee++) { // We start one year before to have data to be able to make delta
382 $annee_decalage = $annee;
383 if ($mois > 12) {
384 $annee_decalage = $annee + 1;
385 }
386 $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m");
387 $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m");
388
389 if ($annee >= $year_start) { // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output.
390 if ($modecompta == 'CREANCES-DETTES') {
391 // Value turnover of month w/o VAT
392 print '<td class="right">';
393 if (!empty($cumulative_ht[$case])) {
394 $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
395 print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">'.price($cumulative_ht[$case], 1).'</a>';
396 } else {
397 if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) {
398 print '0';
399 } else {
400 print '&nbsp;';
401 }
402 }
403 print "</td>";
404 }
405
406 // Value turnover of month
407 print '<td class="right">';
408 if (!empty($cumulative[$case])) {
409 $now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
410 if ($modecompta != 'BOOKKEEPING') {
411 print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">';
412 }
413 print price($cumulative[$case], 1);
414 if ($modecompta != 'BOOKKEEPING') {
415 print '</a>';
416 }
417 } else {
418 if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) {
419 print '0';
420 } else {
421 print '&nbsp;';
422 }
423 }
424 print "</td>";
425
426 // Percentage of month
427 if ($annee_decalage > $minyear && $case <= $casenow) {
428 if (!empty($cumulative[$caseprev]) && !empty($cumulative[$case])) {
429 $percent = (round(($cumulative[$case] - $cumulative[$caseprev]) / $cumulative[$caseprev], 4) * 100);
430 //print "X $cumulative[$case] - $cumulative[$caseprev] - $cumulative[$caseprev] - $percent X";
431 print '<td class="borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
432 }
433 if (!empty($cumulative[$caseprev]) && empty($cumulative[$case])) {
434 print '<td class="borderrightlight right">-100%</td>';
435 }
436 if (empty($cumulative[$caseprev]) && !empty($cumulative[$case])) {
437 //print '<td class="right">+Inf%</td>';
438 print '<td class="borderrightlight right">-</td>';
439 }
440 if (isset($cumulative[$caseprev]) && empty($cumulative[$caseprev]) && empty($cumulative[$case])) {
441 print '<td class="borderrightlight right">+0%</td>';
442 }
443 if (!isset($cumulative[$caseprev]) && empty($cumulative[$case])) {
444 print '<td class="borderrightlight right">-</td>';
445 }
446 } else {
447 print '<td class="borderrightlight right">';
448 if ($minyearmonth <= $case && $case <= $maxyearmonth) {
449 print '-';
450 } else {
451 print '&nbsp;';
452 }
453 print '</td>';
454 }
455
456 if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) {
457 print '<td width="15">&nbsp;</td>';
458 }
459 }
460
461 if (empty($total_ht[$annee])) {
462 $total_ht[$annee] = ((!empty($cumulative_ht[$case])) ? $cumulative_ht[$case] : 0);
463 } else {
464 $total_ht[$annee] += ((!empty($cumulative_ht[$case])) ? $cumulative_ht[$case] : 0);
465 }
466 if (empty($total[$annee])) {
467 $total[$annee] = (empty($cumulative[$case]) ? 0 : $cumulative[$case]);
468 } else {
469 $total[$annee] += (empty($cumulative[$case]) ? 0 : $cumulative[$case]);
470 }
471 }
472
473 print '</tr>';
474}
475
476// Affiche total
477print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td>';
478for ($annee = $year_start; $annee <= $year_end; $annee++) {
479 if ($modecompta == 'CREANCES-DETTES') {
480 // Montant total HT
481 if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) {
482 print '<td class="nowrap right">';
483 print($total_ht[$annee] ? price($total_ht[$annee]) : "0");
484 print "</td>";
485 } else {
486 print '<td>&nbsp;</td>';
487 }
488 }
489
490 // Montant total
491 if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) {
492 print '<td class="nowrap right">'.($total[$annee] ? price($total[$annee]) : "0")."</td>";
493 } else {
494 print '<td>&nbsp;</td>';
495 }
496
497 // Pourcentage total
498 if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) {
499 if ($total[$annee - 1] && $total[$annee]) {
500 $percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100);
501 print '<td class="nowrap borderrightlight right">';
502 print($percent >= 0 ? "+$percent" : "$percent").'%';
503 print '</td>';
504 }
505 if (!empty($total[$annee - 1]) && empty($total[$annee])) {
506 print '<td class="borderrightlight right">-100%</td>';
507 }
508 if (empty($total[$annee - 1]) && !empty($total[$annee])) {
509 print '<td class="borderrightlight right">+'.$langs->trans('Inf').'%</td>';
510 }
511 if (empty($total[$annee - 1]) && empty($total[$annee])) {
512 print '<td class="borderrightlight right">+0%</td>';
513 }
514 } else {
515 print '<td class="borderrightlight right">';
516 if (!empty($total[$annee]) || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) {
517 print '-';
518 } else {
519 print '&nbsp;';
520 }
521 print '</td>';
522 }
523
524 if ($annee != $year_end) {
525 print '<td width="15">&nbsp;</td>';
526 }
527}
528print "</tr>\n";
529print "</table>";
530print '</div>';
531
532// End of page
533llxFooter();
534$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:594
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:613
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.