Incam_Intranet/vacaciones.php

194 lines
5.6 KiB
PHP
Raw Permalink Normal View History

<?php
include("seguridad.php");
include("functions.php");
/*
* S<EFBFBD>lo los t<EFBFBD>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);
$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'];
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
$permisos=new Permisos($usuario,$usuario->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
$back="vacaciones.php";
if($_POST['action']){
switch ($_POST['action']) {
case "pedir":
$ultimo_dia = verifica_long_mes($mes_hoy,$ano_hoy);
// Recorremos todos los valores de los d<>as
$dias=array();
for($i=1;$i<=$ultimo_dia;$i++){
if($_POST['d'.$i.'-'.$mes_hoy]=="on"){
//if($vacaciones->esSolicitable($i)){
$dias[$i]="";
//}
}
}
try{
$vacaciones->solicitar($dias);
$tipo="ok";
$msg=$locale['290'];
foreach($dias as $diaShow => $mensaje){
$msg.=$diaShow." ";
}
} 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();
for($i=1;$i<=$ultimo_dia;$i++){
if($_POST['a'.$i.'-'.$mes_hoy]=="on"){
//if($vacaciones->esAnulable($i)){
$dias[$i]="";
//}
}
}
try{
$vacaciones->solicitarAnulacion($dias);
$tipo="ok";
$msg=$locale['464'];
foreach($dias as $diaShow){
$msg.=$diaShow." ";
}
} catch (Exception $e){
$tipo="error";
$msg=$e->getMessage();
}
break;
case "eliminar":
$ultimo_dia = verifica_long_mes($mes_hoy,$ano_hoy);
// Recorremos todos los valores de los d<>as
$dias=array();
for($i=1;$i<=$ultimo_dia;$i++){
if($_POST['e'.$i.'-'.$mes_hoy]=="on"){
//if($vacaciones->esAnulableSolicitud($i)){
$dias[$i]="";
//}
}
}
try{
$vacaciones->eliminarSolicitud($dias);
$tipo="ok";
$msg=$locale['471'];
foreach($dias as $diaShow => $mensaje){
$msg.=$diaShow." ";
}
} catch (Exception $e){
$tipo="error";
$msg=$e->getMessage();
}
break;
default:
break;
}
}
if($msg!=""){
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
}
?>
<ul id="tabnav">
<li class='activo'><a href="vacaciones.php"><?php echo $locale['328']; ?></a></li>
<li class='inactivo'><a href="vacacionesAnual.php"><?php echo $locale['329']; ?></a></li>
</ul>
<div id="ContTabul">
<div style="float:left; width:48%;">
<!-- Calendario mensual -->
<b><?php echo $locale['015']; ?></b><br /><?php
$diaoff=substr(constante("daycacationsoff"),0,2);
$mesoff=substr(constante("daycacationsoff"),3,2);
$diaCierreVac=mktime(0,0,0,$mesoff,$diaoff,date('Y'));
$hoy=mktime(0,0,0,date('m'),date('d'),date('Y'));
if($hoy>$diaCierreVac){
// este y posterior
echo "(".date('Y').") ".$usuario->getDiasVacaciones(date('Y'))."<br />";
$pos=date('Y')+1;
echo "(".$pos.") ".$usuario->getDiasVacaciones($pos);
} else {
$pos=date('Y')-1;
echo "(".$pos.") ".$usuario->getDiasVacaciones($pos). "<br />";
echo "(".date('Y').") ".$usuario->getDiasVacaciones(date('Y'));
}
?>
<form id="vacaciones" action="vacaciones.php" method="post" name="vacaciones">
<input type="hidden" name="mes" value="<?php echo $mes_hoy; ?>" />
<input type="hidden" name="anio" value="<?php echo $ano_hoy; ?>" />
<?php
$vacaciones=new Vacaciones($usuario,$usuario->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
include_once("ver_vacaciones.php");
?>
<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']; ?>" />
<input type="button" class="button" onClick="javascript:submitform('eliminar')" value="<?php echo $locale['470']; ?>" />
</form>
</div>
<div style="float:right; ">
<?php echo $html->leyendaVacaciones(); ?>
</div>
<div style="clear:both;"></div>
<?php
// Mostramos las observaciones de las solicitudes rechazadas
$vacApro=$vacaciones->getVacApro();
$vacRech=$vacaciones->getVacRech();
$vacPend=$vacaciones->getVacPend();
$vacSoli=$vacaciones->getVacSoli();
$todosDias=array_merge($vacSoli,$vacApro,$vacRech,$vacPend);
sort($todosDias);
if(count($todosDias)>0){
echo $locale['562']."<br />";
foreach($todosDias as $dia){
echo "<b>".$dia.$locale['de'].nombre_mes($mes_hoy).$locale['de'].$ano_hoy."</b> : ";
if($vacaciones->getObservacionRRHH($dia)!=""){
echo "<span class=\"comentarioRRHH\">".$vacaciones->getObservacionRRHH($dia)."</span>";
}
echo "<br />";
}
}
?>
</div>
<?php
include_once("html/pie.php");
?>