dolibarr  9.0.0
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
6  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('compta','bills','donation','salaries'));
36 
37 $date_startmonth=GETPOST('date_startmonth','int');
38 $date_startday=GETPOST('date_startday','int');
39 $date_startyear=GETPOST('date_startyear','int');
40 $date_endmonth=GETPOST('date_endmonth','int');
41 $date_endday=GETPOST('date_endday','int');
42 $date_endyear=GETPOST('date_endyear','int');
43 
44 $nbofyear=4;
45 
46 // Date range
47 $year=GETPOST('year','int');
48 if (empty($year))
49 {
50  $year_current = strftime("%Y",dol_now());
51  $month_current = strftime("%m",dol_now());
52  $year_start = $year_current - ($nbofyear - 1);
53 } else {
54  $year_current = $year;
55  $month_current = strftime("%m",dol_now());
56  $year_start = $year - ($nbofyear - 1);
57 }
58 $date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
59 $date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
60 
61 // We define date_start and date_end
62 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
63 {
64  $q=GETPOST("q")?GETPOST("q"):0;
65  if ($q==0)
66  {
67  // We define date_start and date_end
68  $year_end=$year_start + ($nbofyear - 1);
69  $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
70  if (! GETPOST('month'))
71  {
72  if (! GETPOST("year") && $month_start > $month_current)
73  {
74  $year_start--;
75  $year_end--;
76  }
77  $month_end=$month_start-1;
78  if ($month_end < 1) $month_end=12;
79  else $year_end++;
80  }
81  else $month_end=$month_start;
82  $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
83  }
84  if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
85  if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
86  if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
87  if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
88 }
89 
90 // $date_start and $date_end are defined. We force $year_start and $nbofyear
91 $tmps=dol_getdate($date_start);
92 $year_start = $tmps['year'];
93 $tmpe=dol_getdate($date_end);
94 $year_end = $tmpe['year'];
95 $nbofyear = ($year_end - $year_start) + 1;
96 //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'));
97 
98 
99 // Security check
100 $socid = GETPOST('socid','int');
101 if ($user->societe_id > 0) $socid = $user->societe_id;
102 if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
103 if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
104 
105 // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
106 $modecompta = $conf->global->ACCOUNTING_MODE;
107 if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
108 if (GETPOST("modecompta",'alpha')) $modecompta=GETPOST("modecompta",'alpha');
109 
110 
111 /*
112  * View
113  */
114 
115 llxHeader();
116 
117 $form=new Form($db);
118 
119 $exportlink='';
120 
121 // Affiche en-tete du rapport
122 if ($modecompta == 'CREANCES-DETTES')
123 {
124  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear");
125  $calcmode=$langs->trans("CalcModeDebt");
126  $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
127  if (! empty($conf->accounting->enabled)) $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
128  $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
129  $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
130  $description=$langs->trans("RulesAmountWithTaxIncluded");
131  $description.='<br>'.$langs->trans("RulesResultDue");
132  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.="<br>".$langs->trans("DepositsAreNotIncluded");
133  else $description.="<br>".$langs->trans("DepositsAreIncluded");
134  $builddate=dol_now();
135  //$exportlink=$langs->trans("NotYetAvailable");
136 }
137 else if ($modecompta=="RECETTES-DEPENSES") {
138  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear");
139  $calcmode=$langs->trans("CalcModeEngagement");
140  $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
141  if (! empty($conf->accounting->enabled)) $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
142  $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
143  $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
144  $description=$langs->trans("RulesAmountWithTaxIncluded");
145  $description.='<br>'.$langs->trans("RulesResultInOut");
146  $builddate=dol_now();
147  //$exportlink=$langs->trans("NotYetAvailable");
148 }
149 else if ($modecompta=="BOOKKEEPING")
150 {
151  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByYear");
152  $calcmode=$langs->trans("CalcModeBookkeeping");
153  $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
154  $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
155  $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
156  $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
157  $description=$langs->trans("RulesAmountOnInOutBookkeepingRecord");
158  $description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')';
159  $builddate=dol_now();
160  //$exportlink=$langs->trans("NotYetAvailable");
161 }
162 
163 $hselected='report';
164 
165 report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode);
166 
167 if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
168 {
169  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
170 }
171 
172 
173 
174 /*
175  * Factures clients
176  */
177 
178 $subtotal_ht = 0;
179 $subtotal_ttc = 0;
180 if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
181 {
182  if ($modecompta == 'CREANCES-DETTES')
183  {
184  $sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
185  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
186  $sql.= ", ".MAIN_DB_PREFIX."facture as f";
187  $sql.= " WHERE f.fk_soc = s.rowid";
188  $sql.= " AND f.fk_statut IN (1,2)";
189  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
190  else $sql.= " AND f.type IN (0,1,2,3,5)";
191  if (! empty($date_start) && ! empty($date_end))
192  $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
193  }
194  else if ($modecompta=="RECETTES-DEPENSES")
195  {
196  /*
197  * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
198  * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
199  */
200  $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
201  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
202  $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
203  $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
204  $sql.= " WHERE p.rowid = pf.fk_paiement";
205  $sql.= " AND pf.fk_facture = f.rowid";
206  if (! empty($date_start) && ! empty($date_end))
207  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
208  }
209 
210  $sql.= " AND f.entity = ".$conf->entity;
211  if ($socid) $sql.= " AND f.fk_soc = $socid";
212  $sql.= " GROUP BY dm";
213  $sql.= " ORDER BY dm";
214 
215  //print $sql;
216  dol_syslog("get customers invoices", LOG_DEBUG);
217  $result=$db->query($sql);
218  if ($result)
219  {
220  $num = $db->num_rows($result);
221  $i = 0;
222  while ($i < $num)
223  {
224  $row = $db->fetch_object($result);
225  $encaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
226  $encaiss_ttc[$row->dm] = $row->amount_ttc;
227  $i++;
228  }
229  $db->free($result);
230  }
231  else {
232  dol_print_error($db);
233  }
234 }
235 else if ($modecompta=="BOOKKEEPING")
236 {
237  // Nothing from this table
238 }
239 
240 if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
241 {
242  // On ajoute les paiements clients anciennes version, non lies par paiement_facture
243  if ($modecompta != 'CREANCES-DETTES')
244  {
245  $sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
246  $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
247  $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
248  $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
249  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
250  $sql.= " WHERE pf.rowid IS NULL";
251  $sql.= " AND p.fk_bank = b.rowid";
252  $sql.= " AND b.fk_account = ba.rowid";
253  $sql.= " AND ba.entity IN (".getEntity('bank_account').")";
254  if (! empty($date_start) && ! empty($date_end))
255  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
256  $sql.= " GROUP BY dm";
257  $sql.= " ORDER BY dm";
258 
259  dol_syslog("get old customers payments not linked to invoices", LOG_DEBUG);
260  $result = $db->query($sql);
261  if ($result) {
262  $num = $db->num_rows($result);
263  $i = 0;
264  while ($i < $num)
265  {
266  $row = $db->fetch_object($result);
267 
268  if (! isset($encaiss[$row->dm])) $encaiss[$row->dm]=0;
269  $encaiss[$row->dm] += (isset($row->amount_ht)?$row->amount_ht:0);
270 
271  if (! isset($encaiss_ttc[$row->dm])) $encaiss_ttc[$row->dm]=0;
272  $encaiss_ttc[$row->dm] += $row->amount_ttc;
273 
274  $i++;
275  }
276  }
277  else {
278  dol_print_error($db);
279  }
280  }
281  else if ($modecompta=="RECETTES-DEPENSES")
282  {
283  // Nothing from this table
284  }
285 }
286 else if ($modecompta=="BOOKKEEPING")
287 {
288  // Nothing from this table
289 }
290 
291 
292 /*
293  * Frais, factures fournisseurs.
294  */
295 $subtotal_ht = 0;
296 $subtotal_ttc = 0;
297 
298 if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
299 {
300  if ($modecompta == 'CREANCES-DETTES')
301  {
302  $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
303  $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
304  $sql.= " WHERE f.fk_statut IN (1,2)";
305  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
306  else $sql.= " AND f.type IN (0,1,2,3)";
307  if (! empty($date_start) && ! empty($date_end))
308  $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
309  }
310  else if ($modecompta=="RECETTES-DEPENSES")
311  {
312  $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
313  $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
314  $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
315  $sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
316  $sql.= " WHERE f.rowid = pf.fk_facturefourn";
317  $sql.= " AND p.rowid = pf.fk_paiementfourn";
318  if (! empty($date_start) && ! empty($date_end))
319  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
320  }
321 
322  $sql.= " AND f.entity = ".$conf->entity;
323  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
324  $sql.= " GROUP BY dm";
325 
326  dol_syslog("get suppliers invoices", LOG_DEBUG);
327  $result=$db->query($sql);
328  if ($result)
329  {
330  $num = $db->num_rows($result);
331  $i = 0;
332  while ($i < $num)
333  {
334  $row = $db->fetch_object($result);
335 
336  if (! isset($decaiss[$row->dm])) $decaiss[$row->dm]=0;
337  $decaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
338 
339  if (! isset($decaiss_ttc[$row->dm])) $decaiss_ttc[$row->dm]=0;
340  $decaiss_ttc[$row->dm] = $row->amount_ttc;
341 
342  $i++;
343  }
344  $db->free($result);
345  }
346  else {
347  dol_print_error($db);
348  }
349 }
350 else if ($modecompta=="BOOKKEEPING")
351 {
352  // Nothing from this table
353 }
354 
355 
356 
357 /*
358  * TVA
359  */
360 
361 $subtotal_ht = 0;
362 $subtotal_ttc = 0;
363 if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
364 {
365  if ($modecompta == 'CREANCES-DETTES')
366  {
367  // TVA a payer
368  $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm";
369  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
370  $sql.= " WHERE f.fk_statut IN (1,2)";
371  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
372  else $sql.= " AND f.type IN (0,1,2,3,5)";
373  $sql.= " AND f.entity = ".$conf->entity;
374  if (! empty($date_start) && ! empty($date_end))
375  $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
376  $sql.= " GROUP BY dm";
377 
378  dol_syslog("get vat to pay", LOG_DEBUG);
379  $result=$db->query($sql);
380  if ($result) {
381  $num = $db->num_rows($result);
382  $i = 0;
383  if ($num) {
384  while ($i < $num) {
385  $obj = $db->fetch_object($result);
386 
387  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
388  $decaiss[$obj->dm] += $obj->amount;
389 
390  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
391  $decaiss_ttc[$obj->dm] += $obj->amount;
392 
393  $i++;
394  }
395  }
396  } else {
397  dol_print_error($db);
398  }
399  // TVA a recuperer
400  $sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm";
401  $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
402  $sql.= " WHERE f.fk_statut IN (1,2)";
403  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
404  else $sql.= " AND f.type IN (0,1,2,3)";
405  $sql.= " AND f.entity = ".$conf->entity;
406  if (! empty($date_start) && ! empty($date_end))
407  $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
408  $sql.= " GROUP BY dm";
409 
410  dol_syslog("get vat to receive back", LOG_DEBUG);
411  $result=$db->query($sql);
412  if ($result) {
413  $num = $db->num_rows($result);
414  $i = 0;
415  if ($num) {
416  while ($i < $num) {
417  $obj = $db->fetch_object($result);
418 
419  if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
420  $encaiss[$obj->dm] += $obj->amount;
421 
422  if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
423  $encaiss_ttc[$obj->dm] += $obj->amount;
424 
425  $i++;
426  }
427  }
428  } else {
429  dol_print_error($db);
430  }
431  }
432  else if ($modecompta=="RECETTES-DEPENSES")
433  {
434  // TVA reellement deja payee
435  $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
436  $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
437  $sql.= " WHERE amount > 0";
438  $sql.= " AND t.entity = ".$conf->entity;
439  if (! empty($date_start) && ! empty($date_end))
440  $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
441  $sql.= " GROUP BY dm";
442 
443  dol_syslog("get vat really paid", LOG_DEBUG);
444  $result=$db->query($sql);
445  if ($result) {
446  $num = $db->num_rows($result);
447  $i = 0;
448  if ($num) {
449  while ($i < $num) {
450  $obj = $db->fetch_object($result);
451 
452  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
453  $decaiss[$obj->dm] += $obj->amount;
454 
455  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
456  $decaiss_ttc[$obj->dm] += $obj->amount;
457 
458  $i++;
459  }
460  }
461  } else {
462  dol_print_error($db);
463  }
464  // TVA recuperee
465  $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
466  $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
467  $sql.= " WHERE amount < 0";
468  $sql.= " AND t.entity = ".$conf->entity;
469  if (! empty($date_start) && ! empty($date_end))
470  $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
471  $sql.= " GROUP BY dm";
472 
473  dol_syslog("get vat really received back", LOG_DEBUG);
474  $result=$db->query($sql);
475  if ($result) {
476  $num = $db->num_rows($result);
477  $i = 0;
478  if ($num) {
479  while ($i < $num) {
480  $obj = $db->fetch_object($result);
481 
482  if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
483  $encaiss[$obj->dm] += $obj->amount;
484 
485  if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
486  $encaiss_ttc[$obj->dm] += $obj->amount;
487 
488  $i++;
489  }
490  }
491  } else {
492  dol_print_error($db);
493  }
494  }
495 }
496 else if ($modecompta=="BOOKKEEPING")
497 {
498  // Nothing from this table
499 }
500 
501 /*
502  * Charges sociales non deductibles
503  */
504 
505 $subtotal_ht = 0;
506 $subtotal_ttc = 0;
507 if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
508 {
509  if ($modecompta == 'CREANCES-DETTES')
510  {
511  $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
512  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
513  $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
514  $sql.= " WHERE cs.fk_type = c.id";
515  $sql.= " AND c.deductible = 0";
516  if (! empty($date_start) && ! empty($date_end))
517  $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
518  }
519  else if ($modecompta=="RECETTES-DEPENSES")
520  {
521  $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
522  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
523  $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
524  $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
525  $sql.= " WHERE p.fk_charge = cs.rowid";
526  $sql.= " AND cs.fk_type = c.id";
527  $sql.= " AND c.deductible = 0";
528  if (! empty($date_start) && ! empty($date_end))
529  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
530  }
531 
532  $sql.= " AND cs.entity = ".$conf->entity;
533  $sql.= " GROUP BY c.libelle, dm";
534 
535  dol_syslog("get social contributions deductible=0 ", LOG_DEBUG);
536  $result=$db->query($sql);
537  if ($result) {
538  $num = $db->num_rows($result);
539  $i = 0;
540  if ($num) {
541  while ($i < $num) {
542  $obj = $db->fetch_object($result);
543 
544  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
545  $decaiss[$obj->dm] += $obj->amount;
546 
547  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
548  $decaiss_ttc[$obj->dm] += $obj->amount;
549 
550  $i++;
551  }
552  }
553  } else {
554  dol_print_error($db);
555  }
556 }
557 else if ($modecompta=="BOOKKEEPING")
558 {
559  // Nothing from this table
560 }
561 
562 
563 /*
564  * Charges sociales deductibles
565  */
566 
567 $subtotal_ht = 0;
568 $subtotal_ttc = 0;
569 if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
570 {
571  if ($modecompta == 'CREANCES-DETTES')
572  {
573  $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
574  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
575  $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
576  $sql.= " WHERE cs.fk_type = c.id";
577  $sql.= " AND c.deductible = 1";
578  if (! empty($date_start) && ! empty($date_end))
579  $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
580  }
581  else if ($modecompta=="RECETTES-DEPENSES")
582  {
583  $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
584  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
585  $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
586  $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
587  $sql.= " WHERE p.fk_charge = cs.rowid";
588  $sql.= " AND cs.fk_type = c.id";
589  $sql.= " AND c.deductible = 1";
590  if (! empty($date_start) && ! empty($date_end))
591  $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
592  }
593 
594  $sql.= " AND cs.entity = ".$conf->entity;
595  $sql.= " GROUP BY c.libelle, dm";
596 
597  dol_syslog("get social contributions paid deductible=1", LOG_DEBUG);
598  $result=$db->query($sql);
599  if ($result) {
600  $num = $db->num_rows($result);
601  $i = 0;
602  if ($num) {
603  while ($i < $num) {
604  $obj = $db->fetch_object($result);
605 
606  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
607  $decaiss[$obj->dm] += $obj->amount;
608 
609  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
610  $decaiss_ttc[$obj->dm] += $obj->amount;
611 
612  $i++;
613  }
614  }
615  } else {
616  dol_print_error($db);
617  }
618 }
619 else if ($modecompta=="BOOKKEEPING")
620 {
621  // Nothing from this table
622 }
623 
624 
625 /*
626  * Salaries
627  */
628 
629 if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
630 {
631  if ($modecompta == 'CREANCES-DETTES') $column = 'p.datev';
632  if ($modecompta == "RECETTES-DEPENSES") $column = 'p.datep';
633 
634  $subtotal_ht = 0;
635  $subtotal_ttc = 0;
636  $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount";
637  $sql .= " FROM " . MAIN_DB_PREFIX . "payment_salary as p";
638  $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")";
639  if (! empty($date_start) && ! empty($date_end))
640  $sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
641  $sql .= " GROUP BY p.label, dm";
642 
643  dol_syslog("get social salaries payments");
644  $result = $db->query($sql);
645  if ($result) {
646  $num = $db->num_rows($result);
647  $i = 0;
648  if ($num) {
649  while ($i < $num) {
650  $obj = $db->fetch_object($result);
651 
652  if (! isset($decaiss[$obj->dm]))
653  $decaiss[$obj->dm] = 0;
654  $decaiss[$obj->dm] += $obj->amount;
655 
656  if (! isset($decaiss_ttc[$obj->dm]))
657  $decaiss_ttc[$obj->dm] = 0;
658  $decaiss_ttc[$obj->dm] += $obj->amount;
659 
660  $i ++;
661  }
662  }
663  } else {
664  dol_print_error($db);
665  }
666 }
667 elseif ($modecompta == "BOOKKEEPING")
668 {
669  // Nothing from this table
670 }
671 
672 
673 /*
674  * Expense reports
675  */
676 
677 if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
678 {
679  $langs->load('trips');
680 
681  if ($modecompta == 'CREANCES-DETTES') {
682  $sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
683  $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
684  $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
685  $sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
686  $sql.= " AND p.fk_statut>=5";
687 
688  $column='p.date_valid';
689  if (! empty($date_start) && ! empty($date_end))
690  $sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
691  } elseif ($modecompta == 'RECETTES-DEPENSES') {
692  $sql = "SELECT date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
693  $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
694  $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
695  $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
696  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
697  $sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
698  $sql.= " AND p.fk_statut>=5";
699 
700  $column='pe.datep';
701  if (! empty($date_start) && ! empty($date_end))
702  $sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
703  }
704 
705  $sql.= " GROUP BY dm";
706 
707  dol_syslog("get expense report outcome");
708  $result=$db->query($sql);
709  $subtotal_ht = 0;
710  $subtotal_ttc = 0;
711  if ($result)
712  {
713  $num = $db->num_rows($result);
714  if ($num)
715  {
716  while ($obj = $db->fetch_object($result))
717  {
718  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
719  $decaiss[$obj->dm] += $obj->amount_ht;
720 
721  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
722  $decaiss_ttc[$obj->dm] += $obj->amount_ttc;
723  }
724  }
725  }
726  else
727  {
728  dol_print_error($db);
729  }
730 }
731 elseif ($modecompta == 'BOOKKEEPING') {
732  // Nothing from this table
733 }
734 
735 
736 /*
737  * Donation get dunning paiement
738  */
739 
740 if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
741 {
742  $subtotal_ht = 0;
743  $subtotal_ttc = 0;
744 
745  if ($modecompta == 'CREANCES-DETTES') {
746  $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
747  $sql.= " FROM ".MAIN_DB_PREFIX."don as p";
748  $sql.= " WHERE p.entity IN (".getEntity('donation').")";
749  $sql.= " AND fk_statut in (1,2)";
750  if (! empty($date_start) && ! empty($date_end))
751  $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
752  }
753  elseif ($modecompta == 'RECETTES-DEPENSES') {
754  $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount";
755  $sql.= " FROM ".MAIN_DB_PREFIX."don as p";
756  $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
757  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
758  $sql.= " WHERE p.entity IN (".getEntity('donation').")";
759  $sql.= " AND fk_statut >= 2";
760  if (! empty($date_start) && ! empty($date_end))
761  $sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'";
762  }
763 
764  $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
765 
766  dol_syslog("get donation payments");
767  $result=$db->query($sql);
768  if ($result)
769  {
770  $num = $db->num_rows($result);
771  $i = 0;
772  if ($num)
773  {
774  while ($i < $num)
775  {
776  $obj = $db->fetch_object($result);
777 
778  if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
779  $encaiss[$obj->dm] += $obj->amount;
780 
781  if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
782  $encaiss_ttc[$obj->dm] += $obj->amount;
783 
784  $i++;
785  }
786  }
787  }
788  else
789  {
790  dol_print_error($db);
791  }
792 }
793 elseif ($modecompta == 'BOOKKEEPING') {
794  // Nothing from this table
795 }
796 
797 
798 
799 /*
800  * Request in mode BOOKKEEPING
801  */
802 
803 if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
804 {
805  $predefinedgroupwhere = "(";
806  //$predefinedgroupwhere.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))";
807  $predefinedgroupwhere.= " (pcg_type = 'EXPENSE')";
808  $predefinedgroupwhere.= " OR ";
809  //$predefinedgroupwhere.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))";
810  $predefinedgroupwhere.= " (pcg_type = 'INCOME')";
811  $predefinedgroupwhere.= ")";
812 
813  $charofaccountstring = $conf->global->CHARTOFACCOUNTS;
814  $charofaccountstring=dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
815 
816  $sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount";
817  $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa";
818  $sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity;
819  $sql.= " AND ".$predefinedgroupwhere;
820  $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
821  if (! empty($date_start) && ! empty($date_end))
822  $sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'";
823  $sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm";
824  //print $sql;
825 
826  $subtotal_ht = 0;
827  $subtotal_ttc = 0;
828 
829  dol_syslog("get bookkeeping record");
830  $result=$db->query($sql);
831  if ($result)
832  {
833  $num = $db->num_rows($result);
834  $i = 0;
835  if ($num)
836  {
837  while ($i < $num)
838  {
839  $obj = $db->fetch_object($result);
840 
841  if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
842  if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
843  $encaiss[$obj->dm] += $obj->credit;
844  $decaiss[$obj->dm] += $obj->debit;
845  if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
846  if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
847  $encaiss_ttc[$obj->dm] += 0;
848  $decaiss_ttc[$obj->dm] += 0;
849 
850  $i++;
851  }
852  }
853  }
854  else
855  {
856  dol_print_error($db);
857  }
858 }
859 
860 
861 
862 $action = "balance";
863 $object = array(&$encaiss, &$encaiss_ttc, &$decaiss, &$decaiss_ttc);
864 $parameters["mode"] = $modecompta;
865 // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
866 $hookmanager->initHooks(array('externalbalance'));
867 $reshook=$hookmanager->executeHooks('addReportInfo',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
868 
869 
870 
871 /*
872  * Show result array
873  */
874 
875 $totentrees=array();
876 $totsorties=array();
877 
878 print '<div class="div-table-responsive">';
879 print '<table class="tagtable liste">'."\n";
880 
881 print '<tr class="liste_titre"><td class="liste_titre">&nbsp;</td>';
882 
883 for ($annee = $year_start ; $annee <= $year_end ; $annee++)
884 {
885  print '<td align="center" colspan="2" class="liste_titre borderrightlight">';
886  print '<a href="clientfourn.php?year='.$annee.'">';
887  print $annee;
888  if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
889  print '</a></td>';
890 }
891 print '</tr>';
892 print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
893 // Loop on each year to ouput
894 for ($annee = $year_start ; $annee <= $year_end ; $annee++)
895 {
896  print '<td class="liste_titre" align="center">';
897  $htmlhelp='';
898  // if ($modecompta == 'RECETTES-DEPENSES') $htmlhelp=$langs->trans("PurchasesPlusVATEarnedAndDue");
899  print $form->textwithpicto($langs->trans("Outcome"), $htmlhelp);
900  print '</td>';
901  print '<td class="liste_titre" align="center" class="borderrightlight">';
902  $htmlhelp='';
903  // if ($modecompta == 'RECETTES-DEPENSES') $htmlhelp=$langs->trans("SalesPlusVATToRetreive");
904  print $form->textwithpicto($langs->trans("Income"), $htmlhelp);
905  print '</td>';
906 }
907 print '</tr>';
908 
909 
910 // Loop on each month
911 $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0;
912 for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
913 {
914  $mois_modulo = $mois;
915  if($mois>12) {$mois_modulo = $mois-12;}
916 
917  print '<tr class="oddeven">';
918  print "<td>".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,$annee),"%B")."</td>";
919  for ($annee = $year_start ; $annee <= $year_end ; $annee++)
920  {
921  $annee_decalage=$annee;
922  if($mois>12) {$annee_decalage=$annee+1;}
923  $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage));
924 
925  print '<td align="right">&nbsp;';
926  if ($modecompta == 'BOOKKEEPING')
927  {
928  if (isset($decaiss[$case]) && $decaiss[$case] != 0)
929  {
930  print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($decaiss[$case],'MT')).'</a>';
931  if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
932  $totsorties[$annee]+=$decaiss[$case];
933  }
934  }
935  else
936  {
937  if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
938  {
939  print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
940  if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
941  $totsorties[$annee]+=$decaiss_ttc[$case];
942  }
943  }
944  print "</td>";
945 
946  print '<td align="right" class="borderrightlight">&nbsp;';
947  if ($modecompta == 'BOOKKEEPING')
948  {
949  if (isset($encaiss[$case]))
950  {
951  print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($encaiss[$case],'MT')).'</a>';
952  if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
953  $totentrees[$annee]+=$encaiss[$case];
954  }
955  }
956  else
957  {
958  if (isset($encaiss_ttc[$case]))
959  {
960  print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($encaiss_ttc[$case],'MT')).'</a>';
961  if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
962  $totentrees[$annee]+=$encaiss_ttc[$case];
963  }
964  }
965  print "</td>";
966  }
967 
968  print '</tr>';
969 }
970 
971 // Total
972 
973 $nbcols=0;
974 print '<tr class="liste_total impair"><td>';
975 if ($modecompta == 'BOOKKEEPING') print $langs->trans("Total");
976 else print $langs->trans("TotalTTC");
977 print '</td>';
978 for ($annee = $year_start ; $annee <= $year_end ; $annee++)
979 {
980  $nbcols+=2;
981  print '<td align="right">'.(isset($totsorties[$annee])?price(price2num($totsorties[$annee],'MT')):'&nbsp;').'</td>';
982  print '<td align="right" style="border-right: 1px solid #DDD">'.(isset($totentrees[$annee])?price(price2num($totentrees[$annee],'MT')):'&nbsp;').'</td>';
983 }
984 print "</tr>\n";
985 
986 // Empty line
987 print '<tr class="impair"><td>&nbsp;</td>';
988 print '<td colspan="'.$nbcols.'">&nbsp;</td>';
989 print "</tr>\n";
990 
991 // Balance
992 
993 print '<tr class="liste_total"><td>'.$langs->trans("AccountingResult").'</td>';
994 for ($annee = $year_start ; $annee <= $year_end ; $annee++)
995 {
996  print '<td align="right" colspan="2" class="borderrightlight"> ';
997  if (isset($totentrees[$annee]) || isset($totsorties[$annee]))
998  {
999  $in=(isset($totentrees[$annee])?price2num($totentrees[$annee], 'MT'):0);
1000  $out=(isset($totsorties[$annee])?price2num($totsorties[$annee],'MT'):0);
1001  print price(price2num($in-$out, 'MT')).'</td>';
1002  // print '<td>&nbsp;</td>';
1003  }
1004 }
1005 print "</tr>\n";
1006 
1007 print "</table>";
1008 print '</div>';
1009 
1010 // End of page
1011 llxFooter();
1012 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
img_next($titlealt='default', $moreatt='')
Show next logo.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
llxHeader()
Header empty.
Definition: index.php:36
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
dol_now($mode='gmt')
Return date for now.
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_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
Definition: report.lib.php:41
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...