RecuperaDati($query) ; $nomeCliente = PreparaStringaPerPDF($d['NomeCliente'][0]) ; $nomeCasa = PreparaStringaPerPDF($d['NomeCasa'][0]) ; if ($agente != "" and $agente != 'tutti') $nomeAgente = PreparaStringaPerPDF($d['NomeAgente'][0]) ; for ($i=0; $i<$n; $i++) { $idProdotto = $d['IdProdotto'][$i] ; $idOrdine = $d['IdOrdini'][$i] ; $NumBott = $d['NumBott'][$i] + $d['NumBottSM'][$i] ; if (! in_array($idOrdine, $arrOrdini)) { $arrOrdini[] = $idOrdine ; $arrDate[] = ItaDate($d['DataOrdine'][$i]) ; $arrAvo[] = $d['AmmontareOrdineSenzaIva'][$i] ; } if (! array_key_exists($idProdotto, $arrVal)) $arrVal[$idProdotto] = array('NomeProdotto' => $d['NomeProdotto'][$i], 'Ordini' => array($idOrdine => array('NumBott' => $NumBott, 'Data' => ItaDate($d['DataOrdine'][$i]), ) ), 'TotBott' => $NumBott ) ; else { $arrVal[$idProdotto]['TotBott'] += $NumBott ; if (! array_key_exists($idOrdine, $arrVal[$idProdotto]['Ordini'])) $arrVal[$idProdotto]['Ordini'][$idOrdine] = array('NumBott' => $NumBott, 'Data' => ItaDate($d['DataOrdine'][$i])) ; else $arrVal[$idProdotto]['Ordini'][$idOrdine]['NumBott'] += $NumBott ; } } global $noteOrdini ; class MYPDF extends TCPDF { //Page header public function Header() { global $id ; global $annoInEsame ; global $nomeCasa ; global $nomeCliente ; global $nomeAgente ; global $arrVal ; global $arrOrdini ; global $arrDate ; global $totOrdiniVis ; $db = new FC_SQL ; $this->SetFillColor(255, 255, 255); $this->SetTextColor(0); $this->SetFont('helvetica', '', 6); $this->Cell(90, 3, ' AZIENDA', "LTR", 0, 'L', 1) ; $this->Cell(90, 3, ' CLIENTE', "LTR", 0, 'L', 1) ; $this->Cell(90, 3, ' AGENTE', "LTR", 1, 'L', 1) ; $this->SetFont('helvetica', '', 10); $this->Cell(90, 5, $nomeCasa, "LBR", 0, 'L', 1) ; $this->Cell(90, 5, $nomeCliente, "LBR", 0, 'L', 1) ; $this->Cell(90, 5, $nomeAgente, "LBR", 1, 'L', 1) ; $this->Ln() ; $this->SetFont('helvetica', '', 7); // $this->SetLineWidth(0.4); $this->Cell(70, 6, "Prodotto", "LTRB", 0, 'C', 0) ; $this->Cell(20, 6, "Totale Bott.", "LTRB", 0, 'C', 0) ; $this->Cell(180, 6, "Data Ordine (num. bottiglie)", "LTRB", 1, 'C', 0) ; } // 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); // $noteOrdine = $pdf->NoteOrdine() ; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Fabrizio Curcio'); $pdf->SetTitle('Report Cliente'); $pdf->SetSubject('Report Cliente'); $pdf->SetKeywords('PDF'); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP-1, 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); $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0); $pdf->SetFont('helvetica', '', 7); foreach($arrVal as $idProdotto => $arrSingProd) { $totDate = 1 ; $riga = 1 ; $cnt = count($arrSingProd['Ordini']) ; $nrighe = ceil($cnt / 9) ; if ($nrighe == 1) $pdf->Cell(70, 6, PreparaStringaPerPDF($arrSingProd['NomeProdotto']), "LTRB", 0, 'L', 0) ; else $pdf->Cell(70, 6, PreparaStringaPerPDF($arrSingProd['NomeProdotto']), "LTR", 0, 'L', 0) ; $pdf->Cell(20, 6, $arrSingProd['TotBott'], "LTRB", 0, 'L', 0) ; foreach($arrSingProd['Ordini'] as $idPrd => $arrOrd) { if ($totDate == 10) { $riga ++ ; $pdf->Ln() ; $totDate = 1 ; if (($nrighe > 1) && ($riga == $nrighe)) { $pdf->Cell(90, 6, "", "LB", 0, 'L', 0) ; } else { $pdf->Cell(90, 6, "", "L", 0, 'L', 0) ; } $pdf->Cell(20, 6, $arrOrd['Data'] . " (" . $arrOrd['NumBott'] . ")", "LTRB", 0, 'L', 0) ; $totDate = 2 ; } else { $pdf->Cell(20, 6, $arrOrd['Data'] . " (" . $arrOrd['NumBott'] . ")", "LTRB", 0, 'L', 0) ; $totDate ++ ; } } $pdf->Ln() ; $pdf->Ln() ; } $granTotal = 0 ; $pdf->Cell(90, 6, "TOTALI EURO", "LTRB", 0, 'R', 0) ; for ($i=0; $iCell(16, 6, nfe($arrAvo[$i]), "LTRB", 0, 'C', 0) ; } if (count($arrAvo) < $totOrdiniVis) { for ($i=count($arrAvo); $i<$totOrdiniVis; $i++) $pdf->Cell(16, 6, "", "LTRB", 0, 'C', 0) ; } $pdf->Cell(20, 6, nfe($granTotal), "LTRB", 0, 'C', 0) ; $pdf->SetDisplayMode('real') ; //Close and output PDF document $pdf->Output('ReportCliente.pdf', 'I') ; ?>