SetFillColor(255, 255, 255); $this->SetTextColor(0); $this->SetFont('helvetica', '', 8); $this->Cell(25, 10, "Data: " . Date("d/m/Y"), "", 0, 'L', 1) ; $this->SetFont('helvetica', '', 10); $this->Cell(150, 10, " Ordini con provvigioni " . $str . " per il fornitore: " . stripslashes($nomeFornitore), "", 1, 'C', 1) ; // $this->Ln() ; $this->SetFont('helvetica', '', 8); $this->Cell(70, 6, "Cliente", "LBTR", 0, 'C', 1) ; $this->Cell(15, 6, "Num. Fatt", "LBTR", 0, 'C', 1) ; $this->Cell(20, 6, "Data Fattura", "LBTR", 0, 'C', 1) ; $this->Cell(20, 6, "Saldo Fattura", "LBTR", 0, 'C', 1) ; $this->Cell(17, 6, "Imp. Fattura", "LBTR", 0, 'C', 1) ; $this->Cell(17, 6, "Imp. Provv", "LBTR", 0, 'C', 1) ; $this->Cell(20, 6, "Sal. Prov. Age.", "LBTR", 1, 'C', 1) ; } // Page footer public function Footer() { // Position at 15 mm from bottom $this->SetY(-15); // Set font $this->SetFont('helvetica', 'I', 8); // Page number $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF("P", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); debug (0, "C") ; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Fabrizio Curcio'); $pdf->SetTitle('Copia Commissione'); $pdf->SetSubject('Copia Commissione'); $pdf->SetKeywords('PDF'); //set margins // originale $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP + 60, PDF_MARGIN_RIGHT); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP + 5, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); $pdf->AddPage(); $pdf->SetLineWidth(0.1); if ($dal == "") { $datadal = MySqlDate("01/01/$anno") ; $dataal = MySqlDate("31/12/$anno") ; } else { $datadal = MySqlDate($dal) ; $dataal = MySqlDate($al) ; } $dbt = new FC_SQL ; if ($tipo == "nonpagate") { $query = " select distinct *, F.provvigione as ProvvigioneAgenzia, C.Nome as NomeCliente, F.Nome as NomeFornitore from ordini O, pagamenti P, clienti C, fornitori F where O.Anno = $anno and O.NumFattura <> 0 and SaldoProvvigione = 0 and O.DataSpedFattura >= '$datadal' and O.DataSpedFattura <= '$dataal' and O.idfornitore = $fornitore and O.IdCliente = C.IdClienti and O.IdFornitore = F.IdFornitori and O.IdPagamento = P.IdPagamenti order by O.DataSpedFattura, O.NumFattura " ; /* $query = " select *, $tfornitori.provvigione as ProvvigioneAgenzia, $tclienti.Nome as NomeCliente, $tfornitori.Nome as NomeFornitore from $tordini, $tpagamenti, $tclienti, $tfornitori where $tordini.NumFattura <> 0 and SaldoProvvigione = 0 and $tordini.DataSpedFattura >= '$datadal' and $tordini.DataSpedFattura <= '$dataal' and $tordini.idfornitore = $fornitore and $tordini.IdCliente = $tclienti.IdClienti and $tordini.IdFornitore = $tfornitori.IdFornitori and $tordini.IdPagamento = $tpagamenti.IdPagamenti order by NumFattura " ; */ } else { $query = " select *, $tfornitori.provvigione as ProvvigioneAgenzia, $tclienti.Nome as NomeCliente, $tfornitori.Nome as NomeFornitore from $tordini, $tpagamenti, $tclienti, $tfornitori where $tordini.NumFattura <> 0 and SaldoProvvigione = 1 and $tordini.DataSpedFattura >= '$datadal' and $tordini.DataSpedFattura <= '$dataal' and $tordini.idfornitore = $fornitore and $tordini.IdCliente = $tclienti.IdClienti and $tordini.IdFornitore = $tfornitori.IdFornitori and $tordini.IdPagamento = $tpagamenti.IdPagamenti order by NumFattura" ; } list($n, $d) = $db->RecuperaDati($query) ; for ($i=0; $i<$n; $i++) { $annoOrdine = $d['Anno'][$i] ; $idordine = $d['IdOrdini'][$i] ; $numfattura = $d['NumFattura'][$i] ; $importoNC = $d['ImportoNC'][$i] ; if ($importoNC > 0) $valNC = ($importoNC / 1.2) ; else $valNC = 0 ; if ($fornitore == $idsarzi) $dbt->query("select * from $tdettagli, $tsarzi where $tdettagli.idordine = $idordine and $tdettagli.idprodotto = CONCAT('SA',idprodotti)") ; else $dbt->query("select * from dettagli D, prodotti P where P.Anno = $annoOrdine and D.Anno = $annoOrdine and D.idordine = $idordine and P.idprodotti = D.idprodotto") ; $importo = 0 ; while ($dbt->next_record()) { $impparz = $dbt->f("NumCartoni") * $dbt->f("ConfezioniDa") * $dbt->f("PrezzoUnitario") ; if ($dbt->f("ScontoPrd") != "" ) $impparz = CalcolaScontoProdotto($impparz, $dbt->f("ScontoPrd")) ; $importo += $impparz ; } $sconto1 = ($importo * $d['Sconto1'][$i] / 100) ; $subimporto1 = $importo - $sconto1 ; $sconto2 = ($subimporto1 * $d['Sconto2'][$i] / 100) ; $sconti = $sconto1 + $sconto2 ; $importo = $importo - $sconti - $valNC; $importoprov = ($importo * $d['ProvvigioneAgenzia'][$i] / 100) ; $totale += $importo ; $totaleprov += $importoprov ; $pdf->SetFont('helvetica', '', 8); $pdf->Cell(70, 8, " " . PreparaStringaPerPDF($d['NomeCliente'][$i]), "LTRB", 0, 'L', 0) ; $pdf->Cell(15, 8, $d['NumFattura'][$i], "LTRB", 0, 'C', 0) ; $pdf->Cell(20, 8, ItaDate($d['DataSpedFattura'][$i]), "LTRB", 0, 'C', 0) ; $pdf->Cell(20, 8, SiNo($d['SaldoFattura'][$i]), "LTRB", 0, 'C', 0) ; $pdf->Cell(17, 8, nfe($importo). " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(17, 8, nfe($importoprov) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(20, 8, SiNo($d['SaldoProvvigione'][$i]), "LTRB", 1, 'C', 0) ; } $pdf->Cell(125, 8, "Totale: ", "LTRB", 0, 'R', 0) ; $pdf->Cell(17, 8, nfe($totale) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(17, 8, nfe($totaleprov) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(20, 8, " ", "LTRB", 0, 'R', 0) ; $pdf->SetDisplayMode('real') ; //Close and output PDF document // Per la Dali deve essere: // $pdf->Output('Ordine.pdf', 'I') ; // PER TEST: $fileName = Date("Y-m-d ") . $nomeCliente . ".pdf" ; $pdf->Output($fileName, 'D') ; ?>