<?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 $pant=$_POST['pant']; ?>
<?php $docu=$_POST['docu']; ?>
<?php $enti=$_POST['enti']; ?>
<?php $enti2=$_POST['enti2']; ?>
<?php $anio=$_POST['anio']; ?>
<?php $mes=$_POST['mes']; ?>
<?php $modif=$_POST['modif']; ?>

<?php if($pant==''){$pant='PANT0';}?>
<?php if(!@mb_stristr('PANT.IMPR',substr($pant,0,4))) {return;} ?>

<?php

// if($docu=='')
{$docu='CAR1';}

// $sql_carr='select * from carr1 where docu="'.$docu.'" and iuser="'.$user_codigo.'" order by fecha desc limit 1';
// $res_carr=mysql_query($sql_carr,$link_vcrx);
// if(mysql_num_rows($res_carr)==0)
// {
// 	$sql_icarr='insert into carr1(docu,fecha,iuser)value("'.$docu.'",now(),"'.$user_codigo.'")';
// 	$res_icarr=mysql_query($sql_icarr,$link_vcrx);
// 	$res_carr=mysql_query($sql_carr,$link_vcrx);
// }
// $idcarr=mysql_result($res_carr,0,'idnum1');


$idcarr=get_carr();


if($cfg_empr=='dly1'){dly1_calc1($docu,$idcarr);}


?>

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

<?php $orient=$_POST['orient']; ?>

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


	<?php $crow=0; ?>
	<?php $ccol=0; ?>
	<?php $tnumero=0; ?>

<?php
// $hpant1 =ceil($screenh*0.30);
// $hpant11=ceil($screenh*0.10);
// $hpant2 =ceil($screenh*0.70);
$xfontsize=12;

// $wpant1 =$screenw*.9;
// if($mobile=='true' and $orient=='V'){$xfontsize=40;}
// if($mobile=='true' and $orient=='H'){$xfontsize=12;}
if($orient=='V'){$xfontsize=40;}
if($orient=='H'){$xfontsize=12;}

$hpant1 =ceil($screenh*0.30);
$hpant11=ceil($screenh*0.10);
$hpant2 =ceil($screenh*0.30);

// echo $screenw;
$wpant1 =$screenw*.9;
	
if ($orient=='V')
{
	$hpant1 =ceil($screenh*0.90);
  $hpant11=ceil($screenh*0.40);
	$hpant2 =ceil($screenh*0.90);
  $wpant1 =$screenw -20;
}

$sql_dato='select * from user0 where user_codigo="'.$user_codigo.'"';
$res_dato=mysql_query($sql_dato,$link_vcrx);

$user_datosok=1;
$user_nombre=mysql_result($res_dato,0,'user_descri');
$user_cedula=mysql_result($res_dato,0,'user_cedula');
$user_ciudad=mysql_result($res_dato,0,'user_ciudad');
$user_postal=mysql_result($res_dato,0,'user_postal');
$user_calle1=mysql_result($res_dato,0,'user_calle1');
$user_calle2=mysql_result($res_dato,0,'user_calle2');
$user_calle3=mysql_result($res_dato,0,'user_calle3');
$user_callen=mysql_result($res_dato,0,'user_callen');
$user_referidox=mysql_result($res_dato,0,'user_referidox');

$direccion=$user_calle1.' /'.$user_calle2.' ('.$user_callen.') '.$user_calle3;


if(empty($user_cedula) or empty($user_calle1)){$user_datosok=0;}

if(mb_stristr('gmny',$cfg_empr))
{if(empty($user_referidox)){$user_datosok=0;}}

$sql_updt='update carr1,user0 set enti=user_cedula where iuser=user_codigo and (enti="" or enti is null)';
$sql_updt.=' and iuser="'.$user_codigo.'"';
$res_updt=mysql_query($sql_updt,$link_vcrx);

if($empr=='gmny'){$envio=4;}
if($empr=='gnya')
{
  $envio=4;
  if(mb_stristr($user_ciudad,'GUAYAQ')){$envio=2.50;}
}

// $user_datosok=0;

?>

