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