   <?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))
               {
  $fecha = $_GET['fecha'];
  //$fecha = '2021/07/29';
  
  $sql="SELECT * FROM `venta`,venta_detalle,productos,pacientes WHERE `ven_fecha` = '$fecha' and ven_id = vdet_id and `vdet_pro_id` = pro_id AND ven_pac_id = pac_id"; //CURDATE() ;
  $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('Corte de Día: ') . date("d/m/Y", strtotime($fecha)),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'])),0,1,'L');
      //$pdf->SetXY(10,35);
      //$pdf->Cell(50,30, 'Fecha ' . date("d/m/Y", strtotime($row2['ven_fecha'])),0,1,'L');
      $pdf->SetXY(10,45);
      $pdf->SetFont('Arial','B',9);
      $pdf->Cell(10,10,'NUM',1,0,'L');
      $pdf->Cell(136,10,'PACIENTE',1,0,'L');
      $pdf->Cell(26,10,'FECHA',1,0,'L');
      $pdf->Cell(20,10,'VENTA',1,1,'C');
      $pdf->SetFont('Arial','',10);
      $n=0;$L=0;while($row = mysqli_fetch_array($resultado)) { $l=$l+1;
      $n=$n+$row['ven_total'];
      $pdf->Cell(10,10,$l,1,0,'L');
      $pdf->Cell(136,10,utf8_decode($row['pac_nombre']),1,0,'L');  
      $pdf->Cell(26,10,date("d/m/Y", strtotime($row['ven_fecha'])),1,0,'L'); 
      $pdf->Cell(20,10,money_format('%(#5.2n', $row['ven_total']),1,1,'C');
      }
      $pdf->SetFont('Arial','B',12);
      $pdf->Cell(28,10,'TOTAL',1,0,'L');
      $pdf->Cell(164,10,money_format('%(#5.2n', $n),1,1,'R');
     
      
       
   
       $pdf->Output();
   }     
   
   ?>