git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk/src@1 e2b1556b-49f8-d141-9351-52d6861a72d9
161 lines
4.5 KiB
PHP
161 lines
4.5 KiB
PHP
<?php
|
|
include("seguridad.php");
|
|
include("functions.php");
|
|
|
|
/*
|
|
* Sólo los técnicos
|
|
*/
|
|
if(!$usuario->tieneRol("6")){
|
|
header("Location: aplicacion.php?e=permiso");
|
|
echo "no puedes";
|
|
exit;
|
|
}
|
|
|
|
include_once("html/cabecera.php");
|
|
|
|
?>
|
|
<SCRIPT language="JavaScript">
|
|
function submitform(action)
|
|
{
|
|
campoIdEstado=document.createElement("input");
|
|
campoIdEstado.type="hidden";
|
|
campoIdEstado.name="action";
|
|
campoIdEstado.value=action;
|
|
|
|
var formulario=document.getElementById('vacaciones');
|
|
formulario.appendChild(campoIdEstado);
|
|
document.vacaciones.submit();
|
|
}
|
|
</SCRIPT>
|
|
<h2><?php echo $locale['466']; ?></h2>
|
|
<?php
|
|
|
|
include_once("Objects/Permisos.php");
|
|
include_once("Objects/HTML.php");
|
|
$html=new HTML($locale);
|
|
|
|
$mes_hoy=date("m");
|
|
if($_GET['mes']!="") $mes_hoy=$_GET['mes'];
|
|
if($_POST['mes']!="") $mes_hoy=$_POST['mes'];
|
|
|
|
$ano_hoy=date("Y");
|
|
if($_GET['anio']!="") $ano_hoy=$_GET['anio'];
|
|
if($_POST['anio']!="") $ano_hoy=$_POST['anio'];
|
|
|
|
if($_POST['action']){
|
|
// me quedo con todo de POST menos anio,y action
|
|
$quitar=array("anio"=>"","action"=>"");
|
|
$solicitud=$_POST;
|
|
$solicitud=array_diff_key($solicitud,$quitar);
|
|
switch ($_POST['action']) {
|
|
case "pedir":
|
|
$ultimo_dia = verifica_long_mes($mes_hoy,$ano_hoy);
|
|
// Recorremos todos los valores de los días
|
|
$dias=array();
|
|
foreach($solicitud as $key => $valor){
|
|
if($valor=="on"){
|
|
$trozos=explode("-",$key);
|
|
$anio=substr($trozos[0],1,strpos($trozos[0],"-")-1);
|
|
$mes=$trozos[1];
|
|
$dia=$trozos[2];
|
|
// Compruebo que sea solicitable
|
|
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mes,$ano_hoy,$locale);
|
|
$dias[$mes][]=$dia;
|
|
}
|
|
}
|
|
try{
|
|
$tipo="ok";
|
|
$msg="";
|
|
foreach($dias as $mensual => $diasSolicitar){
|
|
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mensual,$ano_hoy,$locale);
|
|
$permisos->solicitar($diasSolicitar);
|
|
foreach($diasSolicitar as $diaShow){
|
|
$msg.=$diaShow." de ".nombre_mes($mensual)."<br />";
|
|
}
|
|
}
|
|
$msg=$locale['290']."<br />".$msg;
|
|
} catch (Exception $e){
|
|
$tipo="error";
|
|
$msg=$e->getMessage();
|
|
}
|
|
break;
|
|
|
|
case "anular":
|
|
$ultimo_dia = verifica_long_mes($mes_hoy,$ano_hoy);
|
|
// Recorremos todos los valores de los días
|
|
$dias=array();
|
|
foreach($solicitud as $key => $valor){
|
|
if($valor=="on"){
|
|
$trozos=explode("-",$key);
|
|
$anio=substr($trozos[0],1,strpos($trozos[0],"-")-1);
|
|
$mes=$trozos[1];
|
|
$dia=$trozos[2];
|
|
// Compruebo que sea solicitable
|
|
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mes,$ano_hoy,$locale);
|
|
$dias[$mes][]=$dia;
|
|
}
|
|
}
|
|
try{
|
|
$tipo="ok";
|
|
$msg="";
|
|
foreach($dias as $mensual => $diasSolicitar){
|
|
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mensual,$ano_hoy,$locale);
|
|
$permisos->solicitarAnulacion($diasSolicitar);
|
|
foreach($diasSolicitar as $diaShow){
|
|
$msg.=$diaShow." de ".nombre_mes($mensual)."<br />";
|
|
}
|
|
}
|
|
$msg=$locale['464']."<br />".$msg;
|
|
} catch (Exception $e){
|
|
$tipo="error";
|
|
$msg=$e->getMessage();
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
if($msg!=""){
|
|
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
|
}
|
|
|
|
?>
|
|
<ul id="tabnav">
|
|
<li class='inactivo'><a href="permisos.php?mes=<?php echo $mes_hoy."&anio=".$ano_hoy; ?>"><?php echo $locale['328']; ?></a></li>
|
|
<li class='activo'><a href="permisosAnual.php?mes=<?php echo $mes_hoy."&anio=".$ano_hoy; ?>"><?php echo $locale['329']; ?></a></li>
|
|
</ul>
|
|
|
|
<div id="ContTabul">
|
|
<form id="vacaciones" action="permisosAnual.php" method="post" name="vacaciones">
|
|
|
|
<?php
|
|
for($mes_hoy=1;$mes_hoy<=12;$mes_hoy++){
|
|
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
|
?>
|
|
<div style="float:left;margin-left:10px; margin-bottom:10px">
|
|
<!-- Calendario mensual -->
|
|
<input type="hidden" name="anio" value="<?php echo $ano_hoy; ?>" />
|
|
<?php
|
|
include("ver_permisos.php");
|
|
?>
|
|
|
|
</div>
|
|
<?php
|
|
if($mes_hoy%2==0){
|
|
echo "<div style=\"clear:both;\"></div>";
|
|
}
|
|
}
|
|
?>
|
|
<div style="clear:both; text-align:center">
|
|
<input type="button" class="button" onClick="javascript:submitform('pedir')" value="<?php echo $locale['466']; ?>" />
|
|
<input type="button" class="button" onClick="javascript:submitform('anular')" value="<?php echo $locale['467']; ?>" />
|
|
|
|
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
include_once("html/pie.php");
|
|
?>
|