diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 1bd3b44af90d0bddcadd3e470ac5612b0be3316a..c2985ac8e7f2e0ae4c23cf998bf97245ec97a886 100755
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -54,14 +54,19 @@ $html=new Form($db);
 
 $year_current = strftime("%Y",dol_now());
 $pastmonth = strftime("%m",dol_now()) - 1;
-if ($pastmonth == 0) $pastmonth = 12;
+$pastmonthyear = $year_current; 
+if ($pastmonth == 0) 
+{
+	$pastmonth = 12;
+	$pastmonthyear--;
+}
 
 $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
 $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
 
 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 {
-	$date_start=dol_get_first_day($year_current,$pastmonth,false); $date_end=dol_get_last_day($year_current,$pastmonth,false);
+	$date_start=dol_get_first_day($pastmonthyear,$pastmonth,false); $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
 }
 
 $nom=$langs->trans("PurchasesJournal");
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index b14dacb1aa2130d86729113ce6c6ae99e29b0977..a55d824cb7482b3d3e0dec1249e3c0097825fe3a 100755
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -56,14 +56,19 @@ $html=new Form($db);
 
 $year_current = strftime("%Y",dol_now());
 $pastmonth = strftime("%m",dol_now()) - 1;
-if ($pastmonth == 0) $pastmonth = 12;
+$pastmonthyear = $year_current; 
+if ($pastmonth == 0) 
+{
+	$pastmonth = 12;
+	$pastmonthyear--;
+}
 
 $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
 $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
 
 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 {
-	$date_start=dol_get_first_day($year_current,$pastmonth,false); $date_end=dol_get_last_day($year_current,$pastmonth,false);
+	$date_start=dol_get_first_day($pastmonthyear,$pastmonth,false); $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
 }
 
 $nom=$langs->trans("SellsJournal");
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index e55da222ae97d08d7240de280f4371bae9c05076..6c2b95b06a4fafdc69fded9e479da0c72c7f0874 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -20,7 +20,7 @@
 
 /**
  *  \file        htdocs/compta/resultat/clientfourn.php
- *	\brief       Page reporting resultat
+ *	\brief       Page reporting
  *  \version     $Id$
  */
 
@@ -41,13 +41,15 @@ if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->compta
 accessforbidden();
 
 // Date range
-$year=$_REQUEST["year"];
+$year=GETPOST("year");
 if (empty($year))
 {
 	$year_current = strftime("%Y",dol_now());
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year_current;
 } else {
 	$year_current = $year;
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year;
 }
 $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);	// Date for local PHP server
@@ -55,11 +57,21 @@ $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"
 // Quarter
 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 {
-	$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
+	$q=GETPOST("q")?GETPOST("q"):0;
 	if ($q==0)
 	{
-		if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); }
-		else { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,12,false); }
+		// We define date_start and date_end
+		$year_end=$year_start;
+		$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+		if ($month_start > $month_current)
+		{
+			$year_start--;
+			$year_end--;				
+		}
+		$month_end=$month_start-1;
+		if ($month_end < 1) $month_end=12;
+		else $year_end++;
+		$date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
 	}
 	if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
 	if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index 7c3d073438ee1b3473906481295df404d2eff6d2..92af92ae595ffbae83a0b991390083b775acc9c2 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -440,20 +440,26 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 print '</tr>';
 
 $var=True;
+
 // Loop on each month
-for ($mois = 1 ; $mois <= 12 ; $mois++)
+$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0;
+for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
 {
+	$mois_modulo = $mois;
+	if($mois>12) {$mois_modulo = $mois-12;}
 	$var=!$var;
 	print '<tr '.$bc[$var].'>';
-	print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,$annee),"%B")."</td>";
+	print "<td>".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,$annee),"%B")."</td>";
 	for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 	{
-		$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
+		$annee_decalage=$annee;
+		if($mois>12) {$annee_decalage=$annee+1;}
+		$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage));
 
 		print '<td align="right">&nbsp;';
 		if ($decaiss_ttc[$case] != 0)
 		{
-			print '<a href="clientfourn.php?year='.$annee.'&month='.$mois.'">'.price($decaiss_ttc[$case]).'</a>';
+			print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price($decaiss_ttc[$case]).'</a>';
 			$totsorties[$annee]+=$decaiss_ttc[$case];
 		}
 		print "</td>";
@@ -461,7 +467,7 @@ for ($mois = 1 ; $mois <= 12 ; $mois++)
 		print '<td align="right">&nbsp;';
 		if ($encaiss_ttc[$case] != 0)
 		{
-			print '<a href="clientfourn.php?year='.$annee.'&month='.$mois.'">'.price($encaiss_ttc[$case]).'</a>';
+			print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price($encaiss_ttc[$case]).'</a>';
 			$totentrees[$annee]+=$encaiss_ttc[$case];
 		}
 		print "</td>";
@@ -482,7 +488,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 }
 print "</tr>\n";
 
-// Ligne vierge
+// Empty line
 print '<tr><td>&nbsp;</td>';
 print '<td colspan="'.$nbcols.'">&nbsp;</td>';
 print "</tr>\n";
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index 86572badb6c44b08ab50f15abf77f7ec0db2152e..0dd422f15cc8eb40d54420b81f0ba4f1de8d7ff1 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -49,9 +49,11 @@ $year=$_REQUEST["year"];
 if (empty($year))
 {
 	$year_current = strftime("%Y",dol_now());
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year_current;
 } else {
 	$year_current = $year;
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year;
 }
 $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
@@ -59,11 +61,21 @@ $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"
 // Quarter
 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 {
-	$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
+	$q=GETPOST("q")?GETPOST("q"):0;
 	if ($q==0)
 	{
-		if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); }
-		else { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,12,false); }
+		// We define date_start and date_end
+		$year_end=$year_start;
+		$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+		if ($month_start > $month_current)
+		{
+			$year_start--;
+			$year_end--;				
+		}
+		$month_end=$month_start-1;
+		if ($month_end < 1) $month_end=12;
+		else $year_end++;
+		$date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
 	}
 	if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
 	if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index 75f69949d00192f015e688c8ba40404df48d2313..20986bdd0eaa9f6cadde3f4b1806518d8edc2df4 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -52,9 +52,11 @@ $year=$_REQUEST["year"];
 if (empty($year))
 {
 	$year_current = strftime("%Y",dol_now());
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year_current;
 } else {
 	$year_current = $year;
+	$month_current = strftime("%m",dol_now());
 	$year_start = $year;
 }
 $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
@@ -62,11 +64,21 @@ $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"
 // Quarter
 if (empty($date_start) || empty($date_end)) // We define date_start and date_end
 {
-	$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
+	$q=GETPOST("q")?GETPOST("q"):0;
 	if ($q==0)
 	{
-		if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); }
-		else { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,12,false); }
+		// We define date_start and date_end
+		$year_end=$year_start;
+		$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+		if ($month_start > $month_current)
+		{
+			$year_start--;
+			$year_end--;				
+		}
+		$month_end=$month_start-1;
+		if ($month_end < 1) $month_end=12;
+		else $year_end++;
+		$date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
 	}
 	if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
 	if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }