   <?php require 'funcs/conexion.php';
   require 'funcs/funcs.php';
   require ('fpdf/fpdf.php');
   setlocale(LC_MONETARY, 'en_US');

    setlocale(LC_TIME, 'es_ES.UTF-8');
   date_default_timezone_set('America/Mexico_City');



       
   if (!empty($_GET))
               {
  $ven_id = $_GET['ven_id'];
  $sql="SELECT * FROM venta,pacientes,`venta_detalle`,productos WHERE `vdet_pro_id` = pro_id and ven_id = vdet_ven_id AND ven_pac_id = pac_id and vdet_ven_id = $ven_id";
  $result = $mysqli->query($sql); 
    $row2 = $result->fetch_assoc();
    
    //`age_fecha` >= '$fi' and `age_fecha` <= '$ff'
  $resultado = mysqli_query($mysqli, $sql);
class PDF extends FPDF
{
   
   function Header()
   {
      //$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');
      
      $pdf->AliasNbPages();
      $pdf->AddPage();
      $pdf->SetAutoPageBreak(TRUE, 44);
      $pdf->SetXY(10,5);
       $pdf->SetFont('Arial','B',18);
      $pdf->Cell(45,30, utf8_decode('Ticket de Venta: '),0,0,'L');
      $pdf->SetXY(10,15);
      $pdf->SetFont('Arial','B',12);
      $pdf->Cell(50,30, 'Fecha ' . date("d/m/Y", strtotime($row2['ven_fecha'])) . ' Hora ' . $row2['ven_hora'] . ' hrs.'  ,0,1,'L');
      $pdf->SetXY(10,45);
      $pdf->SetFont('Arial','B',9);
      $pdf->Cell(10,10,'NUM',1,0,'L');
      $pdf->Cell(18,10,'TIPO',1,0,'L');
      $pdf->Cell(144,10,'NOMBRE',1,0,'L');
      $pdf->Cell(20,10,'PRECIO',1,1,'C');
      $pdf->SetFont('Arial','',10);
      $n=0;$L=0;while($row = mysqli_fetch_array($resultado)) { $l=$l+1;
      $n=$n+$row['num'];
      $pdf->Cell(10,10,$l,1,0,'L');
      $pdf->Cell(18,10,utf8_decode($row['pro_tipo']),1,0,'L');  
      $pdf->Cell(144,10,utf8_decode($row['pro_nombre']),1,0,'L'); 
      $pdf->Cell(20,10,money_format('%(#5.2n', $row['vdet_pro_venta']),1,1,'C');
      }
      $pdf->SetFont('Arial','B',12);
      $pdf->Cell(28,10,'TOTAL',1,0,'L');
      $pdf->Cell(164,10,money_format('%(#5.2n', $row2['ven_total']),1,1,'R');
     
      
       
   
       $pdf->Output();
   }     
   
   ?>