FIX Missing token and take into account max date when it can.
This commit is contained in:
parent
6f0071bebe
commit
70706d9ea7
@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries'));
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
$date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$date_startday = GETPOST('date_startday', 'int');
|
||||
$date_startmonth = GETPOST('date_startmonth', 'int');
|
||||
$date_startyear = GETPOST('date_startyear', 'int');
|
||||
$date_endday = GETPOST('date_endday', 'int');
|
||||
$date_endmonth = GETPOST('date_endmonth', 'int');
|
||||
$date_endyear = GETPOST('date_endyear', 'int');
|
||||
|
||||
$nbofyear = 4;
|
||||
|
||||
@ -193,15 +193,18 @@ elseif ($modecompta == "BOOKKEEPING")
|
||||
{
|
||||
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj";
|
||||
$sql .= " WHERE b.entity = ".$conf->entity;
|
||||
$sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
|
||||
$sql .= " AND aj.entity = ".$conf->entity;
|
||||
$sql .= " AND b.code_journal = aj.code AND aj.nature = 2"; // @todo currently count amount in sale journal, but we need to define a category group for turnover
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= " ORDER BY dm";
|
||||
// TODO Add a filter on $date_start and $date_end to reduce quantity on data
|
||||
//print $sql;
|
||||
|
||||
$minyearmonth = $maxyearmonth = 0;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -214,7 +217,7 @@ if ($result)
|
||||
$cum[$obj->dm] = $obj->amount_ttc;
|
||||
if ($obj->amount_ttc)
|
||||
{
|
||||
$minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm);
|
||||
$minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm);
|
||||
$maxyearmonth = max($maxyearmonth, $obj->dm);
|
||||
}
|
||||
$i++;
|
||||
@ -309,9 +312,17 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
|
||||
$mois_modulo = $mois; // ajout
|
||||
if ($mois > 12) {$mois_modulo = $mois - 12; } // ajout
|
||||
|
||||
if ($year_start == $year_end) {
|
||||
if ($mois > $date_endmonth && $year_end >= $date_endyear) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Month
|
||||
print "<td>".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, 2000), "%B")."</td>";
|
||||
|
||||
for ($annee = $year_start - 1; $annee <= $year_end; $annee++) // We start one year before to have data to be able to make delta
|
||||
{
|
||||
$annee_decalage = $annee;
|
||||
|
||||
@ -53,16 +53,17 @@ function report_header($reportname, $notused, $period, $periodlink, $description
|
||||
$head[$h][1] = $langs->trans("Report");
|
||||
$head[$h][2] = 'report';
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
|
||||
|
||||
dol_fiche_head($head, 'report');
|
||||
|
||||
foreach($moreparam as $key => $value)
|
||||
{
|
||||
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
|
||||
print '<input type="hidden" name="'.$key.'" value="'.$value.'">'."\n";
|
||||
}
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
print '<table class="border tableforfield centpercent">'."\n";
|
||||
|
||||
$variante = ($periodlink || $exportlink);
|
||||
|
||||
@ -73,7 +74,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description
|
||||
print $reportname;
|
||||
print '</td>';
|
||||
if ($variante) print '<td></td>';
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Calculation mode
|
||||
if ($calcmode)
|
||||
@ -84,7 +85,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description
|
||||
print $calcmode;
|
||||
if ($variante) print '<td></td>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
|
||||
// Ligne de la periode d'analyse du rapport
|
||||
@ -94,14 +95,14 @@ function report_header($reportname, $notused, $period, $periodlink, $description
|
||||
if ($period) print $period;
|
||||
if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Ligne de description
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ReportDescription").'</td>';
|
||||
print '<td>'.$description.'</td>';
|
||||
if ($variante) print '<td></td>';
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Ligne d'export
|
||||
print '<tr>';
|
||||
@ -110,9 +111,9 @@ function report_header($reportname, $notused, $period, $periodlink, $description
|
||||
print dol_print_date($builddate, 'dayhour');
|
||||
print '</td>';
|
||||
if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
|
||||
print '</tr>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
print '</table>';
|
||||
print '</table>'."\n";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user