<?php 

session_start();   
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);

ini_set('memory_limit','2048M');
ini_set('max_execution_time','0');

function error($tipo){

		switch($tipo){				
			case 'tamaño_fila':
				$mensaje = 'ERROR DE TABLA: El tamaño de la fila es mas grande que el de la página.';
				break;		
		}
		
		 print "<script language=JavaScript>";
		 print "alert('".$mensaje."');";
		 print "close();";		
		 print "</script>";	
		 exit();

}

function columna($id,$dato,$prop,$textalign='L',$valign='T'){
	
	global $pdf,$margen_tabla,$ancho,$altura;
	// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0, $valign='T', $fitcell=false,opciones_adicionales)
	$pdf->MultiCell($ancho[$id], $prop['alturamaxima'], utf8_encode($dato), 1, $textalign, 1, 0, '', '', true, 0, true, false, 0, $valign,false,$prop);
	if($pdf->saltopag){return false;}
	$altura[$id]=$pdf->altura_celda;
	
	return $altura;

}

function procesar_fila($datos){
		
		global $pdf,$margen_tabla,$ancho;
		
		$altura_pagina = $pdf->getPageHeight();
		$prop['alturamaxima']=3;
		$prop['check_pagebreak']=0;
		
		$pdf->startMultipleTransaction();								
		$prop['alturamaxima'] = fila($datos,$prop);
		if($prop['alturamaxima']>$altura_pagina){error('tamaño_fila');}
		$salto = $pdf->saltopag;									
		$pdf = $pdf->rollbackMultipleTransaction();
						
		if($salto){
			$pdf->AddPage();
			encabezado();
			$pdf->startMultipleTransaction();											
			$prop['alturamaxima'] = fila($datos,$prop);													
			$pdf = $pdf->rollbackMultipleTransaction();
			$salto = 0;		
		}
		
		
		$pdf->startMultipleTransaction();
		$pagina = $pdf->getPage();
		
		fila($datos,$prop);
		
		$pagina2 = $pdf->getPage();				
		if($pagina!=$pagina2){
			
				$pdf = $pdf->rollbackMultipleTransaction();									
				$pdf->AddPage();
				encabezado();
				fila($datos,$prop);											
		}	
		else{					  
														
				$pdf->commitMultipleTransaction();
		} 

}

	
$ruta = '../../../';

include("../clases/covensol_cor_c_srh.php");
$objsrh = new covensol_cor_c_srh();
	
require_once('../../../shared/tcpdf_new/config/lang/ita.php');
require_once('../../../shared/tcpdf_new/tcpdf_rep.php');  
//error_reporting(E_ALL);
//set_time_limit(18000);


$parametros = array();
//$objsrh->io_conexiones->decodificar_get();
$parametros = $objsrh->io_conexiones->asignar_get();

//$datos_encabezado = '<p  style="text-align:rigth;"><b> '.'FECHA Y HORA: </b>'.date('d/m/Y').' - '.date('H:i').'<br/><b>BD: </b>'.$_SESSION['ls_database'].'<br/><b>USUARIO: </b>'.$_SESSION['la_logusr'].'</p>';
$datos_encabezado='';
$pdf = new TCPDFREP('LANDSCAPE', PDF_UNIT, 'LETTER', true, 'UTF-8', false);
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$pdf->setHeaderFont(array('', '', 8));
$pdf->ancho_logo =80;
$pdf->alto_logo =20;
$pdf->SetHeaderData('../imagenes/ivss.jpg', $_SESSION["ls_width"], '', $datos_encabezado);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);		
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setPrintHeader(true);
//$pdf->setTextoFooter(utf8_encode(''));
$pdf->SetLineStyle(array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(200, 200, 200))); 
$pdf->AddPage();

$pdf->color_fondo('#FFFFFF');
$pdf->SetFont('helvetica', '', 6);
$titulo = '<b>RELACIÓN DE NOVEDADES</b> ';	
$pdf->writeHTMLCell(235, '', '', '', '', 0, 0, 1, true, 'C', true);
$pdf->SetFont('helvetica', '', 5);
$pdf->writeHTMLCell(15, '', '', '', 'FORMA: 14-10', 0, 1, 1, true, 'C', true);
$pdf->writeHTMLCell(235, '', '', '', '', 0, 0, 1, true, 'C', true);
$pdf->SetFont('helvetica', '', 6);
$pdf->writeHTMLCell(15, '', '', '', 'PÁGINA', 1, 1, 1, true, 'C', true);
$pdf->SetFont('helvetica', '', 10);
$pdf->writeHTMLCell(235, '', '', '', $titulo, 0, 0, 1, true, 'C', true);
$pdf->SetFont('helvetica', '', 6);
//$pdf->writeHTMLCell(15, '', '', '', $pdf->getPage().'/'.$pdf->getNumPages(), 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(15, '', '', '', '___/___', 1, 0, 1, true, 'C', true);		

//$tit_rep = '<p  style="text-align:center;">'.$titulo.'</p>';
//$pdf->writeHTML($tit_rep, true, false, false, false, '');

$pdf->SetFont('helvetica', '', 8);



$ancho[1] = 20;
$ancho[2] = 20;
$ancho[3] = 20;
$ancho[4] = 60;
$ancho[5] = 20;
$ancho[6] = 20;
$ancho[7] = 20;
$ancho[8] = 65;

$ancho_total = array_sum($ancho);
$margen_tabla=1;	
$mensaje="";
$param['tamaño_letra']=6;

