diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 73a4e7d902a..0d2958da7df 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -45,8 +45,12 @@ $date_endyear = GETPOST('date_endyear', 'int'); $nbofyear = 4; +// Change this to test different cases of setup +//$conf->global->SOCIETE_FISCAL_MONTH_START = 7; + + // Date range -$year = GETPOST('year', 'int'); +$year = GETPOST('year', 'int'); // this is used for navigation previous/next. It is the last year to show in filter if (empty($year)) { $year_current = dol_print_date(dol_now(), "%Y"); $month_current = dol_print_date(dol_now(), "%m"); @@ -54,7 +58,7 @@ if (empty($year)) { } else { $year_current = $year; $month_current = dol_print_date(dol_now(), "%m"); - $year_start = $year - ($nbofyear - 1); + $year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1); } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); @@ -64,18 +68,16 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q") ? GETPOST("q", 'int') : 0; if ($q == 0) { // We define date_start and date_end - $year_end = $year_start + ($nbofyear - 1); - $month_start = GETPOST("month") ? GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1); + $month_start = GETPOST("month") ? GETPOST("month", 'int') : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!GETPOST('month')) { - if (!GETPOST("year") && $month_start > $month_current) { + if (!$year && $month_start > $month_current) { $year_start--; $year_end--; } $month_end = $month_start - 1; if ($month_end < 1) { $month_end = 12; - } else { - $year_end++; } } else { $month_end = $month_start; @@ -200,7 +202,6 @@ if ($modecompta == 'CREANCES-DETTES') { //$exportlink=$langs->trans("NotYetAvailable"); } -$hselected = 'report'; report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta), $calcmode); @@ -996,17 +997,18 @@ $reshook = $hookmanager->executeHooks('addReportInfo', $parameters, $object, $ac $totentrees = array(); $totsorties = array(); +$year_end_for_table = ($year_end - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 1 : 0)); print '
| '; -for ($annee = $year_start; $annee <= $year_end; $annee++) { +for ($annee = $year_start; $annee <= $year_end_for_table; $annee++) { print ' | '; print ''; print $annee; - if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) { + if (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1) { print '-'.($annee + 1); } print ' | '; @@ -1014,7 +1016,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { print '|
| '.$langs->trans("Month").' | '; // Loop on each year to ouput -for ($annee = $year_start; $annee <= $year_end; $annee++) { +for ($annee = $year_start; $annee <= $year_end_for_table; $annee++) { print ''; $htmlhelp = ''; // if ($modecompta == 'RECETTES-DEPENSES') $htmlhelp=$langs->trans("PurchasesPlusVATEarnedAndDue"); @@ -1039,7 +1041,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) { print ' | |
| ".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, $annee), "%B")." | "; - for ($annee = $year_start; $annee <= $year_end; $annee++) { + for ($annee = $year_start; $annee <= $year_end_for_table; $annee++) { $annee_decalage = $annee; if ($mois > 12) { $annee_decalage = $annee + 1; @@ -1100,7 +1102,7 @@ if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'BOOKKEEPING') { print $langs->trans("TotalTTC"); } print ''; -for ($annee = $year_start; $annee <= $year_end; $annee++) { +for ($annee = $year_start; $annee <= $year_end_for_table; $annee++) { $nbcols += 2; print ''.(isset($totsorties[$annee]) ?price(price2num($totsorties[$annee], 'MT')) : ' ').' | '; print ''.(isset($totentrees[$annee]) ?price(price2num($totentrees[$annee], 'MT')) : ' ').' | '; @@ -1115,7 +1117,7 @@ print "
| '.$langs->trans("AccountingResult").' | '; -for ($annee = $year_start; $annee <= $year_end; $annee++) { +for ($annee = $year_start; $annee <= $year_end_for_table; $annee++) { print ''; if (isset($totentrees[$annee]) || isset($totsorties[$annee])) { $in = (isset($totentrees[$annee]) ?price2num($totentrees[$annee], 'MT') : 0); | |