From aa3a2f0a075e50bfb81fe849e840c150c36f8494 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Jan 2011 15:15:19 +0000 Subject: [PATCH] Fix: Reports does not use FISCAL_MONTH_START --- htdocs/compta/journal/purchasesjournal.php | 9 +++++++-- htdocs/compta/journal/sellsjournal.php | 9 +++++++-- htdocs/compta/resultat/clientfourn.php | 22 +++++++++++++++++----- htdocs/compta/resultat/index.php | 18 ++++++++++++------ htdocs/compta/stats/cabyuser.php | 18 +++++++++++++++--- htdocs/compta/stats/casoc.php | 18 +++++++++++++++--- 6 files changed, 73 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 1bd3b44af90..c2985ac8e7f 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 b14dacb1aa2..a55d824cb74 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 e55da222ae9..6c2b95b06a4 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 7c3d073438e..92af92ae595 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 ''; $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 ''; - print "".dol_print_date(dol_mktime(12,0,0,$mois,1,$annee),"%B").""; + print "".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,$annee),"%B").""; 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 ' '; if ($decaiss_ttc[$case] != 0) { - print ''.price($decaiss_ttc[$case]).''; + print ''.price($decaiss_ttc[$case]).''; $totsorties[$annee]+=$decaiss_ttc[$case]; } print ""; @@ -461,7 +467,7 @@ for ($mois = 1 ; $mois <= 12 ; $mois++) print ' '; if ($encaiss_ttc[$case] != 0) { - print ''.price($encaiss_ttc[$case]).''; + print ''.price($encaiss_ttc[$case]).''; $totentrees[$annee]+=$encaiss_ttc[$case]; } print ""; @@ -482,7 +488,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) } print "\n"; -// Ligne vierge +// Empty line print ' '; print ' '; print "\n"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 86572badb6c..0dd422f15cc 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 75f69949d00..20986bdd0ea 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); }