$pdf->SetFont('helvetica', '', 5);
$pdf->Ln();
$PERIODO = '<p  style="text-align:center;">CORRESPONDIENTE AL PERÍODO COMPRENDIDO ENTRE LAS FECHAS: </p>';
//$pdf->writeHTML($PERIODO, true, false, false, false, '');
$pdf->Ln();
$pdf->color_fondo('#FFFFFF');
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)
$pdf->writeHTMLCell(185, '', '', '', '', 0, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'DIA', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'MES', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'AÑO', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(5, '', '', '', '', 'L', 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'DIA', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'MES', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', 'AÑO', 1, 1, 1, true, 'C', true);

$pdf->writeHTMLCell(185, '', '', '', '<b>CORRESPONDIENTE AL PERÍODO COMPRENDIDO ENTRE LAS FECHAS:</b>', 0, 0, 1, true, 'R', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(5, '', '', '', 'Y', 'L', 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);
$pdf->writeHTMLCell(10, '', '', '', '', 1, 0, 1, true, 'C', true);;
$pdf->Ln();
$pdf->Ln();



$tabla_detalle = '<tr>
					<td height="20" width="50"></td>
					<td width="50"></td>
					<td width="50"></td>
					<td width="50"></td>
					<td width="220"></td>
					<td width="180"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="31.25" align="center"></td>
					<td width="20" align="center"></td>
					<td width="20" align="center">3</td>
				  </tr>';
				  
for($i=1;$i<=15;$i++){
	$tabla_detalle_tot .= $tabla_detalle;

}				  
			  
$TablaPrincipal = '<table cellspacing="0" cellpadding="3" border="1">
                  <tr>
					<td colspan="4"  rowspan="2" width="200" align="center"><p><br />SALARIO O SUELDO</p></td>
					<td width="220" align="center">PATRONO O EMPRESA</td>
					<td width="180" align="center">NUMERO DE EMPRESA</td>
					<td width="250" align="center">LAPSOS DE INTERRUPCIÓN</td>
					<td width="40" align="center">USO IVSS</td>
				  </tr>
				  <tr>
					<td height="20" width="220"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="20"></td>
					<td width="125" align="center" >PERMISO NO REMUNERADO</td>
					<td width="125" align="center" >PERIODO EN REPOSO</td>
					<td width="20" rowspan="3">C/N</td>
					<td width="20" rowspan="3">C O D. </td>
									
				  </tr>
				  <tr>					
					<td colspan="2" align="center" width="100">SEMANAL</td>
					<td colspan="2" align="center" width="100">MENSUAL</td>
					<td  width="220" align="center" rowspan="2"><p><br />APELLIDOS Y NOMBRES</p></td>
					<td  width="180" align="center" rowspan="2"><p><br />N° DE ASEGURADO</p></td>
					<td colspan="2" align="center" width="62.5">DESDE</td>
					<td colspan="2" align="center" width="62.5">HASTA</td>
					<td colspan="2" align="center" width="62.5">DESDE</td>
					<td colspan="2" align="center" width="62.5">HASTA</td>
				  </tr>
				  <tr>
					<td width="50" align="center">ANTERIOR</td>
					<td width="50" align="center">ACTUAL</td>
					<td width="50" align="center">ANTERIOR</td>
					<td width="50" align="center">ACTUAL</td>
					<td width="31.25">DIA</td>
					<td width="31.25">MES</td>
					<td width="31.25">DIA</td>
					<td width="31.25">MES</td>
					<td width="31.25">DIA</td>
					<td width="31.25">MES</td>
					<td width="31.25">DIA</td>
					<td width="31.25">MES</td>
				  </tr>
				'.$tabla_detalle_tot.'  
				 
				</table>';
$pdf->SetLineStyle(array('width' => 0.85 / $pdf->getScaleFactor(), 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
$pdf->writeHTML($TablaPrincipal, true, false, false, false, '');

/*
$tabla1 = '<table cellspacing="0" cellpadding="3" border="1">
					  <tr>
						<td width="100" height="25"></td>
						<td width="130"  height="25" rowspan="2"></td>
					  </tr>
					  <tr>
						<td height="25"></td>
					  </tr>
						
		   </table>
';
$pdf->writeHTML($tabla1, false, false, false, false, '');
*/

$tabla2 = '<table cellspacing="0" cellpadding="3" border="1">
					  <tr>
						<td width="130" rowspan="2" align="left"><p>LUGAR:<br /><br /><br /><br />FECHA:</p></td>
						<td width="160" align="center">PATRONO O REPRESENTANTE LEGAL</td>						
						<td width="160" align="center">RECIBIDO EN EL IVSS</td>
						<td width="120" colspan="3" align="center">FECHA</td>						
						<td width="160" align="center">CODIFICADO</td>
						<td width="160" align="center">CRITICADO</td>
					  </tr>
					  <tr>
						<td width="160" align="center"><p><br /><br /><br /><br /><br />FIRMA Y SELLO</p></td>
						<td height="55" width="160">&nbsp;</td>						
						<td width="40">&nbsp;</td>
						<td width="40">&nbsp;</td>
						<td width="40">&nbsp;</td>
						<td width="160">&nbsp;</td>
						<td width="160">&nbsp;</td>
					  </tr>
			</table> 
 ';
$pdf->writeHTML($tabla2, true, false, false, false, '');

$pdf->SetFont('helvetica', '', 6);
$pie = 'Este Formulario está autorizado por el IVSS y válido únicamente para ser consignado en las oficinas administrativas<br />
<b>EL FORMULARIO Y SU TRAMITACION SON COMPLETAMENTE GRATUITOS</b><br />
www.ivss.gov.ve';
$pdf->writeHTMLCell(240, '', '', '', $pie, 0, 1, 1, true, 'C', true);

$pdf->Output('reporte.pdf', 'I');























?>