Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.19 KB | None | 0 0
  1. <?php
  2. $TIPO_BUSQUEDA = $_POST["TIPO_BUSQUEDA"];
  3. function ejecuta_consulta($labusqueda)
  4. {
  5. include("conexiond.php");
  6.  
  7. $conexion= mysqli_connect($db_host, $db_usuario, $db_contra);
  8.  
  9. if (mysqli_connect_errno()) {
  10. echo "Fallo al conectar con la base de datos";
  11. exit();
  12. }
  13.  
  14. mysqli_select_db($conexion, $db_nombre) or die("No se encuentra la base de datos.");
  15.  
  16.  
  17. $consulta = "SELECT datosbasicos.CED_PAC,datosbasicos.NOM_PAC,datosbasicos.APE_PAC,datosbasicos.SEX_PAC,datosmedicos.COD_CONSULTA,datosmedicos.ALT_PAC,datosmedicos.PESO_PAC,datosmedicos.FECHA,datosmedicos.TIPO_CONSULTA,datosmedicos.SINTOMAS,datosmedicos.OBSERV,datosmedicos.HIS_PAC,datosmedicos.MEDI_PAC,datosmedicos.OPERADO,datosmedicos.ALERGIAS FROM datosbasicos INNER JOIN datosmedicos ON datosbasicos.CED_PAC=datosmedicos.CED_PAC WHERE datosbasicos.NOM_PAC LIKE '%$labusqueda%' OR datosbasicos.CED_PAC LIKE '%$labusqueda%' OR datosmedicos.COD_CONSULTA LIKE '%$labusqueda%' OR datosbasicos.CED_PAC LIKE '%$labusqueda%' OR datosmedicos.FECHA LIKE '%$labusqueda%' ";
  18.  
  19. $resultados = mysqli_query($conexion, $consulta);
  20.  
  21. $filas = array(); // Crea la variable $filas y se le asigna un array vacío
  22. // (Si la consulta no devuelve ningún resultado, la función por lo menos va a retornar un array vacío)
  23.  
  24. while ($fila=mysqli_fetch_array($resultados, MYSQLI_ASSOC)) {
  25. $filas[] = $fila; // Añade el array $fila al final de $filas
  26. }
  27.  
  28. mysqli_close($conexion);
  29.  
  30. return $filas; // Devuelve el array $filas
  31. }
  32. ?>
  33.  
  34. <!DOCTYPE html>
  35. <html>
  36.  
  37. <head>
  38. <title>Sistema de historias médicas - Dr. Darling Davila</title>
  39. <meta charset="utf-8">
  40. <link rel="stylesheet" href="css/bootstrap.css">
  41. <link rel="stylesheet" type="text/css" href="css/estilo.css">
  42. <link href="https://fonts.googleapis.com/css?family=Lato|Roboto" rel="stylesheet">
  43. </head>
  44.  
  45. <body>
  46. <?php
  47. $mibusqueda=$_GET["buscar"];
  48.  
  49. $mipag=$_SERVER["PHP_SELF"];
  50.  
  51. if ($mibusqueda!=null) {
  52. $pacientes = ejecuta_consulta($mibusqueda);
  53. ?>
  54.  
  55. <div id="main-container">
  56. <img src='imagenes/header.png' class='img'>
  57. <table>
  58. <thead>
  59. <tr>
  60. <th>Codigo Consulta</th>
  61. <th>Fecha</th>
  62. <th>Cedula</th>
  63. <th>Nombres</th>
  64. <th>Apellidos</th>
  65. <th>Sexo</th>
  66. <th>Altura</th>
  67. <th>Peso</th>
  68. <th>Sintomas</th>
  69. <th>Observaciones</th>
  70. <th>Tipo de consulta</th>
  71. <th>Medicamentos actuales</th>
  72. <th>Alergias</th>
  73. <th>Operado</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. <?php
  78. // Si la variable $pacientes esta definida y no está vacía
  79. if (isset($pacientes) && !empty($pacientes)) {
  80. // Recorre cada $paciente dentro del array $pacientes
  81. foreach ($pacientes as $paciente) {
  82. ?>
  83. <tr>
  84. <td><?php echo $paciente['COD_CONSULTA'] ?></td>
  85. <td><?php echo $paciente['FECHA'] ?></td>
  86. <td><?php echo $paciente['CED_PAC'] ?></td>
  87. <td><?php echo $paciente['NOM_PAC'] ?></td>
  88. <td><?php echo $paciente['APE_PAC'] ?></td>
  89. <td><?php echo $paciente['SEX_PAC'] ?></td>
  90. <td><?php echo $paciente['ALT_PAC'] ?></td>
  91. <td><?php echo $paciente['PESO_PAC'] ?></td>
  92. <td><?php echo $paciente['SINTOMAS'] ?></td>
  93. <td><?php echo $paciente['OBSERV'] ?></td>
  94. <td><?php echo $paciente['TIPO_CONSULTA'] ?></td>
  95. <td><?php echo $paciente['MEDI_PAC'] ?></td>
  96. <td><?php echo $paciente['ALERGIAS'] ?></td>
  97. <td><?php echo $paciente['OPERADO'] ?></td>
  98. </tr>
  99. <?php
  100. }
  101. } ?>
  102. </tbody>
  103. </div>
  104. <?php
  105. } else {
  106. echo("<form action='". $mipag . "' method='GET'>
  107. <img src='imagenes/header.png'>
  108. <h2>Busqueda de paciente</h2>
  109. <div class='contenedor'>
  110. <select name='TIPO_BUSQUEDA' class='input-100 text-center col-md-12'>
  111. <option value='Cedula' selected='selected' <?PHP if($TIPO_BUSQUEDA=='Cedula'){ echo 'selected='selected'; } ?> Cedula</option>
  112. <option value='Edad' <?PHP if($TIPO_BUSQUEDA=='Edad'){ echo 'selected='selected'; } ?> Edad</option>
  113. <option value='Nombre' <?PHP if($TIPO_BUSQUEDA=='Nombre'){ echo 'selected='selected'; } ? >Nombre</option>
  114. <option value='Fecha' <?PHP if($TIPO_BUSQUEDA=='Fecha'){ echo 'selected='selected'; } ?> Fecha</option>
  115. </select>
  116. <input type='text' name='buscar' class='input-100 text-center inline-block col-md-6 btn-enviar espacio-arriba'></label>
  117.  
  118. <input type='submit' name='enviando' value='Consulta' class='text-center inline-block col-md-12 espacio-arriba btn-enviar'>
  119. </div>
  120. </form>");
  121. }
  122. ?>
  123.  
  124. </body>
  125.  
  126. </html>
  127.  
  128. <?php
  129. require('tfpdf.php');
  130. $con=mysqli_connect('localhost','root','12345678');
  131. mysqli_select_db($con,'pacientes');
  132.  
  133.  
  134. class PDF extends TFPDF {
  135. function Header(){
  136. $this->SetFont('Arial','B',15);
  137.  
  138. //dummy cell to put logo
  139. //$this->Cell(12,0,'',0,0);
  140. //is equivalent to:
  141. $this->Cell(12);
  142.  
  143. //put logo
  144. $this->Image('imagenes/header.png',150,10,60);
  145.  
  146. $this->Cell(1,50,'Lista de pacientes',0,1);
  147.  
  148. //dummy cell to give line spacing
  149. //$this->Cell(0,5,'',0,1);
  150. //is equivalent to:
  151. $this->Ln(5);
  152. $this->SetFont('Arial','B',11);
  153.  
  154. $this->SetFillColor(54,150,129);
  155. $this->SetDrawColor(36,99,85);
  156. $this->Cell(40,5,'Nombre ',1,0,'',true);
  157. $this->Cell(40,5,'Apellido',1,0,'',true);
  158. $this->Cell(25,5,'Edad',1,0,'',true);
  159. $this->Cell(25,5,'Sexo',1,0,'',true);
  160. $this->Cell(30,5,'Telefono',1,0,'',true);
  161. $this->Cell(30,5,'Celular',1,0,'',true);
  162. $this->Cell(130,5,'Direccion',1,1,'',true);
  163.  
  164.  
  165. }
  166. function Footer(){
  167. //add table's bottom line
  168. $this->Cell(190,0,'','T',1,'',true);
  169.  
  170. //Go to 1.5 cm from bottom
  171. $this->SetY(-15);
  172.  
  173. $this->SetFont('Arial','',8);
  174.  
  175. //width = 0 means the cell is extended up to the right margin
  176. $this->Cell(0,10,'Page '.$this->PageNo()." / {pages}",0,0,'C');
  177. }
  178. }
  179.  
  180.  
  181. //A4 width : 219mm
  182. //default margin : 10mm each side
  183. //writable horizontal : 219-(10*2)=189mm
  184.  
  185.  
  186. $pdf = new PDF('L','mm',array(400,200)); //use new class
  187.  
  188. //define new alias for total page numbers
  189. $pdf->AliasNbPages('{pages}');
  190.  
  191. $pdf->SetAutoPageBreak(true,15);
  192. $pdf->AddPage();
  193.  
  194. $pdf->SetFont('Arial','',9);
  195. $pdf->SetDrawColor(36,99,85);
  196.  
  197. // Add a Unicode font (uses UTF-8)
  198. $pdf->AddFont('Arial','','Arial.ttf',true);
  199. $pdf->SetFont('Arial','',11);
  200.  
  201. $query=mysqli_query($con,"select * from datosbasicos");
  202. while($data=mysqli_fetch_array($query)){
  203. $pdf->Cell(40,5,$data['NOM_PAC'],'LR',0);
  204. $pdf->Cell(40,5,$data['APE_PAC'],'LR',0);
  205. $pdf->Cell(25,5,$data['EDAD_PAC'],'LR',0);
  206. $pdf->Cell(25,5,$data['SEX_PAC'],'LR',0);
  207. $pdf->Cell(30,5,$data['TEL_PAC'],'LR',0);
  208. $pdf->Cell(30,5,$data['CEL_PAC'],'LR',0);
  209. $pdf->Cell(130,5,$data['DIR_PAC'],'LR',0);
  210.  
  211. if($pdf->GetStringWidth($data['email']) > 65){
  212. $pdf->SetFont('Arial','',7);
  213. $pdf->Cell(65,5,$data['email'],'LR',0);
  214. $pdf->SetFont('Arial','',9);
  215. }else{
  216. $pdf->Cell(65,5,$data['email'],'LR',0);
  217. }
  218. $pdf->Cell(60,5,$data['address'],'LR',1);
  219. }
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. $pdf->Output();
  235. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement