$giorno $mese
per l'agente $nome_agente" ; debug (0, "AGENTE = $nome_agente ; HCONFRONTI = $hconfronti ; CLIENTE = $nome_cliente ; FORNITORE = $nome_forni") ; ?> <? echo TITLE ?>
2002) { ?>
  Numero Ordini  
query($query) ; $i = 0 ; while ($db->next_record()) { $tot = $db->f("tot") ; $nordini[] = $tot ; ${"tot_$an"} = $tot ; ${"wid_$an"} = ($tot * 748) / 4000 ; debug (0, "TOT $an = $tot -- wid = $wid") ; ?>
">  ">
Differenza   

  Venduto  
query("select * from fornitori_$an order by Nome") ; while ($db->next_record()) { $totfornitori ++ ; $totforn = 0 ; $totproforn = 0 ; $nomefornitore = $db->f("Nome") ; $idfor = $db->f("IdFornitori") ; $provvigione = $db->f("Provvigione") ; $qord = " select * from ordini_$an where idfornitore = $idfor and dataordine <= '$dataordine' and idagente = $id_agente order by idordini " ; debug (0, $qord) ; $dbord->query($qord) ; while ($dbord->next_record()) { $count ++ ; $id = $dbord->f("IdOrdini") ; $totordine = 0 ; $sco1 = $dbord->f("Sconto1") ; $sco2 = $dbord->f("Sconto2") ; $sco3 = $dbord->f("Sconto3") ; $idordine = $dbord->f("IdOrdini") ; $importoNC = $dbord->f("ImportoNC") ; if ($importoNC > 0) $valNC = ($importoNC / 1.2) ; else $valNC = 0 ; if ($idfor != $idsarzi) $query = "select * from dettagli_$an, prodotti_$an where dettagli_$an.idordine = $idordine and prodotti_$an.idprodotti = dettagli_$an.idprodotto " ; else $query = "select * from dettagli_$an, sarzi_$an where dettagli_$an.idordine = $idordine and dettagli_$an.idprodotto = CONCAT('SA', idprodotti)" ; $dbt->query($query) ; while ($dbt->next_record()) { $impparz = $dbt->f("NumCartoni") * $dbt->f("ConfezioniDa") * $dbt->f("PrezzoUnitario") ; if ($dbt->f("ScontoPrd") != "") $impparz = CalcolaScontoProdotto($impparz, $dbt->f("ScontoPrd")) ; $totordine += $impparz ; } $sconto1 = ($totordine * $sco1 / 100) ; $ammpro1 = $totordine - $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 e l'eventuale * ammontare della nota di credito. Idem per il * fatturato *************************************************************/ $totproordine = ($ammpro2 * $provvigione / 100) ; $sconto = $sconto1 + $sconto2 ; $totordine = $totordine - $sconto - $valNC; $totforn += $totordine ; $totproforn += $totproordine ; debug (0, "ORDINE = $idordine -- TOTORDINE = $totordine") ; } $gtotal_tmp += $totforn ; $wid = ($gtotal_tmp * 748) / 4000000 ; $i ++ ; } ?>
 
Differenza   

  Fatturato  
query("select * from fornitori_$an order by Nome") ; while ($db->next_record()) { $totfornitori ++ ; $totforn = 0 ; $totproforn = 0 ; $nomefornitore = $db->f("Nome") ; $idfor = $db->f("IdFornitori") ; $provvigione = $db->f("Provvigione") ; $qord = " select * from ordini_$an where idfornitore = $idfor and importofattura > 0 and dataspedfattura <= '$dataordine' and idagente = $id_agente " ; debug (0, $qord) ; $dbord->query($qord) ; while ($dbord->next_record()) { $totordine = 0 ; $sco1 = $dbord->f("Sconto1") ; $sco2 = $dbord->f("Sconto2") ; $sco3 = $dbord->f("Sconto3") ; $idordine = $dbord->f("IdOrdini") ; $importoNC = $dbord->f("ImportoNC") ; if ($importoNC > 0) $valNC = ($importoNC / 1.2) ; else $valNC = 0 ; if ($idfor != $idsarzi) $query = "select * from dettagli_$an, prodotti_$an where dettagli_$an.idordine = $idordine and prodotti_$an.idprodotti = dettagli_$an.idprodotto " ; else $query = "select * from dettagli_$an, sarzi_$an where dettagli_$an.idordine = $idordine and dettagli_$an.idprodotto = CONCAT('SA', idprodotti)" ; $dbt->query($query) ; while ($dbt->next_record()) { $impparz = $dbt->f("NumCartoni") * $dbt->f("ConfezioniDa") * $dbt->f("PrezzoUnitario") ; if ($dbt->f("ScontoPrd") != "") $impparz = CalcolaScontoProdotto($impparz, $dbt->f("ScontoPrd")) ; $totordine += $impparz ; } $sconto1 = ($totordine * $sco1 / 100) ; $ammpro1 = $totordine - $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 e l'eventuale * ammontare della nota di credito. Idem per il * fatturato *************************************************************/ $totproordine = ($ammpro2 * $provvigione / 100) ; $sconto = $sconto1 + $sconto2 ; $totordine = $totordine - $sconto - $valNC; $totforn += $totordine ; $totproforn += $totproordine ; debug (0, "ORDINE = $idordine -- TOTORDINE = $totordine") ; } $gtotalf_tmp += $totforn ; $wid = ($gtotalf_tmp * 748) / 2000000 ; $i ++ ; } ?>
 
Differenza   



Il confronto fra due anni puņ essere effettuato solo a partire dal 2003.