<resultado>
<?php if(mb_stristr('PANT0',$pant)) { ?>
			<div id="pant" style="border:solid 2px; overflow:auto;">
<?php if($user_datosok==0){?>
<table id="filtro" cellpadding="2" width="100%" border="0" class="<?php echo $classtab?>"
			style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
	<tr>
		<td align="right" style="color:red; font-weight:bold; text-decoration:underline; font-size:<?php echo $xfontsize+6;?>;">
			<?php echo 'DEBE COMPLETAR SUS DATOS PARA ORDENAR PEDIDO';?>
		</td>
		<td width="10%" align="right">
		<?php $pidtxt='f_datos';  $pcaption='COMPLETAR DATOS'; $psize=$xfontsize;
			$ponclick="user_dato()";
		include('vrbutton.php'); ?>
		</td>
	</tr>
</table>	
<?php } ?>
<?php if($user_datosok==1){?>        
						<table cellspacing="0" cellpadding="2" width="100%" 
                   style="font-family:arial;font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;background-color:white;">
<tr>
  <td>
<table>
	<tr>
	<?php $pcaption="CEDULA : "; $ptabla='enti'; $pcodigo=$user_cedula; $psize=$xfontsize+3; $pcolu='codigo'; include('vrsaycod.php');?>
	</tr>
	<tr>
	<?php $pcaption="NOMBRE : "; $ptabla='enti'; $pcodigo=$user_cedula; $psize=$xfontsize+3; $pcolu='descri'; include('vrsaycod.php');?>
	</tr>
	<tr>
	<?php $pcaption="Dirección : "; $ptabla='enti'; $pcodigo=$user_cedula; $psize=$xfontsize+3; $pcolu='calle1'; include('vrsaycod.php');?>
	</tr>	
</table>	
  </td>
  <td>
    <table>
      
    <tr style="<?php if($user_tipo=='invi'){echo 'display:none;';}?>">
        <?php 	$pidtxt='enti2'; $pcaption='EMPRESARIO'; $ptabla='enti'; $pexact=1;  $psize=$xfontsize; include('vrgetcod.php'); ?>
    </tr>
    <tr style="<?php if($user_tipo=='invi'){echo 'display:none;';}?>">
        <?php 	$pidtxt='telef'; $pcaption='TELEFONO';  $plong=10; $psize=$xfontsize; include('vrgetnum.php'); ?>
    </tr>
    <tr>
    <td></td>
<!-- 		<td width="10%" align="right"> -->
    <td>
		<?php $pidtxt='f_orden';  $pcaption='ORDENAR PEDIDO'; $psize=$xfontsize;
			$ponclick="if(confirm('Ordenar Pedido ?')){php_func('carr2clie(".$idcarr.",'+document.getElementById('enti2').value+')');hoja_carr('PANT0');};";
		include('vrbutton.php'); ?>
		</td>
					<td align="center" style="display:none;">
					<?php $pidtxt='detadocu'; $pcaption=''; $ponclick=''; $psize=$xfontsize; $pdefa=0; include('vrchkbox.php'); ?>
					</td>
      </tr>
    </table>
  </td>
  <td>
<table>
  <tr>
		<?php $pidtxt='f_orden';  $pcaption='IMPRIMIR'; $psize=$xfontsize;
			$ponclick='{window.open("print1.php?prnt=1&docu='.$docu.'&idnum='.$idcarr.'","_blank")}';
		include('vrbutton.php'); ?>
    
  </tr>
        </table>        
    
  </td>
</tr>  
</table>        
        
        
<?php } ?>
        
			<table cellspacing="0" cellpadding="2" width="<?php if($orient=='V'){echo '99%'; }else{echo '100%'; };?>" 
             style="font-family:arial;font-size:<?php echo $xfontsize; ?>px; border-collapse:collapse; background-color:white;">
				<tr>
				<td id="pant0">
						<table cellspacing="0" cellpadding="2" width="100%" 
                   style="font-family:arial;font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;background-color:white;">
						<tr>
							<td>
								<?php 	$pidtxt='cant'; $pcaption='Cantidad';  $pdefa=1; $psize=$xfontsize;
                    $poptn1=1;$poptn2=99;
                    include('vrselopt.php');
                ?>
								<?php 	$pidtxt='item'; $pcaption='Item'; $ptabla='item'; $pdefa=''; $pnotob=0;  $pexact=0; $psize=$xfontsize;
                    $pwhere='and(item_puni>0 and (item_hoja=1 or item_ctlg=1))';
                    include('vrgetcod.php');
                ?>
								<?php 	$pidtxt='deta'; $pcaption='NOTAS'; $plong=30; $psize=$xfontsize; include('vrgettxt.php'); ?>
							</td>
							<td align="left">
								<?php 	$pidtxt='agregar'; $pcaption='Agregar'; $psize=$xfontsize;
                    $ponclick ='add_carr("'.$idcarr.'",document.getElementById("item").value,"cant","deta");'; 
                    $ponclick.='hoja_carr("PANT1");'; 
                    include('vrbutton.php'); ?>
							</td>
						</tr>
						</table>
				</td>	
				</tr>	
			</table>
<?php } ?>			

  </div>	
		<div id="pant1" style="border:solid 1px; overflow:auto; font-family:arial;">
		<div id="tpant1b"></div>
    </div>
		<hr>
		<div id="pant11" style="border:solid 1px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant2"  style="border:solid 1px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant9"></div>
	
