RecuperaDati($query) ; return ($d['NoteOrdini'][0]) ; } } // create new PDF document $pdf = new MYPDF("P", 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'); //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(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); $arrIdOrd = explode(",", $lista_id) ; debug (0, "COUNT = " . count($arrIdOrd)) ; for ($aa = 0; $aa < count($arrIdOrd); $aa++) { $idOrdine = $arrIdOrd[$aa] ; debug (0, "PRIMA => IDORDINE = $idOrdine , AA = $aa") ; /******************************************************* * Devo modificare il valore del campo DaInviare della * tabella ordini segnalando questo ordine come * inviato (cioè il valore del campo = 0) ********************************************************/ debug (0, "update ordini set DaInviare = 0 where IdOrdini = $idOrdine and Anno = $anno") ; $db->query("update ordini set DaInviare = 0 where IdOrdini = $idOrdine and Anno = $anno") ; // recupero i dati dell'ordine $query = " select RFC.Codice, O.*, C.Nome as NomeCliente, 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.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, 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 = $anno, tipologie T where 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 O.IdOrdini = $idOrdine and O.Anno = $anno "; list($n, $d) = $db->RecuperaDati($query) ; $nomeCliente = $d['NomeCliente'][0] ; $arNA = explode(" ", $d['NomeAgente'][0]) ; $allaCasa = ' ' . PreparaStringaPerPDF($d["NomeFornitore"][0]) ; $inCasa = ' ' . PreparaStringaPerPDF($d['IndirizzoFornitori'][0]) . " " . $d['CapFornitori'][0] . " " . PreparaStringaPerPDF($d['CittaFornitori'][0]) . " (" . $d['ProvinciaFornitori'][0] . ")" ; $pdf->AddPage(); $pdf->SetXY(15, 5) ; $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0); $pdf->SetFont('helvetica', '', 9); $pdf->Cell(140, 3, ' ALLA CASA', "LTR", 0, 'L', 1) ; $pdf->Cell(40, 3, ' AGENTE', "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(140, 5, $allaCasa, "LR", 0, 'L', 1) ; $pdf->Cell(40, 5, ' ' . $arNA[0], "LBR", 1, 'L', 1) ; $pdf->Cell(140, 5, $inCasa, "LBR", 0, 'L', 1) ; $pdf->Cell(40, 5, ' ' . $arNA[1], "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); // $pdf->Cell(26, 3, ' AGENTE', "LTR", 0, 'L', 1) ; $pdf->Cell(25, 3, ' DATA ORDINE', "LTR", 0, 'L', 1) ; $pdf->Cell(20, 3, ' CODICE', "LTR", 0, 'L', 1) ; $pdf->Cell(135, 3, ' CLIENTE', "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); // $pdf->Cell(26, 0, ' Curcio Fabrizio', "LBR", 0, 'L', 1) ; $pdf->Cell(25, 0, ' ' . ItaDate($d['DataOrdine'][0]), "LBR", 0, 'L', 1) ; $pdf->Cell(20, 0, ' ' . $d['Codice'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(135, 0, ' ' . PreparaStringaPerPDF($d['NomeCliente'][0]), "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(90, 3, ' VIA', "LTR", 0, 'L', 1) ; $pdf->Cell(15, 3, ' CAP', "LTR", 0, 'L', 1) ; $pdf->Cell(55, 3, " LOCALITA'", "LTR", 0, 'L', 1) ; $pdf->Cell(20, 3, " PROVINCIA", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(90, 0, ' ' . PreparaStringaPerPDF($d['IndirizzoCliente'][0]), "LBR", 0, 'L', 1) ; $pdf->Cell(15, 0, ' ' . $d['CapCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(55, 0, ' ' . $d['CittaCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(20, 0, ' ' . $d['ProvinciaCliente'][0], "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(35, 3, ' PARTITA IVA', "LTR", 0, 'L', 1) ; $pdf->Cell(40, 3, " CODICE FISCALE", "LTR", 0, 'L', 1) ; // $pdf->Cell(45, 3, ' TIPO DI ESERCIZIO', "LTR", 0, 'L', 1) ; $pdf->Cell(105, 3, " EPOCA DI CONSEGNA", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(35, 0, ' ' . $d['PivaCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(40, 0, ' ' . $d['CodFiscCliente'][0], "LBR", 0, 'L', 1) ; // $pdf->Cell(45, 0, ' ' . $d['TipologiCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(105, 0, ' ' . $d['EpocaDiConsegna'][0], "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(35, 3, ' TELEFONO', "LTR", 0, 'L', 1) ; $pdf->Cell(35, 3, ' PAGAMENTO', "LTR", 0, 'L', 1) ; $pdf->Cell(40, 0, ' SCONTO PAGAMENTO', "LTR", 0, 'L', 1) ; $pdf->Cell(70, 3, " CHIUSURA", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(35, 0, ' ' . $d['TelefonoCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(35, 0, ' ' . $d['ModalitaPagamenti'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(40, 0, ' ' . nfp($d['Sconto3'][0]), "LBR", 0, 'L', 1) ; $pdf->Cell(70, 0, ' ' . PreparaStringaPerPDF($d['ChiusuraCliente'][0]), "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(180, 3, ' LUOGO DI CONSEGNA', "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(180, 0, ' ' . PreparaStringaPerPDF($d['IndirizzoConsegna'][0]), "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(180, 3, ' RIFERIMENTO', "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(180, 0, ' ' . PreparaStringaPerPDF($d['RiferimentoCliente'][0]), "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(180, 3, " BANCA D'APPOGGIO" , "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(180, 3, ' ' . PreparaStringaPerPDF($d['BancaCliente'][0]), "LBR", 1, 'L', 1) ; $pdf->SetFont('helvetica', '', 9); $pdf->Cell(18, 3, ' ABI', "LTR", 0, 'L', 1) ; $pdf->Cell(18, 3, ' CAB', "LTR", 0, 'L', 1) ; $pdf->Cell(40, 0, ' NUMERO DI CONTO', "LTR", 0, 'L', 1) ; $pdf->Cell(104, 3, " IBAN", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 10); $pdf->Cell(18, 0, ' ' . $d['AbiCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(18, 0, ' ' . $d['CabCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(40, 0, ' ' . $d['CcCliente'][0], "LBR", 0, 'L', 1) ; $pdf->Cell(104, 0, ' ' . $d['CodIban'][0], "LBR", 1, 'L', 1) ; /* $this->SetFont('helvetica', '', 5); $pdf->Cell(180, 3, " N O T E", "LTR", 1, 'L', 1) ; $pdf->SetFont('helvetica', 'B', 8); $pdf->Cell(180, 3, ' ' . PreparaStringaPerPDF($d['NoteOrdini'][0]), "LBR", 1, 'L', 1) ; */ $pdf->Ln() ; $pdf->SetFont('helvetica', '', 8); $pdf->SetLineWidth(0.4); $pdf->Cell(14, 8, "Codice", "LTRB", 0, 'C', 0) ; $pdf->Cell(107, 8, "Descrizione Merce", "LTRB", 0, 'C', 0) ; $pdf->Cell(15, 8, "Num. Bott.", "LTRB", 0, 'C', 0) ; $pdf->Cell(25, 8, "Prezzo", "LTRB", 0, 'C', 0) ; $pdf->Cell(22, 8, "Sconto Prodotto", "LTRB", 1, 'C', 0) ; $pdf->Ln() ; $noteOrdine = $pdf->NoteOrdine($idOrdine, $anno) ; $pdf->setFont('helvetica', 'B', 10); // $pdf->AddPage(); $pdf->SetLineWidth(0.1); $dbtmp = new FC_SQL ; $qdett = " select * from dettagli D, prodotti P where D.IdOrdine = $idOrdine and D.Anno = $anno 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++) { $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) $prezzoListino = nfe($prezzoDaUsare) . " (+ acc e ta)" ; else $prezzoListino = nfe($prezzoDaUsare) ; if ($d["ScontoPrd"][$i] != "") $scontoProdotto = $d["ScontoPrd"][$i] . "%" ; else $scontoProdotto = "" ; $pdf->SetFont('helvetica', '', 8); $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 SM.IdOrdine = $idOrdine and SM.Anno = $anno and SM.IdProdotto = P.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', '', 9); $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ù parole */ $lunNote = strlen($noteOrdine) ; $ciclo = true ; $i = 0 ; $piuRighe = false ; if ($lunNote > 100) { $piuRighe = true ; $out = substr($noteOrdine, 0, 100) ; while ($ciclo) { $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 ($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->Ln() ; $pdf->SetFont('helvetica', '', 10); $pdf->Cell(14, 5, "Cordiali Saluti", "", 1, 'L', 0) ; $pdf->Cell(80, 8, "Dali snc", "", 1, 'L', 0) ; $pdf->SetDisplayMode('real') ; debug (0, "DOPO => IDORDINE = $idOrdine , AA = $aa") ; } //Close and output PDF document $fileName = Date("Y-m-d ") . $nomeCliente . ".pdf" ; // Per NON aprire subito // $pdf->Output($fileName, 'D') ; // Aprire subito $pdf->Output($fileName, 'I') ; ?>