28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
34$langs->loadLangs(array(
'banks',
'categories'));
43$hookmanager->initHooks(array(
'bankannualreport',
'globalcard'));
46$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
47$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
49 $socid = $user->socid;
51$result =
restrictedArea($user,
'banque', $fieldvalue,
'bank_account&bank_account',
'',
'', $fieldtype);
53$year_start =
GETPOST(
'year_start');
57 $year_start = $year_current - 2;
58 $year_end = $year_current;
60 $year_end = $year_start + 2;
73if ($id > 0 && !preg_match(
'/,/', $id)) {
74 $result = $object->fetch($id);
78 $result = $object->fetch(0, $ref);
86$title = $object->ref.
' - '.$langs->trans(
"IOMonthlyReporting");
93$sql =
"SELECT SUM(b.amount)";
94$sql .=
", date_format(b.dateo,'%Y-%m') as dm";
95$sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
96$sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
97$sql .=
" WHERE b.fk_account = ba.rowid";
98$sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
99$sql .=
" AND b.amount >= 0";
101 $sql .=
" AND b.fk_account IN (".$db->sanitize($db->escape($id)).
")";
103$sql .=
" GROUP BY dm";
105$resql = $db->query($sql);
107 $num = $db->num_rows($resql);
110 $row = $db->fetch_row($resql);
111 $encaiss[$row[1]] = $row[0];
118$sql =
"SELECT SUM(b.amount)";
119$sql .=
", date_format(b.dateo,'%Y-%m') as dm";
120$sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
121$sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
122$sql .=
" WHERE b.fk_account = ba.rowid";
123$sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
124$sql .=
" AND b.amount <= 0";
126 $sql .=
" AND b.fk_account IN (".$db->sanitize($db->escape($id)).
")";
128$sql .=
" GROUP BY dm";
130$resql = $db->query($sql);
132 $num = $db->num_rows($resql);
135 $row = $db->fetch_row($resql);
136 $decaiss[$row[1]] = -$row[0];
146print
dol_get_fiche_head($head,
'annual', $langs->trans(
"FinancialAccount"), 0,
'account');
148$title = $langs->trans(
"FinancialAccount").
" : ".$object->label;
149$link = ($year_start ?
'<a href="'.$_SERVER[
"PHP_SELF"].
'?account='.$object->id.
'&year_start='.($year_start - 1).
'">'.
img_previous(
'',
'class="valignbottom"').
"</a> ".$langs->trans(
"Year").
' <a href="'.$_SERVER[
"PHP_SELF"].
'?account='.$object->id.
'&year_start='.($year_start + 1).
'">'.
img_next(
'',
'class="valignbottom"').
'</a>' :
'');
151$linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
156 if (!preg_match(
'/,/', $id)) {
157 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
159 $bankaccount =
new Account($db);
160 $listid = explode(
',', $id);
161 foreach ($listid as $key => $aId) {
162 $bankaccount->fetch($aId);
163 $bankaccount->label = $bankaccount->ref;
164 print $bankaccount->getNomUrl(1);
165 if ($key < (count($listid) - 1)) {
171 print $langs->trans(
"AllAccounts");
180print
'<div class="div-table-responsive">';
181print
'<table class="noborder centpercent">';
183print
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Month").
'</td>';
184for ($annee = $year_start; $annee <= $year_end; $annee++) {
185 print
'<td align="center" width="20%" colspan="2" class="liste_titre borderrightlight">'.$annee.
'</td>';
189print
'<tr class="liste_titre">';
190print
'<td class="liste_titre"> </td>';
191for ($annee = $year_start; $annee <= $year_end; $annee++) {
192 print
'<td class="liste_titre" align="center">'.$langs->trans(
"Debit").
'</td><td class="liste_titre" align="center">'.$langs->trans(
"Credit").
'</td>';
196for ($annee = $year_start; $annee <= $year_end; $annee++) {
197 $totsorties[$annee] = 0;
198 $totentrees[$annee] = 0;
201for ($mois = 1; $mois < 13; $mois++) {
202 print
'<tr class="oddeven">';
203 print
"<td>".dol_print_date(
dol_mktime(1, 1, 1, $mois, 1, 2000),
"%B").
"</td>";
205 for ($annee = $year_start; $annee <= $year_end; $annee++) {
206 $case = sprintf(
"%04s-%02s", $annee, $mois);
208 print
'<td class="right" width="10%"> ';
209 if (isset($decaiss[$case]) && $decaiss[$case] > 0) {
210 print
price($decaiss[$case]);
211 $totsorties[$annee] += $decaiss[$case];
215 print
'<td class="right borderrightlight" width="10%"> ';
216 if (isset($encaiss[$case]) && $encaiss[$case] > 0) {
217 print
price($encaiss[$case]);
218 $totentrees[$annee] += $encaiss[$case];
226print
'<tr class="liste_total"><td><b>'.$langs->trans(
"Total").
"</b></td>";
227for ($annee = $year_start; $annee <= $year_end; $annee++) {
228 print
'<td class="right nowraponall"><b>'. (isset($totsorties[$annee]) ?
price($totsorties[$annee]) :
'') .
'</b></td>';
229 print
'<td class="right nowraponall"><b>'. (isset($totentrees[$annee]) ?
price($totentrees[$annee]) :
'') .
'</b></td>';
242$sql =
"SELECT SUM(b.amount) as total";
243$sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
244$sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
245$sql .=
" WHERE b.fk_account = ba.rowid";
246$sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
248 $sql .=
" AND b.fk_account IN (".$db->sanitize($db->escape($id)).
")";
251$resql = $db->query($sql);
253 $obj = $db->fetch_object($resql);
255 $balance = $obj->total;
261print
'<table class="noborder centpercent">';
264print
'<tr class="liste_total"><td><b>'.$langs->trans(
"CurrentBalance").
"</b></td>";
265print
'<td colspan="'.($nbcol).
'" class="right">'.
price($balance).
'</td>';
274$result =
dol_mkdir($conf->bank->dir_temp);
276 $langs->load(
"errors");
281 $sql =
"SELECT MIN(b.datev) as min, MAX(b.datev) as max";
282 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
283 $sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
284 $sql .=
" WHERE b.fk_account = ba.rowid";
285 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
286 if ($id &&
GETPOST(
"option") !=
'all') {
287 $sql .=
" AND b.fk_account IN (".$db->sanitize($id).
")";
290 $resql = $db->query($sql);
292 $num = $db->num_rows($resql);
293 $obj = $db->fetch_object($resql);
294 $min = $db->jdate($obj->min);
295 $max = $db->jdate($obj->max);
299 $log =
"graph.php: min=".$min.
" max=".$max;
304 $tblyear[0] = array();
305 $tblyear[1] = array();
306 $tblyear[2] = array();
308 for ($annee = 0; $annee < 3; $annee++) {
309 $sql =
"SELECT date_format(b.datev,'%m')";
310 $sql .=
", SUM(b.amount)";
311 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
312 $sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
313 $sql .=
" WHERE b.fk_account = ba.rowid";
314 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
315 $sql .=
" AND b.datev >= '".($year - $annee).
"-01-01 00:00:00'";
316 $sql .=
" AND b.datev <= '".($year - $annee).
"-12-31 23:59:59'";
317 $sql .=
" AND b.amount > 0";
318 if ($id &&
GETPOST(
"option") !=
'all') {
319 $sql .=
" AND b.fk_account IN (".$db->sanitize($id).
")";
321 $sql .=
" GROUP BY date_format(b.datev,'%m');";
323 $resql = $db->query($sql);
325 $num = $db->num_rows($resql);
328 $row = $db->fetch_row($resql);
329 $tblyear[$annee][$row[0]] = $row[1];
339 $data_year_0 = array();
340 $data_year_1 = array();
341 $data_year_2 = array();
343 for ($i = 0; $i < 12; $i++) {
344 $data_year_0[$i] = isset($tblyear[0][substr(
"0".($i + 1), -2)]) ? $tblyear[0][substr(
"0".($i + 1), -2)] : 0;
345 $data_year_1[$i] = isset($tblyear[1][substr(
"0".($i + 1), -2)]) ? $tblyear[1][substr(
"0".($i + 1), -2)] : 0;
346 $data_year_2[$i] = isset($tblyear[2][substr(
"0".($i + 1), -2)]) ? $tblyear[2][substr(
"0".($i + 1), -2)] : 0;
347 $labels[$i] = $langs->transnoentitiesnoconv(
"MonthVeryShort".sprintf(
"%02d", $i + 1));
352 $file = $conf->bank->dir_temp.
"/credmovement".$id.
"-".$year.
".png";
353 $fileurl = DOL_URL_ROOT.
'/viewimage.php?modulepart=banque_temp&file='.
"/credmovement".$id.
"-".$year.
".png";
354 $title = $langs->transnoentities(
"Credit").
' - '.$langs->transnoentities(
"Year").
': '.($year - 2).
' - '.($year - 1).
" - ".$year;
355 $graph_datas = array();
356 for ($i = 0; $i < 12; $i++) {
357 $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
361 $px1->SetData($graph_datas);
362 $px1->SetLegend(array(($year), ($year - 1), ($year - 2)));
363 $px1->SetLegendWidthMin(180);
364 $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
365 $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue());
366 $px1->SetTitle($title);
367 $px1->SetWidth($WIDTH);
368 $px1->SetHeight($HEIGHT);
369 $px1->SetType(array(
'line',
'line',
'line'));
371 $px1->setBgColor(
'onglet');
372 $px1->setBgColorGrid(array(255, 255, 255));
373 $px1->SetHorizTickIncrement(1);
374 $px1->draw($file, $fileurl);
376 $show1 = $px1->show();
386 $tblyear[0] = array();
387 $tblyear[1] = array();
388 $tblyear[2] = array();
390 for ($annee = 0; $annee < 3; $annee++) {
391 $sql =
"SELECT date_format(b.datev,'%m')";
392 $sql .=
", SUM(b.amount)";
393 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
394 $sql .=
", ".MAIN_DB_PREFIX.
"bank_account as ba";
395 $sql .=
" WHERE b.fk_account = ba.rowid";
396 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
397 $sql .=
" AND b.datev >= '".($year - $annee).
"-01-01 00:00:00'";
398 $sql .=
" AND b.datev <= '".($year - $annee).
"-12-31 23:59:59'";
399 $sql .=
" AND b.amount < 0";
400 if ($id &&
GETPOST(
"option") !=
'all') {
401 $sql .=
" AND b.fk_account IN (".$db->sanitize($id).
")";
403 $sql .=
" GROUP BY date_format(b.datev,'%m');";
405 $resql = $db->query($sql);
407 $num = $db->num_rows($resql);
410 $row = $db->fetch_row($resql);
411 $tblyear[$annee][$row[0]] = abs($row[1]);
421 $data_year_0 = array();
422 $data_year_1 = array();
423 $data_year_2 = array();
425 for ($i = 0; $i < 12; $i++) {
426 $data_year_0[$i] = isset($tblyear[0][substr(
"0".($i + 1), -2)]) ? $tblyear[0][substr(
"0".($i + 1), -2)] : 0;
427 $data_year_1[$i] = isset($tblyear[1][substr(
"0".($i + 1), -2)]) ? $tblyear[1][substr(
"0".($i + 1), -2)] : 0;
428 $data_year_2[$i] = isset($tblyear[2][substr(
"0".($i + 1), -2)]) ? $tblyear[2][substr(
"0".($i + 1), -2)] : 0;
429 $labels[$i] = $langs->transnoentitiesnoconv(
"MonthVeryShort".sprintf(
"%02d", $i + 1));
433 $file = $conf->bank->dir_temp.
"/debmovement".$id.
"-".$year.
".png";
434 $fileurl = DOL_URL_ROOT.
'/viewimage.php?modulepart=banque_temp&file='.
"/debmovement".$id.
"-".$year.
".png";
435 $title = $langs->transnoentities(
"Debit").
' - '.$langs->transnoentities(
"Year").
': '.($year - 2).
' - '.($year - 1).
" - ".$year;
436 $graph_datas = array();
437 for ($i = 0; $i < 12; $i++) {
438 $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
442 $px2->SetData($graph_datas);
443 $px2->SetLegend(array(($year), ($year - 1), ($year - 2)));
444 $px2->SetLegendWidthMin(180);
445 $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
446 $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue());
447 $px2->SetTitle($title);
448 $px2->SetWidth($WIDTH);
449 $px2->SetHeight($HEIGHT);
450 $px2->SetType(array(
'line',
'line',
'line'));
452 $px2->setBgColor(
'onglet');
453 $px2->setBgColorGrid(array(255, 255, 255));
454 $px2->SetHorizTickIncrement(1);
455 $px2->draw($file, $fileurl);
457 $show2 = $px2->show();
465 print
'<div class="fichecenter"><div class="fichehalfleft"><div align="center">';
467 print
'</div></div><div class="fichehalfright"><div align="center">';
469 print
'</div></div></div>';
470 print
'<div class="clearboth"></div>';
474print
"\n</div><br>\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Class to manage bank accounts.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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.