dolibarr 19.0.3
clientfourn.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 Dourseanud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2014-2106 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@netlogic.fr>
11 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
12 * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
38require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
43require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
44require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan'));
48
49$date_startmonth = GETPOST('date_startmonth', 'int');
50$date_startday = GETPOST('date_startday', 'int');
51$date_startyear = GETPOST('date_startyear', 'int');
52$date_endmonth = GETPOST('date_endmonth', 'int');
53$date_endday = GETPOST('date_endday', 'int');
54$date_endyear = GETPOST('date_endyear', 'int');
55$showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes';
56
57$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
58$sortfield = GETPOST('sortfield', 'aZ09comma');
59$sortorder = GETPOST('sortorder', 'aZ09comma');
60$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
61if (empty($page) || $page == -1) {
62 $page = 0;
63} // If $page is not defined, or '' or -1
64$offset = $limit * $page;
65$pageprev = $page - 1;
66$pagenext = $page + 1;
67//if (! $sortfield) $sortfield='s.nom, s.rowid';
68if (!$sortorder) {
69 $sortorder = 'ASC';
70}
71
72// Date range
73$year = GETPOST('year', 'int'); // this is used for navigation previous/next. It is the last year to show in filter
74if (empty($year)) {
75 $year_current = dol_print_date(dol_now(), "%Y");
76 $month_current = dol_print_date(dol_now(), "%m");
77 $year_start = $year_current;
78} else {
79 $year_current = $year;
80 $month_current = dol_print_date(dol_now(), "%m");
81 $year_start = $year;
82}
83$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
84$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
85
86// We define date_start and date_end
87if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
88 $q = GETPOST("q") ? GETPOST("q", 'int') : 0;
89 if ($q == 0) {
90 // We define date_start and date_end
91 $year_end = $year_start;
92 $month_start = GETPOST("month") ? GETPOST("month", 'int') : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
93 $month_end = "";
94 if (!GETPOST('month')) {
95 if (!$year && $month_start > $month_current) {
96 $year_start--;
97 $year_end--;
98 }
99 if (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1) {
100 $month_end = $month_start - 1;
101 $year_end = $year_start + 1;
102 }
103 if ($month_end < 1) {
104 $month_end = 12;
105 }
106 } else {
107 $month_end = $month_start;
108 }
109 $date_start = dol_get_first_day($year_start, $month_start, false);
110 $date_end = dol_get_last_day($year_end, $month_end, false);
111 }
112 if ($q == 1) {
113 $date_start = dol_get_first_day($year_start, 1, false);
114 $date_end = dol_get_last_day($year_start, 3, false);
115 }
116 if ($q == 2) {
117 $date_start = dol_get_first_day($year_start, 4, false);
118 $date_end = dol_get_last_day($year_start, 6, false);
119 }
120 if ($q == 3) {
121 $date_start = dol_get_first_day($year_start, 7, false);
122 $date_end = dol_get_last_day($year_start, 9, false);
123 }
124 if ($q == 4) {
125 $date_start = dol_get_first_day($year_start, 10, false);
126 $date_end = dol_get_last_day($year_start, 12, false);
127 }
128}
129
130// $date_start and $date_end are defined. We force $year_start and $nbofyear
131$tmps = dol_getdate($date_start);
132$year_start = $tmps['year'];
133$tmpe = dol_getdate($date_end);
134$year_end = $tmpe['year'];
135$nbofyear = ($year_end - $year_start) + 1;
136//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'));
137
138// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
139$modecompta = $conf->global->ACCOUNTING_MODE;
140if (isModEnabled('accounting')) {
141 $modecompta = 'BOOKKEEPING';
142}
143if (GETPOST("modecompta", 'alpha')) {
144 $modecompta = GETPOST("modecompta", 'alpha');
145}
146
147$AccCat = new AccountancyCategory($db);
148
149// Security check
150$socid = GETPOST('socid', 'int');
151if ($user->socid > 0) {
152 $socid = $user->socid;
153}
154if (isModEnabled('comptabilite')) {
155 $result = restrictedArea($user, 'compta', '', '', 'resultat');
156}
157if (isModEnabled('accounting')) {
158 $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
159}
160$hookmanager->initHooks(['customersupplierreportlist']);
161
162
163/*
164 * View
165 */
166
167llxHeader();
168
169$form = new Form($db);
170
171$periodlink = '';
172$exportlink = '';
173
174$total_ht = 0;
175$total_ttc = 0;
176
177// Affiche en-tete de rapport
178if ($modecompta == "CREANCES-DETTES") {
179 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
180 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
181 $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>" : "");
182 $description = $langs->trans("RulesResultDue");
183 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
184 $description .= $langs->trans("DepositsAreNotIncluded");
185 } else {
186 $description .= $langs->trans("DepositsAreIncluded");
187 }
188 if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
189 $description .= $langs->trans("SupplierDepositsAreNotIncluded");
190 }
191 $builddate = dol_now();
192 //$exportlink=$langs->trans("NotYetAvailable");
193} elseif ($modecompta == "RECETTES-DEPENSES") {
194 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
195 $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
196 $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>" : "");
197 $description = $langs->trans("RulesResultInOut");
198 $builddate = dol_now();
199 //$exportlink=$langs->trans("NotYetAvailable");
200} elseif ($modecompta == "BOOKKEEPING") {
201 $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
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 $arraylist = array('no'=>$langs->trans("CustomerCode"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
204 $period .= ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("DetailBy").'</span> '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
205 $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>" : "");
206 $description = $langs->trans("RulesResultBookkeepingPredefined");
207 $description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts")).')';
208 $builddate = dol_now();
209 //$exportlink=$langs->trans("NotYetAvailable");
210}
211
212// Define $calcmode line
213$calcmode = '';
214if (isModEnabled('accounting')) {
215 $calcmode .= '<input type="radio" name="modecompta" id="modecompta3" value="BOOKKEEPING"'.($modecompta == 'BOOKKEEPING' ? ' checked="checked"' : '').'><label for="modecompta3"> '.$langs->trans("CalcModeBookkeeping").'</label>';
216 $calcmode .= '<br>';
217}
218$calcmode .= '<input type="radio" name="modecompta" id="modecompta1" value="RECETTES-DEPENSES"'.($modecompta == 'RECETTES-DEPENSES' ? ' checked="checked"' : '').'><label for="modecompta1"> '.$langs->trans("CalcModeEngagement");
219if (isModEnabled('accounting')) {
220 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
221}
222$calcmode .= '</label>';
223$calcmode .= '<br><input type="radio" name="modecompta" id="modecompta2" value="CREANCES-DETTES"'.($modecompta == 'CREANCES-DETTES' ? ' checked="checked"' : '').'><label for="modecompta2"> '.$langs->trans("CalcModeDebt");
224if (isModEnabled('accounting')) {
225 $calcmode .= ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("CalcModeNoBookKeeping").')</span>';
226}
227$calcmode .= '</label>';
228
229
230report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'showaccountdetail'=>$showaccountdetail), $calcmode);
231
232if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
233 print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
234}
235
236// Show report array
237$param = '&modecompta='.urlencode($modecompta).'&showaccountdetail='.urlencode($showaccountdetail);
238if ($date_startday) {
239 $param .= '&date_startday='.$date_startday;
240}
241if ($date_startmonth) {
242 $param .= '&date_startmonth='.$date_startmonth;
243}
244if ($date_startyear) {
245 $param .= '&date_startyear='.$date_startyear;
246}
247if ($date_endday) {
248 $param .= '&date_endday='.$date_endday;
249}
250if ($date_endmonth) {
251 $param .= '&date_endmonth='.$date_endmonth;
252}
253if ($date_endyear) {
254 $param .= '&date_endyear='.$date_endyear;
255}
256
257print '<table class="liste noborder centpercent">';
258print '<tr class="liste_titre">';
259
260if ($modecompta == 'BOOKKEEPING') {
261 print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
262} else {
263 print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'width200 ');
264}
266if ($modecompta == 'BOOKKEEPING') {
267 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'amount', '', $param, 'class="right"', $sortfield, $sortorder);
268} else {
269 if ($modecompta == 'CREANCES-DETTES') {
270 print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder);
271 } else {
272 print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is
273 }
274 print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
275}
276print "</tr>\n";
277
278
279$total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
280
281
282if ($modecompta == 'BOOKKEEPING') {
283 $predefinedgroupwhere = "(";
284 $predefinedgroupwhere .= " (pcg_type = 'EXPENSE')";
285 $predefinedgroupwhere .= " OR ";
286 $predefinedgroupwhere .= " (pcg_type = 'INCOME')";
287 $predefinedgroupwhere .= ")";
288
289 $charofaccountstring = getDolGlobalInt('CHARTOFACCOUNTS');
290 $charofaccountstring = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
291
292 $sql = "SELECT -1 as socid, aa.pcg_type, SUM(f.credit - f.debit) as amount";
293 if ($showaccountdetail == 'no') {
294 $sql .= ", f.thirdparty_code as name";
295 }
296 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
297 $sql .= ", ".MAIN_DB_PREFIX."accounting_account as aa";
298 $sql .= " WHERE f.numero_compte = aa.account_number";
299 $sql .= " AND ".$predefinedgroupwhere;
300 $sql .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
301 $sql .= " AND f.entity = ".$conf->entity;
302 if (!empty($date_start) && !empty($date_end)) {
303 $sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
304 }
305 $sql .= " GROUP BY pcg_type";
306 if ($showaccountdetail == 'no') {
307 $sql .= ", name, socid"; // group by "accounting group" (INCOME/EXPENSE), then "customer".
308 }
309 $sql .= $db->order($sortfield, $sortorder);
310
311 $oldpcgtype = '';
312
313 dol_syslog("get bookkeeping entries", LOG_DEBUG);
314 $result = $db->query($sql);
315 if ($result) {
316 $num = $db->num_rows($result);
317 $i = 0;
318 if ($num > 0) {
319 while ($i < $num) {
320 $objp = $db->fetch_object($result);
321
322 if ($showaccountdetail == 'no') {
323 if ($objp->pcg_type != $oldpcgtype) {
324 print '<tr class="trforbreak"><td colspan="3" class="tdforbreak">'.dol_escape_htmltag($objp->pcg_type).'</td></tr>';
325 $oldpcgtype = $objp->pcg_type;
326 }
327 }
328
329 if ($showaccountdetail == 'no') {
330 print '<tr class="oddeven">';
331 print '<td></td>';
332 print '<td>';
333 print dol_escape_htmltag($objp->pcg_type);
334 print($objp->name ? ' ('.dol_escape_htmltag($objp->name).')' : ' ('.$langs->trans("Unknown").')');
335 print "</td>\n";
336 print '<td class="right nowraponall"><span class="amount">'.price($objp->amount)."</span></td>\n";
337 print "</tr>\n";
338 } else {
339 print '<tr class="oddeven trforbreak">';
340 print '<td colspan="2" class="tdforbreak">';
341 print dol_escape_htmltag($objp->pcg_type);
342 print "</td>\n";
343 print '<td class="right nowraponall tdforbreak"><span class="amount">'.price($objp->amount)."</span></td>\n";
344 print "</tr>\n";
345 }
346
347 $total_ht += (isset($objp->amount) ? $objp->amount : 0);
348 $total_ttc += (isset($objp->amount) ? $objp->amount : 0);
349
350 if ($objp->pcg_type == 'INCOME') {
351 $total_ht_income += (isset($objp->amount) ? $objp->amount : 0);
352 $total_ttc_income += (isset($objp->amount) ? $objp->amount : 0);
353 }
354 if ($objp->pcg_type == 'EXPENSE') {
355 $total_ht_outcome -= (isset($objp->amount) ? $objp->amount : 0);
356 $total_ttc_outcome -= (isset($objp->amount) ? $objp->amount : 0);
357 }
358
359 // Loop on detail of all accounts
360 // This make 14 calls for each detail of account (NP, N and month m)
361 if ($showaccountdetail != 'no') {
362 $tmppredefinedgroupwhere = "pcg_type = '".$db->escape($objp->pcg_type)."'";
363 $tmppredefinedgroupwhere .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
364 //$tmppredefinedgroupwhere .= " AND thirdparty_code = '".$db->escape($objp->name)."'";
365
366 // Get cpts of category/group
367 $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere);
368
369 foreach ($cpts as $j => $cpt) {
370 $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, (empty($cpt['dc']) ? 0 : $cpt['dc']));
371 if ($return < 0) {
372 setEventMessages(null, $AccCat->errors, 'errors');
373 $resultN = 0;
374 } else {
375 $resultN = $AccCat->sdc;
376 }
377
378
379 if ($showaccountdetail == 'all' || $resultN != 0) {
380 print '<tr>';
381 print '<td></td>';
382 print '<td class="tdoverflowmax200"> &nbsp; &nbsp; '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].'</td>';
383 print '<td class="right nowraponall"><span class="amount">'.price($resultN).'</span></td>';
384 print "</tr>\n";
385 }
386 }
387 }
388
389 $i++;
390 }
391 } else {
392 print '<tr><td colspan="3" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
393 }
394 } else {
395 dol_print_error($db);
396 }
397} else {
398 /*
399 * Customer invoices
400 */
401 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>';
402
403 if ($modecompta == 'CREANCES-DETTES') {
404 $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
405 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
406 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
407 $sql .= " WHERE f.fk_soc = s.rowid";
408 $sql .= " AND f.fk_statut IN (1,2)";
409 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
410 $sql .= " AND f.type IN (0,1,2,5)";
411 } else {
412 $sql .= " AND f.type IN (0,1,2,3,5)";
413 }
414 if (!empty($date_start) && !empty($date_end)) {
415 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
416 }
417 } elseif ($modecompta == 'RECETTES-DEPENSES') {
418 /*
419 * List of payments (old payments are not seen by this query because, on older versions, they were not linked via payment_invoice.
420 * old versions, they were not linked via payment_invoice. They are added later)
421 */
422 $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
423 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
424 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
425 $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
426 $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
427 $sql .= " WHERE p.rowid = pf.fk_paiement";
428 $sql .= " AND pf.fk_facture = f.rowid";
429 $sql .= " AND f.fk_soc = s.rowid";
430 if (!empty($date_start) && !empty($date_end)) {
431 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
432 }
433 }
434 $sql .= " AND f.entity IN (".getEntity('invoice').")";
435 if ($socid) {
436 $sql .= " AND f.fk_soc = ".((int) $socid);
437 }
438 $sql .= " GROUP BY name, socid";
439 $sql .= $db->order($sortfield, $sortorder);
440
441 dol_syslog("get customer invoices", LOG_DEBUG);
442 $result = $db->query($sql);
443 if ($result) {
444 $num = $db->num_rows($result);
445 $i = 0;
446 while ($i < $num) {
447 $objp = $db->fetch_object($result);
448
449 print '<tr class="oddeven">';
450 print '<td>&nbsp;</td>';
451 print "<td>".$langs->trans("Bills").' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$objp->socid.'">'.$objp->name."</td>\n";
452
453 print '<td class="right">';
454 if ($modecompta == 'CREANCES-DETTES') {
455 print '<span class="amount">'.price($objp->amount_ht)."</span>";
456 }
457 print "</td>\n";
458 print '<td class="right"><span class="amount">'.price($objp->amount_ttc)."</span></td>\n";
459
460 $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
461 $total_ttc += $objp->amount_ttc;
462 print "</tr>\n";
463 $i++;
464 }
465 $db->free($result);
466 } else {
467 dol_print_error($db);
468 }
469
470 // We add the old customer payments, not linked by payment_invoice
471 if ($modecompta == 'RECETTES-DEPENSES') {
472 $sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc";
473 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
474 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
475 $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
476 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
477 $sql .= " WHERE pf.rowid IS NULL";
478 $sql .= " AND p.fk_bank = b.rowid";
479 $sql .= " AND b.fk_account = ba.rowid";
480 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
481 if (!empty($date_start) && !empty($date_end)) {
482 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
483 }
484 $sql .= " GROUP BY name, idp";
485 $sql .= " ORDER BY name";
486
487 dol_syslog("get old customer payments not linked to invoices", LOG_DEBUG);
488 $result = $db->query($sql);
489 if ($result) {
490 $num = $db->num_rows($result);
491 $i = 0;
492 if ($num) {
493 while ($i < $num) {
494 $objp = $db->fetch_object($result);
495
496
497 print '<tr class="oddeven">';
498 print '<td>&nbsp;</td>';
499 print "<td>".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n";
500
501 print '<td class="right">';
502 if ($modecompta == 'CREANCES-DETTES') {
503 print '<span class="amount">'.price($objp->amount_ht)."</span></td>\n";
504 }
505 print '</td>';
506 print '<td class="right"><span class="amount">'.price($objp->amount_ttc)."</span></td>\n";
507
508 $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
509 $total_ttc += $objp->amount_ttc;
510
511 print "</tr>\n";
512 $i++;
513 }
514 }
515 $db->free($result);
516 } else {
517 dol_print_error($db);
518 }
519 }
520
521 if ($total_ttc == 0) {
522 print '<tr class="oddeven">';
523 print '<td>&nbsp;</td>';
524 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
525 print '</tr>';
526 }
527
528 $total_ht_income += $total_ht;
529 $total_ttc_income += $total_ttc;
530
531 print '<tr class="liste_total">';
532 print '<td></td>';
533 print '<td></td>';
534 print '<td class="right">';
535 if ($modecompta == 'CREANCES-DETTES') {
536 print price($total_ht);
537 }
538 print '</td>';
539 print '<td class="right">'.price($total_ttc).'</td>';
540 print '</tr>';
541
542 /*
543 * Donations
544 */
545
546 if (isModEnabled('don')) {
547 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
548
549 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
550 if ($modecompta == 'CREANCES-DETTES') {
551 $sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
552 $sql .= " FROM ".MAIN_DB_PREFIX."don as p";
553 $sql .= " WHERE p.entity IN (".getEntity('donation').")";
554 $sql .= " AND fk_statut in (1,2)";
555 } else {
556 $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
557 $sql .= " FROM ".MAIN_DB_PREFIX."don as p";
558 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
559 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
560 $sql .= " WHERE p.entity IN (".getEntity('donation').")";
561 $sql .= " AND fk_statut >= 2";
562 }
563 if (!empty($date_start) && !empty($date_end)) {
564 $sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
565 }
566 }
567 $sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
568 $newsortfield = $sortfield;
569 if ($newsortfield == 's.nom, s.rowid') {
570 $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
571 }
572 if ($newsortfield == 'amount_ht') {
573 $newsortfield = 'amount';
574 }
575 if ($newsortfield == 'amount_ttc') {
576 $newsortfield = 'amount';
577 }
578 $sql .= $db->order($newsortfield, $sortorder);
579
580 dol_syslog("get dunning");
581 $result = $db->query($sql);
582 $subtotal_ht = 0;
583 $subtotal_ttc = 0;
584 if ($result) {
585 $num = $db->num_rows($result);
586 $i = 0;
587 if ($num) {
588 while ($i < $num) {
589 $obj = $db->fetch_object($result);
590
591 $total_ht += $obj->amount;
592 $total_ttc += $obj->amount;
593 $subtotal_ht += $obj->amount;
594 $subtotal_ttc += $obj->amount;
595
596 print '<tr class="oddeven">';
597 print '<td>&nbsp;</td>';
598
599 print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
600
601 print '<td class="right">';
602 if ($modecompta == 'CREANCES-DETTES') {
603 print '<span class="amount">'.price($obj->amount).'</span>';
604 }
605 print '</td>';
606 print '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
607 print '</tr>';
608 $i++;
609 }
610 } else {
611 print '<tr class="oddeven"><td>&nbsp;</td>';
612 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
613 print '</tr>';
614 }
615 } else {
616 dol_print_error($db);
617 }
618
619 $total_ht_income += $subtotal_ht;
620 $total_ttc_income += $subtotal_ttc;
621
622 print '<tr class="liste_total">';
623 print '<td></td>';
624 print '<td></td>';
625 print '<td class="right">';
626 if ($modecompta == 'CREANCES-DETTES') {
627 print price($subtotal_ht);
628 }
629 print '</td>';
630 print '<td class="right">'.price($subtotal_ttc).'</td>';
631 print '</tr>';
632 }
633
634 /*
635 * Suppliers invoices
636 */
637 if ($modecompta == 'CREANCES-DETTES') {
638 $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
639 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
640 $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
641 $sql .= " WHERE f.fk_soc = s.rowid";
642 $sql .= " AND f.fk_statut IN (1,2)";
643 if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
644 $sql .= " AND f.type IN (0,1,2)";
645 } else {
646 $sql .= " AND f.type IN (0,1,2,3)";
647 }
648 if (!empty($date_start) && !empty($date_end)) {
649 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
650 }
651 } elseif ($modecompta == 'RECETTES-DEPENSES') {
652 $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
653 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
654 $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
655 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
656 $sql .= " ON pf.fk_facturefourn = f.rowid";
657 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
658 $sql .= " ON f.fk_soc = s.rowid";
659 $sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
660 if (!empty($date_start) && !empty($date_end)) {
661 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
662 }
663 }
664
665 $sql .= " AND f.entity = ".((int) $conf->entity);
666 if ($socid) {
667 $sql .= " AND f.fk_soc = ".((int) $socid);
668 }
669 $sql .= " GROUP BY name, socid";
670 $sql .= $db->order($sortfield, $sortorder);
671
672 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
673
674 $subtotal_ht = 0;
675 $subtotal_ttc = 0;
676 dol_syslog("get suppliers invoices", LOG_DEBUG);
677 $result = $db->query($sql);
678 if ($result) {
679 $num = $db->num_rows($result);
680 $i = 0;
681 if ($num > 0) {
682 while ($i < $num) {
683 $objp = $db->fetch_object($result);
684
685 print '<tr class="oddeven">';
686 print '<td>&nbsp;</td>';
687 print "<td>".$langs->trans("Bills").' <a href="'.DOL_URL_ROOT."/fourn/facture/list.php?socid=".$objp->socid.'">'.$objp->name.'</a></td>'."\n";
688
689 print '<td class="right">';
690 if ($modecompta == 'CREANCES-DETTES') {
691 print '<span class="amount">'.price(-$objp->amount_ht)."</span>";
692 }
693 print "</td>\n";
694 print '<td class="right"><span class="amount">'.price(-$objp->amount_ttc)."</span></td>\n";
695
696 $total_ht -= (isset($objp->amount_ht) ? $objp->amount_ht : 0);
697 $total_ttc -= $objp->amount_ttc;
698 $subtotal_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
699 $subtotal_ttc += $objp->amount_ttc;
700
701 print "</tr>\n";
702 $i++;
703 }
704 } else {
705 print '<tr class="oddeven">';
706 print '<td>&nbsp;</td>';
707 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
708 print '</tr>';
709 }
710
711 $db->free($result);
712 } else {
713 dol_print_error($db);
714 }
715
716 $total_ht_outcome += $subtotal_ht;
717 $total_ttc_outcome += $subtotal_ttc;
718
719 print '<tr class="liste_total">';
720 print '<td></td>';
721 print '<td></td>';
722 print '<td class="right">';
723 if ($modecompta == 'CREANCES-DETTES') {
724 print price(-$subtotal_ht);
725 }
726 print '</td>';
727 print '<td class="right">'.price(-$subtotal_ttc).'</td>';
728 print '</tr>';
729
730
731 /*
732 * Social / Fiscal contributions who are not deductible
733 */
734
735 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>';
736
737 if ($modecompta == 'CREANCES-DETTES') {
738 $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(cs.amount) as amount";
739 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
740 $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
741 $sql .= " WHERE cs.fk_type = c.id";
742 $sql .= " AND c.deductible = 0";
743 if (!empty($date_start) && !empty($date_end)) {
744 $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
745 }
746 } elseif ($modecompta == 'RECETTES-DEPENSES') {
747 $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(p.amount) as amount";
748 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
749 $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
750 $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
751 $sql .= " WHERE p.fk_charge = cs.rowid";
752 $sql .= " AND cs.fk_type = c.id";
753 $sql .= " AND c.deductible = 0";
754 if (!empty($date_start) && !empty($date_end)) {
755 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
756 }
757 }
758 $sql .= " AND cs.entity = ".$conf->entity;
759 $sql .= " GROUP BY c.libelle, c.id, c.accountancy_code";
760 $newsortfield = $sortfield;
761 if ($newsortfield == 's.nom, s.rowid') {
762 $newsortfield = 'c.libelle, c.id';
763 }
764 if ($newsortfield == 'amount_ht') {
765 $newsortfield = 'amount';
766 }
767 if ($newsortfield == 'amount_ttc') {
768 $newsortfield = 'amount';
769 }
770
771 $sql .= $db->order($newsortfield, $sortorder);
772
773 dol_syslog("get social contributions deductible=0", LOG_DEBUG);
774 $result = $db->query($sql);
775 $subtotal_ht = 0;
776 $subtotal_ttc = 0;
777 if ($result) {
778 $num = $db->num_rows($result);
779 $i = 0;
780 if ($num) {
781 while ($i < $num) {
782 $obj = $db->fetch_object($result);
783
784 $total_ht -= $obj->amount;
785 $total_ttc -= $obj->amount;
786 $subtotal_ht += $obj->amount;
787 $subtotal_ttc += $obj->amount;
788
789 $titletoshow = '';
790 if ($obj->accountancy_code) {
791 $titletoshow = $langs->trans("AccountingCode").': '.$obj->accountancy_code;
792 $tmpaccountingaccount = new AccountingAccount($db);
793 $tmpaccountingaccount->fetch(0, $obj->accountancy_code, 1);
794 $titletoshow .= ' - '.$langs->trans("AccountingCategory").': '.$tmpaccountingaccount->pcg_type;
795 }
796
797 print '<tr class="oddeven">';
798 print '<td>&nbsp;</td>';
799 print '<td'.($obj->accountancy_code ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>'.dol_escape_htmltag($obj->label).'</td>';
800 print '<td class="right">';
801 if ($modecompta == 'CREANCES-DETTES') {
802 print '<span class="amount">'.price(-$obj->amount).'</span>';
803 }
804 print '</td>';
805 print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
806 print '</tr>';
807 $i++;
808 }
809 } else {
810 print '<tr class="oddeven">';
811 print '<td>&nbsp;</td>';
812 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
813 print '</tr>';
814 }
815 } else {
816 dol_print_error($db);
817 }
818
819 $total_ht_outcome += $subtotal_ht;
820 $total_ttc_outcome += $subtotal_ttc;
821
822 print '<tr class="liste_total">';
823 print '<td></td>';
824 print '<td></td>';
825 print '<td class="right">';
826 if ($modecompta == 'CREANCES-DETTES') {
827 print price(-$subtotal_ht);
828 }
829 print '</td>';
830 print '<td class="right">'.price(-$subtotal_ttc).'</td>';
831 print '</tr>';
832
833
834 /*
835 * Social / Fiscal contributions who are deductible
836 */
837
838 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>';
839
840 if ($modecompta == 'CREANCES-DETTES') {
841 $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(cs.amount) as amount";
842 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
843 $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
844 $sql .= " WHERE cs.fk_type = c.id";
845 $sql .= " AND c.deductible = 1";
846 if (!empty($date_start) && !empty($date_end)) {
847 $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
848 }
849 $sql .= " AND cs.entity = ".$conf->entity;
850 } elseif ($modecompta == 'RECETTES-DEPENSES') {
851 $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(p.amount) as amount";
852 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
853 $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
854 $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
855 $sql .= " WHERE p.fk_charge = cs.rowid";
856 $sql .= " AND cs.fk_type = c.id";
857 $sql .= " AND c.deductible = 1";
858 if (!empty($date_start) && !empty($date_end)) {
859 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
860 }
861 $sql .= " AND cs.entity = ".$conf->entity;
862 }
863 $sql .= " GROUP BY c.libelle, c.id, c.accountancy_code";
864 $newsortfield = $sortfield;
865 if ($newsortfield == 's.nom, s.rowid') {
866 $newsortfield = 'c.libelle, c.id';
867 }
868 if ($newsortfield == 'amount_ht') {
869 $newsortfield = 'amount';
870 }
871 if ($newsortfield == 'amount_ttc') {
872 $newsortfield = 'amount';
873 }
874 $sql .= $db->order($newsortfield, $sortorder);
875
876 dol_syslog("get social contributions deductible=1", LOG_DEBUG);
877 $result = $db->query($sql);
878 $subtotal_ht = 0;
879 $subtotal_ttc = 0;
880 if ($result) {
881 $num = $db->num_rows($result);
882 $i = 0;
883 if ($num) {
884 while ($i < $num) {
885 $obj = $db->fetch_object($result);
886
887 $total_ht -= $obj->amount;
888 $total_ttc -= $obj->amount;
889 $subtotal_ht += $obj->amount;
890 $subtotal_ttc += $obj->amount;
891
892 $titletoshow = '';
893 if ($obj->accountancy_code) {
894 $titletoshow = $langs->trans("AccountingCode").': '.$obj->accountancy_code;
895 $tmpaccountingaccount = new AccountingAccount($db);
896 $tmpaccountingaccount->fetch(0, $obj->accountancy_code, 1);
897 $titletoshow .= ' - '.$langs->trans("AccountingCategory").': '.$tmpaccountingaccount->pcg_type;
898 }
899
900 print '<tr class="oddeven">';
901 print '<td>&nbsp;</td>';
902 print '<td'.($obj->accountancy_code ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>'.dol_escape_htmltag($obj->label).'</td>';
903 print '<td class="right">';
904 if ($modecompta == 'CREANCES-DETTES') {
905 print '<span class="amount">'.price(-$obj->amount).'</span>';
906 }
907 print '</td>';
908 print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
909 print '</tr>';
910 $i++;
911 }
912 } else {
913 print '<tr class="oddeven">';
914 print '<td>&nbsp;</td>';
915 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
916 print '</tr>';
917 }
918 } else {
919 dol_print_error($db);
920 }
921
922 $total_ht_outcome += $subtotal_ht;
923 $total_ttc_outcome += $subtotal_ttc;
924
925 print '<tr class="liste_total">';
926 print '<td></td>';
927 print '<td></td>';
928 print '<td class="right">';
929 if ($modecompta == 'CREANCES-DETTES') {
930 print price(-$subtotal_ht);
931 }
932 print '</td>';
933 print '<td class="right">'.price(-$subtotal_ttc).'</td>';
934 print '</tr>';
935
936
937 /*
938 * Salaries
939 */
940
941 if (isModEnabled('salaries')) {
942 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
943
944 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
945 if ($modecompta == 'CREANCES-DETTES') {
946 $column = 's.dateep'; // We use the date of end of period of salary
947
948 $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, s.label as label, date_format($column,'%Y-%m') as dm, sum(s.amount) as amount";
949 $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
950 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user";
951 $sql .= " WHERE s.entity IN (".getEntity('salary').")";
952 if (!empty($date_start) && !empty($date_end)) {
953 $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
954 }
955 $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, s.label, dm";
956 } else {
957 $column = 'p.datep';
958
959 $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
960 $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
961 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid = p.fk_salary";
962 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user";
963 $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")";
964 if (!empty($date_start) && !empty($date_end)) {
965 $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
966 }
967 $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm";
968 }
969
970 $newsortfield = $sortfield;
971 if ($newsortfield == 's.nom, s.rowid') {
972 $newsortfield = 'u.firstname, u.lastname';
973 }
974 if ($newsortfield == 'amount_ht') {
975 $newsortfield = 'amount';
976 }
977 if ($newsortfield == 'amount_ttc') {
978 $newsortfield = 'amount';
979 }
980 $sql .= $db->order($newsortfield, $sortorder);
981 }
982
983 dol_syslog("get salaries");
984 $result = $db->query($sql);
985 $subtotal_ht = 0;
986 $subtotal_ttc = 0;
987 if ($result) {
988 $num = $db->num_rows($result);
989 $i = 0;
990 if ($num) {
991 while ($i < $num) {
992 $obj = $db->fetch_object($result);
993
994 $total_ht -= $obj->amount;
995 $total_ttc -= $obj->amount;
996 $subtotal_ht += $obj->amount;
997 $subtotal_ttc += $obj->amount;
998
999 print '<tr class="oddeven"><td>&nbsp;</td>';
1000
1001 $userstatic = new User($db);
1002 $userstatic->fetch($obj->fk_user);
1003
1004 print "<td>".$langs->trans("Salary")." <a href=\"".DOL_URL_ROOT."/salaries/list.php?search_user=".urlencode($userstatic->getFullName($langs))."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
1005 print '<td class="right">';
1006 if ($modecompta == 'CREANCES-DETTES') {
1007 print '<span class="amount">'.price(-$obj->amount).'</span>';
1008 }
1009 print '</td>';
1010 print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
1011 print '</tr>';
1012 $i++;
1013 }
1014 } else {
1015 print '<tr class="oddeven">';
1016 print '<td>&nbsp;</td>';
1017 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
1018 print '</tr>';
1019 }
1020 } else {
1021 dol_print_error($db);
1022 }
1023
1024 $total_ht_outcome += $subtotal_ht;
1025 $total_ttc_outcome += $subtotal_ttc;
1026
1027 print '<tr class="liste_total">';
1028 print '<td></td>';
1029 print '<td></td>';
1030 print '<td class="right">';
1031 if ($modecompta == 'CREANCES-DETTES') {
1032 print price(-$subtotal_ht);
1033 }
1034 print '</td>';
1035 print '<td class="right">'.price(-$subtotal_ttc).'</td>';
1036 print '</tr>';
1037 }
1038
1039
1040 /*
1041 * Expense report
1042 */
1043
1044 if (isModEnabled('expensereport')) {
1045 if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
1046 $langs->load('trips');
1047 if ($modecompta == 'CREANCES-DETTES') {
1048 $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, p.total_ht as amount_ht, p.total_ttc as amount_ttc";
1049 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
1050 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
1051 $sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
1052 $sql .= " AND p.fk_statut>=5";
1053
1054 $column = 'p.date_valid';
1055 } else {
1056 $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(pe.amount) as amount_ht, sum(pe.amount) as amount_ttc";
1057 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
1058 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
1059 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
1060 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
1061 $sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
1062 $sql .= " AND p.fk_statut>=5";
1063
1064 $column = 'pe.datep';
1065 }
1066
1067 if (!empty($date_start) && !empty($date_end)) {
1068 $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
1069 }
1070
1071 if ($modecompta == 'CREANCES-DETTES') {
1072 //No need of GROUP BY
1073 } else {
1074 $sql .= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
1075 }
1076 $newsortfield = $sortfield;
1077 if ($newsortfield == 's.nom, s.rowid') {
1078 $newsortfield = 'p.ref';
1079 }
1080 $sql .= $db->order($newsortfield, $sortorder);
1081 }
1082
1083 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
1084
1085 dol_syslog("get expense report outcome");
1086 $result = $db->query($sql);
1087 $subtotal_ht = 0;
1088 $subtotal_ttc = 0;
1089 if ($result) {
1090 $num = $db->num_rows($result);
1091 if ($num) {
1092 while ($obj = $db->fetch_object($result)) {
1093 $total_ht -= $obj->amount_ht;
1094 $total_ttc -= $obj->amount_ttc;
1095 $subtotal_ht += $obj->amount_ht;
1096 $subtotal_ttc += $obj->amount_ttc;
1097
1098 print '<tr class="oddeven">';
1099 print '<td>&nbsp;</td>';
1100 print "<td>".$langs->trans("ExpenseReport")." <a href=\"".DOL_URL_ROOT."/expensereport/list.php?search_user=".$obj->userid."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
1101 print '<td class="right">';
1102 if ($modecompta == 'CREANCES-DETTES') {
1103 print '<span class="amount">'.price(-$obj->amount_ht).'</span>';
1104 }
1105 print '</td>';
1106 print '<td class="right"><span class="amount">'.price(-$obj->amount_ttc).'</span></td>';
1107 print '</tr>';
1108 }
1109 } else {
1110 print '<tr class="oddeven">';
1111 print '<td>&nbsp;</td>';
1112 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
1113 print '</tr>';
1114 }
1115 } else {
1116 dol_print_error($db);
1117 }
1118
1119 $total_ht_outcome += $subtotal_ht;
1120 $total_ttc_outcome += $subtotal_ttc;
1121
1122 print '<tr class="liste_total">';
1123 print '<td></td>';
1124 print '<td></td>';
1125 print '<td class="right">';
1126 if ($modecompta == 'CREANCES-DETTES') {
1127 print price(-$subtotal_ht);
1128 }
1129 print '</td>';
1130 print '<td class="right">'.price(-$subtotal_ttc).'</td>';
1131 print '</tr>';
1132 }
1133
1134
1135 /*
1136 * Various Payments
1137 */
1138 //$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
1139
1140 if (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_VARPAY') && isModEnabled("banque") && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
1141 $subtotal_ht = 0;
1142 $subtotal_ttc = 0;
1143
1144 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VariousPayment").'</td></tr>';
1145
1146 // Debit
1147 $sql = "SELECT SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
1148 $sql .= ' WHERE 1 = 1';
1149 if (!empty($date_start) && !empty($date_end)) {
1150 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
1151 }
1152 $sql .= ' GROUP BY p.sens';
1153 $sql .= ' ORDER BY p.sens';
1154
1155 dol_syslog('get various payments', LOG_DEBUG);
1156 $result = $db->query($sql);
1157 if ($result) {
1158 // Debit (payment of suppliers for example)
1159 $obj = $db->fetch_object($result);
1160 if (isset($obj->amount)) {
1161 $subtotal_ht += -$obj->amount;
1162 $subtotal_ttc += -$obj->amount;
1163
1164 $total_ht_outcome += $obj->amount;
1165 $total_ttc_outcome += $obj->amount;
1166 }
1167 print '<tr class="oddeven">';
1168 print '<td>&nbsp;</td>';
1169 print "<td>".$langs->trans("AccountingDebit")."</td>\n";
1170 print '<td class="right">';
1171 if ($modecompta == 'CREANCES-DETTES') {
1172 print '<span class="amount">'.price(-$obj->amount).'</span>';
1173 }
1174 print '</td>';
1175 print '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
1176 print "</tr>\n";
1177
1178 // Credit (payment received from customer for example)
1179 $obj = $db->fetch_object($result);
1180 if (isset($obj->amount)) {
1181 $subtotal_ht += $obj->amount;
1182 $subtotal_ttc += $obj->amount;
1183
1184 $total_ht_income += $obj->amount;
1185 $total_ttc_income += $obj->amount;
1186 }
1187 print '<tr class="oddeven"><td>&nbsp;</td>';
1188 print "<td>".$langs->trans("AccountingCredit")."</td>\n";
1189 print '<td class="right">';
1190 if ($modecompta == 'CREANCES-DETTES') {
1191 print '<span class="amount">'.price($obj->amount).'</span>';
1192 }
1193 print '</td>';
1194 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
1195 print "</tr>\n";
1196
1197 // Total
1198 $total_ht += $subtotal_ht;
1199 $total_ttc += $subtotal_ttc;
1200 print '<tr class="liste_total">';
1201 print '<td></td>';
1202 print '<td></td>';
1203 print '<td class="right">';
1204 if ($modecompta == 'CREANCES-DETTES') {
1205 print price($subtotal_ht);
1206 }
1207 print '</td>';
1208 print '<td class="right">'.price($subtotal_ttc).'</td>';
1209 print '</tr>';
1210 } else {
1211 dol_print_error($db);
1212 }
1213 }
1214
1215 /*
1216 * Payment Loan
1217 */
1218
1219 if (getDolGlobalString('ACCOUNTING_REPORTS_INCLUDE_LOAN') && isModEnabled('don') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
1220 $subtotal_ht = 0;
1221 $subtotal_ttc = 0;
1222
1223 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("PaymentLoan").'</td></tr>';
1224
1225 $sql = 'SELECT l.rowid as id, l.label AS label, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) as amount FROM '.MAIN_DB_PREFIX.'payment_loan as p';
1226 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'loan AS l ON l.rowid = p.fk_loan';
1227 $sql .= ' WHERE 1 = 1';
1228 if (!empty($date_start) && !empty($date_end)) {
1229 $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
1230 }
1231 $sql .= ' GROUP BY p.fk_loan';
1232 $sql .= ' ORDER BY p.fk_loan';
1233
1234 dol_syslog('get loan payments', LOG_DEBUG);
1235 $result = $db->query($sql);
1236 if ($result) {
1237 require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
1238 $loan_static = new Loan($db);
1239 while ($obj = $db->fetch_object($result)) {
1240 $loan_static->id = $obj->id;
1241 $loan_static->ref = $obj->id;
1242 $loan_static->label = $obj->label;
1243 print '<tr class="oddeven"><td>&nbsp;</td>';
1244 print "<td>".$loan_static->getNomUrl(1).' - '.$obj->label."</td>\n";
1245 if ($modecompta == 'CREANCES-DETTES') {
1246 print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
1247 }
1248 print '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
1249 print "</tr>\n";
1250 $subtotal_ht -= $obj->amount;
1251 $subtotal_ttc -= $obj->amount;
1252 }
1253 $total_ht += $subtotal_ht;
1254 $total_ttc += $subtotal_ttc;
1255
1256 $total_ht_income += $subtotal_ht;
1257 $total_ttc_income += $subtotal_ttc;
1258
1259 print '<tr class="liste_total">';
1260 print '<td></td>';
1261 print '<td></td>';
1262 print '<td class="right">';
1263 if ($modecompta == 'CREANCES-DETTES') {
1264 print price($subtotal_ht);
1265 }
1266 print '</td>';
1267 print '<td class="right">'.price($subtotal_ttc).'</td>';
1268 print '</tr>';
1269 } else {
1270 dol_print_error($db);
1271 }
1272 }
1273
1274 /*
1275 * VAT
1276 */
1277
1278 print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VAT").'</td></tr>';
1279 $subtotal_ht = 0;
1280 $subtotal_ttc = 0;
1281
1282 if (isModEnabled('tax') && ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')) {
1283 if ($modecompta == 'CREANCES-DETTES') {
1284 // VAT to pay
1285 $amount = 0;
1286 $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
1287 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
1288 $sql .= " WHERE f.fk_statut IN (1,2)";
1289 if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
1290 $sql .= " AND f.type IN (0,1,2,5)";
1291 } else {
1292 $sql .= " AND f.type IN (0,1,2,3,5)";
1293 }
1294 if (!empty($date_start) && !empty($date_end)) {
1295 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
1296 }
1297 $sql .= " AND f.entity IN (".getEntity('invoice').")";
1298 $sql .= " GROUP BY dm";
1299 $newsortfield = $sortfield;
1300 if ($newsortfield == 's.nom, s.rowid') {
1301 $newsortfield = 'dm';
1302 }
1303 if ($newsortfield == 'amount_ht') {
1304 $newsortfield = 'amount';
1305 }
1306 if ($newsortfield == 'amount_ttc') {
1307 $newsortfield = 'amount';
1308 }
1309 $sql .= $db->order($newsortfield, $sortorder);
1310
1311 dol_syslog("get vat to pay", LOG_DEBUG);
1312 $result = $db->query($sql);
1313 if ($result) {
1314 $num = $db->num_rows($result);
1315 $i = 0;
1316 if ($num) {
1317 while ($i < $num) {
1318 $obj = $db->fetch_object($result);
1319
1320 $amount -= $obj->amount;
1321 //$total_ht -= $obj->amount;
1322 $total_ttc -= $obj->amount;
1323 //$subtotal_ht -= $obj->amount;
1324 $subtotal_ttc -= $obj->amount;
1325 $i++;
1326 }
1327 }
1328 } else {
1329 dol_print_error($db);
1330 }
1331
1332 $total_ht_outcome -= 0;
1333 $total_ttc_outcome -= $amount;
1334
1335 print '<tr class="oddeven">';
1336 print '<td>&nbsp;</td>';
1337 print "<td>".$langs->trans("VATToPay")."</td>\n";
1338 print '<td class="right">&nbsp;</td>'."\n";
1339 print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
1340 print "</tr>\n";
1341
1342 // VAT to retrieve
1343 $amount = 0;
1344 $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
1345 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
1346 $sql .= " WHERE f.fk_statut IN (1,2)";
1347 if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
1348 $sql .= " AND f.type IN (0,1,2)";
1349 } else {
1350 $sql .= " AND f.type IN (0,1,2,3)";
1351 }
1352 if (!empty($date_start) && !empty($date_end)) {
1353 $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
1354 }
1355 $sql .= " AND f.entity = ".$conf->entity;
1356 $sql .= " GROUP BY dm";
1357 $newsortfield = $sortfield;
1358 if ($newsortfield == 's.nom, s.rowid') {
1359 $newsortfield = 'dm';
1360 }
1361 if ($newsortfield == 'amount_ht') {
1362 $newsortfield = 'amount';
1363 }
1364 if ($newsortfield == 'amount_ttc') {
1365 $newsortfield = 'amount';
1366 }
1367 $sql .= $db->order($newsortfield, $sortorder);
1368
1369 dol_syslog("get vat received back", LOG_DEBUG);
1370 $result = $db->query($sql);
1371 if ($result) {
1372 $num = $db->num_rows($result);
1373 $i = 0;
1374 if ($num) {
1375 while ($i < $num) {
1376 $obj = $db->fetch_object($result);
1377
1378 $amount += $obj->amount;
1379 //$total_ht += $obj->amount;
1380 $total_ttc += $obj->amount;
1381 //$subtotal_ht += $obj->amount;
1382 $subtotal_ttc += $obj->amount;
1383
1384 $i++;
1385 }
1386 }
1387 } else {
1388 dol_print_error($db);
1389 }
1390
1391 $total_ht_income += 0;
1392 $total_ttc_income += $amount;
1393
1394 print '<tr class="oddeven">';
1395 print '<td>&nbsp;</td>';
1396 print '<td>'.$langs->trans("VATToCollect")."</td>\n";
1397 print '<td class="right">&nbsp;</td>'."\n";
1398 print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
1399 print "</tr>\n";
1400 } else {
1401 // VAT really already paid
1402 $amount = 0;
1403 $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
1404 $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
1405 $sql .= " WHERE amount > 0";
1406 if (!empty($date_start) && !empty($date_end)) {
1407 $sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
1408 }
1409 $sql .= " AND t.entity = ".$conf->entity;
1410 $sql .= " GROUP BY dm";
1411 $newsortfield = $sortfield;
1412 if ($newsortfield == 's.nom, s.rowid') {
1413 $newsortfield = 'dm';
1414 }
1415 if ($newsortfield == 'amount_ht') {
1416 $newsortfield = 'amount';
1417 }
1418 if ($newsortfield == 'amount_ttc') {
1419 $newsortfield = 'amount';
1420 }
1421 $sql .= $db->order($newsortfield, $sortorder);
1422
1423 dol_syslog("get vat really paid", LOG_DEBUG);
1424 $result = $db->query($sql);
1425 if ($result) {
1426 $num = $db->num_rows($result);
1427 $i = 0;
1428 if ($num) {
1429 while ($i < $num) {
1430 $obj = $db->fetch_object($result);
1431
1432 $amount -= $obj->amount;
1433 $total_ht -= $obj->amount;
1434 $total_ttc -= $obj->amount;
1435 $subtotal_ht -= $obj->amount;
1436 $subtotal_ttc -= $obj->amount;
1437
1438 $i++;
1439 }
1440 }
1441 $db->free($result);
1442 } else {
1443 dol_print_error($db);
1444 }
1445
1446 $total_ht_outcome -= 0;
1447 $total_ttc_outcome -= $amount;
1448
1449 print '<tr class="oddeven">';
1450 print '<td>&nbsp;</td>';
1451 print "<td>".$langs->trans("VATPaid")."</td>\n";
1452 print '<td <class="right"></td>'."\n";
1453 print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
1454 print "</tr>\n";
1455
1456 // VAT really received
1457 $amount = 0;
1458 $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
1459 $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
1460 $sql .= " WHERE amount < 0";
1461 if (!empty($date_start) && !empty($date_end)) {
1462 $sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
1463 }
1464 $sql .= " AND t.entity = ".$conf->entity;
1465 $sql .= " GROUP BY dm";
1466 $newsortfield = $sortfield;
1467 if ($newsortfield == 's.nom, s.rowid') {
1468 $newsortfield = 'dm';
1469 }
1470 if ($newsortfield == 'amount_ht') {
1471 $newsortfield = 'amount';
1472 }
1473 if ($newsortfield == 'amount_ttc') {
1474 $newsortfield = 'amount';
1475 }
1476 $sql .= $db->order($newsortfield, $sortorder);
1477
1478 dol_syslog("get vat really received back", LOG_DEBUG);
1479 $result = $db->query($sql);
1480 if ($result) {
1481 $num = $db->num_rows($result);
1482 $i = 0;
1483 if ($num) {
1484 while ($i < $num) {
1485 $obj = $db->fetch_object($result);
1486
1487 $amount += -$obj->amount;
1488 $total_ht += -$obj->amount;
1489 $total_ttc += -$obj->amount;
1490 $subtotal_ht += -$obj->amount;
1491 $subtotal_ttc += -$obj->amount;
1492
1493 $i++;
1494 }
1495 }
1496 $db->free($result);
1497 } else {
1498 dol_print_error($db);
1499 }
1500
1501 $total_ht_income += 0;
1502 $total_ttc_income += $amount;
1503
1504 print '<tr class="oddeven">';
1505 print '<td>&nbsp;</td>';
1506 print "<td>".$langs->trans("VATCollected")."</td>\n";
1507 print '<td class="right"></td>'."\n";
1508 print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
1509 print "</tr>\n";
1510 }
1511 }
1512
1513 if ($mysoc->tva_assuj != '0') { // Assujetti
1514 print '<tr class="liste_total">';
1515 print '<td></td>';
1516 print '<td></td>';
1517 print '<td class="right">&nbsp;</td>';
1518 print '<td class="right">'.price(price2num($subtotal_ttc, 'MT')).'</td>';
1519 print '</tr>';
1520 }
1521}
1522
1523$action = "balanceclient";
1524$object = array(&$total_ht, &$total_ttc);
1525$parameters["mode"] = $modecompta;
1526$parameters["date_start"] = $date_start;
1527$parameters["date_end"] = $date_end;
1528// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
1529$hookmanager->initHooks(array('externalbalance'));
1530$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1531print $hookmanager->resPrint;
1532
1533
1534
1535// Total
1536print '<tr>';
1537print '<td colspan="'.($modecompta == 'BOOKKEEPING' ? 3 : 4).'">&nbsp;</td>';
1538print '</tr>';
1539
1540print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
1541if ($modecompta == 'CREANCES-DETTES') {
1542 print '<td class="liste_total right nowraponall">'.price(price2num($total_ht_income, 'MT')).'</td>';
1543} elseif ($modecompta == 'RECETTES-DEPENSES') {
1544 print '<td></td>';
1545}
1546print '<td class="liste_total right nowraponall">'.price(price2num($total_ttc_income, 'MT')).'</td>';
1547print '</tr>';
1548print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
1549if ($modecompta == 'CREANCES-DETTES') {
1550 print '<td class="liste_total right nowraponall">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
1551} elseif ($modecompta == 'RECETTES-DEPENSES') {
1552 print '<td></td>';
1553}
1554print '<td class="liste_total right nowraponall">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
1555print '</tr>';
1556print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
1557if ($modecompta == 'CREANCES-DETTES') {
1558 print '<td class="liste_total right nowraponall">'.price(price2num($total_ht, 'MT')).'</td>';
1559} elseif ($modecompta == 'RECETTES-DEPENSES') {
1560 print '<td></td>';
1561}
1562print '<td class="liste_total right nowraponall">'.price(price2num($total_ttc, 'MT')).'</td>';
1563print '</tr>';
1564
1565print "</table>";
1566print '<br>';
1567
1568// End of page
1569llxFooter();
1570$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 categories of an accounting account.
Class to manage accounting accounts.
Class to manage generation of HTML components Only common components must be here.
Loan.
Class to manage Dolibarr users.
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 informations (by default a local PHP server timestamp) Re...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return 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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.