Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateRow(){
- $idviaje=$_REQUEST['idviaje'];
- $contents = '';
- $content = '';
- include_once('connection.php');
- $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
- $query = $conn->query($sql);
- while($row = $query->fetch_assoc()){
- $content .= "
- <tr>
- <td colspan='2'>Remitente:".$row['nombredircar']."</td>
- <td colspan='3'>Dirección:".$row['direcciondircar']."</td>
- </tr>
- <tr>
- <th>Cod.Pos.".$row['codigopostaldircar']."</th>
- <th colspan='2'>Población".$row['poblaciondircar']."</th>
- <th>".$row['provinciadircar']."</th>
- <th>".$row['paisdircar']."</th>
- </tr>
- <tr>
- <th>".$row['fechacar']."</th>
- <th>".$row['horariocar']."</th>
- <th>".$row['referenciacar']."</th>
- <th>".$row['contactocar']."</th>
- <th>".$row['telefonocar']."</th>
- </tr>
- <tr>
- <td colspan='5'>".$row['observacionesdircar']."</td>
- </tr>
- ";
- }
- $contents=$content;
- return $contents;
- }
- <?php
- $idviaje=$_REQUEST['idviaje'];
- $username=$_REQUEST['username'];
- require_once('tcpdf/tcpdf.php');
- // Extend the TCPDF class to create custom Header and Footer
- class MYPDF extends TCPDF {
- // 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, '´Página '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
- }
- }
- $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
- $pdf->SetCreator(PDF_CREATOR);
- $pdf->SetTitle("Generated PDF using TCPDF");
- $pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
- $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
- $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
- $pdf->SetDefaultMonospacedFont('helvetica');
- $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
- $pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(true);
- $pdf->SetAutoPageBreak(TRUE, 10);
- $pdf->SetFont('helvetica', '', 11);
- $pdf->AddPage();
- $tbl = <<<EOD
- <table cellspacing="0" cellpadding="1" border="1">
- <tr>
- <td>
- <table>
- <tr>
- <td><img src="images/logo_example.jpg" alt="test alt attribute" width="155" height="92" border="0"></td>
- <td><p sice="20"></p>
- <p></p>
- <p></p>
- <p></p>
- </td>
- <td><img src="images/logo_transnet.png" alt="test alt attribute" width="118" height="57" border="0" align="right"></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- EOD;
- $pdf->writeHTML($tbl, true, false, false, false, '');
- $tbl2 = <<<EOD
- <table cellspacing="0" cellpadding="1" border="1">
- <tr>
- <td>Para:$idviaje</td>
- <td>De:$nombreuser</td>
- </tr>
- </table>
- EOD;
- $pdf->writeHTML($tbl2, true, false, false, false, '');
- function generateRow(){
- $idviaje=$_REQUEST['idviaje'];
- $contents = '';
- $content = '';
- include_once('connection.php');
- $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
- $query = $conn->query($sql);
- while($row = $query->fetch_assoc()){
- $content .= "
- <tr>
- <td colspan='2'>Remitente:".$row['nombredircar']."</td>
- <td colspan='3'>Dirección:".$row['direcciondircar']."</td>
- </tr>
- <tr>
- <th>Cod.Pos.".$row['codigopostaldircar']."</th>
- <th colspan='2'>Población".$row['poblaciondircar']."</th>
- <th>".$row['provinciadircar']."</th>
- <th>".$row['paisdircar']."</th>
- </tr>
- <tr>
- <th>".$row['fechacar']."</th>
- <th>".$row['horariocar']."</th>
- <th>".$row['referenciacar']."</th>
- <th>".$row['contactocar']."</th>
- <th>".$row['telefonocar']."</th>
- </tr>
- <tr>
- <td colspan='5'>".$row['observacionesdircar']."</td>
- </tr>
- ";
- }
- $contents=$content;
- return $contents;
- }
- $content = '';
- $content .= '
- <table border="1" cellspacing="0" cellpadding="3">
- <tr>
- <th width="100%" colspan="5">DIRECCIÓN DE CARGA</th>
- </tr>
- ';
- $content .= generateRow();
- $content .= '</table>';
- $pdf->writeHTML($content);
- $pdf->Output('members.pdf', 'I');
- ?>
- function generateRow(){
- $idviaje=$_REQUEST['idviaje'];
- $contents = '';
- $content = '';
- include_once('connection.php');
- $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
- $query = $conn->query($sql);
- while($row = $query->fetch_assoc()){
- $content .= '
- <tr>
- <td colspan="2">Remitente:'.$row['nombredircar'].'</td>
- <td colspan="3">Dirección:'.$row['direcciondircar'].'</td>
- </tr>
- <tr>
- <th>Cod.Pos.'.$row['codigopostaldircar'].'</th>
- <th>Población'.$row['poblaciondircar'].'</th>
- <th>'.$row['provinciadircar'].'</th>
- <th>'.$row['paisdircar'].'</th>
- </tr>
- <tr>
- <th>'.$row['fechacar'].'</th>
- <th>'.$row['horariocar'].'</th>
- <th>'.$row['referenciacar'].'</th>
- <th>'.$row['contactocar'].'</th>
- <th>'.$row['telefonocar'].'</th>
- </tr>
- <tr>
- <td colspan="5">'.$row['observacionesdircar'].'</td>
- </tr>
- ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement