<?php
require('../fpdf.php');
include ("../../Conexion.php");

$UsuEn=$_POST['USUkp'] or $UsuEn=$_GET['USUkp'];
$UsuAImp=strtoupper($_POST['USUkp']) or $UsuAImp=strtoupper($_GET['USUkp']);
$NoDocuSurEn=$_POST['DocSurKP'] or $NoDocuSurEn=$_GET['DocSurKP'];

if ($UsuEn=="")
		{
		echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=RedireccionDeCierre.php' target='_parent'>";
		}

/////////IDENTIFICAR DATOS DE NIVEL///////
		$sql = mysql_query("select * from tabla_usuarios where USUARION='$UsuEn'");
						
	if (mysql_numrows($sql)==0) echo "";
		else{
		$registro=mysql_fetch_array($sql);
		}
		if (mysql_numrows($sql)>0)
		{
		$CNiv=$registro["NIVEL"];
		}
			
	if ($CNiv<>"01" and $CNiv<>"02" and $CNiv<>"04" and $CNiv<>"05")
		{
		echo "<script>alert('No estas autorizado para acceder a este módulo del WMS');</script>";
		echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=RedireccionDeCierre.php'>";
		}

class MiPDF extends FPDF {

		public function Header(){
		
		
			$this -> Image ("../../../WMS_Resources/Imagenes/Logo_Rectangu_Transp.png" , 10 , 10 , 30 ,15);
			$this -> SetFont ( 'Arial' , 'B', '12');
			$this -> Cell ( 180, 10 , '|| Auditoria Manual ||' , 0 , 0 , 'C');
			$this -> Ln ( 2 );
			$this -> SetFont ( 'Arial' , 'I', '10');
			$this -> Cell ( 180, 20 , 'www.logsyswms.com' , 0 , 0 , 'C');
			$this -> Ln ( 4 );
			$this -> SetTextColor (0 , 136 , 29);
			$this -> SetFont ( 'Arial' , '', '10');
			$this -> Cell ( 180, 20 , '_______________________________________________________________________________________________' , 0 , 0 , 'C');
			$this -> Ln ( 3 );
			$this -> SetFont ( 'Arial' , '', '10');
			$this -> Cell ( 180, 20 , '_____________________________________________' , 0 , 0 , 'C');
			$this -> Ln ( 20 );
		}
		
	    function Footer(){
    		// Posición: a 2,0 cm del final
    		$this->SetY(-20);
    		// Arial italic 8
    		$this->SetFont('Arial','I',8);
    		// Número de página
    		$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'C');
		}
}

	$mipdf = new MiPDF();

	$mipdf -> AliasNbPages();
	$mipdf -> addPage();
	
//////////////////////////////////CONSULTAR LA TABLA DEL CONTRATANTE////////////////////////////////////////////
		$sql = mysql_query("select * from tabla_contratante");
						
	if (mysql_numrows($sql)==0) echo "";
		else{
		$registro=mysql_fetch_array($sql);
		}
		if (mysql_numrows($sql)>0)
		{
		$CNomContra=$registro["NOMBRE_FISCAL"];
		$CNomCuenta=$registro["CUENTA"];
		}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////INFORMACIÓN PRINCIPAL////////////////////////////////////////////////////////////////
	
	$CInfPrin_Contra = "P. LOGISTICO:";
	$CInfPrin_Cuen = "CUENTA:";
	$CInfPrin_Doc = "DOCUMENTO:";
	$CInfPrin_Comple = "DOC. COMPLEMENTO:";
	$CInfPrin_Prov = "PROVEEDOR:";
	$CInfPrin_Fecha = "FECHA:";
	$CInfPrin_Usu = "USUARIO:";
	
	
	$mipdf -> SetFont ( 'Courier' , '', '8');
	$mipdf -> SetTextColor (255 , 255 , 255);
	$mipdf -> SetFillColor ( 76 , 100 , 191 );
	$mipdf -> Cell ( 30 , 3 , $CInfPrin_Contra, 1 , 0 , 'L' , true );
	$mipdf -> SetTextColor (0 , 0 , 0);
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	$mipdf -> Cell ( 90 , 3 , $CNomContra, 1 , 0 , 'L' , true );
	$mipdf -> Ln ( 3 );////////////////////////////////////////////////////////
	$mipdf -> SetTextColor (255 , 255 , 255);
	$mipdf -> SetFillColor ( 76 , 100 , 191 );
	$mipdf -> Cell ( 30 , 3 , $CInfPrin_Cuen, 1 , 0 , 'L' , true );
	$mipdf -> SetTextColor (0 , 0 , 0);
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	$mipdf -> Cell ( 90 , 3 , $CNomCuenta, 1 , 0 , 'L' , true );
	$mipdf -> Ln ( 3 );////////////////////////////////////////////////////////
	$mipdf -> SetTextColor (255 , 255 , 255);
	$mipdf -> SetFillColor ( 76 , 100 , 191 );
	$mipdf -> Cell ( 30 , 3 , $CInfPrin_Doc, 1 , 0 , 'L' , true );
	$mipdf -> SetTextColor (0 , 0 , 0);
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	$mipdf -> Cell ( 90 , 3 , $NoDocuSurEn, 1 , 0 , 'L' , true );
	$mipdf -> Ln ( 3 );////////////////////////////////////////////////////////
	$mipdf -> SetTextColor (255 , 255 , 255);
	$mipdf -> SetFillColor ( 76 , 100 , 191 );
	$mipdf -> Cell ( 30 , 3 ,$CInfPrin_Usu, 1 , 0 , 'L' , true );
	$mipdf -> SetTextColor (0 , 0 , 0);
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	$mipdf -> Cell ( 90 , 3 , $UsuAImp, 1 , 0 , 'L' , true );

	
//////////////////////////FIN INFORMACIÓN PRINCIPAL///////////////////////////////////////////////////////////	

	$cabeceraID = "ID";
	$cabeceraDOCU = "DOCUMENTO";
	$cabeceraSKU = "SKU";
	$cabeceraLOT = "LOTE";
	$cabeceraOBS = "DESCRIPCIÓN";
	$cabeceraAL = "P. AUDITADAS";	

	$mipdf -> Ln ( 10 );
	$mipdf -> SetFont ( 'Courier' , '', '6');
	$mipdf -> SetTextColor (255 , 255 , 255);
	$mipdf -> SetFillColor ( 76 , 100 , 191 );

	$mipdf -> Cell ( 6 , 3 , $cabeceraID, 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 24 , 3 , $cabeceraDOCU, 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 25 , 3 , $cabeceraSKU, 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 25 , 3 , $cabeceraLOT, 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 85 , 3 , $cabeceraOBS, 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 16 , 3 , $cabeceraAL, 1 , 0 , 'C' , true );

	$mipdf -> Ln ( 3 );

