/************************************************************* * StampaListaOrdini.php **************************************************************/ include ("../common/public.php") ; print_r($_GET + $_POST) ; // exit ; if ($StampaPdf == "SI") { require_once('../pdf/config/lang/eng.php'); require_once('../pdf/tcpdf.php'); // extend TCPF with custom functions class MYPDF extends TCPDF { // Load table data from file public function LoadData($lines) { foreach($lines as $line) { $data[] = explode(';', chop($line)); } return $data; } // Colored table public function ColoredTable($header, $data) { // Colors, line width and bold font $this->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, substr($row[4], 0, 50), '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) { if (($line / 31) == 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 = "1=1" ; $logIn = $_SESSION['login'] ; if ($logIn == 'dali') { $colToSort = $colToSort + 2 ; $where .= " and (A.idagenti = 11 or A.idagenti = 12 or A.idagenti = 14)" ; } /************************* * filtro Numero Ordine **************************/ if (isset($selIdOrd) and ($selIdOrd != '')) $where .= " and O.IdOrdini = $selIdOrd" ; if (isset($numeroOrdDa) and ($numeroOrdDa != '')) $where .= " and O.IdOrdini >= $selIdOrdDa" ; if (isset($numeroOrdA) and ($numeroOrdA != '')) $where .= " and O.IdOrdini <= $selIdOrdA" ; /************************* * filtro Cliente **************************/ if (isset($cliente) and ($cliente != 'tutti')) $where .= " and C.IdClienti = $cliente" ; /************************* * filtro Fornitore **************************/ if (isset($fornitore) and ($fornitore != 'tutti')) $where .= " and F.IdFornitori = $fornitore" ; /************************* * filtro Agente **************************/ if (isset($agente) and ($agente != 'tutti')) $where .= " and A.IdAgenti = $agente" ; /************************* * filtro Numero Fattura **************************/ if (isset($numFatt) and ($numFatt != '')) { if ($numFatt == 0) $where .= " and (O.NumFattura = '' or O.NumFattura is null)" ; else $where .= " and O.NumFattura = $numFatt" ; } /********************************* * filtro Numero Fattura Presente * = 0 Numero Fattura Non Presente * = 1 Numero Fatura Presente **********************************/ if (isset($numFattPre) and ($numFattPre != '')) { if ($numFattPre == 0) $where .= " and (O.NumFattura = '')" ; else $where .= " and O.NumFattura > 0" ; } /************************* * filtro Fattura Saldata **************************/ if (isset($salFatt) and ($salFatt != -1)) $where .= " and O.SaldoFattura = $salFatt" ; /***************************************** * filtro Provvigione Saldata Fornitore *****************************************/ if (isset($salFor) and ($salFor != -1)) $where .= " and O.SaldoProvvigione = $salFor" ; /***************************************** * filtro Provvigione Saldata Agente *****************************************/ if (isset($salAge) and ($salAge != -1)) $where .= " and O.SaldoProvvigioneAgente = $salAge" ; /***************************************** * filtro Modalita di Pagamento *****************************************/ if (isset($modPag) and ($modPag != 0)) $where .= " and O.IdPagamento = $modPag" ; /***************************************** * filtro Numero Assegno *****************************************/ if (isset($numAss)) if ($numAss == '-99') $where .= " and (O.NumAssegno = '' or O.NumAssegno is null)" ; else if ($numAss != 0) $where .= " and O.NumAssegno = $numAss" ; /***************************************** * filtro Da Inviare *****************************************/ if (isset($daInv) and ($daInv != -1)) $where .= " and O.DaInviare = $daInv" ; /***************************************** * filtro Epoca di Consegna *****************************************/ if (isset($epoca) and ($epoca != '')) $where .= " and O.EpocaDiConsegna = '$epoca'" ; /**************************** * filtro sulla data Ordine *****************************/ if (isset($dataOrdDa) and ($dataOrdDa != '')) $where .= " and O.DataOrdine >= '$dataOrdDa'" ; if (isset($dataOrdA) and ($dataOrdA != '')) $where .= " and O.DataOrdine <= '$dataOrdA'" ; /**************************** * filtro sulla data Fattura *****************************/ if (isset($dataFatDa) and ($dataFatDa != '')) $where .= " and O.DataSpedFattura >= '$dataFatDa'" ; if (isset($dataFatA) and ($dataFatA != '')) $where .= " and O.DataSpedFattura <= '$dataFatA'" ; /*************************************** * controllo la colonna da ordinare ***************************************/ switch($colToSort) { case 3: // id ordine $order_by = "O.IdOrdini $direction" ; break ; case 4: // cliente $order_by = "C.Nome $direction, O.IdOrdini" ; break ; case 5: // fornitore $order_by = "F.Nome $direction, O.IdOrdini" ; break ; case 6: // agente $order_by = "A.Nome $direction, O.IdOrdini" ; break ; case 7: // data ordine $order_by = "O.DataOrdine $direction, O.IdOrdini" ; break ; case 8: // numero fattura $order_by = "O.NumFattura $direction, O.IdOrdini" ; break ; case 9: // data fattura $order_by = "O.DataSpedFattura $direction, O.IdOrdini" ; break ; case 10: // importo fattura $order_by = "O.ImportoFattura $direction, O.IdOrdini" ; break ; case 11: // fattura saldata ? $order_by = "O.SaldoFattura $direction, O.IdOrdini" ; break ; case 12: // data richiesta che sarebbe la data pagamento fattura $order_by = "O.DataRichiesta $direction, O.IdOrdini" ; break ; case 13: // provvigione fornitore saldata? $order_by = "O.SaldoProvvigione $direction, O.IdOrdini" ; break ; case 14: // provvigione agente saldata? $order_by = "O.SaldoProvvigioneAgente $direction, O.IdOrdini" ; break ; case 15: // modalita di pagamento $order_by = "O.ModalitaPagamenti $direction, O.IdOrdini" ; break ; case 16: // numero di assegno $order_by = "O.NumAssegno $direction, O.IdOrdini" ; break ; case 17: // Da inviare di pagamento $order_by = "O.DaInviare $direction, O.IdOrdini" ; break ; case 18: // epoca di consegna $order_by = "O.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 " ; debug (0, $qord) ; 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 .= " Lista Ordini - Anno $anno" ; if ($StampaPdf == "SI") { // 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 Ordini'); $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 //============================================================+ } else { ?>
![]() |
echo $sede ?> echo $datisede ?> echo $emailsede ?> |
| echo $titolo ?> | |||||||||||||||||||
| al echo Date("d/m/Y") ?> | |||||||||||||||||||
| Agente | Cliente | Fornitore | |||||||||||||||||
| N.Ord | Data Ordine | Data Sped Ord | N.Fatt | Data Sped Fatt | Imp. Fatt | Data Pag. Fatt. | Fatt Sald? | Prov AGZ Sald? | Prov AGT Sald? | N. Assegno | Sconti | Mod Pagamento | |||||||
| echo $arrVal['NomeAgente'][$i] ?> | echo $arrVal['NomeCliente'][$i] ?> | echo $arrVal['NomeFornitore'][$i] ?> | |||||||||||||||||
| echo $arrVal['IdOrdini'][$i] ?> | echo StampaStr(ItaDate($arrVal['DataOrdine'][$i])) ?> | echo StampaStr(ItaDate($arrVal['DataSpedizione'][$i])) ?> | echo StampaStr($arrVal['NumFattura'][$i]) ?> | echo StampaStr(ItaDate($arrVal['DataSpedFattura'][$i])) ?> | echo StampaStr(nfe($arrVal['ImportoFattura'][$i])) ?> | echo StampaStr(ItaDate($arrVal['DataRichiesta'][$i])) ?> | echo SiNo($arrVal['SaldoFattura'][$i]) ?> | echo SiNo($arrVal['SaldoProvvigione'][$i]) ?> | echo SiNo($arrVal['SaldoProvvigioneAgente'][$i]) ?> | echo StampaStr($arrVal['NumAssegno'][$i]) ?> | echo StampaStr(nfp($arrVal['Sconto1'][$i]) . " - " . nfp($arrVal['Sconto2'][$i]) . " - " . nfp($arrVal['Sconto3'][$i])) ?> | echo $arrVal['ModalitaPagamenti'][$i] ?> | |||||||