> Tabella Fornitori / Agenti >> Venduto" ; $whereFatt = " 1" ; }else { session_start() ; $_SESSION["Carica"] = "../fornitori/tab_for_age.php?ttot=fatturato" ; $sei_in = "FORNITORI >> Tabella Fornitori / Agenti >> Fatturato" ; $whereFatt = " O.SaldoFattura = 1" ; } $dbt = new FC_SQL ; $i = 0 ; $gtotal = 0 ; $gtotalNew = 0 ; $gtotalpro = 0 ; $dbord = new FC_SQL ; // INIZIA NUOVO CALCOLO $qf = " select * from fornitori where (attivo = '1') or (attivo = '0' and AnnoDisattivazione > $anno) order by Nome " ; $db->query($qf) ; while ($db->next_record()) { $nomefornitore = $db->f("Nome") ; $idfor = $db->f("IdFornitori") ; $aForni[$idfor] = $nomefornitore ; } $str = "" ; foreach($aForni as $idF => $nomeF) { // mi recupero i dati dell'ammontare degli ordini dalla tabella AmmotareVariOrdini $qAVO = " select distinct F.nome as NomeFornitore, F.idFornitori as idfornitore, A.nome as NomeAgente, SUM(AVO.AmmontareOrdineSenzaIva) AOSI, SUM(AVO.AmmontareOrdineConIva) AOCI from ordini O inner join ammontareVariOrdini AVO on AVO.idordine = O.idordini and AVO.Anno = $anno inner join fornitori F on F.IdFornitori = O.IdFornitore inner join agenti A on A.IdAgenti = O.IdAgente where O.Idfornitore = $idF and O.Anno = $anno and $whereFatt group by A.Nome" ; debug (0, $qAVO) ; list($nA, $dA) = $db->RecuperaDati($qAVO) ; for($i=0; $i<$nA; $i++) { $idFF = $dA['idfornitore'][$i] ; $nomeFF = $dA['NomeFornitore'][$i] ; $idAA = $dA['idagente'][$i] ; $nomeAA = $dA['NomeAgente'][$i] ; $aVal[$nomeFF]['ID'] = $idFF ; $aVal[$nomeFF][$nomeAA] = $dA['AOSI'][$i] ; $aVal[$nomeFF]['TOTALE'] += $dA['AOSI'][$i] ; $aAge[$nomeAA]['TOTALE'] += $dA['AOSI'][$i] ; $gtotalNew += $dA['AOSI'][$i] ; } } ksort($aAge) ; $header = "FORNITORE," ; $footer = "TOTALE AGENTE-"; $footer_2 = "(%)-"; $sty_foo_2 = '"text-align:right",' ; $iniWP = "25," ; $strSort = "str," ; $setColType = "ro," ; $setColAlign = "center," ; foreach($aAge as $agente => $arr_agente) { $header .= "$agente," ; $iniWP .= "9," ; $strSort .= "na," ; $setColType .= "ro," ; $setColAlign .= "center," ; $footer .= nfp($arr_agente['TOTALE']) . "-"; $footer_2 .= "(" . nfe(($arr_agente['TOTALE'] / $gtotalNew) * 100) . "%)" . "-"; $sty_foo_2 .= '"text-align:center;font-weight:normal",' ; } $header .= "TOTALE" ; $footer .= nfp($gtotalNew) ; $footer_2 .= "" ; $sty_foo_2 .= '""' ; $strSort .= "euro" ; $iniWP .= "8" ; $setColType .= "ro" ; $setColAlign .= "center" ; $str = "" ; foreach($aVal as $for => $aFor) { $idFor = $aFor["ID"] ; $totFor = $aFor["TOTALE"] ; debug (0, "FOR = $for -- FOR ID = $idFor -- TOTALE = $totFor") ; @reset($aAge) ; if ($totFor > 0) { $str .= "". htmlspecialchars($for) . "" ; foreach($aAge as $ag => $arr_agente) { if (@array_key_exists($ag, $aFor)) { debug(0, "FOR = $for ; AG = $ag ; AFOR[AGE] = " . nfp($aFor[$ag])) ; $str .= "" . nfp($aFor[$ag]) . htmlspecialchars("
") . "(" . nfp(($aFor[$ag] / $aFor['TOTALE']) * 100) . "%)" . "
" ; } else $str .= "" ; } if ($totFor > 0) $str .= "" . nfp($totFor) . "" ; else $str .= "0,00" ; $str .= "
" ; } } $str .= "
" ; ?>
  Venduto Fatturato Venduto Fatturato