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(200, 10, " Ordini con provvigioni " . $str . " all'Agente: $nomeAgente", "", 1, 'C', 1) ; // $this->Ln() ; $this->SetFont('helvetica', '', 8); $this->Cell(10, 6, "Ord. N.", "LBTR", 0, 'C', 1) ; $this->Cell(75, 6, "Cliente", "LBTR", 0, 'C', 1) ; $this->Cell(75, 6, "Azienda", "LBTR", 0, 'C', 1) ; $this->Cell(20, 6, "Num. Fattura", "LBTR", 0, 'C', 1) ; $this->Cell(20, 6, "Saldo Fattura", "LBTR", 0, 'C', 1) ; $this->Cell(15, 6, "Importo", "LBTR", 0, 'C', 1) ; $this->Cell(15, 6, "% Provv.", "LBTR", 0, 'C', 1) ; $this->Cell(15, 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("L", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Fabrizio Curcio'); $pdf->SetTitle('Copia Commissione'); $pdf->SetSubject('Copia Commissione'); $pdf->SetKeywords('PDF'); // $pdf->SetPageFormat('', 'L') ; //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 *, AFP.percentuale as PercentualeAgente, A.Percentuale as PercentualeDefault, C.Nome as NomeCliente, F.Nome as NomeFornitore from ordini O inner join clienti C on C.IdClienti = O.IdCliente inner join fornitori F on F.IdFornitori = O.IdFornitore inner join pagamenti P on P.IdPagamenti = O.IdPagamento left join ageforper AFP on AFP.IdAgente = O.IdAgente and AFP.IdFornitore = O.IdFornitore inner join agenti A on A.IdAgenti = O.IdAgente inner join AmmontareVariOrdini AVO on AVO.IdOrdine = O.IdOrdini and AVO.Anno = $anno where O.Anno = $anno and O.NumFattura <> 0 and O.SaldoProvvigioneAgente = 0 and O.DataSpedFattura >= '$datadal' and O.DataSpedFattura <= '$dataal' and O.idagente = $agente order by O.IdOrdini " ; } else { $query = " select *, AFP.percentuale as PercentualeAgente, A.Percentuale as PercentualeDefault, C.Nome as NomeCliente, F.Nome as NomeFornitore from ordini O inner join clienti C on C.IdClienti = O.IdCliente inner join fornitori F on F.IdFornitori = O.IdFornitore inner join pagamenti P on P.IdPagamenti = O.IdPagamento inner join ageforper AFP on AFP.IdAgente = O.IdAgente and AFP.IdFornitore = O.IdFornitore inner join agenti A on A.IdAgenti = O.IdAgente inner join AmmontareVariOrdini AVO on AVO.IdOrdine = O.IdOrdini and AVO.Anno = $anno where O.Anno = $anno and O.NumFattura <> 0 and O.SaldoProvvigioneAgente = 1 and O.DataSpedFattura >= '$datadal' and O.DataSpedFattura <= '$dataal' and O.idagente = $agente order by O.IdOrdini " ; } debug (0, $query) ; list($n, $d) = $db->RecuperaDati($query) ; // print_r($d) ; for ($i=0; $i<$n; $i++) { if (isset($fatt_sald) and ($fatt_sald != 'tutti') and ($fatt_sald != $d['SaldoFattura'][$i])) continue ; if (isset($fatt_ag_sald) and ($fatt_ag_sald != 'tutti') and ($fatt_ag_sald != $d['SaldoProvvigione'][$i])) continue ; $tot_sel ++ ; $idordine = $d['IdOrdini'][$i] ; $numfattura = $d['NumFattura'][$i] ; if ($d['PercentualeAgente'][$i] != 0) $per = $d['PercentualeAgente'][$i] ; else $per = $d['PercentualeDefault'][$i] ; $totord = $d['BaseProvvigionale'][$i] ; $totprovord = $d['AmmontareProvvAgente'][$i] ; $totale += $totord ; $totaleprov += $totprovord ; $pdf->SetFont('helvetica', '', 7); $pdf->Cell(10, 8, $d['IdOrdini'][$i], "LTRB", 0, 'C', 0) ; $pdf->Cell(75, 8, " " . PreparaStringaPerPDF($d['NomeCliente'][$i]), "LTRB", 0, 'L', 0) ; $pdf->Cell(75, 8, " " . PreparaStringaPerPDF($d['NomeFornitore'][$i]), "LTRB", 0, 'L', 0) ; $pdf->Cell(20, 8, $d['NumFattura'][$i], "LTRB", 0, 'C', 0) ; $pdf->Cell(20, 8, SiNo($d['SaldoFattura'][$i]), "LTRB", 0, 'C', 0) ; $pdf->Cell(15, 8, nfe($totord). " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(15, 8, nfp($per), "LTRB", 0, 'C', 0) ; $pdf->Cell(15, 8, nfe($totprovord) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(20, 8, SiNo($d['SaldoProvvigione'][$i]), "LTRB", 1, 'C', 0) ; } $pdf->Cell(200, 8, "Totale: ", "LTRB", 0, 'R', 0) ; $pdf->Cell(20, 8, nfe($totale) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(20, 8, " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(15, 8, nfe($totaleprov) . " ", "LTRB", 0, 'R', 0) ; $pdf->Cell(50, 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') ; ?>