<?php
session_start();
require('../fpdf/fpdf.php');
require('plantilla_general.php');
require '../../../conexion.php';
require_once('../../../include/sesiones.php');

$sql1=mysqli_query($con,"SELECT * FROM articulos a, venta_detalle k ,articulos_has_bodegas ab
WHERE a.art_id=k.vend_art_id AND a.art_id = ab.articulos_art_id AND a.empresa='$empresa' AND k.empresa='$empresa' and ab.empresa='$empresa' and ab.bodegas='$bod_id' and ab.art_cantidad<=0 and k.kar_fecha<'2019-01-01' group by k.vend_art_id order by a.familias_fam_id asc");

    
$pdf=new PDF_MC_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
$pdf->AliasNbPages();

$pdf->Cell(0,10,'INVENTARIO SIN USO',0,1);

$pdf->SetFont('Arial','',7);
$pdf->SetFillColor(235,225,215);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(15,6,'CODIGO',1,0,'C',1);
$pdf->Cell(100,6,'NOMBRE',1,0,'C',1);
$pdf->Cell(25,6,'FAMILIA',1,0,'C',1);
$pdf->Cell(15,6,'CANTIDAD',1,0,'C',1);
$pdf->Cell(20,6,'COSTO',1,0,'C',1);
$pdf->Cell(20,6,'VENTA',1,0,'C',1);
$pdf->Ln(); 

while ($row=mysqli_fetch_array($sql1))    
{
    $art_id=$row['art_id'];
    $art_referencia=$row['art_referencia'];
    $art_nombre=$row['art_nombre'];
    $art_precio_costo=$row['art_precio_costo'];
    $art_pvp=$row['art_pvp'];
    $art_cantidad=$row['art_cantidad'];
    $familias_fam_id=$row['familias_fam_id'];

    $sql=mysqli_query($con, "SELECT * from familias where fam_id='$familias_fam_id' and empresa='$empresa'");
    $roww=mysqli_fetch_array($sql);
    $fam_nombre=$roww['fam_nombre'];

    $pdf->SetWidths(array(15,100,25,15,20,20));
    srand(time()*1000000);
    $pdf->Row(array($art_referencia,utf8_decode($art_nombre),utf8_decode($fam_nombre),$art_cantidad,number_format($art_precio_costo,0),number_format($art_pvp,0)));
}

$pdf->Output();
?>