Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 KB | None | 0 0
  1. function generateRow(){
  2. $idviaje=$_REQUEST['idviaje'];
  3. $contents = '';
  4. $content = '';
  5. include_once('connection.php');
  6.  
  7. $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
  8. $query = $conn->query($sql);
  9. while($row = $query->fetch_assoc()){
  10. $content .= "
  11. <tr>
  12. <td colspan='2'>Remitente:".$row['nombredircar']."</td>
  13. <td colspan='3'>Dirección:".$row['direcciondircar']."</td>
  14. </tr>
  15. <tr>
  16. <th>Cod.Pos.".$row['codigopostaldircar']."</th>
  17. <th colspan='2'>Población".$row['poblaciondircar']."</th>
  18. <th>".$row['provinciadircar']."</th>
  19. <th>".$row['paisdircar']."</th>
  20. </tr>
  21. <tr>
  22. <th>".$row['fechacar']."</th>
  23. <th>".$row['horariocar']."</th>
  24. <th>".$row['referenciacar']."</th>
  25. <th>".$row['contactocar']."</th>
  26. <th>".$row['telefonocar']."</th>
  27. </tr>
  28. <tr>
  29. <td colspan='5'>".$row['observacionesdircar']."</td>
  30.  
  31. </tr>
  32. ";
  33. }
  34. $contents=$content;
  35.  
  36.  
  37. return $contents;
  38. }
  39.  
  40. <?php
  41.  
  42. $idviaje=$_REQUEST['idviaje'];
  43. $username=$_REQUEST['username'];
  44.  
  45.  
  46.  
  47.  
  48. require_once('tcpdf/tcpdf.php');
  49. // Extend the TCPDF class to create custom Header and Footer
  50. class MYPDF extends TCPDF {
  51.  
  52.  
  53.  
  54. // Page footer
  55. public function Footer() {
  56. // Position at 15 mm from bottom
  57. $this->SetY(-15);
  58. // Set font
  59. $this->SetFont('helvetica', 'I', 8);
  60. // Page number
  61. $this->Cell(0, 10, '´Página '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
  62. }
  63. }
  64. $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  65. $pdf->SetCreator(PDF_CREATOR);
  66. $pdf->SetTitle("Generated PDF using TCPDF");
  67. $pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
  68. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  69. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  70. $pdf->SetDefaultMonospacedFont('helvetica');
  71. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  72. $pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
  73. $pdf->setPrintHeader(false);
  74. $pdf->setPrintFooter(true);
  75. $pdf->SetAutoPageBreak(TRUE, 10);
  76. $pdf->SetFont('helvetica', '', 11);
  77. $pdf->AddPage();
  78.  
  79. $tbl = <<<EOD
  80. <table cellspacing="0" cellpadding="1" border="1">
  81. <tr>
  82. <td>
  83. <table>
  84. <tr>
  85. <td><img src="images/logo_example.jpg" alt="test alt attribute" width="155" height="92" border="0"></td>
  86. <td><p sice="20"></p>
  87. <p></p>
  88. <p></p>
  89. <p></p>
  90.  
  91.  
  92. </td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  93.  
  94.  
  95. <td><img src="images/logo_transnet.png" alt="test alt attribute" width="118" height="57" border="0" align="right"></td>
  96. </tr>
  97. </table>
  98. </td>
  99. </tr>
  100. </table>
  101. EOD;
  102.  
  103. $pdf->writeHTML($tbl, true, false, false, false, '');
  104.  
  105. $tbl2 = <<<EOD
  106. <table cellspacing="0" cellpadding="1" border="1">
  107. <tr>
  108. <td>Para:$idviaje</td>
  109. <td>De:$nombreuser</td>
  110. </tr>
  111. </table>
  112. EOD;
  113.  
  114. $pdf->writeHTML($tbl2, true, false, false, false, '');
  115.  
  116. function generateRow(){
  117. $idviaje=$_REQUEST['idviaje'];
  118. $contents = '';
  119. $content = '';
  120. include_once('connection.php');
  121.  
  122. $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
  123. $query = $conn->query($sql);
  124. while($row = $query->fetch_assoc()){
  125. $content .= "
  126. <tr>
  127. <td colspan='2'>Remitente:".$row['nombredircar']."</td>
  128. <td colspan='3'>Dirección:".$row['direcciondircar']."</td>
  129. </tr>
  130. <tr>
  131. <th>Cod.Pos.".$row['codigopostaldircar']."</th>
  132. <th colspan='2'>Población".$row['poblaciondircar']."</th>
  133. <th>".$row['provinciadircar']."</th>
  134. <th>".$row['paisdircar']."</th>
  135. </tr>
  136. <tr>
  137. <th>".$row['fechacar']."</th>
  138. <th>".$row['horariocar']."</th>
  139. <th>".$row['referenciacar']."</th>
  140. <th>".$row['contactocar']."</th>
  141. <th>".$row['telefonocar']."</th>
  142. </tr>
  143. <tr>
  144. <td colspan='5'>".$row['observacionesdircar']."</td>
  145.  
  146. </tr>
  147. ";
  148. }
  149. $contents=$content;
  150.  
  151.  
  152. return $contents;
  153. }
  154.  
  155. $content = '';
  156. $content .= '
  157.  
  158. <table border="1" cellspacing="0" cellpadding="3">
  159. <tr>
  160. <th width="100%" colspan="5">DIRECCIÓN DE CARGA</th>
  161.  
  162. </tr>
  163. ';
  164. $content .= generateRow();
  165. $content .= '</table>';
  166. $pdf->writeHTML($content);
  167.  
  168.  
  169.  
  170.  
  171.  
  172. $pdf->Output('members.pdf', 'I');
  173.  
  174.  
  175. ?>
  176.  
  177. function generateRow(){
  178. $idviaje=$_REQUEST['idviaje'];
  179. $contents = '';
  180. $content = '';
  181. include_once('connection.php');
  182.  
  183. $sql = "SELECT * FROM direccionescarga WHERE idviaje='$idviaje'";
  184. $query = $conn->query($sql);
  185. while($row = $query->fetch_assoc()){
  186. $content .= '
  187. <tr>
  188. <td colspan="2">Remitente:'.$row['nombredircar'].'</td>
  189. <td colspan="3">Dirección:'.$row['direcciondircar'].'</td>
  190. </tr>
  191. <tr>
  192. <th>Cod.Pos.'.$row['codigopostaldircar'].'</th>
  193. <th>Población'.$row['poblaciondircar'].'</th>
  194. <th>'.$row['provinciadircar'].'</th>
  195. <th>'.$row['paisdircar'].'</th>
  196. </tr>
  197. <tr>
  198. <th>'.$row['fechacar'].'</th>
  199. <th>'.$row['horariocar'].'</th>
  200. <th>'.$row['referenciacar'].'</th>
  201. <th>'.$row['contactocar'].'</th>
  202. <th>'.$row['telefonocar'].'</th>
  203. </tr>
  204. <tr>
  205. <td colspan="5">'.$row['observacionesdircar'].'</td>
  206.  
  207. </tr>
  208.  
  209. ';
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement