<?php session_start();?>
<?php include('php_gene1.php'); ?>
<?php include('../_cfg/config.php');?>
<?php include('php_session.php');?>
<?php //include('excel_reader2.php');?>
<?php //include('vrreadxls.php');?>
<?php include('simplexlsx.class.php');?>
<?php $docu=$_POST['docu']; ?>
<?php $grupo=$_POST['grupo']; ?>
<?php $enti=$_POST['enti']; ?>
<?php $anio=$_POST['anio']; ?>
<?php $mes=$_POST['mes']; ?>
<?php $modif=$_POST['modif']; ?>
<?php $grupo=intval($grupo); ?>
<?php
function rpc_full($grupo,$enti)
{
	include('../_cfg/config.php');
 	include('php_session.php');
	
	$papersize=$ps_a4;
	$xfontsize=16;
	
	$screensize=12;
	$printsize=32;
	
	ob_start();

// $grupo=1;
// $enti='';
	
	$enti_sql='select *  ';
	$enti_sql.='from enti00 where 1=1';
// 	$jwib_sql.='and enti_cong="'.$_SESSION['user_codigo'].'"';
	if($grupo!=''){$enti_sql.=' and enti_zsub="'.$grupo.'"';}
	if($enti!=''){$enti_sql.=' and enti_codigo="'.$enti.'"';}
	$enti_sql.=' order by enti_zsub, enti_descri ';
// 	$enti_res=msql_query($enti_sql,$link_vcrx);
// echo $enti_sql;
?>
	
<?php //////////////////////////////////////////////////////////	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php //////////////////////////////////////////////////////////	?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $grupo.'-'.r_fiel('enti',$enti); ?></title>
	
<style type="text/css">
/* body{ font-family:"Courier New", Courier, monospace;} */
@media print {.noprint {display:none}}
@media screen{.noscreen {display:none}}
	
@page
{
/* size:<?php echo $papersize; ?>; */
size:A5 ;
margin: 10mm 10mm 10mm 10mm; /* 	top right bottom left */
/* font-size: 24px; */
/* 	@body{font-size: 16pt;}	 */
}

p.saltodepagina
{page-break-after: always;}

</style>
	
	
</head>
<?php //////////////////////////////////////////////////////////	?>

<?php //////////////////////////////////////////////////////////	?>
<body>
		
	<?php $xfontsize=$screensize; ?>
<?php	$enti_res=msql_query($enti_sql,$link_vcrx); ?>

<?php $lenti= '';?>		
<?php while($enti_aso=msql_fetch_assoc($enti_res)){?>
<?php //$lenti= $enti_aso['enti_codigo'];?>		
<div id="s21s" valign="top" style="width:140mm; border:solid 0px; font-family:arial;" >
<br>
<div align="center" style="font-weight:bolder;">REGISTRO DE PUBLICADOR DE LA CONGREGACION</div>	
<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
	<tr style="font-size:<?php echo $xfontsize; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
		<td style="font-weight:bolder;">Nombre:</td>
		<td colspan="1"><?php echo $enti_aso['enti_descri'] ;?></td>
		<td style="font-weight:bolder;" align="right"><?php  if($enti_aso['enti_sexo']==2){echo 'MUJER';}else{echo 'HOMBRE';};?></td>
		<td align="right"><?php echo '/'.$enti_aso['enti_cargo'];?></td>
	</tr>	
	<tr style="font-size:<?php echo $xfontsize; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
		<td style="font-weight:bolder;">Dirección:</td>
		<td colspan="1"><?php echo $enti_aso['enti_calle1'].' - '.$enti_aso['enti_calle2'] ;?></td>
		<td style="font-weight:bolder;" align="right"><?php echo 'Grupo : '.$enti_aso['enti_zsub'] ;?></td>
		<td align="right"><?php echo '/'.$enti_aso['enti_csub'];?></td>
	</tr>	
	<tr style="font-size:<?php echo $xfontsize; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
		<td style="font-weight:bolder;">Teléfono:</td>
		<td><?php echo $enti_aso['enti_telefono'] ;?></td>
		<td style="font-weight:bolder;" align="right">Fec.Nacimiento:</td>
		<td><?php echo $enti_aso['enti_fechanacdmy'].' ('.$enti_aso['enti_edad'].')' ;?></td>
	</tr>	
	<tr style="font-size:<?php echo $xfontsize; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
		<td style="font-weight:bolder;">Móvil:</td>
		<td><?php echo $enti_aso['enti_celular'] ;?></td>
		<td style="font-weight:bolder;"align="right">Fec.Bautismo:</td>
		<td><?php echo $enti_aso['enti_fechainidmy'].' ('.$enti_aso['enti_anti'].')' ?></td>
	</tr>	
	<tr style="font-size:<?php echo $xfontsize; ?>px; border-top:solid 1px; border-bottom:solid 1px;">
		<td style="font-weight:bolder;">E-mail:</td>
		<td><?php echo $enti_aso['enti_email'];?></td>
		<td></td>
		<td align="right">O.O.</td>
	</tr>	
</table>

	<?php{
	$rpc1_sql='select jwrt11.*,';
				$rpc1_sql.=' case when fmes>=9 then fanio+1 else fanio end as faniot';
				$rpc1_sql.=' from jwrt11';
				$rpc1_sql.=' where enti="'.$enti_aso['enti_codigo'].'"';
// 				$rpc1_sql.=' order by fecha';
				$rpc1_sql.=' order by faniot desc, fecha ';
				$rpc1_sql.=' limit 36 ';
	
	$crow=0;
	$spublic=0;
	$svideos=0;
	$shoras=0;
	$srevisi=0;
	$scursos=0;
	}?>
<div style="font-size:4px;"><br></div>
<table border="0" width="100%" cellpadding="2" cellspacing="0" style="border-collapse:collapse;font-size:<?php echo $xfontsize; ?>px;">
<?php	$rpc1_res=msql_query($rpc1_sql,$link_vcrx);?>
<?php while($rpc1_aso=msql_fetch_assoc($rpc1_res)){?>
	<?php $crow++; ?>

	<?php if($rpc1_aso['fmes']==9 or $crow==1) {?>
		<tr style="border-top:solid 1px; border-bottom:solid 1px;">
		<th><?php echo $rpc1_aso['faniot']?> </th>
		<th>PUBLIC</th>
		<th>VIDEOS</th>
		<th>HORAS</th>
		<th>REVISITAS</th>
		<th>CURSOS</th>
		<th>NOTAS</th>
		</tr>
	<?php } ?>

	
	<tr style="font-size:<?php echo $xfontsize; ?>px; <?php if($rpc1_aso['fmes']%4==0){echo 'border-bottom:dashed 1px;';}?> ">
		<td><?php echo $rpc1_aso['fmesn'] ;?></td>
		<td align="center"><?php echo number_format($rpc1_aso['public'],0);?></td>
		<td align="center"><?php echo number_format($rpc1_aso['presen'],0);?></td>
		<td align="center"><?php echo number_format($rpc1_aso['horas'],0);?></td>
		<td align="center"><?php echo number_format($rpc1_aso['revisi'],0);?></td>
		<td align="center"><?php echo number_format($rpc1_aso['cursos'],0);?></td>
		<td><?php echo $rpc1_aso['concepto'];?></td>
	</tr>
<?php
	$spublic+=$rpc1_aso['public'];
	$svideos+=$rpc1_aso['presen'];
	$shoras+=$rpc1_aso['horas'];
	$srevisi+=$rpc1_aso['revisi'];
	$scursos+=$rpc1_aso['cursos'];
?>
	<?php if($rpc1_aso['fmes']==8 and $crow>1) {?>
		<tr style="border-top:solid 1px; border-bottom:solid 1px;">
		<th>TOTALES</th>
		<th><?php echo number_format($spublic,0);?></th>
		<th><?php echo number_format($svideos,0);?></th>
		<th><?php echo number_format($shoras,0);?></th>
		<th><?php echo number_format($srevisi,0);?></th>
		<th><?php echo number_format($scursos,0);?></th>
		<th></th>
		</tr>
		<tr><td  style="font-size:4px;"><br></td></tr>
		<?php
		$spublic=0;
		$svideos=0;
		$shoras=0;
		$srevisi=0;
		$scursos=0;
		$crow=0;
		?>
	<?php } ?>
<?php } ?>	
</table>	
</div>
<p class="saltodepagina" />	
<?php } ?>
</body>
<?php //////////////////////////////////////////////////////////	?>

</html>
	
	
<?php	
	
	
	$docuhtml = ob_get_clean(); 
// 	file_put_contents($rutadoc.$docu.'_'.str_pad($idnum,9,"0",STR_PAD_LEFT).'.html',$docuhtml);
// 	if(substr($xclaveacc,10,13)==$cfg_ruc)
// 	{file_put_contents($rutace.$xclaveacc.'.html',$docuhtml);}
return $docuhtml;	
}
	