<?php if(mb_stristr('PANT1',$pant)) { ?>
  
<?php
  
$docuiimp=1;
$sql_pant='select * from carr12 where idnum1="'.$idcarr.'"';

	$total_sql ='max(detalle) as mdetalle,';
	$total_sql.='sum(tcant) as stcant,';
	$total_sql.='sum(tsubt) as stsubt,';
	if($docuiimp==1)
	{
		$total_sql.='sum(tsubtiva0) as stsubtiva0,';
		$total_sql.='sum(tsubtiva) as stsubtiva,';
		$total_sql.='sum(tsubtice) as stsubtice,';
		$total_sql.='sum(tdcto) as stdcto,';
		$total_sql.='sum(tprop) as stprop,';
		$total_sql.='sum(tice) as stice,';
		$total_sql.='sum(tiva) as stiva,';
		$total_sql.='sum(tirbp) as stirbp,';

		$total_sql.='max(dcto) as pdcto,';
		$total_sql.='max(prop) as pprop,';
		$total_sql.='max(ice) as pice,';
		$total_sql.='max(iva) as piva,';
		$total_sql.='max(irbp) as pirbp,';
	}
	$total_sql.='sum(total) as stotal ';

  $sql_tpant=str_replace('select *','select *,'.$total_sql,$sql_pant);
  $sql_pant=str_replace('select *','select *,'.$total_sql,$sql_pant);
  $sql_tpant=$sql_pant;
  
  $sql_pant.=' group by idnum2,iddet ';
  $sql_pant.=' order by iddet ';
  
$res_pant=mysql_query($sql_pant,$link_vcrx);
$res_tpant=mysql_query($sql_tpant,$link_vcrx);
  
  
		$tcant=mysql_result($res_tpant,0,'stcant');
		$tsubt=mysql_result($res_tpant,0,'stsubt');
    $tdetalle=mysql_result($res_tpant,0,'mdetalle');
		if($docuiimp==1)
		{
			$tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
			$tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
			$tdcto=mysql_result($res_tpant,0,'stdcto');
			$tprop=mysql_result($res_tpant,0,'stprop');
			$tice=mysql_result($res_tpant,0,'stice');
			$tiva=mysql_result($res_tpant,0,'stiva');
			$tirbp=mysql_result($res_tpant,0,'stirbp');
		}


		$total=mysql_result($res_tpant,0,'stotal');
  
	$dispcolu=1;
	if($mobile=='true'){$dispcolu=0;}
		if($dispcolu==0)
		{
      $tdetalle='';
			$tsubt=0;
			$tsubtiva=0;	
			$tsubtiva0=0;
			$tdcto=0;
			$tprop=0;
			$tiva=0;
			$tice=0;
			$tirbp=0;

			$trrta=0;
			$triva=0;
		}
  
  
?>  
		<pant1>
		<?php $crow=0; ?>
		<table id="tpant1" class="pant1" border="0"
					 align="center" border="0" cellpadding="3" width="100%"
					 style="font-size:<?php if($orient=='V'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
						border-collapse:collapse;background-color:white;"
						>
			<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
  				<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Linea">L</th>
				<?php if($docuiimp==1){ ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Código" style="<?php if($dispcolu==09){echo'display:;';}?>">Código</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Descripción">Descripción</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Cantidad">Cant</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Prec.Unitario">P.Uni</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tsubt==0){echo'display:none;';}?>">SUB-TOT</th>			
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tdcto==0){echo'display:none;';}?>">DCTO</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tprop==0){echo'display:none;';}?>">PROP</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tice==0){echo'display:none;';}?>">ICE</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tiva==0){echo'display:none;';}?>">IVA</th>	
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="<?php if($tirbp==0){echo'display:none;';}?>">IRBP</th>
				<?php } ?>
          <th onclick="sortTable(this,<?php echo $ccol++; ?>);">TOTAL</th>
          <th onclick="sortTable(this,<?php echo $ccol++; ?>);" style="letter-spacing:10px;<?php if($dispcolu==0){echo'display:none;';}?>">NOTAS</th>
