<?php

	# Incluyendo librerias necesarias #
	require "../../../pdf/fpdf.php";
date_default_timezone_set('America/Caracas'); 
$hora_local = date('H:i:s');
	class PDF extends FPDF
{


}
require('../../../Clases/db.php');
 
    $categoria = $_POST['Categoria'];
   
$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(35,7,iconv("UTF-8", "ISO-8859-1",strtoupper("Reporte por Productos")),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(20,8,iconv("UTF-8", "ISO-8859-1","Nombre"),1,0,'C',true);
    $pdf->Cell(24,8,iconv("UTF-8", "ISO-8859-1","Cedula"),1,0,'C',true);
    $pdf->Cell(24,8,iconv("UTF-8", "ISO-8859-1","Direccion"),1,0,'C',true);
    $pdf->Cell(24,8,iconv("UTF-8", "ISO-8859-1","Telefono"),1,0,'C',true);
      $pdf->Cell(30,8,iconv("UTF-8", "ISO-8859-1","Empresa"),1,0,'C',true);
  $pdf->Cell(30,8,iconv("UTF-8", "ISO-8859-1","RIF Empresa"),1,0,'C',true);
  $pdf->Cell(30,8,iconv("UTF-8", "ISO-8859-1","Producto Provee"),1,0,'C',true);

	$pdf->Ln(8);

	
	$pdf->SetTextColor(39,39,51);
     /*----------  Detalles de la tabla  ----------*/
     $sql2 = "SELECT prov.ID,prov.Fecha,prov.Nombre_Empresa,prov.Rif_Empresa,prov.Producto_Provee, prov.Fecha, d.Nombre as Nombre_proveedor, d.Cedula as Cedula_proveedor, d.Apellido as Apellido_prove, d.Direccion as direccion, d.Telefono as telefono, d.Correo as correo,  c.Nombre as p_provee  FROM proveedores prov 
INNER JOIN datos_personales d on prov.CI_Datos = d.Cedula 
INNER join categoria c on prov.Producto_Provee = c.ID 
where prov.Estado = 1 and c.ID = '$categoria'";
$resultado = $conex->query($sql2);
$totalp= 0;
while($rows = $resultado->fetch_assoc()){
 $pdf->Cell(20,7,iconv("UTF-8", "ISO-8859-1",$rows['Nombre_proveedor']),'LR',0,'C');
     $pdf->Cell(24,7,iconv("UTF-8", "ISO-8859-1",$rows['Cedula_proveedor']),'L',0,'C');
$pdf->Cell(24,7,iconv("UTF-8", "ISO-8859-1",$rows['direccion']),'L',0,'C');
$pdf->Cell(24,7,iconv("UTF-8", "ISO-8859-1",$rows['telefono']),'L',0,'C');
  $pdf->Cell(30,7,iconv("UTF-8", "ISO-8859-1",$rows['Nombre_Empresa']),'L',0,'C');
  $pdf->Cell(30,7,iconv("UTF-8", "ISO-8859-1",$rows['Rif_Empresa']),'L',0,'C');
  $pdf->Cell(30,7,iconv("UTF-8", "ISO-8859-1",$rows['p_provee']),'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(20,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');
   $pdf->Cell(20,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');
    $pdf->Cell(20,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');
     $pdf->Cell(19,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');
      $pdf->Cell(1,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');
   
 $pdf->Cell(2,7,iconv("UTF-8", "ISO-8859-1",""),'T',0,'C');

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


