<?php

include("../bd/sql_variables.php");

$db_conexion= mysql_connect("$sql_host", "$sql_usuario", "$sql_pass") or die(header ("No Disponible Servidor de Base de Datos"));
mysql_select_db("$sql_db");

//$idj = $_GET['idj'];
//$ids = $_GET['ids'];

$idj=$_GET['idj'];
$ids=$_GET['ids'];
$ugid=$_GET['ugid'];

if(isset($_POST['ugid']) && isset($_POST['fecha']) && isset($_POST['descsusp'])){
$ugid=$_POST['ugid'];
$fecha=$_POST['fecha'];
$susdesc=$_POST['descsusp'];
$sqlupdate="update tb_usuasist set ua_estado='0' where ug_id='$ugid'";

$fecha = $_POST['fecha'];
	$uno=substr($fecha, 0, 2);
	$dos=substr($fecha, 3, 2);
	$tres=substr($fecha, 6, 4);
	$fecha = ($tres."/".$dos."/".$uno);
$sqlsuspension ="insert into tb_suspencion values ('$ugid','$fecha',upper('$susdesc'))";
//echo $sqlupdate."<br>";
//echo $sqlsuspension;
$resultultsuspensionusu = mysql_query($sqlupdate);
$resultultregsuspeusu = mysql_query($sqlsuspension);
echo "<script type='text/javascript'>window.opener.location.reload(); window.close();</script>";
}

//seleccionando al personal
$sqlp = "select concat(ua_apepat,' ',ua_apemat,' ',ua_nom) as nombre from tb_usuasist where ug_id='$ugid'";
//echo $sqltc;
$resultp = mysql_query($sqlp);
while ($rowp= mysql_fetch_array($resultp)){
$nombre = $rowp['nombre'];
}
?>
<html>
<head>
<title>SUSPENCION DEL PERSONAL ASISTENCIAL</title>
<link rel="stylesheet" type="text/css" href="styles/Style.css">
<link type="text/css" rel="stylesheet" href="src/css/jscal2.css" />
    <link type="text/css" rel="stylesheet" href="src/css/border-radius.css" />
    <!-- <link type="text/css" rel="stylesheet" href="src/css/reduce-spacing.css" /> -->

    <link id="skin-win2k" title="Win 2K" type="text/css" rel="alternate stylesheet" href="src/css/win2k/win2k.css" />
    <link id="skin-steel" title="Steel" type="text/css" rel="alternate stylesheet" href="src/css/steel/steel.css" />
    <link id="skin-gold" title="Gold" type="text/css" rel="alternate stylesheet" href="src/css/gold/gold.css" />
    <link id="skin-matrix" title="Matrix" type="text/css" rel="alternate stylesheet" href="src/css/matrix/matrix.css" />

    <link id="skinhelper-compact" type="text/css" rel="alternate stylesheet" href="src/css/reduce-spacing.css" />

    <script src="src/js/jscal2.js"></script>
	<script src="src/js/lang/en.js"></script>
    <!-- you actually only need to load one of these; we put them all here for demo purposes -->
     <script src="src/js/lang/es.js"></script>
    
    <link type="text/css" rel="stylesheet" href="demopage.css" />

<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
<script type="text/javascript"> 

function ventanaClose(){ 
   //alert("hola mundo");
    window.close();
} 
</script> 
</head>
<body>
<table align='center'>
<tr><td>
<div id='transfpersonal'>
<form action='suspenderpersonal.php' method='POST'>
<?php
echo "<input type='hidden' id='depa' name='depa' value='".$idj."'>";
echo "<input type='hidden' id='serv' name='serv' value='".$ids."'>";
echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";
?>
<fieldset>
	<legend align='left'><font color='blue' size='15'>Registre Datos de Suspencion </font></legend>
	<br>
		<table align='center' class='FacetFormTABLE' width='450'>
		<tr><td class='FacetFieldCaptionTDT' colspan='3'><center>SUSPENCION DEL PERSONAL ASISTENCIAL</center></td></tr>
		<tr><td colspan='2'><center><?php if($error=='0'){ echo "REVISE LOS DATOS, PERSONAL NO REGISTRADO";}elseif($error=='1'){ echo "PERSONAL REGISTRADO";}?></center></td></tr>
		<tr><td align='right' class='FacetFieldCaptionTD' style='width:300px'>PERSONAL </td><td><?php echo $nombre; ?></td></tr>
		<tr><td align='right' class='FacetFieldCaptionTD'>FECHA DE SUSPENCION</td><td>
		<input type='text' id='fecha' name='fecha' size='15'>
		<button id="f_rangeStart_trigger">...</button>
                <button id="f_clearRangeStart" onclick="clearRangeStart()">clear</button>
                <script type="text/javascript">
				  var LEFT_CAL = Calendar.setup({
                    //cont: "cont",
                    //weekNumbers: true,
                    //selectionType: Calendar.SEL_MULTIPLE,
                    //showTime: 12
                    // titleFormat: "%B %Y"
					})
                  new Calendar({
                          inputField: "fecha",
                          dateFormat: "%d/%m/%Y",
                          trigger: "f_rangeStart_trigger",
                          bottomBar: false,
                          onSelect: function() {
                                  var date = Calendar.intToDate(this.selection.get());
								  LEFT_CAL.setLanguage('es');
                                  LEFT_CAL.args.min = date;
                                  LEFT_CAL.redraw();
                                  this.hide();
                          }
                  });
                  function clearRangeStart() {
                          document.getElementById("fecha").value = "";
                          LEFT_CAL.args.min = null;
                          LEFT_CAL.redraw();
                  };
                </script>
		
		</td></tr>
		<tr><td align='right' class='FacetFieldCaptionTD'>MOTIVO DE SUSPENCION</td><td><input type='text' id='descsusp' name='descsusp' size='80'></td></tr>
		<tr><td align='center' colspan='2'><input type='submit' id='pprog' style='width:150px' class='FacetButton'  value='Suspender'>
		<button type='button' id='pprog' style='width:150px' class='FacetButton' onClick='ventanaClose();' >Cancelar</button>
		</td></tr></table>
	  <br>
	</fieldset>
</div>
</td><tr>
</table>
</body>
</html>