   <?php require 'funcs/conexion.php';
   require 'funcs/funcs.php';
   require ('fpdf/fpdf.php');
   date_default_timezone_set('America/Mexico_City');
   header("Content-Type: text/html;charset=utf-8");

       
   if (!empty($_GET))
               {
                   $not_id = $_GET['not_id'];
                   $tip_id = $_GET['tip_id'];
                   $sql2 = "SELECT * FROM `expediente`,pacientes WHERE `exp_pac_id`=pac_id and exp_id = '$not_id' order by `exp_id` desc limit 1";
                           $result = $mysqli->query($sql2); 
                           $row = $result->fetch_assoc();
                           $exp_id=$row['exp_id'];
                           $exp_pac_id = $row['exp_pac_id'];
                           $edad=$row['exp_edad'];
                           $fechaexp=$row['exp_fecha'];
                           $antecedentes=$row['exp_antecedentes'];
                           $nopatologicos=$row['exp_nopatologicos'];
                           $patologicos=$row['exp_patologicos'];
                           $padecimiento=$row['exp_padecimiento'];
                           $exploracion=$row['exp_exploracion'];
                           $estudios=$row['exp_estudios'];
                           $impresion=$row['exp_impresion'];
                           $plan=$row['exp_plan'];
                           $nombre=$row['pac_nombre'];
                           $sexo=$row['pac_sexo'];
                           $receta=$row['exp_receta'];
                           $hora=$row['exp_hora'];
                           //$img='img/'.$tip_id.'.jpg';

class PDF extends FPDF
{
   
   function Header()
   {
      $tip_id = $_GET['tip_id'];
      $this->Image('img/'.$tip_id.'.jpg', 10, 6, 70,12);
      //$this->Image("img/fi.jpg", 5, null, 200,30);
      $this->Image('img/logo.png', 150, 5, 40 );
      $this->Image('img/fondo.png', 10, 160, 180,90);
     
      $this->Ln(20);

   }
   function Footer()
   {
       $this->SetXY(120,238);
       $this->SetFont('Arial','B',10);
      $this->Cell(13,30, utf8_decode('Dra. Nelly Eugenia Robles Luján. C.P. 4412680'),0,0,'L');

      //Go to 1.5 cm from bottom
       $this->SetY(-40);
       //this->Image('img/fi.png', 5, 270, 200 );     
         

       $this->Image("img/fi.jpg", 5, null, 200,30);
       //Select Arial italic 8
       $this->SetFont('Arial','I',8);
       //Print current and total page numbers
       $this->Cell(0,10,utf8_decode('Página ').$this->PageNo().'/{nb}',0,0,'C');
   }
}

      $pdf = new PDF('P','mm','A4',$tip_id);
      
      $pdf->AliasNbPages();
      $pdf->AddPage();
  $pdf->SetAutoPageBreak(TRUE, 44);
      

      $pdf->SetXY(10,10);
       $pdf->SetFont('Arial','B',10);
      $pdf->Cell(45,30, 'Nombre del Paciente: ',0,0,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->Cell(50,30, utf8_decode($nombre) ,0,1,'L');
       $pdf->SetXY(10,15);
       $pdf->SetFont('Arial','B',10);
      $pdf->Cell(13,30, 'Edad: ',0,0,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->Cell(35,30, $edad . ' ' . utf8_decode('años'),0,0,'L');
      $pdf->SetFont('Arial','B',10);
      $pdf->Cell(13,30, 'Sexo: ',0,0,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->Cell(35,30, $sexo ,0,0,'L');
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,30, 'Fecha: ',0,0,'L');
       $pdf->SetFont('Arial','',10);
      $pdf->Cell(35,30, $fechaexp ,0,0,'L');
      $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,30, 'Hora: ',0,0,'L');
       $pdf->SetFont('Arial','',10);
      $pdf->Cell(45,30, $hora ,0,1,'L');
       $pdf->SetXY(10,35);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'ANTECEDENTES HEREDOFAMILIARES: ',0,1,'L');
       $pdf->SetXY(10,45);
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($antecedentes) ,0,'L',0);
       
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'ANTECEDENTES PERSONALES NO PATOLOGICOS: ',0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($nopatologicos) ,0,'L',0);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'ANTECEDENTES PERSONALES PATOLOGICOS: ',0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($patologicos) ,0,'L',0);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'PADECIMIENTO ACTUAL: ',0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($padecimiento) ,0,'L',0);    
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, utf8_decode('EXPLORACIÓN FÍSICA: '),0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($exploracion) ,0,'L',0);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'ESTUDIOS: ',0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($estudios) ,0,'L',0);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, utf8_decode('IMPRESIÓN DIAGNÓSTICA: '),0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($impresion) ,0,'L',0);
       $pdf->SetFont('Arial','B',10);
       $pdf->Cell(20,10, 'PLAN: ',0,1,'L');
       $pdf->SetFont('Arial','',10);
       $pdf->MultiCell(190,5, utf8_decode($plan) ,0,'L',0);
       

     
      
       
   
       $pdf->Output();
   }     
   
   ?>