dolibarr  7.0.0-beta
result.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016-2017 Jamal Elbaz <jamelbaz@gmail.com>
3  * Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
4  * Copyright (C) 2018 Laurent Destailleur <eldy@destailleur.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
32 
33 $langs->loadLangs(array('compta','bills','donation','salaries','accountancy'));
34 
35 $error = 0;
36 
37 $mesg = '';
38 $action = GETPOST('action','aZ09');
39 $cat_id = GETPOST('account_category');
40 $selectcpt = GETPOST('cpt_bk');
41 $id = GETPOST('id', 'int');
42 $rowid = GETPOST('rowid', 'int');
43 $cancel = GETPOST('cancel','alpha');
44 $showaccountdetail = GETPOST('showaccountdetail','aZ09')?GETPOST('showaccountdetail','aZ09'):'no';
45 
46 
47 $date_startmonth=GETPOST('date_startmonth','int');
48 $date_startday=GETPOST('date_startday','int');
49 $date_startyear=GETPOST('date_startyear','int');
50 $date_endmonth=GETPOST('date_endmonth','int');
51 $date_endday=GETPOST('date_endday','int');
52 $date_endyear=GETPOST('date_endyear','int');
53 
54 $nbofyear=1;
55 
56 // Date range
57 $year=GETPOST('year','int');
58 if (empty($year))
59 {
60  $year_current = strftime("%Y", dol_now());
61  $month_current = strftime("%m", dol_now());
62  $year_start = $year_current - ($nbofyear - 1);
63 } else {
64  $year_current = $year;
65  $month_current = strftime("%m", dol_now());
66  $year_start = $year - ($nbofyear - 1);
67 }
68 $date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
69 $date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
70 
71 // We define date_start and date_end
72 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
73 {
74  $q=GETPOST("q")?GETPOST("q"):0;
75  if ($q==0)
76  {
77  // We define date_start and date_end
78  $year_end=$year_start + ($nbofyear - 1);
79  $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
80  $date_startmonth = $month_start;
81  if (! GETPOST('month'))
82  {
83  if (! GETPOST("year") && $month_start > $month_current)
84  {
85  $year_start--;
86  $year_end--;
87  }
88  $month_end=$month_start-1;
89  if ($month_end < 1) $month_end=12;
90  else $year_end++;
91  }
92  else $month_end=$month_start;
93  $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
94  }
95  if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
96  if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
97  if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
98  if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
99 }
100 
101 if (($date_start < dol_time_plus_duree($date_end, -1, 'y')) || ($date_start > $date_end))
102 {
103  $date_end = dol_time_plus_duree($date_start - 1, 1, 'y');
104 }
105 
106 // $date_start and $date_end are defined. We force $start_year and $nbofyear
107 $tmps=dol_getdate($date_start);
108 $start_year = $tmps['year'];
109 $tmpe=dol_getdate($date_end);
110 $year_end = $tmpe['year'];
111 $nbofyear = ($year_end - $start_year) + 1;
112 
113 $date_start_previous = dol_time_plus_duree($date_start, -1, 'y');
114 $date_end_previous = dol_time_plus_duree($date_end, -1, 'y');
115 
116 //var_dump($date_start." ".$date_end." ".$date_start_previous." ".$date_end_previous." ".$nbofyear);
117 
118 
119 if($cat_id == 0){
120  $cat_id = null;
121 }
122 
123 // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
124 $modecompta = $conf->global->ACCOUNTING_MODE;
125 if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
126 if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta",'alpha');
127 
128 // Security check
129 if ($user->societe_id > 0)
130  accessforbidden();
131 if (! $user->rights->accounting->comptarapport->lire)
132  accessforbidden();
133 
134 $AccCat = new AccountancyCategory($db);
135 
136 
137 /*
138  * View
139  */
140 
141 $months = array(
142  $langs->trans("JanuaryMin"),
143  $langs->trans("FebruaryMin"),
144  $langs->trans("MarchMin"),
145  $langs->trans("AprilMin"),
146  $langs->trans("MayMin"),
147  $langs->trans("JuneMin"),
148  $langs->trans("JulyMin"),
149  $langs->trans("AugustMin"),
150  $langs->trans("SeptemberMin"),
151  $langs->trans("OctoberMin"),
152  $langs->trans("NovemberMin"),
153  $langs->trans("DecemberMin"),
154 );
155 
156 llxheader('', $langs->trans('ReportInOut'));
157 
158 $formaccounting = new FormAccounting($db);
159 $form = new Form($db);
160 
161 $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($start_year - 1) . '">' . img_previous() . '</a>';
162 $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($start_year + 1) . '">' . img_next() . '</a>';
163 
164 
165 
166 // Affiche en-tete de rapport
167 if ($modecompta=="CREANCES-DETTES")
168 {
169  $name=$langs->trans("AnnualByAccountDueDebtMode");
170  $calcmode=$langs->trans("CalcModeDebt");
171  $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')';
172  $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.'&modecompta=BOOKKEEPING">','</a>').')';
173  $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
174  //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
175  $description=$langs->trans("RulesResultDue");
176  if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
177  else $description.= $langs->trans("DepositsAreIncluded");
178  $builddate=dol_now();
179  //$exportlink=$langs->trans("NotYetAvailable");
180 }
181 else if ($modecompta=="RECETTES-DEPENSES") {
182  $name=$langs->trans("AnnualByAccountInputOutputMode");
183  $calcmode=$langs->trans("CalcModeEngagement");
184  $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')';
185  $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=BOOKKEEPING">','</a>').')';
186  //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
187  $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
188  //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
189  $description=$langs->trans("RulesResultInOut");
190  $builddate=dol_now();
191  //$exportlink=$langs->trans("NotYetAvailable");
192 }
193 else if ($modecompta=="BOOKKEEPING")
194 {
195  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
196  $calcmode=$langs->trans("CalcModeBookkeeping");
197  //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
198  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
199  $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
200  $arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
201  $period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
202  $periodlink = $textprevyear . $textnextyear ;
203  $exportlink = '';
204  $description=$langs->trans("RulesResultBookkeepingPersonalized").
205  $description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/categories_list.php?search_country_id='.$mysoc->country_id.'&mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("AccountingCategory")).')';
206  //if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
207  //else $description.= $langs->trans("DepositsAreIncluded");
208  $builddate=dol_now();
209 }
210 
211 report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'action' => ''), $calcmode);
212 
213 
214 if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
215 {
216  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
217 }
218 
219 
220 $moreforfilter='';
221 
222 print '<div class="div-table-responsive">';
223 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
224 
225 print '<tr class="liste_titre">';
226 print '<th class="liste_titre">'.$langs->trans("AccountingCategory").'</th>';
227 print '<th class="liste_titre"></th>';
228 print '<th class="liste_titre" align="right">'.$langs->trans("PreviousPeriod").'</th>';
229 print '<th class="liste_titre" align="right">'.$langs->trans("SelectedPeriod").'</th>';
230 foreach($months as $k => $v){
231  if (($k+1) >= $date_startmonth)
232  {
233  print '<th class="liste_titre width50" align="right" >'.$langs->trans($v).'</th>';
234  }
235 }
236 foreach($months as $k => $v){
237  if (($k+1) < $date_startmonth)
238  {
239  print '<th class="liste_titre width50" align="right" >'.$langs->trans($v).'</th>';
240  }
241 }
242 print '</tr>';
243 
244 if ($modecompta == 'CREANCES-DETTES')
245 {
246  //if (! empty($date_start) && ! empty($date_end))
247  // $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
248 }
249 else if ($modecompta=="RECETTES-DEPENSES")
250 {
251  //if (! empty($date_start) && ! empty($date_end))
252  // $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
253 }
254 else if ($modecompta=="BOOKKEEPING")
255 {
256 
257  //All categories
258  $cats = $AccCat->getCats();
259  if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
260 
261  $j=1;
262  $sommes = array();
263  $totPerAccount = array();
264 
265  foreach ($cats as $cat) // Loop on each group
266  {
267  if (!empty($cat['category_type'])) // category calculed
268  {
269  // When we enter here, $sommes was filled by group of accounts
270 
271  $formula = $cat['formula'];
272 
273  print '<tr class="liste_total">';
274 
275  // Year NP
276  print '<td class="liste_total width200">';
277  print $cat['code'];
278  print '</td><td>';
279  print $cat['label'];
280  print '</td>';
281 
282  $vars = array();
283 
284  // Previous Fiscal year (N-1)
285  foreach($sommes as $code => $det){
286  $vars[$code] = $det['NP'];
287  }
288 
289 
290  $result = strtr($formula, $vars);
291 
292  //var_dump($result);
293  //$r = $AccCat->calculate($result);
294  $r = dol_eval($result, 1);
295  //var_dump($r);
296 
297  print '<td class="liste_total right">' . price($r) . '</td>';
298 
299  // Year N
300  $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...)
301  $sommes[$code]['NP'] += $r;
302 
303  // Current fiscal year (N)
304  if (is_array($sommes) && ! empty($sommes)){
305  foreach($sommes as $code => $det){
306  $vars[$code] = $det['N'];
307  }
308  }
309 
310  $result = strtr($formula, $vars);
311 
312  //$r = $AccCat->calculate($result);
313  $r = dol_eval($result, 1);
314 
315  print '<td class="liste_total right">' . price($r) . '</td>';
316  $sommes[$code]['N'] += $r;
317 
318  // Detail by month
319  foreach($months as $k => $v)
320  {
321  if (($k+1) >= $date_startmonth)
322  {
323  foreach($sommes as $code => $det){
324  $vars[$code] = $det['M'][$k];
325  }
326  $result = strtr($formula, $vars);
327 
328  //$r = $AccCat->calculate($result);
329  $r = dol_eval($result, 1);
330 
331  print '<td class="liste_total right">' . price($r) . '</td>';
332  $sommes[$code]['M'][$k] += $r;
333  }
334  }
335  foreach($months as $k => $v)
336  {
337  if (($k+1) < $date_startmonth)
338  {
339  foreach($sommes as $code => $det){
340  $vars[$code] = $det['M'][$k];
341  }
342  $result = strtr($formula, $vars);
343 
344  //$r = $AccCat->calculate($result);
345  $r = dol_eval($result, 1);
346 
347  print '<td class="liste_total right">' . price($r) . '</td>';
348  $sommes[$code]['M'][$k] += $r;
349  }
350  }
351 
352 
353  print "</tr>\n";
354 
355  //var_dump($sommes);
356  }
357  else // normal category
358  {
359  $totCat = array();
360  $totCat['NP'] = 0;
361  $totCat['N'] = 0;
362  $totCat['M'] = array();
363  foreach($months as $k => $v)
364  {
365  $totCat['M'][$k] = 0;
366  }
367 
368  // Get cpts of category/group
369  $cpts = $AccCat->getCptsCat($cat['rowid']);
370 
371  print "<tr>";
372 
373  // Column group
374  print '<td class="width200">';
375  print $cat['code'];
376  print '</td><td>';
377  print $cat['label'];
378  if (count($cpts) > 0) // Show example of 5 first accounting accounts
379  {
380  $i=0;
381  foreach($cpts as $cpt)
382  {
383  if ($i > 5)
384  {
385  print '...)';
386  break;
387  }
388  if ($i > 0) print ', ';
389  else print ' (';
390  print $cpt['account_number'];
391  $i++;
392  }
393  if ($i <= 5) print ')';
394  }
395  else
396  {
397  print ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
398  }
399  print '</td>';
400 
401  $code = $cat['code'];
402 
403  // Set value into column NPrevious, N and each month M ($totCat)
404  // This make 14 calls for each detail of account (NP, N and month m)
405  foreach($cpts as $i => $cpt)
406  {
407  // N-1
408  $return = $AccCat->getResult($cpt['account_number'], 0, $date_start_previous, $date_end_previous, $cpt['dc']);
409 
410  if ($return < 0) {
411  setEventMessages(null, $AccCat->errors, 'errors');
412  $resultNP=0;
413  } else {
414  $resultNP=$AccCat->sdc;
415  }
416 
417  //N
418  $return = $AccCat->getResult($cpt['account_number'], 0, $date_start, $date_end, $cpt['dc']);
419  if ($return < 0) {
420  setEventMessages(null, $AccCat->errors, 'errors');
421  $resultN=0;
422  } else {
423  $resultN=$AccCat->sdc;
424  }
425 
426  $totCat['NP'] += $resultNP;
427  $totCat['N'] += $resultN;
428  $sommes[$code]['NP'] += $resultNP;
429  $sommes[$code]['N'] += $resultN;
430  $totPerAccount[$cpt['account_number']]['NP'] = $resultNP;
431  $totPerAccount[$cpt['account_number']]['N'] = $resultN;
432 
433  foreach($months as $k => $v)
434  {
435  $return = $AccCat->getResult($cpt['account_number'], $k+1, $date_start, $date_end, $cpt['dc']);
436  if ($return < 0) {
437  setEventMessages(null, $AccCat->errors, 'errors');
438  $resultM=0;
439  } else {
440  $resultM=$AccCat->sdc;
441  }
442  $totCat['M'][$k] += $resultM;
443  $sommes[$code]['M'][$k] += $resultM;
444  $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
445  }
446  }
447 
448  // Now output columns for row $code ('VTE', 'MAR', ...)
449  print '<td align="right">' . price($totCat['NP']) . '</td>';
450  print '<td align="right">' . price($totCat['N']) . '</td>';
451 
452  // Each month
453  foreach($totCat['M'] as $k => $v){
454  if (($k+1) >= $date_startmonth) print '<td align="right">' . price($v) . '</td>';
455  }
456  foreach($totCat['M'] as $k => $v){
457  if (($k+1) < $date_startmonth) print '<td align="right">' . price($v) . '</td>';
458  }
459 
460  print "</tr>\n";
461 
462  // Loop on detail of all accounts
463  // This make 14 calls for each detail of account (NP, N and month m)
464  if ($showaccountdetail != 'no')
465  {
466  foreach($cpts as $i => $cpt)
467  {
468  $resultNP=$totPerAccount[$cpt['account_number']]['NP'];
469  $resultN=$totPerAccount[$cpt['account_number']]['N'];
470 
471  if ($showaccountdetail == 'all' || $resultN > 0)
472  {
473  print '<tr>';
474  print '<td></td>';
475  print '<td class="tdoverflowmax200">';
476  print ' &nbsp; &nbsp; ' . length_accountg($cpt['account_number']);
477  print ' - ';
478  print $cpt['account_label'];
479  print '</td>';
480  print '<td align="right">' . price($resultNP) . '</td>';
481  print '<td align="right">' . price($resultN) . '</td>';
482 
483  // Make one call for each month
484  foreach($months as $k => $v)
485  {
486  if (($k+1) >= $date_startmonth)
487  {
488  $resultM=$totPerAccount[$cpt['account_number']]['M'][$k];
489  print '<td align="right">' . price($resultM) . '</td>';
490  }
491  }
492  foreach($months as $k => $v)
493  {
494  if (($k+1) < $date_startmonth)
495  {
496  $resultM=$totPerAccount[$cpt['account_number']]['M'][$k];
497  print '<td align="right">' . price($resultM) . '</td>';
498  }
499  }
500 
501  print "</tr>\n";
502  }
503  }
504  }
505  }
506  }
507 }
508 
509 print "</table>";
510 print '</div>';
511 
512 llxFooter();
513 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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...
img_previous($titlealt= 'default', $moreatt='')
Show previous logo.
img_next($titlealt= 'default', $moreatt='')
Show next logo.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage categories of an accounting account.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1')
Show information for admin users or standard users.
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:459
print
Draft customers invoices.
Definition: index.php:91
Class to manage generation of HTML components for accounting management.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
Definition: report.lib.php:41
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116