?>



	
<?php

	

$jworgs='http://wol.jw.org';
$jworgl=$jworgs.'/es/wol/dt/r4/lp-s/';
// echo $jworgl;


$cong_sql='select * from cong0 where cong_codigo="'.$_SESSION['cong_codigo'].'"';
$cong_res=msql_query($cong_sql,$link_vcrx);
$salas = msql_result($cong_res,0,'cong_sala');


// $jwib_sql='select * from user0 where user_codigo="'.$_SESSION['user_codigo'].'"';
// $jwib_res=msql_query($jwib_sql,$link_vcrx);

$jwib_sql='select *, user_vida +user_mmae +user_estu +user_dpub +user_vari +user_asem as modifica ';
$jwib_sql.='from user0 where user_codigo="'.$_SESSION['user_codigo'].'"';
$jwib_res=msql_query($jwib_sql,$link_vcrx);

$modifica= msql_result($jwib_res,0,'modifica');

$full=false;
$invi=false;

// echo '****'.$modif;

if($modif=='1') 
{
$acce=msql_result($jwib_res,0,'user_acce');
$vida=msql_result($jwib_res,0,'user_vida');
$mmae=msql_result($jwib_res,0,'user_mmae');
$dpub=msql_result($jwib_res,0,'user_dpub');
$estu=msql_result($jwib_res,0,'user_estu');
$asem=msql_result($jwib_res,0,'user_asem');
$vari=msql_result($jwib_res,0,'user_vari');

if(mb_stristr('sist.admi',$_SESSION['user_tipo'])){$full=true;}

if(mb_stristr('invi',$_SESSION['user_tipo'])){$invi=true;}

}

if($modifica>0 and $anio=='' and $modif=='') {$bmodif=true;}

$semaa=date('W',strtotime('now'));
$fechaa=date('Y-m-d');
$prdoa=date('Ym');

