"); $log = false ; if ($log) $handle = fopen('log_LoadListaClienti.txt', 'a+') ; $posStart = $_GET['posStart'] ; $count = $_GET['count'] ; if ($log) { fwrite($handle, "posStart = " . $posStart . "\n") ; fwrite($handle, "count = " . $count . "\n") ; } /*************************************************************************** * where-list ***************************************************************************/ $selCli = $_GET["selcli"] ; $selAge = $_GET["selage"] ; $selCat = $_GET["selcat"] ; $selTot = $_GET["seltot"] ; $selPiva = $_GET["selpiva"] ; $selCodFis = $_GET["selcodfis"] ; $selInd = $_GET["selind"] ; $selCap = $_GET["selcap"] ; $selCitta = $_GET["selcitta"] ; $selZona = $_GET["selzona"] ; $selProv = $_GET["selprov"] ; $selTel = $_GET["seltel"] ; $selFax = $_GET["selfax"] ; $selEmail = $_GET["selemail"] ; $selCons = $_GET["selcons"] ; $selNote = $_GET["selnote"] ; $ordinaper = $_GET["ordinaper"] ; $direction = $_GET["direction"] ; $where = "1=1" ; /************************* * filtro Cliente **************************/ if (isset($selCli) and ($selCli != 'tutti')) $where .= " and C.Nome like '%$selCli%'" ; /************************* * filtro Agente **************************/ if (isset($selAge) and ($selAge != 'tutti')) $where .= " and A.IdAgenti = $selAge" ; /************************* * filtro Categoria **************************/ if (isset($selCat) and ($selCat != 'tutti')) $where .= " and T.IdTipologie = $selCat" ; /************************* * filtro Totale Ordini **************************/ if (isset($selTot) and ($selTot != 'tutti')) if ($selTot == 'zero') $where .= " and O.idordini is null" ; else $where .= " and O.idordini > 0" ; /************************* * filtro Partita Iva **************************/ if (isset($selPiva) and ($selPiva != '')) $where .= " and C.piva like '%$selPiva%'" ; /************************* * filtro Codice Fiscale **************************/ if (isset($selCodFis) and ($selCodFis != '')) $where .= " and C.codfisc like '%$selCodFis%'" ; /***************************************** * filtro Indirizzo *****************************************/ if (isset($selInd) and ($selInd != '')) $where .= " and C.indirizzo like '%$selInd%'" ; /***************************************** * filtro Cap *****************************************/ if (isset($selCap) and ($selCap != '')) $where .= " and C.cap like '%$selCap%'" ; /***************************************** * filtro Citta' *****************************************/ if (isset($selCitta) and ($selCitta != '')) $where .= " and C.citta like '%$selCitta%'" ; /************************* * filtro Zona **************************/ if (isset($selZona) and ($selZona != 'tutti')) $where .= " and Z.IdZone = $selZona" ; /***************************************** * filtro Provincia *****************************************/ if (isset($selProv) and ($selProv != '')) $where .= " and C.provincia like '%$selProv%'" ; /***************************************** * filtro Telefono *****************************************/ if (isset($selTel) and ($selTel != '')) $where .= " and C.telefono like '%$selTel%'" ; /***************************************** * filtro Fax *****************************************/ if (isset($selFax) and ($selFax != '')) $where .= " and C.fax like '%$selFax%'" ; /***************************************** * filtro Email *****************************************/ if (isset($selEmail) and ($selEmail != '')) $where .= " and C.email like '%$selEmail%'" ; /***************************************** * filtro Consegna *****************************************/ if (isset($selCons) and ($selCons != '')) $where .= " and C.consegna like '%$selCons%'" ; /***************************************** * filtro Note *****************************************/ if (isset($selNote) and ($selNote != '')) $where .= " and C.note like '%$selNote%'" ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($ordinaper) { case 0: // cliente $order_by = "C.Nome $direction" ; break ; case 1: // agente $order_by = "A.nome $direction, C.Nome" ; break ; case 2: // categoria $order_by = "T.descrizione $direction, C.Nome" ; break ; case 3: // totale ordini $order_by = "num_ordini $direction, C.Nome" ; break ; case 4: // partita iva $order_by = "C.piva $direction, C.Nome" ; break ; case 5: // codice fiscale $order_by = "C.codfisc $direction, C.Nome" ; break ; case 6: // indirizzo $order_by = "C.indirizzo $direction, C.Nome" ; break ; case 7: // cap $order_by = "C.cap $direction, C.Nome" ; break ; case 8: // citta $order_by = "C.citta $direction, C.Nome" ; break ; case 9: // zona $order_by = "Z.NomeZona $direction, C.Nome" ; break ; case 10: // provincia $order_by = "C.provincia $direction, C.Nome" ; break ; case 11: // telefono $order_by = "C.telefono $direction, C.Nome" ; break ; case 12: // fax $order_by = "C.fax $direction, C.Nome" ; break ; case 13: // email $order_by = "C.email $direction, C.Nome" ; break ; case 14: // consegna $order_by = "C.consegna $direction, C.Nome" ; break ; case 15: // note $order_by = "C.note $direction, C.Nome" ; break ; } $qcli = " select count(O.idordini) as NumOrdini, C.idclienti as IdClienti, C.cap as CapCliente, C.citta as CittaCliente, Z.NomeZona as ZonaCliente, C.provincia as ProvinciaCliente, C.telefono as TelefonoCliente, C.fax as FaxCliente, C.indirizzo as IndirizzoCliente, C.piva as PivaCliente, C.codfisc as CodFiscCliente, C.nome as NomeCliente, C.Email as Email, A.Nome as NomeAgente, C.Note as NoteCliente, C.consegna as Consegna, T.Descrizione as Categoria from clienti C left join ordini O on O.idcliente = C.idclienti and O.Anno = $anno left join zone Z on Z.IdZone = C.idzona, agenti A, tipologie T where A.IdAgenti = C.IdAgente and C.idtipologia = T.idtipologie and $where group by C.Nome order by $order_by limit 0,20 " ; if ($log) fwrite($handle, "$qcli \n") ; list($nrowsdati, $dati) = $db->RecuperaDati($qcli) ; if ($log) fwrite($handle, "\n") ; print("") ; $arrClienti = array() ; for ($i = 0; $i < $nrowsdati ; $i++ ) { $id = $dati['IdClienti'][$i] ; $tot_ordini = $dati['NumOrdini'][$i] ; $cliente = htmlspecialchars($dati['NomeCliente'][$i]) ; $agente = htmlspecialchars($dati['NomeAgente'][$i]) ; $categoria = $dati['Categoria'][$i] ; $piva = $dati['PivaCliente'][$i] ; $codfis = $dati['CodFiscCliente'][$i] ; $indirizzo = htmlspecialchars($dati['IndirizzoCliente'][$i]) ; $cap = $dati['CapCliente'][$i] ; $citta = $dati['CittaCliente'][$i] ; $zona = $dati['ZonaCliente'][$i] ; $prov = $dati['ProvinciaCliente'][$i] ; $telefono = $dati['TelefonoCliente'][$i] ; $fax = $dati['FaxCliente'][$i] ; $email = $dati['Email'][$i] ; $consegna = htmlspecialchars($dati['Consegna'][$i]) ; $note = htmlspecialchars($dati['NoteCliente'][$i]) ; if ($log) fwrite($handle, "$cliente$agente$categoria$piva$codfis$indirizzo$cap$citta$prov$telefono$fax$email$consegna$note\n") ; print ("$cliente$agente$categoria$tot_ordini$piva$codfis$indirizzo$cap$citta$zona$prov$telefono$fax$email$consegna$note") ; } if ($log) fwrite($handle, "\n") ; print ("") ; if ($log) fclose($handle) ; ?>