"); $dbtot = new FC_SQL ; $log = false ; if ($log) $handle = fopen('log_LoadListaFattureInScadenza.txt', 'a+') ; $posStart = $_GET['posStart'] ; $count = $_GET['count'] ; if ($log) { fwrite($handle, "posStart = " . $posStart . "\n") ; fwrite($handle, "count = " . $count . "\n") ; } /*************************************************************************** * where-list e altro ***************************************************************************/ $tipo = $_GET["tipo"] ; $selAge = $_GET["selage"] ; $selCli = $_GET["selcli"] ; $selFor = $_GET["selfor"] ; $selFat = $_GET["selfat"] ; $selDataFat = $_GET["seldatafat"] ; $selPag = $_GET["selpag"] ; $ordinaper = $_GET["ordinaper"] ; $direction = $_GET["direction"] ; $where = "1=1" ; $whereData = "1=1 " ; if ($tipo == 30) { // vuol dire che desidero le fatture la cui scadenza è al max fra 30 giorni $giorni = 31 ; $data = date("Y-m-d", mktime(0,0,0, date("m"), date("d") - $giorni, date("Y"))) ; $whereData = " O.dataspedfattura <= '$data' " ; if ($log) fwrite($handle, "WHERE DATA = $whereData \n") ; } /************************* * filtro Agente **************************/ if (isset($selAge) and ($selAge != 'tutti')) $where .= " and A.IdAgenti = $selAge" ; /************************* * 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 Fornitori **************************/ if (isset($selFor) and ($selFor != 'tutti')) $where .= " and F.IdFornitori = $selFor" ; /************************* * filtro Clienti **************************/ if (isset($selCli) and ($selCli != 'tutti')) $where .= " and C.IdClienti = $selCli" ; /************************* * filtro Pagamento **************************/ if (isset($selPag) and ($selPag != 'tutti')) $where .= " and P.IdPagamenti = $selPag" ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($ordinaper) { case 0: // numero ordine $order_by = "O.idordini $direction" ; break ; case 1: // agente $order_by = "A.Nome $direction, C.Nome" ; break ; case 2: // cliente $order_by = "C.Nome $direction, O.IdOrdini" ; break ; case 3: // fornitore $order_by = "F.Nome $direction, C.Nome" ; break ; case 4: // numero fattura $order_by = "O.NumFattura $direction, C.Nome" ; break ; case 5: // data fattura $order_by = "O.DataSpedFattura $direction, C.Nome" ; break ; case 6: // pagamento $order_by = "P.Modalita $direction, C.Nome" ; break ; case 7: // importo fattura $order_by = "O.ImportoFattura $direction, C.Nome" ; break ; } /******************************************************************************** * NB: non posso usare la funzione nativa del MySql DATEDIFF in quanto è stata * implementata solo dalla release 4.1.1 ********************************************************************************/ $qcli = " select O.*, case when (O.DataSpedFattura = '0000-00-00') then '2002-01-01' else O.DataSpedFattura end as DataSpedizioneFattura, DAYOFYEAR(O.DataSpedFattura), A.idagenti as IdAgenti, A.nome as NomeAgente, F.idfornitori as IdFornitori, F.Nome as NomeFornitore, C.idclienti as IdClienti, C.nome as NomeCliente, P.idpagamenti as IdPagamenti, P.modalita as TipoPagamento from ordini O inner join pagamenti P on P.IdPagamenti = O.idpagamento inner join fornitori F on F.idfornitori = O.idfornitore inner join clienti C on C.idclienti = O.idcliente inner join agenti A on A.idagenti = O.idagente where O.Anno = $anno and O.saldofattura = 0 and O.NumFattura <> 0 and O.dataspedfattura <= NOW() and O.idpagamento NOT IN (2,7) and O.idfornitore = F.idfornitori and O.idcliente = C.idclienti and $whereData and $where 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++ ) { $numNA = $dati['NumNA'][$i] ; $numNC = $dati['NumNC'][$i] ; $idordine = $dati['IdOrdini'][$i] ; // ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dati['DataSpedizioneFattura'][$i], $reg_str) ; // $ggpass = dateDiff(date("d"), date("m"), date("Y"), $reg_str[3], $reg_str[2], $reg_str[1]) ; // $ggpass = 100 ; if ($ggpass <= 90) $class="min_90" ; elseif ($ggpass > 90 and $ggpass <= 120) $class = "mag_90" ; else $class = "mag_120" ; if ($numNC > 0 and $numNA > 0) $class .= " visNCNA" ; elseif ($numNC > 0 or $numNA > 0) $class .= " visNC" ; $str = "" ; $str .= "$idordine" ; $str .= "" . htmlspecialchars($dati['NomeAgente'][$i]) . "" ; $str .= "" . htmlspecialchars($dati['NomeCliente'][$i]) . "" ; $str .= "" . htmlspecialchars($dati['NomeFornitore'][$i]) . "" ; if ($numNC > 0 and $numNA > 0) { $str .= "" . $dati['NumFattura'][$i] . htmlspecialchars("
NC:$numNC") . htmlspecialchars("
NA:$numNA") . "
" ; $str .= "" . ItaDate($dati['DataSpedFattura'][$i]) . "(" . $ggpass . ")" . htmlspecialchars("
") . ItaDate($dati['DataNC'][$i]) . htmlspecialchars("
") . ItaDate($dati['DataNA'][$i]) . "
" ; } elseif ($numNA > 0) { $str .= "" . $dati['NumFattura'][$i] . htmlspecialchars("
NA:$numNA") . "
" ; $str .= "" . ItaDate($dati['DataSpedFattura'][$i]) . " (" . $ggpass . ")" . htmlspecialchars("
") . ItaDate($dati['DataNA'][$i]) . "
" ; } elseif ($numNC > 0) { $str .= "" . $dati['NumFattura'][$i] . htmlspecialchars("
NC:$numNC") . "
" ; $str .= "" . ItaDate($dati['DataSpedFattura'][$i]) . " (" . $ggpass . ")" . htmlspecialchars("
") . ItaDate($dati['DataNC'][$i]) . "
" ; } else { $str .= "" . $dati['NumFattura'][$i] . "" ; $str .= "" . ItaDate($dati['DataSpedFattura'][$i]) . " (" . $ggpass . ")" . "" ; } $str .= "" . htmlspecialchars($dati['TipoPagamento'][$i]) . "" ; if ($numNC > 0 and $numNA > 0) $str .= "" . nfe($dati['ImportoFattura'][$i]) . htmlspecialchars("
-") . nfe($dati['ImportoNC'][$i]) . htmlspecialchars("
") . nfe($dati['ImportoNA'][$i]) ."
" ; elseif ($numNA > 0) $str .= "" . nfe($dati['ImportoFattura'][$i]) . htmlspecialchars("
") . nfe($dati['ImportoNA'][$i]) . "
" ; elseif ($numNC > 0) $str .= "" . nfe($dati['ImportoFattura'][$i]) . htmlspecialchars("
-") . nfe($dati['ImportoNC'][$i]) . "
" ; else $str .= "" . nfe($dati['ImportoFattura'][$i]) . "" ; $str .= "
" ; if ($log) fwrite($handle, "$str\n") ; print ("$str") ; } print ("") ; print ("
") ; if ($log) fclose($handle) ; ?>