<!--           <th onclick="" <?php $ccol++; ?> align="center" title="Eliminar">X</th> -->
				<th width="10%" align="right">
					<span style="display:none;">ELIMINAR</span>
					<?php $pidtxt='f_elim';  $pcaption='ELIMINAR TODO';  $psize=$xfontsize; if($mobile=='true' or 1==1){$pabrev="X";}; $psize=$xfontsize+3;
					$ponclick="if(confirm('Limpiar Hoja ?')){php_func('del_carr(".$idcarr.")');hoja_carr('PANT0');};";
// 					$ponclick="if(confirm('Vaciar Carrito ?')){del_carr('".$idcarr."');carr_clie();};";
// 					$ponclick='';
					include('vrbutton.php'); ?>
				</th>
          
				</tr>
			</thead>
<!-- 		  <tbody id="tpant1b" style="overflow-y:auto; overflow-x:hidden; display:block; border-bottom:solid 1px; --> 
			<tbody id="tpant1b" style="overflow-y:auto; display:block; 
					<?php if($orient=='V'){echo'min-height:'.($hpant2-75).'px;';}else{echo'min-height:'.($hpant2-90).'px;';}  ?> 
					<?php if($orient=='V'){echo'height:'.($hpant2-75).'px;';}else{echo'height:'.($hpant2-90).'px;';}  ?> ">
			<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
			<?php $crow++; ?>
			<?php $duni=$aso_pant['item_duni']; ?>
			<?php $dpre=$aso_pant['item_dpre']; ?>
			<?php $dval=$aso_pant['item_dval']; ?>
			<?php 
          $icodigov=$aso_pant['item_codigov'];
          if($icodigov=='')
          $icodigov=$aso_pant['item'];
            
      ?>
			<?php if($dval==0){$dval=2;} ?>
			<?php if($dpre==0){$dpre=2;} ?>
			<?php if($duni==0){$duni=0;} ?>
			<?php if(ceil($aso_pant['cant'])!=floor($aso_pant['cant']) and $duni==0){$duni=2;} ?>
      <tr id="tr_fila<?php echo $crow;?>" class="tr_fila" valign="top" height="<?php //if($mobile=='true'){echo '55px';};?>"
          style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> "
          onmouseover="_filabg(event,'tr_fila','<?php echo $crow; ?>','');"
          onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
                  {if(document.getElementById('detadocu').checked)
                  {info_docu('PANT2','<?php echo $aso_pant['docu']; ?>','<?php echo $aso_pant['idnum1']; ?>');}}
                  <?php if($touchs=='true'){?>
                  <?php } ?>
                   "
          >
				<td align="center" style="font-size:80%;">
					<span style="display:none;"><?php echo fillzero($crow); ?></span><?php echo $aso_pant['iddet']; ?>
				</td>
				<?php if($docuiimp==1){ ?>
					<td align="left" style="<?php if($dispcolu==09){echo'display:;';}?>" title="<?php echo $aso_pant['item']; ?>">
						<?php echo $icodigov; ?>
					</td>
					<td align="left" title="<?php echo $aso_pant['itemce']; ?>"
								style="">
						<?php echo $aso_pant['item_descri']; ?>
					</td>
					<td align="center"><?php echo number_format(abs($aso_pant['cant']),$duni); ?></td>
					<td align="right" >
						<div style="display:none;"><?php echo fillzero($aso_pant['puni'],15); ?></div>
						<?php echo number_format(abs($aso_pant['puni']),$dpre); ?>
					</td>
					<td align="right" style="<?php if($tsubt==0){echo'display:none;';} ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tsubt'],15); ?></div>
						<?php echo number_format(abs($aso_pant['tsubt']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tdcto==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['dcto']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tdcto'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tdcto']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tprop==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['prop']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tprop'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tprop']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tice==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['ice']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tice'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tice']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tiva==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['iva']),$dval).'%'; ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tiva'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tiva']),$dval); ?>
					</td>
					<td align="right" style="<?php if($tirbp==0){echo'display:none;';} ?>font-style:italic;" title="<?php echo number_format(abs($aso_pant['irbp']),$dval); ?>">
						<div style="display:none;"><?php echo fillzero($aso_pant['tirbp'],9); ?></div>
						<?php echo number_format(abs($aso_pant['tirbp']),$dval); ?>
					</td>
				<?php } ?>
					
						<td align="right" style="<?php if($total==0){echo'display:none;';} ?>">
								<div style="display:none;"><?php echo fillzero($aso_pant['total'],15); ?></div>
								<?php echo number_format(abs($aso_pant['total']),$dval); ?>
						</td>
						<td align="left" style="<?php if($dispcolu==0){echo'display:none;';} ?>
																		<?php if(strlen(trim($aso_pant['detalle']))>20){echo 'font-size:80%';} ?>">
							<?php if(trim($aso_pant['detalle'])!=trim($aso_pant['item_descri'])){echo $aso_pant['detalle'];};?></td>
						<td align="center" style="">
							<?php $pidtxt='del_'.$aso_pant['iddet'].$aso_pant['iddet'];
							$pcaption='X';
							$ptitle='Eliminar'.$aso_pant['item_codigov'];
							$pabrev='X'; $psize=$xfontsize+3;
							$ponclick ="if(confirm('Eliminar Código : ".$aso_pant['item_codigov']."-".$aso_pant['item_descri']." ?'))";
							$ponclick.="{php_func('del_carr(".$aso_pant['idnum1'].",".$aso_pant['iddet'].")');hoja_carr('PANT0');};";
							include('vrbutton.php'); ?>
						</td>

            <?php if($modi_docu==1){?>
<!--             <td align="center">X</th> -->
            <?php }?>
				</tr>

			<?php } ?>
			</tbody>	
			<tfoot style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-top:solid 1px;">
					<th></th>
					<th></th> 
					<th style="letter-spacing:10px; "><?php {echo 'TOTALES';} ?></th>
					<th><?php echo number_format(abs($tcant),2); ?></th>
					<th></th>
					<?php if($docuiimp==1){ ?>
						<th align="right" style="<?php if($tsubt==0){echo'display:none;';}?>">
							<?php echo number_format(abs($tsubt),2); ?>
						</th>
						<th align="right" style="<?php if($tdcto==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tdcto),2); ?>
						</th>	
						<th align="right" style="<?php if($tprop==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tprop),2); ?>
						</th>	
						<th align="right" style="<?php if($tice==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tice),2); ?>
						</th>	
						<th align="right" style="<?php if($tiva==0){echo'display:none;';}?> font-style:italic;" >
							<?php echo number_format(abs($tiva),2); ?>
						</th>	
						<th align="right" style="<?php if($tirbp==0){echo'display:none;';}?> font-style:italic;">
							<?php echo number_format(abs($tirbp),2); ?>
						</th>	
				<?php } ?>
					<th align="right">
						<?php echo number_format(abs($total),2); ?>
					</th>
					<th></th>
					<th></th>

        
        </tr>
      </tfoot>
      
			</table>

			<pant1>
				
