<?php include "../index/conexion.inc" ?>
<?php include "../index/validacion.php" ?>
<?php
	if (!empty($_POST['lista']))
	{
		if ($_POST['opcion'] == '1')
		{
			// conexión
			$servername = $svr_servidor;
			$conectioninfo = array("Database"=>$svr_base, "UID"=>$svr_usuario, "PWD"=>$svr_contrasena, "CharacterSet"=>"UTF-8");
			$conexion = sqlsrv_connect($servername, $conectioninfo);
			if ($conexion == false)
			{
				$mensaje = "Existe un error al intentar conectarse con el servidor...";
			}
			else
			{
				require('fpdf.php');
				$fpdf = new FPDF();
				$fpdf->AddPage('portrait' , 'letter');
				
				class PDF extends FPDF
				{
					// Cabecera de página
					function Header()
					{
						global $code;
						global $tienda;
						global $fecha;
						global $gondola;
						global $gondolaubi;
						global $unidadest;
						global $usuario;
						$cvV01 = date("F j, Y, g:i a");
						$this->SetFont('Arial','',18);
						$this->Text(10,10,'INVENTARIO FISICO');
						$this->SetFont('Arial','',12);
						$this->Cell(280,1,'Concepto "A" INVENTARIO FISICO CD '.$tienda,0,0,'C');
						$this->Text(10,16,'DOCUMENTO # '.$code);
						$this->Text(10,22,'GONDOLA # '.$gondola.' / UBN.: '.$gondolaubi);
						$this->Text(10,28,'TOTAL UNIDADES: '.$unidadest);
						$this->Text(150,16,'SALDOS A FECHA: '.$fecha);
						$this->Text(150,22,'USUARIO: '.$usuario);
						$this->Text(150,28,''.$cvV01.'',0,0,'R');
						$this->Line(10, 30, 290, 30);
						$this->Ln(20);
						$w = array(10, 38, 25, 15, 17, 17, 17, 28);
						$this->Cell($w[0],10,'BODEGA',0,0,'C');
						$this->Cell($w[1],10,'LINEA',0,0,'C');
						$this->Cell($w[2],10,'ESTILO',0,0,'C');
						$this->Cell($w[3],10,'COLOR',0,0,'C');
						$this->Cell($w[4],10,'TALLA',0,0,'C');
						//$this->Cell($w[5],10,'COSTO',0,0,'C');
						$this->Cell($w[5],10,'C1',0,0,'C');
						$this->Cell($w[6],10,'C2',0,0,'C');
						$this->Cell($w[7],10,'C1-C2',0,0,'C');
						$this->Cell($w[7],10,'PROVEEDOR',0,0,'C');
						$this->Line(10, 40, 290, 40);
						$this->Ln();
					}
					// Pie de página
					function Footer()
					{
						$this->SetFont('Arial','',8);
						// Posición: a 1,5 cm del final
						$this->SetY(-15);
						// Número de página
						$this->Line(10, 250, 210, 250);
						$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'R');
					}
				}
				$pdf = new PDF('L');
				$fpdf->AddPage('portrait' , 'letter');
				foreach($_POST['lista'] as $selected)
				{
					$code = $selected;
					$sql = "SELECT DISTINCT Z2.*,  ISNULL(Z2.CODBARRAS, -1) AS INDICADOR \n"
						  ."FROM \n"
						  ."( \n"
						  ."	SELECT Z1.CODARTICULO, Z1.REFPROVEEDOR, Z1.TALLA, Z1.COLOR, Z1.CODBARRAS, Z1.BODEGA, Z1.NOMBREALMACEN, SUM(Z1.UNIDADES) AS UNIDADES, \n"
						  ."	Z1.FECHAALTA, Z1.CODVENDEDOR, Z1.VENDEDOR, Z1.UBICACION, Z1.IDZONA, Z1.PASILLO, Z1.LADO, Z1.CODPROVEEDOR, Z1.GONDOLA, \n"
						  ."	Z1.DOCUMENTO, Z1.CODUBICACION, Z1.DEPARTAMENTO, 1 AS ORD  ,SUM( ISNULL(dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 1),0))REV1, \n"
							."SUM( ISNULL(dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 2),0))REV2, \n"
							."SUM( ISNULL(UNIDADES-ISNULL(dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 1),0),0))DIF \n" 
						  ."	FROM \n"
						  ."	( \n"
						  ."		SELECT AR.CODARTICULO, AR.REFPROVEEDOR, ISNULL(AL1.TALLA, ISNULL(AL2.TALLA, AL3.TALLA)) AS TALLA, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)) AS COLOR, \n"
						  ."		A.CODBARRAS, A.BODEGA, B.NOMBREALMACEN, A.UNIDADES AS UNIDADES, CONVERT(DATE, A.FECHAALTA) AS FECHAALTA, ISNULL(V.CODVENDEDOR, 0) AS CODVENDEDOR, \n"
						  ."		V.NOMVENDEDOR AS VENDEDOR, A.CAJAMASTER, A.UBICACION, UB.IDZONA, UB.PASILLO, UB.LADO, P.CODPROVEEDOR, A.GONDOLA, A.DOCUMENTO, UB.CODUBICACION, \n"
						  ."		D.DESCRIPCION AS DEPARTAMENTO \n"
						  ."		FROM JOIN_INVENTARIO_FISICO AS A \n"
						  ."		LEFT JOIN ALMACEN AS B ON (A.BODEGA = B.CODALMACEN COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL1 ON (A.CODBARRAS = AL1.CODBARRAS COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL2 ON (A.CODBARRAS = AL2.CODBARRAS2 COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL3 ON (A.CODBARRAS = AL3.CODBARRAS3 COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOS AS AR ON (AR.CODARTICULO = AL1.CODARTICULO OR AR.CODARTICULO = AL2.CODARTICULO OR AR.CODARTICULO = AL3.CODARTICULO) \n"
						  ."		LEFT JOIN JOIN_UBICACIONES AS UB ON (A.UBICACION = IDUBICACION) \n"
						  ."		LEFT JOIN VENDEDORES AS V ON (A.USUARIO = V.CODVENDEDOR) \n"
						  ."		LEFT JOIN REFERENCIASPROV AS P ON (AR.REFPROVEEDOR = P.REFPROVEEDOR) \n"
						  ."		LEFT JOIN DEPARTAMENTO AS D ON (AR.DPTO = D.NUMDPTO) \n"
						  ."		WHERE (A.DOCUMENTO = ".$code.") \n"
						  ."	) AS Z1 \n"
						  ."	GROUP BY Z1.CODARTICULO, Z1.REFPROVEEDOR, Z1.TALLA, Z1.COLOR, Z1.CODBARRAS, Z1.BODEGA, Z1.NOMBREALMACEN, Z1.FECHAALTA, Z1.CODVENDEDOR, Z1.VENDEDOR,  \n"
						  ."	Z1.UBICACION, Z1.IDZONA, Z1.PASILLO, Z1.LADO, Z1.CODPROVEEDOR, Z1.GONDOLA, Z1.DOCUMENTO, Z1.CODUBICACION, Z1.DEPARTAMENTO \n"
						  ."	UNION ALL \n"
						  ."	SELECT NULL, AR.REFPROVEEDOR, NULL, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)), NULL, NULL, NULL, SUM(A.UNIDADES), NULL, \n"
						  ."	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2 AS ORD ,\n"
						  ."    SUm( ISNULL(dbo.JOIN_INV_REV (A.CODBARRAS , GONDOLA , UBICACION, 1),0))REV1, \n"
						."	SUM(ISNULL(dbo.JOIN_INV_REV (A.CODBARRAS , GONDOLA , UBICACION, 2),0))REV2, \n"
						."	SUM(ISNULL(UNIDADES-ISNULL(dbo.JOIN_INV_REV (A.CODBARRAS , GONDOLA , UBICACION, 1),0),0))DIF\n"
						  ."	FROM JOIN_INVENTARIO_FISICO AS A \n"
						  ."	LEFT JOIN ALMACEN AS B ON (A.BODEGA = B.CODALMACEN COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL1 ON (A.CODBARRAS = AL1.CODBARRAS COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL2 ON (A.CODBARRAS = AL2.CODBARRAS2 COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL3 ON (A.CODBARRAS = AL3.CODBARRAS3 COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOS AS AR ON (AR.CODARTICULO = AL1.CODARTICULO OR AR.CODARTICULO = AL2.CODARTICULO OR AR.CODARTICULO = AL3.CODARTICULO) \n"
						  ."	LEFT JOIN JOIN_UBICACIONES AS UB ON (A.UBICACION = IDUBICACION) \n"
						  ."	LEFT JOIN VENDEDORES AS V ON (A.USUARIO = V.CODVENDEDOR) \n"
						  ."	LEFT JOIN REFERENCIASPROV AS P ON (AR.REFPROVEEDOR = P.REFPROVEEDOR) \n"
						  ."	LEFT JOIN DEPARTAMENTO AS D ON (AR.DPTO = D.NUMDPTO) \n"
						  ."	WHERE (A.DOCUMENTO = ".$code.") \n"
						  ."	GROUP BY AR.REFPROVEEDOR, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)) \n"
						  .") AS Z2 \n"
						  ."ORDER BY Z2.REFPROVEEDOR , Z2.COLOR, Z2.ORD";
					$pa1 = array();
					$op1 = array("scrollable" => SQLSRV_CURSOR_KEYSET);
					$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
					$unidadest = 0;
					while($fila = sqlsrv_fetch_array($re1))
					{
						if ($fila['INDICADOR'] != -1)
						{
							$tienda = $fila['NOMBREALMACEN'];
							$fecha = $fila['FECHAALTA']->format('Y-m-d');
							$gondola = $fila['GONDOLA'];
							$usuario = $fila['VENDEDOR'];
							$gondolaubi = $fila['CODUBICACION'];
							$unidadest = $unidadest + $fila['UNIDADES'];
						}
					}
					// DISEÑO PDF
					$pdf->AliasNbPages();
					$pdf->AddPage('portrait' , 'letter'); 
					// DETALLE Anchuras de las columnas GRID
					$w = array(10, 38, 25, 15, 15, 15, 25, 25);
					$pdf->SetFont('Arial','',14);
					$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
					while($fila = sqlsrv_fetch_array($re1))
					{
						if ($fila['INDICADOR'] == -1)
						{
							$pdf->SetFont('Arial','B',10); 
							$pdf->Cell($w[0],10,'TOTAL',0,0,'C');
							$pdf->Cell($w[1],10,'',0,0,'C');
							$pdf->Cell($w[2],10,'',0,0,'C');
							$pdf->Cell($w[3],10,'',0,0,'C');
							$pdf->Cell($w[4],10,'',0,0,'C');
							$pdf->Cell($w[4],10,''.$fila['UNIDADES'].'',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['REV1'].'',0,0,'C');
							$pdf->Cell($w[5],10,''.$fila['DIF'].'',0,0,'C');
							//$pdf->Cell($w[6],10,'',0,0,'C');
							//$pdf->Cell($w[7],10,'',0,0,'C');
							$pdf->Cell($w[6],10,'',0,0,'C');
						}
						else
						{
							$pdf->SetFont('Arial','',10); 
							$pdf->Cell($w[0],10,''.$fila['BODEGA'].'',0,0,'C');
							$pdf->Cell($w[1],10,''.$fila['DEPARTAMENTO'].'',0,0,'C');
							$pdf->Cell($w[2],10,''.$fila['REFPROVEEDOR'].'',0,0,'C');
							$pdf->Cell($w[3],10,''.$fila['COLOR'].'',0,0,'C');
							$pdf->Cell($w[4],10,''.$fila['TALLA'].'',0,0,'C');
							$pdf->Cell($w[5],10,''.$fila['UNIDADES'].'',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['REV1'].'',0,0,'C');
							$pdf->Cell($w[5],10,''.$fila['DIF'].'',0,0,'C');
							//$pdf->Cell($w[7],10,'0.00',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['CODPROVEEDOR'].'',0,0,'C');
						}
						$pdf->Ln();
					}
				}
				$pdf->Output();
			}
		}
		else
		{
			// conexión
			$servername = $svr_servidor;
			$conectioninfo = array("Database"=>$svr_base, "UID"=>$svr_usuario, "PWD"=>$svr_contrasena, "CharacterSet"=>"UTF-8");
			$conexion = sqlsrv_connect($servername, $conectioninfo);
			if ($conexion == false)
			{
				$mensaje = "Existe un error al intentar conectarse con el servidor...";
			}
			else
			{
				require('fpdf.php');
				class PDF extends FPDF
				{
					// Cabecera de página
					function Header()
					{
						global $code;
						global $tienda;
						global $fecha;
						global $gondola;
						global $gondolaubi;
						global $unidadest;
						global $usuario;
						$cvV01 = date("F j, Y, g:i a");
						$this->SetFont('Arial','',18);
						$this->Text(10,10,'INVENTARIO FISICO');
						$this->SetFont('Arial','',12);
						$this->Cell(280,1,'Concepto "A" INVENTARIO FISICO CD '.$tienda,0,0,'C');
						$this->Text(10,16,'DOCUMENTO # '.$code);
						$this->Text(10,22,'GONDOLA # '.$gondola.' / UBN.: '.$gondolaubi);
						$this->Text(10,28,'TOTAL UNIDADES: '.$unidadest);
						$this->Text(150,16,'SALDOS A FECHA: '.$fecha);
						$this->Text(150,22,'USUARIO: '.$usuario);
						$this->Text(150,28,''.$cvV01.'',0,0,'R');
						$this->Line(10, 30, 210, 30);
						$this->Ln(20);
						$w = array(27, 6, 24, 14, 18, 15, 23, 25, 30);
						$this->Cell($w[0],10,'CAJA MASTER',0,0,'C');
						$this->Cell($w[0],10,'BOD',0,0,'C');
						$this->Cell($w[1],10,'LINEA',0,0,'C');
						$this->Cell($w[2],10,'ESTILO',0,0,'C');
						$this->Cell($w[3],10,'COLOR',0,0,'C');
						$this->Cell($w[4],10,'TALLA',0,0,'C');
						$this->Cell($w[5],10,'COSTO',0,0,'C');
						$this->Cell($w[6],10,'CANTIDAD',0,0,'C');
						$this->Cell($w[7],10,'REV1',0,0,'C');
						$this->Cell($w[8],10,'DIF',0,0,'C');
					//	$this->Cell($w[9],10,'PROVEEDOR',0,0,'C');
						$this->Line(10, 40, 210, 40);
						$this->Ln();
					}
					// Pie de página
					function Footer()
					{
						$this->SetFont('Arial','',8);
						// Posición: a 1,5 cm del final
						$this->SetY(-15);
						// Número de página
						$this->Line(10, 253, 210, 253);
						$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'R');
					}
				}
				$pdf = new PDF('L');
				foreach($_POST['lista'] as $selected)
				{
					$code = $selected;
					$sql = "SELECT DISTINCT Z2.*, ISNULL(dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 1),0)REV1 , dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 2)REV2  , UNIDADES-ISNULL(dbo.JOIN_INV_REV (CODBARRAS , GONDOLA , UBICACION, 1),0)DIF ,ISNULL(Z2.CODBARRAS, -1) AS INDICADOR \n"
						  ."FROM \n"
						  ."( \n"
						  ."	SELECT Z1.CAJAMASTER, Z1.CODARTICULO, Z1.REFPROVEEDOR, Z1.TALLA, Z1.COLOR, Z1.CODBARRAS, Z1.BODEGA, Z1.NOMBREALMACEN, SUM(Z1.UNIDADES) AS UNIDADES, \n"
						  ."	Z1.FECHAALTA, Z1.CODVENDEDOR, Z1.VENDEDOR, Z1.UBICACION, Z1.IDZONA, Z1.PASILLO, Z1.LADO, Z1.CODPROVEEDOR, Z1.GONDOLA, \n"
						  ."	Z1.DOCUMENTO, Z1.CODUBICACION, Z1.DEPARTAMENTO, 1 AS ORD \n"
						  ."	FROM \n"
						  ."	( \n"
						  ."		SELECT AR.CODARTICULO, AR.REFPROVEEDOR, ISNULL(AL1.TALLA, ISNULL(AL2.TALLA, AL3.TALLA)) AS TALLA, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)) AS COLOR, \n"
						  ."		A.CODBARRAS, A.BODEGA, B.NOMBREALMACEN, A.UNIDADES AS UNIDADES, CONVERT(DATE, A.FECHAALTA) AS FECHAALTA, ISNULL(V.CODVENDEDOR, 0) AS CODVENDEDOR, \n"
						  ."		V.NOMVENDEDOR AS VENDEDOR, A.CAJAMASTER, A.UBICACION, UB.IDZONA, UB.PASILLO, UB.LADO, P.CODPROVEEDOR, A.GONDOLA, A.DOCUMENTO, UB.CODUBICACION, \n"
						  ."		D.DESCRIPCION AS DEPARTAMENTO \n"
						  ."		FROM JOIN_INVENTARIO_FISICO AS A \n"
						  ."		LEFT JOIN ALMACEN AS B ON (A.BODEGA = B.CODALMACEN COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL1 ON (A.CODBARRAS = AL1.CODBARRAS COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL2 ON (A.CODBARRAS = AL2.CODBARRAS2 COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOSLIN AS AL3 ON (A.CODBARRAS = AL3.CODBARRAS3 COLLATE Latin1_General_CS_AI) \n"
						  ."		LEFT JOIN ARTICULOS AS AR ON (AR.CODARTICULO = AL1.CODARTICULO OR AR.CODARTICULO = AL2.CODARTICULO OR AR.CODARTICULO = AL3.CODARTICULO) \n"
						  ."		LEFT JOIN JOIN_UBICACIONES AS UB ON (A.UBICACION = IDUBICACION) \n"
						  ."		LEFT JOIN VENDEDORES AS V ON (A.USUARIO = V.CODVENDEDOR) \n"
						  ."		LEFT JOIN REFERENCIASPROV AS P ON (AR.REFPROVEEDOR = P.REFPROVEEDOR) \n"
						  ."		LEFT JOIN DEPARTAMENTO AS D ON (AR.DPTO = D.NUMDPTO) \n"
						  ."		WHERE (A.DOCUMENTO = ".$code.") \n"
						  ."	) AS Z1 \n"
						  ."	GROUP BY Z1.CAJAMASTER, Z1.CODARTICULO, Z1.REFPROVEEDOR, Z1.TALLA, Z1.COLOR, Z1.CODBARRAS, Z1.BODEGA, Z1.NOMBREALMACEN, Z1.FECHAALTA, Z1.CODVENDEDOR, Z1.VENDEDOR,  \n"
						  ."	Z1.UBICACION, Z1.IDZONA, Z1.PASILLO, Z1.LADO, Z1.CODPROVEEDOR, Z1.GONDOLA, Z1.DOCUMENTO, Z1.CODUBICACION, Z1.DEPARTAMENTO \n"
						  ."	UNION ALL \n"
						  ."	SELECT NULL, NULL, AR.REFPROVEEDOR, NULL, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)), NULL, NULL, NULL, SUM(A.UNIDADES), NULL, \n"
						  ."	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2 AS ORD \n"
						  ."	FROM JOIN_INVENTARIO_FISICO AS A \n"
						  ."	LEFT JOIN ALMACEN AS B ON (A.BODEGA = B.CODALMACEN COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL1 ON (A.CODBARRAS = AL1.CODBARRAS COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL2 ON (A.CODBARRAS = AL2.CODBARRAS2 COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOSLIN AS AL3 ON (A.CODBARRAS = AL3.CODBARRAS3 COLLATE Latin1_General_CS_AI) \n"
						  ."	LEFT JOIN ARTICULOS AS AR ON (AR.CODARTICULO = AL1.CODARTICULO OR AR.CODARTICULO = AL2.CODARTICULO OR AR.CODARTICULO = AL3.CODARTICULO) \n"
						  ."	LEFT JOIN JOIN_UBICACIONES AS UB ON (A.UBICACION = IDUBICACION) \n"
						  ."	LEFT JOIN VENDEDORES AS V ON (A.USUARIO = V.CODVENDEDOR) \n"
						  ."	LEFT JOIN REFERENCIASPROV AS P ON (AR.REFPROVEEDOR = P.REFPROVEEDOR) \n"
						  ."	LEFT JOIN DEPARTAMENTO AS D ON (AR.DPTO = D.NUMDPTO) \n"
						  ."	WHERE (A.DOCUMENTO = ".$code.") \n"
						  ."	GROUP BY AR.REFPROVEEDOR, ISNULL(AL1.COLOR, ISNULL(AL2.COLOR, AL3.COLOR)) \n"
						  .") AS Z2 \n"
						  ."ORDER BY Z2.REFPROVEEDOR, Z2.COLOR, Z2.ORD, Z2.CAJAMASTER";
					$pa1 = array();
					$op1 = array("scrollable" => SQLSRV_CURSOR_KEYSET);
					$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
					$unidadest = 0;
					while($fila = sqlsrv_fetch_array($re1))
					{
						if ($fila['INDICADOR'] != -1)
						{
							$tienda = $fila['NOMBREALMACEN'];
							$fecha = $fila['FECHAALTA']->format('Y-m-d');
							$gondola = $fila['GONDOLA'];
							$usuario = $fila['VENDEDOR'];
							$unidadest = $unidadest + $fila['UNIDADES'];
							$gondolaubi = $fila['CODUBICACION'];
						}
					}
					// DISEÑO PDF
					$pdf->AliasNbPages();
					$pdf->AddPage('portrait' , 'letter');
					// DETALLE Anchuras de las columnas GRID
					$w = array(25, 12, 25, 11, 18, 20, 20, 30, 30);
					$pdf->SetFont('Arial','',14);
					$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
					while($fila = sqlsrv_fetch_array($re1))
					{
						if ($fila['INDICADOR'] == -1)
						{
							$pdf->SetFont('Arial','B',10); 
							$pdf->Cell($w[1],10,'',0,0,'C');
							$pdf->Cell($w[1],10,'',0,0,'C');
							$pdf->Cell($w[0],10,'TOTAL',0,0,'C');
							$pdf->Cell($w[1],10,'',0,0,'C');
							$pdf->Cell($w[2],10,'',0,0,'C');
							$pdf->Cell($w[3],10,'',0,0,'C');
							$pdf->Cell($w[4],10,'',0,0,'C');
							$pdf->Cell($w[5],10,'',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['UNIDADES'].'',0,0,'C');
							$pdf->Cell($w[7],10,'',0,0,'C');
							$pdf->Cell($w[6],10,'',0,0,'C');
						}
						else
						{
							$pdf->SetFont('Arial','',10);
							$pdf->Cell($w[0],10,''.$fila['CAJAMASTER'].'',0,0,'C');
							$pdf->Cell($w[0],10,''.$fila['BODEGA'].'',0,0,'C');
							$pdf->Cell($w[1],10,''.$fila['DEPARTAMENTO'].'',0,0,'C');
							$pdf->Cell($w[2],10,''.$fila['REFPROVEEDOR'].'',0,0,'C');
							$pdf->Cell($w[3],10,''.$fila['COLOR'].'',0,0,'C');
							$pdf->Cell($w[4],10,''.$fila['TALLA'].'',0,0,'C');
							$pdf->Cell($w[5],10,'0.00',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['UNIDADES'].'',0,0,'C');
							//$pdf->Cell($w[7],10,'0.00',0,0,'C');
							$pdf->Cell($w[7],10,''.$fila['REV1'].'',0,0,'C');
							$pdf->Cell($w[6],10,''.$fila['DIF'].'',0,0,'C');
						}
						$pdf->Ln();
					}
				}
				$pdf->Output();
			}
		}
	}
?>