$fecha2=strtotime ('today -12 months');
// if($modif=='1')
// {$fecha2=strtotime ('last Monday -56 days');}
$fecha2=date('Y-m-01',$fecha2);

$fecha=date('Y-m-01');
$printer=false;

// if($fecha2>$fecha){$fecha2=$fecha;}

$ipip=$_SERVER['REMOTE_ADDR'];
$ipip_sql='insert into ipip0(ipip_codigo)value("'.$ipip.'")';
$ipip_res=msql_query($ipip_sql,$link_vcrx);
$ipip_sql='update ipip0 set ';
$ipip_sql.='ipip_descri="'.$_SERVER['REMOTE_PORT'].'",';
$ipip_sql.='ipip_idate=now(),';
$ipip_sql.='ipip_status=ipip_status ';
$ipip_sql.='where ipip_codigo="'.$ipip.'"';
$ipip_res=msql_query($ipip_sql,$link_vcrx);



?>


	
<?php if(mb_stristr('XLSX',$docu)) { ?>
<?php
$origen = $_FILES['archivo']['tmp_name'];
$destino="../informes.xlsx";
echo move_uploaded_file($origen,$destino);
	
$xlsfile="../informes.xlsx";
$xlsx = new SimpleXLSX($xlsfile);
$hojas=	$xlsx->sheetNames();

for( $choja = 0; $choja <= count($hojas); $choja++)
{
// 	echo $hojas[$choja];
// 	echo "\n";
	if($hojas[$choja]=='Publicadores')
	{
			$xfila=$xlsx->rows($choja);

			$xcabe= $xfila[0];
			for( $ccolu = 0; $ccolu <= count($xcabe); $ccolu++)
			{
				if($xcabe[$ccolu]=='codigo'){$col_codigo=$ccolu;}
				if($xcabe[$ccolu]=='nombre'){$col_nombre=$ccolu;}
				if($xcabe[$ccolu]=='grupo'){$col_zsub=$ccolu;}
				if($xcabe[$ccolu]=='email'){$col_email=$ccolu;}
				if($xcabe[$ccolu]=='nacimiento'){$col_nacimiento=$ccolu;}
				if($xcabe[$ccolu]=='bautismo'){$col_bautismo=$ccolu;}
				if($xcabe[$ccolu]=='cdla'){$col_calle1=$ccolu;}
				if($xcabe[$ccolu]=='sexo'){$col_sexo=$ccolu;}
				if($xcabe[$ccolu]=='direccion'){$col_calle2=$ccolu;}
				if($xcabe[$ccolu]=='telefono'){$col_telefono=$ccolu;}
				if($xcabe[$ccolu]=='movil'){$col_movil=$ccolu;}
				if($xcabe[$ccolu]=='publicador'){$col_csub=$ccolu;}
				if($xcabe[$ccolu]=='privilegio'){$col_privilegio=$ccolu;}
			}
		
			for( $cfila = 1; $cfila <= count($xfila); $cfila++)
			{
				$xregi= $xfila[$cfila];

				$regi_sql='insert into enti0(enti_codigo)value('.$xregi[$col_codigo].')';
				$regi_res=msql_query($regi_sql,$link_vcrx);
				
				$regi_sql='update enti0 set ';
				$regi_sql.='enti_descri="'.$xregi[$col_nombre].'", ';
				$regi_sql.='enti_zsub="'.$xregi[$col_zsub].'", ';
				$regi_sql.='enti_csub="'.$xregi[$col_csub].'", ';
				$regi_sql.='enti_cargo="'.$xregi[$col_privilegio].'", ';
				$regi_sql.='enti_calle1="'.$xregi[$col_calle1].'", ';
				$regi_sql.='enti_calle2="'.$xregi[$col_calle2].'", '; 
				$regi_sql.='enti_telefono="'.$xregi[$col_telefono].'", '; 
				$regi_sql.='enti_celular="'.$xregi[$col_movil].'", '; 
				$regi_sql.='enti_email="'.$xregi[$col_email].'", '; 
				$regi_sql.='enti_sexo="'.$xregi[$col_sexo].'", '; 
				$regi_sql.='enti_fechanac="'.$xregi[$col_nacimiento].'", '; 
				$regi_sql.='enti_fechaini="'.$xregi[$col_bautismo].'", '; 
				$regi_sql.='enti_status="-" ';
				$regi_sql.='where enti_codigo='.$xregi[$col_codigo];
				$regi_res=msql_query($regi_sql,$link_vcrx);
// 				echo $regi_sql;

				
			}
// 			echo $xcolu[2];

	}

				$regi_sql='update enti0 set enti_sexo="1" where enti_sexo="H"';
				$regi_res=msql_query($regi_sql,$link_vcrx);
				
				$regi_sql='update enti0 set enti_sexo="2" where enti_sexo="M"';
				$regi_res=msql_query($regi_sql,$link_vcrx);
	
	
	if($hojas[$choja]=='Informes')
	{
			$xfila=$xlsx->rows($choja);

			$xcabe= $xfila[0];
			for( $ccolu = 0; $ccolu <= count($xcabe); $ccolu++)
			{
				if($xcabe[$ccolu]=='idPub'){$col_enti=$ccolu;}
				if($xcabe[$ccolu]=='mes'){$col_fecha=$ccolu;}
				if($xcabe[$ccolu]=='codTp'){$col_tipo=$ccolu;}
				if($xcabe[$ccolu]=='publicaciones'){$col_public=$ccolu;}
				if($xcabe[$ccolu]=='presentaciones'){$col_presen=$ccolu;}
				if($xcabe[$ccolu]=='horas'){$col_horas=$ccolu;}
				if($xcabe[$ccolu]=='revisitas'){$col_revisi=$ccolu;}
				if($xcabe[$ccolu]=='estudios'){$col_cursos=$ccolu;}
				if($xcabe[$ccolu]=='nota'){$col_concepto=$ccolu;}
			}

				$regi_sql='delete from jwrt1';
				$regi_res=msql_query($regi_sql,$link_vcrx);
				
				$regi_sql='alter table jwrt1 AUTO_INCREMENT=1';
				$regi_res=msql_query($regi_sql,$link_vcrx);
		
			for( $cfila = 1; $cfila <= count($xfila); $cfila++)
			{
				$xregi= $xfila[$cfila];

				$regi_sql='insert into jwrt1(docu,status,idate)value("RPC1","-",now())';
				$regi_res=msql_query($regi_sql,$link_vcrx);
				
				$regi_sql='select max(idnum1) as idnum1 from jwrt1';
				$regi_res=msql_query($regi_sql,$link_vcrx);
				$idnum1 = msql_result($regi_res,0,'idnum1');
				
				$regi_sql='update jwrt1 set ';
				$regi_sql.='enti="'.$xregi[$col_enti].'", ';
				$regi_sql.='fecha="'.$xregi[$col_fecha].'01'.'", ';
				$regi_sql.='public="'.$xregi[$col_public].'", ';
				$regi_sql.='presen="'.$xregi[$col_presen].'", ';
				$regi_sql.='horas="'.$xregi[$col_horas].'", ';
				$regi_sql.='revisi="'.$xregi[$col_revisi].'", ';
				$regi_sql.='cursos="'.$xregi[$col_cursos].'", ';
				$regi_sql.='concepto="'.$xregi[$col_concepto].'", ';
				$regi_sql.='status="-" ';
				$regi_sql.='where idnum1='.$idnum1;
				$regi_res=msql_query($regi_sql,$link_vcrx);
				
			}

	}

	
}


?> 
			
<?php } ?>
	