<?php } ?>			
			
<?php if(mb_stristr('PANT2',$pant)) { ?>
			<pantd>
			<?php $user_sql='select * from user00 where enti_codigo ="'.$enti.'"';	?>
			<?php $res_carr=mysql_query($user_sql,$link_vcrx); ?>
			<b>
			<?php echo mysql_result($res_carr,0,'user_descri'); ?>
				</b>
			</pantd>
	
			<pant2>
				<?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;

				$res_carr=mysql_query($user_sql,$link_vcrx); 
// 			 echo mysql_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($aso_carr=mysql_fetch_assoc($res_carr)){ ?>
				<?php if ($aso_carr['faniot']!=$ufaniot) { $ufaniot=$aso_carr['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 ($aso_carr['fmes']%4==0) {echo 'border-bottom:dotted 1px ; ';} ?>">
					<td>
					<?php if($aso_carr['fanio'].$aso_carr['fmes']>=$prdoa){ ?>
<!-- 					<div id="scrollhere" ></div> -->
					<?php } ?>
								<?php 	$pidtxt='regis'.$aso_carr['idnum1']; $pcaption='Registro'; $pabrev='R'; 
										$ponclick='hoja_carr("PANT1","'.$aso_carr['enti'].'","'.$aso_carr['fanio'].'","'.$aso_carr['fmes'].'")';
										include('vrbutton.php');
								?>
					</td>
					<td align="left">
						<?php echo $aso_carr['fanio'].' /'.$aso_carr['fmesn'] ?>
					</td>
					<td align="center">
						<?php echo number_format($aso_carr['public'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($aso_carr['presen'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($aso_carr['horas'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($aso_carr['revisi'],0) ?>
					</td>
					<td align="center">
						<?php echo number_format($aso_carr['cursos'],0) ?>
					</td>
					<td align="left">
						<?php echo $aso_carr['concepto'] ?>
					</td>
				</tr>
					<?php $tpublic+=$aso_carr['public']; ?>
					<?php $tpresen+=$aso_carr['presen']; ?>
					<?php $thoras+=$aso_carr['horas']; ?>
					<?php $trevisi+=$aso_carr['revisi']; ?>
					<?php $tcursos+=$aso_carr['cursos']; ?>
				
				<?php if($aso_carr['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>
			</pant2>
	
<?php } ?>			
			
<?php if(mb_stristr('USERR.RPCI',$pant)) { ?>
			<?php
				$user_sql='select * from user00 where enti_codigo ="'.$enti.'"';
				$res_carr=mysql_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=mysql_query($rpc1_sql,$link_vcrx);
// 	echo $rpc1_sql;
	
	
			$head1=0;
			$foot1=0;
	
			if($mes==9){$head1=1;}
			else
			{
				$rpc1_res=mysql_query($rpc1_sql,$link_vcrx);
				if(mysql_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(mysql_result($res_carr,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(mysql_result($res_carr,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(mysql_result($res_carr,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 mysql_result($res_carr,0,'user_descri') ?>
					</td>
				</tr>
				<tr style="height:4mm;">
<!-- 					<td></td> -->
					<td colspan="5">
						<?php echo mysql_result($res_carr,0,'user_calle1').' '.mysql_result($res_carr,0,'user_calle2') ?>
					</td>
				</tr>
				<tr style="height:5mm;">
<!-- 					<td></td> -->
					<td style="width:30mm;">
						<?php echo mysql_result($res_carr,0,'user_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo mysql_result($res_carr,0,'user_telefono') ?>
					</td>
					<td style="width:25mm;"></td>
					<td style="width:25mm;">
						<?php echo mysql_result($res_carr,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 mysql_result($res_carr,0,'user_fechainidmy') ?>
			</div>
		</div>		
	
<?php		//		$rpc1_res=mysql_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=mysql_query($rpcm_sql,$link_vcrx);
							$cfecha=date('Y-m-01',strtotime($cfecha.' +1 month'));
// 																echo $rpcm_sql;
					?>
					<?php if (mysql_num_rows($rpcm_res)!=0) {?>
					<?php if($cmes==12){$foot1=1;} ?>
					<td>
					</td>	
					<td align="center" >
						<?php echo number_format(mysql_result($rpcm_res,0,'public'),0);  ?>
					</td>
					<td align="center" >
						<?php echo number_format(mysql_result($rpcm_res,0,'presen'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(mysql_result($rpcm_res,0,'horas'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(mysql_result($rpcm_res,0,'revisi'),0); ?>
					</td>
					<td align="center" >
						<?php echo number_format(mysql_result($rpcm_res,0,'cursos'),0); ?>
					</td>
					<td align="left" >
						<?php echo mysql_result($rpcm_res,0,'concepto') ?>
					</td>
					<?php $tpublic+=mysql_result($rpcm_res,0,'public'); ?>
					<?php $tpresen+=mysql_result($rpcm_res,0,'presen'); ?>
					<?php $thoras+=mysql_result($rpcm_res,0,'horas'); ?>
					<?php $trevisi+=mysql_result($rpcm_res,0,'revisi'); ?>
					<?php $tcursos+=mysql_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>
