include ("../common/public.php") ;
$arrVal = array() ;
$query = "
select
month(O.DataOrdine) as Mese,
count(*) as TotOrdini,
F.IdFornitori,
F.Nome
from
ordini O
inner join fornitori F on F.idfornitori = O.idfornitore
where
O.Anno = $anno
group by
Mese,
O.idfornitore
order by
F.Nome,
Mese
" ;
list($n, $d) = $db->RecuperaDati($query) ;
for($i=0; $i<$n; $i++)
{
if (! array_key_exists($d['IdFornitori'][$i], $arrVal))
$arrVal[$d['IdFornitori'][$i]] = array('Nome' => $d['Nome'][$i]) ;
$arrVal[$d['IdFornitori'][$i]][$d['Mese'][$i]] += $d['TotOrdini'][$i] ;
$totaleMese[$d['Mese'][$i]] += $d['TotOrdini'][$i] ;
$totaleFornitore[$d['IdFornitori'][$i]] += $d['TotOrdini'][$i] ;
}
$granTotale = 0 ;
$str = "" ;
foreach($arrVal as $idFornitore => $arrValSF)
// while(list($idFornitore, $arrValSF) = each($arrVal))
{
$str .= "" ;
$str .= "| " . htmlspecialchars($arrValSF['Nome']) . " | " ;
for ($mese=1; $mese<=12; $mese++ )
{
if (array_key_exists($mese, $arrValSF))
$str .= "" . $arrValSF[$mese] . " | " ;
else
$str .= "0 | " ;
}
$str .= "" . $totaleFornitore[$idFornitore] . " | " ;
$granTotale += $totaleFornitore[$idFornitore] ;
$str .= "
" ;
}
$str .= "" ;
$header = "FORNITORE,GEN,FEB,MAR,APR,MAG,GIU,LUG,AGO,SET,OTT,NOV,DIC,TOTALE" ;
$footer = "TOTALE:," . $totaleMese[1] . "," . $totaleMese[2] . "," . $totaleMese[3] . "," . $totaleMese[4] . "," . $totaleMese[5] . "," . $totaleMese[6] . "," . $totaleMese[7] . "," . $totaleMese[8] . "," . $totaleMese[9] . "," . $totaleMese[10] . "," . $totaleMese[11] . "," . $totaleMese[12] . "," . $granTotale ;
$strSort = "str,int,int,int,int,int,int,int,int,int,int,int,int,int" ;
$iniWP = "30,5,5,5,5,5,5,5,5,5,5,5,5,10" ;
$setColType = "ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro" ;
$setColAlign = "left,center,center,center,center,center,center,center,center,center,center,center,center,center" ;
?>
New Document
| |
Ordini per Fornitore |
Ordini per Fornitore per Mese |
Totali |
|
Numero Fornitori: echo count($arrVal) ?>
(clicca sulla casella di un mese per vedere la lista degli ordini)