<resultado>
<?php if(mb_stristr('RPC0',$docu)) { ?>
			<div id="rpc" style="border:solid 2px; overflow:auto;">
			<table cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px; border-collapse:collapse; background-color:white;">
				<tr>
				<td id="rpc0">
						<table cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px;border-collapse:collapse;background-color:white;">
						<tr>
							<td>
								<?php 	$pidtxt='fecha1'; $pcaption='Desde'; $pdefa='2000-01-01'; include('vrgetfec.php'); ?>
								<?php 	$pidtxt='fecha2'; $pcaption='Hasta'; include('vrgetfec.php'); ?>
								<?php 	$pidtxt='nombre'; $pcaption='Nombre'; $plong=30; include('vrgettxt.php'); ?>
								<?php 	$pidtxt='grupo'; $pcaption='Grupo'; $plong=3; include('vrgetnum.php'); ?>
							</td>
							<td>
								<?php 	$pidtxt='consul'; $pcaption='Consultar'; $ponclick='jwib_rpc1("RPC1")'; include('vrbutton.php'); ?>
							</td>
							<td>
								<?php 	$pidtxt='subir'; $pcaption='Subir'; $ponclick='jwib_rpc1("XLSX","'.$pidtxt.'")'; include('vrgetfil.php'); ?>
							</td>
						</tr>
						</table>
				</td>	
				</tr>	
			</table>
			</div>	
<!-- <br> -->
					<div id="rpc1" style="border:solid 1px; overflow:auto;max-height:180px;"></div>
<!-- <br> -->
					<div id="rpcd" style="border:solid 1px; overflow:auto;max-height:220px;"></div>
					<div id="rpc2" style="border:solid 1px; overflow:auto;max-height:210px;"></div>
<?php } ?>			
	