$consulta = mysql_query ( "select * from tabla_detalledocsur WHERE NO_DOCUMENTO='$NoDocuSurEn' ORDER BY ID  ASC" );

$ID = "0";
while ( $datos = mysql_fetch_array( $consulta ) )
{
	$ID = $ID + 1;
	$SKU = $datos [ 'SKU' ];
	$DESC = $datos [ 'DESCRIPCION' ];
	$LOTC = $datos [ 'LOTE' ];

	
	$mipdf -> SetFont ( 'Courier' , '', '7');
	$mipdf -> SetTextColor (0 , 0 , 0 );
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	
	$mipdf -> Cell ( 6 , 3 , $ID , 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 24 , 3 , $NoDocuSurEn , 1 , 0 , 'L' , true );
	$mipdf -> Cell ( 25 , 3 , $SKU , 1 , 0 , 'L' , true );
	$mipdf -> Cell ( 25 , 3 , $LOTC , 1 , 0 , 'L' , true );
	$mipdf -> Cell ( 85 , 3 , $DESC , 1 , 0 , 'L' , true );
	$mipdf -> Cell ( 16 , 3 , $SN , 1 , 0 , 'C' , true );

	$mipdf -> Ln ( 3 );
}

	$mipdf -> Ln ( 0 );
	$mipdf -> SetFont ( 'Courier' , 'B', '8');
	$mipdf -> SetFillColor ( 208 , 72 , 69 );
	$mipdf -> SetTextColor (255 , 255 , 255);
	$TDC= "Total: ".$ID;
	$mipdf -> Cell ( 6 , 3 , '' , 0 , 0 , 'C' , true );
	$mipdf -> Cell ( 24 , 3 , $TDC, 0 , 0 , 'C' , true );
	$mipdf -> Cell ( 60 , 3 , '' , 0 , 0 , 'L' , true );
	$mipdf -> Cell ( 16 , 3 , '' , 0 , 0 , 'L' , true );
	$mipdf -> Cell ( 16 , 3 , '' , 0 , 0 , 'L' , true );
	$mipdf -> Cell ( 16 , 3 , $SN , 0 , 0 , 'C' , true );
	$mipdf -> Cell ( 16 , 3 , $SN , 0 , 0 , 'C' , true );
	$mipdf -> Cell ( 22 , 3 , '' , 0 , 0 , 'C' , true );
	$mipdf -> Cell ( 5 , 3 , '' , 0 , 0 , 'C' , true );

//////////////////////IMPRIME EL AREA DE FIRMAS///////////////////////////////////////////////////////////////////////////
	$mipdf -> Ln ( 20 );
	$mipdf -> SetFont ( 'Courier' , 'B', '8');
	$mipdf -> SetFillColor ( 255 , 255 , 255 );
	$mipdf -> SetTextColor (0 , 0 , 0);
	$mipdf -> Cell ( 47 , 3 , 'ENTREGA' , 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 47 , 3 , 'AUDITA', 1 , 0 , 'C' , true );
	$mipdf -> Cell ( 47 , 3 , 'CAPTURA' , 1 , 0 , 'C' , true );
	$mipdf -> SetFont ( 'Courier' , 'B', '5');
	$mipdf -> Cell ( 47 , 3 , 'www.logsyswms.com' , 1 , 0 , 'C' , true );
	
	$mipdf -> SetTextColor (0 , 0 , 0);
	
$mipdf -> Output();

?>
