<?php
 
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
?>
<?php
 
include("DN61000_CL.php");
?>
<?php

	$botmod=-1;
	if ($_POST['bot']==""){
		echo '<h2>!!! SELECCIONA UN REGISTRO... ACTUALIZANDO !!!</h2>';
		echo '<meta content="1; url=DN61000_PR.php"  HTTP-EQUIV="REFRESH">';
		exit();
	}
	else{
		$sqbusqx=mysqli_query($con ,"select * from dntrab_a where no_trab = '".$_POST['bot']."'");
		$arbusq=mysqli_fetch_array($sqbusqx);
		$sqbusqx=mysqli_query($con ,"select * from dntrab_b where no_nom = '".$_POST['bot']."'");
		$arbusqx=mysqli_fetch_array($sqbusqx);
		$sqbcm=mysqli_fetch_array(mysqli_query($con ,"select * from dncatper where no_pd = '".$_POST['secatpd']."' and operac = '".$_POST['seperded']."'"));
	}
	$busproc=mysqli_query($con ,"select * from dnpargen");
	$arbusproc=mysqli_fetch_array($busproc);
	//$m=substr($_SESSION['m_a'],0,2);
	$a=$_SESSION['axo_pro'];
	$nomusu = new clase('dnnomanu',$a,$_POST['bot'],$_SESSION['num_usu']);
	if(isset($_POST['boagregar'])){
		$ag=$nomusu->agregar($_POST['seperded'],$_POST['secatpd'],$_POST['tecan'],$_POST['tenepa'],$sqbcm["cve_mae"],$_POST['tegis'],$_POST['teexis'],$_POST['tegim'],$_POST['teexim']);
	}
	elseif(isset($_POST['bomodificar'])){
		$nod=$nomusu->lstBusqElem($_POST['bot2']);
		$modusu = mysqli_fetch_array($nod);
	}
	elseif(isset($_POST['bomodificara'])){
		$ag=$nomusu->modifica($_POST['bot3'],$_POST['seperded'],$_POST['secatpd'],$_POST['tecan'],$_POST['tenepa'],$sqbcm["cve_mae"],$_POST['tegis'],$_POST['teexis'],$_POST['tegim'],$_POST['teexim']);
	}
	elseif(isset($_POST['boeliminar'])){
		$nomusu->eliminar($_POST['bot2']);
	}
	$detnom=$nomusu->listaBusq();
	 ?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

<body>
 <?php
 
