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

$tar_id=$_GET['tar_id'];
$query=mysqli_query($con,"SELECT * FROM articulos where empresa='$empresa' and art_tipo='articulo' and art_estado='Activo' ORDER BY art_nombre ASC ");

$pdf=new PDF_MC_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
$pdf->AliasNbPages();
//Table with 20 rows and 4 columns

$pdf->SetFillColor(255,255,255);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(30,6,'REF',1,0,'C',1);
$pdf->Cell(120,6,'NOMBRE',1,0,'C',1);
$pdf->Cell(30,6,'PRECIO',1,0,'C',1);
$pdf->Ln();  

$pdf->SetFont('Arial','',7);
	
 while ($roww=mysqli_fetch_array($query))	
 	{
		$art_id=$roww['art_id'];
		$sql2=mysqli_query($con, "SELECT * from articulos_has_bodegas where bodegas='$bod_id' and empresa='$empresa' and articulos_art_id='$art_id'");
        $c=mysqli_fetch_array($sql2);
        $art_cantidad=$c['art_cantidad'];

		$sql_pre=mysqli_query($con, "SELECT * from precio WHERE articulos_art_id='$art_id' and tarifas_tar_id='$tar_id' and empresa='$empresa' ");
		$rw_pre= mysqli_fetch_array($sql_pre);
		$numrows = $rw_pre['pre_id'];
		if ($numrows>0)
		{
			$pre_precio=$rw_pre['pre_precio'];
		}
		else
		{
			$pre_precio=$row['art_pvp'];
		}

		$pdf->SetWidths(array(30,120,30));
		srand(time()*1000000);
		$pdf->Row(array($roww['art_referencia'],$roww['art_nombre'],number_format($pre_precio,0)));
	}
$pdf->Output();
?>
