query("select * from $tclienti where IdClienti = $cliente") ; while ($db->next_record()) $nome = $db->f("Nome") ; } else { $onlyc = 0 ; $all = 1 ; } list($idfor, $nomefor) = split("\^", $fornitore) ; if ($onlyc == 1 and $idfor == 0) { /************************************************************************ * ho scelto il totale complessivo del solo cliente $cliente ************************************************************************/ ?>
0) { ?>
0) { $where_for = " $tfornitori.idfornitori = $idfor" ; $titolo = "Totale Venduto / Fatturato di tutti i clienti verso il fornitore: $nomefor" ; } /******************************************* * Tutti i clienti verso tutti i fornitori *******************************************/ $qc = " select * from $tclienti order by Nome " ; list($nc, $dc) = $db->RecuperaDati($qc) ; for ($i=0; $i<$nc; $i++) { $TotOrdCli = 0 ; $TotProCli = 0 ; $TotFatCli = 0 ; $TotProFatCli = 0 ; $idcli = $dc['IdClienti'][$i] ; $nomecliente = $dc['Nome'][$i] ; $qo = " select *, $tfornitori.idfornitori, $tfornitori.provvigione as Provvigione from $tordini, $tfornitori where $tordini.idcliente = $idcli and $tfornitori.idfornitori = $tordini.idfornitore and $where_for " ; debug (0, $qo) ; list($no, $do) = $dbord->RecuperaDati($qo) ; for ($j=0; $j<$no; $j++) { $totordine = 0 ; $totproordine = 0 ; $ammpro = 0 ; $idforn = $do['IdFornitori'][$j] ; $provvigione = $do['Provvigione'][$j] ; $idordine = $do['IdOrdini'][$j] ; $importoNC = $do['ImportoNC'][$j] ; $importofattura = $do['ImportoFattura'][$j] ; if ($importoNC > 0) $valNC = ($importoNC / 1.2) ; else $valNC = 0 ; if ($idforn != $idsarzi) $qd = "select * from $tdettagli, $tprodotti, $tordini where $tordini.idordini = $idordine and $tdettagli.idordine = $idordine and $tprodotti.idprodotti = $tdettagli.idprodotto " ; else $qd = "select * from $tdettagli, $tsarzi, $tordini where $tordini.idordini = $idordine and $tdettagli.idordine = $idordine and $tdettagli.idprodotto = CONCAT('SA',idprodotti)" ; list($nd, $dd) = $dbt->RecuperaDati($qd) ; for ($x=0; $x<$nd; $x++) { $sco1 = $dd['Sconto1'][$x] ; $sco2 = $dd['Sconto2'][$x] ; $sco3 = $dd['Sconto3'][$x] ; $impparz = $dd['NumCartoni'][$x] * $dd['ConfezioniDa'][$x] * $dd['PrezzoUnitario'][$x] ; if ($dd['ScontoPrd'][$x] != "") $impparz = CalcolaScontoProdotto($impparz, $dd['ScontoPrd'][$x]) ; $ammpro += $impparz ; } $sconto1 = ($ammpro * $sco1 / 100) ; $ammpro1 = $ammpro - $sconto1 ; $sconto2 = ($ammpro1 * $sco2 / 100) ; $ammpro2 = $ammpro1 - $sconto2 - $valNC ; /**************************************************************************************************************** * Calcolo a questo punto l'ammontare delle provvigioni per questo ordine dopo aver sottratto dall'imponibile gli * eventuali 2 sconti forniti dal fornitore. Idem per il fatturato *****************************************************************************************************************/ $totproordine = ($ammpro2 * $provvigione / 100) ; $sconto = $sconto1 + $sconto2 ; $ammpro = $ammpro - $sconto - $valNC ; $totordine += $ammpro ; $TotOrdCli += $totordine ; if ($importofattura > 0) { $TotFatCli += $totordine ; $TotProFatCli += $totproordine ; } $TotProCli += $totproordine ; } $gTotVen += $TotOrdCli ; $gTotProvVen += $TotProCli ; $gTotFat += $TotFatCli ; $gTotProvFat += $TotProFatCli ; $item[0][] = $nomecliente ; $item[1][] = $TotOrdCli ; $item[3][] = $TotProCli ; $item[4][] = $idcli ; $item[5][] = $TotFatCli ; $item[6][] = $TotProFatCli ; } } $str = "" ; foreach($item[0] as $idx => $nomecliente) { if ($item[1][$idx] > 0) { $id_cliente = $item[4][$idx] ; $str .= "" ; $str .= "" . htmlspecialchars($nomecliente) . "" ; $str .= "" . nfe($item[1][$idx]) . "" ; $str .= "" . nfe($item[3][$idx]) . "" ; $str .= "" . nfe($item[5][$idx]) . "" ; $str .= "" . nfe($item[6][$idx]) . "" ; $str .= "" ; } } $str .= "" ; $header = "CLIENTE,TOTALE VENDUTO,PROVV VENDUTO,TOTALE FATTURATO,PROVV FATTURATO" ; $footer_ven = "TOTALI:-" . nfe($gTotVen) . "-" . nfe($gTotProvVen) . "-" . nfe($gTotFat) . "-" . nfe($gTotProvFat) ; $strSort = "str,euro,euro,euro,euro" ; $iniWP = "40,14,14,15,15" ; $setColType = "ro,ro,ro,ro,ro" ; $setColAlign = "left,right,right,right,right" ; ?> <? echo TITLE ?>
0) : ?>