/********************************************
* VERSIONE 3.0 READY
********************************************/
include ("../common/public.php") ;
// print_r($_GET + $_POST) ; // exit ;
$tot_sel = 0 ;
if ($tot_auto == 1)
$flag_chk = 1 ;
else
$flag_chk = 0 ;
if (isset($agente) and ($agente != 0))
{
$db->query("select * from agenti where IdAgenti = $agente") ;
while ($db->next_record())
$nome = $db->f("Nome") ;
}
$str = "" ;
if ($dal == "")
{
$datadal = MySqlDate("01/01/$anno") ;
$dataal = MySqlDate("31/12/$anno") ;
}
else
{
$datadal = MySqlDate($dal) ;
$dataal = MySqlDate($al) ;
}
$dbt = new FC_SQL ;
if ($tipo == "nonpagate")
{
$titolo = "Ordini con provvigioni NON PAGATE all'Agente: $nome" ;
$query = "
select
*,
AFP.percentuale as PercentualeAgente,
A.Percentuale as PercentualeDefault,
C.Nome as NomeCliente
from
ordini O
inner join clienti C on C.IdClienti = O.IdCliente
inner join pagamenti P on P.IdPagamenti = O.IdPagamento
left join ageforper AFP on AFP.IdAgente = O.IdAgente and
AFP.IdFornitore = O.IdFornitore and
AFP.Anno = $anno
inner join agenti A on A.IdAgenti = O.IdAgente
inner join AmmontareVariOrdini AVO on AVO.IdOrdine = O.IdOrdini and
AVO.Anno = $anno
where
O.Anno = $anno and
O.NumFattura <> 0 and
O.SaldoProvvigioneAgente = 0 and
O.DataSpedFattura >= '$datadal' and
O.DataSpedFattura <= '$dataal' and
O.idagente = $agente
order by
O.IdOrdini
" ;
}
else
{
$flag_chk = 0 ;
$titolo = "Ordini con provvigioni PAGATE all'Agente: $nome" ;
$query = "
select
*,
AFP.percentuale as PercentualeAgente,
A.Percentuale as PercentualeDefault,
C.Nome as NomeCliente
from
ordini O
inner join clienti C on C.IdClienti = O.IdCliente
inner join pagamenti P on P.IdPagamenti = O.IdPagamento
left join ageforper AFP on AFP.IdAgente = O.IdAgente and
AFP.IdFornitore = O.IdFornitore and
AFP.Anno = $anno
inner join agenti A on A.IdAgenti = O.IdAgente
inner join AmmontareVariOrdini AVO on AVO.IdOrdine = O.IdOrdini and
AVO.Anno = $anno
where
O.Anno = $anno and
O.NumFattura <> 0 and
O.SaldoProvvigioneAgente = 1 and
O.DataSpedFattura >= '$datadal' and
O.DataSpedFattura <= '$dataal' and
O.idagente = $agente
order by
O.IdOrdini
" ;
}
list($n, $d) = $db->RecuperaDati($query) ;
for ($i=0; $i<$n; $i++)
{
if (isset($fatt_sald) and ($fatt_sald != 'tutti') and ($fatt_sald != $d['SaldoFattura'][$i]))
continue ;
if (isset($fatt_ag_sald) and ($fatt_ag_sald != 'tutti') and ($fatt_ag_sald != $d['SaldoProvvigione'][$i]))
continue ;
$tot_sel ++ ;
$idordine = $d['IdOrdini'][$i] ;
$numfattura = $d['NumFattura'][$i] ;
if ($d['PercentualeAgente'][$i] != 0)
$per = $d['PercentualeAgente'][$i] ;
else
$per = $d['PercentualeDefault'][$i] ;
$totord = $d['BaseProvvigionale'][$i] ;
$totprovord = $d['AmmontareProvvAgente'][$i] ;
$totale += $totord ;
$totaleprov += $totprovord ;
$str .= "" ;
$str .= "| $idordine | " ;
$str .= "$numfattura | " ;
$str .= "" . SiNo($d['SaldoFattura'][$i]) . " | " ;
$str .= "" . htmlspecialchars($d['NomeCliente'][$i]) . " | " ;
$str .= "" . ItaDate($d['DataSpedFattura'][$i]) . " | " ;
$str .= "" . nfp($totord) . " | " ;
$str .= "" . nfp($per) . " | " ;
$str .= "" . nfp($totprovord) . " | " ;
$str .= "" . SiNo($d['SaldoProvvigione'][$i]) . " | " ;
$str .= "$flag_chk | " ;
$str .= "
" ;
}
$str .= "" ;
if ($tipo == "nonpagate")
{
$header = "N. ORD,N. FATT,FATT SALD?,CLIENTE,DATA FATT.,IMPORTO,% PROVV,PROVV,PRO. AG SALD?,CALCOLA" ;
$footer = "TOTALE:-#cspan-#cspan-#cspan-#cspan-" . nfp($totale) . "--" . "
0,00
" . "--#cspan" ;
$attHeaderStyle = "background-color:#ffffaa;border-bottom:1px solid silver;padding:2px 2px 0px 2px" ;
$attH = " , ,, , , , , ,, ," ;
$attHS = "$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle,$attHeaderStyle" ;
}
else
{
$header = "N. ORD,N. FATT,FATT SALD?,CLIENTE,DATA FATT.,IMPORTO,% PROVV,PROVV,PRO. AG SALD?" ;
$footer = "TOTALE:-#cspan-#cspan-#cspan-#cspan-" . nfp($totale) . "--" . nfp($totaleprov) . "-" ;
}
$strSort = "int,int,str,str,date,euro,int,euro,str" ;
$iniWP = "7,7,10,23,10,9,8,7,12,7" ;
$setColType = "ro,ro,ro,ro,ro,ro,ro,ro,ro,ch" ;
$setColAlign = "center,center,center,left,center,right,center,right,center,center" ;
?>
echo TITLE ?>
if ($n > 0) : ?>
endif ?>
if ($tipo == "nonpagate")
{
?>
if ($n > 0)
{
?>
}
}
else
{
if ($n > 0)
{
?>
}
}
?>
echo $titolo ?>
Totale Ordini = echo $n ?>;
Selezionati = echo $tot_sel ?>
(Per selezionare un ordine clicca sulla riga corrispondente)