<?php if(mb_stristr('RPC1',$docu)) { ?>
			<rpc1>
	
			<?php
				$enti_sql='select *, max(fecha) as ultimo ';
				$enti_sql.=' from enti00 left join jwrt1 ';
				$enti_sql.=' on enti_codigo=enti ';
				$enti_sql.=' where 1=1 ';
				if($grupo!=""){$enti_sql.=' and enti_zsub="'.$grupo.'"';}
				if($enti!=""){$enti_sql.=' and enti_descri like "%'.$enti.'%"';}
// 				$enti_sql.=' order by enti_zsub, enti_descri';
				$enti_sql.=' group by enti_codigo';
				$enti_sql.=' order by enti_descri';
// 	echo $enti_sql;
				$enti_res=msql_query($enti_sql,$link_vcrx);
			?>
	
				<?php $crow=0; ?>
			<table  border="0" class="scroll info1 autocol" onclick="resizetab('info1');"  onmouseover="this.onclick();" cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px;border-collapse:collapse;border:#000000 solid 1px;background-color:white;">
			<?php while($enti_aso=msql_fetch_assoc($enti_res)){ ?>
				<?php if ($crow%1000==0) { ?>
				<thead style="display:block;">
				<tr style="border-bottom:solid 1px;">
				<th></th>
				<th></th>
				<th>CODIGO</th>
				<th>NOMBRE</th>
				<th>GRUPO</th>
				<th>DIRECCION</th>
				<th>TELEFONO</th>
				<th>EMAIL</th>
				<th>NACIMIENTO</th>
				<th>BAUTISMO</th>
				<th>ULTIMO</th>
				</tr>
				</thead>
				<?php } ?>
				<?php $crow++; ?> 
<!-- 
				<tr class="tr_cabe" id="<?php echo $enti_aso['enti_codigo']; ?>" onclick="tr_click('tr_cabe',this);" style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> ">
-->
				<?php if($crow==1){ ?>
				 <tbody style="height:100px; overflow-y: auto; display:block;">
				<?php } ?>
				<tr id="tr_fila<?php echo $crow;?>" 
						class="tr_fila" 
						style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> "
						onclick="
										 _filabg(event,'tr_fila','<?php echo $crow; ?>','');
<!-- 										 jwib_rpc1('RPC2','<?php echo $enti_aso['enti_codigo']; ?>'); -->
										 "; 							
						onkeypress=""
						onkeyup=""
						ondblclick=""
						>
					<td>
								<?php
										$pidtxt='info'.'tr_fila'.$crow; $pname='itr_fila'; $pcaption='Imprimir'; $pabrev='I';
										$ponclick='jwib_rpc1("RPCI","'.$enti_aso['enti'].'")';
										include('vrbutton.php');
								?>
					</td>
					<td style="display:block;"
						onclick="
										 jwib_rpc1('RPC2','<?php echo $enti_aso['enti_codigo']; ?>');
										 "; 							
							>
								<?php 	$pidtxt='radio'.'tr_fila'.$crow; $pname='rtr_fila'; $pcaption=''; include('vrradio.php'); ?>
					</td>
					<td>
						<?php echo $enti_aso['enti_codigo'] ?>
					</td>
					<td>
						<?php echo $enti_aso['enti_descri'] ?>
					</td>
					<td align="center">
						<?php echo $enti_aso['enti_zsub'] ?>
					</td>
					<td>
						<?php echo $enti_aso['enti_calle1'].' - '.$enti_aso['enti_calle2'] ?>
					</td>
					<td>
						<?php echo $enti_aso['enti_telefono'] ?>
					</td>
					<td>
						<?php echo $enti_aso['enti_email'] ?>
					</td>
					<td align="center">
						<?php echo $enti_aso['enti_fechanacdmy'].' ('.$enti_aso['enti_edad'].')' ?>
					</td>
					<td align="center">
						<?php echo $enti_aso['enti_fechainidmy'].' ('.$enti_aso['enti_anti'].')' ?>
					</td>
					<td align="center">
						<?php echo date('M/Y',strtotime($enti_aso['ultimo'])); ?>
					</td>
				</tr>
				
			<?php } ?>
			<?php //if($crow==1){echo '</tbody>';}?>
			</tbody>
<!-- 			<tfoot style="display:block"> -->
<!-- 				<tr> -->
<!-- 			<th>total 1</th> -->
<!-- 			<th>total 2</th> -->
<!-- 				</tr> -->
<!-- 			</tfoot> -->
			</table>

			<rpc1>
				
<?php } ?>			
			
