"); $dbtot = new FC_SQL ; $log = false ; if ($log) $handle = fopen('log_LoadListaFatture.txt', 'a+') ; $posStart = $_GET['posStart'] ; $count = $_GET['count'] ; if ($log) { fwrite($handle, "posStart = " . $posStart . "\n") ; fwrite($handle, "count = " . $count . "\n") ; } /*************************************************************************** * where-list ***************************************************************************/ $selOrd = $_GET["selord"] ; $selFat = $_GET["selfat"] ; $selDataFat = $_GET["seldatafat"] ; $selDataScadFat = $_GET["seldatafat"] ; $selFor = $_GET["selfor"] ; $selCli = $_GET["selcli"] ; $selInc = $_GET["selinc"] ; $ordinaper = $_GET["ordinaper"] ; $direction = $_GET["direction"] ; $where = "1=1" ; /************************* * filtro Num Ordine **************************/ if (isset($selOrd) and ($selOrd != '')) $where .= " and O.IdOrdini = $selOrd" ; /************************* * filtro Numero Fattura **************************/ if (isset($selFat) and ($selFat != '')) $where .= " and O.NumFattura = $selFat" ; /************************* * filtro Data Fattura **************************/ if (isset($selDataFat) and ($selDataFat != '')) { $selDataFat = MySqlDate($selDataFat) ; $where .= " and O.DataSpedFattura = '$selDataFat'" ; } /****************************** * filtro Data Scadenza Fattura ******************************/ if (isset($selDataScadFat) and ($selDataScadFat != '')) { $selDataScadFat = MySqlDate($selDataScadFat) ; $where .= " and O.DataScadFattura = '$selDataScadFat'" ; } /************************* * filtro Fornitori **************************/ if (isset($selFor) and ($selFor != 'tutti')) $where .= " and O.idfornitore = $selFor" ; /************************* * filtro Clienti **************************/ if (isset($selCli) and ($selCli != 'tutti')) $where .= " and O.idcliente = $selCli" ; /************************* * filtro Inaccasate **************************/ if (isset($selInc) and ($selInc != 'tutti')) $where .= " and O.SaldoFattura = $selInc" ; /*************************************** * 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, O.idordini" ; break ; case 2: // data fattura $order_by = "O.DataSpedFattura $direction, O.NumFattura" ; break ; case 3: // data scadenza fattura $order_by = "O.DataScadFattura $direction, O.NumFattura" ; break ; case 4: // fornitore $order_by = "F.Nome $direction, O.NumFattura" ; break ; case 5: // cliente $order_by = "C.Nome $direction, O.NumFattura" ; break ; case 6: // importo fattura $order_by = "O.ImportoFattura $direction, O.NumFattura" ; break ; case 7: // incassata $order_by = "O.SaldoFattura $direction, O.NumFattura" ; break ; } $qcli = " select O.*, F.nome as NomeFornitore, C.nome as NomeCliente from $tordini O inner join $tfornitori F on F.idfornitori = O.idfornitore inner join $tclienti C on C.idclienti = O.idcliente where O.dataspedfattura <> '' and O.dataspedfattura <> '0000-00-00' and $where order by $order_by " ; 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++ ) { $idordine = $dati['IdOrdini'][$i] ; if ($dati['SaldoFattura'][$i] == 0) $sn = "No" ; else $sn = "Si" ; $str = "" ; $str .= "$idordine" ; $str .= "" . $dati['NumFattura'][$i] . "" ; $str .= "" . ItaDate($dati['DataSpedFattura'][$i]) . "" ; $str .= "" . ItaDate($dati['DataScadFattura'][$i]) . "" ; $str .= "" . htmlspecialchars($dati['NomeFornitore'][$i]) . "" ; $str .= "" . htmlspecialchars($dati['NomeCliente'][$i]) . "" ; $str .= "" . nfe($dati['ImportoFattura'][$i]) . "" ; $str .= "" . $sn . "" ; $str .= "" ; if ($log) fwrite($handle, "$str\n") ; print ("$str") ; } print ("") ; if ($log) fclose($handle) ; ?>