"); $log = false ; if ($log) $handle = fopen('log_LoadTotaliAgentiClientiFornitori.txt', 'a+') ; $posStart = $_GET['posStart'] ; $count = $_GET['count'] ; $from = $_GET['from'] ; $agente = $_GET['agente'] ; $$hidcli = $_GET['hidcli'] ; $hnomecli = $_GET['hnomecli'] ; $hidfor = $_GET['hidfor'] ; $hnomefor = $_GET['hnomefor'] ; $mese = $_GET['mese'] ; $where_age = " O.idagente = $id " ; $where_cli = "1" ; $where_for = "1" ; if ($from == "totali_cli") { list($id, $nome_agente) = explode("^", $agente) ; $strIdCli = substr($hidcli, 0, -1) ; $arrIdCli = explode(",", $strIdCli) ; $strNomeCli = substr($hnomecli, 0, -1) ; $strNomeCli = str_replace(",", " / ", $strNomeCli) ; if (in_array(0, $arrIdCli)) $where_cli = "1" ; else $where_cli = "C.idclienti IN ($strIdCli)" ; if ($id == 0) $where_age = "1" ; else $where_age = " O.idagente = $id " ; } elseif ($from == "totali_for") { list($id, $nome_agente) = explode("^", $agente) ; $strIdFor = substr($hidfor, 0, -1) ; $arrIdFor = explode(",", $strIdFor) ; $strNomeFor = substr($hnomefor, 0, -1) ; $strNomeFor = str_replace(",", " / ", $strNomeFor) ; if (in_array(0, $arrIdFor)) $where_for = "1" ; else $where_for = "F.idfornitori IN ($strIdFor)" ; if ($id == 0) $where_age = "1" ; else $where_age = " O.idagente = $id " ; } elseif ($from == "ordini_per_cliente_per_mese") { $where_cli = "month(O.dataordine) = $mese" ; $where_for = "1" ; } else if ($from == "ordini_per_cliente_per_mese") { $where_cli = "month(O.dataordine) = $mese" ; $where_for = "1" ; } $ordinaper = $_GET["ordinaper"] ; $direction = $_GET["direction"] ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($ordinaper) { case 0: // numero ordine $order_by = "O.IdOrdini $direction" ; break ; case 1: // numero fattura $order_by = "O.NumFattura $direction" ; break ; case 2: // nome agente $order_by = "A.Nome $direction, O.IdOrdini ASC" ; break ; case 3: // nome cliente $order_by = "C.Nome $direction, O.IdOrdini ASC" ; break ; case 4: // nome cliente $order_by = "F.Nome $direction, O.IdOrdini ASC" ; break ; case 5: // imponibile provvigionale $order_by = "AVO.BaseProvvigionale $direction, O.IdOrdini ASC" ; break ; case 6: // data ordine $order_by = "O.DataOrdine $direction, O.IdOrdini ASC" ; break ; case 7: // data fattura $order_by = "O.DataSpedFattura $direction, O.IdOrdini ASC" ; break ; case 8: // percentuale provvigione agente $order_by = "AVO.PercentualeProvvAgente $direction, O.IdOrdini ASC" ; break ; case 9: // ammontare provvigione agente $order_by = "AVO.AmmontareProvvAgente $direction, O.IdOrdini ASC" ; break ; default: // mesi $order_by = "O.IdOrdini ASC" ; break ; } print("") ; $query = " select O.IdOrdini, O.NumFattura, O.ImportoFattura, O.DataOrdine, O.DataSpedFattura, A.Nome as NomeAgente, C.Nome as NomeCliente, F.Nome as NomeFornitore, AVO.* from ordini O inner join agenti A on A.idagenti = O.idagente inner join clienti C on C.idclienti = O.idcliente inner join fornitori F on F.idfornitori = O.idfornitore inner join AmmontareVariOrdini AVO on AVO.idordine = O.idordini and AVO.Anno = $anno where O.Anno = $anno and $where_age and $where_cli and $where_for order by $order_by " ; if ($log) fwrite($handle, "$query \n") ; list($n, $d) = $db->RecuperaDati($query) ; for ($i=0; $i<$n; $i++) { $idOrdine = $d['IdOrdini'][$i] ; $numFattura = $d['NumFattura'][$i] ; $nomeAgente = htmlspecialchars($d['NomeAgente'][$i]) ; $nomeCliente = htmlspecialchars($d['NomeCliente'][$i]) ; $nomeFornitore = htmlspecialchars($d['NomeFornitore'][$i]) ; $impOrdine = nfe($d['AmmontareOrdineSenzaIva'][$i]) ; $baseProvv = nfe($d['BaseProvvigionale'][$i]) ; $dataOrdine = ItaDate($d['DataOrdine'][$i]) ; $dataSpedFattura = ItaDate($d['DataSpedFattura'][$i]) ; $percProvvAgente = nfp($d['PercentualeProvvAgente'][$i]) ; $ammProvvAgente = nfe($d['AmmontareProvvAgente'][$i]) ; print("$idOrdine$numFattura$nomeAgente$nomeCliente$nomeFornitore$impOrdine$baseProvv$dataOrdine$dataSpedFattura$percProvvAgente$ammProvvAgente") ; } print ("") ; if ($log) fclose($handle) ; ?>