<?php
require('../../../pdf/fpdf.php');
date_default_timezone_set('America/Caracas'); 
$hora_local = date('H:i:s');
class PDF extends FPDF
{ }
require('../../../Clases/db.php');


   
 
  
   
$mostrar = new conn ();
$conex = $mostrar->crearconn();
    $pdf = new PDF();
$pdf->SetX(4);

$pdf->SetMargins(17,17,17);
  $pdf->AddPage();
$pdf->Image('../../../Imagenes/logo.png',165,12,35,35,'PNG');
  $pdf->SetFont('Arial','B',16);
  $pdf->SetTextColor(32,100,210);
  $pdf->Cell(150,10,iconv("UTF-8", "ISO-8859-1",strtoupper("Emperadora Internet y Mas")),0,0,'L');

  $pdf->Ln(9);

  $pdf->SetFont('Arial','',10);
  $pdf->SetTextColor(39,39,51);
  $pdf->Cell(150,9,iconv("UTF-8", "ISO-8859-1","RIF: J-29966140-6"),0,0,'L');

  $pdf->Ln(5);

  $pdf->Cell(150,9,iconv("UTF-8", "ISO-8859-1","Valencia Barrio Monumental III Av principal
"),0,0,'L');

  $pdf->Ln(5);

  $pdf->Cell(150,9,iconv("UTF-8", "ISO-8859-1","Teléfono: 0241-8480889"),0,0,'L');

  $pdf->Ln(5);

  $pdf->Cell(150,9,iconv("UTF-8", "ISO-8859-1","Email: laemperadorainternetymas@gmail.com"),0,0,'L');

  $pdf->Ln(10);

  $pdf->SetFont('Arial','',10);
  $pdf->Cell(30,7,iconv("UTF-8", "ISO-8859-1","Fecha de emisión:"),0,0);
  $pdf->SetTextColor(97,97,97);
  $pdf->Cell(116,7,iconv ("UTF-8", "ISO-8859-1",date("d/m/Y", strtotime($hora_local))." ".date($hora_local)),0,0,'L');
  $pdf->SetFont('Arial','B',10);
  $pdf->SetTextColor(39,39,51);
  $pdf->Cell(26,7,iconv("UTF-8", "ISO-8859-1",strtoupper("Reporte Total del Inventario")),0,0,'C');

  

  $pdf->Ln(9);
  # Tabla de productos #
  $pdf->SetFont('Arial','',8);
  $pdf->SetFillColor(23,83,201);
  $pdf->SetDrawColor(23,83,201);
  $pdf->SetTextColor(255,255,255);
  $pdf->Cell(18,8,iconv("UTF-8", "ISO-8859-1","Cod"),1,0,'C',true);
    $pdf->Cell(35,8,iconv("UTF-8", "ISO-8859-1","Producto"),1,0,'C',true);
    $pdf->Cell(30,8,iconv("UTF-8", "ISO-8859-1","Descripcion"),1,0,'C',true);
      $pdf->Cell(35,8,iconv("UTF-8", "ISO-8859-1","Categoria"),1,0,'C',true);
  $pdf->Cell(15,8,iconv("UTF-8", "ISO-8859-1","Precio C"),1,0,'C',true);
  $pdf->Cell(15,8,iconv("UTF-8", "ISO-8859-1","Precio V"),1,0,'C',true);
    $pdf->Cell(22,8,iconv("UTF-8", "ISO-8859-1","Proveedor"),1,0,'C',true);
      $pdf->Cell(15,8,iconv("UTF-8", "ISO-8859-1","Stock"),1,0,'C',true);

  $pdf->Ln(8);

  
  $pdf->SetTextColor(39,39,51);
     /*----------  Detalles de la tabla  ----------*/
     $sql2 = "SELECT p.Cod,p.Nombre,p.Descripcion,p.Imagen,p.Stock_actual,p.Precio_Compra,p.Precio_Venta,p.ID_Proveedores,p.Stock_Actual, ca.Nombre as nombre_categoria, d.Nombre as nombre_proveedor from productos p INNER JOIN proveedores pr ON p.ID_Proveedores = pr.ID INNER JOIN datos_personales d on pr.CI_Datos = d.Cedula INNER JOIN categoria ca ON p.ID_Categoria = ca.ID where p.Estado = 1 ";
$resultado = $conex->query($sql2);
$totalp= 0;
while($rows = $resultado->fetch_assoc()){
 $stockstotal= $rows['Stock_Actual'];

    $totalp += $stockstotal;

    $pdf->Cell(18,7,iconv("UTF-8", "ISO-8859-1",$rows['Cod']),'LR',0,'C');
    $pdf->Cell(35,7,iconv("UTF-8", "ISO-8859-1",$rows['Nombre']),'L',0,'C');
     $pdf->Cell(35,7,iconv("UTF-8", "ISO-8859-1",$rows['Descripcion']),'L',0,'C');
  $pdf->Cell(30,7,iconv("UTF-8", "ISO-8859-1",$rows['nombre_categoria']),'L',0,'C');
  $pdf->Cell(15,7,iconv("UTF-8", "ISO-8859-1",$rows['Precio_Compra']),'L',0,'C');
  $pdf->Cell(15,7,iconv("UTF-8", "ISO-8859-1",$rows['Precio_Venta']),'LR',0,'C');
   $pdf->Cell(22,7,iconv("UTF-8", "ISO-8859-1",$rows['nombre_proveedor']),'L',0,'C');
    $pdf->Cell(15,7,iconv("UTF-8", "ISO-8859-1",$rows['Stock_actual']),'LR',0,'C');

  $pdf->Ln(7);
  /*----------  Fin Detalles de la tabla  ----------*/

}


$pdf->SetFont('Arial','B',9);
$pdf->Cell(100,7,iconv("UTF-8", "ISO-8859-1",''),'T',0,'C');
  $pdf->Cell(15,7,iconv("UTF-8", "ISO-8859-1",''),'T',0,'C');
  $pdf->Cell(32,7,iconv("UTF-8", "ISO-8859-1","Cantidad Total"),'T',0,'C');
 $pdf->Cell(38,7,iconv("UTF-8", "ISO-8859-1",$totalp),'T',0,'C');

  $pdf->Ln(7);
$pdf->Output("I",true);
