<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>
<?php //include('excel_reader2.php');?>
<?php //include('vrreadxls.php');?>
<?php $docu=$_POST['docu']; ?>
<?php $enti=$_POST['enti']; ?>
<?php $anio=$_POST['anio']; ?>
<?php $mes=$_POST['mes']; ?>
<?php $modif=$_POST['modif']; ?>


<?php $cong=$_POST['cong']; ?>
<?php $nombre=$_POST['nombre']; ?>
<?php $tipo=$_POST['tipo']; ?>


<?php $xfrepo='C';?>


	
	
<resultado>
<?php if(mb_stristr('USER0',$docu)) { ?>
			<div id="user" 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="user0">
						<table cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px;border-collapse:collapse;background-color:white;">
						<tr>
							<td>
								<?php 	$pidtxt='cong'; $pcaption='Congregacion'; $ptabla='cong'; $pdefa=$user_cong; $pnotob=1;  include('vrgetcod.php'); ?>
								<?php 	$pidtxt='nombre'; $pcaption='Nombre'; $plong=30; include('vrgettxt.php'); ?>
								<?php 	$pidtxt='tipo'; $pcaption='Tipo'; $ptabla='tusr';  include('vrgetcod.php'); ?>
							</td>
							<td>
							<?php $pname="forder"; $pidtxt='fordec'; $pcaption='Codigo'; if($xfrepo=='C' ){$pdefa='checked';} include('vrradio.php'); ?>	
							<?php $pname="forder"; $pidtxt='forden'; $pcaption='Nombre'; if($xfrepo=='D'){$pdefa='checked';}; include('vrradio.php'); ?>	
							</td>
							<td>
								<?php 	$pidtxt='consul'; $pcaption='Consultar'; $ponclick='jwib_user("USER1")'; include('vrbutton.php'); ?>
							</td>
						</tr>
						</table>
				</td>	
				</tr>	
			</table>
			</div>	
<!-- <br> -->
					<div id="user1" style="border:solid 1px; overflow:auto;max-height:180px;"></div>
<!-- <br> -->
					<div id="userd" style="border:solid 1px; overflow:auto;max-height:220px;"></div>
					<div id="user2" style="border:solid 1px; overflow:auto;max-height:210px;"></div>
<?php } ?>			
	
<?php if(mb_stristr('USER1',$docu)) { ?>
			<user1>
	
			<?php
				$user_sql='select * from user0 ';
				$user_sql.=' where 1=1';
				if($cong!=""){$user_sql.=' and user_cong = "'.$cong.'"';}
				if($nombre!=""){$user_sql.=' and user_descri like  "%'.$nombre.'%"';}
				if($tipo!=""){$user_sql.=' and user_tipo = "'.$tipo.'"';}
// 				$user_sql.=' order by enti_zsub, enti_descri';
				$user_sql.=' order by user_cong, user_descri';
				$user_res=msql_query($user_sql,$link_vcrx);
// 	echo $user_sql;
			?>
	
				<?php $crow=0; ?>
<!-- 			<table  class="scroll info1" onclick="resize('info1');"  onmouseover="resize('info1');" cellspacing="0" cellpadding="2" width="100%" style="font-family:arial;font-size:14px;border-collapse:collapse;border:#000000 solid 1px;background-color:white;"> -->
				
			<table class="scroll info1" onclick="resize('info1');"  onmouseover="resize('info1');" 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($user_aso=msql_fetch_assoc($user_res)){ ?>
				<?php if ($crow%1000==0) { ?>
				<tr style="border-bottom:solid 1px;">
				<th width="1%"></th>
				<th>CODIGO</th>
				<th>NOMBRE</th>
				<th>TIPO</th>
				<th>CONG</th>
				<th>NICK</th>
				<th>EMAIL</th>
				<th>ASEM</th>
				<th>MMAE</th>
				<th>VIDA</th>
				<th>ESTU</th>
				<th>RPUB</th>
				<th>ASIS</th>
				<th>VARI</th>
				</tr>
				<?php } ?>
				<?php $crow++; ?> 
				<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_user('USER2','<?php echo $user_aso['user_codigo']; ?>');
										 "; 							
						onkeypress=""
						onkeyup=""
						ondblclick=""
						>
					<td style="display:block;">
								<?php 	$pidtxt='radio'.'tr_fila'.$crow; $pname='rtr_fila'; $pcaption=''; include('vrradio.php'); ?>
					</td>
					<td align="center">
						<?php echo $user_aso['user_codigo'] ?>
					</td>
					<td>
						<?php echo $user_aso['user_descri'] ?>
					</td>
					<td align="center">
						<?php echo $user_aso['user_tipo'] ?>
					</td>
					<td align="center">
						<?php echo $user_aso['user_cong'] ?>
					</td>
					<td>
						<?php echo $user_aso['user_nickname'] ?>
					</td>
					<td>
						<?php echo $user_aso['user_email'] ?>
					</td>
					<td align="center">
							<?php  $pidtxt='chkasem'.$user_aso['user_codigo']; $pdefa=$user_aso['user_asem']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="asem"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkmmae'.$user_aso['user_codigo']; $pdefa=$user_aso['user_mmae']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="mmae"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkvida'.$user_aso['user_codigo']; $pdefa=$user_aso['user_vida']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="vida"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkestu'.$user_aso['user_codigo']; $pdefa=$user_aso['user_estu']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="estu"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkrpub'.$user_aso['user_codigo']; $pdefa=$user_aso['user_dpub']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="dpub"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkasis'.$user_aso['user_codigo']; $pdefa=$user_aso['user_asis']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="asis"; include('vrchkbox.php'); ?>	
					</td>
					<td align="center">
							<?php  $pidtxt='chkvari'.$user_aso['user_codigo']; $pdefa=$user_aso['user_vari']; $ptabla="user"; $pline=$user_aso['user_codigo']; $pcolu="vari"; include('vrchkbox.php'); ?>	
					</td>
				</tr>
			<?php } ?>
			</table>

			<user1>
				
<?php } ?>			
			
