git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk/src@1 e2b1556b-49f8-d141-9351-52d6861a72d9
156 lines
4.3 KiB
PHP
156 lines
4.3 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['611']; ?></h2>
|
||
<?php
|
||
|
||
include_once("Objects/Vacaciones.php");
|
||
include_once("Objects/HTML.php");
|
||
$html=new HTML($locale);
|
||
|
||
$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"){
|
||
$dia=substr($key,1,strpos($key,"-")-1);
|
||
$mes=substr($key,strpos($key,"-")+1,strlen($key));
|
||
// Compruebo que sea solicitable
|
||
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mes,$ano_hoy,$locale);
|
||
$dias[$mes][]=$dia;
|
||
}
|
||
}
|
||
try{
|
||
$tipo="ok";
|
||
$msg="";
|
||
foreach($dias as $mensual => $diasSolicitar){
|
||
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mensual,$ano_hoy,$locale);
|
||
$vacaciones->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"){
|
||
$dia=substr($key,1,strpos($key,"-")-1);
|
||
$mes=substr($key,strpos($key,"-")+1,strlen($key));
|
||
// Compruebo que sea solicitable
|
||
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mes,$ano_hoy,$locale);
|
||
$dias[$mes][]=$dia;
|
||
}
|
||
}
|
||
try{
|
||
$tipo="ok";
|
||
$msg="";
|
||
foreach($dias as $mensual => $diasSolicitar){
|
||
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mensual,$ano_hoy,$locale);
|
||
$vacaciones->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="vacaciones.php"><?php echo $locale['328']; ?></a></li>
|
||
<li class='activo'><a href="vacacionesAnual.php"><?php echo $locale['329']; ?></a></li>
|
||
</ul>
|
||
|
||
<div id="ContTabul">
|
||
<form id="vacaciones" action="vacacionesAnual.php" method="post" name="vacaciones">
|
||
|
||
<?php
|
||
for($mes_hoy=1;$mes_hoy<=12;$mes_hoy++){
|
||
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
||
$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_vacaciones.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['289']; ?>" />
|
||
<input type="button" class="button" onClick="javascript:submitform('anular')" value="<?php echo $locale['463']; ?>" />
|
||
|
||
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<?php
|
||
include_once("html/pie.php");
|
||
?>
|