Hi, I've generated a report with Koolreport and Laravel; in the table, I have the amount of orders grouped by month of the selected year.
This is my code:
<?php
$query = DB::table('fattura')
->select('anagrafica.nome_breve', DB::raw('SUM(qta*prezzo) as somma'), DB::raw('MONTH(data_documento) as mese_documento'))
->leftJoin('riga_fattura', 'riga_fattura.id_fattura', 'fattura.id')
->leftJoin('anagrafica', 'anagrafica.id', 'fattura.id_cliente')
->where([['data_documento', 'LIKE', $anno.'-'.$mese.'-%']])
->groupBy('mese_documento')
->orderBy('mese_documento', 'ASC');
$vendita = array(
"dataSource"=>$query->get()
);
Table::create(array(
"dataSource"=>$vendita['dataSource'],
"showFooter"=>true,
"cssClass"=>array(
"table"=>"table-bordered table-striped table-hover"
),
"columns"=>array(
"mese_documento"=>array(
"label"=>"Mese"
),
"somma"=>array(
"label"=>"Somma",
"type"=>"number",
"footer"=>"sum",
"footerText"=>"<b>Totale:</b> @value",
'formatValue'=>function($value){
return "€ ".number_format($value, 2, ",", ".");
}
)
),
));
?>
Now, I want to add a column with the amount of the orders of the previous year, grouped by month. How I can do this? Thanks! Roberto