SetCreator(PDF_CREATOR); $pdf->SetAuthor('Fabrizio Curcio'); $pdf->SetTitle('Storico Fatturato'); $pdf->SetSubject('Storico Fatturato'); $pdf->SetKeywords('PDF'); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP + 60, PDF_MARGIN_RIGHT); // $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(FALSE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); $pdf->AddPage('L', 'A4'); // $pdf->AddPage(); $pdf->SetLineWidth(0.1); $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0); // $pdf->SetXY(15, 100) ; $pdf->SetXY(10, 10) ; $pdf->SetFont('helvetica', '', 14); $pdf->Cell(274, 14, "Storico Fatturato " . '"' . $nomefornitore . '"', "", 0, 'C', 0) ; $pdf->SetXY(10, 30) ; $pdf->Cell(275, 10, "ANNO", "LTR", 0, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(10, 37) ; $pdf->Cell(275, 5, "-differenza % con anno precedente-", "LRB", 0, 'C', 0) ; $annoIn = 2000 ; $nAn = 0 ; $iniX = 10 ; $iniY = 45 ; for ($na=0; $na<$numAnni; $na ++) { for ($aa=$annoIn; $aa<=$anno; $aa++) { if (($aa <= $anno) && ($nAn < 10)) { $pdf->SetFont('helvetica', '', 12); $pdf->SetXY($iniX, $iniY) ; $pdf->Cell(27.5, 8, $aa, "LTR", 0, 'C', 0) ; if (array_key_exists($aa, $arrVal)) $fatt = nfp($arrVal[$aa]) ; else $fatt = "" ; $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($iniX, $iniY + 8) ; $pdf->Cell(27.5, 8, $fatt, "LR", 0, 'C', 0) ; if ($arrPerc[$aa] != "") $fattPerc = "(" . $arrPerc[$aa] . "%)" ; else $fattPerc = "" ; if ($arrPerc[$aa] >= 0) $col = "green" ; else $col = "red" ; $pdf->SetXY($iniX, $iniY + 14) ; $pdf->Cell(27.5, 8, $fattPerc, "LRB", 0, 'C', 0) ; $iniX += 27.5 ; // $annIn ++ ; $nAn ++ ; } else { if ($nAn == 10) { $aa -- ; $nAn = 0 ; $iniX = 10 ; $iniY += 27 ; } else { $nAn = 11 ; $aa = $anno + 1 ; $na = 4 ; } } if ($aa == $anno) { $na = 4 ; } } } /* $pdf->SetXY(127, 30) ; $pdf->Cell(70, 10, "BOTTIGLIE", "LTRB", 0, 'C', 0) ; $pdf->SetXY(199, 30) ; $pdf->Cell(70, 10, "PREZZO MEDIO", "LTRB", 1, 'C', 0) ; $pdf->SetXY(37, 40) ; $pdf->Cell(22, 7, $anno, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-1, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, "DIFF %", "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-2, "LTRB", 0, 'C', 0) ; $pdf->SetX(127) ; $pdf->Cell(22, 7, $anno, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-1, "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, "DIFF %", "LTRB", 0, 'C', 0) ; $pdf->SetX(199) ; $pdf->Cell(22, 7, $anno, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-1, "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, "DIFF %", "LTRB", 1, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(15, 47) ; $pdf->Cell(20, 8, "Gennaio", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Febbraio", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Marzo", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Aprile", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Maggio", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Giugno", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Luglio", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Agosto", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Settembre", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Ottobre", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Novembre", "LTRB", 1, 'L', 0) ; $pdf->Cell(20, 8, "Dicembre", "LTRB", 1, 'L', 0) ; $pdf->SetXY(37, 47) ; for($i=1; $i<=12; $i++) { $diffFatt = $NewArrVal[$i]['FatturatoAP'] - $NewArrVal[$i]['Fatturato'] ; if ($diffFatt != 0 and $NewArrVal[$i]['FatturatoAP'] != "0,00") $diffFattper = @nfeExt((($diffFatt / $NewArrVal[$i]['FatturatoAP']) * 100) * -1) ; else $diffFattper = @nfeExt(0) ; $diffBott = $NewArrVal[$i]['TotBottAP'] - $NewArrVal[$i]['TotBott'] ; if ($diffBott != 0 and $NewArrVal[$i]['TotBottAP'] != 0) $diffBottper = @nfeExt((($diffBott / $NewArrVal[$i]['TotBottAP']) * 100) * -1); else $diffBottper = @nfeExt(0) ; if($NewArrVal[$i]['TotBott'] > 0) $pm = $NewArrVal[$i]['Fatturato'] / $NewArrVal[$i]['TotBott'] ; else $pm = 0 ; $totPM += $pm ; if($NewArrVal[$i]['TotBottAP'] > 0) $pmAP = $NewArrVal[$i]['FatturatoAP'] / $NewArrVal[$i]['TotBottAP'] ; else $pmAP = 0 ; $totPMAP += $pmAP ; $diffPM = $pmAP - $pm ; if ($diffPM != 0 and $pm != 0) $diffPMper = @nfeExt((($diffPM / $pm) * 100) * -1) ; else $diffPMper = @nfeExt(0) ; if ($diffPM <= 0) $classPM = "piu" ; elseif ($diffPM > 0) { $classPM = "meno" ; if ($diffPMper == "0,00000") $diffPMper = "-100,00000" ; } else $classPM = "" ; $diffCli = $arrTotali[9] - $arrTotali[8] ; if ($diffCli != 0 and $arrTotali[9] != 0) $diffCliper = ((($diffCli / $arrTotali[9]) * 100) * -1) ; else $diffCliper = 0 ; if ($diffCli < 0) $classCli = "piu" ; elseif ($diffCli > 0) { $classCli = "meno" ; if ($diffCliper == "0,00000") $diffCliper = "100,00000" ; } else $classCli = "" ; $pdf->Cell(22, 8, nfp($NewArrVal[$i]['Fatturato']), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 8, nfp($NewArrVal[$i]['FatturatoAP']), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 8, $diffFattper . " %", "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 8, nfp($NewArrVal[$i]['Fatturato2AP']), "LTRB", 0, 'R', 0) ; $pdf->SetX(127) ; $pdf->Cell(22, 8, nfl($NewArrVal[$i]['TotBott']), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 8, nfl($NewArrVal[$i]['TotBottAP']), "LTRB", 0, 'R', 0) ; $pdf->Cell(26, 8, $diffBottper . " %", "LTRB", 0, 'R', 0) ; $pdf->SetX(199) ; $pdf->Cell(22, 8, nfp($pm), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 8, nfp($pmAP), "LTRB", 0, 'R', 0) ; $pdf->Cell(26, 8, $diffPMper . " %", "LTRB", 0, 'R', 0) ; $pdf->SetXY(37, 47 + ($i*8)) ; } $pdf->SetXY(15, 144) ; $pdf->SetFont('helvetica', '', 12); $pdf->Cell(20, 7, "TOTALI", "LTRB", 0, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->SetX(37) ; $pdf->Cell(22, 7, nfp($arrTotali[0]), "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, nfp($arrTotali[1]), "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, nfeExt($arrTotali[5]) . " %", "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, nfp($arrTotali[2]), "LTRB", 0, 'C', 0) ; $pdf->SetX(127) ; $pdf->Cell(22, 7, nfl($arrTotali[3]), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 7, nfl($arrTotali[4]), "LTRB", 0, 'R', 0) ; $pdf->Cell(26, 7, nfeExt($arrTotali[6]) . " %", "LTRB", 0, 'R', 0) ; $pdf->SetX(199) ; $pdf->Cell(22, 7, nfp($totPM / 12), "LTRB", 0, 'R', 0) ; $pdf->Cell(22, 7, nfp($totPMAP / 12), "LTRB", 0, 'R', 0) ; $pdf->Cell(26, 7, nfeExt($arrTotali[7]) . " %", "LTRB", 0, 'R', 0) ; $pdf->SetFont('helvetica', '', 12); $pdf->SetXY(37, 160) ; $pdf->Cell(70, 10, "CLIENTI SERVITI", "LTRB", 0, 'C', 0) ; $pdf->SetX(110) ; $pdf->Cell(70, 10, "FATTURATO PER CLIENTE", "LTRB", 1, 'C', 0) ; $pdf->SetX(37) ; $pdf->Cell(22, 7, $anno, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-1, "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, "DIFF %", "LTRB", 0, 'C', 0) ; $pdf->SetX(110) ; $pdf->Cell(22, 7, $anno, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $anno-1, "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, "DIFF %", "LTRB", 1, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->SetX(37) ; $pdf->Cell(22, 7, $arrTotali[8], "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, $arrTotali[9], "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, nfeExt($diffCliper) . " %", "LTRB", 0, 'C', 0) ; $pdf->SetX(110) ; $pdf->Cell(22, 7, nfp($arrTotali[10]), "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 7, nfp($arrTotali[11]), "LTRB", 0, 'C', 0) ; $pdf->Cell(26, 7, nfeExt($arrTotali[12]) . " %", "LTRB", 1, 'C', 0) ; */ $pdf->SetDisplayMode('real') ; //Close and output PDF document $fileName = Date("Y-m-d ") . "StoFatt.pdf" ; // $pdf->Output($fileName, 'D') ; $pdf->Output($fileName, 'I') ; ?>