diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 8d2b44c40af..97e362145ae 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,12 +126,14 @@ if ($result < 0) { // Loading table $amounts $amounts = array(); - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; $sql .= ", SUM(b.amount)"; @@ -534,12 +537,14 @@ if ($result < 0) { $credits = array(); $debits = array(); - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%d')"; $sql .= ", SUM(b.amount)"; @@ -569,12 +574,14 @@ if ($result < 0) { dol_print_error($db); } - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%d')"; $sql .= ", SUM(b.amount)"; @@ -805,10 +812,10 @@ print ''; // Graphs if ($mode == 'standard') { - $prevyear = $year; - $nextyear = $year; - $prevmonth = $month - 1; - $nextmonth = $month + 1; + $prevyear = (int) $year; + $nextyear = (int) $year; + $prevmonth = (int) $month - 1; + $nextmonth = (int) $month + 1; if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; @@ -817,6 +824,10 @@ if ($mode == 'standard') { $nextmonth = 1; $nextyear++; } + $nextmonth = sprintf('%02d', $nextmonth); + $prevmonth = sprintf('%02d', $prevmonth); + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); // For month $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; @@ -832,8 +843,10 @@ if ($mode == 'standard') { print ''; // For year - $prevyear = $year - 1; - $nextyear = $year + 1; + $prevyear = (int) $year - 1; + $nextyear = (int) $year + 1; + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
';