"); $dbtot = new FC_SQL ; $log = true ; if ($log) $handle = fopen('log_LoadStatisticheClienti.txt', 'a+') ; $posStart = $_GET['posStart'] ; $count = $_GET['count'] ; $totordini = $_GET['totordini'] ; if ($log) { fwrite($handle, "posStart = " . $posStart . "\n") ; fwrite($handle, "count = " . $count . "\n") ; fwrite($handle, "totordini = " . $totordini . "\n") ; } $ordinaper = $_GET["ordinaper"] ; $direction = $_GET["direction"] ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($ordinaper) { case 0: // cliente $order_by = "C.Nome $direction" ; break ; case 1: // totale ordini case 2: // totale ordini percentuale $order_by = "num_ordini $direction, C.Nome" ; break ; } $qcli = " select count(O.idordini) as num_ordini, C.idclienti as IdClienti, C.nome as NomeCliente from $tclienti C left join $tordini O on O.idcliente = C.idclienti group by C.idclienti, C.nome order by $order_by" ; if ($log) fwrite($handle, "$qcli \n") ; list($nrowsdati, $dati) = $db->RecuperaDati($qcli) ; if ($log) fwrite($handle, "\n") ; print("") ; for ($i = 0; $i < $nrowsdati ; $i++ ) { $id = $dati['IdClienti'][$i] ; $num_ordini = $dati['num_ordini'][$i] ; $cliente = htmlspecialchars($dati['NomeCliente'][$i]) ; $percf = sprintf ("%.2f", $num_ordini * 100 / $totordini) ; if ($log) fwrite($handle, "$cliente$num_ordini$percf\n") ; print ("$cliente$num_ordini$percf") ; } print ("") ; if ($log) fclose($handle) ; ?>