> Totali >> Da Agente/i al Cliente/i" ; list($id, $nome_agente) = explode("^", $agente) ; $strIdCli = substr($hidcli, 0, -1) ; $arrIdCli = explode(",", $strIdCli) ; $strNomeCli = substr($hnomecli, 0, -1) ; $strNomeCli = str_replace(",", " / ", $strNomeCli) ; if (in_array(0, $arrIdCli)) $where_cli = "1" ; else $where_cli = "C.idclienti IN ($strIdCli)" ; if ($id == 0) { $single_agente = false ; if ($strNomeCli == "Tutti") $titolo = "Totali di Tutti gli agenti verso Tutti i clienti" ; else $titolo = "Totali di Tutti gli agenti verso il cliente $strNomeCli" ; $where_age = "1" ; } else { $single_agente = true ; if ($strNomeCli == "Tutti") $titolo = "Totali dell'agente $nome_agente verso Tutti i clienti" ; else $titolo = "Totali dell'agente $nome_agente verso il cliente $strNomeCli" ; $sei_in = "AGENTI >> Totali vs Cliente/i" ; $where_age = " O.idagente = $id " ; } } elseif ($from == "totali_for") { $sei_in = "AGENTI >> Totali >> Da Agente/i al Fornitore/i" ; list($id, $nome_agente) = explode("^", $agente) ; $strIdFor = substr($hidfor, 0, -1) ; $arrIdFor = explode(",", $strIdFor) ; $strNomeFor = substr($hnomefor, 0, -1) ; $strNomeFor = str_replace(",", " / ", $strNomeFor) ; if (in_array(0, $arrIdFor)) $where_for = "1" ; else $where_for = "F.idfornitori IN ($strIdFor)" ; if ($id == 0) { $single_agente = false ; if ($strNomeCli == "Tutti") $titolo = "Totali di Tutti gli agenti verso Tutti i fornitori" ; else $titolo = "Totali di Tutti gli agenti verso il fornitore $strNomeFor" ; $where_age = "1" ; } else { $single_agente = true ; if ($strNomeFor == "Tutti") $titolo = "Totali dell'agente $nome_agente verso Tutti i fornitori" ; else $titolo = "Totali dell'agente $nome_agente verso il fornitore $strNomeFor" ; $where_age = " O.idagente = $id " ; } } elseif ($from == "ordini_per_cliente_per_mese") { $sei_in = "AGENTI >> Totali >> Singolo mese per Agente" ; $single_agente = false ; $meseToVis = $arrMesi[$mese] ; $titolo = "Totali dell'agente $nome_agente per il mese di $meseToVis" ; $where_cli = "month(O.dataordine) = $mese" ; $where_for = "1" ; } /*** * cerco di calcolare qualche totale * 1. Numero degli ordini e totali sul venduto ***/ $query = " select count(*) as TotaleOrdini, sum(AVO.AmmontareOrdineSenzaIva) as TotaleAmmontareOrdini, sum(AVO.BaseProvvigionale) as TotaleVenduto, sum(AVO.AmmontareProvvAgente) as TotaleProvvigioniVenduto from ordini O inner join agenti A on A.idagenti = O.idagente inner join clienti C on C.idclienti = O.idcliente inner join fornitori F on F.idfornitori = O.idfornitore inner join AmmontareVariOrdini AVO on AVO.idordine = O.idordini and AVO.Anno = $anno where O.Anno = $anno and $where_age and $where_cli and $where_for " ; debug (0, $query) ; list($n, $d) = $db->RecuperaDati($query) ; $totOrdini = $d['TotaleOrdini'][0] ; $totAmmOrd = $d['TotaleAmmontareOrdini'][0] ; $totVen = $d['TotaleVenduto'][0] ; $totProvvVen = $d['TotaleProvvigioniVenduto'][0] ; /*** * 1. Numero degli ordini con Fattura ***/ $query = " select count(*) as TotaleOrdiniConFattura, sum(AVO.AmmontareOrdineSenzaIva) as TotaleAmmontareOrdini, sum(AVO.BaseProvvigionale) as TotaleFatturato, sum(AVO.AmmontareProvvAgente) as TotaleProvvigioniFatturato from ordini O inner join agenti A on A.idagenti = O.idagente inner join clienti C on C.idclienti = O.idcliente inner join fornitori F on F.idfornitori = O.idfornitore inner join AmmontareVariOrdini AVO on AVO.idordine = O.idordini and AVO.Anno = $anno where O.Anno = $anno and O.ImportoFattura > 0 and $where_age and $where_cli and $where_for " ; list($n, $d) = $db->RecuperaDati($query) ; $totOrdiniConFattura = $d['TotaleOrdiniConFattura'][0] ; $totAmmOrdConFattura = $d['TotaleAmmontareOrdini'][0] ; $totFat = $d['TotaleFatturato'][0] ; $totProvvFat = $d['TotaleProvvigioniFatturato'][0] ; if (! isset($colToSort) or $colToSort == '') $colToSort = 0 ; if (! isset($direction) or $direction == '') $direction = "ASC" ; $strLoadXml = "LoadTotaliAgentiClientiFornitori.php?ordinaper=$colToSort&direction=$direction&from=$from&agente=$agente&hidcli=$hidcli&hnomecli=$hnomecli&hidfor=$hidfor&hnomefor=$hnomefor&mese=$mese&id=$id" ; debug (0, $strLoadXml) ; $header = "N.ORD,N.FATT,AGENTE,CLIENTE,FORNITORE,IMPON ORDINE,IMPON PROVV,DATA ORDINE,DATA FATTURA,% PROVV,PROVV" ; // $header = "N.ORD,N.FATT,AGENTE,CLIENTE,FORNITORE,IMPON PROVV,DATA ORDINE,DATA FATTURA,% PROVV,PROVV" ; if ($single_agente) { $footer = "TOTALE VENDUTO:-#cspan-#cspan-#cspan-" . nfe($totAmmOrd) . "--" . nfe($totVen) . "----" . nfe($totProvvVen) ; $footer2 = "TOTALE FATTURATO:-#cspan-#cspan-#cspan-" . nfe($totAmmOrdConFattura) . "--" . nfe($totFat) . "----" . nfe($totProvvFat) ; } else { $footer = "TOTALE VENDUTO:-#cspan-#cspan-#cspan-#cspan-" . nfe($totAmmOrd) . "-" . nfe($totVen) . "----" . nfe($totProvvVen) ; $footer2 = "TOTALE FATTURATO:-#cspan-#cspan-#cspan-#cspan-" . nfe($totAmmOrdConFattura) . "-" . nfe($totFat) . "----" . nfe($totProvvFat) ; } $strSort = "int,int,str,str,str,euro,euro,date,date,int,euro" ; $iniWP = "5,6,10,13,22,9,9,9,9,8,10" ; $setColType = "ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro" ; $setColAlign = "center,center,left,left,left,right,right,center,center,center,right" ; ?> <? echo TITLE ?>
Numero Ordini: ; Numero Ordini con Fattura: (per selezionare un ordine clicca sulla riga corrispondente)