dolibarr 21.0.0-beta
projects.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6 * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
10 * Copyright (C) 2018 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
12 * Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 * Copyright (C) 2024 Yoan Mollard <ymollard@users.noreply.github.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
38require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
39require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
44require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
45require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
46
55// Load translation files required by the page
56$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan'));
57
58$date_startmonth = GETPOSTINT('date_startmonth');
59$date_startday = GETPOSTINT('date_startday');
60$date_startyear = GETPOSTINT('date_startyear');
61$date_endmonth = GETPOSTINT('date_endmonth');
62$date_endday = GETPOSTINT('date_endday');
63$date_endyear = GETPOSTINT('date_endyear');
64$showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes';
65
66$search_project_ref = GETPOST('search_project_ref', 'alpha');
67
68$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
69$sortfield = GETPOST('sortfield', 'aZ09comma');
70$sortorder = GETPOST('sortorder', 'aZ09comma');
71$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
72if (empty($page) || $page == -1) {
73 $page = 0;
74} // If $page is not defined, or '' or -1
75$offset = $limit * $page;
76$pageprev = $page - 1;
77$pagenext = $page + 1;
78//if (! $sortfield) $sortfield='s.nom, s.rowid';
79if (!$sortorder) {
80 $sortorder = 'ASC';
81}
82
83// Date range
84$year = GETPOSTINT('year'); // this is used for navigation previous/next. It is the last year to show in filter
85if (empty($year)) {
86 $year_current = dol_print_date(dol_now(), "%Y");
87 $month_current = dol_print_date(dol_now(), "%m");
88 $year_start = $year_current;
89} else {
90 $year_current = $year;
91 $month_current = dol_print_date(dol_now(), "%m");
92 $year_start = $year;
93}
94$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
95$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
96
97// We define date_start and date_end
98if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
99 $q = GETPOST("q") ? GETPOSTINT("q") : 0;
100 if ($q == 0) {
101 // We define date_start and date_end
102 $year_end = $year_start;
103 $month_start = GETPOST("month") ? GETPOSTINT("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
104 $month_end = "";
105 if (!GETPOST('month')) {
106 if (!$year && $month_start > $month_current) {
107 $year_start--;
108 $year_end--;
109 }
110 if (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1) {
111 $month_end = $month_start - 1;
112 $year_end = $year_start + 1;
113 }
114 if ($month_end < 1) {
115 $month_end = 12;
116 }
117 } else {
118 $month_end = $month_start;
119 }
120 $date_start = dol_get_first_day($year_start, $month_start, false);
121 $date_end = dol_get_last_day($year_end, $month_end, false);
122 }
123 if ($q == 1) {
124 $date_start = dol_get_first_day($year_start, 1, false);
125 $date_end = dol_get_last_day($year_start, 3, false);
126 }
127 if ($q == 2) {
128 $date_start = dol_get_first_day($year_start, 4, false);
129 $date_end = dol_get_last_day($year_start, 6, false);
130 }
131 if ($q == 3) {
132 $date_start = dol_get_first_day($year_start, 7, false);
133 $date_end = dol_get_last_day($year_start, 9, false);
134 }
135 if ($q == 4) {
136 $date_start = dol_get_first_day($year_start, 10, false);
137 $date_end = dol_get_last_day($year_start, 12, false);
138 }
139}
140
141// $date_start and $date_end are defined. We force $year_start and $nbofyear
142$tmps = dol_getdate($date_start);
143$year_start = $tmps['year'];
144$tmpe = dol_getdate($date_end);
145$year_end = $tmpe['year'];
146$nbofyear = ($year_end - $year_start) + 1;
147//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour'));
148
149// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
150$modecompta = getDolGlobalString('ACCOUNTING_MODE');
151if (isModEnabled('accounting')) {
152 // $modecompta = 'BOOKKEEPING';
153 $modecompta = 'CREANCES-DETTES';
154}
155if (GETPOST("modecompta", 'alpha')) {
156 $modecompta = GETPOST("modecompta", 'alpha');
157}
158
159$AccCat = new AccountancyCategory($db);
160
161// Security check
162$socid = GETPOSTINT('socid');
163if ($user->socid > 0) {
164 $socid = $user->socid;
165}
166if (isModEnabled('comptabilite')) {
167 $result = restrictedArea($user, 'compta', '', '', 'resultat');
168}
169if (isModEnabled('accounting')) {
170 $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
171}
172$hookmanager->initHooks(['customersupplierreportlist']);
173
174
175/*
176 * View
177 */
178
179llxHeader();
180
181$form = new Form($db);
182
183$periodlink = '';
184$exportlink = '';
185
186$total_ht = 0;
187$total_ttc = 0;
188
189$name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects");
190$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
191$builddate = dol_now();
192
193// Display report header
194if ($modecompta == "CREANCES-DETTES") {
195 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects");
196 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
197 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
198 $builddate = dol_now();
199 //$exportlink=$langs->trans("NotYetAvailable");
200} elseif ($modecompta == "RECETTES-DEPENSES") {
201 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects");
202 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
203 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
204 $builddate = dol_now();
205 //$exportlink=$langs->trans("NotYetAvailable");
206} elseif ($modecompta == "BOOKKEEPING") {
207 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects");
208 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
209 $arraylist = array('no'=>$langs->trans("CustomerCode"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
210 $period .= ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("DetailBy").'</span> '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
211 $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."&showaccountdetail=".$showaccountdetail."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."&showaccountdetail=".$showaccountdetail."'>".img_next()."</a>" : "");
212 $builddate = dol_now();
213 //$exportlink=$langs->trans("NotYetAvailable");
214}
215
216// Define $calcmode line
217$calcmode = '';
218/*
219if (isModEnabled('accounting')) {
220 $calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
221 $calcmode .= '<br>';
222}
223*/
224$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModePayment");
225if (isModEnabled('accounting')) {
226 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
227}
228$calcmode .= '</label>';
229$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeDebt");
230if (isModEnabled('accounting')) {
231 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
232}
233$calcmode .= '</label>';
234
235report_header($name, '', $period, $periodlink, "", $builddate, $exportlink, array('modecompta'=>$modecompta, 'showaccountdetail'=>$showaccountdetail), $calcmode);
236
237// Show report array
238$param = '&modecompta='.urlencode($modecompta).'&showaccountdetail='.urlencode($showaccountdetail);
239$search_date_url = '';
240if ($date_startday) {
241 $param .= '&date_startday='.$date_startday;
242 $search_date_url .= '&search_date_startday='.$date_startday;
243}
244if ($date_startmonth) {
245 $param .= '&date_startmonth='.$date_startmonth;
246 $search_date_url .= '&search_date_startmonth='.$date_startmonth;
247}
248if ($date_startyear) {
249 $param .= '&date_startyear='.$date_startyear;
250 $search_date_url .= '&search_date_startyear='.$date_startyear;
251}
252if ($date_endday) {
253 $param .= '&date_endday='.$date_endday;
254 $search_date_url .= '&search_date_endday='.$date_endday;
255}
256if ($date_endmonth) {
257 $param .= '&date_endmonth='.$date_endmonth;
258 $search_date_url .= '&search_date_endmonth='.$date_endmonth;
259}
260if ($date_endyear) {
261 $param .= '&date_endyear='.$date_endyear;
262 $search_date_url .= '&search_date_endyear='.$date_endyear;
263}
264
265print '<table class="liste noborder centpercent">';
266print '<tr class="liste_titre">';
267
268if ($modecompta == 'BOOKKEEPING') {
269 print_liste_field_titre("ByProjects", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
270} else {
271 print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'width200 ');
272}
274if ($modecompta == 'BOOKKEEPING') {
275 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'amount', '', $param, 'class="right"', $sortfield, $sortorder);
276} else {
277 if ($modecompta == 'CREANCES-DETTES') {
278 print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder);
279 } else {
280 print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is
281 }
282 print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
283}
284print "</tr>\n";
285
286
287$total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
288
289if ($modecompta == 'BOOKKEEPING') {
290 echo "<p>BOOKKEEPING mode not implemented for this report type by project.</p>";
291} else {
292 /*
293 * Customer invoices
294 */
295 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>';
296
297 $sql = '';
298 if ($modecompta == 'CREANCES-DETTES') {
299 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
300 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
301 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
302 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON f.fk_projet = p.rowid";
303 $sql .= " WHERE f.fk_soc = s.rowid";
304 $sql .= " AND f.entity IN (".getEntity('invoice').")";
305 $sql .= " AND f.fk_statut IN (1,2)";
306 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
307 $sql .= " AND f.type IN (0,1,2,5)";
308 } else {
309 $sql .= " AND f.type IN (0,1,2,3,5)";
310 }
311 if (!empty($date_start) && !empty($date_end)) {
312 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
313 }
314 if ($socid) {
315 $sql .= " AND f.fk_soc = ".((int) $socid);
316 }
317 $sql .= " GROUP BY p.rowid, project_name";
318 $sql .= $db->order($sortfield, $sortorder);
319 } elseif ($modecompta == 'RECETTES-DEPENSES') {
320 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(pf.amount) as amount_ttc";
321 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
322 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
323 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON f.fk_projet = p.rowid";
324 $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
325 $sql .= ", ".MAIN_DB_PREFIX."paiement as pa";
326 $sql .= " WHERE pa.rowid = pf.fk_paiement";
327 $sql .= " AND pf.fk_facture = f.rowid";
328 $sql .= " AND f.fk_soc = s.rowid";
329 $sql .= " AND f.entity IN (".getEntity('invoice').")";
330 if (!empty($date_start) && !empty($date_end)) {
331 $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
332 }
333 if ($socid) {
334 $sql .= " AND f.fk_soc = ".((int) $socid);
335 }
336 $sql .= " GROUP BY p.rowid, project_name";
337 $sql .= $db->order($sortfield, $sortorder);
338 }
339
340 dol_syslog("by project, get customer invoices", LOG_DEBUG);
341 $result = $db->query($sql);
342 if ($result) {
343 $num = $db->num_rows($result);
344 $i = 0;
345 while ($i < $num) {
346 $objp = $db->fetch_object($result);
347 echo '<tr class="oddeven">';
348 echo '<td>&nbsp;</td>';
349 echo "<td>".$langs->trans("Project")." ";
350 if (!empty($objp->project_name)) {
351 echo ' <a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objp->rowid.'">'.$objp->project_name.'</a>';
352 } else {
353 echo $langs->trans("None");
354 }
355 $detailed_list_url = '';
356 //$detailed_list_url .= '?search_project_ref='.urlencode($search_project_ref);
357 $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name;
358 $detailed_list_url .= $search_date_url;
359 echo ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php'.$detailed_list_url.'">'.$langs->trans("DetailedListLowercase")."</a>)\n";
360 echo "</td>\n";
361 echo '<td class="right">';
362 if ($modecompta == 'CREANCES-DETTES') {
363 echo '<span class="amount">'.price($objp->amount_ht)."</span>";
364 }
365 echo "</td>\n";
366 echo '<td class="right"><span class="amount">'.price($objp->amount_ttc)."</span></td>\n";
367
368 $total_ht += ($objp->amount_ht ?? 0);
369 $total_ttc += $objp->amount_ttc;
370 echo "</tr>\n";
371 $i++;
372 }
373 $db->free($result);
374 } else {
375 dol_print_error($db);
376 }
377
378 if ($total_ttc == 0) {
379 echo '<tr class="oddeven">';
380 echo '<td>&nbsp;</td>';
381 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
382 echo '</tr>';
383 }
384
385 $total_ht_income += $total_ht;
386 $total_ttc_income += $total_ttc;
387
388 echo '<tr class="liste_total">';
389 echo '<td></td>';
390 echo '<td></td>';
391 echo '<td class="right">';
392 if ($modecompta == 'CREANCES-DETTES') {
393 echo price($total_ht);
394 }
395 echo '</td>';
396 echo '<td class="right">'.price($total_ttc).'</td>';
397 echo '</tr>';
398
399 /*
400 * Donations
401 */
402
403 if (isModEnabled('don')) {
404 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
405
406 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
407 if ($modecompta == 'CREANCES-DETTES') {
408 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(d.amount) as amount";
409 $sql .= " FROM ".MAIN_DB_PREFIX."don as d";
410 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON d.fk_projet = p.rowid";
411 $sql .= " WHERE d.entity IN (".getEntity('donation').")";
412 $sql .= " AND d.fk_statut in (1,2)";
413 } else {
414 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(d.amount) as amount";
415 $sql .= " FROM ".MAIN_DB_PREFIX."don as d";
416 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = d.rowid";
417 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON d.fk_projet = p.rowid";
418 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
419 $sql .= " WHERE d.entity IN (".getEntity('donation').")";
420 $sql .= " AND d.fk_statut >= 2";
421 }
422 if (!empty($date_start) && !empty($date_end)) {
423 $sql .= " AND d.datedon >= '".$db->idate($date_start)."' AND d.datedon <= '".$db->idate($date_end)."'";
424 }
425 }
426 $sql .= " GROUP BY p.rowid, p.ref";
427 $newsortfield = $sortfield;
428 if ($newsortfield == 's.nom, s.rowid') {
429 $newsortfield = 'p.ref';
430 }
431 if ($newsortfield == 'amount_ht') {
432 $newsortfield = 'amount';
433 }
434 if ($newsortfield == 'amount_ttc') {
435 $newsortfield = 'amount';
436 }
437 $sql .= $db->order($newsortfield, $sortorder);
438
439 dol_syslog("by project, get dunning");
440 $result = $db->query($sql);
441 $subtotal_ht = 0;
442 $subtotal_ttc = 0;
443 if ($result) {
444 $num = $db->num_rows($result);
445 $i = 0;
446 if ($num) {
447 while ($i < $num) {
448 $obj = $db->fetch_object($result);
449
450 $total_ht += $obj->amount;
451 $total_ttc += $obj->amount;
452 $subtotal_ht += $obj->amount;
453 $subtotal_ttc += $obj->amount;
454
455 echo '<tr class="oddeven">';
456 echo '<td>&nbsp;</td>';
457 $project_name = empty($obj->project_name)? $langs->trans("None"): $obj->project_name;
458 echo "<td>".$langs->trans("Project")." <a href=\"".DOL_URL_ROOT."/projet/card.php?id=".$obj->ref."\">".$project_name."</a></td>\n";
459
460 echo '<td class="right">';
461 if ($modecompta == 'CREANCES-DETTES') {
462 echo '<span class="amount">'.price($obj->amount).'</span>';
463 }
464 echo '</td>';
465 echo '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
466 echo '</tr>';
467 $i++;
468 }
469 } else {
470 echo '<tr class="oddeven"><td>&nbsp;</td>';
471 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
472 echo '</tr>';
473 }
474 } else {
475 dol_print_error($db);
476 }
477
478 $total_ht_income += $subtotal_ht;
479 $total_ttc_income += $subtotal_ttc;
480
481 echo '<tr class="liste_total">';
482 echo '<td></td>';
483 echo '<td></td>';
484 echo '<td class="right">';
485 if ($modecompta == 'CREANCES-DETTES') {
486 echo price($subtotal_ht);
487 }
488 echo '</td>';
489 echo '<td class="right">'.price($subtotal_ttc).'</td>';
490 echo '</tr>';
491 }
492
493 /*
494 * Suppliers invoices
495 */
496 if ($modecompta == 'CREANCES-DETTES') {
497 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
498 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
499 $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
500 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON f.fk_projet = p.rowid";
501 $sql .= " WHERE f.fk_soc = s.rowid";
502 $sql .= " AND f.fk_statut IN (1,2)";
503 if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
504 $sql .= " AND f.type IN (0,1,2)";
505 } else {
506 $sql .= " AND f.type IN (0,1,2,3)";
507 }
508 if (!empty($date_start) && !empty($date_end)) {
509 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
510 }
511 } elseif ($modecompta == 'RECETTES-DEPENSES') {
512 $sql = "SELECT pr.rowid as rowid, pr.ref as project_name, sum(pf.amount) as amount_ttc";
513 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
514 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
515 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON pf.fk_facturefourn = f.rowid";
516 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON f.fk_projet = pr.rowid";
517 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
518 $sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
519 if (!empty($date_start) && !empty($date_end)) {
520 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
521 }
522 }
523
524 $sql .= " AND f.entity = ".((int) $conf->entity);
525 if ($socid) {
526 $sql .= " AND f.fk_soc = ".((int) $socid);
527 }
528 $sql .= " GROUP BY rowid, project_name";
529 $sql .= $db->order($sortfield, $sortorder);
530
531 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
532
533 $subtotal_ht = 0;
534 $subtotal_ttc = 0;
535 dol_syslog("by project, get suppliers invoices", LOG_DEBUG);
536 $result = $db->query($sql);
537 if ($result) {
538 $num = $db->num_rows($result);
539 $i = 0;
540 if ($num > 0) {
541 while ($i < $num) {
542 $objp = $db->fetch_object($result);
543
544 echo '<tr class="oddeven">';
545 echo '<td>&nbsp;</td>';
546
547 echo "<td>".$langs->trans("Project")." ";
548 if (!empty($objp->project_name)) {
549 echo ' <a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objp->rowid.'">'.$objp->project_name.'</a>';
550 } else {
551 echo $langs->trans("None");
552 }
553 $detailed_list_url = '';
554 //$detailed_list_url .= '?search_project='.urlencode($search_project_ref);
555 $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name;
556 $detailed_list_url .= $search_date_url;
557 echo ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.$detailed_list_url.'">'.$langs->trans("DetailedListLowercase")."</a>)\n";
558 echo "</td>\n";
559
560 echo '<td class="right">';
561 if ($modecompta == 'CREANCES-DETTES') {
562 echo '<span class="amount">'.price(-$objp->amount_ht)."</span>";
563 }
564 echo "</td>\n";
565 echo '<td class="right"><span class="amount">'.price(-$objp->amount_ttc)."</span></td>\n";
566
567 $total_ht -= (isset($objp->amount_ht) ? $objp->amount_ht : 0);
568 $total_ttc -= $objp->amount_ttc;
569 $subtotal_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
570 $subtotal_ttc += $objp->amount_ttc;
571
572 echo "</tr>\n";
573 $i++;
574 }
575 } else {
576 echo '<tr class="oddeven">';
577 echo '<td>&nbsp;</td>';
578 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
579 echo '</tr>';
580 }
581
582 $db->free($result);
583 } else {
584 dol_print_error($db);
585 }
586
587 $total_ht_outcome += $subtotal_ht;
588 $total_ttc_outcome += $subtotal_ttc;
589
590 echo '<tr class="liste_total">';
591 echo '<td></td>';
592 echo '<td></td>';
593 echo '<td class="right">';
594 if ($modecompta == 'CREANCES-DETTES') {
595 echo price(-$subtotal_ht);
596 }
597 echo '</td>';
598 echo '<td class="right">'.price(-$subtotal_ttc).'</td>';
599 echo '</tr>';
600
601 /*
602 * Salaries
603 */
604
605 if (isModEnabled('salaries')) {
606 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
607
608 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
609 if ($modecompta == 'CREANCES-DETTES') {
610 $column = 's.dateep'; // We use the date of end of period of salary
611
612 $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(s.amount) as amount";
613 $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
614 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user";
615 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON s.fk_projet = p.rowid";
616 $sql .= " WHERE s.entity IN (".getEntity('salary').")";
617 if (!empty($date_start) && !empty($date_end)) {
618 $sql .= " AND ".$db->sanitize($column)." >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
619 }
620 } else {
621 $column = 'ps.datep';
622
623 $sql = "SELECT pr.rowid as rowid, pr.ref as project_name, sum(ps.amount) as amount";
624 $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
625 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid = ps.fk_salary";
626 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user";
627 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON s.fk_projet = pr.rowid";
628 $sql .= " WHERE ps.entity IN (".getEntity('payment_salary').")";
629 if (!empty($date_start) && !empty($date_end)) {
630 $sql .= " AND ".$db->sanitize($column)." >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
631 }
632 }
633
634
635 $sql .= " GROUP BY rowid, project_name";
636 $newsortfield = $sortfield;
637 if ($newsortfield == 's.nom, s.rowid') {
638 $newsortfield = 'project_name';
639 }
640 if ($newsortfield == 'amount_ht') {
641 $newsortfield = 'amount';
642 }
643 if ($newsortfield == 'amount_ttc') {
644 $newsortfield = 'amount';
645 }
646 $sql .= $db->order($newsortfield, $sortorder);
647 }
648
649 dol_syslog("by project, get salaries");
650 $result = $db->query($sql);
651 $subtotal_ht = 0;
652 $subtotal_ttc = 0;
653 if ($result) {
654 $num = $db->num_rows($result);
655 $i = 0;
656 if ($num) {
657 while ($i < $num) {
658 $obj = $db->fetch_object($result);
659
660 $project_name = !empty($obj->project_name) ? $obj->project_name : $langs->trans("None");
661
662 $total_ht -= $obj->amount;
663 $total_ttc -= $obj->amount;
664 $subtotal_ht += $obj->amount;
665 $subtotal_ttc += $obj->amount;
666
667 echo '<tr class="oddeven"><td>&nbsp;</td>';
668 echo "<td>".$langs->trans("Project")." ";
669 if (!empty($objp->project_name)) {
670 echo ' <a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objp->rowid.'">'.$objp->project_name.'</a>';
671 } else {
672 echo $langs->trans("None");
673 }
674 echo "</td>\n";
675 echo '<td class="right">';
676 if ($modecompta == 'CREANCES-DETTES') {
677 echo '<span class="amount">'.price(-$obj->amount).'</span>';
678 }
679 echo '</td>';
680 echo '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
681 echo '</tr>';
682 $i++;
683 }
684 } else {
685 echo '<tr class="oddeven">';
686 echo '<td>&nbsp;</td>';
687 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
688 echo '</tr>';
689 }
690 } else {
691 dol_print_error($db);
692 }
693
694 $total_ht_outcome += $subtotal_ht;
695 $total_ttc_outcome += $subtotal_ttc;
696
697 echo '<tr class="liste_total">';
698 echo '<td></td>';
699 echo '<td></td>';
700 echo '<td class="right">';
701 if ($modecompta == 'CREANCES-DETTES') {
702 echo price(-$subtotal_ht);
703 }
704 echo '</td>';
705 echo '<td class="right">'.price(-$subtotal_ttc).'</td>';
706 echo '</tr>';
707 }
708
709
710 /*
711 * Expense report
712 */
713
714 if (isModEnabled('expensereport')) {
715 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
716 $langs->load('trips');
717 if ($modecompta == 'CREANCES-DETTES') {
718 $sql = "SELECT ed.rowid as rowid, ed.fk_projet, p.rowid as project_rowid, p.ref as project_name, sum(ed.total_ht) as amount_ht, sum(ed.total_ttc) as amount_ttc";
719 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as ed";
720 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as e ON ed.fk_expensereport = e.rowid";
721 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON ed.fk_projet = p.rowid";
722 $sql .= " WHERE e.entity IN (".getEntity('expensereport').")";
723 $sql .= " AND e.fk_statut >= 5";
724
725 $column = 'e.date_valid';
726 } else {
727 $sql = "SELECT ed.rowid as rowid, ed.fk_projet, p.rowid as project_rowid, p.ref as project_name, sum(DISTINCT pe.amount) as amount_ht, sum(DISTINCT pe.amount) as amount_ttc";
728 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as ed";
729 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as e ON ed.fk_expensereport = e.rowid";
730 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = e.rowid";
731 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON ed.fk_projet = p.rowid";
732 $sql .= " WHERE e.entity IN (".getEntity('expensereport').")";
733 $sql .= " AND e.fk_statut >= 5";
734
735 $column = 'pe.datep';
736 }
737
738 if (!empty($date_start) && !empty($date_end)) {
739 $sql .= " AND ".$db->sanitize($column)." >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
740 }
741
742 $sql .= " GROUP BY ed.rowid, ed.fk_projet, p.rowid, p.ref";
743 $newsortfield = $sortfield;
744 if ($newsortfield == 's.nom, s.rowid') {
745 $newsortfield = 'project_name';
746 }
747 $sql .= $db->order($newsortfield, $sortorder);
748 }
749
750 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
751
752 dol_syslog("by project, get expense report outcome");
753 $result = $db->query($sql);
754 $subtotal_ht = 0;
755 $subtotal_ttc = 0;
756 if ($result) {
757 $num = $db->num_rows($result);
758 if ($num) {
759 while ($obj = $db->fetch_object($result)) {
760 $project_name = !empty($obj->project_name) ? $obj->project_name : $langs->trans("None");
761
762 $total_ht -= $obj->amount_ht;
763 $total_ttc -= $obj->amount_ttc;
764 $subtotal_ht += $obj->amount_ht;
765 $subtotal_ttc += $obj->amount_ttc;
766
767 echo '<tr class="oddeven">';
768 echo '<td>&nbsp;</td>';
769
770 echo "<td>".$langs->trans("Project")." ";
771 if (!empty($obj->project_name)) {
772 echo ' <a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->project_rowid.'">'.$obj->project_name.'</a>';
773 } else {
774 echo $langs->trans("None");
775 }
776 $detailed_list_url = '?id='.$obj->project_rowid;
777 $detailed_list_url .= $search_date_url;
778 echo ' (<a href="'.DOL_URL_ROOT.'/projet/element.php'.$detailed_list_url.'">'.$langs->trans("DetailedListLowercase")."</a>)\n";
779 echo "</td>\n";
780
781 echo '<td class="right">';
782 if ($modecompta == 'CREANCES-DETTES') {
783 echo '<span class="amount">'.price(-$obj->amount_ht).'</span>';
784 }
785 echo '</td>';
786 echo '<td class="right"><span class="amount">'.price(-$obj->amount_ttc).'</span></td>';
787 echo '</tr>';
788 }
789 } else {
790 echo '<tr class="oddeven">';
791 echo '<td>&nbsp;</td>';
792 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
793 echo '</tr>';
794 }
795 } else {
796 dol_print_error($db);
797 }
798
799 $total_ht_outcome += $subtotal_ht;
800 $total_ttc_outcome += $subtotal_ttc;
801
802 echo '<tr class="liste_total">';
803 echo '<td></td>';
804 echo '<td></td>';
805 echo '<td class="right">';
806 if ($modecompta == 'CREANCES-DETTES') {
807 echo price(-$subtotal_ht);
808 }
809 echo '</td>';
810 echo '<td class="right">'.price(-$subtotal_ttc).'</td>';
811 echo '</tr>';
812 }
813
814
815
816
817 /*
818 * Various Payments
819 */
820 //$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
821
822 if (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_VARPAY') && isModEnabled("bank") && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
823 $subtotal_ht = 0;
824 $subtotal_ttc = 0;
825
826 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VariousPayment").'</td></tr>';
827
828 // Debit
829 $sql = "SELECT p.rowid as rowid, p.ref as project_name, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
830 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pj ON p.fk_projet = pj.rowid";
831 $sql .= ' WHERE 1 = 1';
832 if (!empty($date_start) && !empty($date_end)) {
833 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
834 }
835 $sql .= ' GROUP BY p.rowid, project_name';
836 $sql .= ' ORDER BY project_name';
837
838 dol_syslog('get various payments', LOG_DEBUG);
839 $result = $db->query($sql);
840 if ($result) {
841 $num = $db->num_rows($result);
842 if ($num) {
843 while ($obj = $db->fetch_object($result)) {
844 $project_name = !empty($obj->project_name) ? $obj->project_name : $langs->trans("None");
845
846 // Debit (payment of suppliers for example)
847 if (isset($obj->amount)) {
848 $subtotal_ht += -$obj->amount;
849 $subtotal_ttc += -$obj->amount;
850
851 $total_ht_outcome += $obj->amount;
852 $total_ttc_outcome += $obj->amount;
853 }
854 echo '<tr class="oddeven">';
855 echo '<td>&nbsp;</td>';
856 echo "<td>".$langs->trans("Project")." <a href=\"".DOL_URL_ROOT."/projet/card.php?id=".urlencode($obj->project_id)."\">".$project_name."</a></td>\n";
857 echo '<td class="right">';
858 if ($modecompta == 'CREANCES-DETTES') {
859 echo '<span class="amount">'.price(-$obj->amount).'</span>';
860 }
861 echo '</td>';
862 echo '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
863 echo "</tr>\n";
864
865 // Credit (payment received from customer for example)
866 if (isset($obj->amount)) {
867 $subtotal_ht += $obj->amount;
868 $subtotal_ttc += $obj->amount;
869
870 $total_ht_income += $obj->amount;
871 $total_ttc_income += $obj->amount;
872 }
873 echo '<tr class="oddeven"><td>&nbsp;</td>';
874 echo "<td>".$langs->trans("Project")." <a href=\"".DOL_URL_ROOT."/projet/card.php?id=".urlencode($obj->project_id)."\">".$project_name."</a></td>\n";
875 echo '<td class="right">';
876 if ($modecompta == 'CREANCES-DETTES') {
877 echo '<span class="amount">'.price($obj->amount).'</span>';
878 }
879 echo '</td>';
880 echo '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
881 echo "</tr>\n";
882 }
883 } else {
884 echo '<tr class="oddeven">';
885 echo '<td>&nbsp;</td>';
886 echo '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
887 echo '</tr>';
888 }
889
890 // Total
891 $total_ht += $subtotal_ht;
892 $total_ttc += $subtotal_ttc;
893 echo '<tr class="liste_total">';
894 echo '<td></td>';
895 echo '<td></td>';
896 echo '<td class="right">';
897 if ($modecompta == 'CREANCES-DETTES') {
898 echo price($subtotal_ht);
899 }
900 echo '</td>';
901 echo '<td class="right">'.price($subtotal_ttc).'</td>';
902 echo '</tr>';
903 } else {
904 dol_print_error($db);
905 }
906 }
907
908 /*
909 * Payment Loan
910 */
911
912 if (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_LOAN') && isModEnabled('don') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
913 $subtotal_ht = 0;
914 $subtotal_ttc = 0;
915
916 echo '<tr class="trforbreak"><td colspan="4">'.$langs->trans("PaymentLoan").'</td></tr>';
917
918 $sql = 'SELECT pj.rowid as rowid, pj.ref as project_name, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) as amount FROM '.MAIN_DB_PREFIX.'payment_loan as p';
919 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'loan AS l ON l.rowid = p.fk_loan';
920 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet AS pj ON l.fk_projet = pj.rowid';
921 $sql .= ' WHERE 1 = 1';
922 if (!empty($date_start) && !empty($date_end)) {
923 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
924 }
925 $sql .= ' GROUP BY pj.rowid, project_name';
926 $sql .= ' ORDER BY project_name';
927
928 dol_syslog('get loan payments', LOG_DEBUG);
929 $result = $db->query($sql);
930 if ($result) {
931 require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
932 $loan_static = new Loan($db);
933 while ($obj = $db->fetch_object($result)) {
934 $project_name = !empty($obj->project_name) ? $obj->project_name : $langs->trans("None");
935
936 echo '<tr class="oddeven"><td>&nbsp;</td>';
937 echo "<td>".$langs->trans("Project")." <a href=\"".DOL_URL_ROOT."/projet/card.php?id=".urlencode($obj->project_id)."\">".$project_name."</a></td>\n";
938 if ($modecompta == 'CREANCES-DETTES') {
939 echo '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
940 }
941 echo '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
942 echo "</tr>\n";
943 $subtotal_ht -= $obj->amount;
944 $subtotal_ttc -= $obj->amount;
945 }
946 $total_ht += $subtotal_ht;
947 $total_ttc += $subtotal_ttc;
948
949 $total_ht_income += $subtotal_ht;
950 $total_ttc_income += $subtotal_ttc;
951
952 echo '<tr class="liste_total">';
953 echo '<td></td>';
954 echo '<td></td>';
955 echo '<td class="right">';
956 if ($modecompta == 'CREANCES-DETTES') {
957 echo price($subtotal_ht);
958 }
959 echo '</td>';
960 echo '<td class="right">'.price($subtotal_ttc).'</td>';
961 echo '</tr>';
962 } else {
963 dol_print_error($db);
964 }
965 }
966}
967
968$action = "balanceclient";
969$object = array(&$total_ht, &$total_ttc);
970$parameters["mode"] = $modecompta;
971$parameters["date_start"] = $date_start;
972$parameters["date_end"] = $date_end;
973// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
974$hookmanager->initHooks(array('externalbalance'));
975$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
976echo $hookmanager->resPrint;
977
978
979
980// Total
981echo '<tr>';
982echo '<td colspan="'.($modecompta == 'BOOKKEEPING' ? 3 : 4).'">&nbsp;</td>';
983echo '</tr>';
984
985echo '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
986if ($modecompta == 'CREANCES-DETTES') {
987 echo '<td class="liste_total right nowraponall">'.price(price2num($total_ht_income, 'MT')).'</td>';
988} elseif ($modecompta == 'RECETTES-DEPENSES') {
989 echo '<td></td>';
990}
991echo '<td class="liste_total right nowraponall">'.price(price2num($total_ttc_income, 'MT')).'</td>';
992echo '</tr>';
993echo '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
994if ($modecompta == 'CREANCES-DETTES') {
995 echo '<td class="liste_total right nowraponall">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
996} elseif ($modecompta == 'RECETTES-DEPENSES') {
997 echo '<td></td>';
998}
999echo '<td class="liste_total right nowraponall">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
1000echo '</tr>';
1001echo '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
1002if ($modecompta == 'CREANCES-DETTES') {
1003 echo '<td class="liste_total right nowraponall">'.price(price2num($total_ht, 'MT')).'</td>';
1004} elseif ($modecompta == 'RECETTES-DEPENSES') {
1005 echo '<td></td>';
1006}
1007echo '<td class="liste_total right nowraponall">'.price(price2num($total_ttc, 'MT')).'</td>';
1008echo '</tr>';
1009
1010echo "</table>";
1011echo '<br>';
1012
1013// End of page
1014llxFooter();
1015
1016$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage categories of an accounting account.
Class to manage generation of HTML components Only common components must be here.
Loan.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:600
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
llxFooter()
Footer empty.
Definition document.php:107
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.