<?php if(mb_stristr('USER2',$docu)) { ?>
			<userd>
			<?php $user_sql='select * from user00 where enti_codigo ="'.$enti.'"';	?>
			<?php $user_res=msql_query($user_sql,$link_vcrx); ?>
			<b>
			<?php echo msql_result($user_res,0,'user_descri'); ?>
				</b>
			</userd>
	
			<user2>
				<?php $tpublic=0; ?>
				<?php $tpresen=0; ?>
				<?php $thoras=0; ?>
				<?php $trevisi=0; ?>
				<?php $tcursos=0; ?>
			<?php
				$user_sql='select jwrt11.*,';
				$user_sql.=' case when fmes>=9 then fanio+1 else fanio end as faniot';
				$user_sql.=' from jwrt11';
				$user_sql.=' where enti="'.$enti.'"';
				$user_sql.=' order by fecha';
// 	echo $user_sql;

				$user_res=msql_query($user_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($user_aso=msql_fetch_assoc($user_res)){ ?>
				<?php if ($user_aso['faniot']!=$ufaniot) { $ufaniot=$user_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 ($user_aso['fmes']%4==0) {echo 'border-bottom:dotted 1px ; ';} ?>">
					<td>
					<?php if($user_aso['fanio'].$user_aso['fmes']>=$prdoa){ ?>
<!-- 					<div id="scrollhere" ></div> -->
					<?php } ?>
								<?php 	$pidtxt='regis'.$user_aso['idnum1']; $pcaption='Registro'; $pabrev='R'; 
										$ponclick='jwib_user("USERR","'.$user_aso['enti'].'","'.$user_aso['fanio'].'","'.$user_aso['fmes'].'")';
										include('vrbutton.php');
								?>
					</td>
					<td align="left">
						<?php echo $user_aso['fanio'].' /'.$user_aso['fmesn'] ?>
					</td>
					<td align="center">
						<?php echo number_format($user_aso['public'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($user_aso['presen'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($user_aso['horas'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($user_aso['revisi'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($user_aso['cursos'],0) ?>
					</td>
					<td align="left">
						<?php echo $user_aso['concepto'] ?>
					</td>
				</tr>
					<?php $tpublic+=$user_aso['public']; ?>
					<?php $tpresen+=$user_aso['presen']; ?>
					<?php $thoras+=$user_aso['horas']; ?>
					<?php $trevisi+=$user_aso['revisi']; ?>
					<?php $tcursos+=$user_aso['cursos']; ?>
				
				<?php if($user_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>
			</user2>
	
<?php } ?>			
			
<?php if(mb_stristr('USERR.RPCI',$docu)) { ?>
			<?php
				$user_sql='select * from user00 where enti_codigo ="'.$enti.'"';
				$user_res=msql_query($user_sql,$link_vcrx);
// 	echo $rpc1_sql;

	$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:150mm;height:99mm; margin-left:30mm;margin-top:0mm;border:solid 1px;font-size:12px;"> -->
	<div id="registro" style="position:fixed;width:140mm;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($user_res,0,'user_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($user_res,0,'user_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($user_res,0,'user_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($user_res,0,'user_descri') ?>
					</td>
				</tr>
				<tr style="height:4mm;">
<!-- 					<td></td> -->
					<td colspan="5">
						<?php echo msql_result($user_res,0,'user_calle1').' '.msql_result($user_res,0,'user_calle2') ?>
					</td>
				</tr>
				<tr style="height:5mm;">
<!-- 					<td></td> -->
					<td style="width:30mm;">
						<?php echo msql_result($user_res,0,'user_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($user_res,0,'user_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo msql_result($user_res,0,'user_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($user_res,0,'user_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>