<?php if(mb_stristr('RPC2',$docu)) { ?>
			<rpcd>
			<?php $enti_sql='select * from enti00 where enti_codigo ="'.$enti.'"';	?>
			<?php $enti_res=msql_query($enti_sql,$link_vcrx); ?>
			<b>
			<?php echo msql_result($enti_res,0,'enti_descri'); ?>
				</b>
			</rpcd>
	
			<rpc2>
				<?php $tpublic=0; ?>
				<?php $tpresen=0; ?>
				<?php $thoras=0; ?>
				<?php $trevisi=0; ?>
				<?php $tcursos=0; ?>
			<?php
				$enti_sql='select jwrt11.*,';
				$enti_sql.=' case when fmes>=9 then fanio+1 else fanio end as faniot';
				$enti_sql.=' from jwrt11';
				$enti_sql.=' where enti="'.$enti.'"';
				$enti_sql.=' order by fecha';
// 	echo $enti_sql;

				$enti_res=msql_query($enti_sql,$link_vcrx); 
// 			 echo msql_error(); 
				?>

			<table cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px; border-collapse:collapse;border:#000000 solid 1px;background-color:white;">
				<?php $crow=0; ?>
				<?php $ufaniot=0; ?>
			<?php while($enti_aso=msql_fetch_assoc($enti_res)){ ?>
				<?php if ($enti_aso['faniot']!=$ufaniot) { $ufaniot=$enti_aso['faniot']; ?>
				<tr>
				<th></th>
				<th>ANIO/MES</th>
				<th>PUBLIC</th>
				<th>PRESEN</th>
				<th>HORAS</th>
				<th>REVISI</th>
				<th>CURSOS</th>
				<th width="50%">NOTAS</th>
				</tr>
				<?php } ?>
					
				<tr style="<?php if ($enti_aso['fmes']%4==0) {echo 'border-bottom:dotted 1px ; ';} ?>">
					<td>
					<?php if($enti_aso['fanio'].$enti_aso['fmes']>=$prdoa){ ?>
<!-- 					<div id="scrollhere" ></div> -->
					<?php } ?>
								<?php 	$pidtxt='regis'.$enti_aso['idnum1']; $pcaption='Registro'; $pabrev='R'; 
										$ponclick='jwib_rpc1("RPCR","'.$enti_aso['enti'].'","'.$enti_aso['fanio'].'","'.$enti_aso['fmes'].'")';
										include('vrbutton.php');
								?>
					</td>
					<td align="left">
						<?php echo $enti_aso['fanio'].' /'.$enti_aso['fmesn'] ?>
					</td>
					<td align="center">
						<?php echo number_format($enti_aso['public'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($enti_aso['presen'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($enti_aso['horas'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($enti_aso['revisi'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($enti_aso['cursos'],0) ?>
					</td>
					<td align="left">
						<?php echo $enti_aso['concepto'] ?>
					</td>
				</tr>
					<?php $tpublic+=$enti_aso['public']; ?>
					<?php $tpresen+=$enti_aso['presen']; ?>
					<?php $thoras+=$enti_aso['horas']; ?>
					<?php $trevisi+=$enti_aso['revisi']; ?>
					<?php $tcursos+=$enti_aso['cursos']; ?>
				
				<?php if($enti_aso['fmes']==8){ ?>
				<tr style=" border-bottom:solid 2px ;">
					<th>
					</th>
					<th >
						TOTALES
					</th>
					<th align="center">
						<?php echo number_format($tpublic,0) ?>
					</th>
					<th align="center">
						<?php echo number_format($tpresen,0) ?>
					</th>
					<th align="center">
						<?php echo number_format($thoras,0) ?>
					</th>
					<th align="center">
						<?php echo number_format($trevisi,0) ?>
					</th>
					<th align="center">
						<?php echo number_format($tcursos,0) ?>
					</th>
					<th align="left">
					</th>
				</tr>
				<?php $tpublic=0; ?>
				<?php $tpresen=0; ?>
				<?php $thoras=0; ?>
				<?php $trevisi=0; ?>
				<?php $tcursos=0; ?>
				<?php } ?>
				
				
				
				
				<?php $crow++; ?> 
			<?php } ?>
			</table>
			<div id="scrollhere" ></div>
			</rpc2>
	
<?php } ?>			

<?php if(mb_stristr('RPCI',$docu)) { ?>
<?php echo rpc_full('',$enti); ?>
<?php } ?>

				
			
<?php if(mb_stristr('RPCR',$docu)) { ?>
			<?php
				$enti_sql='select * from enti00 where enti_codigo ="'.$enti.'"';
				$enti_res=msql_query($enti_sql,$link_vcrx);
	$aniot=$anio;
	if($mes>=9){$aniot++;}
	
	$rpc1_sql='select jwrt11.*,';
				$rpc1_sql.=' case when fmes>=9 then fanio+1 else fanio end as faniot';
				$rpc1_sql.=' from jwrt11';
				$rpc1_sql.=' where enti="'.$enti.'"';
				$rpc1_sql.=' and fanioserv="'.$aniot.'"';
				$rpc1_sql.=' order by fecha';
// 				$rpc1_res=msql_query($rpc1_sql,$link_vcrx);
// 	echo $rpc1_sql;
	
	
			$head1=0;
			$foot1=0;
	
			if($mes==9){$head1=1;}
			else
			{
				$rpc1_res=msql_query($rpc1_sql,$link_vcrx);
				if(msql_result($rpc1_res,0,'fmes')==$mes){$head1=1;} 
			}

	
			$blanco='white;opacity:0.0;';
// 			$blanco='yellow';
// 			$blanco='black';
	
			?>

	
<!-- 	<div id="registro" style="position:fixed;width:140mm;height:100mm; margin-left:0mm;margin-top:0mm;border:solid 0px;font-size:12px;"> -->
	<div id="registro" style="position:fixed;width:155mm;height:100mm; margin-left:0mm;margin-top:0mm;border:solid 0px;font-size:12px;">
<!-- 		<div style="position:relative;width:3mm; left:10mm; top:5mm; z-index:9; font-size:14px;"> -->
			<?php  //echo substr(msql_result($enti_res,0,'enti_descri'),0,1); ?>
<!-- 		</div> -->
		<div style="position:relative;width:3mm; left:131mm; top:0mm; z-index:9;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<?php  if(msql_result($enti_res,0,'enti_sexo')=="1") {echo 'H';}?>
		</div>
		<div style="position:relative;width:3mm; left:131mm; top:5mm; z-index:9;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<?php  if(msql_result($enti_res,0,'enti_sexo')=="2") {echo 'M';}?>
		</div>
<!-- 		<div id="cabecera1" style="position:relative;margin-top:0mm;height:22mm;"> -->
		<div id="cabecera1" style="position:relative;left:20mm;top:-8mm;height:22mm;">
			<table cellspacing="0" cellpadding="0"  
						 style="border-collapse:collapse;background-color:white;width:125mm; font-size:12px; table-layout:fixed;
										<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>" border=0>
				<tr style="height:8mm;"></tr>
				<tr style="height:5mm;">
<!-- 					<td style="width:1mm;"></td> -->
					<td colspan="4">
						<?php echo msql_result($enti_res,0,'enti_descri') ?>
					</td>
				</tr>
				<tr style="height:4mm;">
<!-- 					<td></td> -->
					<td colspan="5">
						<?php echo msql_result($enti_res,0,'enti_calle1').' '.msql_result($enti_res,0,'enti_calle2') ?>
					</td>
				</tr>
				<tr style="height:5mm;">
					<td style="width:25mm;">
						<?php echo msql_result($enti_res,0,'enti_telefono') ?>
					</td>
					<td style="width:20mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($enti_res,0,'enti_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($enti_res,0,'enti_fechanacdmy') ?>
					</td>
				</tr>
			</table>
		</div>		

		<div id="cabecera2" style="margin-top:-8mm;height:8mm;width:140mm;font-size:12px;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<div style="position:relative;margin-left:25mm;margin-top:0mm;height:8mm;width:22mm;">
				<?php echo msql_result($enti_res,0,'enti_fechainidmy') ?>
			</div>
		</div>		
	
<?php		//		$rpc1_res=msql_query($rpc1_sql,$link_vcrx); ?>
				<?php $crow=0; ?>

				<?php $tpublic=0; ?>
				<?php $tpresen=0; ?>
				<?php $thoras=0; ?>
				<?php $trevisi=0; ?>
				<?php $tcursos=0; ?>
		
				<?php $cfecha=$anio.'-09-01' ; ?>
				<?php if ($mes<9) { ?>
				<?php $cfecha=($anio-1).'-09-01' ; ?>
				<?php } ?>
		<div id="detalle" style="top:-13mm;margin-left:0mm;">
			
			<table cellspacing="0" cellpadding="0" width="140mm" style="border-collapse:collapse;background-color:white; font-size:10px; table-layout:fixed;" border=0>
				<tr style="height:3.84mm;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
					<td style="width:20mm;" align="center"><?php echo $aniot; ?></td>	
					<td style="width:19mm;"></td>
					<td style="width:22mm;"></td>
					<td style="width:11mm;"></td>
					<td style="width:15mm;"></td>
					<td style="width:15mm;"></td>
					<td style="width:38mm;"></td>
			</tr>				
			<?php for ($cmes=1; $cmes<=12; $cmes++) { ?>
				<tr style="height:3.84mm;<?php if (date('Ym',strtotime($cfecha))<($anio.$mes)) {echo 'color:'.$blanco.';';} ?>">
					<?php
							$rpcm_sql='select jwrt11.*,case when fmes>=9 then fanio+1 else fanio end as faniot from jwrt11 where enti="'.$enti.'" and fecha="'.$cfecha.'" and status!="X"';
							$rpcm_res=msql_query($rpcm_sql,$link_vcrx);
							$cfecha=date('Y-m-01',strtotime($cfecha.' +1 month'));
					?>
					<?php if (msql_num_rows($rpcm_res)!=0) {?>
					<?php if($cmes==12){$foot1=1;} ?>
					<td>
					</td>	
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'public'),0);  ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'presen'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'horas'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'revisi'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'cursos'),0); ?>
					</td>
					<td align="left" style="font-size:8px;" >
						<?php echo msql_result($rpcm_res,0,'concepto') ?>
					</td>
					<?php $tpublic+=msql_result($rpcm_res,0,'public'); ?>
					<?php $tpresen+=msql_result($rpcm_res,0,'presen'); ?>
					<?php $thoras+=msql_result($rpcm_res,0,'horas'); ?>
					<?php $trevisi+=msql_result($rpcm_res,0,'revisi'); ?>
					<?php $tcursos+=msql_result($rpcm_res,0,'cursos'); ?>
					<?php } ?>
				</tr>
			<?php } ?>
				
				<tr style="height:3.84mm;<?php if ($foot1==0) {echo 'color:'.$blanco.';';} ?> font-weight:bold;">
					<td>
					</td>	
					<td align="center" >
						<?php echo number_format($tpublic,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($tpresen,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($thoras,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($trevisi,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($tcursos,0) ?>
					</td>
					<td align="left" >
					</td>
				</tr>

			</table>
		</div>

		</div>	
<?php } ?>			
	
				
				
<?php if(mb_stristr('RPCR',$docu) and 'LASER'=='1') { ?>
			<?php
				$enti_sql='select * from enti00 where enti_codigo ="'.$enti.'"';
				$enti_res=msql_query($enti_sql,$link_vcrx);
	$aniot=$anio;
	if($mes>=9){$aniot++;}
	
	$rpc1_sql='select jwrt11.*,';
				$rpc1_sql.=' case when fmes>=9 then fanio+1 else fanio end as faniot';
				$rpc1_sql.=' from jwrt11';
				$rpc1_sql.=' where enti="'.$enti.'"';
				$rpc1_sql.=' and fanioserv="'.$aniot.'"';
				$rpc1_sql.=' order by fecha';
// 				$rpc1_res=msql_query($rpc1_sql,$link_vcrx);
// 	echo $rpc1_sql;
	
	
			$head1=0;
			$foot1=0;
	
			if($mes==9){$head1=1;}
			else
			{
				$rpc1_res=msql_query($rpc1_sql,$link_vcrx);
				if(msql_result($rpc1_res,0,'fmes')==$mes){$head1=1;} 
			}

	
			$blanco='white;opacity:0.0;';
// 			$blanco='yellow';
// 			$blanco='black';
	
			?>

	
	<div id="registro" style="position:fixed;width:140mm;height:100mm; margin-left:0mm;margin-top:0mm;border:solid 0px;font-size:12px;">
<!-- 	<div id="registro" style="position:fixed;width:155mm;height:100mm; margin-left:0mm;margin-top:0mm;border:solid 0px;font-size:12px;"> -->
<!-- 		<div style="position:relative;width:3mm; left:10mm; top:5mm; z-index:9; font-size:14px;"> -->
			<?php  //echo substr(msql_result($enti_res,0,'enti_descri'),0,1); ?>
<!-- 		</div> -->
		<div style="position:relative;width:3mm; left:134mm; top:5mm; z-index:9;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<?php  if(msql_result($enti_res,0,'enti_sexo')=="1") {echo 'H';}?>
		</div>
		<div style="position:relative;width:3mm; left:134mm; top:10mm; z-index:9;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<?php  if(msql_result($enti_res,0,'enti_sexo')=="2") {echo 'M';}?>
		</div>
<!-- 		<div id="cabecera1" style="position:relative;margin-top:0mm;height:22mm;"> -->
		<div id="cabecera1" style="position:relative;left:15mm;top:-3mm;height:22mm;">
			<table cellspacing="0" cellpadding="0"  
						 style="border-collapse:collapse;background-color:white;width:125mm; font-size:12px; table-layout:fixed;
										<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>" border=0>
				<tr style="height:8mm;"></tr>
				<tr style="height:5mm;">
<!-- 					<td style="width:1mm;"></td> -->
					<td colspan="4">
						<?php echo msql_result($enti_res,0,'enti_descri') ?>
					</td>
				</tr>
				<tr style="height:4mm;">
<!-- 					<td></td> -->
					<td colspan="5">
						<?php echo msql_result($enti_res,0,'enti_calle1').' '.msql_result($enti_res,0,'enti_calle2') ?>
					</td>
				</tr>
				<tr style="height:5mm;">
<!-- 					<td></td> -->
					<td style="width:30mm;">
						<?php echo msql_result($enti_res,0,'enti_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($enti_res,0,'enti_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($enti_res,0,'enti_fechanacdmy') ?>
					</td>
				</tr>
			</table>
		</div>		

		<div id="cabecera2" style="margin-top:0mm;height:8mm;width:140mm;font-size:12px;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
			<div style="position:relative;margin-left:25mm;margin-top:0mm;height:8mm;width:22mm;">
				<?php echo msql_result($enti_res,0,'enti_fechainidmy') ?>
			</div>
		</div>		
	
<?php		//		$rpc1_res=msql_query($rpc1_sql,$link_vcrx); ?>
				<?php $crow=0; ?>

				<?php $tpublic=0; ?>
				<?php $tpresen=0; ?>
				<?php $thoras=0; ?>
				<?php $trevisi=0; ?>
				<?php $tcursos=0; ?>
		
				<?php $cfecha=$anio.'-09-01' ; ?>
				<?php if ($mes<9) { ?>
				<?php $cfecha=($anio-1).'-09-01' ; ?>
				<?php } ?>
		<div id="detalle" style="top:-2mm;margin-left:0mm;">
			
			<table cellspacing="0" cellpadding="0" width="140mm" style="border-collapse:collapse;background-color:white; font-size:12px; table-layout:fixed;" border=0>
				<tr style="height:4.16mm;<?php if ($head1==0) {echo 'color:'.$blanco.';';} ?>">
					<td style="width:20mm;" align="center"><?php echo $aniot; ?></td>	
					<td style="width:19mm;"></td>
					<td style="width:22mm;"></td>
					<td style="width:11mm;"></td>
					<td style="width:15mm;"></td>
					<td style="width:15mm;"></td>
					<td style="width:38mm;"></td>
			</tr>				
			<?php for ($cmes=1; $cmes<=12; $cmes++) { ?>
				<tr style="height:4.16mm;<?php if (date('Ym',strtotime($cfecha))<($anio.$mes)) {echo 'color:'.$blanco.';';} ?>">
					<?php
							$rpcm_sql='select jwrt11.*,case when fmes>=9 then fanio+1 else fanio end as faniot from jwrt11 where enti="'.$enti.'" and fecha="'.$cfecha.'" and status!="X"';
							$rpcm_res=msql_query($rpcm_sql,$link_vcrx);
							$cfecha=date('Y-m-01',strtotime($cfecha.' +1 month'));
// 																echo $rpcm_sql;
					?>
					<?php if (msql_num_rows($rpcm_res)!=0) {?>
					<?php if($cmes==12){$foot1=1;} ?>
					<td>
					</td>	
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'public'),0);  ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'presen'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'horas'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'revisi'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(msql_result($rpcm_res,0,'cursos'),0); ?>
					</td>
					<td align="left" >
						<?php echo msql_result($rpcm_res,0,'concepto') ?>
					</td>
					<?php $tpublic+=msql_result($rpcm_res,0,'public'); ?>
					<?php $tpresen+=msql_result($rpcm_res,0,'presen'); ?>
					<?php $thoras+=msql_result($rpcm_res,0,'horas'); ?>
					<?php $trevisi+=msql_result($rpcm_res,0,'revisi'); ?>
					<?php $tcursos+=msql_result($rpcm_res,0,'cursos'); ?>
					<?php } ?>
				</tr>
			<?php } ?>
				
				<tr style="height:4.16mm;<?php if ($foot1==0) {echo 'color:'.$blanco.';';} ?> font-weight:bold;">
					<td>
					</td>	
					<td align="center" >
						<?php echo number_format($tpublic,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($tpresen,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($thoras,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($trevisi,0) ?>
					</td>
					<td align="center" >
						<?php echo number_format($tcursos,0) ?>
					</td>
					<td align="left" >
					</td>
				</tr>

			</table>
		</div>

		</div>	
<?php } ?>			
	
</resultado>
