RecuperaDati($query) ; return ($d['NoteOrdini'][0]) ; } //Page header public function Header() { global $id ; global $annoInEsame ; global $nomeCliente ; global $nomeClientePdf ; $db = new FC_SQL ; $query = " select RFC.Codice, O.*, C.Nome as NomeCliente, C.NomePdf as NomeClientePdf, C.indirizzo as IndirizzoCliente, C.cap as CapCliente, C.citta as CittaCliente, C.provincia as ProvinciaCliente, T.Descrizione as TipologiCliente, C.telefono as TelefonoCliente, C.Fax as FaxCliente, C.piva as PivaCliente, C.codfisc as CodFiscCliente, C.note as ChiusuraCliente, C.banca as BancaCliente, C.Abi as AbiCliente, C.cab as CabCliente, C.cc as CcCliente, C.CodIban , C.Riferimento as RiferimentoCliente, C.consegna as IndirizzoConsegna, C.Email as Mail, C.Pec as Pec, F.Nome as NomeFornitore, F.Indirizzo as IndirizzoFornitori, F.Cap as CapFornitori, F.citta as CittaFornitori, F.provincia as ProvinciaFornitori, P.modalita as ModalitaPagamenti, A.Nome as NomeAgente from (ordini O, pagamenti P, clienti C, fornitori F, Agenti A) left join relfornitoriclienti RFC on RFC.IdFornitore = F.IdFornitori and RFC.IdCliente = C.IdClienti and RFC.Anno = $annoInEsame, tipologie T where O.Anno = $annoInEsame and O.IdCliente = C.IdClienti and O.IdFornitore = F.IdFornitori and O.IdPagamento = P.IdPagamenti and O.IdAgente = A.IdAgenti and T.IdTipologie = C.IdTipologia and IdOrdini = $id "; debug (0, $query) ; list($n, $d) = $db->RecuperaDati($query) ; $nomeCliente = $d['NomeCliente'][0] ; $arNA = explode(" ", $d['NomeAgente'][0]) ; if ($d['NomeClientePdf'][0] != "") $nomeClientePdf = $d['NomeClientePdf'][0] ; else $nomeClientePdf = $nomeCliente ; if ($d['Pec'][0] != "") $MailPec = $d['Pec'][0] ; else $MailPec = $d['Mail'][0] ; $allaCasa = ' ' . PreparaStringaPerPDF($d["NomeFornitore"][0]) ; $inCasa = ' ' . PreparaStringaPerPDF($d['IndirizzoFornitori'][0]) . " " . $d['CapFornitori'][0] . " " . PreparaStringaPerPDF($d['CittaFornitori'][0]) . " (" . $d['ProvinciaFornitori'][0] . ")" ; $this->SetFillColor(255, 255, 255); $this->SetTextColor(0); $this->SetFont('helvetica', '', 9); $this->Cell(140, 3, ' ALLA CASA', "LTR", 0, 'L', 1) ; $this->Cell(40, 3, ' AGENTE', "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(140, 5, $allaCasa, "LR", 0, 'L', 1) ; $this->Cell(40, 5, ' ' . $arNA[0], "LBR", 1, 'L', 1) ; $this->Cell(140, 5, $inCasa, "LBR", 0, 'L', 1) ; $this->Cell(40, 5, ' ' . $arNA[1], "LBR", 1, 'L', 1) ; // $this->Ln() ; $this->SetFont('helvetica', '', 9); // $this->Cell(26, 3, ' AGENTE', "LTR", 0, 'L', 1) ; $this->Cell(25, 3, ' DATA ORDINE', "LTR", 0, 'L', 1) ; $this->Cell(20, 3, ' CODICE', "LTR", 0, 'L', 1) ; $this->Cell(135, 3, ' CLIENTE', "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); // $this->Cell(26, 0, ' Curcio Fabrizio', "LBR", 0, 'L', 1) ; $this->Cell(25, 0, ' ' . ItaDate($d['DataOrdine'][0]), "LBR", 0, 'L', 1) ; $this->Cell(20, 0, ' ' . $d['Codice'][0], "LBR", 0, 'L', 1) ; $this->Cell(135, 0, ' ' . PreparaStringaPerPDF($d['NomeCliente'][0]), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(90, 3, ' VIA', "LTR", 0, 'L', 1) ; $this->Cell(15, 3, ' CAP', "LTR", 0, 'L', 1) ; $this->Cell(55, 3, " LOCALITA'", "LTR", 0, 'L', 1) ; $this->Cell(20, 3, " PROVINCIA", "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(90, 0, ' ' . PreparaStringaPerPDF($d['IndirizzoCliente'][0]), "LBR", 0, 'L', 1) ; $this->Cell(15, 0, ' ' . $d['CapCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(55, 0, ' ' . $d['CittaCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(20, 0, ' ' . $d['ProvinciaCliente'][0], "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(35, 3, ' PARTITA IVA', "LTR", 0, 'L', 1) ; $this->Cell(40, 3, " CODICE FISCALE", "LTR", 0, 'L', 1) ; // $this->Cell(45, 3, ' TIPO DI ESERCIZIO', "LTR", 0, 'L', 1) ; // $this->Cell(105, 3, " EPOCA DI CONSEGNA", "LTR", 1, 'L', 1) ; $this->Cell(105, 3, " PEC / CODICE SDI", "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(35, 0, ' ' . $d['PivaCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(40, 0, ' ' . $d['CodFiscCliente'][0], "LBR", 0, 'L', 1) ; // $this->Cell(45, 0, ' ' . $d['TipologiCliente'][0], "LBR", 0, 'L', 1) ; // $this->Cell(105, 0, ' ' . $d['EpocaDiConsegna'][0], "LBR", 1, 'L', 1) ; $this->Cell(105, 0, ' ' . PreparaStringaPerPDF($MailPec), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(35, 3, ' TELEFONO', "LTR", 0, 'L', 1) ; $this->Cell(35, 3, ' FAX', "LTR", 0, 'L', 1) ; $this->Cell(30, 3, ' PAGAMENTO', "LTR", 0, 'L', 1) ; $this->Cell(40, 0, ' SCONTO PAGAMENTO', "LTR", 0, 'L', 1) ; $this->Cell(40, 3, " CHIUSURA", "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(35, 0, ' ' . $d['TelefonoCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(35, 0, ' ' . $d['FaxCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(30, 0, ' ' . $d['ModalitaPagamenti'][0], "LBR", 0, 'L', 1) ; $this->Cell(40, 0, ' ' . nfp($d['Sconto3'][0]), "LBR", 0, 'L', 1) ; $this->Cell(40, 0, ' ' . PreparaStringaPerPDF($d['ChiusuraCliente'][0]), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(180, 3, ' LUOGO DI CONSEGNA', "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(180, 0, ' ' . PreparaStringaPerPDF($d['IndirizzoConsegna'][0]), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(180, 3, ' RIFERIMENTO', "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(180, 0, ' ' . PreparaStringaPerPDF($d['RiferimentoCliente'][0]), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(180, 3, " BANCA D'APPOGGIO" , "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(180, 3, ' ' . PreparaStringaPerPDF($d['BancaCliente'][0]), "LBR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 9); $this->Cell(18, 3, ' ABI', "LTR", 0, 'L', 1) ; $this->Cell(18, 3, ' CAB', "LTR", 0, 'L', 1) ; $this->Cell(40, 0, ' NUMERO DI CONTO', "LTR", 0, 'L', 1) ; $this->Cell(104, 3, " IBAN", "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 10); $this->Cell(18, 0, ' ' . $d['AbiCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(18, 0, ' ' . $d['CabCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(40, 0, ' ' . $d['CcCliente'][0], "LBR", 0, 'L', 1) ; $this->Cell(104, 0, ' ' . $d['CodIban'][0], "LBR", 1, 'L', 1) ; /* $this->SetFont('helvetica', '', 5); $this->Cell(180, 3, " N O T E", "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', 'B', 8); $this->Cell(180, 3, ' ' . PreparaStringaPerPDF($d['NoteOrdini'][0]), "LBR", 1, 'L', 1) ; */ $this->Ln() ; $this->SetFont('helvetica', '', 8); $this->SetLineWidth(0.4); $this->Cell(14, 8, "Codice", "LTRB", 0, 'C', 0) ; $this->Cell(107, 8, "Descrizione Merce", "LTRB", 0, 'C', 0) ; $this->Cell(15, 8, "Num. Bott.", "LTRB", 0, 'C', 0) ; $this->Cell(25, 8, "Prezzo", "LTRB", 0, 'C', 0) ; $this->Cell(22, 8, "Sconto Prodotto", "LTRB", 1, 'C', 0) ; $this->Ln() ; } // 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); $noteOrdine = $pdf->NoteOrdine() ; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Fabrizio Curcio'); $pdf->SetTitle('Copia Commissione'); $pdf->SetSubject('Copia Commissione'); $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(); $pdf->SetLineWidth(0.1); $dbtmp = new FC_SQL ; $qdett = " select * from dettagli D, prodotti P where P.Anno = $annoInEsame and D.Anno = $annoInEsame and D.IdOrdine = $id and D.IdProdotto = P.IdProdotti order by P.nome " ; list($n, $d) = $dbtmp->RecuperaDati($qdett) ; $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0); $pdf->SetXY(15, 100) ; for ($i=0; $i<$n; $i++) { if ($i == 21) { $pdf->AddPage() ; $pdf->SetY(100) ; } $prezzoForzato = $d['PrezzoForzato'][$i] ; if ($prezzoForzato != '' && $prezzoForzato != '0.00') $prezzoDaUsare = $prezzoForzato ; else $prezzoDaUsare = $d["PrezzoUnitario"][$i] ; $numBott = $d['NumCartoni'][$i] * $d['ConfezioniDa'][$i] ; if ($d["Accisa"][$i] > 0) { $pr = $prezzoDaUsare - $d["Accisa"][$i] ; $prezzoListino = nfe($pr) ; // $prezzoListino = nfe($prezzoDaUsare) . " (+ acc e ta)" ; } else $prezzoListino = nfe($prezzoDaUsare) ; if ($d["ScontoPrd"][$i] != "") $scontoProdotto = $d["ScontoPrd"][$i] . "%" ; else $scontoProdotto = "" ; $pdf->SetFont('helvetica', '', 6); $pdf->Cell(14, 8, $d['CodiceProdotto'][$i], "LTRB", 0, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->Cell(107, 8, PreparaStringaPerPDF($d['Nome'][$i]) . " " . $d['Annata'][$i], "LTRB", 0, 'L', 0) ; $pdf->Cell(15, 8, $numBott, "LTRB", 0, 'C', 0) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(25, 8, $prezzoListino, "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 8, $scontoProdotto, "LTRB", 1, 'C', 0) ; } /********************************************** * controllo se ci sono prodotti in sconto merce **********************************************/ $dbmerce = new FC_SQL ; $qmerce = " select * from scontomerce SM, prodotti P where P.Anno = $annoInEsame and SM.Anno = $annoInEsame and SM.IdOrdine = $id and SM.IdProdotto = IdProdotti order by P.nome " ; list($n, $d) = $dbtmp->RecuperaDati($qmerce) ; for ($i=0; $i<$n; $i++) { $numBott = $d['NumCartoni'][$i] * $d['ConfezioniDa'][$i] ; $pdf->SetFont('helvetica', '', 6); $pdf->Cell(14, 8, $d['CodiceProdotto'][$i], "LTRB", 0, 'C', 0) ; $pdf->SetFont('helvetica', '', 10); $pdf->Cell(107, 8, PreparaStringaPerPDF($d['Nome'][$i]) . " " . $d['Annata'][$i], "LTRB", 0, 'L', 0) ; $pdf->Cell(15, 8, $numBott, "LTRB", 0, 'C', 0) ; $pdf->SetFont('helvetica', 'I', 10); $pdf->Cell(47, 8, "Sconto Merce", "LTRB", 1, 'C', 0) ; } $pdf->Ln() ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(183, 3, " N O T E", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); /* controllo la lunghezza delle note per sapere se spezzarle in pių righe (fino a tre) */ $lunNote = strlen($noteOrdine) ; $ciclo = true ; $i = 0 ; $piuRighe = false ; $piu2Righe = false ; if ($lunNote > 180) { $piu2Righe = true ; $out = substr($noteOrdine, 0, 100) ; while ($ciclo) { if (strlen($out) >= $lunNote) { $ciclo = false ; break ; } $x = substr($noteOrdine, 100 + $i, 1) ; if ( $x <> ' ') { $out .= $x ; $i++ ; } else { $ciclo = false ; $out2 = substr($noteOrdine, 101 + $i, 96) ; $out3 = substr($noteOrdine, 197 + $i, strlen($noteOrdine)) ; debug (0, "$out2 -- $out3") ; } } } else { if ($lunNote > 100) { $piuRighe = true ; $out = substr($noteOrdine, 0, 100) ; while ($ciclo) { if (strlen($out) >= $lunNote) { $ciclo = false ; break ; } $x = substr($noteOrdine, 100 + $i, 1) ; if ( $x <> ' ') { $out .= $x ; $i++ ; } else { $ciclo = false ; $out2 = substr($noteOrdine, 101 + $i, strlen($noteOrdine)) ; } } } } // $pdf->SetXY(181, 3) ; if ($piu2Righe) { $pdf->Cell(183, 3, '' . PreparaStringaPerPDF($out), "LR", 1, 'L', 1) ; $pdf->Cell(183, 3, '' . PreparaStringaPerPDF($out2), "LB", 1, 'L', 1) ; $pdf->Cell(183, 3, '' . PreparaStringaPerPDF($out3), "LBR", 1, 'L', 1) ; } elseif ($piuRighe) { $pdf->Cell(183, 3, '' . PreparaStringaPerPDF($out), "LR", 1, 'L', 1) ; $pdf->Cell(183, 3, '' . PreparaStringaPerPDF($out2), "LBR", 1, 'L', 1) ; } else { $pdf->Cell(183, 3, ' ' . PreparaStringaPerPDF($noteOrdine), "LBR", 1, 'L', 1) ; } $pdf->Ln() ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(14, 5, "Assolve gli obblighi di cui all'articolo 62, comma 1, del decreto legge 24 gennaio 2012, n. 1, convertito, con modificazioni,", "", 1, 'L', 0) ; $pdf->Cell(14, 5, "dalla legge 24 marzo 2012, n. 27", "", 1, 'L', 0) ; // $pdf->Ln() ; $pdf->Ln() ; $pdf->SetFont('helvetica', '', 10); $pdf->Cell(14, 5, "Cordiali Saluti", "", 1, 'L', 0) ; $pdf->Cell(80, 8, "Dalė snc", "", 1, 'L', 0) ; $pdf->SetDisplayMode('real') ; //Close and output PDF document $fileName = Date("Y-m-d ") . $nomeClientePdf . ".pdf" ; $pdf->Output($fileName, 'D') ; // $pdf->Output($fileName, 'I') ; ?>