$ayuda = 'DN6100A_AG.php';
include("DYAYUDA.php");
?>
<form id="frm1" name="frm1" method="post" action="DN61000_AG.php">
<input name="pp" type="hidden" value="1">
  <div align="center">
    <input type="hidden" name="bot" id="bot" value="<?php
 echo $_POST['bot'];?>">
	<input type="hidden" name="setipnom" id="setipnom" value="<?php
 echo $_POST['setipnom'];?>">
	<input type="hidden" name="tenonom2" id="tenonom2" value="<?php
 echo $_POST['tenonom2'];?>">
	  
	 <input type="hidden" name="tefecini" id="tefecini" value="<?php
 echo $_POST['tefecini'];?>">
	 <input type="hidden" name="tefecfin" id="tefecfin" value="<?php
 echo $_POST['tefecfin'];?>">
	
	<input type="hidden" name="bot3" id="bot3" value="
	<?php
 
	if(isset($_POST['bomodificar'])){
		echo $_POST['bot2'];
	}
	else{
		echo $_POST['bot3'];
	}
	?>">
  </div>
  <table width="852"  align="center">
    <tr>
      <th colspan="6">DETALLE DE NOMINA  </th>
    </tr>
    <tr>
      <th colspan="6">Catalogo de Empleado </th>
    </tr>
    <tr>
      <th width="106"><div align="center">No. Nomina</div></th>
      <th width="149"><div align="center">Apellido Paterno</div></th>
   	  <th width="162"><div align="center">Apellido Materno</div></th>
  	  <th width="159"><div align="center">Nombre</div></th>
   	  <th width="110"><div align="center">R.F.C.</div></th>
	  <th width="126"><div align="center">No. IMSS</div></th>
    </tr>
    <tr>
      <td><div align="center"><?php
 echo $arbusq["no_nom"]; ?>&nbsp;</div></td>
      <td><div align="center"><?php
 echo $arbusq["ape_pat"]; ?>&nbsp;</div></td>
      <td><div align="center"><?php
 echo $arbusq["ape_mat"]; ?>&nbsp;</div></td>
      <td><div align="center"><?php
 echo $arbusq["nom"]; ?>&nbsp;</div></td>
      <td><div align="center"><?php
 echo $arbusqx["rfc"]; ?>&nbsp;</div></td>
      <td><div align="center"><?php
 echo $arbusqx["seg_soc"];?>&nbsp;</div></td>
    </tr>
  </table>
  	<div align="center">
  	  <input name="boregresar" type="button" id="boregresar" onClick="openpage('DN61000_PR.php','_self')" value="Regresar"/>
  	  <br>
    </div>
  	<div align="center">
  	  <table width="50%" >
      <?php
 
	  if($mensaje){
		  echo '<tr>';
		  echo '<td><div align="center">'.$mensaje.'</div></td>';
		  echo '</tr>';
	  }
	  ?>
    </table>
    <br>
	<table  >
      <tr>
        <th colspan="10" ><div align="center">Detalle de Nominas </div></th>
      </tr>
      <tr>
        <th >Per. / Ded.</th>
        <th >No.</th>
        <th>Descripcion</th>
        <th >Cantidad</th>
        <th >Importe</th>
        <th >Grab./ Ispt</th>
        <th >Grab./IMSS</th>
		<th >Exe./ Ispt</th>
        <th >Exe./IMSS</th>
      </tr>
	  <?php
 
		$totales[0]=0.0;
		$totales[1]=0.0;
		$lab="P";
		$ent=-1;
		while($adetnom=mysqli_fetch_array($detnom)){
			$dncapx=mysqli_query($con ,"select * from dncatper where no_pd = '".$adetnom['no_pd']."' and operac='".$adetnom['operac']."'");
			$dncapxx=mysqli_fetch_array($dncapx);
			if($ent==-1) $ent=0;
			if($adetnom["operac"]!=$lab){
					echo '<tr class="tdagre1">';
					echo '<td colspan="10" ><div align="center" class="style2 Estilo3"><em>Total Percepciones='.number_format($totales[$ent],2,'.',',').'</em></div></td>';
					echo '</tr>';
					echo '<tr class="inputcodigo">';
					echo '<td colspan="10" ><div align="center" class="style2 Estilo3">&nbsp;<em></em></div></td>';
					echo '</tr>';
					$lab=$adetnom["operac"];
					$ent=1;
			}
			
			if($adetnom["no_reg"]!=$botmod){
				echo '<tr>';
				echo '<td><div align="center">'.$adetnom["operac"].'&nbsp;</div></td>';
				echo '<td><div align="center">'.$adetnom["no_pd"].'&nbsp;</div></td>';
				echo '<td>'.$dncapxx["des_perc"].'&nbsp;</td>';
				echo '<td>'.$adetnom["can_mov"].'&nbsp;</td>';
				echo '<td>'.$adetnom["imp_mov"].'&nbsp;</td>';
				echo '<td>'.$adetnom["imp_gra_isp"].'&nbsp;</td>';
				echo '<td>'.$adetnom["imp_gra_ims"].'&nbsp;</td>';
				echo '<td>'.$adetnom["imp_exe_isp"].'&nbsp;</td>';
				echo '<td>'.$adetnom["imp_exe_ims"].'&nbsp;</td>';
				echo '</tr>';
				$totales[$ent] += $adetnom["imp_mov"];
			}
		}
		if($ent!=-1){
			if($ent==0) $tipdp='Percepciones';
			else $tipdp='Deducciones';
			echo '<tr class="tdagre1">';
			echo '<td colspan="10" ><div align="center" class="style2 Estilo3"><em>Total '.$tipdp.' ='.number_format($totales[$ent],2,'.',',').'</em></div></td>';
			echo '</tr>';
		}
		echo '<tr class="tdagre1">';
		echo '<td colspan="10" ><div align="center" class="style2 Estilo3"><em>Neto a Pagar='.number_format(($totales[0]-$totales[1]),2,'.',',').'</em></div></td>';
		echo '</tr>';
	  
	  ?>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  </div>
</form>
</body>
</html>
