SetFillColor(255, 0, 0); $this->SetTextColor(255); $this->SetDrawColor(128, 0, 0); $this->SetLineWidth(0.3); $this->SetFont('', 'B'); // Header $w = array(12, 16, 16, 25, 60, 60, 10, 15, 13, 18, 22); $num_headers = count($header); for($i = 0; $i < $num_headers; ++$i) { $this->Cell($w[$i], 6, $header[$i], 1, 0, 'C', 1); } $this->Ln(); // Color and font restoration $this->SetFillColor(224, 235, 255); $this->SetTextColor(0); $this->SetFont(''); // Data $fill = 0; $line = 0 ; foreach($data as $row) { $line ++ ; $this->SetFillColor(224, 235, 255); $this->SetTextColor(0); $this->SetFont('','', 7) ; $this->Cell($w[0], 5, $row[0], 'LR', 0, 'R', $fill); $this->Cell($w[1], 5, $row[1], 'LR', 0, 'C', $fill); $this->Cell($w[2], 5, $row[2], 'LR', 0, 'C', $fill); $this->Cell($w[3], 5, $row[3], 'LR', 0, 'L', $fill); $this->Cell($w[4], 5, $row[4], 'LR', 0, 'L', $fill); $this->Cell($w[5], 5, $row[5], 'LR', 0, 'L', $fill); $this->Cell($w[6], 5, $row[6], 'LR', 0, 'R', $fill); $this->Cell($w[7], 5, $row[7], 'LR', 0, 'C', $fill); $this->Cell($w[8], 5, $row[8], 'LR', 0, 'R', $fill); $this->Cell($w[9], 5, $row[9], 'LR', 0, 'C', $fill); $this->Cell($w[10], 5, $row[10], 'LR', 0, 'R', $fill); $this->Ln(); $fill=!$fill; if (($line / 33) == 1) { $line = 0 ; $this->Cell(array_sum($w), 0, '', 'T'); $this->Ln(); $this->SetFillColor(255, 0, 0); $this->SetTextColor(255); $this->SetDrawColor(128, 0, 0); $this->SetLineWidth(0.3); $this->SetFont('', 'B', 7); // Header for($i = 0; $i < $num_headers; ++$i) { $this->Cell($w[$i], 6, $header[$i], 1, 0, 'C', 1); } $this->Ln(); } } $this->Cell(array_sum($w), 0, '', 'T'); } } $lista = array() ; /*************************************************************************** * where-list ***************************************************************************/ $selIdOrd = $idOrd ; $selCli = $cliente ; $selFor = $fornitore ; $selAge = $agente ; $selNumFatt = $numFatt ; $selSalFatt = $salFatt ; $selSalFor = $salFor ; $selSalAge = $salAge ; $selModPag = $modPag ; $selNumAss = $numAss ; $selDaInv = $daInv ; $selEpoca = $epoca ; $ordinaper = $colToSort ; $direction = $direction ; $where = "1=1" ; /************************* * filtro Id Ordine **************************/ if (isset($selIdOrd) and ($selIdOrd != '')) $where .= " and O.IdOrdini = $selIdOrd" ; /************************* * filtro Cliente **************************/ if (isset($selCli) and ($selCli != 'tutti')) $where .= " and C.IdClienti = $selCli" ; /************************* * filtro Fornitore **************************/ if (isset($selFor) and ($selFor != 'tutti')) $where .= " and F.IdFornitori = $selFor" ; /************************* * filtro Agente **************************/ if (isset($selAge) and ($selAge != 'tutti')) $where .= " and A.IdAgenti = $selAge" ; /************************* * filtro Numero Fattura **************************/ if (isset($selNumFatt) and ($selNumFatt != '')) { if ($selNumFatt == 0) $where .= " and (O.NumFattura = '' or O.NumFattura is null)" ; else $where .= " and O.NumFattura = $selNumFatt" ; } /************************* * filtro Fattura Saldata **************************/ if (isset($selSalFatt) and ($selSalFatt != -1)) $where .= " and O.SaldoFattura = $selSalFatt" ; /***************************************** * filtro Provvigione Saldata Fornitore *****************************************/ if (isset($selSalFor) and ($selSalFor != -1)) $where .= " and O.SaldoProvvigione = $selSalFor" ; /***************************************** * filtro Provvigione Saldata Agente *****************************************/ if (isset($selSalAge) and ($selSalAge != -1)) $where .= " and O.SaldoProvvigioneAgente = $selSalAge" ; /***************************************** * filtro Modalita di Pagamento *****************************************/ if (isset($selModPag) and ($selModPag != 0)) $where .= " and O.IdPagamento = $selModPag" ; /***************************************** * filtro Numero Assegno *****************************************/ if (isset($selNumAss)) if ($selNumAss == '-99') $where .= " and (O.NumAssegno = '' or O.NumAssegno is null)" ; else if ($selNumAss != 0) $where .= " and O.NumAssegno = $selNumAss" ; /***************************************** * filtro Da Inviare *****************************************/ if (isset($selDaInv) and ($selDaInv != -1)) $where .= " and O.DaInviare = $selDaInv" ; /***************************************** * filtro Epoca di Consegna *****************************************/ if (isset($selEpoca) and ($selEpoca != '')) $where .= " and O.EpocaDiConsegna = '$selEpoca'" ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($ordinaper) { case 0: // id ordine $order_by = "O.IdOrdini $direction" ; break ; case 1: // cliente $order_by = "C.Nome $direction, O.IdOrdini" ; break ; case 2: // fornitore $order_by = "F.Nome $direction, O.IdOrdini" ; break ; case 3: // agente $order_by = "A.Nome $direction, O.IdOrdini" ; break ; case 4: // data ordine $order_by = "O.DataOrdine $direction, O.IdOrdini" ; break ; case 5: // data spedizione $order_by = "O.DataSpedizione $direction, O.IdOrdini" ; break ; case 6: // numero fattura $order_by = "O.NumFattura $direction, O.IdOrdini" ; break ; case 7: // data spedizione fattura $order_by = "O.DataSpedFattura $direction, O.IdOrdini" ; break ; case 8: // importo fattura $order_by = "O.ImportoFattura $direction, O.IdOrdini" ; break ; case 9: // fattura saldata ? $order_by = "O.SaldoFattura $direction, O.IdOrdini" ; break ; case 10: // data richiesta che sarebbe la data pagamento fattura $order_by = "O.DataRichiesta $direction, O.IdOrdini" ; break ; case 11: // provvigione fornitore saldata? $order_by = "O.SaldoProvvigione $direction, O.IdOrdini" ; break ; case 12: // provvigione agente saldata? $order_by = "O.SaldoProvvigioneAgente $direction, O.IdOrdini" ; break ; case 13: // modalita di pagamento $order_by = "ModalitaPagamenti $direction, O.IdOrdini" ; break ; case 14: // numero di assegno $order_by = "NumAssegno $direction, O.IdOrdini" ; break ; case 16: // Da inviare di pagamento $order_by = "DaInviare $direction, O.IdOrdini" ; break ; case 17: // epoca di consegna $order_by = "EpocaDiConsegna $direction, O.IdOrdini" ; break ; } $qord = " select *, A.Nome as NomeAgente, C.Nome as NomeCliente, F.Nome as NomeFornitore, P.modalita as ModalitaPagamenti from ordini O inner join pagamenti P on P.IdPagamenti = O.IdPagamento inner join clienti C on C.IdClienti = O.IdCliente inner join fornitori F on F.IdFornitori = O.IdFornitore inner join agenti A on A.IdAgenti = O.IdAgente where O.Anno = $anno and $where order by $order_by " ; list($n, $arrVal) = $db->RecuperaDati($qord) ; for ($i=0; $i<$n; $i++) { $lista[] = $arrVal['IdOrdini'][$i] . ";" . ItaDate($arrVal['DataOrdine'][$i]) . ";" . ItaDate($arrVal['DataSpedizione'][$i]) . ";" . $arrVal["NomeAgente"][$i] . ";" . $arrVal["NomeCliente"][$i] . ";" . $arrVal['NomeFornitore'][$i] . ";" . $arrVal['NumFattura'][$i] . ";" . ItaDate($arrVal['DataSpedFattura'][$i]) . ";" . nfe($arrVal['ImportoFattura'][$i]) . ";" . ItaDate($arrVal['DataRichiesta'][$i]) . ";" . $arrVal['ModalitaPagamenti'][$i]; } $arrParGen = array() ; $arrParGen = RecuperaParametriGenerali($arrParGen, $tparametri) ; $nome = $arrParGen['NomeAgenzia'] ; $sede = "Sede operativa: " . $arrParGen['IndirizzoAgenzia'] ; $datisede = "Telefono: " . $arrParGen['TelefonoAgenzia'] . " Fax: " . $arrParGen['FaxAgenzia'] . " -- P.I. " . $arrParGen['PartitaIvaAgenzia'] ; $emailsede = "Email: " . $arrParGen['MailAgenzia'] ; $titolo = " Anno $anno - LIsta Ordini al " . Date("d/m/Y") ; // 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('Dali'); $pdf->SetTitle('Lista Clienti'); $pdf->SetSubject('Dali Wine'); $pdf->SetKeywords('PDF'); $vuota = " " ; for ($j=0; $j<180; $j++) $vuota .= " "; // set default header data // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE .' 011', PDF_HEADER_STRING); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $nome, $sede . "\n" . $datisede . "\n" . $emailsede . $vuota . $titolo); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, 15); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 7); // add a page $pdf->AddPage(); //Column titles $header = array('N. Ord.', 'Data Ordine', 'Data Invio', 'Agente', 'Cliente', 'Fornitore', 'N. Fatt.', 'Data Fatt', 'Importo', 'Data Pag. Fatt', 'Mod. Pagamento') ; //Data loading $data = $pdf->LoadData($lista); // print colored table $pdf->ColoredTable($header, $data); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('Lista Ordini.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+