Importación inicial
git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk@1 e2b1556b-49f8-d141-9351-52d6861a72d9
1368
database/selfor.sql
Normal file
208
src/Objects/Administracion.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Administración
|
||||
*
|
||||
* Mantenimiento de las tablas maestras del sistema. Para cada tabla ofrece unos servicios mínimos de:
|
||||
*
|
||||
* - Insertar elemento (addItem)
|
||||
* - Editar elemento (editItem)
|
||||
* - Eliminar elemento (removeItem)
|
||||
* - Obtener tabla (getTabla)
|
||||
*
|
||||
* Adicionalmente puede ofrecer otros servicios para cada tabla.
|
||||
*
|
||||
* 2008-10-21 (diego): Se crea la clase con los métodos necesarios para mantener las
|
||||
* tablas maestras del sistema.
|
||||
*/
|
||||
|
||||
include_once("BD.php");
|
||||
|
||||
class Administracion{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Usuario que tiene sesión activa. */
|
||||
private $usuario;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
/* Información sobre las tablas de sistema*/
|
||||
private $tablasSistema;
|
||||
|
||||
|
||||
//Constructores:
|
||||
|
||||
/**
|
||||
* Crea un objeto encargado de administrar el sistema.
|
||||
* @param usuario - Usuario con sesión activa.
|
||||
* @param locale - Idioma.
|
||||
*/
|
||||
public function Administracion($usuario, $locale){
|
||||
$this->usuario = $usuario;
|
||||
$this->locale = $locale;
|
||||
$this->tablasSistema = array();
|
||||
//perfil, tecnologias, idiomas, titulaciones, tipoVia, provincia, procedenciaCV,
|
||||
//incorporaciones, localidad, constantes, procedencia
|
||||
$this->tablasSistema["perfil"] = array("perfil", "oid", "id", "abrev");
|
||||
$this->tablasSistema["tecnologias"] = array("tecnologia", "oid", "id");
|
||||
$this->tablasSistema["idiomas"] = array("idiomas", "oid", "id");
|
||||
$this->tablasSistema["titulaciones"] = array("titulaciones", "oid", "id");
|
||||
$this->tablasSistema["tipoVia"] = array("tipo_via", "oid", "id");
|
||||
$this->tablasSistema["provincia"] = array("provincias", "oid", "id");
|
||||
$this->tablasSistema["procedenciaCV"] = array("procedencia_cv", "id", "nombre");
|
||||
$this->tablasSistema["incorporaciones"] = array("incorporaciones", "oid", "id");
|
||||
$this->tablasSistema["localidad"] = array("localidades", "oid", "id", "provincia");
|
||||
$this->tablasSistema["constantes"] = array("sistema", "id", "valor");
|
||||
$this->tablasSistema["procedencia"] = array("procedencia", "num", "id", "color");
|
||||
$this->tablasSistema["salario"] = array("salario", "id", "nombre");
|
||||
}
|
||||
|
||||
//Funciones de administración de perfiles:
|
||||
|
||||
public function addItem($vista, $valores){
|
||||
if(!$this->usuario->tieneRol(2)){
|
||||
$error = $this->locale['4039'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
$valoresTabla = $this->tablasSistema[$vista];
|
||||
$tabla = $valoresTabla[0];
|
||||
$campos = array_slice($valoresTabla, 2);
|
||||
if(count($campos) != count($valores)){
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}else{
|
||||
$cadenaCampos = "";
|
||||
foreach($campos as $campo){
|
||||
$cadenaCampos .= $campo.",";
|
||||
}
|
||||
//Quitamos la última coma
|
||||
if ($cadenaCampos{strlen($cadenaCampos) - 1} == ",")
|
||||
$cadenaCampos = substr($cadenaCampos,0,strlen($cadenaCampos) - 1);
|
||||
$cadenaValores = "";
|
||||
foreach($valores as $valor){
|
||||
$cadenaValores .= "'".$valor."',";
|
||||
}
|
||||
//Quitamos la última coma
|
||||
if ($cadenaValores{strlen($cadenaValores) - 1} == ",")
|
||||
$cadenaValores = substr($cadenaValores,0,strlen($cadenaValores) - 1);
|
||||
$consulta = "INSERT INTO ".$tabla." (".$cadenaCampos.") VALUES (".$cadenaValores.")";
|
||||
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function editItem($vista, $valores){
|
||||
if(!$this->usuario->tieneRol(2)){
|
||||
$error = $this->locale['4040'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
$valoresTabla = $this->tablasSistema[$vista];
|
||||
$tabla = $valoresTabla[0];
|
||||
$campoCod = $valoresTabla[1];
|
||||
$cod = $valores[0];
|
||||
$campos = array_slice($valoresTabla, 2);
|
||||
$valores = array_slice($valores, 1);
|
||||
$total = count($campos);
|
||||
if($total != count($valores)){
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}else{
|
||||
$update = "";
|
||||
for($i = 0; $i < $total; $i++){
|
||||
$update .= $campos[$i]." = '".addslashes($valores[$i])."',";
|
||||
}
|
||||
|
||||
//Quitamos la última coma
|
||||
if ($update{strlen($update) - 1} == ",")
|
||||
$update = substr($update,0,strlen($update) - 1);
|
||||
|
||||
$consulta = "UPDATE ".$tabla." SET ".$update." WHERE ".$campoCod."='".$cod."'";
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeItem($vista, $cod){
|
||||
if(!$this->usuario->tieneRol(2)){
|
||||
$error = $this->locale['4041'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
$valoresTabla = $this->tablasSistema[$vista];
|
||||
$tabla = $valoresTabla[0];
|
||||
$campoCod = $valoresTabla[1];
|
||||
$consulta = "DELETE FROM ".$tabla." WHERE ".$campoCod."='".$cod."'";
|
||||
//echo $consulta;
|
||||
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['4038'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function getItem($vista){
|
||||
$tabla = $this->tablasSistema[$vista][0];
|
||||
$consulta="SELECT * FROM ".$tabla;
|
||||
$bd = new BD();
|
||||
$salida=$bd->keyValueQuery($consulta,$this->tablasSistema[$vista][1],$this->tablasSistema[$vista][2]);
|
||||
return $salida;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mantiene el sistema, sobre todo el tema de vacaciones y permisos:
|
||||
* - Vacaciones no aprobadas con permanencia de más de 7 días, se elimina
|
||||
* - Permisos no aprobados con permanencia de más de 7 días, se elimina
|
||||
*/
|
||||
public function mantenSistema(){
|
||||
if(!$this->usuario->tieneRol(2)){
|
||||
$error = $this->locale['4041'];
|
||||
throw new Exception($error);
|
||||
return -1;
|
||||
exit;
|
||||
}
|
||||
$acciones=array();
|
||||
$bd = new BD();
|
||||
//Vacaciones no aprobadas con permanencia de más de 7 días, se elimina
|
||||
$consulta="DELETE FROM vacaciones WHERE DATEDIFF(f_mod,curdate()) < -7 AND aprobada=2";
|
||||
$bd->execQuery($consulta);
|
||||
$acciones[]= mysql_affected_rows().$this->locale['2313'];
|
||||
|
||||
//Vacaciones no aprobadas con permanencia de más de 7 días, se elimina
|
||||
$consulta="DELETE FROM permisos WHERE DATEDIFF(f_mod,curdate()) < -7 AND aprobada=2";
|
||||
$bd->execQuery($consulta);
|
||||
$acciones[]= mysql_affected_rows().$this->locale['2314'];
|
||||
return $acciones;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
115
src/Objects/Afinidad.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Afinidad
|
||||
*
|
||||
* Calcula la afinidad entre pedidos y usuarios.
|
||||
*
|
||||
* 2008-09-30 (diego): Se crea el objeto con los métodos necesarios para calcular afinidades.
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
|
||||
class Afinidad{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Idiomas que requiere el pedido. */
|
||||
private $idiomasPedido;
|
||||
|
||||
/* Idiomas que conoce el candidato. */
|
||||
private $idiomasUsuario;
|
||||
|
||||
/* Tecnologías que requiere el pedido. */
|
||||
private $tecnologiasPedido;
|
||||
|
||||
/* Tecnologías que conoce le usuario. */
|
||||
private $tecnologiasUsuario;
|
||||
|
||||
/* Perfil que requiere el pedido. */
|
||||
private $perfilPedido;
|
||||
|
||||
/* Perfiles que posee el usuario. */
|
||||
private $perfilUsuario;
|
||||
|
||||
/* Provincias donde se desarrollará el proyecto del pedido. */
|
||||
private $provinciasPedido;
|
||||
|
||||
/* Provincias en las que desea trabajar el empleado. */
|
||||
private $provinciaDeseada;
|
||||
|
||||
//Constructores
|
||||
function Afinidad($idiomasPedido, $idiomasUsuario, $tecnologiasPedido,
|
||||
$tecnologiasUsuario, $perfilPedido, $perfilUsuario, $provinciasPedido, $provinciaDeseada){
|
||||
$this->idiomasPedido = $idiomasPedido;
|
||||
$this->idiomasUsuario = $idiomasUsuario;
|
||||
$this->tecnologiasPedido = $tecnologiasPedido;
|
||||
$this->tecnologiasUsuario = $tecnologiasUsuario;
|
||||
$this->perfilPedido = $perfilPedido;
|
||||
$this->perfilUsuario = $perfilUsuario;
|
||||
$this->provinciasPedido = $provinciasPedido;
|
||||
$this->provinciaDeseada = $provinciaDeseada;
|
||||
|
||||
}
|
||||
|
||||
//Funciones
|
||||
|
||||
/**
|
||||
* Calcula la afinidad entre un usuario y un pedido.
|
||||
* @param usuario - usuario candidato al pedido.
|
||||
* @param pedido - pedido para el que calcular la afinidad.
|
||||
*/
|
||||
function calculaAfinidad($pI, $pP, $pT){
|
||||
|
||||
//Si no coincide alguna provincia deseada no nos vale.
|
||||
if($this->provinciasPedido != ""){
|
||||
foreach($this->provinciasPedido as $provincia){
|
||||
if(in_array($provincia, $this->provinciaDeseada)){
|
||||
$vL = $vL + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($vL <= 0) return -1;
|
||||
|
||||
$afi = 0;
|
||||
|
||||
//Afinidad con los perfiles:
|
||||
if(count($this->perfilUsuario) > 0){
|
||||
if(in_array($this->perfilPedido, $this->perfilUsuario)){
|
||||
$vP = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Afinidad con los idiomas:
|
||||
if($this->idiomasPedido != ""){
|
||||
foreach($this->idiomasPedido as $idioma){
|
||||
if(in_array($idioma, $this->idiomasUsuario)){
|
||||
$vI = $vI + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($this->idiomasPedido) > 0){
|
||||
$vI = $vI/count($this->idiomasPedido);
|
||||
}
|
||||
|
||||
//Afinidad con las tecnologías:
|
||||
if($this->tecnologiasPedido != ""){
|
||||
foreach($this->tecnologiasPedido as $this->tecnologia){
|
||||
if(in_array($this->tecnologia, $this->tecnologiasUsuario)){
|
||||
$vT = $vT + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($this->tecnologiasPedido) > 0){
|
||||
$vT = $vT/count($this->tecnologiasPedido);
|
||||
}
|
||||
|
||||
$afi = ($pP * $vP) + ($pI * $vI) + ($pT * $vT);
|
||||
|
||||
return $afi;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
82
src/Objects/Agenda.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Agenda
|
||||
*
|
||||
* Gestiona la agenda personal de un usuario.
|
||||
*
|
||||
* 2008-10-21 (diego): Se crea la clase con los métodos necesarios para gestionar
|
||||
* la agenda de un usuario.
|
||||
*/
|
||||
|
||||
include_once("BD.php");
|
||||
|
||||
class Agenda{
|
||||
private $usuario;
|
||||
|
||||
private $fecha;
|
||||
|
||||
private $agenda = null;
|
||||
|
||||
private $locale;
|
||||
|
||||
public function Agenda($usuario, $fecha, $locale){
|
||||
$this->usuario = $usuario;
|
||||
$this->fecha = date("Y-n-d",$fecha);
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
|
||||
public function getAgenda(){
|
||||
if($this->agenda == null){
|
||||
$agenda = array();
|
||||
$consulta = "SELECT hora, notas FROM agenda WHERE oid = '".$this->usuario->getValor("oid")."' AND fecha = '".$this->fecha."'";
|
||||
$bd = new BD();
|
||||
$agenda = $bd->keyValueQuery($consulta, "hora", "notas");
|
||||
if(gettype($agenda) == "array"){
|
||||
$this->agenda = $agenda;
|
||||
}else{
|
||||
$this->agenda = array();
|
||||
}
|
||||
}
|
||||
return $this->agenda;
|
||||
}
|
||||
|
||||
public function getObservacion($hora){
|
||||
if(($hora >= 0) && ($hora < 24)){
|
||||
$this->getAgenda();
|
||||
return $this->agenda[$hora];
|
||||
}else{
|
||||
$error = $this->locale['3022'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAgenda($hora, $notas){
|
||||
if(($hora >= 0) && ($hora < 24)){
|
||||
$consulta = "DELETE FROM agenda WHERE oid = '".$this->usuario->getValor("oid")."' AND fecha = '".$this->fecha."' AND hora = '".$hora."'";
|
||||
$bd = new BD();
|
||||
$bd->execQuery($consulta);
|
||||
if($notas != ""){
|
||||
$consulta = "INSERT INTO agenda (oid, fecha, hora, notas) VALUES ('".$this->usuario->getValor("oid")."', '".$this->fecha."', '".$hora."', '".$notas."')";
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
$this->agenda[$hora] = $notas;
|
||||
}else{
|
||||
$error = $this->locale['3023'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3022'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
82
src/Objects/Automata.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Autómata
|
||||
*
|
||||
* Realiza transiciones entre estados.
|
||||
*
|
||||
* 2008-10-08 (diego): Se crea el objeto con los métodos necesarios para transitar.
|
||||
*
|
||||
*/
|
||||
|
||||
class Automata{
|
||||
private $objeto;
|
||||
|
||||
private $idioma;
|
||||
|
||||
private $rol;
|
||||
|
||||
function Automata($objeto, $idioma, $rol){
|
||||
$this->objeto = $objeto;
|
||||
$this->rol = $rol;
|
||||
if($idioma == ""){
|
||||
$this->idioma = "sp";
|
||||
}else{
|
||||
$this->idioma = $idioma;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getSiguientes($estado){
|
||||
$consulta = "SELECT final, nombre, rol FROM ".$this->objeto."_transiciones, ".$this->objeto."_estados WHERE inicial='$estado' AND idioma='$this->idioma'" .
|
||||
" AND ".$this->objeto."_transiciones.final = ".$this->objeto."_estados.cod AND ".$this->objeto."_transiciones.rol <> ''";
|
||||
$bd = new BD();
|
||||
$resultado = $bd->execQuery($consulta);
|
||||
|
||||
|
||||
while($rows = mysql_fetch_assoc($resultado)){
|
||||
$final = $rows["final"];
|
||||
$nombre = $rows["nombre"];
|
||||
$rol = $rows["rol"];
|
||||
|
||||
if($this->tienePermisos($rows["rol"])){
|
||||
$lista[$final] = $nombre;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($lista) == 0) $lista = array();
|
||||
|
||||
return $lista;
|
||||
}
|
||||
|
||||
private function tienePermisos($rolTrans){
|
||||
if($rolTrans == "") return true;
|
||||
$arrayRolUsr = explode(".", $this->rol);
|
||||
$arrayRolTrans = explode(".", $rolTrans);
|
||||
|
||||
foreach($arrayRolUsr as $rol){
|
||||
if(in_array($rol, $arrayRolTrans)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTransicion($inicial, $final){
|
||||
$consulta = "SELECT transicion, rol FROM ".$this->objeto."_transiciones WHERE inicial='$inicial' AND final='$final'";
|
||||
$bd = new BD();
|
||||
$resultado = $bd->execQuery($consulta);
|
||||
|
||||
while($rows = mysql_fetch_assoc($resultado)){
|
||||
$rol = $rows["rol"];
|
||||
|
||||
if($this->tienePermisos($rows["rol"])){
|
||||
$transicion = $rows["transicion"];
|
||||
}
|
||||
}
|
||||
|
||||
return $transicion;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
110
src/Objects/BD.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase BD
|
||||
*
|
||||
* Sirve para conectarse a la base de datos y realizar consultas sobre esta
|
||||
*/
|
||||
|
||||
include_once("Conexion.php");
|
||||
|
||||
class BD{
|
||||
|
||||
private $conexion;
|
||||
|
||||
function BD(){
|
||||
$this->conexion = new Conexion();
|
||||
}
|
||||
|
||||
function execQuery($query){
|
||||
$res = mysql_query($query);
|
||||
// $mensaje = $query." - ".$res."\r\n";
|
||||
// $fichero = fopen("querys.log","a");
|
||||
// fputs($fichero,$mensaje);
|
||||
// fclose($fichero);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
function arrayQuery($query, $campo){
|
||||
$array = array();
|
||||
$resultado = $this->execQuery($query);
|
||||
if($resultado){
|
||||
while($rows = mysql_fetch_assoc($resultado)){
|
||||
$array[] = $rows[$campo];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function numFilas($consulta){
|
||||
$res = $this->execQuery($consulta);
|
||||
if($res){
|
||||
return mysql_num_rows($res);
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
function keyValueQuery($query, $key, $value){
|
||||
$array = array();
|
||||
$resultado = $this->execQuery($query);
|
||||
if($resultado){
|
||||
while($rows = mysql_fetch_assoc($resultado)){
|
||||
$array[$rows[$key]] = $rows[$value];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function getCampo($query){
|
||||
$resultado = $this->execQuery($query);
|
||||
//$resultado = mysql_query($query);
|
||||
|
||||
if($resultado){
|
||||
if(mysql_num_rows($resultado)==1){
|
||||
$row= mysql_fetch_row($resultado);
|
||||
$res = $row[0];
|
||||
} else {
|
||||
$res = "";
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getCampos($query){
|
||||
$resultado = $this->execQuery($query);
|
||||
$res = array();
|
||||
|
||||
if($resultado){
|
||||
while ($row=mysql_fetch_row($resultado)){
|
||||
for($pos=0;$pos<mysql_num_fields($resultado);$pos++){
|
||||
$res[mysql_field_name($resultado,$pos)][]=$row[$pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getRegistro($query){
|
||||
$resultado = $this->execQuery($query);
|
||||
$res = array();
|
||||
|
||||
if($resultado){
|
||||
while ($row=mysql_fetch_row($resultado)){
|
||||
for($pos=0;$pos<mysql_num_fields($resultado);$pos++){
|
||||
$res[mysql_field_name($resultado,$pos)]=$row[$pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getLink(){
|
||||
return $this->conexion->getlink();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
44
src/Objects/BDBackup.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase BD
|
||||
*
|
||||
* Sirve para conectarse a la base de datos y realizar consultas sobre esta
|
||||
*/
|
||||
|
||||
include_once("ConexionBackup.php");
|
||||
|
||||
class BDBackup{
|
||||
|
||||
private $conexion;
|
||||
|
||||
function BDBackup(){
|
||||
$this->conexion = new ConexionBackup();
|
||||
}
|
||||
|
||||
function execQuery($query){
|
||||
$res = mysql_query($query);
|
||||
// $mensaje = $query." - ".$res."\r\n";
|
||||
// $fichero = fopen("querys.log","a");
|
||||
// fputs($fichero,$mensaje);
|
||||
// fclose($fichero);
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
function arrayQuery($query, $campo){
|
||||
$array = array();
|
||||
$resultado = $this->execQuery($query);
|
||||
if($resultado){
|
||||
while($rows = mysql_fetch_assoc($resultado)){
|
||||
$array[] = $rows[$campo];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function getLink(){
|
||||
return $this->conexion->getlink();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
197
src/Objects/Backup.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase BD
|
||||
*
|
||||
* Sirve para conectarse a la base de datos y realizar consultas sobre esta
|
||||
*/
|
||||
|
||||
include_once("ConexionBackup.php");
|
||||
include_once("BDBackup.php");
|
||||
include_once("BD.php");
|
||||
|
||||
class Backup{
|
||||
|
||||
private $nombre_bd;
|
||||
|
||||
private $usuario;
|
||||
|
||||
public function Backup($usuario){
|
||||
$conexion = new ConexionBackup();
|
||||
$this->nombre_bd = $conexion->getNombreBD();
|
||||
$this->usuario = $usuario;
|
||||
}
|
||||
|
||||
public function backupGlobal(){
|
||||
if(!$this->usuario->tieneRol(1)){
|
||||
$error = $this->locale['4042'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$consulta = "SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='".$this->nombre_bd."'";
|
||||
$bdB = new BDBackup();
|
||||
$bd = new BD();
|
||||
|
||||
$db_tables = $bdB->arrayQuery($consulta, "TABLE_NAME");
|
||||
|
||||
if(count($db_tables)>0){
|
||||
$crlf = "\n";
|
||||
//ob_start();
|
||||
//@ob_implicit_flush(0);
|
||||
$backup = "#----------------------------------------------------------".$crlf;
|
||||
$backup .= "# Intranet de Selfor SQL Data Dump".$crlf;
|
||||
$backup .= "# Fecha: `".date("d/m/Y H:i")."`".$crlf;
|
||||
$backup .= "#----------------------------------------------------------".$crlf;
|
||||
$backup .= $crlf."SET FOREIGN_KEY_CHECKS=0;".$crlf."#".$crlf;
|
||||
mysql_query('SET SQL_QUOTE_SHOW_CREATE=1');
|
||||
foreach($db_tables as $table){
|
||||
@set_time_limit(1200);
|
||||
mysql_query("OPTIMIZE TABLE $table");
|
||||
$backup .= $crlf."#".$crlf."# Structure for Table `".$table."`".$crlf."#".$crlf;
|
||||
$backup .= "DROP TABLE IF EXISTS `$table`;$crlf";
|
||||
$row=mysql_fetch_array($bd->execQuery("SHOW CREATE TABLE $table"));
|
||||
$backup .= $row[1].";".$crlf;
|
||||
$result=mysql_query("SELECT * FROM $table");
|
||||
if($result&&mysql_num_rows($result)){
|
||||
$backup .= $crlf."#".$crlf."# Table Data for `".$table."`".$crlf."#".$crlf;
|
||||
$column_list="";
|
||||
$num_fields=mysql_num_fields($result);
|
||||
for($i=0;$i<$num_fields;$i++){
|
||||
$column_list.=(($column_list!="")?", ":"")."`".mysql_field_name($result,$i)."`";
|
||||
}
|
||||
}
|
||||
while($row=mysql_fetch_array($result)){
|
||||
$dump="INSERT INTO `$table` ($column_list) VALUES (";
|
||||
for($i=0;$i<$num_fields;$i++){
|
||||
$dump.=($i>0)?", ":"";
|
||||
if(!isset($row[$i])){
|
||||
$dump.="NULL";
|
||||
}elseif($row[$i]=="0"||$row[$i]!=""){
|
||||
$type=mysql_field_type($result,$i);
|
||||
if($type=="tinyint"||$type=="smallint"||$type=="mediumint"||$type=="int"||$type=="bigint"||$type=="timestamp"){
|
||||
$dump.=$row[$i];
|
||||
}else{
|
||||
$search_array=array('\\','\'',"\x00","\x0a","\x0d","\x1a");
|
||||
$replace_array=array('\\\\','\\\'','\0','\n','\r','\Z');
|
||||
$row[$i]=str_replace($search_array,$replace_array,$row[$i]);
|
||||
$dump.="'$row[$i]'";
|
||||
}
|
||||
}else{
|
||||
$dump.="''";
|
||||
}
|
||||
}
|
||||
$dump.=');';
|
||||
$backup .= $dump.$crlf;
|
||||
}
|
||||
}
|
||||
$backup .= $crlf."SET FOREIGN_KEY_CHECKS=1;".$crlf."#".$crlf;
|
||||
$ruta = $this->backupMysql($backup);
|
||||
if($ruta != ""){
|
||||
$aciertos = "Backup realizado";
|
||||
return $ruta;
|
||||
}else{
|
||||
$errores = "Fallo al realizar el backup";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Descargar la base de datos en gzip (al máximo) y enviar por mail.*/
|
||||
private function backupMysql($backup){
|
||||
// Crear nombres de los ficheros backup
|
||||
$fecha=time(); // Fecha actual
|
||||
$archivo=gmstrftime("%y-%m-%d",$fecha); // Formato de la fecha para dar nombre al fichero
|
||||
$asunto = 'Base de datos '.$archivo;
|
||||
$ruta = constante("srcDocs")."/bdcopy/";
|
||||
$ruta=$ruta.$archivo.'.sql'; // Archivo sql
|
||||
$archivo_gz=$ruta.$archivo.'.gz';
|
||||
$resultado = $archivo.'.sql'.$archivo.'.gz';
|
||||
$fp = fopen($ruta, "a");
|
||||
$write = fputs($fp, $backup);
|
||||
fclose($fp);
|
||||
$tamano_archivo = $fp['size'];
|
||||
// Archivo sql.gz
|
||||
|
||||
// Descarga de la base de datos
|
||||
if(file_exists($ruta)) // Si ha creado correctamente el backup
|
||||
{
|
||||
$comprimido=$this->comprimir($ruta,$archivo_gz); // Comprimirlo en gzip
|
||||
if($comprimido=='TRUE'){
|
||||
//$this->enviarAdjunto ($archivo_gz, $asunto); // Envio de mail comprimido
|
||||
}else{
|
||||
//$this->enviarAdjunto ($fp, $asunto); // Envio de mail sin comprimir
|
||||
}
|
||||
|
||||
@unlink($ruta);
|
||||
//TODO ruta segura // Borrar fichero sql
|
||||
//@unlink($archivo_gz); // Borrar fichero sql.gz
|
||||
|
||||
//return TRUE; // Regresa confirmado el backup
|
||||
return $resultado;
|
||||
}
|
||||
else // No ha podido crear el backup
|
||||
return ""; // Regresa denegando el backup
|
||||
}
|
||||
|
||||
// Comprimir en gzip un archivo
|
||||
private function comprimir($archivo_original,$archivo_comprimido)
|
||||
{
|
||||
$fp=@gzopen($archivo_comprimido,'w9'); // Crear archivo comprimido
|
||||
if($fp!='FALSE') // Comprobar que zLib esta activo
|
||||
{
|
||||
$fp2=@fopen($archivo_original,'r'); // Abrir archivo original
|
||||
$buffer=@fread($fp2,filesize($archivo_original));// Leer archivo original
|
||||
@fclose($fp2); // Cerrar archivo original
|
||||
@gzwrite($fp,$buffer); // Escribir archivo comprimido
|
||||
@gzclose($fp); // Cerrar archivo comprimido
|
||||
return TRUE; // Regresa confirmado la compresión
|
||||
}
|
||||
else
|
||||
return FALSE; // Regresa sin comprimirlo
|
||||
}
|
||||
|
||||
// // ENVIO DE CORREO CON ADJUNTO COMPRIMIDO
|
||||
// private function enviarAdjunto($archivo,$asunto)
|
||||
// {
|
||||
// global $mail_enviar;
|
||||
//
|
||||
// $buffer = implode("", file($archivo)); // Leer fichero
|
||||
// $buffer=chunk_split(base64_encode($buffer)); // Codificación en base64 y divido
|
||||
//
|
||||
// // Cabeceras
|
||||
// $cabecera = "MIME-version: 1.0\n";
|
||||
// $cabecera .= "Content-type: multipart/mixed; ";
|
||||
// $cabecera .= "boundary=\"Message-Boundary\"\n";
|
||||
// $cabecera .= "Content-transfer-encoding: 7BIT\n";
|
||||
// $cabecera .= "X-attachments: $archivo";
|
||||
//
|
||||
// // Mensaje
|
||||
// $mensaje = "--Message-Boundary\n";
|
||||
// $mensaje .= "Content-type: text/plain; charset=ISO-8859-1\n";
|
||||
// $mensaje .= "Content-transfer-encoding: 7BIT\n";
|
||||
// $mensaje .= "Content-description: Mail message body\n\n";
|
||||
//
|
||||
// // Adjuntar el fichero
|
||||
// $mensaje .= "\n\n--Message-Boundary\n";
|
||||
// $mensaje .= "Content-type: Binary; name=\"$archivo\"\n";
|
||||
// $mensaje .= "Content-Transfer-Encoding: BASE64\n";
|
||||
// $mensaje .= "Content-disposition: attachment; filename=\"$archivo\"\n\n";
|
||||
// $mensaje .= "$buffer\n";
|
||||
// $mensaje .= "--Message-Boundary--\n";
|
||||
//
|
||||
// @mail($mail_enviar,$asunto,$mensaje,$cabecera); // Envio de mail
|
||||
// }
|
||||
|
||||
function getLink(){
|
||||
if(!$this->usuario->tieneRol(1)){
|
||||
$error = $this->locale['4042'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
return $this->conexion->getlink();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
959
src/Objects/Calendario.php
Normal file
@ -0,0 +1,959 @@
|
||||
<?php
|
||||
include_once("./functions_calendario.php");
|
||||
include_once("BD.php");
|
||||
class Calendario{
|
||||
|
||||
private $mes;
|
||||
private $anio;
|
||||
private $diasEspeciales;
|
||||
private $back;
|
||||
private $locale;
|
||||
private $usuario;
|
||||
private $festivosNacional = "";
|
||||
private $festivosLocales = array();
|
||||
private $hexadecimales;
|
||||
|
||||
private $mesAnt;
|
||||
private $anioAnt;
|
||||
private $mesSig;
|
||||
private $anioSig;
|
||||
|
||||
|
||||
function Calendario($usuario,$mes,$anio,$diasEsp,$back,$locale){
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->diasEspeciales=$diasEsp;
|
||||
if(strpos($back,"?")>0)
|
||||
$this->back=$back."&";
|
||||
else
|
||||
$this->back=$back."?";
|
||||
$this->locale=$locale;
|
||||
$this->usuario=$usuario;
|
||||
$this->hexadecimales = array();
|
||||
|
||||
//calculo el mes y ano del mes anterior
|
||||
$mes_anterior = $mes - 1;
|
||||
$ano_anterior = $anio;
|
||||
if ($mes_anterior==0) {
|
||||
$ano_anterior--;
|
||||
$mes_anterior=12;
|
||||
}
|
||||
$this->mesAnt=$mes_anterior;
|
||||
$this->anioAnt=$ano_anterior;
|
||||
|
||||
//calculo el mes y ano del mes siguiente
|
||||
$mes_siguiente = $mes + 1;
|
||||
$ano_siguiente = $anio;
|
||||
if ($mes_siguiente==13) {
|
||||
$ano_siguiente++;
|
||||
$mes_siguiente=1;
|
||||
}
|
||||
$this->mesSig=$mes_siguiente;
|
||||
$this->anioSig=$ano_siguiente;
|
||||
}
|
||||
|
||||
function getRellenable($parte){
|
||||
$tabla=$this->htmlCabecera("500");
|
||||
|
||||
//Variable para llevar la cuenta del dia actual
|
||||
$dia_actual = 1;
|
||||
//calculo el numero del dia de la semana del primer dia
|
||||
$numero_dia = que_dia_de_semana(1,$this->mes,$this->anio);
|
||||
//calculo el ltimo dia del mes
|
||||
$ultimo_dia = verifica_long_mes($this->mes,$this->anio);
|
||||
|
||||
/*
|
||||
* PRIMERA FILA
|
||||
*/
|
||||
$semana= "<tr class=dia>";
|
||||
for ($i=0;$i<7;$i++) {
|
||||
$horasJob="0";
|
||||
if(array_key_exists($dia_actual,$parte)){
|
||||
$horasJob=$parte[$dia_actual];
|
||||
}
|
||||
if($horasJob=="P"){
|
||||
$textoDia="<input readonly name=\"d".$dia_actual."\" type=\"text\" value=\"".$horasJob."\" maxlength=\"4\" style=\"width:30px \">";
|
||||
} else {
|
||||
$textoDia="<input name=\"d".$dia_actual."\" type=\"text\" value=\"".$horasJob."\" maxlength=\"4\" style=\"width:30px \">";
|
||||
}
|
||||
if ($i < $numero_dia) {
|
||||
//si el dia de la semana i es menor que el numero del primer dia de la semana no pongo nada en la celda
|
||||
$dia = "<td class=dia_vacio ></td>";
|
||||
} else {
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es especial
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
if(($this->diasEspeciales[$dia_actual]=="3")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="4")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="7")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="5")){
|
||||
$textoDia="";
|
||||
}
|
||||
}
|
||||
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$dia_actual++;
|
||||
}
|
||||
$semana.=$dia;
|
||||
}
|
||||
$tabla.=$semana;
|
||||
|
||||
/*
|
||||
* RESTO DE FILAS
|
||||
*/
|
||||
$numero_dia = 0;
|
||||
while ($dia_actual <= $ultimo_dia) {
|
||||
$horasJob="0";
|
||||
if(array_key_exists($dia_actual,$parte)){
|
||||
$horasJob=$parte[$dia_actual];
|
||||
}
|
||||
|
||||
if($horasJob=="P"){
|
||||
$textoDia="<input readonly name=\"d".$dia_actual."\" type=\"text\" value=\"".$horasJob."\" maxlength=\"4\" style=\"width:30px \">";
|
||||
} else {
|
||||
$textoDia="<input name=\"d".$dia_actual."\" type=\"text\" value=\"".$horasJob."\" maxlength=\"4\" style=\"width:30px \">";
|
||||
}
|
||||
//si estamos a principio de la semana escribo el <TR>
|
||||
if ($numero_dia == 0)
|
||||
$semana="<tr align=center class=dia>";
|
||||
//si es el ultimo de la semana, me pongo al principio de la semana y escribo el </tr>
|
||||
$dia="<td ";
|
||||
// Comprobamos si ese dnia es espedia
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
if(($this->diasEspeciales[$dia_actual]=="3")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="4")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="7")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="5")){
|
||||
$textoDia="";
|
||||
}
|
||||
}
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$semana.=$dia;
|
||||
|
||||
$dia_actual++;
|
||||
$numero_dia++;
|
||||
if ($numero_dia == 7) {
|
||||
$numero_dia = 0;
|
||||
$semana.="</tr>";
|
||||
$tabla.=$semana;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* FINAL niLTIMA FILA
|
||||
*/
|
||||
|
||||
if($numero_dia>0){
|
||||
for ($i=$numero_dia;$i<7;$i++) {
|
||||
$semana.= "<td class=dia_vacio></td>";
|
||||
}
|
||||
$tabla.=$semana;
|
||||
}
|
||||
$tabla.="</table>";
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
function getMostrable($parte){
|
||||
$tabla=$this->htmlCabecera("500");
|
||||
|
||||
//Variable para llevar la cuenta del dia actual
|
||||
$dia_actual = 1;
|
||||
//calculo el numero del dia de la semana del primer dia
|
||||
$numero_dia = que_dia_de_semana(1,$this->mes,$this->anio);
|
||||
//calculo el ltimo dia del mes
|
||||
$ultimo_dia = verifica_long_mes($this->mes,$this->anio);
|
||||
|
||||
//escribo la primera fila de la semana
|
||||
//<div class="nombreDia">14</div><div align="center"><input name="2008-10-29" type="text" value="0" maxlength="2" style="width:20px "></div>
|
||||
$semana= "<tr class=dia>";
|
||||
for ($i=0;$i<7;$i++) {
|
||||
$horasJob="0";
|
||||
if(array_key_exists($dia_actual,$parte)){
|
||||
$horasJob=$parte[$dia_actual];
|
||||
}
|
||||
$textoDia=$horasJob;
|
||||
if ($i < $numero_dia) {
|
||||
//si el dia de la semana i es menor que el numero del primer dia de la semana no pongo nada en la celda
|
||||
$dia = "<td class=dia_vacio ></td>";
|
||||
} else {
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es espedia
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
if(($this->diasEspeciales[$dia_actual]=="3")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="4")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="7")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="5")){
|
||||
$textoDia="";
|
||||
}
|
||||
}
|
||||
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$dia_actual++;
|
||||
}
|
||||
$semana.=$dia;
|
||||
}
|
||||
$tabla.=$semana;
|
||||
|
||||
//recorro todos los dems das hasta el final del mes
|
||||
$numero_dia = 0;
|
||||
while ($dia_actual <= $ultimo_dia) {
|
||||
$horasJob="0";
|
||||
if(array_key_exists($dia_actual,$parte)){
|
||||
$horasJob=$parte[$dia_actual];
|
||||
}
|
||||
$textoDia=$horasJob;
|
||||
if ($numero_dia == 0)
|
||||
$semana="<tr align=center class=dia>";
|
||||
$dia="<td ";
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
if(($this->diasEspeciales[$dia_actual]=="3")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="4")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="7")
|
||||
|| ($this->diasEspeciales[$dia_actual]=="5")){
|
||||
$textoDia="";
|
||||
}
|
||||
}
|
||||
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$semana.=$dia;
|
||||
|
||||
$dia_actual++;
|
||||
$numero_dia++;
|
||||
if ($numero_dia == 7) {
|
||||
$numero_dia = 0;
|
||||
$semana.="</tr>";
|
||||
$tabla.=$semana;
|
||||
}
|
||||
}
|
||||
//Comprobando terminar el calendario del mes
|
||||
if($numero_dia>0){
|
||||
for ($i=$numero_dia;$i<7;$i++) {
|
||||
$semana.= "<td class=dia_vacio></td>";
|
||||
}
|
||||
$tabla.=$semana;
|
||||
}
|
||||
$tabla.="</table>";
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
function getSoliVacaciones($mes){
|
||||
$tabla=$this->htmlCabecera("500");
|
||||
|
||||
//Variable para llevar la cuenta del dia actual
|
||||
$dia_actual = 1;
|
||||
//calculo el numero del dia de la semana del primer dia
|
||||
$numero_dia = que_dia_de_semana(1,$this->mes,$this->anio);
|
||||
//calculo el ltimo dia del mes
|
||||
$ultimo_dia = verifica_long_mes($this->mes,$this->anio);
|
||||
|
||||
//escribo la primera fila de la semana
|
||||
$semana= "<tr class=dia>";
|
||||
for ($i=0;$i<7;$i++) {
|
||||
// Comprobamos si ese dnia es puede marcar
|
||||
if($this->puedeSolicitarVacaciones($dia_actual))
|
||||
$textoDia="<input type=\"checkbox\" name=\"d".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
elseif ($this->puedeSolicitarAnulacionVacaciones($dia_actual)) {
|
||||
// Puedo pedir anulacinin
|
||||
$textoDia="<input type=\"checkbox\" name=\"a".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
} elseif ($this->puedeSolicitarAnulacionSolicitud($dia_actual)) {
|
||||
$textoDia="<input type=\"checkbox\" name=\"e".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
} else{
|
||||
$textoDia="";
|
||||
}
|
||||
|
||||
if ($i < $numero_dia) {
|
||||
//si el dia de la semana i es menor que el numero del primer dia de la semana no pongo nada en la celda
|
||||
$dia = "<td class=dia_vacio ></td>";
|
||||
} else {
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es especial
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
}
|
||||
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$dia_actual++;
|
||||
}
|
||||
$semana.=$dia;
|
||||
}
|
||||
$tabla.=$semana;
|
||||
|
||||
//recorro todos los dems das hasta el final del mes
|
||||
$numero_dia = 0;
|
||||
while ($dia_actual <= $ultimo_dia) {
|
||||
// Comprobamos si ese dnia es puede marcar
|
||||
if($this->puedeSolicitarVacaciones($dia_actual))
|
||||
$textoDia="<input type=\"checkbox\" name=\"d".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
elseif ($this->puedeSolicitarAnulacionVacaciones($dia_actual)) {
|
||||
// Puedo pedir anulacinin
|
||||
$textoDia="<input type=\"checkbox\" name=\"a".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
} elseif ($this->puedeSolicitarAnulacionSolicitud($dia_actual)) {
|
||||
$textoDia="<input type=\"checkbox\" name=\"e".$dia_actual."-".$mes."\" value=\"on\">";
|
||||
}else {
|
||||
$textoDia="";
|
||||
}
|
||||
if ($numero_dia == 0)
|
||||
$semana="<tr align=center class=dia>";
|
||||
$dia="<td ";
|
||||
if(array_key_exists($dia_actual,$this->diasEspeciales)){
|
||||
//Si es dia antes de alta, no poner bgcolor
|
||||
if($this->diasEspeciales[$dia_actual]!="7")
|
||||
$dia.=" bgcolor=\"".$this->leyenda($this->diasEspeciales[$dia_actual])."\"";
|
||||
}
|
||||
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$textoDia."</div></td>";
|
||||
$semana.=$dia;
|
||||
|
||||
$dia_actual++;
|
||||
$numero_dia++;
|
||||
if ($numero_dia == 7) {
|
||||
$numero_dia = 0;
|
||||
$semana.="</tr>";
|
||||
$tabla.=$semana;
|
||||
}
|
||||
}
|
||||
//Comprobando terminar el calendario del mes
|
||||
if($numero_dia>0){
|
||||
for ($i=$numero_dia;$i<7;$i++) {
|
||||
$semana.= "<td class=dia_vacio></td>";
|
||||
}
|
||||
$tabla.=$semana;
|
||||
}
|
||||
$tabla.="</table>";
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
function getMiniAgenda($diaVer){
|
||||
$tabla=$this->htmlCabeceraMini($diaVer);
|
||||
|
||||
//Variable para llevar la cuenta del dia actual
|
||||
$dia_actual = 1;
|
||||
//calculo el numero del dia de la semana del primer dia
|
||||
$numero_dia = que_dia_de_semana(1,$this->mes,$this->anio);
|
||||
//calculo el ltimo dia del mes
|
||||
$ultimo_dia = verifica_long_mes($this->mes,$this->anio);
|
||||
|
||||
//escribo la primera fila de la semana
|
||||
$semana= "<tr class=\"semana\">";
|
||||
for ($i=0;$i<7;$i++) {
|
||||
$diaVista=mktime(0,0,0,$this->mes,$dia_actual,$this->anio);
|
||||
// Comprobamos si ese dnia es puede marcar
|
||||
if ($i < $numero_dia) {
|
||||
//si el dia de la semana i es menor que el numero del primer dia de la semana no pongo nada en la celda
|
||||
$dia = "<td class=\"vacio\"></td>";
|
||||
} else {
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es el que estamos viendo
|
||||
if (($this->anio==date("Y",$diaVer)) && ($this->mes==date("m",$diaVer)) && ($dia_actual==date("j",$diaVer))) {
|
||||
// Es el dnia que estamos viendo
|
||||
$dia.=" class=\"vista\" ";
|
||||
} elseif (($this->anio==date("Y")) && ($this->mes==date("m")) && ($dia_actual==date("j"))) {
|
||||
// Es hoy
|
||||
$dia.=" class=\"hoy\" ";
|
||||
}elseif ($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual)) {
|
||||
// Es finde
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
}
|
||||
$dia.=" align=\"center\" valign=\"top\"><a href=\"agenda.php?dia=".$dia_actual."&mes=".$this->mes."&anio=".$this->anio."\"><span style=\"color:#000000;\">".$dia_actual."</span></a></td>";
|
||||
$dia_actual++;
|
||||
}
|
||||
$semana.=$dia;
|
||||
}
|
||||
$tabla.=$semana;
|
||||
|
||||
//recorro todos los dems das hasta el final del mes
|
||||
$numero_dia = 0;
|
||||
while ($dia_actual <= $ultimo_dia) {
|
||||
$diaVista=mktime(0,0,0,$this->mes,$dia_actual,$this->anio);
|
||||
if ($numero_dia == 0)
|
||||
$semana="<tr class=\"semana\">";
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es el que estamos viendo
|
||||
if (($this->anio==date("Y",$diaVer)) && ($this->mes==date("m",$diaVer)) && ($dia_actual==date("j",$diaVer))) {
|
||||
// Es el dnia que estamos viendo
|
||||
$dia.=" class=\"vista\" ";
|
||||
} elseif (($this->anio==date("Y")) && ($this->mes==date("m")) && ($dia_actual==date("j"))) {
|
||||
// Es hoy
|
||||
$dia.=" class=\"hoy\" ";
|
||||
}elseif ($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual)) {
|
||||
// Es finde
|
||||
$dia.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
}
|
||||
$dia.=" align=\"center\" valign=\"top\"><a href=\"agenda.php?dia=".$dia_actual."&mes=".$this->mes."&anio=".$this->anio."\"><span style=\"color:#000000;\">".$dia_actual."</span></a></td>";
|
||||
$semana.=$dia;
|
||||
|
||||
$dia_actual++;
|
||||
$numero_dia++;
|
||||
if ($numero_dia == 7) {
|
||||
$numero_dia = 0;
|
||||
$semana.="</tr>";
|
||||
$tabla.=$semana;
|
||||
}
|
||||
}
|
||||
//Comprobando terminar el calendario del mes
|
||||
if($numero_dia>0){
|
||||
for ($i=$numero_dia;$i<7;$i++) {
|
||||
$semana.= "<td class=dia_vacio></td>";
|
||||
}
|
||||
$tabla.=$semana;
|
||||
}
|
||||
$tabla.="</table>";
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
private function htmlCabeceraMini($diaVer){
|
||||
$nombre_mes = nombre_mes($this->mes);
|
||||
$tabla="<table width=\"200px\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\" class=\"miniCalendario\">";
|
||||
|
||||
// Flechas y nombre del mes
|
||||
$fila= "<tr>";
|
||||
if($this->back!="?")
|
||||
$fila.="<th><a href=\"".$this->back."mesCal=".$this->mesAnt."&anioCal=".$this->anioAnt."&dia=".date("j",$diaVer)."&mes=".date("m",$diaVer)."&anio=".date("Y",$diaVer)."\"><img src=\"css/flecha_menos.gif\" /></a></th>";
|
||||
else
|
||||
$fila.="<th></th>";
|
||||
$fila.="<th colspan=\"5\"><div align=\"center\">".$nombre_mes." de ".$this->anio."</div></th>";
|
||||
if($this->back!="?")
|
||||
$fila.="<th align=\"right\"><a href=\"".$this->back."mesCal=".$this->mesSig."&anioCal=".$this->anioSig."&dia=".date("j",$diaVer)."&mes=".date("m",$diaVer)."&anio=".date("Y",$diaVer)."\"><img src=\"css/flecha_mas.gif\" /></a></th>";
|
||||
else
|
||||
$fila.="<th></th>";
|
||||
$fila.="</tr>";
|
||||
$tabla.=$fila;
|
||||
|
||||
// Nombre de los dnias de la semana
|
||||
$diasSemana= "<tr class=\"nombreSemana\">" .
|
||||
" <td align=center width=\"14%\">L</td>" .
|
||||
" <td align=center width=\"14%\">M</td>" .
|
||||
" <td align=center width=\"14%\">X</td>" .
|
||||
" <td align=center width=\"14%\">J</td>" .
|
||||
" <td align=center width=\"14%\">V</td>" .
|
||||
" <td align=center width=\"14%\">S</td>" .
|
||||
" <td align=center width=\"14%\">D</td>" .
|
||||
"</tr>";
|
||||
$tabla.=$diasSemana;
|
||||
return $tabla;
|
||||
}
|
||||
private function htmlCabecera($tamano){
|
||||
$nombre_mes = nombre_mes($this->mes);
|
||||
if($tamano=="200")
|
||||
$classe="class=\"miniCalendario\"";
|
||||
else
|
||||
$classe="";
|
||||
$tabla="<table width=\"".$tamano."px\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\" ".$classe.">";
|
||||
|
||||
// Flechas y nombre del mes
|
||||
$fila= "<tr class=\"encabezado\">";
|
||||
if($this->back!="?")
|
||||
$fila.="<td><a href=\"".$this->back."mes=".$this->mesAnt."&anio=".$this->anioAnt."\"><img src=\"css/flecha_menos.gif\" /></a></td>";
|
||||
else
|
||||
$fila.="<td></td>";
|
||||
$fila.="<td colspan=\"5\"><div align=\"center\">".$nombre_mes." de ".$this->anio."</div></td>";
|
||||
if($this->back!="?")
|
||||
$fila.="<td align=\"right\"><a href=\"".$this->back."mes=".$this->mesSig."&anio=".$this->anioSig."\"><img src=\"css/flecha_mas.gif\" /></a></td>";
|
||||
else
|
||||
$fila.="<td></td>";
|
||||
$fila.="</tr>";
|
||||
$tabla.=$fila;
|
||||
|
||||
// Nombre de los dnias de la semana
|
||||
$diasSemana= "<tr class=fondo>" .
|
||||
" <td align=center width=\"14%\"> ".$this->locale['050']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['051']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['052']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['053']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['054']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['055']."</td>" .
|
||||
" <td align=center width=\"14%\">".$this->locale['056']."</td>" .
|
||||
"</tr>";
|
||||
$tabla.=$diasSemana;
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
function puedeSolicitarVacaciones($dia){
|
||||
// Comprobamos que el dnia sea posteior a dos desde hoy
|
||||
$diaComprobar = mktime(0,0,0,$this->mes,$dia,$this->anio);
|
||||
$frontera=mktime (0,0,0,date("m"),date("d")+2,date("Y"));
|
||||
if($frontera<$diaComprobar){
|
||||
// Comprobamso que no sea fin de semana
|
||||
if(!($this->esFestivo($this->usuario->getValor("localidad_trabajo"),date("j",$diaComprobar)))){
|
||||
//Si se solicita para este anio o para el prniximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
if(array_key_exists($dia,$this->diasEspeciales)){
|
||||
if($this->diasEspeciales[$dia]=="2"){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return true;
|
||||
}else
|
||||
return false;
|
||||
}else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
function puedeSolicitarAnulacionVacaciones($dia){
|
||||
// Comprobamos que el dnia sea posteior a dos desde hoy
|
||||
$diaComprobar = mktime(0,0,0,$this->mes,$dia,$this->anio);
|
||||
$frontera=mktime (0,0,0,date("m"),date("d")+2,date("Y"));
|
||||
if($frontera<$diaComprobar){
|
||||
// Comprobamso que no sea fin de semana
|
||||
if(!($this->esFestivo($this->usuario->getValor("localidad_trabajo"),date("j",$diaComprobar)))){
|
||||
//Si se solicita para este anio o para el prniximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
if(array_key_exists($dia,$this->diasEspeciales)){
|
||||
if($this->diasEspeciales[$dia]=="5"){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
}else
|
||||
return false;
|
||||
}else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
function puedeSolicitarAnulacionSolicitud($dia){
|
||||
// Comprobamos que el dnia sea posteior a 15 desde hoy
|
||||
$diaComprobar = mktime(0,0,0,$this->mes,$dia,$this->anio);
|
||||
$frontera=mktime (0,0,0,date("m"),date("d")+15,date("Y"));
|
||||
if($frontera<$diaComprobar){
|
||||
// Comprobamos que no sea fin de semana
|
||||
if(!($this->esFestivo($this->usuario->getValor("localidad_trabajo"),date("j",$diaComprobar)))){
|
||||
//Si se solicita para este anio o para el prniximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
if(array_key_exists($dia,$this->diasEspeciales)){
|
||||
if($this->diasEspeciales[$dia]=="3"){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
}else
|
||||
return false;
|
||||
}else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna los festivos nacionales.
|
||||
* @param $dias - Array con los festivos nacionales.
|
||||
* @throws Lanza varias excepciones para casos no permitidos o de error.
|
||||
*/
|
||||
public function setFestivosNacional($dias){
|
||||
if($this->usuario->tieneRol(4)){
|
||||
$this->getFestivosNacional();
|
||||
//Inserto los nuevos:
|
||||
foreach($dias as $dia){
|
||||
//Si no estni, lo inserto.
|
||||
if(!in_array($dia, $this->festivosNacional)){
|
||||
$this->addFestivoNacional($dia);
|
||||
}
|
||||
}
|
||||
//Borro los que ya no estnin:
|
||||
$this->festivosNacional = $this->quitaCeros($this->festivosNacional);
|
||||
$viejos = array_diff($this->festivosNacional, $dias);
|
||||
if(count($viejos) > 0){
|
||||
$consulta = "DELETE FROM festivos_nacional WHERE id IN (";
|
||||
foreach($viejos as $viejo){
|
||||
$fecha = $this->anio."-".$this->mes."-".$viejo;
|
||||
$consulta .= "'".$fecha."',";
|
||||
}
|
||||
//Quitamos la niltima coma
|
||||
if ($consulta{strlen($consulta) - 1} == ",")
|
||||
$consulta = substr($consulta,0,strlen($consulta) - 1);
|
||||
|
||||
$consulta .= ")";
|
||||
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
$this->festivosNacional = $dias;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4043'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aniade un festivo nacional.
|
||||
* @param $dia - dnia a asignar
|
||||
* @return true si se asignni correctamente y false en caso contrario.
|
||||
* @throws Lanza excepcinin si el usuario no tiene permisos o el dnia no es vnilido.
|
||||
*/
|
||||
private function addFestivoNacional($dia){
|
||||
if($this->usuario->tieneRol(4)){
|
||||
if(($dia > 0) && ($dia <= 31)){
|
||||
if($dia < 10){
|
||||
$dia = $dia * 1;
|
||||
$dia = "0".$dia;
|
||||
}
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "INSERT INTO festivos_nacional VALUES ('".$fecha."')";
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
$this->festivosNacional[] = $dia;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4044'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4043'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Asigna los festivos locales.
|
||||
* @param $dias - Array con los festivos locales.
|
||||
* @param $localidad - Localidad donde asignar los festivos.
|
||||
* @throws Lanza varias excepciones para casos no permitidos o de error.
|
||||
*/
|
||||
public function setFestivosLocal($dias, $localidad){
|
||||
if($this->usuario->tieneRol(4)){
|
||||
$actuales = $this->getFestivosLocal($localidad);
|
||||
//Inserto los nuevos:
|
||||
foreach($dias as $dia){
|
||||
//Si no estni, lo inserto.
|
||||
if(!in_array($dia, $actuales)){
|
||||
$this->addFestivoLocal($dia, $localidad);
|
||||
}
|
||||
}
|
||||
//Borro los que ya no estnin:
|
||||
$actuales = $this->quitaCeros($actuales);
|
||||
$viejos = array_diff($actuales, $dias);
|
||||
/*echo "<br>Actualmente hay:<br>";
|
||||
print_r($actuales);
|
||||
echo "<br>Y tengo que dejar:<br>";
|
||||
print_r($dias);
|
||||
echo "<br>Con lo cual elimino:<br>";
|
||||
print_r($viejos);*/
|
||||
if(count($viejos) > 0){
|
||||
$consulta = "DELETE FROM festivos_local WHERE localidad = '".$localidad."' AND fecha IN (";
|
||||
foreach($viejos as $viejo){
|
||||
$fecha = $this->anio."-".$this->mes."-".$viejo;
|
||||
$consulta .= "'".$fecha."',";
|
||||
}
|
||||
//Quitamos la niltima coma
|
||||
if ($consulta{strlen($consulta) - 1} == ",")
|
||||
$consulta = substr($consulta,0,strlen($consulta) - 1);
|
||||
|
||||
$consulta .= ")";
|
||||
$bd = new BD();
|
||||
if(!$bd->execQuery($consulta)){
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4043'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aniade un festivo local.
|
||||
* @param $dia - dnia a asignar
|
||||
* @param $localidad - localidad a la que asignar el dnia festivo.
|
||||
* @return true si se asignni correctamente y false en caso contrario.
|
||||
* @throws Lanza excepcinin si el usuario no tiene permisos o el dnia no es vnilido.
|
||||
*/
|
||||
private function addFestivoLocal($dia, $localidad){
|
||||
if($this->usuario->tieneRol(4)){
|
||||
if(($dia > 0) && ($dia <= 31)){
|
||||
if($dia < 10){
|
||||
$dia = $dia * 1;
|
||||
$dia = "0".$dia;
|
||||
}
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "INSERT INTO festivos_local (localidad, fecha) VALUES ('".$localidad."', '".$fecha."')";
|
||||
$bd = new BD();
|
||||
if(!$bd->execQuery($consulta)){
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4044'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4043'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getFestivosNacional(){
|
||||
if($this->festivosNacional == ""){
|
||||
$this->festivosNacional = array();
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT id FROM festivos_nacional WHERE id LIKE '".$fecha."-%'";
|
||||
$bd = new BD();
|
||||
$array = $bd->arrayQuery($consulta, "id");
|
||||
foreach($array as $elem){
|
||||
$dia = explode("-", $elem);
|
||||
$this->festivosNacional[] = $dia[2]+0;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->festivosNacional;
|
||||
}
|
||||
|
||||
function getFestivosLocal($localidad){
|
||||
if(!array_key_exists($localidad, $this->festivosLocales)){
|
||||
$dias = array();
|
||||
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT fecha FROM festivos_local WHERE fecha LIKE '".$fecha."-%' AND localidad = '".$localidad."'";
|
||||
$bd = new BD();
|
||||
$array = $bd->arrayQuery($consulta, "fecha");
|
||||
foreach($array as $elem){
|
||||
$dia = explode("-", $elem);
|
||||
$dias[] = $dia[2];
|
||||
}
|
||||
$this->festivosLocales[$localidad] = $dias;
|
||||
}
|
||||
|
||||
return $this->festivosLocales[$localidad];
|
||||
}
|
||||
|
||||
function esFestivo($localidad, $dia){
|
||||
$nacional = $this->esFestivoNacional($dia);
|
||||
/*$local = $this->esFestivoLocal($localidad, $dia);
|
||||
$finde = $this->esFinde($dia);*/
|
||||
$local = false;
|
||||
$finde = false;
|
||||
if(!$nacional && $localidad != ""){
|
||||
$local = $this->esFestivoLocal($localidad, $dia);
|
||||
if(!$local){
|
||||
$finde = $this->esFinde($dia);
|
||||
}
|
||||
}else{
|
||||
$finde = $this->esFinde($dia);
|
||||
}
|
||||
|
||||
if($nacional || $local || $finde){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function esFestivoNacional($dia){
|
||||
$festivos = $this->getFestivosNacional();
|
||||
return in_array($dia, $festivos);
|
||||
}
|
||||
|
||||
function esFestivoLocal($localidad, $dia){
|
||||
$festivos = $this->getFestivosLocal($localidad);
|
||||
return in_array($dia, $festivos);
|
||||
}
|
||||
|
||||
private function esFinde($dia){
|
||||
$d = date('N', mktime(0,0,0,$this->mes,$dia,$this->anio));
|
||||
|
||||
if(($d != 6) && ($d != 7)){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function leyenda($cod){
|
||||
if(!array_key_exists($cod, $this->hexadecimales)){
|
||||
$consulta="SELECT hexadecimal FROM leyenda WHERE cod='".$cod."'";
|
||||
$bd=new BD();
|
||||
$valor= $bd->getCampo($consulta);
|
||||
$this->hexadecimales[$cod] = $valor;
|
||||
}
|
||||
return $this->hexadecimales[$cod];
|
||||
}
|
||||
|
||||
/**
|
||||
* Muestra un calendario configurable, mostrando los festivos nacionales y locales
|
||||
* del usuario.
|
||||
* Si el dnia estni dentro del array $diasEsp, se muestra el texto que hay, sino se deja en blanco
|
||||
*
|
||||
* @param $diasEsp : Array con los dnias, de la forma array("1" => array("color" => "codigo color","texto" => "texto interior"))
|
||||
* @param $tipo (g|p) : g = Grande | p = Pequenio
|
||||
*/
|
||||
function getCalendar($diasEsp,$tipo){
|
||||
switch ($tipo) {
|
||||
case "p": // Pequenio
|
||||
$tabla = $this->htmlCabecera("200");
|
||||
break;
|
||||
case "g": // Grande
|
||||
$tabla = $this->htmlCabecera("500");
|
||||
break;
|
||||
default: // Otro valor = grande
|
||||
$tabla = $this->htmlCabecera("500");
|
||||
break;
|
||||
}
|
||||
// Variable para llevar la cuenta del dia actual
|
||||
$dia_actual = 1;
|
||||
//calculo el numero del dia de la semana del primer dia
|
||||
$numero_dia = que_dia_de_semana(1,$this->mes,$this->anio);
|
||||
//calculo el ltimo dia del mes
|
||||
$ultimo_dia = verifica_long_mes($this->mes,$this->anio);
|
||||
|
||||
/*
|
||||
* PRIMERA FILA
|
||||
*/
|
||||
$semana= "<tr class=dia>";
|
||||
for ($i=0;$i<7;$i++) {
|
||||
if ($i < $numero_dia) {
|
||||
//si el dia de la semana i es menor que el numero del primer dia de la semana no pongo nada en la celda
|
||||
$dia = "<td class=dia_vacio ></td>";
|
||||
} else {
|
||||
$texto="";
|
||||
$bgcolor="";
|
||||
if(array_key_exists($dia_actual,$diasEsp)){
|
||||
$texto=$diasEsp[$dia_actual]["texto"];
|
||||
if($diasEsp[$dia_actual]["color"]!="")
|
||||
$bgcolor=" bgcolor=\"".$diasEsp[$dia_actual]["color"]."\"";
|
||||
}
|
||||
$dia="<td";
|
||||
// Comprobamos si ese dnia es festivo
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$bgcolor.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
$dia.=$bgcolor;
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$texto."</div></td>";
|
||||
$dia_actual++;
|
||||
}
|
||||
$semana.=$dia;
|
||||
}
|
||||
$tabla.=$semana;
|
||||
|
||||
/*
|
||||
* RESTO DE FILAS
|
||||
*/
|
||||
$numero_dia = 0;
|
||||
while ($dia_actual <= $ultimo_dia) {
|
||||
$texto="";
|
||||
$bgcolor="";
|
||||
//si estamos a principio de la semana escribo el <TR>
|
||||
if ($numero_dia == 0)
|
||||
$semana="<tr align=center class=dia>";
|
||||
//si es el ultimo de la semana, me pongo al principio de la semana y escribo el </tr>
|
||||
$dia="<td ";
|
||||
// Comprobamos si ese dnia es espedia
|
||||
if(array_key_exists($dia_actual,$diasEsp)){
|
||||
$texto=$diasEsp[$dia_actual]["texto"];
|
||||
if($diasEsp[$dia_actual]["color"]!="")
|
||||
$bgcolor=" bgcolor=\"".$diasEsp[$dia_actual]["color"]."\"";
|
||||
}
|
||||
// Comprobamos si ese dnia es festivo
|
||||
if($this->esFestivo($this->usuario->getValor("localidad_trabajo"),$dia_actual))
|
||||
$bgcolor.=" bgcolor=\"".$this->leyenda("1")."\"";
|
||||
$dia.=$bgcolor;
|
||||
$dia.=" align=\"center\" valign=\"top\" style=\"padding:0px; margin:0px\"><div class=\"nombreDia\">".$dia_actual."</div><div <div class=\"textoDia\">".$texto."</div></td>";
|
||||
$semana.=$dia;
|
||||
|
||||
$dia_actual++;
|
||||
$numero_dia++;
|
||||
if ($numero_dia == 7) {
|
||||
$numero_dia = 0;
|
||||
$semana.="</tr>";
|
||||
$tabla.=$semana;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* FINAL niLTIMA FILA
|
||||
*/
|
||||
|
||||
if($numero_dia>0){
|
||||
for ($i=$numero_dia;$i<7;$i++) {
|
||||
$semana.= "<td class=dia_vacio></td>";
|
||||
}
|
||||
$tabla.=$semana;
|
||||
}
|
||||
$tabla.="</table>";
|
||||
return $tabla;
|
||||
}
|
||||
|
||||
private function quitaCeros($array){
|
||||
$res = array();
|
||||
foreach($array as $elem){
|
||||
$res[] = $elem + 0;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
391
src/Objects/Candidato.php
Normal file
@ -0,0 +1,391 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Candidato
|
||||
*
|
||||
* Contiene toda la información relativa al candidato.
|
||||
*
|
||||
* 2008-10-06 (diego): Se crea el objeto con los métodos necesarios para gestionar candidatos.
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
include_once("Persona.php");
|
||||
class Candidato extends Persona{
|
||||
|
||||
private $usuario;
|
||||
|
||||
function Candidato($usuario, $oid){
|
||||
$consulta = "SELECT oid FROM usuarios WHERE oid = '".$oid."' AND tipo='candidato'";
|
||||
$bd = new BD();
|
||||
$num = $bd->numFilas($consulta);
|
||||
if($num > 0){
|
||||
parent::Persona($oid);
|
||||
$this->usuario = $usuario;
|
||||
}else{
|
||||
$error = "Candidato no encontrado.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
function setCampo($nombre, $valor){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
return parent::setCampo($nombre, $valor);
|
||||
}else{
|
||||
//Campos que se pueden editar por el gerente, ya sea directamente o mediante una transición.
|
||||
if(($nombre == "observaciones" || $nombre == "msgEstado" || $nombre = "diasEspera" || $nombre == "estado") && $this->usuario->tieneRol(3)){
|
||||
return parent::setCampo($nombre, $valor);
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para editar al candidato.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addCurriculum($fichero){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(3) || $this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
return parent::addCurriculum($fichero, $this->usuario->getValor("nombre"));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para asociar CV al candidato.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function removeCurriculum($curriculum, $fecha){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
parent::removeCurriculum($curriculum, $fecha, $this->usuario->getValor("nombre"));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para eliminar un CV al candidato.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
/*SQL que da los pedidos en el que está un candidato dependiendo del estado
|
||||
|
||||
En el ejemplo
|
||||
estado -> 20
|
||||
id Candidato ->12
|
||||
@param $estado - Estado del pedido.
|
||||
@return array codPedido => nombre o vacío.
|
||||
*/
|
||||
function getPedidosByEstado($estado){
|
||||
/*SELECT P.oid,P.nombre
|
||||
FROM pedidos P,candidato_pedido CP
|
||||
WHERE CP.candidato='12'
|
||||
AND CP.estado='20'
|
||||
AND P.oid=CP.pedido*/
|
||||
$idC = $this->getValor("oid");
|
||||
$consulta = "SELECT P.oid as oid,P.nombre as nombre
|
||||
FROM pedidos P,candidato_pedido CP
|
||||
WHERE CP.candidato='$idC'
|
||||
AND CP.estado='$estado'
|
||||
AND P.oid=CP.pedido";
|
||||
$bd = new BD();
|
||||
return $bd->keyValueQuery($consulta, "oid", "nombre");
|
||||
}
|
||||
|
||||
function eliminar(){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
//Nos declaramos un array de estados eliminables:
|
||||
$estados_eliminables = array(10, 20, 50, 40, 60);
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
$estado = $this->getValor("estado");
|
||||
if(in_array($estado, $estados_eliminables)){
|
||||
return parent::eliminar();
|
||||
}else{
|
||||
$nombre_estado = $this->getValor("nombre_estado");
|
||||
$error = "No se pueden eliminar candidatos en estado ".$nombre_estado.".";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para eliminar al candidato.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function actualizarHistorial($mensaje){
|
||||
parent::actualizarHistorial($mensaje, $this->usuario->getValor("nombre"));
|
||||
}
|
||||
|
||||
function getSiguientes(){
|
||||
$estado = $this->getValor("estado");
|
||||
$idioma = $this->usuario->getValor("idioma");
|
||||
$rol = $this->usuario->getValor("rol");
|
||||
$a = new Automata("candidatos", $idioma, $rol);
|
||||
$siguientes = $a->getSiguientes($estado);
|
||||
return $siguientes;
|
||||
}
|
||||
|
||||
function transita($destino, $argumentos){
|
||||
$origen = $this->getValor("estado");
|
||||
$idioma = $this->usuario->getValor("idioma");
|
||||
$rol = $this->usuario->getValor("rol");
|
||||
$a = new Automata("candidatos", $idioma, $rol);
|
||||
$transita = $a->getTransicion($origen,$destino);
|
||||
|
||||
if(($transita == "") || !($transita >= 0)){
|
||||
return false;
|
||||
}else{
|
||||
$res = $this->ejecutaTransicion($transita, $argumentos);
|
||||
if($res){
|
||||
$total = explode("#&dias;", $argumentos);
|
||||
$msj = $total[0];
|
||||
$diasEspera = $total[1];
|
||||
$this->setCampos(array("msgEstado" => $msj, "diasEspera" => $diasEspera, "estado" => $destino));
|
||||
/*$this->setCampo("msgEstado", $msj);
|
||||
$this->setCampo("diasEspera", $diasEspera);
|
||||
$this->setCampo("estado", $destino);*/
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
private function ejecutaTransicion($codigo, $argumentos){
|
||||
//Si no hace nada al transitar salimos sin más.
|
||||
if($codigo == 0) return true;
|
||||
$funcion = "ejecutar$codigo";
|
||||
$res = call_user_func(array("Candidato", $funcion), $argumentos);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disponible a no disponible
|
||||
* Entrevistado a no disponible (entrevistado).
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Editar el estado del candidato desde la vista.
|
||||
|
||||
PRECONDICIONES:
|
||||
- Mensaje con texto.
|
||||
|
||||
POSTCONDICIONES:
|
||||
- Eliminarle de candidaturas en las que no esté rechazado
|
||||
y el pedido esté pendiente, asignado o contratado
|
||||
y comprobar transiciones a otros pedidos.
|
||||
*/
|
||||
private function ejecutar1020($mensaje){
|
||||
|
||||
if($mensaje == ""){
|
||||
echo '<script type="text/javascript">
|
||||
<!--
|
||||
alert("Debe introducir un motivo para pasar al candidato a No disponible");
|
||||
-->
|
||||
</script>';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disponible a Entrevistado
|
||||
* En proceso a En proceso (entrevistado)
|
||||
* No disponible a No disponible (entrevistado)
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Editar el estado del candidato desde la vista.
|
||||
|
||||
PRECONDICIONES:
|
||||
- Ninguna.
|
||||
|
||||
POSTCONDICIONES:
|
||||
- Almacenar en la BD la fecha de la entrevista.
|
||||
*/
|
||||
private function ejecutar1050($mensaje){
|
||||
$fechaAntEntrevista=$this->getValor("fecha_entrevista");
|
||||
if(($fechaAntEntrevista=="2008-1-1") || ($fechaAntEntrevista=="0000-00-00")){
|
||||
$fecha = date(Y."-".m."-".d);
|
||||
$this->setCampos(array("fecha_entrevista" => $fecha));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* En proceso a no disponible
|
||||
* En proceso (entrevistado) a no disponible (entrevistado).
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Editar el estado del candidato desde la vista.
|
||||
|
||||
PRECONDICIONES:
|
||||
- Mensaje con texto.
|
||||
|
||||
POSTCONDICIONES:
|
||||
- Eliminarle de candidaturas en las que no esté rechazado
|
||||
y el pedido esté pendiente, asignado o contratado
|
||||
y comprobar transiciones a otros pedidos.
|
||||
*/
|
||||
private function ejecutar3020($mensaje){
|
||||
if($mensaje == ""){
|
||||
echo '<script type="text/javascript">
|
||||
<!--
|
||||
alert("Debe introducir un motivo para pasar al candidato a No disponible");
|
||||
-->
|
||||
</script>';
|
||||
return false;
|
||||
}
|
||||
$oid = $this->getValor("oid");
|
||||
$consulta = "SELECT pedido FROM candidato_pedido, pedidos WHERE candidato='$oid' AND estado <> '10' AND pedido.oid = candidato_pedido.pedido AND pedido.estado IN ('10', '20', '30')";
|
||||
$bd = new BD();
|
||||
$pedidos = $bd->arrayQuery($consulta, "pedido");
|
||||
//Elimino al usuario de todas las candidaturas en las que no esté rechazado y el pedido esté pendiente, asignado o contratado.
|
||||
$consulta = "DELETE FROM candidato_pedido, pedidos WHERE candidato='$oid' AND estado <> '10' AND pedido.oid = candidato_pedido.pedido AND pedido.estado IN ('10', '20', '30')";
|
||||
|
||||
//Para cada candidatura en la que no esté rechazado compruebo si el sacarle
|
||||
//de ella supone un cambio en el pedido:
|
||||
foreach($pedidos as $idP){
|
||||
$pedido = new Pedido($idP);
|
||||
$estado = $pedido->getEstado("estado");
|
||||
//Si está asignado o contratado tiene que transitar a pendiente
|
||||
//(la transición se encarga ya de comprobar si cumple las precondiciones
|
||||
//de este cambio de estado)
|
||||
if(($estado == '20') || ($estado == '30')){
|
||||
$pedido->transita(10, "");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* No disponible a Disponible
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Editar el estado del candidato desde la vista.
|
||||
|
||||
POSTCONDICIONES:
|
||||
- Calcular la afinidad del candidato con todos los pedidos para que
|
||||
puedan aparecer en ellos como "Propuestos por el sistema".
|
||||
*/
|
||||
private function ejecutar2010(){
|
||||
$this->setCampos(array("estado" => "10"));
|
||||
$this->calculaAfinidad();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* En proceso a disponible
|
||||
* En proceso (entrevistado) a disponible
|
||||
SE LLEGA DESDE:
|
||||
- Rechazar a un candidato.
|
||||
- Poner un pedido en el que se encontraba como "No contratado".
|
||||
|
||||
PRECONDICIONES:
|
||||
- El usuario no se encuentra aceptado en ningún proceso de selección.
|
||||
|
||||
*/
|
||||
private function ejecutar3010(){
|
||||
$id = $this->getValor("oid");
|
||||
$bd = new BD();
|
||||
$consulta = "SELECT * FROM candidato_pedido WHERE candidato='.$id.' AND estado='20'";
|
||||
$res = $bd->numFilas(($consulta));
|
||||
//No se cambia si está en más procesos.
|
||||
if($res > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disponible a En proceso.
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Al aceptar a un candidato disponible en un proceso de selección.
|
||||
|
||||
EFECTOS:
|
||||
- Se envía un email a RRHH informando de que se ha aceptado en un proyecto a un
|
||||
candidato que no ha sido entrevistado.
|
||||
- Se cambia el estado del candidato de disponible a enproceso
|
||||
*/
|
||||
private function ejecutar1030(){
|
||||
//Enviar un mail a RRHH con los datos pidiendo incorporación.
|
||||
$nombre = $this->getValor("nombre")." ".$this->getValor("apellidos");
|
||||
$oid = $this->getValor("oid");
|
||||
$asunto = "Candidato aceptado por pedido no entrevistado";
|
||||
$direccion = constante("email");
|
||||
$path = "http://portal.selforsistemas.net";
|
||||
//$link = "<a href='".$path."/detalle_candidato.php?oid=".$oid."'>".$nombre."</a>";
|
||||
$email = "El candidato ".$nombre." no entrevistado ha sido aceptado para un pedido.";
|
||||
envia_correo($direccion, $asunto, $email);
|
||||
$this->setCampos(array("estado" => "30"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entrevistado a Incorporado
|
||||
* En proceso (entrevistado) a Incorporado *
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Editar el estado del candidato desde la vista.
|
||||
|
||||
PRECONDICIONES:
|
||||
- Ninguna.
|
||||
|
||||
POSTCONDICIONES:
|
||||
- Cambia el tipo a "usuario" y desaparece de la lista de candidatos.
|
||||
- Se añade el campo "Fecha alta".
|
||||
- Se transita automáticamente a "Esperando proyecto".
|
||||
*/
|
||||
private function ejecutar5080($mensaje){
|
||||
$fecha = date(Y."-".m."-".d);
|
||||
$nombre = md5($this->getValor("nombre"));
|
||||
$this->setCampos(array("tipo" => "usuario", "estado" => "90", "password" => $nombre, "rol" => 6, "fecha_alta" => $fecha, "salario" => $mensaje));
|
||||
/*$this->setCampo("estado", "90");
|
||||
$this->setCampo("password", $nombre);
|
||||
$this->setCampo("rol", 6);
|
||||
$this->setCampo("fecha_alta", $fecha);
|
||||
$this->setCampo("salario", $mensaje);*/
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Entrevistado a En proceso(entrevistado).
|
||||
* Admin, RRHH
|
||||
SE LLEGA DESDE:
|
||||
- Al aceptar a un candidato disponible en un proceso de selección.
|
||||
|
||||
EFECTOS:
|
||||
- Se cambia el estado del candidato de en proceso(entrevistado)
|
||||
*/
|
||||
|
||||
private function ejecutar5070(){
|
||||
$this->setCampos(array("estado" => "70"));
|
||||
$this->campos["estado_usuario"]="70";
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
27
src/Objects/CandidatoPedido.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase CandidatoPedido
|
||||
*
|
||||
* Contiene toda la información relativa al usuario.
|
||||
*
|
||||
* 2008-09-30 (diego): Se crea el objeto con los métodos necesarios para recuperar permisos
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
class CandidatoPedido extends Persona{
|
||||
|
||||
//Atributos:
|
||||
|
||||
//Constructores:
|
||||
|
||||
/**
|
||||
* Crea un pedido a partir de un array.
|
||||
* @param rows - campos del pedido.
|
||||
*/
|
||||
function CandidatoPedido($rows){
|
||||
parent::Persona($rows["oid"]);
|
||||
$this->campos = array_merge($this->campos, $rows);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
31
src/Objects/Conexion.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class Conexion{
|
||||
|
||||
private $link;
|
||||
|
||||
private $bd = "localhost";
|
||||
|
||||
private $user = "root";
|
||||
|
||||
private $password = "0selfor0";
|
||||
|
||||
private $nombre_bd = "selfor";
|
||||
|
||||
function Conexion(){
|
||||
$this->link=mysql_connect($this->bd,$this->user,$this->password);
|
||||
if (!mysql_select_db($this->nombre_bd,$this->link))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mysql_query("SET NAMES 'latin1'");
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
function getLink(){
|
||||
return $this->link;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
32
src/Objects/ConexionBackup.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class ConexionBackup{
|
||||
|
||||
private $link;
|
||||
|
||||
private $bd = "localhost";
|
||||
|
||||
private $user = "root";
|
||||
|
||||
private $password = "0selfor0";
|
||||
|
||||
private $nombre_bd = "selfor";
|
||||
|
||||
public function ConexionBackup(){
|
||||
$this->link=mysql_connect($this->bd,$this->user,$this->password);
|
||||
if (!mysql_select_db("information_schema",$this->link)){
|
||||
|
||||
}
|
||||
mysql_query("SET NAMES 'latin1'");
|
||||
}
|
||||
|
||||
public function getNombreBD(){
|
||||
return $this->nombre_bd;
|
||||
}
|
||||
|
||||
public function getLink(){
|
||||
return $this->link;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
59
src/Objects/Documento.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 17/10/2008
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
include_once("BD.php");
|
||||
class Documento{
|
||||
|
||||
private $campos=array();
|
||||
|
||||
function Documento($idDocumento){
|
||||
$this->idDocumento=$idDocumento;
|
||||
$this->campos['oid']=$idDocumento;
|
||||
}
|
||||
|
||||
function getValor($nombre){
|
||||
if(array_key_exists($nombre,$this->campos)){
|
||||
// El campo ya lo habíamos recuperamos, lo mostramos
|
||||
return $this->campos[$nombre];
|
||||
} else {
|
||||
// Hay que recuperar el campo de la base de datos
|
||||
$consulta="SELECT ".$nombre." FROM documentos WHERE oid=\"".$this->campos['oid']."\"";
|
||||
$bd=new BD();
|
||||
$valor= $bd->getCampo($consulta);
|
||||
// Lo insertamos para nosotros
|
||||
$arrayAct=array($nombre => $valor);
|
||||
$this->campos=$this->campos + $arrayAct;
|
||||
return $valor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualiza un valor SÓLO en el objeto
|
||||
*
|
||||
* actValor(key,valor)
|
||||
*/
|
||||
function actValor($key,$valor){
|
||||
// Actualiza el valor SOLO en el objeto
|
||||
$this->$key=$valor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina un documento del servidor y de la base de datos
|
||||
*/
|
||||
function eliminar($directorio){
|
||||
// Eliminamos el fichero
|
||||
if(@unlink($directorio.$this->getValor("ruta"))){
|
||||
// Eliminamos la info de la base de datos
|
||||
$consulta="DELETE FROM documentos WHERE oid='".$this->getValor("oid")."'";
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
255
src/Objects/Empleado.php
Normal file
@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Empleado
|
||||
*
|
||||
* Contiene toda la informaci<EFBFBD>n relativa al empleado.
|
||||
*
|
||||
* 2008-10-06 (diego): Se crea el objeto con los m<EFBFBD>todos necesarios para gestionar empleados.
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
include_once("Persona.php");
|
||||
class Empleado extends Persona{
|
||||
|
||||
private $usuario;
|
||||
|
||||
function Empleado($usuario, $oid){
|
||||
$consulta = "SELECT oid FROM usuarios WHERE oid = '$oid' AND tipo='usuario'";
|
||||
$bd = new BD();
|
||||
$num = $bd->numFilas($consulta);
|
||||
if($num > 0){
|
||||
parent::Persona($oid);
|
||||
$this->usuario = $usuario;
|
||||
}else{
|
||||
$error = "Empleado no encontrado.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
function setCampo($nombre, $valor){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepci<EFBFBD>n
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
$editar = true;
|
||||
switch ($nombre) {
|
||||
case "password":if($valor != ""){
|
||||
$valor = md5($valor);
|
||||
}else{
|
||||
$editar = false;
|
||||
}
|
||||
break;
|
||||
case "dias_vacaciones":
|
||||
$editar=false;
|
||||
if($valor!=$this->getValor("dias_vacaciones")){
|
||||
$consulta = "UPDATE vacaciones_oid SET dias='$valor' WHERE oid='".$this->getValor("oid")."' AND anyo='".date("Y")."'";
|
||||
$bd = new BD();
|
||||
$bd->execQuery($consulta);
|
||||
if(mysql_affected_rows()==0) {
|
||||
$consulta="INSERT INTO vacaciones_oid(dias,oid,anyo) VALUES ('".$valor."','".$this->getValor("oid")."','".date("Y")."')";
|
||||
$bd->execQuery($consulta);
|
||||
}
|
||||
parent::setCampo($nombre,$valor);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if($editar){
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
return parent::setCampo($nombre, $valor);
|
||||
}else{
|
||||
if($nombre == "observaciones" && $this->usuario->tieneRol(3)){
|
||||
return parent::setCampo($nombre, $valor);
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para editar al empleado.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addCurriculum($fichero){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepci<EFBFBD>n
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(3) || $this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
return parent::addCurriculum($fichero, $this->usuario->getValor("nombre"));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para asociar CV al empleado.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function removeCurriculum($curriculum, $fecha){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepci<EFBFBD>n
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
parent::removeCurriculum($curriculum, $fecha, $this->usuario->getValor("nombre"));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para eliminar un CV al empleado.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
function getRoles(){
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
$oid = $this->getValor("oid");
|
||||
$consulta = "SELECT rol FROM usuarios WHERE oid='$oid'";
|
||||
$bd = new BD();
|
||||
$rol = $bd->getCampo($consulta);
|
||||
|
||||
if($rol == ""){
|
||||
$array = array();
|
||||
}else{
|
||||
$array = explode(".", $rol);
|
||||
}
|
||||
|
||||
$roles = array();
|
||||
|
||||
foreach($array as $elem){
|
||||
$roles[$elem] = nombre_rol($elem);
|
||||
}
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para ver los roles del empleado.";
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
}
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
||||
function getSiguientes(){
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
$estado = $this->getValor("estado");
|
||||
$idioma = $this->usuario->getValor("idioma");
|
||||
$rol = $this->usuario->getValor("rol");
|
||||
$a = new Automata("candidatos", $idioma, $rol);
|
||||
$siguientes = $a->getSiguientes($estado);
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para ver los estados de los empleado.";
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
}
|
||||
return $siguientes;
|
||||
}
|
||||
|
||||
function addRol($rol){
|
||||
if($this->usuario->tieneRol(1)){
|
||||
$rol = $this->getValor("rol");
|
||||
$rol .= $rol.".";
|
||||
$this->setCampos(array("rol" => $rol));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para gestionar los roles de los empleado.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
function removeRol($rol){
|
||||
if($this->usuario->tieneRol(1)){
|
||||
$roles = explode(".", $this->getValor("rol"));
|
||||
$rol_final = "";
|
||||
foreach($roles as $r){
|
||||
if($r != $rol){
|
||||
$rol_final .= $r.".";
|
||||
}
|
||||
}
|
||||
$this->setCampos(array("rol" => $rol_final));
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para gestionar los roles de los empleado.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
/*SQL que da los pedidos en el que est<EFBFBD> un candidato dependiendo del estado
|
||||
|
||||
En el ejemplo
|
||||
estado -> 20
|
||||
id Candidato ->12
|
||||
@param $estado - Estado del pedido.
|
||||
@return array codPedido => nombre o vac<EFBFBD>o.
|
||||
*/
|
||||
function getPedidosByEstado($estado){
|
||||
/*SELECT P.oid,P.nombre
|
||||
FROM pedidos P,candidato_pedido CP
|
||||
WHERE CP.candidato='12'
|
||||
AND CP.estado='20'
|
||||
AND P.oid=CP.pedido*/
|
||||
$idC = $this->getValor("oid");
|
||||
$consulta = "SELECT P.oid as oid,P.nombre as nombre
|
||||
FROM pedidos P,candidato_pedido CP
|
||||
WHERE CP.candidato='$idC'
|
||||
AND CP.estado='$estado'
|
||||
AND P.oid=CP.pedido";
|
||||
$bd = new BD();
|
||||
return $bd->keyValueQuery($consulta, "oid", "nombre");
|
||||
}
|
||||
|
||||
function eliminar(){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepci<EFBFBD>n
|
||||
*/
|
||||
$sesion = $this->usuario->getValor("oid");
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
return parent::eliminar();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function actualizarHistorial($mensaje){
|
||||
parent::actualizarHistorial($mensaje, $this->usuario->getValor("nombre"));
|
||||
}
|
||||
|
||||
function transita($destino, $argumentos){
|
||||
$origen = $this->getValor("estado");
|
||||
$idioma = $this->usuario->getValor("idioma");
|
||||
$rol = $this->usuario->getValor("rol");
|
||||
$a = new Automata("candidatos", $idioma, $rol);
|
||||
$transita = $a->getTransicion($origen,$destino);
|
||||
|
||||
if(($transita == "") || !($transita >= 0)){
|
||||
return false;
|
||||
}else{
|
||||
$res = $this->ejecutaTransicion($transita, $argumentos);
|
||||
if($res){
|
||||
$total = explode("#&dias;", $argumentos);
|
||||
$msj = $total[0];
|
||||
$diasEspera = $total[1];
|
||||
$this->setCampos(array("msgEstado" => $msj, "diasEspera" => $diasEspera, "estado" => $destino));
|
||||
/*$this->setCampo("diasEspera", $diasEspera);
|
||||
$this->setCampo("estado", $destino);*/
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
private function ejecutaTransicion($codigo, $argumentos){
|
||||
//Si no hace nada al transitar salimos sin m<>s.
|
||||
if($codigo == 0) return true;
|
||||
$funcion = "ejecutar$codigo";
|
||||
$res = call_user_func(array("Candidato", $funcion), $argumentos);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
208
src/Objects/Empresa.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Empresa
|
||||
*/
|
||||
|
||||
include_once("BD.php");
|
||||
|
||||
class Empresa {
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Usuario que tiene activa la sesión. */
|
||||
private $usuario;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
/* Contiene una lista con todos los atributos y su valor*/
|
||||
private $campos = array();
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Recupera un pedido a partir de su identificador.
|
||||
* @param id - datos necesarios para crear un pedido.
|
||||
*/
|
||||
function Empresa($usuario, $id, $locale){
|
||||
$this->usuario = $usuario;
|
||||
switch (gettype($id)) {
|
||||
case "string":$this->campos['oid']=$id;
|
||||
break;
|
||||
case "array": $this->parseaArray($id);
|
||||
break;
|
||||
case "resource": $this->parseaResource($id);
|
||||
break;
|
||||
default: echo gettype($id);
|
||||
break;
|
||||
}
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el valor de un campo.
|
||||
* @param nombre - nombre del campo por el que buscar.
|
||||
* @return valor del campo buscado.
|
||||
*/
|
||||
function getValor($nombre){
|
||||
$especial = false;
|
||||
if(gettype($nombre) != "integer" && gettype($nombre) != "string"){
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
if(array_key_exists($nombre,$this->campos)){
|
||||
// El campo ya lo habíamos recuperamos, lo mostramos
|
||||
return $this->campos[$nombre];
|
||||
} else {
|
||||
// Hay que recuperar el campo de la base de datos
|
||||
$consulta="SELECT * FROM clientes WHERE oid=\"".$this->campos['oid']."\"";
|
||||
|
||||
switch ($nombre) {
|
||||
case "nombre_gerente":$idGerente=$this->getValor("gerente");
|
||||
$consulta="SELECT CONCAT(nombre,\" \",apellidos) FROM usuarios WHERE oid=\"".$idGerente."\"";
|
||||
$especial = true;
|
||||
break;
|
||||
case "nombre_privacidad":$idGerente=$this->getValor("oid");
|
||||
$consulta="SELECT privado FROM clientes WHERE oid=\"".$idGerente."\"";
|
||||
$especial = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$bd=new BD();
|
||||
|
||||
if(!$especial){
|
||||
$valores = $bd->getRegistro($consulta);
|
||||
|
||||
// Lo insertamos para nosotros
|
||||
foreach($valores as $key => $value){
|
||||
$arrayAct=array($key => $value);
|
||||
$this->campos=$this->campos + $arrayAct;
|
||||
}
|
||||
}else{
|
||||
// Lo insertamos para nosotros
|
||||
$valor= $bd->getCampo($consulta);
|
||||
//echo $valor."-".$consulta;
|
||||
if($nombre == "nombre_privacidad"){
|
||||
switch ($valor) {
|
||||
case 0:
|
||||
$valor = $this->locale['2213'];
|
||||
break;
|
||||
case 1:
|
||||
$valor = $this->locale['2212'];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Lo insertamos para nosotros
|
||||
$arrayAct=array($nombre => $valor);
|
||||
$this->campos=$this->campos + $arrayAct;
|
||||
}
|
||||
|
||||
return $this->campos[$nombre];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso a los campos de la empresa.
|
||||
* @return los campos de la empresa.
|
||||
*/
|
||||
function getCampos(){
|
||||
return $this->campos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna un nuevo campo a la empresa
|
||||
* @param nombre - nombre del campo a asignar.
|
||||
* @param valor - valor del campo.
|
||||
*/
|
||||
private function setCampo($nombre, $valor){
|
||||
$viejo = $this->getValor($nombre);
|
||||
if($viejo != $valor){
|
||||
$this->campos[$nombre] = $valor;
|
||||
$dato = $nombre." = '".$valor."',";
|
||||
return $dato;
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna nuevos campos a la empresa.
|
||||
* @param array - lista de campos a asignar de la forma campo => valor.
|
||||
*/
|
||||
function setCampos($array){
|
||||
if($this->puedeGestionar()){
|
||||
$consulta = "UPDATE clientes SET ";
|
||||
foreach($array as $key => $value){
|
||||
$consulta .= $this->setCampo($key, $value);
|
||||
}
|
||||
//Quitamos la última coma
|
||||
if ($consulta{strlen($consulta) - 1} == ",")
|
||||
$consulta = substr($consulta,0,strlen($consulta) - 1);
|
||||
$oid = $this->getValor("oid");
|
||||
$consulta .= "WHERE oid='$oid'";
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['2206'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina una empresa de la base de datos.
|
||||
*/
|
||||
function eliminar(){
|
||||
//PERMISOS:
|
||||
$gerente = $this->getValor("gerente");
|
||||
if($this->puedeGestionar()){
|
||||
$oid = $this->getValor("oid");
|
||||
$consulta = "DELETE FROM clientes WHERE oid='$oid'";
|
||||
$bd = new BD();
|
||||
if($bd->execQuery($consulta)){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['2206'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si el usuario tiene permisos para gestionar la empresa.
|
||||
*/
|
||||
function puedeGestionar(){
|
||||
//Sólo los gerentes pueden gestionar empresas.
|
||||
if($this->usuario->tieneRol(3)){
|
||||
//Sólo puede si es el propio dueño o administrador.
|
||||
if(($this->usuario->getValor("oid") == $this->getValor("gerente")) || $this->usuario->tieneRol(1)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
482
src/Objects/HTML.php
Normal file
@ -0,0 +1,482 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase HTML
|
||||
*
|
||||
* Muestra contenidos html
|
||||
*/
|
||||
include_once("BD.php");
|
||||
class HTML{
|
||||
|
||||
private $locale;
|
||||
function html($locales){
|
||||
$this->locale=$locales;
|
||||
|
||||
}
|
||||
/*
|
||||
* Crea una paginaci<EFBFBD>n
|
||||
*/
|
||||
function paginacion($numPaginas,$pagActual,$destino,$variables,$nombrePagina){
|
||||
// Comprobamos si hay paginacion
|
||||
if($numPaginas<=1){
|
||||
$salida="";
|
||||
}else{
|
||||
$url=$destino."?";
|
||||
if($variables!=""){
|
||||
$url.=$variables;
|
||||
}
|
||||
$url.="&".$nombrePagina."=";
|
||||
$salida="<ul>";
|
||||
// Flecha de la izquierda
|
||||
if($pagActual!=1){
|
||||
$pagAnterior=$pagActual - 1;
|
||||
$salida.="<li class=\"flecha\"><a href=\"".$url.$pagAnterior."\">";
|
||||
$salida.="<img src=\"css/arrow-left.png\" />" ;
|
||||
$salida.="</a></li>";
|
||||
}
|
||||
for($i=1;$i<=$numPaginas;$i++){
|
||||
$salida.="<li";
|
||||
if($pagActual==$i){
|
||||
$salida.=" class=\"actual\" >";
|
||||
$salida.=$i."</li>";
|
||||
}else{
|
||||
$salida.="><a href=\"".$url.$i."\">".$i."</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
// Flecha de la derecha
|
||||
if($pagActual!=$numPaginas){
|
||||
$pagSiguiente=$pagActual+1;
|
||||
$salida.="<li class=\"flecha\"><a href=\"".$url.$pagSiguiente."\">";
|
||||
$salida.="<img src=\"css/arrow-right.png\" />" ;
|
||||
$salida.="</a></li>";
|
||||
}
|
||||
$salida.="</ul>";
|
||||
}
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
function menuPedidos($usuario,$opciones){
|
||||
if(!is_array($opciones)){
|
||||
$opcionesThis = array();
|
||||
} else {
|
||||
$opcionesThis = $opciones;
|
||||
}
|
||||
echo '<a href="lista_pedidos.php" class="menuOption" style="color:#000000">'.$this->locale['1006'].'</a>';
|
||||
if($usuario->tieneRol("3") ||$usuario->tieneRol("1")){
|
||||
echo '<a href="addPedido.php" class="menuOption" style="color:#000000">'.$this->locale['1008'].'</a>';
|
||||
}
|
||||
echo '<a href="buscar_pedido.php" class="menuOption" style="color:#000000">'.$this->locale['1009'].'</a>';
|
||||
// Buscar candidatos
|
||||
/*if(substr_count($_SERVER['REQUEST_URI'],"/pedido.php?idPedido")==1){
|
||||
echo '<a href="buscar.php" class="menuOption" target="_blank" style="color:#000000">'.$this->locale['820'].'</a>';
|
||||
}
|
||||
*/
|
||||
|
||||
if(!in_array("gestionar",$opcionesThis)){
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/pedido.php?idPedido")==1){
|
||||
echo '<a href="gestion_pedido.php?idPedido='.$_GET['idPedido'].'" class="menuOption" style="color:#000000">'.$this->locale['284'].'</a>';
|
||||
}
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/gestion_pedido.php?idPedido")==1){
|
||||
echo '<a href="pedido.php?idPedido='.$_GET['idPedido'].'" class="menuOption" style="color:#000000">'.$this->locale['1077'].'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function menuCandidatos(){
|
||||
// Lista de candidatos
|
||||
echo '<a href="lista_candidatos.php" class="menuOption" style="color:#000000">'.$this->locale['801'].'</a>';
|
||||
|
||||
// Nuevo candidato
|
||||
echo '<a href="addCandidato.php" class="menuOption" style="color:#000000">'.$this->locale['802'].'</a>';
|
||||
|
||||
// Importar candidato
|
||||
echo '<a href="formulario_importa_candidato.php" class="menuOption"style="color:#000000">'.$this->locale['815'].'</a>';
|
||||
|
||||
// Buscar candidato
|
||||
echo '<a href="buscar_candidato.php" class="menuOption"style="color:#000000">'.$this->locale['816'].'</a>';
|
||||
|
||||
// Editar candidato
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/detalle_candidato.php?oid")==1){
|
||||
echo '<a href="gestion_candidato.php?oid='.$_GET['oid'].'" class="menuOption" style="color:#000000">'.$this->locale['1580'].'</a>';
|
||||
}
|
||||
|
||||
// ver candidato
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/gestion_candidato.php?oid")==1){
|
||||
echo '<a href="detalle_candidato.php?oid='.$_GET['oid'].'" class="menuOption" style="color:#000000">'.$this->locale['1582'].'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function menuEmpleados(){
|
||||
// Lista de empleados
|
||||
echo '<a href="lista_empleados.php" class="menuOption" style="color:#000000">'.$this->locale['806'].'</a>';
|
||||
|
||||
// Nuevo empleado
|
||||
echo '<a href="addEmpleado.php" class="menuOption"style="color:#000000">'.$this->locale['807'].'</a>';
|
||||
|
||||
// Buscar personal
|
||||
echo '<a href="buscar_empleado.php" class="menuOption"style="color:#000000">'.$this->locale['817'].'</a>';
|
||||
|
||||
// Editar empleado
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/detalle_empleado.php?oid")==1){
|
||||
echo '<a href="gestion_empleado.php?oid='.$_GET['oid'].'" class="menuOption" style="color:#000000">'.$this->locale['1584'].'</a>';
|
||||
}
|
||||
|
||||
// ver empleado
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/gestion_empleado.php?oid")==1){
|
||||
echo '<a href="detalle_empleado.php?oid='.$_GET['oid'].'" class="menuOption" style="color:#000000">'.$this->locale['1586'].'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function menuEmpresas($oid,$opciones){
|
||||
if(!is_array($opciones)){
|
||||
$opcionesThis = array();
|
||||
} else {
|
||||
$opcionesThis = $opciones;
|
||||
}
|
||||
echo '<a href="lista_empresas.php" class="menuOption" style="color:#000000">'.$this->locale['2200'].'</a>';
|
||||
echo '<a href="addEmpresa.php" class="menuOption" style="color:#000000">'.$this->locale['2203'].'</a>';
|
||||
if($oid!=""){
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/gestion_empresa.php?oid=")==1){
|
||||
echo '<a href="cliente.php?oid='.$oid.'" class="menuOption" style="color:#000000">'.$this->locale['2309'].'</a>';
|
||||
}
|
||||
if(substr_count($_SERVER['REQUEST_URI'],"/cliente.php?oid=")==1){
|
||||
if(in_array("gestionar",$opcionesThis)){
|
||||
echo '<a href="gestion_empresa.php?oid='.$oid.'" class="menuOption" style="color:#000000">'.$this->locale['2310'].'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function leyendaParteActividad(){
|
||||
echo "<table align=right>";
|
||||
echo "<tr class=encabezado><td colspan=2 align=center>".$this->locale['138b']."</td></tr>";
|
||||
echo "<tr><td>".$this->locale['139']."</td><td>A</td></tr>";
|
||||
echo "<tr><td>".$this->locale['144']."</td><td class=dia_laboral></td></tr>";
|
||||
echo "<tr><td>".$this->locale['145']."</td><td class=dia_festivo></td></tr>";
|
||||
echo "<tr><td>".$this->locale['474']."</td><td class=dia_vacaciones_s></td></tr>";
|
||||
echo "<tr><td>".$this->locale['475']."</td><td class=dia_vacaciones_ap></td></tr>";
|
||||
echo "<tr><td>".$this->locale['476']."</td><td class=dia_vacaciones_r></td></tr>";
|
||||
echo "<tr><td>".$this->locale['477']."</td><td class=dia_vacaciones_an></td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
function leyendaPermisos(){
|
||||
echo "<table align=right>";
|
||||
echo "<tr class=encabezado><td colspan=2 align=center>".$this->locale['138b']."</td></tr>";
|
||||
echo "<tr><td>".$this->locale['144']."</td><td class=dia_laboral></td></tr>";
|
||||
echo "<tr><td>".$this->locale['145']."</td><td class=dia_festivo></td></tr>";
|
||||
echo "<tr><td>".$this->locale['1201']."</td><td class=dia_vacaciones_s></td></tr>";
|
||||
echo "<tr><td>".$this->locale['1203']."</td><td class=dia_vacaciones_ap></td></tr>";
|
||||
echo "<tr><td>".$this->locale['1204']."</td><td class=dia_vacaciones_r></td></tr>";
|
||||
echo "<tr><td>".$this->locale['1202']."</td><td class=dia_vacaciones_an></td></tr>";
|
||||
echo "<tr><td>".$this->locale['147']." o ".$this->locale['149']."</td><td bgcolor=\"#FFAC84\"></td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
function leyendaVacaciones(){
|
||||
echo "<table align=right>";
|
||||
echo "<tr class=encabezado><td colspan=2 align=center>".$this->locale['138b']."</td></tr>";
|
||||
echo "<tr><td>".$this->locale['144']."</td><td class=dia_laboral></td></tr>";
|
||||
echo "<tr><td>".$this->locale['145']."</td><td class=dia_festivo></td></tr>";
|
||||
echo "<tr><td>".$this->locale['146']."</td><td class=dia_vacaciones_s></td></tr>";
|
||||
echo "<tr><td>".$this->locale['147']."</td><td class=dia_vacaciones_ap></td></tr>";
|
||||
echo "<tr><td>".$this->locale['148']."</td><td class=dia_vacaciones_r></td></tr>";
|
||||
echo "<tr><td>".$this->locale['149']."</td><td class=dia_vacaciones_an></td></tr>";
|
||||
echo "<tr><td>".$this->locale['1203']." o ".$this->locale['1202']."</td><td bgcolor=\"#FFAC84\">P</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
/**
|
||||
* Muestra el menu lateral con usuario con varios roles
|
||||
*/
|
||||
function menuLateral($usuario){
|
||||
// Muestra el men<65> lateral
|
||||
// Recogemos todas las opciones
|
||||
$consulta="SELECT * FROM opciones";
|
||||
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
$arrayMenu=array();
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
// Comprobamos si el rol que tiene el usuario puede ver ese menu
|
||||
if($usuario->tieneRolLista($row['roles']))
|
||||
$arrayMenu[$row['menu']]="on";
|
||||
//echo '<li><a title="'.$row['nombre'].'" href="administracion_principal.php?rol='.$row['nombre'].'">'.$row['nombre'].'</a></li>';
|
||||
|
||||
}
|
||||
// Mostramos el menu
|
||||
foreach ($arrayMenu as $opcion => $valor){
|
||||
echo '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>';
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Muestra el submen<EFBFBD> dentro de un men<EFBFBD>
|
||||
*/
|
||||
function menuOpcion($usuario,$menu){
|
||||
// Recogemos todas las opciones
|
||||
$consulta="SELECT * FROM opciones WHERE menu='".$menu."'";
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
$arrayMenu=array();
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
// Comprobamos si el rol que tiene el usuario puede ver ese menu
|
||||
if($usuario->tieneRolLista($row['roles']))
|
||||
echo '<div class="OpcionMenu"><a title="'.$row['nombre'].'" href="'.$row['link'].'.php"><img src="css/'.$row['img'].'.gif" alt="'.$row['nombre'].'"><br>'.$row['nombre'].'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tabla para recoger los par<EFBFBD>metros
|
||||
* @param Nombre de la columna del c<EFBFBD>digo
|
||||
* @param Nombre de la columna del nombre a mostrar
|
||||
* @param Nombre de la select
|
||||
* @param array("cod","nombre") Valor por defecto
|
||||
* @param array("cod" , "cod") Opciones se<EFBFBD>aladas
|
||||
* @param boolean : Mostrar las opciones se<EFBFBD>aladas
|
||||
* @param si es seleccionable multiple o no
|
||||
* @param $size tama<EFBFBD>o m<EFBFBD>ximo, 1=lista desplegable
|
||||
*/
|
||||
function listaSelect($tabla,$codCol,$nameCol,$nombre,$defecto,$opciones,$mostrarOpc,$multiple,$size){
|
||||
$consulta="SELECT ".$codCol." as cod, ".$nameCol." as nombre FROM ".$tabla." ORDER BY nombre";
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
$salida="<select";
|
||||
if($multiple)
|
||||
$salida.=" multiple ";
|
||||
$salida.=" name=\"".$nombre."[]\" id=\"".$nombre."\"";
|
||||
|
||||
if($size>1){
|
||||
if(mysql_num_rows($resultado)>$size)
|
||||
$salida.=" size=\"".$size."\"";
|
||||
else
|
||||
$salida.=" size=\"".mysql_num_rows($resultado)."\"";
|
||||
}
|
||||
$salida.=">";
|
||||
if(count($defecto)!=0)
|
||||
$salida.="<option selected value=\"".$defecto[0]."\">".$defecto[1]."</option>";
|
||||
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
if(gettype($opciones)=="array"){
|
||||
if (!in_array($row['cod'], $opciones)) {
|
||||
$salida.="<option value=\"".$row['cod']."\" >".$row['nombre']."</option>";
|
||||
} elseif ($mostrarOpc) {
|
||||
$salida.="<option selected value=\"".$row['cod']."\" >".$row['nombre']."</option>";
|
||||
}
|
||||
}else {
|
||||
$salida.="<option value=\"".$row['cod']."\" >".$row['nombre']."</option>";
|
||||
}
|
||||
|
||||
}
|
||||
$salida.="</select>";
|
||||
return $salida;
|
||||
}
|
||||
|
||||
/**
|
||||
* Muestra el c<EFBFBD>digo html de una select agrupado, ejemplo localidades->provincias
|
||||
* @param $tablaLoc: Tabla de la localidad
|
||||
* @param $tablaPro: Tabla de la provincia
|
||||
* @param $codLoc : Nombre de la columna del c<EFBFBD>digo de la localidad
|
||||
* @param $nameLoc : Nombre de la columna del nombre de la localidad
|
||||
* @param $codPro : Nombre de la columna del c<EFBFBD>digo de la provincia
|
||||
* @param $namePro : Nombre de la columna del nombre de la provincia
|
||||
* @param $nombre : Nombre de la select
|
||||
* @param $multiple : si es seleccionable multiple o no
|
||||
* @param $size : El tama<EFBFBD>o de la select
|
||||
* @param $opciones : Opciones a se<EFBFBD>alar
|
||||
* @param $mostrarOpc : Si hay que mostar o no las opciones
|
||||
*
|
||||
*/
|
||||
function listaSelectAnidada($tablaLoc,$tablaPro,$codLoc,$nameLoc,$codPro,$namePro,$nombre,$multiple,$size,$opciones,$mostrarOpc){
|
||||
$consulta="SELECT loc.".$codLoc." as id_localidad, loc.".$nameLoc." as nombre_localidad, loc.".$codPro." as id_provincia,pro.".$namePro." as nombre_provincia FROM ".$tablaLoc." loc, ".$tablaPro." pro WHERE loc.provincia=pro.oid ORDER BY nombre_provincia";
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
$salida="<select";
|
||||
if($multiple)
|
||||
$salida.=" multiple ";
|
||||
$salida.=" name=\"".$nombre."[]\" id=\"".$nombre."\"";
|
||||
|
||||
if($size>1){
|
||||
if(mysql_num_rows($resultado)>$size)
|
||||
$salida.=" size=\"".$size."\"";
|
||||
else
|
||||
$salida.=" size=\"".mysql_num_rows($resultado)."\"";
|
||||
}
|
||||
$salida.=">";
|
||||
$provincia="";
|
||||
$primer=true;
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
if($provincia!=$row['nombre_provincia']){
|
||||
$provincia=$row['nombre_provincia'];
|
||||
if(!$primer)
|
||||
$salida.="</optgroup>";
|
||||
else
|
||||
$primer=false;
|
||||
$salida.="<optgroup label=\"".$row['nombre_provincia']."\">";
|
||||
}
|
||||
if(gettype($opciones)=="array"){
|
||||
if (!in_array($row['id_localidad'], $opciones)) {
|
||||
$salida.="<option value=\"".$row['id_localidad']."\" >".$row['nombre_localidad']."</option>";
|
||||
} elseif ($mostrarOpc) {
|
||||
$salida.="<option selected value=\"".$row['id_localidad']."\" >".$row['nombre_localidad']."</option>";
|
||||
}
|
||||
}else {
|
||||
$salida.="<option value=\"".$row['id_localidad']."\" >".$row['nombre_localidad']."</option>";
|
||||
}
|
||||
|
||||
}
|
||||
$salida.="</optgroup>";
|
||||
$salida.="</select>";
|
||||
return $salida;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tabla: Tabla de donde se coger<EFBFBD>n los datos
|
||||
* @param $codCol: Nombre de la columna con el c<EFBFBD>digo
|
||||
* @param $nameCol: Nombre de la columna del nombre
|
||||
* @param $nameColl: Nombre de la columna de la abreviatura
|
||||
*/
|
||||
function adminTabla1($tabla,$codCol,$nameCol,$nameCol2){
|
||||
$salida="<div style=\"float:left; margin-right:10px;min-width:200px\">";
|
||||
$salida.="<b>Escoja la opción actual</b><br />";
|
||||
$nombreColumna="concat(".$nameCol.",\" (\", ".$nameCol2.",\")\")";
|
||||
$salida.=$this->listaSelect($tabla,$codCol,$nombreColumna,"campoSelect",array(),array(),false,false,"15");
|
||||
$salida.="</div>";
|
||||
$salida.="<script type=\"text/javascript\">" .
|
||||
"document.getElementById('campoSelect').onchange=function(){rellenaSelect2InputRecorte('campoSelect','nombreEdit','nombreEdit2');};
|
||||
</script>";
|
||||
$salida.="<div style=\"float:left\" class=\"admin\">" .
|
||||
"<b>Escoja la acción a realizar</b><br />
|
||||
<div class=\"titulo\">Eliminar</div>
|
||||
<input type=\"button\" class=\"button\" name=\"action\" value=\"Eliminar\" onclick=\"verificarEliminarOpcion()\" /><br />
|
||||
<div class=\"titulo\">Editar</div>
|
||||
Nombre : <input id=\"nombreEdit\" type=\"text\" name=\"editName[]\" ><br />
|
||||
Abreviatura : <input id=\"nombreEdit2\" type=\"text\" name=\"editName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Editar\" /><br />
|
||||
<div class=\"titulo\">Añadir nueva</div>
|
||||
Nombre : <input type=\"text\" name=\"newName[]\" ><br />
|
||||
Abreviatura : <input type=\"text\" name=\"newName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Anadir\" />
|
||||
</div>";
|
||||
|
||||
$salida.="<div style=\"clear:both\">
|
||||
</div>";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tabla: Tabla de donde se coger<EFBFBD>n los datos
|
||||
* @param $codCol: Nombre de la columna con el c<EFBFBD>digo
|
||||
* @param $nameCol: Nombre de la columna del nombre
|
||||
*/
|
||||
function adminTabla2($tabla,$codCol,$nameCol){
|
||||
$salida="<div style=\"float:left; margin-right:10px; min-width:200px\">";
|
||||
$salida.="<b>Escoja la opción actual</b><br />";
|
||||
$salida.=$this->listaSelect($tabla,$codCol,$nameCol,"campoSelect",array(),array(),false,false,"15");
|
||||
$salida.="</div>";
|
||||
$salida.="<script type=\"text/javascript\">" .
|
||||
"document.getElementById('campoSelect').onchange=function(){rellenaSelect2Input('campoSelect','nombreEdit');};
|
||||
</script>";
|
||||
|
||||
$salida.="<div style=\"float:left\" class=\"admin\">" .
|
||||
"<b>Escoja la acción a realizar</b><br />
|
||||
<div class=\"titulo\">Eliminar</div>
|
||||
<input type=\"button\" class=\"button\" name=\"action\" value=\"Eliminar\" onclick=\"verificarEliminarOpcion()\" /><br />
|
||||
<div class=\"titulo\">Editar</div>
|
||||
Nombre : <input id=\"nombreEdit\" type=\"text\" name=\"editName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Editar\" /><br />
|
||||
<div class=\"titulo\">Añadir nueva</div>
|
||||
Nombre : <input type=\"text\" name=\"newName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Anadir\" />
|
||||
</div>";
|
||||
|
||||
$salida.="<div style=\"clear:both\">
|
||||
</div>";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
function adminTabla3($tablaLoc,$tablaPro,$codLoc,$nameLoc,$codPro,$namePro){
|
||||
$salida="<div style=\"float:left; margin-right:10px; min-width:200px\">";
|
||||
$salida.="<b>Escoja la opcin actual</b><br />";
|
||||
$salida.=$this->listaSelectAnidada("localidades","provincias","oid","id","provincia","id","campoSelect",false,"15","",true);
|
||||
$salida.="</div>";
|
||||
$salida.="<script type=\"text/javascript\">" .
|
||||
"document.getElementById('campoSelect').onchange=function(){rellenaSelect2InputLoc('campoSelect','nombreEdit','editName');};
|
||||
</script>";
|
||||
|
||||
$salida.="<div style=\"float:left\" class=\"admin\">" .
|
||||
"<b>Escoja la acción a realizar</b><br />
|
||||
<div class=\"titulo\">Eliminar</div>
|
||||
<input type=\"button\" class=\"button\" name=\"action\" value=\"Eliminar\" onclick=\"verificarEliminarOpcion()\" /><br />
|
||||
<div class=\"titulo\">Editar</div>
|
||||
Nombre : <input id=\"nombreEdit\" type=\"text\" name=\"editName[]\" ><br />
|
||||
Provincia : ";
|
||||
$salida .= $this->listaSelect($tablaPro,"oid",$namePro,"editName",array(),array(),false,false,"1");
|
||||
$salida .="<input type=\"submit\" class=\"button\" name=\"action\" value=\"Editar\" />
|
||||
<div class=\"titulo\">Añadir nueva</div>
|
||||
Nombre : <input type=\"text\" name=\"newName[]\" ><br />" .
|
||||
"Provincia : ";
|
||||
$salida .= $this->listaSelect($tablaPro,"oid",$namePro,"newName",array(),array(),false,false,"1");
|
||||
$salida .="<input type=\"submit\" class=\"button\" name=\"action\" value=\"Anadir\" />" .
|
||||
"</div>";
|
||||
|
||||
$salida.="<div style=\"clear:both\">
|
||||
</div>";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
function adminTabla4($tabla,$codCol,$nameCol,$nameCol2){
|
||||
$salida="<table align=center>" .
|
||||
"<tr class=\"encabezado\">" .
|
||||
"<td >Descripcion</td><td>Valor</td>" .
|
||||
"</tr>";
|
||||
$consulta="select ".$codCol." as codigo,".$nameCol." as valor,".$nameCol2." as descripcion FROM ".$tabla;
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
$salida.="<tr>";
|
||||
$salida.="<td>".$row['descripcion']."</td>";
|
||||
$salida.="<td><input type=\"text\" name=\"editName[".$row['codigo']."]\" value=\"".$row['valor']."\"></td>";
|
||||
$salida.="</tr>";
|
||||
}
|
||||
$salida.="</table>";
|
||||
$salida.="<input type=\"submit\" class=\"button\" name=\"action\" value=\"Editar\" />";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tabla: Tabla de donde se coger<EFBFBD>n los datos
|
||||
* @param $codCol: Nombre de la columna con el c<EFBFBD>digo
|
||||
* @param $nameCol: Nombre de la columna del nombre
|
||||
* @param $nameColl: Nombre de la columna de la abreviatura
|
||||
*/
|
||||
function adminTabla5($tabla,$codCol,$nameCol,$nameCol2){
|
||||
$salida="<div style=\"float:left; margin-right:10px;min-width:200px\">";
|
||||
$salida.="<b>Escoja la opción actual</b><br />";
|
||||
$nombreColumna="concat(".$nameCol.",\" (\", ".$nameCol2.",\")\")";
|
||||
$salida.=$this->listaSelect($tabla,$codCol,$nombreColumna,"campoSelect",array(),array(),false,false,"15");
|
||||
$salida.="</div>";
|
||||
$salida.="<script type=\"text/javascript\">" .
|
||||
"document.getElementById('campoSelect').onchange=function(){rellenaSelect2InputRecorte('campoSelect','nombreEdit','nombreEdit2');};
|
||||
</script>";
|
||||
|
||||
$salida.="<div style=\"float:left\" class=\"admin\">" .
|
||||
"<b>Escoja la acción a realizar</b><br />
|
||||
<div class=\"titulo\">Eliminar</div>
|
||||
<input type=\"button\" class=\"button\" name=\"action\" value=\"Eliminar\" onclick=\"verificarEliminarOpcion()\" /><br />
|
||||
<div class=\"titulo\">Editar</div>
|
||||
Nombre : <input id=\"nombreEdit\" type=\"text\" name=\"editName[]\" ><br />
|
||||
Color : <input id=\"nombreEdit2\" type=\"text\" name=\"editName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Editar\" /><br />
|
||||
<div class=\"titulo\">Añadir nueva</div>
|
||||
Nombre : <input type=\"text\" name=\"newName[]\" ><br />
|
||||
Color : <input type=\"text\" name=\"newName[]\" ><input type=\"submit\" class=\"button\" name=\"action\" value=\"Anadir\" />
|
||||
</div>";
|
||||
|
||||
$salida.="<div style=\"clear:both\">
|
||||
</div>";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
62
src/Objects/ListaCandidatos.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaCandidatos
|
||||
*
|
||||
* Contiene una lista de los candidatos.
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("ListaPersonas.php");
|
||||
|
||||
class ListaCandidatos extends ListaPersonas{
|
||||
|
||||
//Atributos:
|
||||
|
||||
//Constructor:
|
||||
|
||||
//Funciones:
|
||||
|
||||
/**
|
||||
* Crea una lista de candidatos.
|
||||
* @param usuario - dueño de la sesión.
|
||||
* @param orden - parámetros por los que ordenar la lista.
|
||||
* @param sql - consulta de búsqueda.
|
||||
*/
|
||||
function ListaCandidatos($usuario,$orden,$sql,$estado){
|
||||
parent::ListaPersonas($usuario, $orden, $sql);
|
||||
$this->tipo = "candidato";
|
||||
$this->estado=$estado;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve la query de la consulta usada en la búsqueda para crear la lista.
|
||||
* @return una cadena de texto con la query.
|
||||
*/
|
||||
function getSQL(){
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve una lista de los posibles estados en los que se puede encontrar un candidato
|
||||
* como Key => value, donde key es el cod del estado y value es el nombre del estado.
|
||||
*/
|
||||
function getEstados(){
|
||||
$consulta = "SELECT cod, nombre FROM candidatos_estados WHERE tipo='candidato'";
|
||||
$bd = new BD();
|
||||
return $bd->keyValueQuery($consulta, "cod", "nombre");
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta un nuevo candidato en la lista de candidatos.
|
||||
* @param campos - datos del candidato.
|
||||
*/
|
||||
function addCandidato($campos){
|
||||
$campos["estado"] = 10;
|
||||
$id = parent::addPersona($campos);
|
||||
$candidato = new Candidato($this->usuario, $id);
|
||||
$mensaje = "Nuevo candidato";
|
||||
$candidato->actualizarHistorial($mensaje);
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
?>
|
||||
46
src/Objects/ListaDocumentos.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 17/10/2008
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
include_once("BD.php");
|
||||
include_once("Usuario.php");
|
||||
include_once("Documento.php");
|
||||
class ListaDocumentos{
|
||||
|
||||
private $usuario;
|
||||
|
||||
function ListaDocumentos($usuario){
|
||||
$this->usuario=$usuario;
|
||||
}
|
||||
|
||||
function getDocumentos(){
|
||||
// Recuperamos toda la lista de documentos
|
||||
$consulta="SELECT * FROM documentos";
|
||||
$bd=new BD();
|
||||
$resultado=$bd->execQuery($consulta);
|
||||
|
||||
$arrayDocumentos=array();
|
||||
|
||||
while($row=mysql_fetch_assoc($resultado)){
|
||||
// Recuperamos en un array la lista de roles que tiene el documento
|
||||
$roles=$row["rol"];
|
||||
// Rol a rol vemos si el usuario tiene ese rol
|
||||
if($this->usuario->tieneRolLista($roles)){
|
||||
//Este manual se puede mostrar
|
||||
$documentoAct=new Documento($row["oid"]);
|
||||
foreach($row as $key => $valor){
|
||||
$documentoAct->actValor($key,$valor);
|
||||
}
|
||||
// Comprobar que no está el documento ya para mostrar
|
||||
|
||||
$arrayDocumentos[]=$documentoAct;
|
||||
}
|
||||
}
|
||||
return $arrayDocumentos;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
63
src/Objects/ListaEmpleados.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaEmpleados
|
||||
*
|
||||
* Contiene una lista de los empleados.
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("ListaPersonas.php");
|
||||
|
||||
class ListaEmpleados extends ListaPersonas{
|
||||
|
||||
//Atributos:
|
||||
|
||||
//Constructor:
|
||||
|
||||
//Funciones:
|
||||
|
||||
/**
|
||||
* Crea una lista de empleados.
|
||||
* @param usuario - dueño de la sesión.
|
||||
* @param orden - parámetros por los que ordenar la lista.
|
||||
* @param sql - consulta de búsqueda.
|
||||
*/
|
||||
function ListaEmpleados($usuario,$orden,$sql,$estado){
|
||||
parent::ListaPersonas($usuario, $orden, $sql);
|
||||
$this->tipo = "usuario";
|
||||
$this->estado=$estado;
|
||||
}
|
||||
|
||||
function getSQL(){
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve una lista de los posibles estados en los que se puede encontrar un candidato
|
||||
* como Key => value, donde key es el cod del estado y value es el nombre del estado.
|
||||
*/
|
||||
function getEstados(){
|
||||
$consulta = "SELECT cod, nombre FROM candidatos_estados WHERE tipo='usuario'";
|
||||
$bd = new BD();
|
||||
return $bd->keyValueQuery($consulta, "cod", "nombre");
|
||||
}
|
||||
|
||||
function addEmpleado($campos){
|
||||
$fecha = date(Y."-".m."-".d);
|
||||
$nombre = $campos["nombre"];
|
||||
$password = md5($nombre);
|
||||
|
||||
$campos["estado"] = 90;
|
||||
$campos["rol"] = 6;
|
||||
$campos["password"] = $password;
|
||||
$campos["fecha_alta"] = $fecha;
|
||||
|
||||
$id = parent::addPersona($campos);
|
||||
$empleado = new Empleado($this->usuario, $id);
|
||||
$mensaje = "Nuevo empleado";
|
||||
$empleado->actualizarHistorial($mensaje);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
121
src/Objects/ListaEmpresas.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaEmpresas
|
||||
*
|
||||
* Contiene una lista de las empresas cliente que tiene un gerente, comprobando los permisos que tiene
|
||||
* éste.
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("Objects/Empresa.php");
|
||||
|
||||
class ListaEmpresas{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de pedidos. */
|
||||
private $empresas = array();
|
||||
|
||||
/* Gestor dueño de la lista. */
|
||||
private $gestor;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea una lista de emmpresas.
|
||||
* @param usuario - gestor dueño de la lista.
|
||||
* @param locale - idioma.
|
||||
*/
|
||||
function ListaEmpresas($usuario,$locale){
|
||||
$this->gestor = $usuario;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca y devuelve todas las empresas clientes del gerente.
|
||||
*/
|
||||
function getEmpresas(){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Gestor (3) - Los suyos y los públicos.
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$estado = $this->tipo;
|
||||
if($this->empresas == null){
|
||||
//Recogemos todas las empresas públicas y las que tienen de gerente al usuario activo.
|
||||
if($this->gestor->tieneRol(3)){
|
||||
if($this->gestor->tieneRol(1)){
|
||||
$consulta = "SELECT * from clientes";
|
||||
}else{
|
||||
$consulta = "SELECT * from clientes WHERE privado = 0 || gerente = ".$this->gestor->getValor("oid");
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['2209'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
$bd=new BD();
|
||||
$resultado = $bd->execQuery($consulta);
|
||||
//Procesamos los pedidos.
|
||||
if(mysql_num_rows($resultado) == 0){
|
||||
$this->empresas = array();
|
||||
}else{
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
$p = new Empresa($this->gestor, $rows["oid"], $this->locale);
|
||||
$this->empresas[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->empresas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añade una empresa a la bd.
|
||||
* @param campos - campos de la nueva empresa.
|
||||
*/
|
||||
function addEmpresa($campos){
|
||||
|
||||
if(!$this->gestor->tieneRol(3)){
|
||||
$error = $this->locale['2204'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
$inserto = "";
|
||||
$valores = "";
|
||||
|
||||
//Procesamos los datos
|
||||
foreach($campos as $key => $value){
|
||||
$inserto .= "$key,";
|
||||
$valores .= "'$value',";
|
||||
}
|
||||
|
||||
if ($inserto{strlen($inserto) - 1} == ",")
|
||||
$inserto = substr($inserto,0,strlen($inserto) - 1);
|
||||
|
||||
if ($valores{strlen($valores) - 1} == ",")
|
||||
$valores = substr($valores,0,strlen($valores) - 1);
|
||||
|
||||
//Insertamos en la BD
|
||||
$consulta = "INSERT INTO clientes ($inserto) VALUES ($valores)";
|
||||
$bd = new BD();
|
||||
if(!$bd->execQuery($consulta)){
|
||||
$error = $this->locale['bd'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}else{
|
||||
$id = mysql_insert_id();
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
89
src/Objects/ListaPartesActividad.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaPartesActividad
|
||||
*
|
||||
* Contiene una lista de partes de actividad de un mes de todos los empleados.
|
||||
*
|
||||
*/
|
||||
include_once("ParteActividad.php");
|
||||
include_once("BD.php");
|
||||
|
||||
class ListaPartesActividad{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de partes. */
|
||||
protected $partes = null;
|
||||
|
||||
/* Usuario que posee activa la sesión. */
|
||||
protected $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* Año del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* modo de búsqueda */
|
||||
private $order_by = "";
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea un objeto Parte de Actividad para un empleado para un mes y año concreto.
|
||||
* @param usuario - Dueño de la sesión.
|
||||
* @param mes - Mes que contempla el parte.
|
||||
* @param anio - Año que contempla el parte.
|
||||
* @param orden - Orden de ordenación de la lista.
|
||||
* @param locale - Contenido del fichero de idioma.
|
||||
*/
|
||||
function ListaPartesActividad($usuario,$mes,$anio, $orden, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if(($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->locale = $locale;
|
||||
if($orden != ""){
|
||||
$this->order_by = $orden;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3024'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso a los partes de todos los empleados del mes.
|
||||
*/
|
||||
function getPartes(){
|
||||
if($this->partes == null){
|
||||
$this->partes = array();
|
||||
$consulta = "SELECT pa.oid,CONCAT(usu.nombre,' ',usu.apellidos) as nombre,sum(dato) as horas,count(*) as jornadas FROM partes_actividad pa,usuarios usu WHERE usu.oid=pa.oid AND fecha like '".$this->anio."-".$this->mes."%' AND dato > 0 AND dato < 25 GROUP BY pa.oid ORDER BY jornadas DESC";
|
||||
$bd = new BD();
|
||||
if($resultado = $bd->execQuery($consulta)){
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
$p = new ParteActividad($this->usuario,$rows["oid"],$this->mes,$this->anio, $this->locale);
|
||||
$p->setHoras($rows["horas"]);
|
||||
$p->setJornadas($rows["jornadas"]);
|
||||
$p->setNombreCompleto($rows["nombre"]);
|
||||
$this->partes[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->partes;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
279
src/Objects/ListaPedido.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaPedido
|
||||
*
|
||||
* Contiene una lista de los pedidos que tiene un gerente, comprobando los permisos que tiene
|
||||
* éste.
|
||||
*
|
||||
* Si tiene permisos de "Gestión de pedidos" podrá ver sus pedidos, si además
|
||||
* tiene permisos de "Selección pedidos"
|
||||
*/
|
||||
|
||||
include_once("Objects/Pedido.php");
|
||||
|
||||
class ListaPedido{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de pedidos. */
|
||||
private $pedidos = array();
|
||||
|
||||
/* Gestor dueño de la lista. */
|
||||
private $gestor;
|
||||
|
||||
/* Campos por los que ordenar la lista. */
|
||||
private $orden;
|
||||
|
||||
/* Condiciones para búsquedas. */
|
||||
private $sql = "";
|
||||
|
||||
/* modo de búsqueda */
|
||||
private $order_by = "";
|
||||
|
||||
/* tipo de pedidos que engloba esta lista*/
|
||||
private $tipo;
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea una lista de pedidos.
|
||||
* @param usuario - gestor dueño de la lista.
|
||||
* @param orden - parámetros por los que ordenar la lista.
|
||||
* @param sql - consulta de búsqueda.
|
||||
*/
|
||||
function ListaPedido($usuario,$orden,$sql,$tipo){
|
||||
$this->gestor = $usuario;
|
||||
$this->orden = $orden;
|
||||
$this->tipo = $tipo;
|
||||
//Si where tiene algún valor se le añade la cláusula where.
|
||||
if($sql != ""){
|
||||
$this->sql = $sql;
|
||||
}
|
||||
if($orden != ""){
|
||||
$this->order_by = $orden;
|
||||
}
|
||||
}
|
||||
|
||||
function getSQL(){
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca y devuelve todos los pedidos del usuario.
|
||||
*/
|
||||
function getPedidos(){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* Selección (4) - Todos
|
||||
* Gestor (3) - Los suyos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$estado = $this->tipo;
|
||||
if($this->pedidos == null){
|
||||
//Modificamos la consulta en función del rol.
|
||||
if($this->gestor->tieneRol(4) || $this->gestor->tieneRol(1)){
|
||||
if($this->sql != ""){
|
||||
// metemos el tipo si es >0
|
||||
if($estado > 0){
|
||||
if(stripos($this->sql,"WHERE")>0){
|
||||
$sqlAntesWhere=substr($this->sql,0,stripos($this->sql,"WHERE"));
|
||||
$sqlDespuesWhere=substr($this->sql,stripos($this->sql,"WHERE")+5,strlen($this->sql));
|
||||
// echo "antes:".$sqlAntesWhere." -- ".$sqlDespuesWhere;
|
||||
$sqlConTipo="WHERE pedidos.estado='".$estado."' and ";
|
||||
$sqlNueva=$sqlAntesWhere.$sqlConTipo.$sqlDespuesWhere;
|
||||
|
||||
} else{
|
||||
echo "COMPRUEBAME si ListaPedido.php cuando no hay WHERE,(avisar a Sergio)";
|
||||
$sqlConTipo="WHERE pedidos.estado='".$estado."' ";
|
||||
$sqlNueva=$this->sql.$sqlConTipo;
|
||||
}
|
||||
} else {
|
||||
$sqlNueva=$this->sql;
|
||||
}
|
||||
$consulta = $sqlNueva." ".$this->order_by;
|
||||
}else{
|
||||
if($estado > 0){
|
||||
$consulta = "SELECT * from pedidos WHERE estado='".$estado."'".$this->orden ;
|
||||
}else{
|
||||
$consulta = "SELECT * from pedidos WHERE estado IN (10, 20, 30) ".$this->orden."";
|
||||
}
|
||||
}
|
||||
}else if($this->gestor->tieneRol(3)){
|
||||
$id = $this->gestor->getValor("oid");
|
||||
if($this->sql != ""){
|
||||
if($estado > 0){
|
||||
if(stripos($this->sql,"WHERE")>0){
|
||||
$sqlAntesWhere=substr($this->sql,0,stripos($this->sql,"WHERE"));
|
||||
$sqlDespuesWhere=substr($this->sql,stripos($this->sql,"WHERE")+5,strlen($this->sql));
|
||||
// echo "antes:".$sqlAntesWhere." -- ".$sqlDespuesWhere;
|
||||
$sqlConTipo="WHERE pedidos.estado='".$estado."' and ";
|
||||
$sqlNueva=$sqlAntesWhere.$sqlConTipo.$sqlDespuesWhere;
|
||||
|
||||
} else{
|
||||
echo "COMPRUEBAME si ListaPedido.php cuando no hay WHERE,(avisar a Sergio)";
|
||||
$sqlConTipo="WHERE pedidos.estado='".$estado."' ";
|
||||
$sqlNueva=$this->sql.$sqlConTipo;
|
||||
}
|
||||
} else {
|
||||
$sqlNueva=$this->sql;
|
||||
}
|
||||
$consulta = $sqlNueva." ".$this->order_by;
|
||||
}else{
|
||||
if($estado > 0){
|
||||
$consulta = "SELECT * FROM pedidos WHERE gerente = '$id' AND estado='$estado'".$this->orden;
|
||||
}else{
|
||||
$consulta = "SELECT * FROM pedidos WHERE estado IN (10, 20, 30) AND gerente = '$id'".$this->orden;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para listar pedidos.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
|
||||
$bd=new BD();
|
||||
$resultado = $bd->execQuery($consulta);
|
||||
//Procesamos los pedidos.
|
||||
if(mysql_num_rows($resultado) == 0){
|
||||
$this->pedidos = array();
|
||||
}else{
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
$p = new Pedido($rows["oid"], $this->gestor);
|
||||
/*for($i=0;$i< mysql_num_fields($resultado);$i++){
|
||||
if(!in_array(mysql_field_name($resultado,$i),$p->getCampos())){
|
||||
$arrayAct=array(mysql_field_name($resultado,$i) => $rows[$i]);
|
||||
$p->setCampos($arrayAct);
|
||||
}
|
||||
}*/
|
||||
$this->pedidos[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->pedidos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve una lista de los posibles estados en los que se puede encontrar un pedido
|
||||
* como Key => value, donde key es el cod del estado y value es el nombre del estado.
|
||||
*/
|
||||
function getEstadosPedidos(){
|
||||
$consulta = "SELECT cod, nombre FROM pedidos_estados";
|
||||
$bd = new BD();
|
||||
return $bd->keyValueQuery($consulta, "cod", "nombre");
|
||||
}
|
||||
|
||||
/**
|
||||
* Añade un pedido a la bd.
|
||||
* @param campos - campos del nuevo pedido.
|
||||
*/
|
||||
function addPedido($campos){
|
||||
|
||||
if(!$this->gestor->tieneRol(1) && !$this->gestor->tieneRol(3)){
|
||||
$error = "El usuario no tiene permisos para crear pedidos.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
|
||||
//Calculamos el id
|
||||
$id = $this->calculaIdProyecto($campos["procedencia"], $campos["cliente"]);
|
||||
$inserto = "oid, fecha";
|
||||
$fecha = "'".date(Y."-".m."-".d)."'";
|
||||
$valores = "$id, $fecha";
|
||||
|
||||
//Procesamos los datos
|
||||
foreach($campos as $key => $value){
|
||||
$inserto .= ", $key";
|
||||
$valores .= ", '$value'";
|
||||
}
|
||||
|
||||
//Insertamos en la BD
|
||||
$consulta = "INSERT INTO pedidos ($inserto) VALUES ($valores)";
|
||||
$bd = new BD();
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return -1;
|
||||
}else{
|
||||
$p = new Pedido($id, $this->gestor);
|
||||
$mensaje = "Nuevo pedido";
|
||||
$p->actualizarHistorial($mensaje);
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
//Calcula el código de un proyecto en función de su procedencia.
|
||||
function calculaIdProyecto($procedencia, $cliente){
|
||||
$bd = new BD();
|
||||
$consulta = "select num,pedidos from procedencia where num='$procedencia'";
|
||||
if($resultado = $bd->execQuery($consulta)){
|
||||
$cli = $cliente;
|
||||
for($i = strlen($cli); $i < 3; $i++){
|
||||
$cli = "0".$cli;
|
||||
}
|
||||
$rows = mysql_fetch_array($resultado);
|
||||
$cod = $rows["pedidos"]+1;
|
||||
$num = $rows["num"];
|
||||
$bd->execQuery("update procedencia set pedidos=pedidos+1 where num=$procedencia");
|
||||
for($i = strlen($cod); $i < 4; $i++){
|
||||
$cod = "0".$cod;
|
||||
}
|
||||
return $num.$cli.$cod;
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Elimina un pedido, tanto de la BD como de la lista de pedidos.
|
||||
// * @param id - Identificador del pedido a eliminar.
|
||||
// * @return true si lo eliminó con éxito y false en caso contrario.
|
||||
// */
|
||||
// function eliminarPedido($id){
|
||||
// //PERMISOS:
|
||||
// /*
|
||||
// * Admin (1) - Eliminar
|
||||
// * Gestor (3) - Lo suyo
|
||||
// * Otro - Excepción
|
||||
// */
|
||||
// if(!$this->gestor->tieneRol(1) && !$this->gestor->tieneRol(3)){
|
||||
// $error = "El usuario no tiene permisos para borrar pedidos.";
|
||||
// throw new Exception($error);
|
||||
// }
|
||||
// $pedido = $this->buscarPedido($id);
|
||||
// //Si lo encuentro puedo eliminarlo.
|
||||
// if($pedido != null){
|
||||
// $lista = $this->pedidos;
|
||||
// $this->pedidos = null;
|
||||
// //Compruebo elemento a elemento es o no el que quiero
|
||||
// //eliminar. Si es así, no lo copio.
|
||||
// foreach($lista as $elem){
|
||||
// if($elem->getValor("oid") != $id){
|
||||
// $this->pedidos[] = $elem;
|
||||
// }
|
||||
// }
|
||||
// //Elimino el pedido de la BD.
|
||||
// $pedido->eliminar();
|
||||
// return true;
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Busca un pedido en función de su identificador.
|
||||
* @return el pedido, en caso de encontrarlo y null en
|
||||
* caso contrario.
|
||||
*/
|
||||
function buscarPedido($id){
|
||||
$lista = $this->getPedidos();
|
||||
if($lista){
|
||||
foreach($lista as $elem){
|
||||
if($elem->getValor("oid") == $id){
|
||||
return $elem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
79
src/Objects/ListaPermisos.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaVacaciones
|
||||
*
|
||||
* Contiene una lista de vacaciones de un mes de todos los empleados.
|
||||
*
|
||||
*/
|
||||
include_once("Objects/Permisos.php");
|
||||
include_once("BD.php");
|
||||
|
||||
class ListaPermisos{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de vacaciones. */
|
||||
protected $vacaciones = null;
|
||||
|
||||
/* Usuario que posee activa la sesión. */
|
||||
protected $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* Año del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea un objeto Lista de Vacaciones para un empleado para un mes y año concreto.
|
||||
* @param usuario - Dueño de la sesión.
|
||||
* @param mes - Mes que contempla las vacaciones.
|
||||
* @param anio - Año que contempla las vacaciones.
|
||||
* @param locale - Contenido del fichero de idioma.
|
||||
*/
|
||||
function ListaPermisos($usuario,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if(($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->locale = $locale;
|
||||
}else{
|
||||
$error = $this->locale['3028'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso a las vacaciones de todos los empleados del mes.
|
||||
*/
|
||||
function getPermisos(){
|
||||
if($this->vacaciones == null){
|
||||
$this->vacaciones = array();
|
||||
$consulta = "SELECT oid FROM permisos WHERE fecha LIKE '".$this->anio."-".$this->mes."%' GROUP BY oid";
|
||||
$bd = new BD();
|
||||
if($resultado = $bd->execQuery($consulta)){
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
$p = new Permisos($this->usuario,$rows["oid"],$this->mes,$this->anio, $this->locale);
|
||||
$this->vacaciones[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->vacaciones;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
289
src/Objects/ListaPersonas.php
Normal file
@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaPersonas
|
||||
*
|
||||
* Contiene una lista de personas.
|
||||
*
|
||||
*/
|
||||
include_once("Candidato.php");
|
||||
include_once("Empleado.php");
|
||||
class ListaPersonas{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de personas. */
|
||||
protected $personas = array();
|
||||
|
||||
/* Usuario que posee activa la sesión. */
|
||||
protected $usuario;
|
||||
|
||||
/* Tipo de personas de la lista (candidatos o empleados). */
|
||||
protected $tipo;
|
||||
|
||||
/* Campos por los que ordenar la lista. */
|
||||
protected $orden;
|
||||
|
||||
/* Condiciones para búsquedas. */
|
||||
protected $sql = "";
|
||||
|
||||
/* modo de búsqueda */
|
||||
protected $order_by = "";
|
||||
|
||||
protected $estado = "";
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea una lista de personas.
|
||||
* @param usuario - dueño de la sesión.
|
||||
* @param orden - parámetros por los que ordenar la lista.
|
||||
* @param sql - consulta de búsqueda.
|
||||
*/
|
||||
function ListaPersonas($usuario,$orden,$sql){
|
||||
$this->usuario = $usuario;
|
||||
$this->orden = $orden;
|
||||
//Si where tiene algún valor se le añade la cláusula where.
|
||||
if($sql != ""){
|
||||
$this->sql = $sql;
|
||||
}
|
||||
if($orden != ""){
|
||||
$this->order_by = $orden;
|
||||
}
|
||||
}
|
||||
|
||||
function getSQL(){
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca y devuelve todas las personas de un tipo.
|
||||
*/
|
||||
function getPersonas(){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Todos
|
||||
* RRHH (4) - Todos
|
||||
* Otro - Excepción
|
||||
*/
|
||||
$estado = $this->estado;
|
||||
if($this->personas == null){
|
||||
//Modificamos la consulta en función del rol.
|
||||
if($this->usuario->tieneRol(4) || $this->usuario->tieneRol(1)){
|
||||
if($this->sql != ""){
|
||||
if($estado > 0){
|
||||
if(stripos($this->sql,"WHERE")>0){
|
||||
$sqlAntesWhere=substr($this->sql,0,stripos($this->sql,"WHERE"));
|
||||
$sqlDespuesWhere=substr($this->sql,stripos($this->sql,"WHERE")+5,strlen($this->sql));
|
||||
// echo "antes:".$sqlAntesWhere." -- ".$sqlDespuesWhere;
|
||||
$sqlConTipo="WHERE usuarios.estado='".$estado."' and ";
|
||||
$sqlNueva=$sqlAntesWhere.$sqlConTipo.$sqlDespuesWhere;
|
||||
|
||||
} else{
|
||||
// TODO quitar el aviso este
|
||||
echo "COMPRUEBAME si ListaPersonas.php cuando no hay WHERE,(avisar a Sergio)";
|
||||
$sqlConTipo="WHERE usuarios.estado='".$estado."' ";
|
||||
$sqlNueva=$this->sql.$sqlConTipo;
|
||||
}
|
||||
|
||||
$consulta = $this->sql." ".$this->order_by;
|
||||
} else {
|
||||
$sqlNueva=$this->sql;
|
||||
}
|
||||
$consulta = $sqlNueva." ".$this->order_by;
|
||||
}else{
|
||||
if($estado > 0){
|
||||
$consulta = "SELECT * from usuarios where tipo = '".$this->tipo."' and estado='".$estado."' ".$this->orden;
|
||||
} else{
|
||||
$consulta = "SELECT * from usuarios where tipo = '".$this->tipo."' and estado in ('10', '30', '50', '70', '90','80', '100')$this->orden";
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$error = "El usuario no tiene permisos para listar personas.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
$bd=new BD();
|
||||
$resultado = $bd->execQuery($consulta);
|
||||
//Procesamos los candidatos.
|
||||
if(mysql_num_rows($resultado) == 0){
|
||||
$this->personas = array();
|
||||
}else{
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
switch ($this->tipo) {
|
||||
case "candidato":$p = new Candidato($this->usuario,$rows["oid"]);
|
||||
break;
|
||||
case "usuario":$p = new Empleado($this->usuario,$rows["oid"]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$this->personas[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->personas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Añade un candidato a la bd.
|
||||
* @param campos - campos del nuevo candidato.
|
||||
*/
|
||||
protected function addPersona($campos){
|
||||
if(!$this->usuario->tieneRol(1) && !$this->usuario->tieneRol(4)){
|
||||
$error = "El usuario no tiene permisos para crear candidatos.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->existe($campos)){
|
||||
$error = "Ya existe una persona con esos campos. No se inserta.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
}
|
||||
|
||||
$fecha = "'".date(Y."-".m."-".d)."'";
|
||||
$inserto = "tipo, fecha_modificacion, fecha_registro";
|
||||
$valores = "'".$this->tipo."', $fecha, $fecha";
|
||||
|
||||
//Procesamos los datos
|
||||
foreach($campos as $key => $value){
|
||||
$inserto .= ", $key";
|
||||
$valores .= ", '$value'";
|
||||
}
|
||||
|
||||
//Insertamos en la BD
|
||||
$consulta = "INSERT INTO usuarios ($inserto) VALUES ($valores)";
|
||||
$bd = new BD();
|
||||
if(!$bd->execQuery($consulta)){
|
||||
$error = "Campos del candidato incorrectos. Por favor, avise al webmaster de este error.";
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
}
|
||||
$id = mysql_insert_id();
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina un candidato, tanto de la BD como de la lista de candidatos.
|
||||
* @param id - Identificador del candidato a eliminar.
|
||||
* @return true si lo eliminó con éxito y false en caso contrario.
|
||||
*/
|
||||
function eliminarPersona($id){
|
||||
//PERMISOS:
|
||||
/*
|
||||
* Admin (1) - Eliminar
|
||||
* RRHH (4) - Eliminar
|
||||
* Otro - Excepción
|
||||
*/
|
||||
if(!$this->usuario->tieneRol(1) && !$this->usuario->tieneRol(4)){
|
||||
$error = "El usuario no tiene permisos para borrar personas.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
$persona = $this->buscarPersona($id);
|
||||
//Si lo encuentro puedo eliminarlo.
|
||||
if($persona != null){
|
||||
$lista = $this->personas;
|
||||
$this->personas = null;
|
||||
//Compruebo elemento a elemento es o no el que quiero
|
||||
//eliminar. Si es así, no lo copio.
|
||||
foreach($lista as $elem){
|
||||
if($elem->getValor("oid") != $id){
|
||||
$this->personas[] = $elem;
|
||||
}
|
||||
}
|
||||
//Elimino el pedido de la BD.
|
||||
$persona->eliminar();
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca un candidato en función de su identificador.
|
||||
* @return el candidato, en caso de encontrarlo y null en
|
||||
* caso contrario.
|
||||
*/
|
||||
function buscarPersona($id){
|
||||
$lista = $this->getPersonas();
|
||||
if($lista){
|
||||
foreach($lista as $elem){
|
||||
if($elem->getValor("oid") == $id){
|
||||
return $elem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function existe($campos){
|
||||
$existe = false;
|
||||
/** EXISTENCIA DE DNI **/
|
||||
$dni = $campos["dni"];
|
||||
|
||||
//Si hay letra en la posición 7 es porque el DNI empezaba por cero y se le ha quitado
|
||||
if(!ereg("^[0-9]+$",$dni[7])){
|
||||
$letra = $dni[7];
|
||||
$cont=8;
|
||||
while(!ereg("^[a-zA-Z]+$",$letra) && $cont < 11){
|
||||
$letra = $dni[$cont];
|
||||
$cont++;
|
||||
}
|
||||
$nums = "0".substr($dni, 0, 7);
|
||||
}else{
|
||||
$letra = $dni[8];
|
||||
$cont=9;
|
||||
while(!verificar_letra($letra) && $cont < 12){
|
||||
$letra = $dni[$cont];
|
||||
$cont++;
|
||||
}
|
||||
$nums = substr($dni, 0, 8);
|
||||
}
|
||||
|
||||
$letra = strtoupper($letra);
|
||||
|
||||
$dni = $nums.$letra;
|
||||
|
||||
$link = conectar();
|
||||
|
||||
$bd = new BD();
|
||||
$consulta = "select dni from usuarios where dni='$dni'";
|
||||
|
||||
if($bd->numFilas($consulta) > 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** EXISTENCIA DE CORREO ELECTRÓNICO **/
|
||||
$email = $campos["email"];
|
||||
|
||||
$consulta = "select email from usuarios where email='$email'";
|
||||
$num = $bd->numFilas($consulta);
|
||||
|
||||
if($num > 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** EXISTENCIA DE NOMBRE Y APELLIDOS **/
|
||||
|
||||
if($campos["nombre"] == "-"){
|
||||
$dato = " ";
|
||||
}else{
|
||||
$dato = $campos["nombre"];
|
||||
}
|
||||
|
||||
$total = trim($dato." ".$campos["apellidos"]);
|
||||
|
||||
$consulta = "select email from usuarios where CONCAT(nombre,' ',apellidos)='$total' or apellidos='$total'";
|
||||
$num = $bd->numFilas($consulta);
|
||||
|
||||
if($num > 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
79
src/Objects/ListaVacaciones.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase ListaVacaciones
|
||||
*
|
||||
* Contiene una lista de vacaciones de un mes de todos los empleados.
|
||||
*
|
||||
*/
|
||||
include_once("Objects/Vacaciones.php");
|
||||
include_once("BD.php");
|
||||
|
||||
class ListaVacaciones{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Una lista de vacaciones. */
|
||||
protected $vacaciones = null;
|
||||
|
||||
/* Usuario que posee activa la sesión. */
|
||||
protected $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* Año del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
//Constructor:
|
||||
|
||||
/**
|
||||
* Crea un objeto Lista de Vacaciones para un empleado para un mes y año concreto.
|
||||
* @param usuario - Dueño de la sesión.
|
||||
* @param mes - Mes que contempla las vacaciones.
|
||||
* @param anio - Año que contempla las vacaciones.
|
||||
* @param locale - Contenido del fichero de idioma.
|
||||
*/
|
||||
function ListaVacaciones($usuario,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if(($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->locale = $locale;
|
||||
}else{
|
||||
$error = $this->locale['3028'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso a las vacaciones de todos los empleados del mes.
|
||||
*/
|
||||
function getVacaciones(){
|
||||
if($this->vacaciones == null){
|
||||
$this->vacaciones = array();
|
||||
$consulta = "SELECT oid FROM vacaciones WHERE fecha LIKE '".$this->anio."-".$this->mes."%' GROUP BY oid";
|
||||
$bd = new BD();
|
||||
if($resultado = $bd->execQuery($consulta)){
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
$p = new Vacaciones($this->usuario,$rows["oid"],$this->mes,$this->anio, $this->locale);
|
||||
$this->vacaciones[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->vacaciones;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
577
src/Objects/ParteActividad.php
Normal file
@ -0,0 +1,577 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 20/10/2008
|
||||
*
|
||||
* Representa el parte de actividad de un empleado y comprende toda su gestión.
|
||||
*
|
||||
* 2008-10-20 (diego): Se crea la clase.
|
||||
*/
|
||||
|
||||
include_once("Empleado.php");
|
||||
include_once("Objects/Permisos.php");
|
||||
|
||||
class ParteActividad{
|
||||
|
||||
/* Usuario de la sesión activa */
|
||||
private $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* Año del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Identificador del dueño del parte*/
|
||||
private $oid;
|
||||
|
||||
/* Empleado dueño del parte. */
|
||||
private $empleado;
|
||||
|
||||
/* Número de horas trabajadas. */
|
||||
private $horas;
|
||||
|
||||
/* Número de jornadas trabajadas. */
|
||||
private $jornadas;
|
||||
|
||||
/* Nombre y apellidos del empleado. */
|
||||
private $nombreCompleto;
|
||||
|
||||
/* Vacaciones asociadas al parte de actividad. */
|
||||
private $vacaciones;
|
||||
|
||||
/* Permisos asociados al parte de actividad. */
|
||||
private $permisos;
|
||||
|
||||
/* Idioma */
|
||||
private $locale;
|
||||
|
||||
/* Observaciones del mes */
|
||||
private $observaciones = null;
|
||||
|
||||
/* Proyecto del parte*/
|
||||
private $proyecto = null;
|
||||
|
||||
/* Cliente */
|
||||
private $cliente = null;
|
||||
|
||||
/**
|
||||
* Crea un objeto Parte de Actividad para un empleado para un mes y año concreto.
|
||||
* @param usuario - Dueño de la sesión.
|
||||
* @param oid - Identificador del dueño del parte de actividad.
|
||||
* @param mes - Mes que contempla el parte.
|
||||
* @param anio - Año que contempla el parte.
|
||||
* @param locale - Contenido del fichero de idioma.
|
||||
*/
|
||||
function ParteActividad($usuario,$oid,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
$this->oid = $oid;
|
||||
$this->locale = $locale;
|
||||
if(($oid == $this->oid) || ($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->empleado = new Empleado($usuario, $oid);
|
||||
$this->horas = -1;
|
||||
$this->jornadas = -1;
|
||||
$this->nombreCompleto = "";
|
||||
$this->vacaciones = null;
|
||||
$this->permisos = null;
|
||||
}else{
|
||||
$error = $this->locale['3024'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getMes(){
|
||||
return $this->mes;
|
||||
}
|
||||
|
||||
function getAnio(){
|
||||
return $this->anio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al parte de actividad del empleado
|
||||
*/
|
||||
function getParte(){
|
||||
$parte=array();
|
||||
|
||||
//Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
|
||||
//Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3002'];
|
||||
throw new Exception($error);
|
||||
return $parte;
|
||||
exit;
|
||||
}else{
|
||||
//Busco el parte de actividad del presente mes:
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT dato, fecha FROM partes_actividad WHERE oid='".$this->oid."' AND fecha like '".$fecha."-%'";
|
||||
$bd = new BD();
|
||||
$array = $bd->keyValueQuery($consulta, "fecha", "dato");
|
||||
//Nos quedamos sólo con el día:
|
||||
foreach($array as $key => $value){
|
||||
$fecha_array = explode("-", $key);
|
||||
$search = array(".");
|
||||
$replace = array(",");
|
||||
$value = str_replace($search, $replace, $value);
|
||||
$parte[$fecha_array[2]+0] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $parte;
|
||||
}
|
||||
|
||||
function rellenaParte($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol técnico y es el que tiene la sesión activa o tiene permisos de admin o RRHH seguimos.
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
if(($oidP == $this->oid) || ($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
foreach($dias as $dia => $parte){
|
||||
if($this->esRellenableDia($dia) || $parte == "P"){
|
||||
$dias_correctos[$dia] = $parte;
|
||||
}else{
|
||||
$dias_fallidos[$dia] = $parte;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rellenables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los días, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos)){
|
||||
//TODO Duda
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepción.
|
||||
}else{
|
||||
$error = $this->locale['3008'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepción.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function insertarDias($dias){
|
||||
$oid = $this->oid;
|
||||
$partes = $this->getParte();
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia => $parte){
|
||||
if($parte != "P"){
|
||||
//Verificamos cada valor del parte:
|
||||
if($this->verificarValorParte($parte)){
|
||||
$search = array(",");
|
||||
$replace = array(".");
|
||||
$parte = str_replace($search, $replace, $parte);
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
//Comprobamos si ha cambiado el parte.
|
||||
if($partes[$dia] != $parte){
|
||||
//Si ya existía actualizamos
|
||||
if(array_key_exists($dia, $partes)){
|
||||
//Si es 0 lo borro en lugar de actualizar.
|
||||
if($parte != "0"){
|
||||
$consulta = "UPDATE partes_actividad SET dato = '".$parte."' WHERE oid = '".$oid."' AND fecha = '".$fecha."'";
|
||||
}else{
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
}
|
||||
}else{
|
||||
//Si es 0 ni inserto.
|
||||
if($parte != "0"){
|
||||
$consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$oid."', '".$fecha."', '".$parte."')";
|
||||
}
|
||||
}
|
||||
//Hay casos en los que no hace falta tocar la base de datos.
|
||||
if($consulta != ""){
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
}else{
|
||||
$mensaje = "Modificado el parte del ".$dia."-".$this->mes."-".$this->anio." -> ".$parte;
|
||||
$this->empleado->actualizarHistorial($mensaje);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3009'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDiasAntesAlta(){
|
||||
$fecha_alta = $this->empleado->getValor("fecha_alta");
|
||||
$fecha_alta = explode("-", $fecha_alta);
|
||||
$mes_alta = $fecha_alta[1];
|
||||
$mes = $this->mes;
|
||||
$anio = $this->anio;
|
||||
$anio_alta = $fecha_alta[0];
|
||||
|
||||
//Si es un mes posterior al de alta, devolvemos vacío
|
||||
if(($anio > $anio_alta) || ($anio == $anio_alta && $mes > $mes_alta)){
|
||||
return array();
|
||||
//Si es un mes anterior al de alta, devolvemos todos
|
||||
}else if(($anio < $anio_alta) || ($anio == $anio_alta && $mes < $mes_alta)){
|
||||
$total = verifica_long_mes($mes, $anio);
|
||||
$dias = array();
|
||||
for($i = 1; $i <= $total; $i++){
|
||||
$dias[] = $i;
|
||||
}
|
||||
return $dias;
|
||||
//Si estamos en el mismo mes, calculamos:
|
||||
}else{
|
||||
$dia_alta = $fecha_alta[2];
|
||||
$dias = array();
|
||||
for($i = 1; $i <= $dia_alta; $i++){
|
||||
$dias[] = $i;
|
||||
}
|
||||
return $dias;
|
||||
}
|
||||
}
|
||||
|
||||
private function verificarValorParte($dato){
|
||||
if ((ereg("^[0-9]+(,[0-9]+)*$",$dato) && ($dato < 25)) || ($dato == "A") || ($dato == "P")){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['3009']." -> ".$dato;
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si el mes es objeto de ser rellenable o no.
|
||||
*/
|
||||
public function esRellenable(){
|
||||
//Si es administrador o RRHH puede rellenar todos.
|
||||
if(($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
return true;
|
||||
}else{
|
||||
$mes = $this->mes;
|
||||
$anio = $this->anio;
|
||||
$dia_hoy = date("j");
|
||||
$mes_hoy = date("n");
|
||||
$anio_hoy = date("Y");
|
||||
//Sólo podemos actualizar partes del mismo mes o del anterior (hasta el día 3).
|
||||
if($anio != $anio_hoy) return false;
|
||||
if(($mes+1 == $mes_hoy) && ($dia_hoy <= 3)) return true;
|
||||
if($mes != $mes_hoy) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private function esRellenableDia($dia){
|
||||
if(($this->usuario->tieneRol(1)) || ($this->usuario->tieneRol(4))){
|
||||
return true;
|
||||
}else{
|
||||
$mes = $this->mes;
|
||||
$anio = $this->anio;
|
||||
$dia_hoy = date("j");
|
||||
$mes_hoy = date("n");
|
||||
$anio_hoy = date("Y");
|
||||
//No se puede rellenar parte de vacaciones solicitadas o aprobadas
|
||||
if($this->vacaciones == null){
|
||||
$this->vacaciones = new Vacaciones($this->usuario, $this->oid, $this->mes, $this->anio, $this->locale);
|
||||
$this->vacaciones->setEmpleado($this->empleado, $this->oid);
|
||||
}
|
||||
if($this->vacaciones->getEstadoDia($dia) == 0) return false;
|
||||
if($this->vacaciones->getEstadoDia($dia) == 1) return false;
|
||||
//No se puede rellenar parte de permisos solicitados o aprobados
|
||||
if($this->permisos == null){
|
||||
$this->permisos = new Permisos($this->usuario, $this->oid, $this->mes, $this->anio, $this->locale);
|
||||
$this->permisos->setEmpleado($this->empleado, $this->oid);
|
||||
}
|
||||
if($this->permisos->getEstadoDia($dia) == 0) return false;
|
||||
if($this->permisos->getEstadoDia($dia) == 1) return false;
|
||||
//Sólo podemos actualizar partes del mismo mes o del anterior (hasta el día 3).
|
||||
if($anio != $anio_hoy) return false;
|
||||
if(($mes+1 == $mes_hoy) && ($dia_hoy <= 3)) return true;
|
||||
if($mes != $mes_hoy) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function setHoras($horas){
|
||||
$this->horas = $horas;
|
||||
return $this->horas;
|
||||
}
|
||||
|
||||
public function setJornadas($horas){
|
||||
$this->jornadas = $horas;
|
||||
return $this->jornadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula las horas totales trabajadas.
|
||||
*
|
||||
* @return Un entero con el número de horas.
|
||||
*/
|
||||
public function getHoras(){
|
||||
if($this->horas == -1){
|
||||
$parte = $this->getParte();
|
||||
$suma = 0;
|
||||
foreach($parte as $dia){
|
||||
if($this->haTrabajado($dia)){
|
||||
$suma = $suma + $dia;
|
||||
}
|
||||
}
|
||||
$this->horas = $suma;
|
||||
}
|
||||
|
||||
return $this->horas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula las jornadas totales trabajadas.
|
||||
*
|
||||
* @return Un entero con el número de jornadas.
|
||||
*/
|
||||
public function getJornadas(){
|
||||
if($this->jornadas == -1){
|
||||
$parte = $this->getParte();
|
||||
$suma = 0;
|
||||
foreach($parte as $dia){
|
||||
if($this->haTrabajado($dia)){
|
||||
$suma = $suma + 1;
|
||||
}
|
||||
}
|
||||
$this->jornadas = $suma;
|
||||
}
|
||||
|
||||
return $this->jornadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si un día se ha trabajado o no.
|
||||
*
|
||||
* @return true si se trabajó y false en caso contrario.
|
||||
*/
|
||||
private function haTrabajado($dia){
|
||||
if ((ereg("^[0-9]+(.[0-9]+)*$",$dia) && ($dia < 25) && ($dia > 0))){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function setNombreCompleto($nombre){
|
||||
$this->nombreCompleto = $nombre;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al nombre del empleado.
|
||||
*/
|
||||
public function getNombreEmpleado(){
|
||||
if($this->nombreCompleto == ""){
|
||||
$this->nombreCompleto = $this->empleado->getValor("nombre")." ".$this->empleado->getValor("apellidos");
|
||||
}
|
||||
|
||||
return $this->nombreCompleto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al identificador del empleado.
|
||||
*/
|
||||
public function getOidEmpleado(){
|
||||
return $this->oid;
|
||||
}
|
||||
|
||||
|
||||
function setObservacion($observaciones){
|
||||
// //Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3002'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}else{
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
if($observaciones==""){
|
||||
// Eliminamos la observacion
|
||||
$consulta="DELETE FROM observaciones WHERE oid = '".$this->oid."' AND fecha = '".$fecha."'";
|
||||
$this->observaciones = null;
|
||||
} else {
|
||||
$this->getObservacion();
|
||||
//Si no había cliente insertamos.
|
||||
if(($this->observaciones == null)){
|
||||
$consulta = "INSERT INTO observaciones (oid, fecha, fecha_mod, persona, observacion) VALUES ('".$this->oid."', '".$fecha."', curdate(),'".$this->usuario->getValor("nombre")."', '".$observaciones."')";
|
||||
$this->observaciones = $observaciones;
|
||||
//Si se ha modificado el clientea actualizamos.
|
||||
}elseif($this->observaciones != $observaciones){
|
||||
$consulta = "UPDATE observaciones SET observacion = '".$observaciones."', fecha_mod = curdate() WHERE oid = '".$this->oid."' AND fecha = '".$fecha."'";
|
||||
$this->observaciones = $observaciones;
|
||||
}
|
||||
}
|
||||
|
||||
//Si hay que actualizar, actualizo:
|
||||
if($consulta != ""){
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna el cliente del empleado.
|
||||
*/
|
||||
public function setCliente($cliente){
|
||||
//Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3002'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}else{
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$this->getCliente();
|
||||
//Si no había cliente insertamos.
|
||||
if(($this->observaciones == null) && ($this->cliente == null) && ($this->proyecto == null)){
|
||||
$consulta = "INSERT INTO observaciones (oid, fecha, fecha_mod, persona, cliente) VALUES ('".$this->oid."', '".$fecha."', curdate(),'".$this->usuario->getValor("nombre")."', '".$cliente."')";
|
||||
$this->cliente = $cliente;
|
||||
//Si se ha modificado el clientea actualizamos.
|
||||
}else if($this->cliente != $cliente){
|
||||
$consulta = "UPDATE observaciones SET cliente = '".$cliente."', fecha_mod = curdate() WHERE persona = '".$this->usuario->getValor("nombre")."' AND fecha = '".$fecha."'";
|
||||
$this->cliente = $cliente;
|
||||
}
|
||||
|
||||
//Si hay que actualizar, actualizo:
|
||||
if($consulta != ""){
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna el proyecto del empleado.
|
||||
*/
|
||||
public function setProyecto($proyecto){
|
||||
//Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3002'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}else{
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$this->getCliente();
|
||||
//Si no había cliente insertamos.
|
||||
if(($this->observaciones == null) && ($this->cliente == null) && ($this->proyecto == null)){
|
||||
$consulta = "INSERT INTO observaciones (oid, fecha, fecha_mod, persona, proyecto) VALUES ('".$this->oid."', '".$fecha."', curdate(),'".$this->usuario->getValor("nombre")."', '".$proyecto."')";
|
||||
$this->proyecto = $proyecto;
|
||||
//Si se ha modificado el clientea actualizamos.
|
||||
}else if($this->proyecto != $proyecto){
|
||||
$consulta = "UPDATE observaciones SET proyecto = '".$proyecto."', fecha_mod = curdate() WHERE persona = '".$this->usuario->getValor("nombre")."' AND fecha = '".$fecha."'";
|
||||
$this->proyecto = $proyecto;
|
||||
}
|
||||
|
||||
//Si hay que actualizar, actualizo:
|
||||
if($consulta != ""){
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getObservacion(){
|
||||
if(($this->observaciones == null) && ($this->cliente == null) && ($this->proyecto == null)){
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT observacion, proyecto, cliente FROM observaciones WHERE oid='".$this->oid."' AND fecha = '".$fecha."'";
|
||||
$bd = new BD();
|
||||
$campos = $bd->getCampos($consulta);
|
||||
if(array_key_exists("observacion", $campos)){
|
||||
$this->observaciones = $campos["observacion"][0];
|
||||
}
|
||||
if(array_key_exists("proyecto", $campos)){
|
||||
$this->proyecto = $campos["proyecto"][0];
|
||||
}
|
||||
if(array_key_exists("cliente", $campos)){
|
||||
$this->cliente = $campos["cliente"][0];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->observaciones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al cliente del proyecto del empleado.
|
||||
*/
|
||||
public function getCliente(){
|
||||
if(($this->observaciones == null) && ($this->cliente == null) && ($this->proyecto == null)){
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT observacion, proyecto, cliente FROM observaciones WHERE oid='".$this->oid."' AND fecha = '".$fecha."'";
|
||||
$bd = new BD();
|
||||
$campos = $bd->getCampos($consulta);
|
||||
if(array_key_exists("observacion", $campos)){
|
||||
$this->observaciones = $campos["observacion"][0];
|
||||
}
|
||||
if(array_key_exists("proyecto", $campos)){
|
||||
$this->proyecto = $campos["proyecto"][0];
|
||||
}
|
||||
if(array_key_exists("cliente", $campos)){
|
||||
$this->cliente = $campos["cliente"][0];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->cliente;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al cliente del proyecto del empleado.
|
||||
*/
|
||||
public function getProyecto(){
|
||||
if(($this->observaciones == null) && ($this->cliente == null) && ($this->proyecto == null)){
|
||||
$fecha = $this->anio."-".$this->mes;
|
||||
$consulta = "SELECT observacion, proyecto, cliente FROM observaciones WHERE oid='".$this->oid."' AND fecha = '".$fecha."'";
|
||||
$bd = new BD();
|
||||
$campos = $bd->getCampos($consulta);
|
||||
if(array_key_exists("observacion", $campos)){
|
||||
$this->observaciones = $campos["observacion"][0];
|
||||
}
|
||||
if(array_key_exists("proyecto", $campos)){
|
||||
$this->proyecto = $campos["proyecto"][0];
|
||||
}
|
||||
if(array_key_exists("cliente", $campos)){
|
||||
$this->cliente = $campos["cliente"][0];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->proyecto;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
1287
src/Objects/Pedido.php
Normal file
867
src/Objects/Permisos.php
Normal file
@ -0,0 +1,867 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 20/10/2008
|
||||
*
|
||||
* Representa la vacaciones de un empleado y comprende toda su gesti<EFBFBD>n.
|
||||
*
|
||||
* 2008-10-20 (diego): Se crea la clase.
|
||||
*/
|
||||
|
||||
include_once("Empleado.php");
|
||||
include_once("ParteActividad.php");
|
||||
include_once("./functions_sistema.php");
|
||||
include_once("Calendario.php");
|
||||
|
||||
class Permisos{
|
||||
|
||||
/* Lista de vacaciones */
|
||||
private $vacaciones;
|
||||
|
||||
/* Lista de vacaciones solicitadas */
|
||||
private $vacacionesSolicitadas = null;
|
||||
|
||||
/* Lista de vacaciones aprobadas*/
|
||||
private $vacacionesAprobadas = null;
|
||||
|
||||
/* Lista de vacaciones rechazadas*/
|
||||
private $vacacionesRechazadas = null;
|
||||
|
||||
/* Lista de vacaciones pendientes de anulaci<63>n */
|
||||
private $vacacionesAnulables = null;
|
||||
|
||||
/* Usuario de la sesi<73>n activa */
|
||||
private $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* A<>o del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Identificador del solicitante de vacaciones*/
|
||||
private $oid;
|
||||
|
||||
/* Empleado solicitante de vacaciones */
|
||||
private $empleado;
|
||||
|
||||
/* Calendario para calcular d<>as especiales. */
|
||||
private $calendario;
|
||||
|
||||
/** Idioma */
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* Crea un objeto que representa las vacaciones de un usuario.
|
||||
* @param usuario - Usuario con la sesi<EFBFBD>n activa.
|
||||
* @param oid - Identificador del propietario de las vacaciones.
|
||||
* @param mes - Mes del a<EFBFBD>o en que se gestionan las vacaciones.
|
||||
* @param anio - A<EFBFBD>o para el que se gestionan las vacaciones.
|
||||
* @param locale - Idioma en el que mostrar los mensajes.
|
||||
*/
|
||||
function Permisos($usuario,$oid,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->oid = $oid;
|
||||
$this->locale = $locale;
|
||||
$this->calendario = new Calendario($this->usuario, $this->mes, $this->anio, array(), "", $this->locale);
|
||||
if($oid > 0){
|
||||
$this->empleado = new Empleado($usuario, $oid);
|
||||
}else{
|
||||
$error = $this->locale['1534'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n en un determinado estado.
|
||||
*
|
||||
* @param estado - Estado en el que se busca que est<EFBFBD>n las vacaciones.
|
||||
* @return Una lista con las vacaciones en ese estado.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
private function cargaPermisos(){
|
||||
if($this->vacaciones == null){
|
||||
$this->vacacionesSolicitadas = array();
|
||||
$this->vacacionesAprobadas = array();
|
||||
$this->vacacionesRechazadas = array();
|
||||
$this->vacacionesAnulables = array();
|
||||
//Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
//Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3031'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
//Permisos correctos, sigo.
|
||||
}else{
|
||||
//Cargo la lista de d<>as:
|
||||
$fecha = $this->anio."-".$this->mes."-";
|
||||
$consulta = "SELECT fecha, aprobada FROM permisos WHERE oid='".$this->oid."' AND fecha like '".$fecha."%'";
|
||||
$bd = new BD();
|
||||
$array = $bd->keyValueQuery($consulta, "fecha", "aprobada");
|
||||
$this->vacaciones = array();
|
||||
foreach($array as $fecha => $estado){
|
||||
$dia = explode("-", $fecha);
|
||||
$dia = $dia[2]+0;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// $dias=array();
|
||||
//
|
||||
// //Comprobamos permisos:
|
||||
// $oidP = $this->usuario->getValor("oid");
|
||||
//
|
||||
// //Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
// if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
// $error = $this->locale['3031'];
|
||||
// throw new Exception($error);
|
||||
// return $dias;
|
||||
// exit;
|
||||
// }else{
|
||||
// //Busco los d<>as solicitados:
|
||||
// $fecha = $this->anio."-".$this->mes."-";
|
||||
// $consulta = "SELECT fecha FROM vacaciones WHERE oid='".$this->oid."' AND aprobada = '".$estado."' AND fecha like '".$fecha."%'";
|
||||
// $bd = new BD();
|
||||
// $array = $bd->arrayQuery($consulta, "fecha");
|
||||
// foreach($array as $elem){
|
||||
// $dia = explode("-", $elem);
|
||||
// $dias[] = $dia[2]+0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $dias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n solicitadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getPermisosSolicitados(){
|
||||
if($this->vacacionesSolicitadas == null){
|
||||
$this->cargaPermisos();
|
||||
}
|
||||
|
||||
return $this->vacacionesSolicitadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n aprobadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getPermisosAprobados(){
|
||||
if($this->vacacionesAprobadas == null){
|
||||
$this->cargaPermisos();
|
||||
}
|
||||
|
||||
return $this->vacacionesAprobadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n rechazadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones rechazadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getPermisosRechazados(){
|
||||
if($this->vacacionesRechazadas == null){
|
||||
$this->cargaPermisos();
|
||||
}
|
||||
|
||||
return $this->vacacionesRechazadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n pendientes de anulaci<EFBFBD>n.
|
||||
*
|
||||
* @return Una lista con las vacaciones pendientes de anulaci<EFBFBD>n.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getPermisosPendientes(){
|
||||
if($this->vacacionesAnulables == null){
|
||||
$this->cargaPermisos();
|
||||
}
|
||||
|
||||
return $this->vacacionesAnulables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al mes.
|
||||
* @return El mes.
|
||||
*/
|
||||
function getMes(){
|
||||
return $this->mes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al a<EFBFBD>o.
|
||||
* @return El a<EFBFBD>o.
|
||||
*/
|
||||
function getAnio(){
|
||||
return $this->anio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula el estado en el que se encuentra un d<EFBFBD>a.
|
||||
*
|
||||
* @param dia - D<EFBFBD>a dentro del mes y a<EFBFBD>o de las vacaciones.
|
||||
* @return El c<EFBFBD>digo de estado si se encuentra el d<EFBFBD>a, -1 en caso contrario.
|
||||
*/
|
||||
public function getEstadoDia($dia){
|
||||
$this->cargaPermisos();
|
||||
$estado = $this->vacaciones[$dia];
|
||||
|
||||
if($estado == "" || $estado < 0){
|
||||
$estado = -1;
|
||||
}
|
||||
|
||||
return $estado;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function insertarDias($dias, $estado){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//En el caso de solicitud de permisos o solicitud de anulaci<63>n de permisos es t<>cnico.
|
||||
if($estado == 0 || $estado == 3){
|
||||
$observacion = "observacion_tecnico";
|
||||
$observacion2 = "observacion_rrhh";
|
||||
$mensaje2 = $this->getObservacionRRHH($dia);
|
||||
//En caso de aprobaci<63>n o rechace de permisos es RRHH
|
||||
}else if($estado == 1 || $estado == 2){
|
||||
$observacion = "observacion_rrhh";
|
||||
$observacion2 = "observacion_tecnico";
|
||||
$mensaje2 = $this->getObservacionTecnico($dia);
|
||||
}
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM permisos WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO permisos (oid, fecha, aprobada,f_mod , ".$observacion.", ".$observacion2.") VALUES ('".$oid."', '".$fecha."', '".$estado."',curdate(), '".$mensaje."', '".$mensaje2."')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
$this->cambiaEstado($dia, $estado);
|
||||
$consulta = "";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function eliminaDia($dia){
|
||||
$this->vacaciones = array_diff($this->vacaciones, array($dia));
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function cambiaEstado($dia, $estado){
|
||||
$this->cargaPermisos();
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
if($estadoPrevio == "") $estadoPrevio = -1;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
//Actuamos s<>lo si hay cambio de estado.
|
||||
if($estadoPrevio != $estado){
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
//Y lo insertamos en la correspondiente:
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getObservacionTecnico($dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "SELECT observacion_tecnico FROM permisos WHERE fecha = '".$fecha."' AND oid = ".$this->oid."";
|
||||
$bd = new BD();
|
||||
return $bd->getCampo($consulta);
|
||||
}
|
||||
|
||||
public function getObservacionRRHH($dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "SELECT observacion_rrhh FROM permisos WHERE fecha = '".$fecha."' AND oid = ".$this->oid."";
|
||||
$bd = new BD();
|
||||
return $bd->getCampo($consulta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicita unos d<EFBFBD>as de vacaciones. Si alguno falla no se solicita ninguno.
|
||||
* @return true si se pudieron solicitar todos y false si falla alguno.
|
||||
*/
|
||||
public function solicitar($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if((($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid))
|
||||
|| $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
if(($this->esSolicitable($dia)) and ($mensaje != "")){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
$solicitud = $dia.",";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 0)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['620']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."\n\n";
|
||||
$email = $email."\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['621'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3033'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3032'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede solicitar un d<EFBFBD>a como vacaciones.
|
||||
*
|
||||
*/
|
||||
public function esSolicitable($dia){
|
||||
if($this->usuario->tieneRol("4")){
|
||||
return true;
|
||||
}
|
||||
$plazo = constante("antelacion_permisos");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si no est<73>n ya solicitadas ni el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
|
||||
if(($estado == -1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Aprobaci<EFBFBD>n de una solicitud de vacaciones.
|
||||
*/
|
||||
public function aprobar($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
$muestra_dias = "";
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo aprobar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son aprobables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la aprobaci<63>n e insertamos
|
||||
//una P en el parte de actividad.
|
||||
if($this->insertarDias($dias_correctos, 1)){
|
||||
$bd = new BD();
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$this->oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$this->oid."', '".$fecha."', 'P')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
}
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
$email = $this->locale['617']." ".$muestra_dias.$this->locale['623'];
|
||||
|
||||
if(!envia_correo_empleados($direccion, $this->locale['622'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3035'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos aprobables.
|
||||
}else{
|
||||
$error = $this->locale['3035'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3034'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de vacaciones.
|
||||
*/
|
||||
function rechazar($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo rechazar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 2)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$email = $this->locale['617']." ".$muestra_dias.$this->locale['624'];
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['622'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3036'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3036'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3037'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de anulaci<EFBFBD>n de vacaciones.
|
||||
*/
|
||||
function rechazarAnulacion($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo rechazar vacaciones pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 1)){
|
||||
//TODO <20>Necesario?
|
||||
}else{
|
||||
$error = $this->locale['3038'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3038'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3037'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Anulaci<EFBFBD>n de unas permisos aprobados.
|
||||
*/
|
||||
function anular($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo anular las pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$solicitud = $dia.",";
|
||||
$dias_correctos[] = $dia;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son aprobables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las anuladas.
|
||||
if($this->anularDias($dias_correctos)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['618']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."\n\n";
|
||||
$path = "http://portal.selforsistemas.net";
|
||||
$link = "<a href='".$path."/detalle_empleado.php?oid=".$oid."'>".$nombre."</a>";
|
||||
$email = $email.$link."\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['619'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3039'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos anulables.
|
||||
}else{
|
||||
$error = $this->locale['3039'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3040'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function eliminarSolicitud($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo eliminar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[] = $dia;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->anularDias($dias_correctos)){
|
||||
return true;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3012'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function anularDias($dias){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM permisos WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$this->eliminaDia($dia);
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
// $consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$oid."', '".$fecha."', '0')";
|
||||
// if(!$bd->execQuery($consulta)){
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicitud de anulaci<EFBFBD>n de unas vacaciones aprobadas.
|
||||
*/
|
||||
function solicitarAnulacion($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if(($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
if($this->esAnulable($dia)){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 3)){
|
||||
//TODO
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3041'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3041'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function setEmpleado($empleado, $oid){
|
||||
$this->empleado = $empleado;
|
||||
$this->oid = $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede solicitar un d<EFBFBD>a como vacaciones.
|
||||
*
|
||||
*/
|
||||
public function esAnulable($dia){
|
||||
$plazo = constante("antelacion_permisos");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si est<73>n aprobadas y el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
if(($estado == 1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getOidPersona(){
|
||||
return $this->empleado->getValor("oid");
|
||||
}
|
||||
|
||||
function getNombrePersona(){
|
||||
return $this->empleado->getValor("nombre")." ".$this->empleado->getValor("apellidos");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
1074
src/Objects/Persona.php
Normal file
63
src/Objects/Rol.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Rol
|
||||
*
|
||||
* Contiene toda la información relativa al rol.
|
||||
*
|
||||
* 2008-11-03 (diego): Se crea la clase con los métodos necesarios para gestionar roles.
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
class Rol{
|
||||
|
||||
/* Lista de roles que están por encima del representado por el objeto
|
||||
* y que heredan todos sus permisos. */
|
||||
private $padres = array();
|
||||
|
||||
private $id;
|
||||
|
||||
private $nombre;
|
||||
|
||||
function Rol($oid){
|
||||
$consulta = "SELECT id, padres FROM rol WHERE oid = '$oid'";
|
||||
$bd = new BD();
|
||||
$campos = $bd->getCampos($consulta);
|
||||
if(count($campos[0] > 0)){
|
||||
$this->oid = $oid;
|
||||
$this->id = $campos["id"][0];
|
||||
$this->padres = $campos["padres"][0];
|
||||
}else{
|
||||
$error = "Error de conexión.";
|
||||
throw new Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
function getValor($campo){
|
||||
switch ($campo) {
|
||||
case "nombre":
|
||||
return $this->nombre;
|
||||
break;
|
||||
case "oid":
|
||||
return $this->oid;
|
||||
break;
|
||||
case "padres":
|
||||
return $this->padres;
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si es hijo de un rol especificado.
|
||||
* @param rol - Rol padre.
|
||||
* @return true en caso afirmativo y false en caso contrario.
|
||||
*/
|
||||
function esHijoDe($rol){
|
||||
$arrayByUser=explode(".", $this->padres);
|
||||
return in_array($rol, $arrayByUser);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
210
src/Objects/Semaforo.php
Normal file
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Semaforo
|
||||
*
|
||||
* Gestiona los semáforos.
|
||||
*
|
||||
* 2008-09-30 (diego): Se crea el objeto con los métodos necesarios para bloquear registros en uso.
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
|
||||
class Semaforo{
|
||||
|
||||
//Atributos:
|
||||
|
||||
/* Usuario que tiene activa la sesión */
|
||||
private $usuario;
|
||||
private $paginas;
|
||||
private $locale;
|
||||
|
||||
function Semaforo($usuario,$locale){
|
||||
$this->usuario = $usuario;
|
||||
//Para los pedidos
|
||||
$this->paginas["gestion_pedido.php"]['0'] = "edit";
|
||||
$this->paginas["gestion_pedido.php"]['1'] = "idPedido";
|
||||
$this->paginas["gestion_pedido.php"]['2'] = "pedidos";
|
||||
$this->paginas["gestion_pedido.php"]['3'] = "pedido.php";
|
||||
$this->paginas["gestion_pedido.php"]['4'] = "1";
|
||||
$this->paginas["eliminar_pedido.php"]['0'] = "edit";
|
||||
$this->paginas["eliminar_pedido.php"]['1'] = "idPedido";
|
||||
$this->paginas["eliminar_pedido.php"]['2'] = "pedidos";
|
||||
$this->paginas["eliminar_pedido.php"]['3'] = "pedido.php";
|
||||
$this->paginas["eliminar_pedido.php"]['4'] = "2";
|
||||
$this->paginas["gestion_candidato.php"]['0'] = "edit";
|
||||
$this->paginas["gestion_candidato.php"]['1'] = "oid";
|
||||
$this->paginas["gestion_candidato.php"]['2'] = "usuarios";
|
||||
$this->paginas["gestion_candidato.php"]['3'] = "detalle_candidato.php";
|
||||
$this->paginas["gestion_candidato.php"]['4'] = "3";
|
||||
$this->paginas["gestion_empleado.php"]['0'] = "edit";
|
||||
$this->paginas["gestion_empleado.php"]['1'] = "oid";
|
||||
$this->paginas["gestion_empleado.php"]['2'] = "usuarios";
|
||||
$this->paginas["gestion_empleado.php"]['3'] = "detalle_empleado.php";
|
||||
$this->paginas["gestion_empleado.php"]['4'] = "4";
|
||||
$this->paginas["elimina_candidato.php"]['0'] = "edit";
|
||||
$this->paginas["elimina_candidato.php"]['1'] = "oid";
|
||||
$this->paginas["elimina_candidato.php"]['2'] = "usuarios";
|
||||
$this->paginas["elimina_candidato.php"]['3'] = "detalle_candidato.php";
|
||||
$this->paginas["elimina_candidato.php"]['4'] = "5";
|
||||
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
function regular($url){
|
||||
$pagina = $this->nombrePagina($url);
|
||||
$modo = $this->paginas[$pagina]['0'];
|
||||
$id_modo = $this->paginas[$pagina]['1'];
|
||||
$tabla = $this->paginas[$pagina]['2'];
|
||||
$id = $this->parametro($url, $id_modo);
|
||||
//Sistema de bloqueo nuevo.
|
||||
if($modo == "edit" && $id){
|
||||
//Si no está bloqueado lo bloqueo para mí.
|
||||
if(!$this->estaBloqueado($tabla, $id)){
|
||||
$this->bloquear($tabla, $id);
|
||||
//Si está bloqueado lanzo una excepción para avisar.
|
||||
}else{
|
||||
$cod = $this->paginas[$pagina]['4'];
|
||||
$error = $this->paginas[$pagina]['3'];
|
||||
$error .= "?$id_modo=$id&msgSem=$cod";
|
||||
throw new Exception($error);
|
||||
}
|
||||
//Página de no bloqueo, la libero.
|
||||
}else if($modo != "edit"){
|
||||
$this->liberar();
|
||||
}
|
||||
}
|
||||
|
||||
function getMensaje($cod){
|
||||
$m = "s$cod";
|
||||
return $this->locale[$m];
|
||||
}
|
||||
|
||||
private function nombrePagina($url){
|
||||
$tok = strtok ($url,"/");
|
||||
$pag = $tok;
|
||||
|
||||
while ($tok !== false) {
|
||||
$tok = strtok("/");
|
||||
if($tok !== false){
|
||||
$pag = $tok;
|
||||
}
|
||||
}
|
||||
|
||||
$pag = strtok ($pag,"?");
|
||||
|
||||
return $pag;
|
||||
}
|
||||
|
||||
private function parametro($url, $id_modo){
|
||||
//Recuperamos los argumentos
|
||||
$tok = strtok ($url,"?");
|
||||
$pag = $tok;
|
||||
|
||||
while ($tok !== false) {
|
||||
$tok = strtok("?");
|
||||
if($tok !== false){
|
||||
$pag = $tok;
|
||||
}
|
||||
}
|
||||
|
||||
//Miramos argumento a argumento
|
||||
$tok = strtok ($pag,"&");
|
||||
|
||||
while ($tok !== false) {
|
||||
if($tok !== false){
|
||||
$id = strtok($tok, "=");
|
||||
if($id == $id_modo){
|
||||
$valor = strtok("&");
|
||||
}
|
||||
}
|
||||
$tok = strtok("&");
|
||||
}
|
||||
|
||||
return $valor;
|
||||
}
|
||||
|
||||
private function bloquear($tabla, $id){
|
||||
$usuario = $this->usuario->getValor("oid");
|
||||
$consulta = "UPDATE $tabla SET mutex='$usuario', tiempo=now() WHERE oid='$id'";
|
||||
$bd=new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
private function liberar(){
|
||||
$usuario = $this->usuario->getValor("oid");
|
||||
$this->liberarPartesActividad($usuario);
|
||||
$this->liberarPedidos($usuario);
|
||||
$this->liberarUsuarios($usuario);
|
||||
$this->liberarVacaciones($usuario);
|
||||
}
|
||||
|
||||
private function liberarPartesActividad($usuario){
|
||||
$consulta = "UPDATE partes_actividad SET mutex='0' WHERE mutex='$usuario'";
|
||||
$bd=new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
private function liberarPedidos($usuario){
|
||||
$consulta = "UPDATE pedidos SET mutex='0' WHERE mutex='$usuario'";
|
||||
$bd=new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
private function liberarUsuarios($usuario){
|
||||
$consulta = "UPDATE usuarios SET mutex='0' WHERE mutex='$usuario'";
|
||||
$bd=new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
private function liberarVacaciones($usuario){
|
||||
$consulta = "UPDATE vacaciones SET mutex='0' WHERE mutex='$usuario'";
|
||||
$bd=new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
private function estaBloqueado($tabla, $id){
|
||||
$seguimos = false;
|
||||
$usuario = $this->usuario->getValor("oid");
|
||||
$consulta = "select mutex,tiempo from $tabla where oid = '".$id."'";
|
||||
$bd = new BD();
|
||||
if($resultado = $bd->execQuery($consulta)){
|
||||
while ($row = mysql_fetch_array($resultado)){
|
||||
$mutex = $row["mutex"];
|
||||
$fecha = $row["tiempo"];
|
||||
$seguimos = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Si está bloqueado por el usuario que tiene sesión no se considera ocupado y puede entrar.
|
||||
if($mutex == $usuario) return false;
|
||||
|
||||
if ($seguimos && ($mutex > 0)){
|
||||
/* Ahora tenemos que comparar la fecha almacenada con la actual. Si
|
||||
la diferencia es mayor de 20 minutos, volvemos a poner el mutex a 0
|
||||
*/
|
||||
list($a_m_d, $h_m_s) = split(" ",$fecha);
|
||||
list($anio, $mes, $dia) = split("-",$a_m_d);
|
||||
list($hora, $minuto, $segundo) = split(":",$h_m_s);
|
||||
|
||||
$fecha_mutex = mktime($hora,$minuto,$segundo,$mes,$dia,$anio);
|
||||
$fecha_ahora = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));
|
||||
|
||||
//Han pasado 1200 segundos?
|
||||
$diferencia = $fecha_ahora - $fecha_mutex;
|
||||
if ($diferencia >= 1200){
|
||||
//Ha caducado el semáforo, lo ponemos a cero
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
if ($resultado = mysql_query("update $tabla set mutex=0 where oid = '".$oid."'")){
|
||||
return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
88
src/Objects/Usuario.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
* Clase Usuario
|
||||
*
|
||||
* Contiene toda la información relativa al usuario.
|
||||
*
|
||||
* 2008-09-30 (sergio): Se crea el objeto con los métodos necesarios para recuperar permisos
|
||||
*
|
||||
*/
|
||||
include_once("BD.php");
|
||||
include_once("Persona.php");
|
||||
class Usuario extends Persona{
|
||||
|
||||
function Usuario($email){
|
||||
$bd = new BD();
|
||||
$consulta = "SELECT oid FROM usuarios WHERE email='$email'";
|
||||
$oid = $bd->getCampo($consulta);
|
||||
parent::Persona($oid);
|
||||
}
|
||||
|
||||
public function getRutaCV($id){
|
||||
if($this->tieneRol(4) || $this->tieneRol(3)){
|
||||
$consulta = "SELECT curriculum FROM curriculum_usuario WHERE cod = '".$id."'";
|
||||
$bd = new BD();
|
||||
$ruta = $bd->getCampo($consulta);
|
||||
|
||||
if($ruta != ""){
|
||||
return $ruta;
|
||||
}else{
|
||||
$error = $this->locale['4045'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4045'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function getNombreCV($id){
|
||||
if($this->tieneRol(4) || $this->tieneRol(3)){
|
||||
$ruta = $this->getRutaCV($id);
|
||||
$consulta="SELECT CONCAT(nombre,\" \",apellidos,\" (\",fecha,\")\") FROM usuarios, curriculum_usuario WHERE curriculum_usuario.cod=\"".$id."\" AND curriculum_usuario.oid = usuarios.oid";
|
||||
$bd = new BD();
|
||||
$nombre = $bd->getCampo($consulta);
|
||||
|
||||
$posicion = strrpos($ruta,".")+1;
|
||||
$extension = substr($ruta,$posicion);
|
||||
|
||||
$resultado = $nombre.".".$extension;
|
||||
|
||||
if($resultado != ""){
|
||||
return $resultado;
|
||||
}else{
|
||||
$error = $this->locale['4045'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['4045'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function compruebaChangePass(){
|
||||
if($this->tieneRol("6")){
|
||||
// Comprobamos que el usuario tiene una password distina que la de por defecto
|
||||
$pass=$this->getValor("password");
|
||||
$passDefecto=md5($this->getValor("nombre"));
|
||||
if($pass==$passDefecto){
|
||||
?>
|
||||
<script>
|
||||
alert("Recuerde que debe de cambiar la contraseña que se le ha asignado");
|
||||
document.location="password.php";
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
959
src/Objects/Vacaciones.php
Normal file
@ -0,0 +1,959 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 20/10/2008
|
||||
*
|
||||
* Representa la vacaciones de un empleado y comprende toda su gesti<EFBFBD>n.
|
||||
*
|
||||
* 2008-10-20 (diego): Se crea la clase.
|
||||
*/
|
||||
|
||||
include_once("Empleado.php");
|
||||
include_once("ParteActividad.php");
|
||||
include_once("./functions_sistema.php");
|
||||
include_once("Calendario.php");
|
||||
|
||||
class Vacaciones{
|
||||
|
||||
/* Lista de vacaciones */
|
||||
private $vacaciones;
|
||||
|
||||
/* Lista de vacaciones solicitadas */
|
||||
private $vacacionesSolicitadas = null;
|
||||
|
||||
/* Lista de vacaciones aprobadas*/
|
||||
private $vacacionesAprobadas = null;
|
||||
|
||||
/* Lista de vacaciones rechazadas*/
|
||||
private $vacacionesRechazadas = null;
|
||||
|
||||
/* Lista de vacaciones pendientes de anulaci<63>n */
|
||||
private $vacacionesAnulables = null;
|
||||
|
||||
/* Usuario de la sesi<73>n activa */
|
||||
private $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* A<>o del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Identificador del solicitante de vacaciones*/
|
||||
private $oid;
|
||||
|
||||
/* Empleado solicitante de vacaciones */
|
||||
private $empleado;
|
||||
|
||||
/* Calendario para calcular d<>as especiales. */
|
||||
private $calendario;
|
||||
|
||||
/** Idioma */
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* Crea un objeto que representa las vacaciones de un usuario.
|
||||
* @param usuario - Usuario con la sesi<EFBFBD>n activa.
|
||||
* @param oid - Identificador del propietario de las vacaciones.
|
||||
* @param mes - Mes del a<EFBFBD>o en que se gestionan las vacaciones.
|
||||
* @param anio - A<EFBFBD>o para el que se gestionan las vacaciones.
|
||||
* @param locale - Idioma en el que mostrar los mensajes.
|
||||
*/
|
||||
function Vacaciones($usuario,$oid,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->oid = $oid;
|
||||
$this->locale = $locale;
|
||||
$this->calendario = new Calendario($this->usuario, $this->mes, $this->anio, array(), "", $this->locale);
|
||||
if($oid > 0){
|
||||
$this->empleado = new Empleado($usuario, $oid);
|
||||
}else{
|
||||
$error = $this->locale['1534'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n en un determinado estado.
|
||||
*
|
||||
* @param estado - Estado en el que se busca que est<EFBFBD>n las vacaciones.
|
||||
* @return Una lista con las vacaciones en ese estado.
|
||||
* @throws Lanza excepciones si el usuario no tiene vacaciones.
|
||||
*/
|
||||
private function cargaVacaciones(){
|
||||
if($this->vacaciones == null){
|
||||
$this->vacacionesSolicitadas = array();
|
||||
$this->vacacionesAprobadas = array();
|
||||
$this->vacacionesRechazadas = array();
|
||||
$this->vacacionesAnulables = array();
|
||||
//Comprobamos vacaciones:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
//Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3031'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
//Vacaciones correctos, sigo.
|
||||
}else{
|
||||
//Cargo la lista de d<>as:
|
||||
$fecha = $this->anio."-".$this->mes."-";
|
||||
$consulta = "SELECT fecha, aprobada FROM vacaciones WHERE oid='".$this->oid."' AND fecha like '".$fecha."%'";
|
||||
$bd = new BD();
|
||||
$array = $bd->keyValueQuery($consulta, "fecha", "aprobada");
|
||||
$this->vacaciones = array();
|
||||
foreach($array as $fecha => $estado){
|
||||
$dia = explode("-", $fecha);
|
||||
$dia = $dia[2]+0;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// $dias=array();
|
||||
//
|
||||
// //Comprobamos vacaciones:
|
||||
// $oidP = $this->usuario->getValor("oid");
|
||||
//
|
||||
// //Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
// if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
// $error = $this->locale['3031'];
|
||||
// throw new Exception($error);
|
||||
// return $dias;
|
||||
// exit;
|
||||
// }else{
|
||||
// //Busco los d<>as solicitados:
|
||||
// $fecha = $this->anio."-".$this->mes."-";
|
||||
// $consulta = "SELECT fecha FROM vacaciones WHERE oid='".$this->oid."' AND aprobada = '".$estado."' AND fecha like '".$fecha."%'";
|
||||
// $bd = new BD();
|
||||
// $array = $bd->arrayQuery($consulta, "fecha");
|
||||
// foreach($array as $elem){
|
||||
// $dia = explode("-", $elem);
|
||||
// $dias[] = $dia[2]+0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $dias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n solicitadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene vacaciones.
|
||||
*/
|
||||
function getVacSoli(){
|
||||
if($this->vacacionesSolicitadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesSolicitadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n aprobadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene vacaciones.
|
||||
*/
|
||||
function getVacApro(){
|
||||
if($this->vacacionesAprobadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesAprobadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n rechazadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones rechazadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene vacaciones.
|
||||
*/
|
||||
function getVacRech(){
|
||||
if($this->vacacionesRechazadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesRechazadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n pendientes de anulaci<EFBFBD>n.
|
||||
*
|
||||
* @return Una lista con las vacaciones pendientes de anulaci<EFBFBD>n.
|
||||
* @throws Lanza excepciones si el usuario no tiene vacaciones.
|
||||
*/
|
||||
function getVacPend(){
|
||||
if($this->vacacionesAnulables == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesAnulables;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Calcula el n<>mero de d<>as de vacaciones restantes de un empleado.
|
||||
// *
|
||||
// * @return los d<>as restantes de vacaciones dentro del año.
|
||||
// */
|
||||
// public function getVacacionesRestantes(){
|
||||
// //TODO deber<65>a lanzar excepci<63>n por permisos de consulta.
|
||||
// $anio_hoy = date("Y");
|
||||
// $consulta = "SELECT dias FROM vacaciones_oid WHERE oid='".$this->empleado->getValor("oid")."' AND anyo='".$this->anio."'";
|
||||
// $bd = new BD();
|
||||
// $dias = $bd->getCampo($consulta);
|
||||
// //Primero comprobamos si est<73> en la tabla guardado:
|
||||
// if(($dias >= 0) && ($dias != "")){
|
||||
// return $dias;
|
||||
// //Para el a<>o presente se calcula seg<65>n su fecha de alta.
|
||||
// }else if($this->anio == $anio_hoy){
|
||||
// $fecha = $this->empleado->getValor("fecha_alta");
|
||||
// $fecha_array = explode("-", $fecha);
|
||||
// $anyo = $fecha_array[0];
|
||||
// $mes = $fecha_array[1];
|
||||
// $dia = $fecha_array[2];
|
||||
// $fecha = mktime(0,0,0,$mes,$dia,$anyo);
|
||||
// $dias_mes = date('t',$fecha);
|
||||
// $fiestas = constante("fiestas");
|
||||
// //Si se dio de alta un a<>o anterior al actual tiene todos sus d<>as.
|
||||
// if($anyo < date('Y')){
|
||||
// //Se deja fiestas tal y como est<73>.
|
||||
// //Si no, se calculan seg<65>n la f<>rmula.
|
||||
// }else{
|
||||
// $fiestas = (($fiestas/12)*(12-$mes))+(($fiestas/12/$dias_mes)*($dias_mes-$dia));
|
||||
// $fiestas=round($fiestas,0);
|
||||
// }
|
||||
// //Para a<>os posteriores tiene todos los d<>as.
|
||||
// }else if($this->anio > $anio_hoy){
|
||||
// $fiestas = constante("fiestas");
|
||||
// //Y para a<>os anteriores, devolvemos cero.
|
||||
// }else{
|
||||
// $fiestas = 0;
|
||||
// }
|
||||
//
|
||||
// //Actualizamos la tabla para ahorrar c<>lculos posteriores:
|
||||
// $consulta = "INSERT INTO vacaciones_oid (oid, anyo, dias) VALUES ('".$this->oid."', '".$this->anio."', '".$fiestas."')";
|
||||
// $bd = new BD();
|
||||
// $bd->execQuery($consulta);
|
||||
//
|
||||
// return $fiestas;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Acceso al mes.
|
||||
* @return El mes.
|
||||
*/
|
||||
function getMes(){
|
||||
return $this->mes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al a<EFBFBD>o.
|
||||
* @return El a<EFBFBD>o.
|
||||
*/
|
||||
function getAnio(){
|
||||
return $this->anio;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asigna el valor de las vacaciones restantes del empleado.
|
||||
*
|
||||
* @param dias - N<EFBFBD>mero de d<EFBFBD>as de vacaciones restantes a asociar.
|
||||
* @return True si se asign<EFBFBD> correctamente y false en caso contrario.
|
||||
* @throws Lanza excepci<EFBFBD>n si el usuario no tiene permiso.
|
||||
*/
|
||||
public function setVacacionesRestantes($dias){
|
||||
//Comprobamos permisos.
|
||||
if($this->usuario->tieneRol(4) || $this->usuario->tieneRol(1)){
|
||||
$consulta = "UPDATE vacaciones_oid SET dias='$dias' WHERE oid='".$this->oid."' AND anyo='".$this->anio."'";
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
$error = $this->locale['3001'];
|
||||
throw new Exception($error);
|
||||
return $dias;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula el estado en el que se encuentra un d<EFBFBD>a.
|
||||
*
|
||||
* @param dia - D<EFBFBD>a dentro del mes y a<EFBFBD>o de las vacaciones.
|
||||
* @return El c<EFBFBD>digo de estado si se encuentra el d<EFBFBD>a, -1 en caso contrario.
|
||||
*/
|
||||
public function getEstadoDia($dia){
|
||||
$this->cargaVacaciones();
|
||||
$estado = $this->vacaciones[$dia];
|
||||
|
||||
if($estado == "" || $estado < 0){
|
||||
$estado = -1;
|
||||
}
|
||||
|
||||
return $estado;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function insertarDias($dias, $estado){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//En el caso de solicitud de vacaciones o solicitud de anulaci<63>n de vacaciones es t<>cnico.
|
||||
if($estado == 0 || $estado == 3){
|
||||
$observacion = "observacion_tecnico";
|
||||
$observacion2 = "observacion_rrhh";
|
||||
$mensaje2 = $this->getObservacionRRHH($dia);
|
||||
//En caso de aprobaci<63>n o rechace de vacaciones es RRHH
|
||||
}else if($estado == 1 || $estado == 2){
|
||||
$observacion = "observacion_rrhh";
|
||||
$observacion2 = "observacion_tecnico";
|
||||
$mensaje2 = $this->getObservacionTecnico($dia);
|
||||
}
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM vacaciones WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO vacaciones (oid, fecha, aprobada, f_mod, ".$observacion.", ".$observacion2.") VALUES ('".$oid."', '".$fecha."', '".$estado."',curdate(), '".$mensaje."', '".$mensaje2."')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
$this->cambiaEstado($dia, $estado);
|
||||
$consulta = "";
|
||||
/* Efectos de los cambios de estado:
|
||||
* Solicitada: sin efectos.
|
||||
* Aprobada: restar d<EFBFBD>a de vacaciones y actualizar parte.
|
||||
* Rechazada: sin efectos.
|
||||
* Pendiente de anulaci<EFBFBD>n: sin efectos.
|
||||
*/
|
||||
switch ($estado) {
|
||||
case 1:
|
||||
//Se quita un d<>a de vacaciones, salvo en el caso de
|
||||
//que estemos rechazando una solicitud de anulaci<63>n.
|
||||
|
||||
// Si el d<>a es 24 de diciembre o 31 de Diciembre, se resta s<>lo 0,5
|
||||
if($estadoPrevio != 3){
|
||||
if(($dia=="24") || ($dia=="31") && $this->mes=="12"){
|
||||
$this->empleado->variaVacaciones(-0.5);
|
||||
}else {
|
||||
$this->empleado->variaVacaciones(-1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function eliminaDia($dia){
|
||||
$this->vacaciones = array_diff($this->vacaciones, array($dia));
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function cambiaEstado($dia, $estado){
|
||||
$this->cargaVacaciones();
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
if($estadoPrevio == "") $estadoPrevio = -1;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
//Actuamos s<>lo si hay cambio de estado.
|
||||
if($estadoPrevio != $estado){
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
//Y lo insertamos en la correspondiente:
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getObservacionTecnico($dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "SELECT observacion_tecnico FROM vacaciones WHERE fecha = '".$fecha."' AND oid = ".$this->oid."";
|
||||
$bd = new BD();
|
||||
return $bd->getCampo($consulta);
|
||||
}
|
||||
|
||||
public function getObservacionRRHH($dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "SELECT observacion_rrhh FROM vacaciones WHERE fecha = '".$fecha."' AND oid = ".$this->oid."";
|
||||
$bd = new BD();
|
||||
return $bd->getCampo($consulta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicita unos d<EFBFBD>as de vacaciones. Si alguno falla no se solicita ninguno.
|
||||
* @return true si se pudieron solicitar todos y false si falla alguno.
|
||||
*/
|
||||
public function solicitar($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if((($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid))
|
||||
|| $this->usuario->tieneRol(4)){
|
||||
|
||||
foreach($dias as $dia => $mensaje){
|
||||
if(($this->esSolicitable($dia))){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
$solicitud = $dia.",";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 0)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['616']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."/".$this->mes."/".$this->anio."\n\n";
|
||||
$email .= "\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['611'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3004'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3004'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede solicitar un d<EFBFBD>a como vacaciones.
|
||||
* Si el usuario tiene rol RRHH sí que puede solicitar
|
||||
*
|
||||
*/
|
||||
public function esSolicitable($dia){
|
||||
if($this->usuario->tieneRol("4")){
|
||||
return true;
|
||||
}
|
||||
$plazo = constante("antelacion_vacaciones");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
$mes_hoy=date("m");
|
||||
$ano_hoy=date("Y");
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si no est<73>n ya solicitadas ni el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
|
||||
if(($estado == -1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-01") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Aprobaci<EFBFBD>n de una solicitud de vacaciones.
|
||||
*/
|
||||
public function aprobar($dia){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la aprobaci<63>n e insertamos
|
||||
//una P en el parte de actividad.
|
||||
// Calculamos el número que va a restar
|
||||
$diasResta=1;
|
||||
if(($dia=="24") || ($dia=="31") && $this->mes=="12"){
|
||||
$diasResta=0.5;
|
||||
}
|
||||
|
||||
// Comprobamos que tenga vacaciones suficientes
|
||||
if($this->empleado->diasTotalesVacaciones()<$diasResta){
|
||||
$error = $this->locale['3004'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$array=array();
|
||||
$array[$dia]="";
|
||||
if($this->insertarDias($array, 1)){
|
||||
$bd = new BD();
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$this->oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$this->oid."', '".$fecha."', 'P')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
}
|
||||
$nombre = $this->empleado->getValor("nombre");
|
||||
$apellidos = $this->empleado->getValor("apellidos");
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
$email = $this->locale['613']." ".$dia.$this->locale['614'];
|
||||
//$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['622'], $email)){
|
||||
//TODO Excepcion?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3011'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de vacaciones.
|
||||
*/
|
||||
function rechazar($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo rechazar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 2)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$email = $this->locale['613']." ".$muestra_dias.$this->locale['615'];
|
||||
//$direccion = constante("email_rrhh");
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['622'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$email = $this->locale['613']." ".$muestra_dias.$this->locale['615'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3012'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3017'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de anulaci<EFBFBD>n de vacaciones.
|
||||
*/
|
||||
function rechazarAnulacion($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo rechazar vacaciones pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 1)){
|
||||
//TODO <20>Necesario?
|
||||
}else{
|
||||
$error = $this->locale['3029'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3029'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3017'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Anulaci<EFBFBD>n de unas vacaciones aprobados.
|
||||
*/
|
||||
function anular($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo anular las pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$solicitud = $dia.",";
|
||||
$dias_correctos[] = $dia;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son aprobables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las anuladas.
|
||||
if($this->anularDias($dias_correctos)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['600']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."\n\n";
|
||||
$path = "http://portal.selforsistemas.net";
|
||||
$link = "<a href='".$path."/detalle_empleado.php?oid=".$oid."'>".$nombre."</a>";
|
||||
$email = $email.$link."\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['619'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
|
||||
// Se suma 1 d<>a a las vacaciones
|
||||
// Si es 24 o 31 de diciembre se suma 1;
|
||||
if(($dia=="24") || ($dia=="31") && $this->mes=="12"){
|
||||
$this->empleado->variaVacaciones(0.5);
|
||||
}else{
|
||||
$this->empleado->variaVacaciones(1);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$error = $this->locale['3013'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos anulables.
|
||||
}else{
|
||||
$error = $this->locale['3013'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3018'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function eliminarSolicitud($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
//S<>lo puedo eliminar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[] = $dia;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->anularDias($dias_correctos)){
|
||||
return true;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3012'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function anularDias($dias){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM vacaciones WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$this->eliminaDia($dia);
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
// $consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$oid."', '".$fecha."', '0')";
|
||||
// if(!$bd->execQuery($consulta)){
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicitud de anulaci<EFBFBD>n de unas vacaciones aprobadas.
|
||||
*/
|
||||
function solicitarAnulacion($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if(($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid)){
|
||||
foreach($dias as $dia => $mensaje){
|
||||
if($this->esAnulable($dia)){
|
||||
$dias_correctos[$dia] = $mensaje;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 3)){
|
||||
//TODO
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3016'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3016'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function setEmpleado($empleado, $oid){
|
||||
$this->empleado = $empleado;
|
||||
$this->oid = $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede anular un d<EFBFBD>a de vacaciones.
|
||||
*
|
||||
*/
|
||||
public function esAnulable($dia){
|
||||
$plazo = constante("antelacion_vacaciones");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si est<73>n aprobadas y el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
if(($estado == 1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['3019'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
$error = $this->locale['3015'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
$error = $this->locale['3019'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getOidPersona(){
|
||||
return $this->empleado->getValor("oid");
|
||||
}
|
||||
|
||||
function getNombrePersona(){
|
||||
return $this->empleado->getValor("nombre")." ".$this->empleado->getValor("apellidos");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
923
src/Objects/Vacaciones_old.php
Normal file
@ -0,0 +1,923 @@
|
||||
<?php
|
||||
/*
|
||||
* Created on 20/10/2008
|
||||
*
|
||||
* Representa la vacaciones de un empleado y comprende toda su gesti<EFBFBD>n.
|
||||
*
|
||||
* 2008-10-20 (diego): Se crea la clase.
|
||||
*/
|
||||
|
||||
include_once("Empleado.php");
|
||||
include_once("ParteActividad.php");
|
||||
include_once("./functions_sistema.php");
|
||||
include_once("Calendario.php");
|
||||
|
||||
class Vacaciones{
|
||||
|
||||
/* Lista de vacaciones */
|
||||
private $vacaciones;
|
||||
|
||||
/* Lista de vacaciones solicitadas */
|
||||
private $vacacionesSolicitadas = null;
|
||||
|
||||
/* Lista de vacaciones aprobadas*/
|
||||
private $vacacionesAprobadas = null;
|
||||
|
||||
/* Lista de vacaciones rechazadas*/
|
||||
private $vacacionesRechazadas = null;
|
||||
|
||||
/* Lista de vacaciones pendientes de anulaci<63>n */
|
||||
private $vacacionesAnulables = null;
|
||||
|
||||
/* Usuario de la sesi<73>n activa */
|
||||
private $usuario;
|
||||
|
||||
/* Mes del calendario a considerar. */
|
||||
private $mes;
|
||||
|
||||
/* A<>o del calendario a considerar. */
|
||||
private $anio;
|
||||
|
||||
/* Identificador del solicitante de vacaciones*/
|
||||
private $oid;
|
||||
|
||||
/* Empleado solicitante de vacaciones */
|
||||
private $empleado;
|
||||
|
||||
/* Calendario para calcular d<>as especiales. */
|
||||
private $calendario;
|
||||
|
||||
/** Idioma */
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* Crea un objeto que representa las vacaciones de un usuario.
|
||||
* @param usuario - Usuario con la sesi<EFBFBD>n activa.
|
||||
* @param oid - Identificador del propietario de las vacaciones.
|
||||
* @param mes - Mes del a<EFBFBD>o en que se gestionan las vacaciones.
|
||||
* @param anio - A<EFBFBD>o para el que se gestionan las vacaciones.
|
||||
* @param locale - Idioma en el que mostrar los mensajes.
|
||||
*/
|
||||
function Vacaciones($usuario,$oid,$mes,$anio, $locale){
|
||||
$this->usuario=$usuario;
|
||||
if($mes < 10){
|
||||
//Me aseguro de que no tenga cero delante
|
||||
$mes = $mes + 0;
|
||||
//Y le pongo el cero delante.
|
||||
$mes = "0".$mes;
|
||||
}
|
||||
$this->mes=$mes;
|
||||
$this->anio=$anio;
|
||||
$this->oid = $oid;
|
||||
$this->locale = $locale;
|
||||
$this->calendario = new Calendario($this->usuario, $this->mes, $this->anio, array(), "", $this->locale);
|
||||
if($oid > 0){
|
||||
$this->empleado = new Empleado($usuario, $oid);
|
||||
}else{
|
||||
$error = $this->locale['1534'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n en un determinado estado.
|
||||
*
|
||||
* @param estado - Estado en el que se busca que est<EFBFBD>n las vacaciones.
|
||||
* @return Una lista con las vacaciones en ese estado.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
private function cargaVacaciones(){
|
||||
if($this->vacaciones == null){
|
||||
$this->vacacionesSolicitadas = array();
|
||||
$this->vacacionesAprobadas = array();
|
||||
$this->vacacionesRechazadas = array();
|
||||
$this->vacacionesAnulables = array();
|
||||
//Comprobamos permisos:
|
||||
$oidP = $this->usuario->getValor("oid");
|
||||
//Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
$error = $this->locale['3001'];
|
||||
throw new Exception($error);
|
||||
return array();
|
||||
exit;
|
||||
//Permisos correctos, sigo.
|
||||
}else{
|
||||
//Cargo la lista de d<>as:
|
||||
$fecha = $this->anio."-".$this->mes."-";
|
||||
$consulta = "SELECT fecha, aprobada FROM vacaciones WHERE oid='".$this->oid."' AND fecha like '".$fecha."%'";
|
||||
$bd = new BD();
|
||||
$array = $bd->keyValueQuery($consulta, "fecha", "aprobada");
|
||||
$this->vacaciones = array();
|
||||
foreach($array as $fecha => $estado){
|
||||
$dia = explode("-", $fecha);
|
||||
$dia = $dia[2]+0;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// $dias=array();
|
||||
//
|
||||
// //Comprobamos permisos:
|
||||
// $oidP = $this->usuario->getValor("oid");
|
||||
//
|
||||
// //Si no soy yo y no soy admin ni RRHH, no tengo permiso:
|
||||
// if(($oidP != $this->oid) && (!$this->usuario->tieneRol(1)) && (!$this->usuario->tieneRol(4))){
|
||||
// $error = $this->locale['3001'];
|
||||
// throw new Exception($error);
|
||||
// return $dias;
|
||||
// exit;
|
||||
// }else{
|
||||
// //Busco los d<>as solicitados:
|
||||
// $fecha = $this->anio."-".$this->mes."-";
|
||||
// $consulta = "SELECT fecha FROM vacaciones WHERE oid='".$this->oid."' AND aprobada = '".$estado."' AND fecha like '".$fecha."%'";
|
||||
// $bd = new BD();
|
||||
// $array = $bd->arrayQuery($consulta, "fecha");
|
||||
// foreach($array as $elem){
|
||||
// $dia = explode("-", $elem);
|
||||
// $dias[] = $dia[2]+0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $dias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n solicitadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getVacSoli(){
|
||||
if($this->vacacionesSolicitadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesSolicitadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n aprobadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones aprobadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getVacApro(){
|
||||
if($this->vacacionesAprobadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesAprobadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n rechazadas.
|
||||
*
|
||||
* @return Una lista con las vacaciones rechazadas.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getVacRech(){
|
||||
if($this->vacacionesRechazadas == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesRechazadas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una lista de todas las vacaciones del usuario en el mes y a<EFBFBD>o que
|
||||
* est<EFBFBD>n pendientes de anulaci<EFBFBD>n.
|
||||
*
|
||||
* @return Una lista con las vacaciones pendientes de anulaci<EFBFBD>n.
|
||||
* @throws Lanza excepciones si el usuario no tiene permisos.
|
||||
*/
|
||||
function getVacPend(){
|
||||
if($this->vacacionesAnulables == null){
|
||||
$this->cargaVacaciones();
|
||||
}
|
||||
|
||||
return $this->vacacionesAnulables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula el n<EFBFBD>mero de d<EFBFBD>as de vacaciones restantes de un empleado.
|
||||
*
|
||||
* @return los d<EFBFBD>as restantes de vacaciones dentro del a<EFBFBD>o.
|
||||
*/
|
||||
public function getVacacionesRestantes(){
|
||||
//TODO deber<65>a lanzar excepci<63>n por permisos de consulta.
|
||||
$anio_hoy = date("Y");
|
||||
$consulta = "SELECT dias FROM vacaciones_oid WHERE oid='".$this->empleado->getValor("oid")."' AND anyo='".$this->anio."'";
|
||||
$bd = new BD();
|
||||
$dias = $bd->getCampo($consulta);
|
||||
//Primero comprobamos si est<73> en la tabla guardado:
|
||||
if(($dias >= 0) && ($dias != "")){
|
||||
return $dias;
|
||||
//Para el a<>o presente se calcula seg<65>n su fecha de alta.
|
||||
}else if($this->anio == $anio_hoy){
|
||||
$fecha = $this->empleado->getValor("fecha_alta");
|
||||
$fecha_array = explode("-", $fecha);
|
||||
$anyo = $fecha_array[0];
|
||||
$mes = $fecha_array[1];
|
||||
$dia = $fecha_array[2];
|
||||
$fecha = mktime(0,0,0,$mes,$dia,$anyo);
|
||||
$dias_mes = date('t',$fecha);
|
||||
$fiestas = constante("fiestas");
|
||||
//Si se dio de alta un a<>o anterior al actual tiene todos sus d<>as.
|
||||
if($anyo < date('Y')){
|
||||
//Se deja fiestas tal y como est<73>.
|
||||
//Si no, se calculan seg<65>n la f<>rmula.
|
||||
}else{
|
||||
$fiestas = (($fiestas/12)*(12-$mes))+(($fiestas/12/$dias_mes)*($dias_mes-$dia));
|
||||
round($fiestas);
|
||||
}
|
||||
//Para a<>os posteriores tiene todos los d<>as.
|
||||
}else if($this->anio > $anio_hoy){
|
||||
$fiestas = constante("fiestas");
|
||||
//Y para a<>os anteriores, devolvemos cero.
|
||||
}else{
|
||||
$fiestas = 0;
|
||||
}
|
||||
|
||||
//Actualizamos la tabla para ahorrar c<>lculos posteriores:
|
||||
$consulta = "INSERT INTO vacaciones_oid (oid, anyo, dias) VALUES ('".$this->oid."', '".$this->anio."', '".$fiestas."')";
|
||||
$bd = new BD();
|
||||
$bd->execQuery($consulta);
|
||||
|
||||
return round($fiestas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al mes.
|
||||
* @return El mes.
|
||||
*/
|
||||
function getMes(){
|
||||
return $this->mes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceso al a<EFBFBD>o.
|
||||
* @return El a<EFBFBD>o.
|
||||
*/
|
||||
function getAnio(){
|
||||
return $this->anio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna el valor de las vacaciones restantes del empleado.
|
||||
*
|
||||
* @param dias - N<EFBFBD>mero de d<EFBFBD>as de vacaciones restantes a asociar.
|
||||
* @return True si se asign<EFBFBD> correctamente y false en caso contrario.
|
||||
* @throws Lanza excepci<EFBFBD>n si el usuario no tiene permiso.
|
||||
*/
|
||||
public function setVacacionesRestantes($dias){
|
||||
//Comprobamos permisos.
|
||||
if($this->usuario->tieneRol(4) || $this->usuario->tieneRol(1)){
|
||||
$consulta = "UPDATE vacaciones_oid SET dias='$dias' WHERE oid='".$this->oid."' AND anyo='".$this->anio."'";
|
||||
$bd = new BD();
|
||||
return $bd->execQuery($consulta);
|
||||
}else{
|
||||
$error = $this->locale['3001'];
|
||||
throw new Exception($error);
|
||||
return $dias;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula el estado en el que se encuentra un d<EFBFBD>a.
|
||||
*
|
||||
* @param dia - D<EFBFBD>a dentro del mes y a<EFBFBD>o de las vacaciones.
|
||||
* @return El c<EFBFBD>digo de estado si se encuentra el d<EFBFBD>a, -1 en caso contrario.
|
||||
*/
|
||||
public function getEstadoDia($dia){
|
||||
$this->cargaVacaciones();
|
||||
$estado = $this->vacaciones[$dia];
|
||||
|
||||
if($estado == "" || $estado < 0){
|
||||
$estado = -1;
|
||||
}
|
||||
|
||||
return $estado;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function insertarDias($dias, $estado){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM vacaciones WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO vacaciones (oid, fecha, aprobada) VALUES ('".$oid."', '".$fecha."', '".$estado."')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
$this->cambiaEstado($dia, $estado);
|
||||
$consulta = "";
|
||||
/* Efectos de los cambios de estado:
|
||||
* Solicitada: sin efectos.
|
||||
* Aprobada: restar d<EFBFBD>a de vacaciones y actualizar parte.
|
||||
* Rechazada: sin efectos.
|
||||
* Pendiente de anulaci<EFBFBD>n: sin efectos.
|
||||
*/
|
||||
switch ($estado) {
|
||||
case 1:
|
||||
//Se quita un d<>a de vacaciones, salvo en el caso de
|
||||
//que estemos rechazando una solicitud de anulaci<63>n.
|
||||
if($estadoPrevio != 3){
|
||||
$this->addVacacionesRestantes(-1);
|
||||
}
|
||||
// $fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
// $consulta = "DELETE FROM partes_actividad WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
// $bd->execQuery($consulta);
|
||||
// $consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$oid."', '".$fecha."', 'V')";
|
||||
// if(!$bd->execQuery($consulta)){
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function eliminaDia($dia){
|
||||
$this->vacaciones = array_diff($this->vacaciones, array($dia));
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function cambiaEstado($dia, $estado){
|
||||
$this->cargaVacaciones();
|
||||
$estadoPrevio = $this->vacaciones[$dia];
|
||||
if($estadoPrevio == "") $estadoPrevio = -1;
|
||||
$this->vacaciones[$dia] = $estado;
|
||||
//Actuamos s<>lo si hay cambio de estado.
|
||||
if($estadoPrevio != $estado){
|
||||
//Lo eliminamos de la lista donde estuviera:
|
||||
switch($estadoPrevio){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas = array_diff($this->vacacionesSolicitadas, array($dia));
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas = array_diff($this->vacacionesAprobadas, array($dia));
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas = array_diff($this->vacacionesRechazadas, array($dia));
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables = array_diff($this->vacacionesAnulables, array($dia));
|
||||
break;
|
||||
}
|
||||
//Y lo insertamos en la correspondiente:
|
||||
switch($estado){
|
||||
case 0:
|
||||
$this->vacacionesSolicitadas[] = $dia;
|
||||
break;
|
||||
case 1:
|
||||
$this->vacacionesAprobadas[] = $dia;
|
||||
break;
|
||||
case 2:
|
||||
$this->vacacionesRechazadas[] = $dia;
|
||||
break;
|
||||
case 3:
|
||||
$this->vacacionesAnulables[] = $dia;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function addVacacionesRestantes($num){
|
||||
if($num < 0){
|
||||
$num = -1*$num;
|
||||
$consulta = "UPDATE vacaciones_oid SET dias=dias-".$num." WHERE oid='".$this->oid."' AND anyo='".$this->anio."'";
|
||||
}else{
|
||||
$consulta = "UPDATE vacaciones_oid SET dias=dias+".$num." WHERE oid='".$this->oid."' AND anyo='".$this->anio."'";
|
||||
}
|
||||
$bd = new BD();
|
||||
$bd->execQuery($consulta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicita unos d<EFBFBD>as de vacaciones. Si alguno falla no se solicita ninguno.
|
||||
* @return true si se pudieron solicitar todos y false si falla alguno.
|
||||
*/
|
||||
public function solicitar($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if(($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid)){
|
||||
//Si le quedan d<>as restantes seguimos:
|
||||
if($this->getVacacionesRestantes() >= count($dias)){
|
||||
foreach($dias as $dia){
|
||||
if($this->esSolicitable($dia)){
|
||||
$dias_correctos[] = $dia;
|
||||
$solicitud = $dia.",";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 0)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['609']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."\n\n";
|
||||
$email = $email."\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['611'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3004'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3004'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3003'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede solicitar un d<EFBFBD>a como vacaciones.
|
||||
*
|
||||
*/
|
||||
public function esSolicitable($dia){
|
||||
$plazo = constante("antelacion_vacaciones");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si no est<73>n ya solicitadas ni el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
|
||||
if(($estado == -1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['3005'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
$error = $this->locale['3006'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
$error = $this->locale['3005'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aprobaci<EFBFBD>n de una solicitud de vacaciones.
|
||||
*/
|
||||
public function aprobar($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
$muestra_dias = "";
|
||||
foreach($dias as $dia){
|
||||
//S<>lo puedo aprobar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[] = $dia;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son aprobables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la aprobaci<63>n.
|
||||
if($this->insertarDias($dias_correctos, 1)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$email = $this->locale['613']." ".$muestra_dias.$this->locale['614'];
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['605'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3011'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos aprobables.
|
||||
}else{
|
||||
$error = $this->locale['3011'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3010'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de vacaciones.
|
||||
*/
|
||||
function rechazar($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia){
|
||||
//S<>lo puedo rechazar vacaciones solicitadas.
|
||||
if($this->getEstadoDia($dia) == 0){
|
||||
$dias_correctos[] = $dia;
|
||||
$muestra_dias .= $dia."-".$this->mes."-".$this->anio." ";
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 2)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$email = $this->locale['613']." ".$muestra_dias.$this->locale['615'];
|
||||
$direccion = $this->empleado->getValor("email");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['605'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3012'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3012'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3017'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rechace de una solicitud de anulaci<EFBFBD>n de vacaciones.
|
||||
*/
|
||||
function rechazarAnulacion($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia){
|
||||
//S<>lo puedo rechazar vacaciones pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$dias_correctos[] = $dia;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son rechazables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las rechazadas.
|
||||
if($this->insertarDias($dias_correctos, 1)){
|
||||
//TODO <20>Necesario?
|
||||
}else{
|
||||
$error = $this->locale['3029'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos rechazables.
|
||||
}else{
|
||||
$error = $this->locale['3029'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3017'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Anulaci<EFBFBD>n de unas vacaciones aprobadas.
|
||||
*/
|
||||
function anular($dias){
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if($this->usuario->tieneRol(1) || $this->usuario->tieneRol(4)){
|
||||
foreach($dias as $dia){
|
||||
//S<>lo puedo anular las pendientes de anulaci<63>n.
|
||||
if($this->getEstadoDia($dia) == 3){
|
||||
$solicitud = $dia.",";
|
||||
$dias_correctos[] = $dia;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son aprobables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con las anuladas.
|
||||
if($this->anularDias($dias_correctos)){
|
||||
$nombre = $this->usuario->getValor("nombre");
|
||||
$apellidos = $this->usuario->getValor("apellidos");
|
||||
$oid = $this->usuario->getValor("oid");
|
||||
$email = $this->locale['600']." $nombre $apellidos.\n\n";
|
||||
$email .= $solicitud."\n\n";
|
||||
$path = "http://portal.selforsistemas.net";
|
||||
$link = "<a href='".$path."/detalle_empleado.php?oid=".$oid."'>".$nombre."</a>";
|
||||
$email = $email.$link."\n\n";
|
||||
$direccion = constante("email_rrhh");
|
||||
if(!envia_correo_empleados($direccion, $this->locale['603'], $email)){
|
||||
//TODO <20>Excepci<63>n?
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3013'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no son todos anulables.
|
||||
}else{
|
||||
$error = $this->locale['3013'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3018'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function anularDias($dias){
|
||||
$oid = $this->oid;
|
||||
$bd = new BD();
|
||||
foreach($dias as $dia){
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM vacaciones WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
//Si todo ha ido bien comprobamos el estado a ver si hay que actualizar
|
||||
//las vacaciones restantes.
|
||||
}else{
|
||||
$this->eliminaDia($dia);
|
||||
$solicitante->variaVacaciones(1);
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$consulta = "DELETE FROM partes_actividad WHERE oid = '".$oid."' AND fecha='".$fecha."'";
|
||||
$bd->execQuery($consulta);
|
||||
$consulta = "INSERT INTO partes_actividad (oid, fecha, dato) VALUES ('".$oid."', '".$fecha."', '0')";
|
||||
if(!$bd->execQuery($consulta)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solicitud de anulaci<EFBFBD>n de unas vacaciones aprobadas.
|
||||
*/
|
||||
function solicitarAnulacion($dias){
|
||||
if(count($dias) <= 0){
|
||||
$error = $this->locale['3027'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
$dias_correctos = array();
|
||||
$dias_fallidos = array();
|
||||
//Comprobamos que estamos recibiendo el argumento bien formado.
|
||||
if(gettype($dias) == "array"){
|
||||
//Si tiene rol t<>cnico seguimos.
|
||||
if(($this->usuario->tieneRol(6)) && ($this->usuario->getValor("oid") == $this->oid)){
|
||||
foreach($dias as $dia){
|
||||
if($this->esAnulable($dia)){
|
||||
$dias_correctos[] = $dia;
|
||||
}else{
|
||||
$dias_incorrectos[] = $dia;
|
||||
}
|
||||
}
|
||||
//Comprobamos que todos son solicitables:
|
||||
if((count($dias_correctos) == count($dias)) && (count($dias_fallidos) == 0)){
|
||||
//Si insertamos todos los d<>as, enviamos el mail con la solicitud.
|
||||
if($this->insertarDias($dias_correctos, 3)){
|
||||
//TODO
|
||||
}
|
||||
}else{
|
||||
$error = $this->locale['3016'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3016'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Si no, lanzamos excepci<63>n.
|
||||
}else{
|
||||
$error = $this->locale['3007'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function setEmpleado($empleado, $oid){
|
||||
$this->empleado = $empleado;
|
||||
$this->oid = $oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si se puede solicitar un d<EFBFBD>a como vacaciones.
|
||||
*
|
||||
*/
|
||||
public function esAnulable($dia){
|
||||
$plazo = constante("antelacion_vacaciones");
|
||||
$fecha = $this->anio."-".$this->mes."-".$dia;
|
||||
$estado = $this->getEstadoDia($dia);
|
||||
$localidad = $this->empleado->getValor("localidad");
|
||||
$oid = $this->oid;
|
||||
//Si el plazo es correcto seguimos:
|
||||
if(fecha_valida($fecha) > $plazo){
|
||||
//Si est<73>n aprobadas y el d<>a es festivo seguimos:
|
||||
$c = $this->calendario;
|
||||
if(($estado == 1) && (!$c->esFestivo($localidad, $dia))){
|
||||
//Si se solicita para este a<>o o para el pr<70>ximo dentro del plazo, todo ok:
|
||||
if(($this->anio == date("Y")) || (($this->anio == date("Y") + 1) && (fecha_valida(date("Y")."-12-15") <= 0))){
|
||||
return true;
|
||||
}else{
|
||||
$error = $this->locale['3019'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//D<>a solicitado o festivo
|
||||
}else{
|
||||
$error = $this->locale['3015'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
//Fecha fuera de plazo.
|
||||
}else{
|
||||
$error = $this->locale['3019'];
|
||||
throw new Exception($error);
|
||||
return false;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getOidPersona(){
|
||||
return $this->empleado->getValor("oid");
|
||||
}
|
||||
|
||||
function getNombrePersona(){
|
||||
return $this->empleado->getValor("nombre")." ".$this->empleado->getValor("apellidos");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
15
src/RPC/RPCPrueba.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
session_start();
|
||||
/*
|
||||
* Created on 07/10/2008
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
|
||||
{
|
||||
"eliminado" : "true",
|
||||
"error":"no tienes los permisos"
|
||||
}
|
||||
*/
|
||||
echo '{"eliminado":"true","error":"no tienes los permisos"}'
|
||||
?>
|
||||
276
src/addCandidato.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
/**
|
||||
* Página que ofrece un formulario para agregar candidatos y contiene la lógica
|
||||
* para agregar un candidato
|
||||
*
|
||||
* Hay que tener cuidado porque todas las variables que se le pasan por post son agregadas.
|
||||
*/
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")
|
||||
&& !$usuario->tieneRol("1")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$errores=array();
|
||||
|
||||
if(stripinput($_POST['action'])=="add"){
|
||||
$errores_persona = "";
|
||||
include_once("campos_persona.php");
|
||||
if(count($provincia_deseada)==0){
|
||||
$errores_persona .= $locale['1708']."<br />";
|
||||
$errores[]="22";
|
||||
}
|
||||
|
||||
if((count($perfil)==1) && ($perfil["0"]=="")){
|
||||
$errores_persona .= $locale['1705']."<br />";
|
||||
$errores[]="23";
|
||||
}
|
||||
include_once("verificar_candidato.php");
|
||||
if(count($errores)==0){
|
||||
$arrayInsert=array();
|
||||
include_once("Objects/ListaCandidatos.php");
|
||||
$listaCandidatos=new ListaCandidatos($usuario,"","","10");
|
||||
$fecha_nacimiento_ini = stripinput($_POST['anyonac'])."-".stripinput($_POST['mesnac'])."-".stripinput($_POST['dianac']);
|
||||
$fecha_entrevista = stripinput($_POST['anyoentre'])."-".stripinput($_POST['mesentre'])."-".stripinput($_POST['diaentre']);
|
||||
$camposQuitar=array();
|
||||
$camposQuitar["dianac"]=stripinput($_POST['dianac']);
|
||||
$camposQuitar["mesnac"]=stripinput($_POST['mesnac']);
|
||||
$camposQuitar["anyonac"]=stripinput($_POST['anyonac']);
|
||||
$camposQuitar["diaalta"]=stripinput($_POST['diaalta']);
|
||||
$camposQuitar["mesalta"]=stripinput($_POST['mesalta']);
|
||||
$camposQuitar["anyoalta"]=stripinput($_POST['anyoalta']);
|
||||
$camposQuitar["MAX_FILE_SIZE"]=stripinput($_POST['MAX_FILE_SIZE']);
|
||||
$camposQuitar["tecnologia"]=stripinput($_POST['tecnologia']);
|
||||
$camposQuitar["idiomas"]=stripinput($_POST['idiomas']);
|
||||
$camposQuitar["titulaciones"]=stripinput($_POST['titulaciones']);
|
||||
$camposQuitar["provincia_deseada"]=stripinput($_POST['provincia_deseada']);
|
||||
$camposQuitar["perfil"]=stripinput($_POST['perfil']);
|
||||
$camposQuitar["action"]=stripinput($_POST['action']);
|
||||
$camposQuitar["diaentre"]=stripinput($_POST['diaentre']);
|
||||
$camposQuitar["mesentre"]=stripinput($_POST['mesentre']);
|
||||
$camposQuitar["anyoentre"]=stripinput($_POST['anyoentre']);
|
||||
|
||||
|
||||
$camposInsertar=array_diff_assoc($_POST,$camposQuitar);
|
||||
$camposInsertar["fecha_nacimiento"]=$fecha_nacimiento_ini;
|
||||
$camposInsertar["procedenciaCV"]=$_POST['procedenciaCV'][0];
|
||||
if($fecha_entrevista!="2008-1-1")
|
||||
$camposInsertar["fecha_entrevista"]=$fecha_entrevista;
|
||||
$vacio=array();
|
||||
$vacio['0']="";
|
||||
$_POST['tecnologia']=array_diff_assoc($_POST['tecnologia'],$vacio);
|
||||
$_POST['idiomas']=array_diff_assoc($_POST['idiomas'],$vacio);
|
||||
$_POST['titulaciones']=array_diff_assoc($_POST['titulaciones'],$vacio);
|
||||
foreach($camposInsertar as $nombre_campo => $valor){
|
||||
if($valor!="")
|
||||
$arrayInsert[$nombre_campo]=$valor;
|
||||
}
|
||||
// Insertamos el nuevo candidato
|
||||
try{
|
||||
$errorInsert=false;
|
||||
$idCandidatoNew=$listaCandidatos->addCandidato($arrayInsert);
|
||||
if($idCandidatoNew!="-1"){
|
||||
include_once("Objects/Candidato.php");
|
||||
$candidatoNew=new Candidato($usuario,$idCandidatoNew);
|
||||
$candidatoNew->addTecnologias($_POST['tecnologia']);
|
||||
$candidatoNew->addIdiomas($_POST['idiomas']);
|
||||
$candidatoNew->addTitulaciones($_POST['titulaciones']);
|
||||
if($_POST['provincia_deseada']==""){
|
||||
$_POST['provincia_deseada']=array();
|
||||
}
|
||||
//$candidatoNew->addLocalidadesDeseadas($_POST['localidad_deseada']);
|
||||
$candidatoNew->addProvinciasDeseadas($_POST['provincia_deseada']);
|
||||
$candidatoNew->addPerfiles($_POST['perfil']);
|
||||
$candidatoNew->addCurriculum($_FILES['userfile']);
|
||||
header("Location: detalle_candidato.php?oid=".$idCandidatoNew);
|
||||
} else {
|
||||
$tipomsg="error";
|
||||
$mensaje="No se ha podido insertar";
|
||||
}
|
||||
} catch (Exception $e){
|
||||
$tipomsg="error";
|
||||
$mensaje=$e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$tipomsg="error";
|
||||
$mensaje=$errores_persona;
|
||||
}
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
$html->menuCandidatos();
|
||||
echo "<h2>".$locale['802']."</h2>";
|
||||
if($mensaje!=""){
|
||||
// Mostramos el mensaje
|
||||
echo "<div class=\"aviso ".$tipomsg."\">".$mensaje."</div>";
|
||||
}
|
||||
|
||||
echo $locale['286'];
|
||||
$tipo="usuario";
|
||||
|
||||
if($errorInsert){
|
||||
|
||||
}
|
||||
|
||||
echo "<form action=\"addCandidato.php\" method=\"POST\" enctype=\"multipart/form-data\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"add\" />";
|
||||
//Datos personales:
|
||||
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
|
||||
echo '<div class="encabezado">'.$locale['1548'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("1",$errores)) echo " class=\"errorcampo\"";
|
||||
echo $en.' width="25%" textalign="right">'.$locale['100'].'<br><input type="text" name="nombre" value="'.$_POST['nombre'].'" size="20" maxlength="50"><br></td>
|
||||
<td ';
|
||||
if(in_array("2",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" textalign="right">'.$locale['101'].'<br><input type="text" name="apellidos" value="'.$_POST['apellidos'].'" size="30" maxlength="150"></td>
|
||||
<td width="25%" textalign="right">'.$locale['116'].'<br>';
|
||||
rellena_fecha_select($fecha_nacimiento, "nac");
|
||||
echo '</td>';
|
||||
echo '<td ';
|
||||
if(in_array("4",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$edni.' textalign="right">'.$locale['1539'].'<br><input type="text" name="dni" value="'.$_POST['dni'].'" size="9" maxlength="9"></td></tr>';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("5",$errores)) echo ' class="errorcampo"';
|
||||
echo ' width="25%">'.$locale['103'].'<input type="text" name="email" value="'.$_POST['email'].'" size="30" maxlength="50"></td>
|
||||
<td ';
|
||||
if(in_array("6",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$etm.' textalign="right" width=20%>'.$locale['107'].'<input type="text" name="t_movil" value="'.$_POST['t_movil'].'" size="9" maxlength="9"></td>
|
||||
<td ';
|
||||
if(in_array("7",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$etc.' textalign="right" width=20%>'.$locale['108'].'<input type="text" name="t_casa" value="'.$_POST['t_casa'].'" size="9" maxlength="9"></td>
|
||||
<td ';
|
||||
|
||||
echo ' width="25%" '.$ett.' textalign="right" width=20%></td>
|
||||
</tr>';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("13",$errores)) echo " class=\"errorcampo\"";
|
||||
echo $em.' textalign="right">'.$locale['114'.$tipo.''].'';
|
||||
rellena_desplegable_localidad($_POST['localidad'], "localidad");
|
||||
echo '</td>
|
||||
<td '.$dir.' textalign="right">'.$locale['128'].'';
|
||||
$auxiliar = '<option value="">-</option>';
|
||||
rellena_desplegable_select("tipo_via","tipo_via",$auxiliar,$_POST['tipo_via']);
|
||||
echo '<br>'.$locale['110'].'<input type="text" name="direccion" value="'.$_POST['direccion'].'" size="20" maxlength="50"></td>
|
||||
<td textalign="right" '.$enum.'>'.$locale['111'].'
|
||||
<input type="text" name="numero" value="'.$_POST['numero'].'" size="5" maxlength="25"><br>
|
||||
'.$locale['112'].'
|
||||
<input type="text" name="piso" value="'.$_POST['piso'].'" size="5" maxlength="25"><br>
|
||||
'.$locale['113'].'
|
||||
<input type="text" name="puerta" value="'.$_POST['puerta'].'" size="5" maxlength="25">
|
||||
</td>
|
||||
<td ';
|
||||
if(in_array("12",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' textalign="right" '.$ecp.'>'.$locale['115'].'
|
||||
<input type="text" name="cp" value="'.$_POST['cp'].'" size="3" maxlength="5">
|
||||
</td>
|
||||
</tr>';
|
||||
echo '<tr>
|
||||
<td colspan="4" align="center">'.$locale['126'].'<br><textarea name="descripcion" rows="4" cols="40" style="overflow: auto;width:100%; height:150px"">'.$_POST['descripcion'].'</textarea></td></tr></table>';
|
||||
|
||||
//Datos laborales:
|
||||
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
|
||||
echo '<div class="encabezado">'.$locale['1550'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<td ';
|
||||
if(in_array("20",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="33%" textalign="right">'.$locale['1800'].'* : ';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
rellena_procedencias("procedencia",$auxiliar,$_POST['procedencia']);
|
||||
echo '</td>';
|
||||
echo '<td>'.$locale['1576']." ";
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
rellena_desplegable_select_oid("incorporaciones","incorporacion","",$_POST['incorporacion']);
|
||||
echo '</td>';
|
||||
echo "<td></td>";
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td width="33%" textalign="right">';
|
||||
if ($_POST['fecha_entrevista']!="0000-00-00"){
|
||||
echo $locale['1095']." : ";
|
||||
echo rellena_fecha_select($_POST['fecha_entrevista'],"entre");
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td width="33%" textalign="right">';
|
||||
echo $locale['1800']." ".$locale['1091'].":";
|
||||
echo $html->listaSelect("procedencia_cv","id","nombre","procedenciaCV",array("","-"),array($_POST['procedenciaCV']),true,false,"1");
|
||||
|
||||
|
||||
echo '</td>';
|
||||
echo '<td textalign="right">'.$locale['129'];
|
||||
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
|
||||
rellena_desplegable_select_oidCol("salario","id","nombre","salario_min",$auxiliar,$_POST['salario_min']);
|
||||
echo "<br />".$locale['130'];
|
||||
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
|
||||
rellena_desplegable_select_oidCol("salario","id","nombre","salario_max",$auxiliar,$_POST['salario_max']);
|
||||
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td ';
|
||||
if(in_array("23",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' textalign="right" '.$eper.'><div style="float:left ">'.$locale['121'].'</div><div style="float:left ">';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("perfil","oid","id","perfil",array("",$locale['ns']),$_POST['perfil'],true,true,"15");
|
||||
echo '</div></td>
|
||||
<td textalign="right"><div style="float:left ">'.$locale['1561'].'</div><div style="float:left ">';
|
||||
|
||||
echo $html->listaSelect("provincias","oid","id","provincia_deseada",array("",$locale['ns']),$_POST['provincia_deseada'],true,true,"15");
|
||||
|
||||
echo '</div></td>';
|
||||
echo "<td></td>";
|
||||
echo '</tr>';
|
||||
echo '<tr>
|
||||
<td colspan="3" align="center">'.$locale['135'].'<br><textarea name="observaciones" rows="7" cols="50" style="overflow: auto;width:100%; height:150px"">'.$_POST['observaciones'].'</textarea></td></tr><tr>';
|
||||
echo '</tr></table>';
|
||||
|
||||
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
|
||||
// CURRICULUM
|
||||
echo '<div class="encabezado">'.$locale['1549'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<tr align="center">
|
||||
<td textalign="right">'.$locale['122'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("tecnologia","oid","id","tecnologia",array("",$locale['ns']),$_POST['tecnologia'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td align="right">'.$locale['123'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("idiomas","oid","id","idiomas",array("",$locale['ns']),$_POST['idiomas'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td align="right">'.$locale['124'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("titulaciones","oid","id","titulaciones",array("",$locale['ns']),$_POST['titulaciones'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
</tr>';
|
||||
echo '<tr><td colspan="6">';
|
||||
menu_curriculums($_GET['oid'], "candidato");
|
||||
echo '</td></tr><tr>';
|
||||
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
|
||||
<td colspan="6" textalign="right">'.$locale['125'].'<br>';
|
||||
echo '<input name="userfile" type="file">';
|
||||
echo '</td></tr></table>';
|
||||
|
||||
echo '</table>';
|
||||
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
|
||||
echo "</form>";
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
264
src/addEmpleado.php
Normal file
@ -0,0 +1,264 @@
|
||||
<?php
|
||||
/**
|
||||
* Página que ofrece un formulario para agregar candidatos y contiene la lógica
|
||||
* para agregar un candidato
|
||||
*
|
||||
* Hay que tener cuidado porque todas las variables que se le pasan por post son agregadas.
|
||||
*/
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")
|
||||
&& !$usuario->tieneRol("1")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$errores=array();
|
||||
|
||||
if(stripinput($_POST['action'])=="add"){
|
||||
$errores_persona = "";
|
||||
include_once("campos_persona.php");
|
||||
if(count($provincia_deseada)==0){
|
||||
$errores_persona .= $locale['1708']."<br />";
|
||||
$errores[]="22";
|
||||
}
|
||||
|
||||
if((count($perfil)==1) && ($perfil["0"]=="")){
|
||||
$errores_persona .= $locale['1705']."<br />";
|
||||
$errores[]="23";
|
||||
}
|
||||
include_once("verificar_usuario.php");
|
||||
if(count($errores)==0){
|
||||
$arrayInsert=array();
|
||||
include_once("Objects/ListaEmpleados.php");
|
||||
$listaEmpleados=new ListaEmpleados($usuario,"","","10");
|
||||
$fecha_nacimiento_ini = stripinput($_POST['anyonac'])."-".stripinput($_POST['mesnac'])."-".stripinput($_POST['dianac']);
|
||||
$fecha_alta = stripinput($_POST['anyoalta'])."-".stripinput($_POST['mesalta'])."-".stripinput($_POST['dianac']);
|
||||
$camposQuitar=array();
|
||||
$camposQuitar["dianac"]=stripinput($_POST['dianac']);
|
||||
$camposQuitar["mesnac"]=stripinput($_POST['mesnac']);
|
||||
$camposQuitar["anyonac"]=stripinput($_POST['anyonac']);
|
||||
$camposQuitar["diaalta"]=stripinput($_POST['diaalta']);
|
||||
$camposQuitar["mesalta"]=stripinput($_POST['mesalta']);
|
||||
$camposQuitar["anyoalta"]=stripinput($_POST['anyoalta']);
|
||||
$camposQuitar["MAX_FILE_SIZE"]=stripinput($_POST['MAX_FILE_SIZE']);
|
||||
$camposQuitar["tecnologia"]=stripinput($_POST['tecnologia']);
|
||||
$camposQuitar["idiomas"]=stripinput($_POST['idiomas']);
|
||||
$camposQuitar["titulaciones"]=stripinput($_POST['titulaciones']);
|
||||
$camposQuitar["provincia_deseada"]=stripinput($_POST['provincia_deseada']);
|
||||
$camposQuitar["perfil"]=stripinput($_POST['perfil']);
|
||||
$camposQuitar["action"]=stripinput($_POST['action']);
|
||||
|
||||
$camposInsertar=array_diff_assoc($_POST,$camposQuitar);
|
||||
$camposInsertar["fecha_nacimiento"]=$fecha_nacimiento_ini;
|
||||
$camposInsertar["fecha_alta"]=$fecha_alta;
|
||||
$vacio=array();
|
||||
$vacio['0']="";
|
||||
$_POST['tecnologia']=array_diff_assoc($_POST['tecnologia'],$vacio);
|
||||
$_POST['idiomas']=array_diff_assoc($_POST['idiomas'],$vacio);
|
||||
$_POST['titulaciones']=array_diff_assoc($_POST['titulaciones'],$vacio);
|
||||
foreach($camposInsertar as $nombre_campo => $valor){
|
||||
if($valor!="")
|
||||
$arrayInsert[$nombre_campo]=$valor;
|
||||
}
|
||||
// Insertamos el nuevo empleado
|
||||
try{
|
||||
$errorInsert=false;
|
||||
$idEmpleadoNew=$listaEmpleados->addEmpleado($arrayInsert);
|
||||
if($idEmpleadoNew!="-1"){
|
||||
include_once("Objects/Empleado.php");
|
||||
$empleadoNew=new Empleado($usuario,$idEmpleadoNew);
|
||||
$empleadoNew->addTecnologias($_POST['tecnologia']);
|
||||
$empleadoNew->addIdiomas($_POST['idiomas']);
|
||||
$empleadoNew->addTitulaciones($_POST['titulaciones']);
|
||||
if($_POST['provincia_deseada']==""){
|
||||
$_POST['provincia_deseada']=array();
|
||||
}
|
||||
$empleadoNew->addProvinciasDeseadas($_POST['provincia_deseada']);
|
||||
$empleadoNew->addPerfiles($_POST['perfil']);
|
||||
$empleadoNew->addCurriculum($_FILES['userfile']);
|
||||
header("Location: detalle_empleado.php?oid=".$idEmpleadoNew);
|
||||
} else {
|
||||
$tipomsg="error";
|
||||
$mensaje="No se ha podido insertar";
|
||||
}
|
||||
} catch (Exception $e){
|
||||
$tipomsg="error";
|
||||
$mensaje=$e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$tipomsg="error";
|
||||
$mensaje=$errores_persona;
|
||||
}
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
$html->menuEmpleados();
|
||||
echo "<h2>".$locale['807']."</h2>";
|
||||
if($mensaje!=""){
|
||||
// Mostramos el mensaje
|
||||
echo "<div class=\"aviso ".$tipomsg."\">".$mensaje."</div>";
|
||||
}
|
||||
|
||||
echo $locale['286'];
|
||||
$tipo="usuario";
|
||||
|
||||
if($errorInsert){
|
||||
|
||||
}
|
||||
|
||||
echo "<form action=\"addEmpleado.php\" method=\"POST\" enctype=\"multipart/form-data\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"add\" />";
|
||||
//Datos personales:
|
||||
echo '<input type="submit" value="'.$locale['807'].'" class="button">';
|
||||
echo '<div class="encabezado">'.$locale['1548'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("2",$errores)) echo " class=\"errorcampo\"";
|
||||
echo $en.' width="25%" textalign="right">'.$locale['100'].'<br><input type="text" name="nombre" value="'.$_POST['nombre'].'" size="20" maxlength="50"><br></td>
|
||||
<td ';
|
||||
if(in_array("3",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" textalign="right">'.$locale['101'].'<br><input type="text" name="apellidos" value="'.$_POST['apellidos'].'" size="30" maxlength="150"></td>
|
||||
<td width="25%" textalign="right">'.$locale['116'].'<br>';
|
||||
rellena_fecha_select($fecha_nacimiento, "nac");
|
||||
echo '</td>';
|
||||
echo '<td ';
|
||||
if(in_array("4",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$edni.' textalign="right">'.$locale['1539'].'<br><input type="text" name="dni" value="'.$_POST['dni'].'" size="9" maxlength="9"></td></tr>';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("1",$errores)) echo ' class="errorcampo"';
|
||||
echo ' width="25%">'.$locale['103'].'<input type="text" name="email" value="'.$_POST['email'].'" size="30" maxlength="50"></td>
|
||||
<td ';
|
||||
if(in_array("6",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$etm.' textalign="right" width=20%>'.$locale['107'].'<input type="text" name="t_movil" value="'.$_POST['t_movil'].'" size="9" maxlength="9"></td>
|
||||
<td ';
|
||||
if(in_array("7",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$etc.' textalign="right" width=20%>'.$locale['108'].'<input type="text" name="t_casa" value="'.$_POST['t_casa'].'" size="9" maxlength="9"></td>
|
||||
<td ';
|
||||
if(in_array("8",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="25%" '.$ett.' textalign="right" width=20%>'.$locale['109'].'<input type="text" name="t_trabajo" value="'.$_POST['t_trabajo'].'" size="9" maxlength="9"></td>
|
||||
</tr>';
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("17",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' textalign="right">'.$locale['114'.$tipo.''].'';
|
||||
rellena_desplegable_localidad($_POST['localidad'], "localidad");
|
||||
echo '</td>
|
||||
<td '.$dir.' textalign="right">'.$locale['128'].'';
|
||||
$auxiliar = '<option value="">-</option>';
|
||||
rellena_desplegable_select("tipo_via","tipo_via",$auxiliar,$_POST['tipo_via']);
|
||||
echo '<br>'.$locale['110'].'<input type="text" name="direccion" value="'.$_POST['direccion'].'" size="20" maxlength="50"></td>
|
||||
<td textalign="right" '.$enum.'>'.$locale['111'].'
|
||||
<input type="text" name="numero" value="'.$_POST['numero'].'" size="5" maxlength="25"><br>
|
||||
'.$locale['112'].'
|
||||
<input type="text" name="piso" value="'.$_POST['piso'].'" size="5" maxlength="25"><br>
|
||||
'.$locale['113'].'
|
||||
<input type="text" name="puerta" value="'.$_POST['puerta'].'" size="5" maxlength="25">
|
||||
</td>
|
||||
<td ';
|
||||
if(in_array("12",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' textalign="right" '.$ecp.'>'.$locale['115'].'
|
||||
<input type="text" name="cp" value="'.$_POST['cp'].'" size="3" maxlength="5">
|
||||
</td>
|
||||
</tr>';
|
||||
echo '<tr>
|
||||
<td colspan="4" align="center">'.$locale['126'].'<br><textarea name="descripcion" rows="4" cols="40" style="overflow: auto;">'.$_POST['descripcion'].'</textarea></td></tr></table>';
|
||||
|
||||
//Datos laborales:
|
||||
echo '<input type="submit" value="'.$locale['807'].'" class="button">';
|
||||
echo '<div class="encabezado">'.$locale['1550'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td ';
|
||||
if(in_array("20",$errores)) echo " class=\"errorcampo\"";
|
||||
echo 'width="33%" textalign="right">'.$locale['1800'].'* : ';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
rellena_procedencias("procedencia",$auxiliar,$_POST['procedencia']);
|
||||
echo '<td width="33%" textalign="right">';
|
||||
echo $locale['1800']." ".$locale['1091'].":";
|
||||
echo $html->listaSelect("procedencia_cv","id","nombre","procedenciaCV",array("","-"),array($_POST['procedenciaCV']),true,false,"1");
|
||||
echo '</td>
|
||||
<td ';
|
||||
if(in_array("14",$errores)) echo " class=\"errorcampo\"";
|
||||
echo 'textalign="right">'.$locale['1618'].'<input type="text" name="salario" value="'.$_POST['salario'].'" size="10" maxlength="25"><br></td>
|
||||
|
||||
</tr>';
|
||||
echo '</tr>';
|
||||
|
||||
|
||||
echo '<tr>
|
||||
<td ';
|
||||
if(in_array("5",$errores)) echo " class=\"errorcampo\"";
|
||||
echo 'textalign="right">'.$locale['105usuario'].'<input type="text" name="seguridad_social" value="'.$_POST['seguridad_social'].'" size="12" maxlength="12"><br></td>
|
||||
<td ';
|
||||
if(in_array("9",$errores)) echo " class=\"errorcampo\"";
|
||||
echo 'textalign="right">'.$locale['106'].'<input type="text" name="cuenta_corriente" value="'.$_POST['cuenta_corriente'].'" size="20" maxlength="20"><br></td><td></td>
|
||||
</tr>';
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td ';
|
||||
if(in_array("23",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' textalign="right" '.$eper.'><div style="float:left ">'.$locale['121'].'</div><div style="float:left ">';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
echo $html->listaSelect("perfil","oid","id","perfil",array("",$locale['ns']),$_POST['perfil'],true,true,"15");
|
||||
|
||||
echo '</div></td>';
|
||||
echo '<td ';
|
||||
if(in_array("22",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ' width="33%" textalign="right" '.$ldes.'><div style="float:left ">'.$locale['1590'].'* </div><div style="float:left ">';
|
||||
|
||||
echo $html->listaSelect("provincias","oid","id","provincia_deseada",array("",$locale['ns']),$_POST['provincia_deseada'],true,true,"15");
|
||||
|
||||
echo '</div></td>';
|
||||
|
||||
echo '<tr>
|
||||
<td colspan="3" align="center">'.$locale['135'].'<br><textarea name="observaciones" rows="7" cols="50" style="overflow: auto;">'.$_POST['observaciones'].'</textarea></td></tr><tr>';
|
||||
echo '</tr></table>';
|
||||
|
||||
echo '<input type="submit" value="'.$locale['807'].'" class="button">';
|
||||
// CURRICULUM
|
||||
echo '<div class="encabezado">'.$locale['1549'].'</div>';
|
||||
echo '<table align="center" width="100%">';
|
||||
echo '<tr align="center">
|
||||
<td textalign="right">'.$locale['122'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("tecnologia","oid","id","tecnologia",array("",$locale['ns']),$_POST['tecnologia'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td align="right">'.$locale['123'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("idiomas","oid","id","idiomas",array("",$locale['ns']),$_POST['idiomas'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
<td align="right">'.$locale['124'].'</td><td>';
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
|
||||
echo $html->listaSelect("titulaciones","oid","id","titulaciones",array("",$locale['ns']),$_POST['titulaciones'],true,true,"15");
|
||||
|
||||
echo '</td>
|
||||
|
||||
</tr>';
|
||||
echo '<tr><td colspan="6">';
|
||||
menu_curriculums($_GET['oid'], "candidato");
|
||||
echo '</td></tr><tr>';
|
||||
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
|
||||
<td colspan="6" textalign="right">'.$locale['125'].'<br>';
|
||||
echo '<input name="userfile" type="file">';
|
||||
echo '</td></tr></table>';
|
||||
|
||||
echo '</table>';
|
||||
echo '<input type="submit" value="'.$locale['807'].'" class="button">';
|
||||
echo "</form>";
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
78
src/addEmpresa.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!$usuario->tieneRol("3")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if($_POST['action']=="add"){
|
||||
$id=$_POST['id'];
|
||||
$gerente=$_POST['gerente'];
|
||||
$privado=$_POST['privado'];
|
||||
$errores=array();
|
||||
if($id=="") $errores[]="1";
|
||||
if($gerente=="") $errores[]="2";
|
||||
if($privado=="") $errores[]="3";
|
||||
|
||||
if(count($errores)==0){
|
||||
try{
|
||||
include_once("Objects/ListaEmpresas.php");
|
||||
$listaEmpresas = new ListaEmpresas($usuario,$locale);
|
||||
$arrayInsert=array();
|
||||
$arrayInsert["id"]=$id;
|
||||
$arrayInsert["gerente"]=$gerente;
|
||||
$arrayInsert["privado"]=$privado;
|
||||
$idEmpresaNew=$listaEmpresas->addEmpresa($arrayInsert);
|
||||
header("Location: gestion_empresa.php?oid=".$idEmpresaNew);
|
||||
|
||||
} catch(Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
}
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
$html = new HTML($locale);
|
||||
echo $html->menuEmpresas("","");
|
||||
?>
|
||||
<h2><?php echo $locale['2203']; ?></h2>
|
||||
<?php if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
} ?>
|
||||
<div id="ContTabul">
|
||||
<form action="addEmpresa.php" method="post" >
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<table>
|
||||
<tr>
|
||||
<td><?php echo $locale['1803']; ?></td>
|
||||
<td><input type="text" name="id" value="<?php echo $_POST['id']; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $locale['2214']; ?></td>
|
||||
<td>
|
||||
<?php echo rellena_personal_permiso("gerente","GP",$auxiliar,$_POST['gerente']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $locale['2215']; ?></td>
|
||||
<td>
|
||||
<select name="privado">
|
||||
<option value="0" <?php if($_POST['privado']=="0") echo "selected"; ?>><?php echo $locale['2213']; ?></option>
|
||||
<option value="1" <?php if($_POST['privado']=="1") echo "selected"; ?>><?php echo $locale['2212']; ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" class="button" value="<?php echo $locale['add']; ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
205
src/addPedido.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
include_once("Objects/Pedido.php");
|
||||
include_once("Objects/HTML.php");
|
||||
|
||||
$html=new HTML($locale);
|
||||
// Comprobamos los permisos
|
||||
// Sólo los gerentes y administradores puede añadir pedidos
|
||||
if(!$usuario->tieneRol("3")&&!$usuario->tieneRol("1")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
$errores = array();
|
||||
|
||||
// Todas las variables
|
||||
$nombre=$_POST['nombre'];
|
||||
$prioridad=$_POST['prioridad'];
|
||||
$empleados=$_POST['empleados'];
|
||||
$duracion=$_POST['duracion'];
|
||||
$clientes=$_POST['clientes'];
|
||||
$perfil=$_POST['perfil'];
|
||||
$salario_min=$_POST['salario_min'];
|
||||
$salario_max=$_POST['salario_max'];
|
||||
$procedencia=$_POST['procedencia'];
|
||||
$tecnologias=$_POST['tecnologia'];
|
||||
$idiomas=$_POST['idiomas'];
|
||||
$provincias=$_POST['provincias'];
|
||||
$observaciones=$_POST['observaciones'];
|
||||
$pesoTec=$_POST['pesoTec'];
|
||||
$pesoIdi=$_POST['pesoIdi'];
|
||||
$pesoPer=$_POST['pesoPer'];
|
||||
|
||||
if($usuario->tieneRol("1")){
|
||||
$gerente=$_POST['gerente'];
|
||||
} else {
|
||||
$gerente=$usuario->getValor("oid");
|
||||
}
|
||||
if($_POST['action']=="add"){
|
||||
// Comprobamos campos obligatorios
|
||||
if($nombre==""){
|
||||
$errores[]= "1";
|
||||
}
|
||||
if(($prioridad=="") ||($empleados=="") || ($duracion=="") || (!($empleados>0)) ||(!($duracion>0))){
|
||||
$errores[]= "2";
|
||||
}
|
||||
if($gerente==""){
|
||||
$errores[]= "3";
|
||||
}
|
||||
if($clientes==""){
|
||||
$errores[]= "4";
|
||||
}
|
||||
if($perfil==""){
|
||||
$errores[]= "5";
|
||||
}
|
||||
if(($salario_min=="") ||($salario_max=="") || ($salario_min>$salario_max)){
|
||||
$errores[]= "6";
|
||||
}
|
||||
if($procedencia==""){
|
||||
$errores[]= "7";
|
||||
}
|
||||
|
||||
if(($pesoTec=="") ||($pesoIdi=="") || ($pesoPer=="")
|
||||
|| !is_numeric($pesoTec) || !is_numeric($pesoIdi) || !is_numeric($pesoPer)
|
||||
|| (!($pesoTec>=0)) ||(!($pesoIdi>=0)) || (!($pesoPer>=0))
|
||||
|| ($pesoTec + $pesoIdi + $pesoPer != 100)){
|
||||
$errores[]="8";
|
||||
}
|
||||
// Si no hay errores insertamos el pedido
|
||||
if(count($errores)==0){
|
||||
include_once("Objects/ListaPedido.php");
|
||||
$listaPedidos=new ListaPedido($usuario,"","","0");
|
||||
$arrayInsert=array();
|
||||
$arrayInsert["nombre"]=$nombre;
|
||||
$arrayInsert["prioridad"]= $prioridad;
|
||||
$arrayInsert["empleados"]=$empleados;
|
||||
$arrayInsert["duracion"]=$duracion;
|
||||
$arrayInsert["gerente"]=$gerente;
|
||||
$arrayInsert["perfil"]=$perfil;
|
||||
$arrayInsert["cliente"]=$clientes;
|
||||
$arrayInsert["salario_min"]=$salario_min;
|
||||
$arrayInsert["salario_max"]=$salario_max;
|
||||
$arrayInsert["procedencia"]=$procedencia;
|
||||
$arrayInsert["observaciones"]=$observaciones;
|
||||
$arrayInsert["estado"]="10";
|
||||
$arrayInsert["pesoIdioma"]=$pesoIdi;
|
||||
$arrayInsert["pesoPerfil"]=$pesoPer;
|
||||
$arrayInsert["pesoTecno"]=$pesoTec;
|
||||
$idPedido=$listaPedidos->addPedido($arrayInsert);
|
||||
if($idPedido=="-1"){
|
||||
// Se he producido un fallo al insertar
|
||||
$errores[]= "0";
|
||||
$msg="No se ha podido agregar el pedido";
|
||||
$tipo="error";
|
||||
} else {
|
||||
$pedido=$listaPedidos->buscarPedido($idPedido);
|
||||
$pedido->addTecnologias($tecnologias);
|
||||
$pedido->addIdiomas($idiomas);
|
||||
$pedido->addProvincias($provincias);
|
||||
header("Location: pedido.php?idPedido=".$idPedido."&msg=1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include("html/cabecera.php");
|
||||
|
||||
if($pesoTec=="") $pesoTec="40";
|
||||
if($pesoIdi=="") $pesoIdi="10";
|
||||
if($pesoPer=="") $pesoPer="50";
|
||||
|
||||
echo $html->menuPedidos($usuario,"");
|
||||
|
||||
|
||||
echo "<h2>".$locale['1058']."</h2>";
|
||||
if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
}
|
||||
echo '<form method="POST" action="addPedido.php" name="form_registro" enctype="multipart/form-data">';
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"add\" />";
|
||||
echo "<table id=\"addPedido\">" .
|
||||
"<tr>" .
|
||||
" <td";
|
||||
if(in_array("1",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">".$locale['1043']."<input type=\"text\" name=\"nombre\" value=\"".$nombre."\" size=\"30\" maxlength=\"30\" ></td>" .
|
||||
" <td";
|
||||
if(in_array("2",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">" .$locale['1022'].":";
|
||||
rellena_prioridad_select("prioridad",$prioridad);
|
||||
echo " - ".$locale['1024'].": <input type=\"text\" name=\"empleados\" value=\"".$empleados."\" maxlenght=\"3\" size=\"2\"" .
|
||||
"<br />".$locale['1026'].": <input type=\"text\" name=\"duracion\" value=\"".$duracion."\" maxlenght=\"3\" size=\"2\" />" .
|
||||
"</td>";
|
||||
echo "<td";
|
||||
if(in_array("3",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">".$locale['1027'];
|
||||
// Si es Admin puede asignar un gerente, si no, sólo a él
|
||||
if($usuario->tieneRol("1")){
|
||||
$auxiliar = "";
|
||||
rellena_personal_permiso("gerente","GP",$auxiliar,$usuario->getValor("oid"));
|
||||
} else {
|
||||
echo "<input type=\"text\" readonly value=\"".$usuario->getValor("nombre")." ".$usuario->getValor("apellidos")."\" />";
|
||||
}
|
||||
|
||||
echo "</td></tr>" .
|
||||
" <tr><td";
|
||||
if(in_array("4",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">".$locale['1504'];
|
||||
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
|
||||
rellena_desplegable_select_oid("clientes","clientes",$auxiliar,$clientes);
|
||||
echo "</td><td";
|
||||
if(in_array("5",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">".$locale['121'];
|
||||
rellena_desplegable_select_oid("perfil","perfil",$auxiliar,$perfil);
|
||||
echo "</td><td>".$locale['132'].": ".$locale['2100'];
|
||||
|
||||
echo "</td></tr>";
|
||||
|
||||
echo "<tr><td colspan=\"2\"";
|
||||
if(in_array("6",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">";
|
||||
echo $locale['129'];
|
||||
rellena_desplegable_select_oidCol("salario","id","nombre","salario_min",$auxiliar,$salario_min);
|
||||
echo ' - '.$locale['130'].'';
|
||||
rellena_desplegable_select_oidCol("salario","id","nombre","salario_max",$auxiliar,$salario_max);
|
||||
|
||||
echo "</td><td";
|
||||
if(in_array("7",$errores)) echo " class=\"errorcampo\"";
|
||||
echo ">".$locale['1800'];
|
||||
rellena_procedencias("procedencia",$auxiliar,$procedencia);
|
||||
echo "</td></tr>";
|
||||
echo "<tr><td colspan=\"3\">" .
|
||||
"<table><tr><td>".$locale['122']."</td><td>";
|
||||
|
||||
echo $html->listaSelect("tecnologia","oid","id","tecnologia",array("",$locale['ns']),$tecnologias,true,true,"15");
|
||||
|
||||
|
||||
echo "</td><td>".$locale['123']."</td><td>";
|
||||
echo $html->listaSelect("idiomas","oid","id","idiomas",array("",$locale['ns']),$idiomas,true,true,"15");
|
||||
|
||||
echo "</td><td>".$locale['209']."</td><td>";
|
||||
echo $html->listaSelect("provincias","oid","id","provincias",array("",$locale['ns']),$provincias,true,true,"15");
|
||||
|
||||
echo "</td>";
|
||||
?>
|
||||
<td <?php if(in_array("8",$errores)) echo " class=\"errorcampo\""; ?> width="200px">
|
||||
<?php echo $locale['1078']; ?>: <input name="pesoTec" type="text" size="5" align="right" value="<?php echo $pesoTec; ?>" <?php if((!is_numeric($pesoTec))&& ($pesoTec!="")) echo " class=\"errorcampo\""; ?>> %<br />
|
||||
<?php echo $locale['1079']; ?>: <input name="pesoIdi" type="text" size="5" value="<?php echo $pesoIdi; ?>" <?php if((!is_numeric($pesoIdi)) && ($pesoIdi!="")) echo " class=\"errorcampo\""; ?>> %<br />
|
||||
<?php echo $locale['1080']; ?>: <input name="pesoPer" type="text" size="5" value="<?php echo $pesoPer; ?>" <?php if((!is_numeric($pesoPer))&& ($pesoPer!="")) echo " class=\"errorcampo\""; ?>> %<br />
|
||||
<?php echo $locale['1081']; ?>
|
||||
</td>
|
||||
<?php
|
||||
|
||||
echo "</tr></table></td></tr>";
|
||||
echo '<tr>' .
|
||||
'<td colspan="3" align="center">'.$locale['135'].'<br><textarea name="observaciones" rows="4" cols="40" maxlength="300" style="overflow: auto;">'.$observaciones.'</textarea></td>' .
|
||||
'</tr>';
|
||||
|
||||
// Botones de guardar y restablecer
|
||||
echo "<tr><td colspan=\"3\" align=\"center\">";
|
||||
echo '<input type="submit" value="'.$locale['gu'].'" onclick="return comprobar_registro(this)" class="button">';
|
||||
echo '<input type="reset" value="'.$locale['res'].'" class="button"></td>';
|
||||
echo "</tr></table>";
|
||||
echo "</form>";
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
115
src/addSolicitudesEmpleado.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")
|
||||
&& !$usuario->tieneRol("1")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("Objects/Vacaciones.php");
|
||||
include_once("Objects/Empleado.php");
|
||||
include_once("Objects/Permisos.php");
|
||||
include_once("html/cabeceraPrint.php");
|
||||
$oid=$_GET['oid'];
|
||||
if($_POST['oid']!="") $oid=$_POST['oid'];
|
||||
|
||||
$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'];
|
||||
|
||||
$tipoSoli="v";
|
||||
if($_GET['tipo']!="") $tipoSoli=$_GET['tipo'];
|
||||
if($_POST['tipo']!="") $tipoSoli=$_POST['tipo'];
|
||||
|
||||
$empleado=new Empleado($usuario,$oid);
|
||||
$vacaciones=new Vacaciones($usuario,$empleado->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
||||
$permisos=new Permisos($usuario,$empleado->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
||||
$back="addSolicitudesEmpleado.php?oid=".$oid."&tipo=".$tipoSoli;
|
||||
switch ($_POST['action']) {
|
||||
case "crear":
|
||||
$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"){
|
||||
$dias[$i]="solicitud creada por RRHH";
|
||||
}
|
||||
}
|
||||
try{
|
||||
if($tipoSoli=="v"){
|
||||
$vacaciones->solicitar($dias);
|
||||
}elseif($tipoSoli=="p"){
|
||||
$permisos->solicitar($dias);
|
||||
} else{
|
||||
$tipo="error";
|
||||
$msg="error en la selección";
|
||||
}
|
||||
if($msg==""){
|
||||
$tipo="ok";
|
||||
$msg=$locale['290'];
|
||||
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>";
|
||||
}
|
||||
?>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.buttonSolicitud {font-size: 16px;
|
||||
background-image:url(css/vacaciones.gif);
|
||||
background-repeat:no-repeat;
|
||||
height:43px;
|
||||
padding-left:45px;
|
||||
font-weight:bold;
|
||||
}
|
||||
.buttonPermiso {font-size: 16px;
|
||||
background-image:url(css/permiso.gif);
|
||||
background-repeat:no-repeat;
|
||||
height:43px;
|
||||
padding-left:45px;
|
||||
font-weight:bold;
|
||||
}
|
||||
.buttonSolicitudActivo{
|
||||
background-color:#00CCFF;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
||||
<input type="button" class="buttonSolicitud <?php if($tipoSoli=="v") echo "buttonSolicitudActivo"; ?>" value="Crear vacaciones" onclick="irA('addSolicitudesEmpleado.php?oid=<?php echo $oid; ?>&tipo=v&mes=<?php echo $mes_hoy;?>&anio=<?php echo $ano_hoy;?>')"/>
|
||||
<input type="button" class="buttonPermiso <?php if($tipoSoli=="p") echo "buttonSolicitudActivo"; ?>" value="Crear permisos" onclick="irA('addSolicitudesEmpleado.php?oid=<?php echo $oid; ?>&tipo=p&mes=<?php echo $mes_hoy;?>&anio=<?php echo $ano_hoy;?>')"/><br />
|
||||
<input type="button" class="button" value="Cerrar" onclick="window.close();">
|
||||
<?php echo "<b>".$locale['413']."</b>".$empleado->getValor("nombre")." ".$empleado->getValor("apellidos"); ?>
|
||||
<form id="vacaciones" action="addSolicitudesEmpleado.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; ?>" />
|
||||
<input type="hidden" name="oid" value="<?php echo $oid; ?>" />
|
||||
<input type="hidden" name="action" value="crear" />
|
||||
<input type="hidden" name="tipo" value="<?php echo $tipoSoli; ?>" />
|
||||
<?php
|
||||
$vacaciones=new Vacaciones($usuario,$empleado->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
||||
$permisos=new Permisos($usuario,$empleado->getValor("oid"),$mes_hoy,$ano_hoy,$locale);
|
||||
include_once("ver_vacaciones.php");
|
||||
?>
|
||||
<input type="submit" class="button" value="<?php
|
||||
if($tipoSoli=="v")
|
||||
echo $locale['289'];
|
||||
else echo $locale['466']; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
19
src/admin_backup.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!$usuario->tieneRol("2")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
?>
|
||||
|
||||
<h2><?php echo $locale['1810']; ?></h2>
|
||||
<h4><?php echo $locale['1809']; ?></h4>
|
||||
<form action="backup_bd.php" method="post">
|
||||
<input type="submit" class="button" value="<?php echo $locale["gu"]; ?>">
|
||||
</form>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
392
src/administracion.php
Normal file
@ -0,0 +1,392 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
if (!comprobar_permisos("AS")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* ADMINISTRACION.PHP */
|
||||
|
||||
echo "<h2>".$locale['200']."</h2>";
|
||||
echo "<br/><br/>";
|
||||
echo "<p><b>".$locale['201']."</b></p>";
|
||||
$e = stripinput($_GET["e"]);
|
||||
$a = stripinput($_GET["a"]);
|
||||
$opcion = stripinput($_GET["opcion"]);
|
||||
|
||||
//Pestañas de navegación
|
||||
echo '<ul id="tabnav">';
|
||||
if($opcion != "perfil"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=perfil'>".$locale['202']."</a></li>";
|
||||
if($opcion != "tecnologia"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=tecnologia'>".$locale['203']."</a></li>";
|
||||
if($opcion != "estado"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=estado'>".$locale['204']."</a></li>";
|
||||
|
||||
if($opcion != "estado_pedidos"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=estado_pedidos'>".$locale['712']."</a></li>";
|
||||
|
||||
if($opcion != "estado_candidatura"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=estado_candidatura'>".$locale['1807']."</a></li>";
|
||||
|
||||
if($opcion != "situacion"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=situacion'>".$locale['205']."</a></li>";
|
||||
if($opcion != "idioma"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=idioma'>".$locale['206']."</a></li>";
|
||||
if($opcion != "titulacion"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=titulacion'>".$locale['207']."</a></li>";
|
||||
if($opcion != "tipo_via"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=tipo_via'>".$locale['208']."</a></li>";
|
||||
if($opcion != "provincia"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=provincia'>".$locale['209']."</a></li>";
|
||||
if($opcion != "localidad"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=localidad'>".$locale['210']."</a></li>";
|
||||
|
||||
if($opcion != "constantes"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=constantes'>".$locale['212']."</a></li>";
|
||||
if($opcion != "procedencia"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=procedencia'>".$locale['1800']."</a></li>";
|
||||
|
||||
if($opcion != "incorporacion"){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion.php?opcion=incorporacion'>".$locale['1814']."</a></li>";
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div id="ContTabul">';
|
||||
/* ------------ PERFIL */
|
||||
if($opcion == "perfil"){
|
||||
echo '<form action="tablas_madre.php?opcion=perfil&action=eliminar" method="POST" name="form_e_perfil">';
|
||||
echo rellena_perfiles("perfil","perfil","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['220'].'" onclick="return admin_e_perfil()" class="button"><br><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo ' '.$locale['224'].' <input type="text" name="abrev" size="10" maxlength="30"> ';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['221']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=perfil&accion=insertar" method="POST" name="form_i_perfil">
|
||||
<tr>
|
||||
<td align="right" width="60">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
<td align="right" width="60">'.$locale['224'].'</td>
|
||||
<td><input type="text" name="abrev" size="10" maxlength="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['225'].'" onclick="return admin_i_perfil()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ PERFIL */
|
||||
}else if($opcion == "tecnologia"){
|
||||
/* ------------ TECNOLOGÍA */
|
||||
echo '<form action="tablas_madre.php?opcion=tecnologia&action=eliminar" method="POST" name="form_e_tecnologia">';
|
||||
echo rellena_desplegable_oid("tecnologia","tecnologia","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['229'].'" onclick="return admin_e_tecnologia()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['230']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=tecnologia&accion=insertar" method="POST" name="form_i_tecnologia">
|
||||
<tr>
|
||||
<td align="right" width="60">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="60" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['231'].'" onclick="return admin_i_tecnologia()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ TECNOLOGÍA */
|
||||
}else if($opcion == "estado"){
|
||||
/* ------------ ESTADO */
|
||||
echo '<form action="tablas_madre.php?opcion=estado&action=editar" method="POST" name="form_e_estado">';
|
||||
echo rellena_desplegable_orden("estado","estado","");
|
||||
echo '<input type="submit" name="enviar" value="+" class="button"><input type="submit" name="enviar" value="-" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['232'].'" onclick="return admin_e_estado()" class="button">
|
||||
</form>';
|
||||
echo "<h4>".$locale['233']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=estado&accion=insertar" method="POST" name="form_i_estado">
|
||||
<tr>
|
||||
<td align="right" width="30">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['234'].'" onclick="return admin_i_estado()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ ESTADO */
|
||||
}else if($opcion == "estado_pedidos"){
|
||||
/* ------------ ESTADO PEDIDOS*/
|
||||
echo '<form action="tablas_madre.php?opcion=estado_pedidos&action=editar" method="POST" name="form_e_estado">';
|
||||
echo rellena_desplegable_orden("estado_pedidos","estado_pedidos","");
|
||||
echo '<input type="submit" name="enviar" value="+" class="button"><input type="submit" name="enviar" value="-" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['232'].'" onclick="return admin_e_estado()" class="button">
|
||||
</form>';
|
||||
echo "<h4>".$locale['233']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=estado_pedidos&accion=insertar" method="POST" name="form_i_estado">
|
||||
<tr>
|
||||
<td align="right" width="30">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['234'].'" onclick="return admin_i_estado()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ ESTADO PEDIDOS*/
|
||||
}else if($opcion == "estado_candidatura"){
|
||||
/* ------------ ESTADO CANDIDATURAS*/
|
||||
echo '<form action="tablas_madre.php?opcion=estado_candidatura&action=editar" method="POST" name="form_e_estado">';
|
||||
echo rellena_desplegable_orden("estado_candidatura","estado_candidatura","");
|
||||
echo '<input type="submit" name="enviar" value="+" class="button"><input type="submit" name="enviar" value="-" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['232'].'" onclick="return admin_e_estado()" class="button">
|
||||
</form>';
|
||||
echo "<h4>".$locale['233']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=estado_candidatura&accion=insertar" method="POST" name="form_i_estado">
|
||||
<tr>
|
||||
<td align="right" width="30">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['234'].'" onclick="return admin_i_estado()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ ESTADO CANDIDATURAS*/
|
||||
}else if($opcion == "situacion"){
|
||||
/* ------------ SITUACIÓN */
|
||||
echo '<form action="tablas_madre.php?opcion=situacion&action=eliminar" method="POST" name="form_e_situacion">';
|
||||
echo rellena_desplegable("situacion","situacion","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['235'].'" onclick="return admin_e_situacion()" class="button">
|
||||
</form>';
|
||||
echo "<h4>".$locale['236']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=situacion&accion=insertar" method="POST" name="form_i_situacion">
|
||||
<tr>
|
||||
<td align="right" width="30">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['237'].'" onclick="return admin_i_situacion()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ SITUACIÓN */
|
||||
}else if($opcion == "idioma"){
|
||||
/* ------------ IDIOMA */
|
||||
echo '<form action="tablas_madre.php?opcion=idioma&action=eliminar" method="POST" name="form_e_idioma">';
|
||||
echo rellena_desplegable_oid("idiomas","idiomas","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['238'].'" onclick="return admin_e_idioma()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['239']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=idioma&accion=insertar" method="POST" name="form_i_idioma">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['240'].'" onclick="return admin_i_idioma()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ IDIOMA */
|
||||
}else if($opcion == "titulacion"){
|
||||
/* ------------ TITULACION */
|
||||
echo '<form action="tablas_madre.php?opcion=titulacion&action=eliminar" method="POST" name="form_e_titulacion">';
|
||||
echo rellena_desplegable_oid("titulaciones","titulaciones","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['241'].'" onclick="return admin_e_titulacion()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['242']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=titulacion&accion=insertar" method="POST" name="form_i_titulacion">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="50"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['243'].'" onclick="return admin_i_titulacion()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ TITULACION */
|
||||
}else if($opcion == "tipo_via"){
|
||||
/* ------------ TIPO_VIA */
|
||||
echo '<form action="tablas_madre.php?opcion=tipo_via&action=eliminar" method="POST" name="form_e_tipo_via">';
|
||||
echo rellena_desplegable("tipo_via","tipo_via","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['244'].'" onclick="return admin_e_tipo_via()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['245']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=tipo_via&accion=insertar" method="POST" name="form_i_tipo_via">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="5" maxlength="5"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['246'].'" onclick="return admin_i_tipo_via()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ TIPO_VIA */
|
||||
}else if($opcion == "provincia"){
|
||||
/* ------------ PROVINCIA */
|
||||
echo '<form action="tablas_madre.php?opcion=provincia&action=eliminar" method="POST" name="form_e_provincia">';
|
||||
echo rellena_desplegable_oid("provincias","provincias","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['247'].'" onclick="return admin_e_provincia()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['248']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=provincia&accion=insertar" method="POST" name="form_i_provincia">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="20" maxlength="50"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['249'].'" onclick="return admin_i_provincia()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ PROVINCIA */
|
||||
}else if($opcion == "localidad"){
|
||||
/* ------------ LOCALIDAD */
|
||||
echo '<form action="tablas_madre.php?opcion=localidad&action=eliminar" method="POST" name="form_e_localidad">';
|
||||
echo rellena_desplegable_localidad("", "localidades");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['250'].'" onclick="return admin_e_localidad()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['251']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=localidad&accion=insertar" method="POST" name="form_i_localidad">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
<td align="right" width="100">'.$locale['256'].'</td>
|
||||
<td>';
|
||||
echo rellena_desplegable_oid("provincias","provincias","");
|
||||
echo '<td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['252'].'" onclick="return admin_i_localidad()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ LOCALIDAD */
|
||||
}else if($opcion == "constantes"){
|
||||
/* ------------ CONSTANTES DEL SISTEMA*/
|
||||
echo '<form action="constantes.php" name="form_sistema" method="post">';
|
||||
echo '<table>';
|
||||
$link = conectar();
|
||||
$consulta = "select * from sistema";
|
||||
$resultado = mysql_query($consulta, $link);
|
||||
if($resultado){
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
echo "<tr><td>".$rows['id']." </td><td><input type=text name=".$rows['id']." size='50' maxlength='50' value=".$rows['valor']."></td></tr>";
|
||||
}
|
||||
}
|
||||
echo "<p><tr><td colspan=2><b>".$locale['228'].":</b></td></tr></p>";
|
||||
echo "<p><tr><td>Nombre: <input type=text name=id value=''></td>
|
||||
<td>Valor: <input type=text size='50' maxlength='50' name=valor></td></tr></p>";
|
||||
echo '<p><tr><td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['258'].'" class="button"></td></tr></p>
|
||||
</form>';
|
||||
echo '</table>';
|
||||
/* ------------ CONSTANTES DEL SISTEMA*/
|
||||
}else if($opcion == "procedencia"){
|
||||
/* ------------ PROCEDENCIA */
|
||||
echo '<form action="tablas_madre.php?opcion=procedencia&action=eliminar" method="POST" name="form_e_procedencia">';
|
||||
echo rellena_procedencias("procedencia","","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['1801'].'" onclick="return admin_e_procedencia()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<p>".$locale['1802']."</p>";
|
||||
echo '<form action="tablas_madre.php?opcion=procedencia&accion=insertar" method="POST" name="form_i_procedencia">
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right" width="60">'.$locale['1803'].'</td>
|
||||
<td><input type="text" name="cadena" size="60" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" width="60">'.$locale['1804'].'</td>
|
||||
<td>';
|
||||
rellena_desplegable_color("color");
|
||||
echo '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['1805'].'" onclick="return admin_i_procedencia()" class="button"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>';
|
||||
/* ------------ PROCEDENCIA */
|
||||
|
||||
}else if($opcion == "incorporacion"){
|
||||
/* ------------ INCORPORACION */
|
||||
echo '<form action="tablas_madre.php?opcion=incorporacion&action=eliminar" method="POST" name="form_e_incorporacion">';
|
||||
echo rellena_desplegable("incorporaciones","incorporacion","");
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['1811'].'" onclick="return admin_e_incorporacion()" class="button"><br>'.$locale['223'].'<input type="text" name="cadena" size="30" maxlength="100">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['ed'].'" class="button"><br>';
|
||||
echo '</form>';
|
||||
echo "<h4>".$locale['1812']."</h4>";
|
||||
echo '<form action="tablas_madre.php?opcion=incorporacion&accion=insertar" method="POST" name="form_i_incorporacion">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="5" maxlength="5"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['1813'].'" onclick="return admin_i_incorporacion()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ INCORPORACION */
|
||||
|
||||
}else{
|
||||
echo "<p>".$locale['200'].".</p>";
|
||||
}
|
||||
echo '</div>';
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
152
src/administracion_alarmas.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
if (!comprobar_permisos("AS")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
|
||||
/* ADMINISTRACIÓN_ALARMAS.PHP */
|
||||
|
||||
menu_alarmas("");
|
||||
|
||||
echo "<h2>".$locale['300']."</h2>";
|
||||
echo "<br/>";
|
||||
echo "<p><b>".$locale['301']."</b></p>";
|
||||
$order = stripinput($_GET["order"]);
|
||||
$order_by = $order;
|
||||
$orden = stripinput($_GET["orden"]);
|
||||
$oid = stripinput($_GET["oid"]);
|
||||
$offset = stripinput($_GET["offset"]);
|
||||
$periodicidad = stripinput($_GET["periodicidad"]);
|
||||
|
||||
if ($order_by == "")
|
||||
$order_by = "rol, periodicidad";
|
||||
else if ($orden != "")
|
||||
$order_by .= " DESC";
|
||||
|
||||
if(!isset($offset) || $offset == ""){
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
|
||||
$link = conectar();
|
||||
|
||||
echo '<ul id="tabnav">';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div id="ContTabul">';
|
||||
//Mostramos las alarmas.
|
||||
$consulta = "(select alarmas.prioridad as prioridad, alarmas.id as id, alarmas.nombre as nombre, alarmas.periodicidad as periodicidad, rol.id as rol from alarmas,rol where rol.oid = alarmas.rol) union (select alarmas.prioridad as prioridad, alarmas.id as id, alarmas.nombre as nombre, alarmas.periodicidad as periodicidad, alarmas.rol as rol from alarmas where alarmas.rol is NULL) order by ".$order_by;
|
||||
if ($resultado = mysql_query($consulta)){
|
||||
$cont = mysql_num_rows($resultado);
|
||||
$limit = constante("lista");
|
||||
$consulta .= " limit ".$offset.",".$limit;
|
||||
$resultado = mysql_query($consulta);
|
||||
$num = mysql_num_rows($resultado);
|
||||
|
||||
if($num > 0){
|
||||
//Mostramos la cabecera de la tabla.
|
||||
echo '<table width=100%>';
|
||||
echo '<tr class="encabezado">';
|
||||
echo '<td align="center">'.$locale['1521'].'<br/>
|
||||
<table><tr><td class=sinborde>
|
||||
<form action="administracion_alarmas.php?order=nombre" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/asc.png">';
|
||||
echo '</form></td><td class=sinborde>';
|
||||
echo '<form action="administracion_alarmas.php?order=nombre&orden=desc" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/desc.png">';
|
||||
echo '</form></td></tr></table>';
|
||||
echo '<td align="center">'.$locale['1022'].'<br/>
|
||||
<table><tr><td class=sinborde>
|
||||
<form action="administracion_alarmas.php?order=prioridad" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/asc.png">';
|
||||
echo '</form></td><td class=sinborde>';
|
||||
echo '<form action="administracion_alarmas.php?order=prioridad&orden=desc" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/desc.png">';
|
||||
echo '</form></td></tr></table>';
|
||||
echo '<td align="center">'.$locale['331'].'<br/>
|
||||
<table><tr><td class=sinborde>
|
||||
<form action="administracion_alarmas.php?order=periodicidad" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/asc.png">';
|
||||
echo '</form></td><td class=sinborde>';
|
||||
echo '<form action="administracion_alarmas.php?order=periodicidad&orden=desc" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/desc.png">';
|
||||
echo '</form></td></tr></table>';
|
||||
echo '<td align="center">'.$locale['1530'].'<br/>
|
||||
<table><tr><td class=sinborde>
|
||||
<form action="administracion_alarmas.php?order=rol" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/asc.png">';
|
||||
echo '</form></td><td class=sinborde>';
|
||||
echo '<form action="administracion_alarmas.php?order=rol&orden=desc" method="POST">';
|
||||
echo '<input type="image" name="menos" src="css/desc.png">';
|
||||
echo '</form></td></tr></table>';
|
||||
echo '</td>';
|
||||
echo '<td align="center" colspan="2">Acciones</td>';
|
||||
|
||||
while ($row = mysql_fetch_array($resultado)){
|
||||
$id = $row["id"];
|
||||
$nombre = $row["nombre"];
|
||||
$periodicidad = $row["periodicidad"];
|
||||
$rol = $row["rol"];
|
||||
$prioridad = $row["prioridad"];
|
||||
|
||||
if($rol == "") $rol = "GLOBAL";
|
||||
|
||||
//Escribimos los resultados
|
||||
echo "<tr>";
|
||||
echo '<td align="left">'.$nombre.'</td>';
|
||||
echo '<td align="left">'.discretiza_prioridad($prioridad).'</td>';
|
||||
echo '<td align="left">'.periodicidad($periodicidad).'</td>';
|
||||
echo '<td align="left">'.$rol.'</td>';
|
||||
echo '<td align="center">
|
||||
<form action="formulario_alarma.php?oid='.$id.'" method="post">
|
||||
<input type="image" src="css/edit.png"></td>';
|
||||
echo '</form>';
|
||||
echo '<form action="eliminar_alarma.php" method="POST">';
|
||||
echo '<input type="hidden" name="oid" value="'.$id.'">';
|
||||
echo '<td align="center"><input type="image" name="eliminar" src="css/eliminar.png" onclick="return eliminar_alarma(this)"></td>';
|
||||
echo '</form>';
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
//Calculamos el número de páginas y mostramos la navegación
|
||||
$paginas = $cont / $limit;
|
||||
if($limit < $cont){
|
||||
echo '<br><center><table align="center"><tr class=encabezado>';
|
||||
if($limit <= $offset){
|
||||
echo '<form action="administracion_alarmas.php?orden='.$orden.'&order='.$order.'&offset='.($offset-$limit).'" method="POST">';
|
||||
echo '<td align="center"><input type="image" name="menos" src="css/flecha_menos.gif"></td>';
|
||||
echo '</form>';
|
||||
}
|
||||
for($i = 0; $i < $paginas; $i++){
|
||||
if(($i*$limit) == $offset){
|
||||
echo "<td>".($i+1)."</td>";
|
||||
}else{
|
||||
echo '<form action="administracion_alarmas.php?orden='.$orden.'&order='.$order.'&offset='.($i*$limit).'" method="POST">';
|
||||
echo '<td align="center"><input type="submit" class="paginado" name="menos" value="'.($i+1).'"></td>';
|
||||
echo '</form>';
|
||||
}
|
||||
}
|
||||
if(($limit*$offset+1) < $cont){
|
||||
echo '<form action="administracion_alarmas.php?orden='.$orden.'&order='.$order.'&offset='.($offset+$limit).'" method="POST">';
|
||||
echo '<td align="center"><input type="image" name="mas" src="css/flecha_mas.gif"></td>';
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</tr></table></center>';
|
||||
}
|
||||
}else{
|
||||
echo "<p>".$locale['307']."</p>";
|
||||
}
|
||||
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
115
src/administracion_festivos.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
include_once("seguridad.php");
|
||||
include_once("functions.php");
|
||||
include_once("Objects/Administracion.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
include_once("Objects/Calendario.php");
|
||||
|
||||
$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'];
|
||||
|
||||
$back="administracion_festivos.php";
|
||||
switch ($_POST['action'] ) {
|
||||
case "actualizar":// recorremos todos los días para ver cual está on
|
||||
try{
|
||||
for($mesVer=1;$mesVer<=12;$mesVer++){
|
||||
$diasFestivos=array();
|
||||
$calendarioAct=new Calendario($usuario,$mesVer,$ano_hoy,array(),"",$locale);
|
||||
for($diaVer=1;$diaVer<=31;$diaVer++){
|
||||
if($_POST[$ano_hoy."-".$mesVer."-".$diaVer]=="on"){
|
||||
$diasFestivos[]=$diaVer;
|
||||
}
|
||||
}
|
||||
$calendarioAct->setFestivosNacional($diasFestivos);
|
||||
$msg=$locale['2312'].$locale['2303'];
|
||||
$tipo="ok";
|
||||
}
|
||||
} catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function cambiaFecha(){
|
||||
var anio=document.getElementById('anioSelect').value;
|
||||
document.location="administracion_festivos.php?anio="+anio;
|
||||
}
|
||||
|
||||
-->
|
||||
</script>
|
||||
<h2><?php echo $locale['219']; ?></h2>
|
||||
<?php if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
} ?>
|
||||
<ul id="tabnav">
|
||||
<li class='activo'><a href="administracion_festivos.php">Nacional</a></li>
|
||||
<li class='inactivo'><a href="administracion_festivosLocal.php">Locales</a></li>
|
||||
</ul>
|
||||
<div id="ContTabul">
|
||||
<form action="administracion_festivos.php" method="post" >
|
||||
<input type="hidden" name="action" value="actualizar" />
|
||||
<?php echo $locale['412']; ?>:<select name="anio" onChange="javascript:cambiaFecha()" id="anioSelect">
|
||||
<?php
|
||||
for($i=2008;$i<=2010;$i++){
|
||||
echo "<option value=\"".$i."\" ";
|
||||
if($i == $ano_hoy){
|
||||
echo " selected ";
|
||||
}
|
||||
echo " >".$i."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="<?php echo $locale['ac'];?>" value="<?php echo $locale['ac'];?>" class="button" />
|
||||
<?php
|
||||
for($mes_mostrar=1;$mes_mostrar<=12;$mes_mostrar++){
|
||||
?>
|
||||
<div style="float:left;margin-left:10px; margin-bottom:10px">
|
||||
<?php
|
||||
// Mostramos el mes actual
|
||||
$calendario=new Calendario($usuario,$mes_mostrar,$ano_hoy,array(),"",$locale);
|
||||
$diasEsp=array();
|
||||
for($dia=1;$dia<=31;$dia++){
|
||||
if(!$calendario->esFestivo($usuario->getValor("localidad_trabajo"),$dia)){
|
||||
$chek="<input type=\"checkbox\" name=\"".$ano_hoy."-".$mes_mostrar."-".$dia."\" />";
|
||||
$diasEsp[$dia]["texto"]=$chek;
|
||||
} elseif ($calendario->esFestivoNacional($dia)) {
|
||||
// Es festivo porque es local
|
||||
$chek=$chek="<input type=\"checkbox\" name=\"".$ano_hoy."-".$mes_mostrar."-".$dia."\" checked=\"checked\" />";
|
||||
$diasEsp[$dia]["texto"]=$chek;
|
||||
$diasEsp[$dia]["color"]="#FF3535";
|
||||
}
|
||||
}
|
||||
echo $calendario->getCalendar($diasEsp,"g");
|
||||
// Fin de mostrar el mes
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if($mes_mostrar%2==0){
|
||||
echo "<div style=\"clear:both;\"></div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<input type="submit" name="<?php echo $locale['ac'];?>" value="<?php echo $locale['ac'];?>" class="button" />
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
132
src/administracion_festivosLocal.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
include_once("seguridad.php");
|
||||
include_once("functions.php");
|
||||
include_once("Objects/Administracion.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
include_once("Objects/Calendario.php");
|
||||
include_once("Objects/Administracion.php");
|
||||
|
||||
$administracion = new Administracion($usuario,$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'];
|
||||
|
||||
$back="administracion_festivos.php";
|
||||
$localidades=$administracion->getItem("localidad");
|
||||
$localidad=array_shift(array_keys($localidades));
|
||||
if($_GET['localidad']!="") $localidad=$_GET['localidad'];
|
||||
if($_POST['campoSelect']!="") $localidad=$_POST['campoSelect'][0];
|
||||
|
||||
switch ($_POST['action'] ) {
|
||||
case "actualizar":// recorremos todos los días para ver cual está on
|
||||
try{
|
||||
for($mesVer=1;$mesVer<=12;$mesVer++){
|
||||
$diasFestivos=array();
|
||||
$calendarioAct=new Calendario($usuario,$mesVer,$ano_hoy,array(),"",$locale);
|
||||
for($diaVer=1;$diaVer<=31;$diaVer++){
|
||||
if($_POST[$ano_hoy."-".$mesVer."-".$diaVer]=="on"){
|
||||
$diasFestivos[]=$diaVer;
|
||||
}
|
||||
}
|
||||
$calendarioAct->setFestivosLocal($diasFestivos,$localidad);
|
||||
$msg=$locale['2312'].$locale['2303'];
|
||||
$tipo="ok";
|
||||
}
|
||||
} catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function cambiaFecha(){
|
||||
var anio=document.getElementById('anioSelect').value;
|
||||
var localidad=document.getElementById('campoSelect').value;
|
||||
document.location="administracion_festivosLocal.php?anio="+anio+"&localidad="+localidad;
|
||||
}
|
||||
|
||||
-->
|
||||
</script>
|
||||
<h2><?php echo $locale['219']; ?></h2>
|
||||
<?php if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
} ?>
|
||||
<ul id="tabnav">
|
||||
<li class='inactivo'><a href="administracion_festivos.php">Nacional</a></li>
|
||||
<li class='activo'><a href="administracion_festivosLocal.php">Locales</a></li>
|
||||
</ul>
|
||||
<div id="ContTabul">
|
||||
<form action="administracion_festivosLocal.php" method="post" >
|
||||
<input type="hidden" name="action" value="actualizar" />
|
||||
<?php echo $locale['412']; ?>:<select name="anio" onChange="javascript:cambiaFecha()" id="anioSelect">
|
||||
<?php
|
||||
for($i=2008;$i<=2010;$i++){
|
||||
echo "<option value=\"".$i."\" ";
|
||||
if($i == $ano_hoy){
|
||||
echo " selected ";
|
||||
}
|
||||
echo " >".$i."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
$selectLocalidades=$html->listaSelectAnidada("localidades","provincias","oid","id","provincia","id","campoSelect",false,"1",array($localidad),true);
|
||||
// Añadimos el onChange a la select
|
||||
$selectLocalidades=str_replace("<select","<select onChange=\"javascript:cambiaFecha()\"",$selectLocalidades);
|
||||
echo $selectLocalidades;
|
||||
?>
|
||||
<input type="submit" name="<?php echo $locale['ac'];?>" value="<?php echo $locale['ac'];?>" class="button" />
|
||||
<?php
|
||||
for($mes_mostrar=1;$mes_mostrar<=12;$mes_mostrar++){
|
||||
?>
|
||||
<div style="float:left;margin-left:10px; margin-bottom:10px">
|
||||
<?php
|
||||
// Mostramos el mes actual
|
||||
$calendario=new Calendario($usuario,$mes_mostrar,$ano_hoy,array(),"",$locale);
|
||||
$diasEsp=array();
|
||||
for($dia=1;$dia<=31;$dia++){
|
||||
if(!$calendario->esFestivo($localidad,$dia)){
|
||||
// No es festivo
|
||||
$chek="<input type=\"checkbox\" name=\"".$ano_hoy."-".$mes_mostrar."-".$dia."\" />";
|
||||
$diasEsp[$dia]["texto"]=$chek;
|
||||
} elseif ($calendario->esFestivoLocal($localidad,$dia)) {
|
||||
// Es festivo porque es local
|
||||
$chek=$chek="<input type=\"checkbox\" name=\"".$ano_hoy."-".$mes_mostrar."-".$dia."\" checked=\"checked\" />";
|
||||
$diasEsp[$dia]["texto"]=$chek;
|
||||
$diasEsp[$dia]["color"]="#FF3535";
|
||||
}
|
||||
}
|
||||
echo $calendario->getCalendar($diasEsp,"g");
|
||||
// Fin de mostrar el mes
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if($mes_mostrar%2==0){
|
||||
echo "<div style=\"clear:both;\"></div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<input type="submit" name="<?php echo $locale['ac'];?>" value="<?php echo $locale['ac'];?>" class="button" />
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
21
src/administracion_principal.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
|
||||
/* ADMINISTRACION_PRINCIPAL.PHP */
|
||||
$rol = stripinput($_GET["rol"]);
|
||||
|
||||
echo "<h2>".$rol."</h2>";
|
||||
|
||||
/* ------------ PERFIL */
|
||||
//echo "<table width=100%><tr>";
|
||||
// menu_rol($rol);
|
||||
//echo "</tr></table>";
|
||||
$html->menuOpcion($usuario,$rol);
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
73
src/administracion_roles.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
if (!comprobar_permisos("AS")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
|
||||
/* MODIFICAR_USUARIOS.PHP */
|
||||
|
||||
echo "<h2>".$locale['215']."</h2>";
|
||||
echo "<br/>";
|
||||
$e = stripinput($_GET["e"]);
|
||||
$a = stripinput($_GET["a"]);
|
||||
$rol = stripinput($_GET["rol"]);
|
||||
|
||||
$link = conectar();
|
||||
|
||||
$consulta = "select * from rol";
|
||||
$resultado = mysql_query($consulta,$link);
|
||||
|
||||
echo '<ul id="tabnav">';
|
||||
while($rows = mysql_fetch_array($resultado)){
|
||||
if($rol != $rows["id"]){
|
||||
echo "<li class='activo'>";
|
||||
}else{
|
||||
$permisos = $rows["permisos"];
|
||||
$opciones = $rows["opciones"];
|
||||
echo "<li class='inactivo'>";
|
||||
}
|
||||
echo "<a href='administracion_roles.php?rol=".$rows["id"]."'>".$rows["id"]."</a></li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div id="ContTabul">';
|
||||
if($rol != ""){
|
||||
echo '<form action="editar_rol.php" method="POST" name="form_rol">';
|
||||
echo '<input type="text" name="rol" value="'.$rol.'"><br>';
|
||||
echo '<input type="hidden" name="id" value="'.$rol.'"><br>';
|
||||
$permisos = explode(".", $permisos);
|
||||
$opciones = explode(".", $opciones);
|
||||
echo '<p><b>'.$locale['281'].'</b></p>';
|
||||
ver_permisos($permisos);
|
||||
echo '<br><table><tr><td class=sinborde><input type="submit" name="enviar" value="'.$locale['262'].'" class="button">';
|
||||
echo '</form></td>';
|
||||
echo '<td class=sinborde><form action="tablas_madre.php?opcion=rol&action=eliminar" method="POST" name="form_e_rol">';
|
||||
echo '<input type="hidden" name="rol" value="'.$rol.'">';
|
||||
echo '<input type="submit" name="enviar" value="'.$locale['263'].'" onclick="return admin_e_rol()" class="button">';
|
||||
echo '</form></td></tr></table>';
|
||||
}else{
|
||||
echo "<p>".$locale['215']."</p>";
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
/* ------------ ROLES */
|
||||
echo "<p><b>".$locale['264']."</b></p>";
|
||||
echo '<form action="tablas_madre.php?opcion=rol&accion=insertar" method="POST" name="form_i_rol">
|
||||
<tr>
|
||||
<td align="right" width="100">'.$locale['223'].'</td>
|
||||
<td><input type="text" name="cadena" size="30" maxlength="100"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" name="enviar" value="'.$locale['265'].'" onclick="return admin_i_rol()" class="button"></td>
|
||||
</tr>
|
||||
</form>';
|
||||
/* ------------ ROLES */
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
81
src/administracion_salarios.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
include_once("seguridad.php");
|
||||
include_once("functions.php");
|
||||
include_once("Objects/Administracion.php");
|
||||
|
||||
if(!$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/HTML.php");
|
||||
include_once("Objects/Administracion.php");
|
||||
$html=new HTML($locale);
|
||||
if($_POST['action']!=""){
|
||||
$administrador=new Administracion($usuario,$locale);
|
||||
switch ($_POST['action']) {
|
||||
case "Editar":$texto=$_POST['editName'];
|
||||
try{
|
||||
$cod=$_POST['campoSelect'];
|
||||
$texto=array_merge($cod,$texto);
|
||||
$administrador->editItem("salario",$texto);
|
||||
$msg=$locale['2300'].$locale['2303'];
|
||||
$tipo="ok";
|
||||
} catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
break;
|
||||
case "Eliminar":
|
||||
$cod=$_POST['campoSelect'];
|
||||
$cod=$cod[0];
|
||||
try{
|
||||
$administrador->removeItem("salario",$cod);
|
||||
$msg=$locale['2301'].$locale['2303'];
|
||||
$tipo="ok";
|
||||
} catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Anadir": $texto=$_POST['newName'];
|
||||
try{
|
||||
$administrador->addItem("salario",$texto);
|
||||
$msg=$locale['2302'].$locale['2303'];
|
||||
$tipo="ok";
|
||||
} catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
$tipo="error";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!-- ADMINISTRACI<EFBFBD>N_SALARIOS.PHP -->
|
||||
|
||||
<h2><?php echo $locale['500']; ?></h2>
|
||||
<?php if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
} ?>
|
||||
<div id="ContTabul">
|
||||
<script src="js/adminTablas.js" language="JavaScript" type="text/javascript"></script>
|
||||
<form id="formularioMantenimiento" action="administracion_salarios.php" method="post">
|
||||
<?php
|
||||
echo $html->adminTabla2("salario","id","nombre");
|
||||
|
||||
?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
119
src/agenda.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/Agenda.php");
|
||||
|
||||
$dia_hoy=date("d");
|
||||
if($_GET['dia']!="") $dia_hoy=$_GET['dia'];
|
||||
if($_POST['dia']!="") $dia_hoy=$_POST['dia'];
|
||||
|
||||
$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'];
|
||||
|
||||
|
||||
// Recuperamos información para el mini calendario
|
||||
$dia_cal=$dia_hoy;
|
||||
if($_GET['diaCal']!="") $dia_cal=$_GET['diaCal'];
|
||||
if($_POST['diaCal']!="") $dia_cal=$_POST['diaCal'];
|
||||
|
||||
|
||||
$mes_cal=$mes_hoy;
|
||||
if($_GET['mesCal']!="") $mes_cal=$_GET['mesCal'];
|
||||
if($_POST['mesCal']!="") $mes_cal=$_POST['mesCal'];
|
||||
|
||||
|
||||
$ano_cal=$ano_hoy;
|
||||
if($_GET['anioCal']!="") $ano_cal=$_GET['anioCal'];
|
||||
if($_POST['anioCal']!="") $ano_cal=$_POST['anioCal'];
|
||||
|
||||
$hoy=mktime(0,0,0,$mes_hoy,$dia_hoy,$ano_hoy);
|
||||
$manana=mktime(0,0,0,$mes_hoy,$dia_hoy+1,$ano_hoy);
|
||||
$ayer=mktime(0,0,0,$mes_hoy,$dia_hoy-1,$ano_hoy);
|
||||
|
||||
$agenda=new Agenda($usuario,$hoy,$locale);
|
||||
?>
|
||||
<h2><?php echo $locale['716']; ?></h2>
|
||||
<?php
|
||||
if($_POST['action']){
|
||||
switch ($_POST['action']) {
|
||||
case "actualizar":
|
||||
try{
|
||||
for($i=0;$i<=23;$i++){
|
||||
$agenda->setAgenda($i,$_POST['h'.$i]);
|
||||
}
|
||||
$tipo="ok";
|
||||
$msg=$locale['717'];
|
||||
}catch (Exception $e){
|
||||
$tipo="error";
|
||||
$msg=$e->getMessage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($msg!=""){
|
||||
echo "<div class=\"aviso ".$tipo."\">".$msg."</div>";
|
||||
}
|
||||
?>
|
||||
<div id="ContTabul">
|
||||
|
||||
<p class="encabezado" align="center">
|
||||
<a href="agenda.php?dia=<?php echo date("j",$ayer);?>&mes=<?php echo date("m",$ayer);?>&anio=<?php echo date("Y",$ayer);?>">
|
||||
<img src='css/flecha_menos.gif'>
|
||||
</a>
|
||||
<span class="encabezado"><?php echo nombre_dia(date("N",$hoy));?> <?php echo ver_fecha_larga(date("Y-n-d",$hoy));?></span>
|
||||
<a href="agenda.php?dia=<?php echo date("j",$manana);?>&mes=<?php echo date("m",$manana);?>&anio=<?php echo date("Y",$manana);?>">
|
||||
<img src='css/flecha_mas.gif'>
|
||||
</a>
|
||||
</p>
|
||||
<div style="float:left;">
|
||||
<form action="agenda.php" method="post">
|
||||
<input type="hidden" name="action" value="actualizar" />
|
||||
<input type="hidden" name="mes" value="<?php echo date("m",$hoy); ?>" />
|
||||
<input type="hidden" name="anio" value="<?php echo date("Y",$hoy); ?>" />
|
||||
<input type="hidden" name="dia" value="<?php echo date("j",$hoy); ?>" />
|
||||
<input type="hidden" name="mesCal" value="<?php echo $mes_cal; ?>" />
|
||||
<input type="hidden" name="anioCal" value="<?php echo $ano_cal; ?>" />
|
||||
|
||||
<table cellpadding="0" cellspacing="1" width="400" class="agenda">
|
||||
<tr class="encabezado">
|
||||
<th width="50">Hora</th>
|
||||
<th>Observacion</th>
|
||||
</tr>
|
||||
<?php
|
||||
for($hora=0;$hora<=23;$hora++){
|
||||
?>
|
||||
<tr>
|
||||
<td class="agendaTitDia"><?php echo $hora;?>:00</td>
|
||||
<td><textarea name="h<?php echo $hora;?>"><?php echo $agenda->getObservacion($hora); ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</table
|
||||
<br />
|
||||
<input type="submit" value="<?php echo $locale['ac']." ".$locale['702']; ?>" class="button" />
|
||||
</div>
|
||||
<div style="float:left;padding-left:20px">
|
||||
<?php
|
||||
include_once("Objects/Calendario.php");
|
||||
$calendario=new Calendario($usuario,$mes_cal,$ano_cal,"","agenda.php",$locale);
|
||||
echo $calendario->getMiniAgenda($hoy);
|
||||
?>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
|
||||
</div>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
111
src/alarmas.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
if(!$_SESSION["oid"]){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
}
|
||||
|
||||
if($link = conectar()){
|
||||
$rol = $_SESSION["rol"];
|
||||
$consulta = "select * from alarmas where rol='$rol' or rol is null order by prioridad";
|
||||
$resultado = mysql_query($consulta, $link);
|
||||
$alarmas = "";
|
||||
|
||||
//Comprobamos todas las alarmas asociadas a nuestro rol para mostrar las activas.
|
||||
while($rows=mysql_fetch_array($resultado)){
|
||||
$id = $rows["id"];
|
||||
$nombre = $rows["nombre"];
|
||||
$periodicidad = $rows["periodicidad"];
|
||||
$mensaje = $rows["mensaje"];
|
||||
$rol = $rows["rol"];
|
||||
$activacion = $rows["activacion"];
|
||||
$duracion = $rows["duracion"];
|
||||
$prioridad = $rows["prioridad"];
|
||||
$flag = $rows["flag"];
|
||||
$mail = $rows["mail"];
|
||||
$valor = nivel_alarma($prioridad);
|
||||
|
||||
if($periodicidad == "d"){
|
||||
if(alarma_diaria($activacion, $duracion)){
|
||||
$alarmas .= ver_alarma($valor, $nombre, $mensaje);
|
||||
if($flag == 0){
|
||||
set_flag($id, 1);
|
||||
if($mail == 1){
|
||||
mail_alarma($nombre, $mensaje, $rol);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($flag == 1){
|
||||
set_flag($id, 0);
|
||||
}
|
||||
}
|
||||
}else if($periodicidad == "s"){
|
||||
$mes = date("n");
|
||||
$dia = date("j");
|
||||
$ano = date("Y");
|
||||
$dia_semana = dia_semana($dia, $mes, $ano);
|
||||
if(alarma_semanal($activacion, $duracion, $dia_semana)){
|
||||
if($flag == 0){
|
||||
set_flag($id, 1);
|
||||
if($mail == 1){
|
||||
mail_alarma($nombre, $mensaje, $rol);
|
||||
}
|
||||
}
|
||||
$alarmas .= ver_alarma($valor, $nombre, $mensaje);
|
||||
}else{
|
||||
if($flag == 1){
|
||||
set_flag($id, 0);
|
||||
}
|
||||
}
|
||||
}else if($periodicidad == "m"){
|
||||
if($dia <= 0){
|
||||
$mes = date("n");
|
||||
$dia = date("j");
|
||||
$ano = date("Y");
|
||||
}
|
||||
if(alarma_mensual($activacion, $duracion, $dia)){
|
||||
if($flag == 0){
|
||||
set_flag($id, 1);
|
||||
if($mail == 1){
|
||||
mail_alarma($nombre, $mensaje, $rol);
|
||||
}
|
||||
}
|
||||
$alarmas .= ver_alarma($valor, $nombre, $mensaje);
|
||||
}else{
|
||||
if($flag == 1){
|
||||
set_flag($id, 0);
|
||||
}
|
||||
}
|
||||
}else if($periodicidad == "a"){
|
||||
if($dia <= 0){
|
||||
$mes = date("n");
|
||||
$dia = date("j");
|
||||
$ano = date("Y");
|
||||
}
|
||||
if(alarma_anual($activacion, $duracion, $dia, $mes, $ano)){
|
||||
$alarmas .= ver_alarma($valor, $nombre, $mensaje);
|
||||
if($flag == 0){
|
||||
set_flag($id, 1);
|
||||
if($mail == 1){
|
||||
mail_alarma($nombre, $mensaje, $rol);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($flag == 1){
|
||||
set_flag($id, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($alarmas != ""){
|
||||
echo "<table align=right><tr><td class=sinborde>";
|
||||
echo $alarmas;
|
||||
echo "</td></tr></table>";
|
||||
}else{
|
||||
//echo "<p><font size=6 color=green><b>".$locale[330]."</b></font></p>";
|
||||
}
|
||||
|
||||
}else{
|
||||
echo "<p>".$locale['bd']."</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
18
src/aplicacion.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
|
||||
/* APLICACION.PHP */
|
||||
|
||||
echo "<h2>".$locale['002']."</h2>";
|
||||
|
||||
if($_SESSION["oid"]){
|
||||
include_once("alarmas.php");
|
||||
}
|
||||
$usuario->compruebaChangePass();
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
33
src/backup_bd.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include_once("seguridad.php");
|
||||
include_once("functions.php");
|
||||
include_once("Objects/Backup.php");
|
||||
|
||||
if(!$usuario->tieneRol("2")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
try{
|
||||
$backup = new Backup($usuario);
|
||||
$ruta = $backup->backupGlobal();
|
||||
include_once("Objects/Administracion.php");
|
||||
$administracion=new Administracion($usuario,$locale);
|
||||
$constantes=$administracion->getItem("constantes");
|
||||
$url = $constantes['srcDocs'];
|
||||
|
||||
$ruta="descargas.php?tipo=back&cod=".$ruta;
|
||||
|
||||
?>
|
||||
|
||||
<iframe id="file_download" width="0" height="0" scrolling="no" frameborder="0" src="<?php echo $ruta;?>"></iframe>
|
||||
<?php
|
||||
echo $locale['1816'];
|
||||
|
||||
echo "<a href='$ruta'>Descargar</a>";
|
||||
}catch (Exception $e) {
|
||||
$msg=$e->getMessage();
|
||||
include_once("showError.php");
|
||||
}
|
||||
|
||||
?>
|
||||
21
src/borrar_curriculum.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
$oid = stripinput($_GET["oid"]);
|
||||
$curriculum = stripinput($_GET["curriculum"]);
|
||||
$fecha = stripinput($_GET["fecha"]);
|
||||
$tipo = stripinput($_GET["tipo"]);
|
||||
|
||||
if($tipo == "candidato"){
|
||||
$c = new Candidato($_SESSION["usuario"], $oid);
|
||||
$c->removeCurriculum($curriculum, $fecha);
|
||||
}
|
||||
|
||||
if($tipo == "usuario"){
|
||||
header("Location: usuarios.php?oid=$oid&e=$errores&a=$aciertos");
|
||||
}else if($tipo == "candidato"){
|
||||
header("Location: gestion_candidato.php?oid=$oid");
|
||||
}
|
||||
?>
|
||||
38
src/buscar_candidato.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
// Sólo los administradores y rrhh pueden buscar
|
||||
if(!$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* BUSCAR.PHP */
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
echo $html->menuCandidatos();
|
||||
|
||||
$tipobusqueda="candidato";
|
||||
?>
|
||||
<h2><?php echo $locale['820']; ?></h2>
|
||||
|
||||
<div id="ContTabul">
|
||||
<form action="busqueda_candidato_multiple.php" method="POST" name="form_busqueda_multiple">
|
||||
<?php include_once("formulario_buscar_persona.php"); ?>
|
||||
<table align="center" width="100%" cellspacing="2" cellpadding="2" border="0">
|
||||
<tr>
|
||||
<td class="sinborde" align="center">
|
||||
<input type="submit" name="enviar" value="Buscar" class="button" onclick="return comprobar_busqueda_multiple(this)">
|
||||
<input type="reset" name="borrar" value="Borrar" class="button" >
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
38
src/buscar_empleado.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
// Sólo los administradores y rrhh pueden buscar
|
||||
if(!$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* BUSCAR.PHP */
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
echo $html->menuEmpleados();
|
||||
|
||||
$tipobusqueda="usuario";
|
||||
?>
|
||||
<h2><?php echo $locale['817']; ?></h2>
|
||||
|
||||
<div id="ContTabul">
|
||||
<form action="busqueda_empleado_multiple.php" method="POST" name="form_busqueda_multiple">
|
||||
<?php include_once("formulario_buscar_persona.php"); ?>
|
||||
<table align="center" width="100%" cellspacing="2" cellpadding="2" border="0">
|
||||
<tr>
|
||||
<td class="sinborde" align="center">
|
||||
<input type="submit" name="enviar" value="Buscar" class="button" onclick="return comprobar_busqueda_multiple(this)">
|
||||
<input type="reset" name="borrar" value="Borrar" class="button" >
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
86
src/buscar_pedido.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
// Sólo los gerentes, administradores y rrhh pueden buscar
|
||||
if(!$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("3")
|
||||
&& !$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* BUSCAR_PROYECTOS.PHP */
|
||||
include_once("Objects/HTML.php");
|
||||
$html=new HTML($locale);
|
||||
echo $html->menuPedidos($usuario,"");
|
||||
?>
|
||||
<h2><?php echo $locale['800']; ?></h2>
|
||||
<form action="busqueda_pedidos_multiple.php" method="POST" name="form_busqueda_pedidos_multiple">
|
||||
|
||||
<table align="center" width="80%" cellspacing="2" cellpadding="2" border="0">
|
||||
<tr>
|
||||
<td><?php echo $locale['1043']; ?><input type="text" name="nombre" value="" size="30" maxlength="30"></td>
|
||||
<td><?php echo $locale['1022'];
|
||||
rellena_prioridad_select("prioridad",0,5,"");
|
||||
|
||||
?></td>
|
||||
<td><?php echo $locale['1027'];
|
||||
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
|
||||
rellena_personal_permiso("gerente","GP",$auxiliar,$gerente);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $locale['1504'];
|
||||
rellena_desplegable_select_oid("clientes","clientes",$auxiliar,$cliente);
|
||||
?></td>
|
||||
<td><?php echo $locale['121'];
|
||||
rellena_desplegable_select_oid("perfil","perfil",$auxiliar,$perfil);
|
||||
?></td>
|
||||
<td><?php echo $locale['132'];
|
||||
rellena_desplegable_select_oidCol("pedidos_estados","cod","nombre","estado",$auxiliar,$estado);
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
<td><?php echo $locale['1800'];
|
||||
rellena_procedencias("procedencia",$auxiliar,$procedencia);
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<table><tr>
|
||||
<td align="right"><?php echo $locale['122']; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
echo $html->listaSelect("tecnologia","oid","id","tecnologia",array("",$locale['ns']." ".$locale['1074']),array(),true,true,"15");
|
||||
?>
|
||||
</td>
|
||||
<td align="right"><?php echo $locale['123'];?></td>
|
||||
<td>
|
||||
<?php
|
||||
echo $html->listaSelect("idiomas","oid","id","idiomas",array("",$locale['ns']." ".$locale['1075']),array(),true,true,"15");
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td align="right"><?php echo $locale['209'];?></td><td>
|
||||
<?php
|
||||
|
||||
echo $html->listaSelect("provincias","oid","id","provincias",array("",$locale['ns']." ".$locale['1076']),array(),true,true,"15");
|
||||
?>
|
||||
</td>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center">
|
||||
<input type="submit" name="enviar" value="Buscar" class="button" onclick="return comprobar_busqueda_multiple(this)">
|
||||
<input type="reset" name="borrar" value="Borrar" class="button" >
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
include_once("html/pie.php");
|
||||
?>
|
||||
65
src/busqueda_candidato_multiple.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
// Sólo los administradores y rrhh pueden buscar
|
||||
if(!$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* BUSQUEDA.PHP */
|
||||
include_once("Objects/HTML.php");
|
||||
$html = new HTML($locale);
|
||||
|
||||
echo $html->menuCandidatos();
|
||||
|
||||
?>
|
||||
<h2><?php echo $locale['820']; ?></h2>
|
||||
<?php
|
||||
|
||||
$where = "";
|
||||
$tabla = "";
|
||||
|
||||
include_once("Objects/ListaCandidatos.php");
|
||||
|
||||
// Agregamos el estado de los pedidos que queremos mostrar
|
||||
if(($_GET['byEstado']!="") && ($_GET['byEstado']!="0")){
|
||||
$tipoPedidos=$_GET['byEstado'];
|
||||
$whereTipo=" and estado=".$tipoPedidos;
|
||||
} else {
|
||||
$tipoPedidos="0";
|
||||
$whereTipo="";
|
||||
}
|
||||
|
||||
// Variables por si es una ordenacion
|
||||
$order_by="";
|
||||
if($_GET["order"]!=""){
|
||||
$order_by = " ORDER by ".stripinput($_GET["order"])." ".$_GET["modo"];
|
||||
}
|
||||
if($_GET['reutilizar']=="si"){
|
||||
$listaCandidatos = unserialize($_SESSION["ultimaBusquedaCandidatos"]);
|
||||
// creamos el nuevo objeto con el orden
|
||||
$sql=$listaCandidatos->getSQL();
|
||||
$listaCandidatos=new ListaCandidatos($usuario,$order_by,$sql,$tipoPedidos);
|
||||
}else{
|
||||
// Recuperamos todos los valores
|
||||
include_once("campos_persona.php");
|
||||
// Construimos la sql
|
||||
$condicion = "usuarios.tipo = 'candidato',";
|
||||
include_once("busqueda_personas_multiple.php");
|
||||
$listaCandidatos=new ListaCandidatos($usuario,$order_by,$consulta,$tipoPedidos);
|
||||
}
|
||||
$s = serialize($listaCandidatos);
|
||||
$_SESSION["ultimaBusquedaCandidatos"]=$s;
|
||||
$variablesExtra="reutilizar=si";
|
||||
|
||||
|
||||
include_once("ver_lista_candidatos.php");
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
65
src/busqueda_empleado_multiple.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
// Sólo los administradores y rrhh pueden buscar
|
||||
if(!$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("4")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
/* BUSQUEDA.PHP */
|
||||
include_once("Objects/HTML.php");
|
||||
$html = new HTML($locale);
|
||||
|
||||
echo $html->menuEmpleados();
|
||||
|
||||
?>
|
||||
<h2><?php echo $locale['817']; ?></h2>
|
||||
<?php
|
||||
|
||||
$where = "";
|
||||
$tabla = "";
|
||||
|
||||
include_once("Objects/ListaEmpleados.php");
|
||||
|
||||
// Agregamos el estado de los pedidos que queremos mostrar
|
||||
if(($_GET['byEstado']!="") && ($_GET['byEstado']!="0")){
|
||||
$tipoPedidos=$_GET['byEstado'];
|
||||
$whereTipo=" and estado=".$tipoPedidos;
|
||||
} else {
|
||||
$tipoPedidos="0";
|
||||
$whereTipo="";
|
||||
}
|
||||
|
||||
// Variables por si es una ordenacion
|
||||
$order_by="";
|
||||
if($_GET["order"]!=""){
|
||||
$order_by = " ORDER by ".stripinput($_GET["order"])." ".$_GET["modo"];
|
||||
}
|
||||
if($_GET['reutilizar']=="si"){
|
||||
$listaEmpleados = unserialize($_SESSION["ultimaBusquedaEmpleados"]);
|
||||
// creamos el nuevo objeto con el orden
|
||||
$sql=$listaEmpleados->getSQL();
|
||||
$listaEmpleados=new ListaEmpleados($usuario,$order_by,$sql,$tipoPedidos);
|
||||
}else{
|
||||
// Recuperamos todos los valores
|
||||
include_once("campos_persona.php");
|
||||
// Construimos la sql
|
||||
$condicion = "usuarios.tipo = 'usuario',";
|
||||
include_once("busqueda_personas_multiple.php");
|
||||
$listaEmpleados=new ListaEmpleados($usuario,$order_by,$consulta,$tipoPedidos);
|
||||
}
|
||||
$s = serialize($listaEmpleados);
|
||||
$_SESSION["ultimaBusquedaEmpleados"]=$s;
|
||||
$variablesExtra="reutilizar=si";
|
||||
|
||||
|
||||
include_once("ver_lista_empleados.php");
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
172
src/busqueda_pedidos_multiple.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
if(!$usuario->tieneRol("4")
|
||||
&& !$usuario->tieneRol("1")
|
||||
&& !$usuario->tieneRol("3")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
include_once("Objects/HTML.php");
|
||||
$html = new HTML($locale);
|
||||
|
||||
/* BUSQUEDA.PHP */
|
||||
|
||||
echo $html->menuPedidos($usuario,"");
|
||||
echo "<h2>".$locale['808']."</h2>";
|
||||
|
||||
$order = stripinput($_GET["order"]);
|
||||
$order_by = stripinput($order);
|
||||
$orden = stripinput($_GET["orden"]);
|
||||
$offset = stripinput($_GET["offset"]);
|
||||
|
||||
if ($order_by == "")
|
||||
$order_by = "nombre";
|
||||
else if ($orden != "")
|
||||
$order_by .= " DESC";
|
||||
|
||||
if(!isset($offset)){
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
include_once("campos_pedido.php");
|
||||
|
||||
$where = "";
|
||||
$tabla = "";
|
||||
|
||||
if ($nombre != ""){
|
||||
$condicion .= "pedidos.nombre like '%".$nombre."%',";
|
||||
}
|
||||
|
||||
if ($gerente != ""){
|
||||
$condicion .= "pedidos.gerente = '".$gerente."',";
|
||||
}
|
||||
|
||||
if ($cliente != ""){
|
||||
$condicion .= "pedidos.cliente = '".$cliente."',";
|
||||
}
|
||||
|
||||
if ($estado != ""){
|
||||
$condicion .= "pedidos.estado = '".$estado."',";
|
||||
}
|
||||
|
||||
if ($procedencia != ""){
|
||||
$condicion .= "pedidos.procedencia = '".$procedencia."',";
|
||||
}
|
||||
|
||||
if ($perfil != ""){
|
||||
$condicion .= "pedidos.perfil = '".$perfil."',";
|
||||
}
|
||||
|
||||
$puesto_tecno = false;
|
||||
if($tecnologia != ""){
|
||||
foreach($tecnologia as $tecno)
|
||||
if ($tecno != ""){
|
||||
if(!$puesto_tecno)
|
||||
$tabla .= ",tecnologia_pedido";
|
||||
$puesto_tecno = true;
|
||||
$condicion .= "tecnologia_pedido.tecnologia = '".$tecno."' and tecnologia_pedido.oid_i = pedidos.oid or ";
|
||||
}
|
||||
}
|
||||
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
$puesto_provincia = false;
|
||||
if($provincias != ""){
|
||||
foreach($provincias as $provincia)
|
||||
if ($provincia != ""){
|
||||
if(!$puesto_provincia)
|
||||
$tabla .= ",provincia_pedido";
|
||||
$puesto_provincia = true;
|
||||
$condicion .= "provincia_pedido.provincia = '".$provincia."' and provincia_pedido.oid_i = pedidos.oid or ";
|
||||
}
|
||||
}
|
||||
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
$puesto_idioma = false;
|
||||
if($idiomas != ""){
|
||||
foreach($idiomas as $idioma){
|
||||
if ($idioma != ""){
|
||||
if(!$puesto_idioma)
|
||||
$tabla .= ",idioma_pedido";
|
||||
$puesto_idioma = true;
|
||||
$condicion .= "idioma_pedido.idioma = '".$idioma."' and idioma_pedido.oid_i = pedidos.oid or ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
// Mostramos sólo los del gerente o si es admin todos
|
||||
if(!$usuario->tieneRol("1")){
|
||||
$condicion.=" gerente='".$usuario->getValor("oid")."',";
|
||||
}
|
||||
|
||||
// Agregamos el estado de los pedidos que queremos mostrar
|
||||
if(($_GET['byEstado']!="") && ($_GET['byEstado']!="0")){
|
||||
$tipoPedidos=$_GET['byEstado'];
|
||||
$whereTipo=" and estado=".$tipoPedidos;
|
||||
} else {
|
||||
$tipoPedidos="0";
|
||||
$whereTipo="";
|
||||
}
|
||||
|
||||
if ($condicion != "") $where = " where ";
|
||||
|
||||
//Quitamos la última coma
|
||||
if ($condicion{strlen($condicion) - 1} == ",")
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 1);
|
||||
//Reemplazamos las comas por "and"
|
||||
$condicion = str_replace(","," and ",$condicion);
|
||||
|
||||
$limit = constante("lista");;
|
||||
$link = conectar();
|
||||
$consulta = "select DISTINCT pedidos.oid as codigo, pedidos.* from pedidos".$tabla.$where.$condicion;
|
||||
|
||||
// Creamos el objeto ListaPedidos
|
||||
// Variables por si es una ordenacion
|
||||
$order_by="";
|
||||
if($_GET["order"]!=""){
|
||||
$order_by = " ORDER by ".stripinput($_GET["order"])." ".$_GET["modo"];
|
||||
}
|
||||
$where="";
|
||||
$modo = stripinput($_GET["modo"]);
|
||||
|
||||
// Comprobamos si nos están buscando de nuevo o símplemente quieren ordenar
|
||||
if($_GET['reutilizar']=="si"){
|
||||
$listaPedidos = unserialize($_SESSION["ultimaBusquedaPedidos"]);
|
||||
// creamos el nuevo objeto con el orden
|
||||
$sql=$listaPedidos->getSQL();
|
||||
$listaPedidos=new ListaPedido($usuario,$order_by,$sql,$tipoPedidos);
|
||||
}else{
|
||||
$listaPedidos=new ListaPedido($usuario,$order_by,$consulta,$tipoPedidos);
|
||||
}
|
||||
// Metemos el objeto a la sesion
|
||||
$s = serialize($listaPedidos);
|
||||
$_SESSION["ultimaBusquedaPedidos"]=$s;
|
||||
$variablesExtra="reutilizar=si";
|
||||
|
||||
|
||||
|
||||
|
||||
include_once("ver_lista_pedidos.php");
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
193
src/busqueda_personas_multiple.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
include("functions.php");
|
||||
|
||||
if ($nombre != ""){
|
||||
$condicion .= "usuarios.nombre like '%".$nombre."%',";
|
||||
}
|
||||
|
||||
if ($apellidos != ""){
|
||||
$condicion .= "usuarios.apellidos like '%".$apellidos."%',";
|
||||
}
|
||||
|
||||
if ($email != ""){
|
||||
$condicion .= "usuarios.email like '%".$email."%',";
|
||||
}
|
||||
|
||||
if ($dni != ""){
|
||||
$condicion .= "usuarios.dni = '".$dni."',";
|
||||
}
|
||||
|
||||
if($busca_nac == "on"){
|
||||
$condicion .= "fecha_nacimiento >= '".$fecha_nacimiento_ini."' and fecha_nacimiento <= '".$fecha_nacimiento_fin."'";
|
||||
}
|
||||
|
||||
if ($t_casa != ""){
|
||||
$condicion .= "usuarios.t_casa = '".$t_casa."',";
|
||||
}
|
||||
|
||||
if ($t_trabajo != ""){
|
||||
$condicion .= "usuarios.t_trabajo = '".$t_trabajo."',";
|
||||
}
|
||||
|
||||
if ($t_movil != ""){
|
||||
$condicion .= "usuarios.t_movil = '".$t_movil."',";
|
||||
}
|
||||
|
||||
if ($direccion != ""){
|
||||
$condicion .= "usuarios.direccion like '%".$direccion."%',";
|
||||
}
|
||||
|
||||
if ($localidad != ""){
|
||||
$condicion .= "usuarios.localidad = '".$localidad."',";
|
||||
}
|
||||
|
||||
if ($cp != ""){
|
||||
$condicion .= "usuarios.cp = '".$cp."',";
|
||||
}
|
||||
|
||||
if($busca_alta == "on"){
|
||||
$condicion .= "fecha_alta >= '".$fecha_alta_ini."' and fecha_alta <= '".$fecha_alta_fin."'";
|
||||
}
|
||||
|
||||
if($busca_registro == "on"){
|
||||
$condicion .= "fecha_registro >= '".$fecha_reg_ini."' and fecha_registro <= '".$fecha_reg_fin."'";
|
||||
}
|
||||
|
||||
if($busca_modificacion == "on"){
|
||||
$condicion .= "fecha_modificacion >= '".$fecha_mod_ini."' and fecha_modificacion <= '".$fecha_mod_fin."'";
|
||||
}
|
||||
|
||||
if($busca_contratacion == "on"){
|
||||
$condicion .= "fecha_alta >= '".$fecha_cont_ini."' and fecha_alta <= '".$fecha_cont_fin."'";
|
||||
}
|
||||
|
||||
//if ($estado != ""){
|
||||
// $condicion .= "usuarios.estado = '".$estado."',";
|
||||
//}
|
||||
|
||||
//if ($disponible == '1'){
|
||||
// $condicion .= "usuarios.disponible = '1',";
|
||||
//}
|
||||
|
||||
if ($procedencia != ""){
|
||||
$condicion .= "usuarios.procedencia = '".$procedencia."',";
|
||||
}
|
||||
|
||||
if ($localidad_trabajo != ""){
|
||||
$condicion .= "usuarios.localidad_trabajo = '".$localidad_trabajo."',";
|
||||
}
|
||||
|
||||
$puesto_provincia = false;
|
||||
if(is_array($provincia_deseada)){
|
||||
foreach($provincia_deseada as $provincia)
|
||||
if ($provincia != ""){
|
||||
if(!$puesto_provincia)
|
||||
$tabla .= ",provincia_usuario";
|
||||
$puesto_provincia = true;
|
||||
$condicion .= "provincia_usuario.provincia = '".$provincia."' and provincia_usuario.oid_i = usuarios.oid or ";
|
||||
}
|
||||
}
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
|
||||
if ($seguridad_social != ""){
|
||||
$condicion .= "usuarios.seguridad_social = '".$seguridad_social."',";
|
||||
}
|
||||
|
||||
if ($cuenta_corriente != ""){
|
||||
$condicion .= "usuarios.cuenta_corriente = '".$cuenta_corriente."',";
|
||||
}
|
||||
|
||||
//if ($rol != ""){
|
||||
// $condicion .= "usuarios.rol = '".$rol."',";
|
||||
//}
|
||||
|
||||
if ($perfil != ""){
|
||||
$condicion .= "usuarios.perfil = '".$perfil."',";
|
||||
}
|
||||
|
||||
if ($salario != ""){
|
||||
$condicion .= "usuarios.salario_min <= '".$salario."' and usuarios.salario_max >= '".$salario."',";
|
||||
}
|
||||
|
||||
if ($cliente_actual != ""){
|
||||
$condicion .= "usuarios.cliente_actual = '".$cliente_actual."',";
|
||||
}
|
||||
|
||||
if ($quien_contacto != ""){
|
||||
$condicion .= "usuarios.quien_contacto like '%".$quien_contacto."%',";
|
||||
}
|
||||
|
||||
//if ($situacion != ""){
|
||||
// $condicion .= "usuarios.situacion = '".$situacion."',";
|
||||
//}
|
||||
|
||||
$puesto_tecno = false;
|
||||
if(is_array($tecnologia)){
|
||||
foreach($tecnologia as $tecno)
|
||||
if ($tecno != ""){
|
||||
if(!$puesto_tecno)
|
||||
$tabla .= ",tecnologia_usuario";
|
||||
$puesto_tecno = true;
|
||||
$condicion .= "tecnologia_usuario.tecnologia = '".$tecno."' and tecnologia_usuario.oid_i = usuarios.oid or ";
|
||||
}
|
||||
}
|
||||
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
$puesto_idioma = false;
|
||||
if(is_array($idiomas)){
|
||||
foreach($idiomas as $idioma){
|
||||
if ($idioma != ""){
|
||||
if(!$puesto_idioma)
|
||||
$tabla .= ",idioma_usuario";
|
||||
$puesto_idioma = true;
|
||||
$condicion .= "idioma_usuario.idioma = '".$idioma."' and idioma_usuario.oid_i = usuarios.oid or ";
|
||||
}
|
||||
}
|
||||
}
|
||||
$puesto_titu = false;
|
||||
if(is_array($titulaciones)){
|
||||
foreach($titulaciones as $titulacion)
|
||||
if ($titulacion != ""){
|
||||
if(!$puesto_titu)
|
||||
$tabla .= ",titulacion_usuario";
|
||||
$puesto_titu = true;
|
||||
$condicion .= "titulacion_usuario.titulacion = '".$titulacion."' and titulacion_usuario.oid_i = usuarios.oid or ";
|
||||
}
|
||||
}
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
//Quitamos el último or y ponemos una coma
|
||||
if (($condicion{strlen($condicion) - 3} == "o") && ($condicion{strlen($condicion) - 2} == "r")){
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 3);
|
||||
$condicion .= ",";
|
||||
}
|
||||
|
||||
if ($condicion != "") $where = " where ";
|
||||
|
||||
//Quitamos la última coma
|
||||
if ($condicion{strlen($condicion) - 1} == ",")
|
||||
$condicion = substr($condicion,0,strlen($condicion) - 1);
|
||||
//Reemplazamos las comas por "and"
|
||||
$condicion = str_replace(","," and ",$condicion);
|
||||
|
||||
//$limit = constante("lista");;
|
||||
//$link = conectar();
|
||||
$consulta = "select usuarios.* from usuarios".$tabla.$where.$condicion;
|
||||
|
||||
|
||||
?>
|
||||
|
||||
54
src/cambia_password.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
include_once("seguridad.php");
|
||||
include_once("functions.php");
|
||||
include_once("html/cabecera.php");
|
||||
|
||||
$oid = stripinput($_POST["oid"]);
|
||||
$viejo = stripinput($_POST["viejo"]);
|
||||
$nuevo = stripinput($_POST["nuevo"]);
|
||||
$confirmar = stripinput($_POST["confirmar"]);
|
||||
|
||||
if($oid != $_SESSION["oid"]){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
|
||||
//$oid = $_SESSION["oid"];
|
||||
//
|
||||
//if($link = conectar()){
|
||||
// $consulta = "select password from usuarios where oid='$oid'";
|
||||
// $resultado = mysql_query($consulta, $link);
|
||||
// $rows = mysql_fetch_array($resultado);
|
||||
// $password = $rows["password"];
|
||||
//
|
||||
//
|
||||
// if($password != md5($viejo)){
|
||||
// $errores .= $locale['030'];
|
||||
// }else if($nuevo == ""){
|
||||
// $errores .= $locale['1568'];
|
||||
// }else if($nuevo != $confirmar){
|
||||
// $errores = $locale['1569'];
|
||||
// }else{
|
||||
// $nuevo = md5($nuevo);
|
||||
// $consulta = "update usuarios set password='$nuevo' where oid='$oid'";
|
||||
// $resultado = mysql_query($consulta,$link);
|
||||
// $aciertos = $locale['1570'];
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//header("Location: password.php?e=$errores&a=$aciertos");
|
||||
|
||||
$usuario = $_SESSION["usuario"];
|
||||
if($usuario->setPassword($viejo, $nuevo, $confirmar)){
|
||||
|
||||
}else{
|
||||
$msg=$locale['4036'];
|
||||
include_once("showError.php");
|
||||
}
|
||||
|
||||
include_once("password.php");
|
||||
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
38
src/campos_alarma.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$nombre = stripinput($_POST["nombre"]);
|
||||
$mensaje = stripinput($_POST["mensaje"]);
|
||||
$periodicidad = stripinput($_POST["periodicidad"]);
|
||||
if($periodicidad == "d"){
|
||||
$activacion0 = stripinput($_POST["activaciond0"]);
|
||||
$activacion1 = stripinput($_POST["activaciond1"]);
|
||||
if($activacion0 != "" and $activacion1 != "")
|
||||
$activacion = $activacion0."-".$activacion1;
|
||||
$duracion = stripinput($_POST["duraciond"]);
|
||||
}else if($periodicidad == "s"){
|
||||
$activacion = stripinput($_POST["activacions"]);
|
||||
$duracion = stripinput($_POST["duracions"]);
|
||||
}else if($periodicidad == "m"){
|
||||
$activacion = stripinput($_POST["activacionm"]);
|
||||
$duracion = stripinput($_POST["duracionm"]);
|
||||
}else if($periodicidad == "a"){
|
||||
$activacion0 = stripinput($_POST["activaciona0"]);
|
||||
$activacion1 = stripinput($_POST["activaciona1"]);
|
||||
$duracion = stripinput($_POST["duraciona"]);
|
||||
if($activacion0 != "" and $activacion1 != "")
|
||||
$activacion = $activacion0."-".$activacion1;
|
||||
}
|
||||
|
||||
if(!es_numerico($duracion) || $duracion < 0) $duracion = 0;
|
||||
|
||||
$rol = stripinput($_POST["rol"]);
|
||||
$prioridad = stripinput($_POST["prioridad"]);
|
||||
$mail = stripinput($_POST["mail"]);
|
||||
$global = stripinput($_POST["global"]);
|
||||
|
||||
if($mail) $mail = 1;
|
||||
else $mail = 0;
|
||||
|
||||
if($global) $rol = "";
|
||||
|
||||
?>
|
||||
25
src/campos_pedido.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
if(!$_SESSION["oid"]){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
}
|
||||
|
||||
$prioridad = stripinput($_POST["prioridad"]);
|
||||
$nombre = stripinput($_POST["nombre"]);
|
||||
$fecha = stripinput($_POST["fecha"]);
|
||||
$cliente = stripinput($_POST["clientes"]);
|
||||
$perfil = stripinput($_POST["perfil"]);
|
||||
$duracion = stripinput($_POST["duracion"]);
|
||||
$empleados = stripinput($_POST["empleados"]);
|
||||
$observaciones = stripinput($_POST["observaciones"]);
|
||||
$gerente = stripinput($_POST["gerente"]);
|
||||
$salario_min = stripinput($_POST["salario_min"]);
|
||||
$salario_max = stripinput($_POST["salario_max"]);
|
||||
$estado = stripinput($_POST["estado"]);
|
||||
$procedencia = stripinput($_POST["procedencia"]);
|
||||
$tecnologia = $_POST["tecnologia"];
|
||||
$idiomas = $_POST["idiomas"];
|
||||
$localidades = $_POST["localidades"];
|
||||
$provincias = $_POST["provincias"];
|
||||
$activo = $_POST["activo"];
|
||||
?>
|
||||
160
src/campos_persona.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
if(!$_SESSION["oid"]){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
}
|
||||
|
||||
/*** DATOS PERSONALES ***/
|
||||
|
||||
$password = stripinput($_POST["password"]);
|
||||
$nombre = stripinput($_POST["nombre"]);
|
||||
$apellidos = stripinput($_POST["apellidos"]);
|
||||
$dia = stripinput($_POST["dianac"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesnac"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyonac"]);
|
||||
$fecha_nacimiento = $anyo."-".$mes."-".$dia;
|
||||
$dni = stripinput($_POST["dni"]);
|
||||
$t_casa = stripinput($_POST["t_casa"]);
|
||||
$t_movil = stripinput($_POST["t_movil"]);
|
||||
$t_trabajo = stripinput($_POST["t_trabajo"]);
|
||||
$email = stripinput($_POST["email"]);
|
||||
$tipo_via = stripinput($_POST["tipo_via"]);
|
||||
$direccion = stripinput($_POST["direccion"]);
|
||||
$numero = stripinput($_POST["numero"]);
|
||||
$piso = stripinput($_POST["piso"]);
|
||||
$puerta = stripinput($_POST["puerta"]);
|
||||
$cp = stripinput($_POST["cp"]);
|
||||
$localidad = stripinput($_POST["localidad"]);
|
||||
$descripcion = stripinput($_POST["descripcion"]);
|
||||
|
||||
/*** DATOS LABORALES ***/
|
||||
|
||||
$dia = stripinput($_POST["diaalta"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesalta"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyoalta"]);
|
||||
$fecha_alta = $anyo."-".$mes."-".$dia;
|
||||
$estado = stripinput($_POST["estado"]);
|
||||
$disponible = stripinput($_POST["disponible"]);
|
||||
if($disponible) $disponible = 1; else $disponible = 0;
|
||||
$incorporacion = stripinput($_POST["incorporacion"]);
|
||||
$procedencia = stripinput($_POST["procedencia"]);
|
||||
$localidad_trabajo = stripinput($_POST["localidad_trabajo"]);
|
||||
$localidad_deseada = $_POST["localidad_deseada"];
|
||||
$provincia_deseada = $_POST["provincia_deseada"];
|
||||
//if($localidad_deseada == "") $localidad_deseada = $localidad;
|
||||
$seguridad_social = stripinput($_POST["seguridad_social"]);
|
||||
$cuenta_corriente = stripinput($_POST["cuenta_corriente"]);
|
||||
$rol = stripinput($_POST["rol"]);
|
||||
$salario_min = stripinput($_POST["salario_min"]);
|
||||
$salario_max = stripinput($_POST["salario_max"]);
|
||||
$cliente_actual = stripinput($_POST["clientes"]);
|
||||
$quien_contacto = stripinput($_POST["quien_contacto"]);
|
||||
$situacion = stripinput($_POST["situacion"]);
|
||||
$observaciones = stripinput($_POST["observaciones"]);
|
||||
$informe_entrevista = stripinput($_POST["informe_entrevista"]);
|
||||
$informe_cliente = stripinput($_POST["informe_cliente"]);
|
||||
$contenido = stripinput($_POST["contenido"]);
|
||||
|
||||
$tecnologia = $_POST["tecnologia"];
|
||||
$idiomas = $_POST["idiomas"];
|
||||
$titulaciones = $_POST["titulaciones"];
|
||||
$pedidos = $_POST["pedidos"];
|
||||
$perfil = $_POST["perfil"];
|
||||
|
||||
if(comprobar_permisos("APU")){
|
||||
$permisos = "";
|
||||
for ($i = 0;$i < count($_POST['permisos']);$i++) {
|
||||
$permisos .= $_POST['permisos'][$i];
|
||||
if ($i != (count($_POST['permisos'])-1)) $permisos .= ".";
|
||||
}
|
||||
}else{
|
||||
$permisos = stripinput($_POST["permisos"]);
|
||||
}
|
||||
|
||||
/** DATOS EXCLUSIVOS DE LAS BÚSQUEDAS **/
|
||||
$busca_nac = stripinput($_POST["busca_nac"]);
|
||||
|
||||
$dia = stripinput($_POST["dianac_ini"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesnac_ini"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyonac_ini"]);
|
||||
$fecha_nacimiento_ini = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$dia = stripinput($_POST["dianac_fin"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesnac_fin"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyonac_fin"]);
|
||||
$fecha_nacimiento_fin = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$busca_alta = stripinput($_POST["busca_alta"]);
|
||||
$busca_registro = stripinput($_POST["busca_registro"]);
|
||||
$busca_modificacion = stripinput($_POST["busca_modificacion"]);
|
||||
$busca_contratacion = stripinput($_POST["busca_contratacion"]);
|
||||
|
||||
$dia = stripinput($_POST["diaalta_ini"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesalta_ini"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyoalta_ini"]);
|
||||
$fecha_alta_ini = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$dia = stripinput($_POST["diaalta_fin"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesalta_fin"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyoalta_fin"]);
|
||||
$fecha_alta_fin = $anyo."-".$mes."-".$dia;
|
||||
|
||||
// Fecha de registro
|
||||
$dia = stripinput($_POST["diareg_ini"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesreg_ini"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyoreg_ini"]);
|
||||
$fecha_reg_ini = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$dia = stripinput($_POST["diareg_fin"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesreg_fin"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyoreg_fin"]);
|
||||
$fecha_reg_fin = $anyo."-".$mes."-".$dia;
|
||||
|
||||
// Fecha de modificación
|
||||
$dia = stripinput($_POST["diamod_ini"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesmod_ini"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyomod_ini"]);
|
||||
$fecha_mod_ini = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$dia = stripinput($_POST["diamod_fin"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mesmod_fin"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyomod_fin"]);
|
||||
$fecha_mod_fin = $anyo."-".$mes."-".$dia;
|
||||
|
||||
// Fecha de contratación
|
||||
$dia = stripinput($_POST["diacont_ini"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mescont_ini"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyocont_ini"]);
|
||||
$fecha_cont_ini = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$dia = stripinput($_POST["diacont_fin"]);
|
||||
if($dia < 10) $dia = "0".($dia+0);
|
||||
$mes = stripinput($_POST["mescont_fin"]);
|
||||
if($mes < 10) $mes = "0".($mes+0);
|
||||
$anyo = stripinput($_POST["anyocont_fin"]);
|
||||
$fecha_cont_fin = $anyo."-".$mes."-".$dia;
|
||||
|
||||
$salario = stripinput($_POST["salario"]);
|
||||
?>
|
||||
75
src/candidaturas.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
if(!$_SESSION["oid"]){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
}
|
||||
|
||||
//Mostramos al candidato
|
||||
//$consulta = "select usuarios.nombre as nombre,usuarios.apellidos as apellidos, pedidos.nombre as pedido, estado_candidatura.id as estado from usuarios,candidato_pedido,pedidos,estado_candidatura where usuarios.oid='".$persona->getValor("oid")."' and candidato_pedido.candidato='".$persona->getValor("oid")."' and candidato_pedido.pedido = pedidos.oid and candidato_pedido.estado <> 6 ";
|
||||
|
||||
$consulta = "SELECT U.oid as idCandidato,P.oid as idPedido, U.nombre,U.apellidos,P.nombre AS pedido, CE.nombre AS estado, P.oid,CP.obsRRHH,CP.obsGerente
|
||||
FROM usuarios U,pedidos P,candidato_pedido CP,candidaturas_estado CE
|
||||
WHERE U.oid='".$persona->getValor("oid")."'
|
||||
AND CP.candidato=U.oid
|
||||
AND P.oid=CP.pedido
|
||||
AND CE.cod=CP.estado
|
||||
AND CE.idioma=U.idioma
|
||||
AND CP.estado <> '30'";
|
||||
if ($resultado = consultar($consulta)){
|
||||
$num = mysql_num_rows($resultado);
|
||||
if($num == 0){
|
||||
echo $locale['1037'];
|
||||
}else{
|
||||
$row = mysql_fetch_array($resultado);
|
||||
$nombre = $row["nombre"];
|
||||
$apellidos = $row["apellidos"];
|
||||
|
||||
echo "<ul>";
|
||||
do{
|
||||
$estado = $row["estado"];
|
||||
$pedido = $row["pedido"];
|
||||
$oid = $row["oid"];
|
||||
$obsRRHH = $row["obsRRHH"];
|
||||
$obsGerente = $row["obsGerente"];
|
||||
$idCandidato = $row["idCandidato"];
|
||||
echo "<li><a href=\"pedido.php?idPedido=".$oid."\" target=\"_blank\" />$oid</a> - ";
|
||||
if($usuario->tieneRol("4")){
|
||||
?>
|
||||
<a onclick="mostrarCapa('obs-<?php echo $oid; ?>')" ondblclick="ocultarCapa('obs-<?php echo $oid; ?>')">
|
||||
<img src="<?php echo (($obsRRHH!="") || ($obsGerente!=""))? "css/coment.png" : "css/add_coment.png"; ?>" /></a>
|
||||
<div id="obs-<?php echo $oid; ?>" class="capaObs" onmouseover="mostrarCapa('obs-<?php echo $oid; ?>')">
|
||||
<img src="css/dell.png" onclick="ocultarCapa('obs-<?php echo $oid; ?>')" style="padding:2px 10px 2px 0px ">
|
||||
<table width="550" bgcolor="#999999" style="border-collapse:separate ">
|
||||
<tr>
|
||||
<td width="50%"><b>Comentario de RRHH</b></td>
|
||||
<td width="50%"><b>Comentario del Gerente</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%">
|
||||
<form action="<?php echo $back; ?>" method="post">
|
||||
<input type="hidden" name="action" value="addComent">
|
||||
<input type="hidden" name="idPedido" value="<?php echo $oid; ?>">
|
||||
<input type="hidden" name="idCandidato" value="<?php echo $idCandidato; ?>">
|
||||
<textarea name="obs" class="obsPropuesta" ><?php echo $obsRRHH; ?></textarea>
|
||||
<input class="button" style="border-color:#000000; " type="submit" value="comentar" >
|
||||
</form>
|
||||
</td>
|
||||
<td width="50%">
|
||||
<textarea readonly name="obs" class="obsPropuesta" ><?php echo $obsGerente; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
echo " $pedido ($estado)</li>";
|
||||
}while ($row = mysql_fetch_array($resultado));
|
||||
echo "</ul>";
|
||||
}
|
||||
}else{
|
||||
echo $locale['bd'];
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
82
src/cliente.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
|
||||
|
||||
|
||||
if(!$usuario->tieneRol("3")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
$oid = $_GET["oid"];
|
||||
include_once("html/cabecera.php");
|
||||
include_once("Objects/ListaPedido.php");
|
||||
include_once("Objects/HTML.php");
|
||||
include_once("Objects/Empresa.php");
|
||||
$html = new HTML($locale);
|
||||
try{
|
||||
$empresa=new Empresa($usuario,$oid,$locale);
|
||||
}catch (Exception $e){
|
||||
$msg=$e->getMessage();
|
||||
include_once("showError.php");
|
||||
exit();
|
||||
}
|
||||
/* CLIENTES.PHP */
|
||||
|
||||
//Mostramos los detalles de un cliente
|
||||
$link = conectar();
|
||||
//Buscamos el cliente a partir del oid:
|
||||
$resultado = mysql_query("select id,gerente,privado from clientes where oid='$oid'");
|
||||
$rows = mysql_fetch_array($resultado);
|
||||
$nombre = $rows['id'];
|
||||
$gerente = $rows['gerente'];
|
||||
$privado = $rows['privado'];
|
||||
if($empresa->puedeGestionar()){
|
||||
echo $html->menuEmpresas($oid,array("gestionar"));
|
||||
}else
|
||||
echo $html->menuEmpresas($oid,"");
|
||||
echo "<h2>".$nombre."</h2>";
|
||||
|
||||
$editar = "si";
|
||||
|
||||
//Pestañas de navegación
|
||||
echo '<ul id="tabnav">';
|
||||
echo " <li class='inactivo'>
|
||||
<form action='cliente.php' method='post'>";
|
||||
echo "<input type='hidden' name='oid' value='".$oid."'>";
|
||||
echo "<input type='submit' class='binactivo' value='".$nombre."'></td>";
|
||||
echo '</form></li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<div id="ContTabul">';
|
||||
|
||||
if($usuario->tieneRol("1")){
|
||||
$consulta = "select pedidos.procedencia as procedencia, pedidos.oid as oid, pedidos.fecha as fecha, pedidos.prioridad as prioridad, pedidos.nombre as nombre, pedidos.cliente as cliente, pedidos.empleados as empleados, pedidos.perfil as perfil from clientes,pedidos where pedidos.cliente='$oid' and clientes.oid='$oid'".$whereTipo;
|
||||
}else{
|
||||
$consulta = "select pedidos.procedencia as procedencia, pedidos.oid as oid, pedidos.fecha as fecha, pedidos.prioridad as prioridad, pedidos.nombre as nombre, pedidos.cliente as cliente, pedidos.empleados as empleados, pedidos.perfil as perfil from clientes,pedidos where pedidos.cliente='$oid' and clientes.oid='$oid' and pedidos.gerente='$gerente'".$whereTipo;
|
||||
}
|
||||
// Variables por si es una ordenacion
|
||||
$order_by="";
|
||||
if($_GET["order"]!=""){
|
||||
$order_by = " ORDER by ".stripinput($_GET["order"])." ".$_GET["modo"];
|
||||
}
|
||||
$where="";
|
||||
$modo = stripinput($_GET["modo"]);
|
||||
|
||||
if(($_GET['byEstado']!="") && ($_GET['byEstado']!="0")){
|
||||
$tipoPedidos=$_GET['byEstado'];
|
||||
} else {
|
||||
$tipoPedidos="0";
|
||||
}
|
||||
|
||||
$listaPedidos=new ListaPedido($usuario,$order_by,$consulta,$tipoPedidos);
|
||||
$variablesExtra="oid=".$oid;
|
||||
include_once("ver_lista_pedidos.php");
|
||||
echo '</tbody>
|
||||
</table>';
|
||||
|
||||
echo "</div>";
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
42
src/constantes.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
include("seguridad.php");
|
||||
include("functions.php");
|
||||
if (!comprobar_permisos("AS")){
|
||||
header("Location: aplicacion.php?e=permiso");
|
||||
exit;
|
||||
}
|
||||
//include_once("html/cabecera.php");
|
||||
|
||||
/* TABLAS_MADRE.PHP */
|
||||
|
||||
$id = stripinput($_POST["id"]);
|
||||
$valor = stripinput($_POST["valor"]);
|
||||
|
||||
if ($link = conectar()){
|
||||
foreach($_POST as $key => $value){
|
||||
$value = stripinput($value);
|
||||
$key = stripinput($key);
|
||||
$consulta = "update sistema set valor='$value' where id='$key'";
|
||||
$resultado = mysql_query($consulta, $link);
|
||||
if(!resultado){
|
||||
$errores .= $locale['900']." $key";
|
||||
}
|
||||
}
|
||||
|
||||
if($id != ""){
|
||||
$consulta = "insert into sistema (id, valor) values ('$id','$valor')";
|
||||
$resultado = mysql_query($consulta, $link);
|
||||
if(!resultado){
|
||||
$errores .= $locale['901']." $key";
|
||||
}
|
||||
}
|
||||
}else
|
||||
$errores .= $locale['bd'];
|
||||
|
||||
if(!$errores) $aciertos .= $locale['902'];
|
||||
|
||||
header("Location: administracion.php?opcion=constantes&e=$errores&a=$aciertos");
|
||||
include_once("html/pie.php");
|
||||
|
||||
?>
|
||||
80
src/control.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
//FICHERO DE IDIOMAS
|
||||
define("LOCALE", "idiomas/");
|
||||
define("LOCALESET", "sp/");
|
||||
include LOCALE.LOCALESET."lenguaje.php";
|
||||
|
||||
include("functions.php");
|
||||
include_once("Objects/Usuario.php");
|
||||
|
||||
//si es necesario cambiar la config. del php.ini desde tu script
|
||||
ini_set("session.use_only_cookies","1");
|
||||
ini_set("session.use_trans_sid","0");
|
||||
|
||||
//Nos conectamos a la base de datos
|
||||
if ($link=conectar()){
|
||||
|
||||
//header("Location: index.php?errorusuario=si");
|
||||
//Obtenemos los campos
|
||||
$login = stripinput($_POST['usuario']);
|
||||
$password = stripinput($_POST['password']);
|
||||
$pass = md5($password);
|
||||
|
||||
//ejecutamos una consulta para comprobar si existe el nombre
|
||||
$result = mysql_query("select * from usuarios where email='$login' and tipo='usuario' and password='$pass';", $link);
|
||||
|
||||
//Si es cero, no existe el nombre
|
||||
$salida = 0;
|
||||
while($row = mysql_fetch_array($result)){
|
||||
$salida = $salida + 1;
|
||||
}
|
||||
|
||||
if ($salida == 0) {
|
||||
header("Location: index.php?errorusuario=si");
|
||||
} else {
|
||||
//Cambiamos la variable login de session
|
||||
$info = mysql_query("select * from usuarios where email='$login' and password='$pass';", $link);
|
||||
$row = mysql_fetch_array($info);
|
||||
|
||||
//Permisos del rol
|
||||
$rol = $row["rol"];
|
||||
$info_rol = mysql_query("select permisos from rol where oid='$rol';", $link);
|
||||
$row_rol = mysql_fetch_array($info_rol);
|
||||
|
||||
//usuario y contraseña válidos
|
||||
//asigno un nombre a la sesión para poder guardar diferentes datos
|
||||
session_name("loginUsuario");
|
||||
// inicio la sesión
|
||||
session_start();
|
||||
|
||||
$_SESSION["login"] = $login;
|
||||
$_SESSION["password"] = $password;
|
||||
$_SESSION["rol"] = $row["rol"];
|
||||
$_SESSION["oid"] = $row["oid"];
|
||||
$_SESSION["nombre"] = $row["nombre"];
|
||||
$_SESSION["descripcion"] = $row["descripcion"];
|
||||
$_SESSION["permisos"] = $row["permisos"];
|
||||
$_SESSION["idioma"] = $row["idioma"];
|
||||
$_SESSION["permisos_rol"] = $row_rol["permisos"];
|
||||
$_SESSION["duracion"] = constante("sesion");
|
||||
|
||||
$usuario = new Usuario($login);
|
||||
$_SESSION["usuario"] = $usuario;
|
||||
$_SESSION["ultimaBusquedaPedidos"] = null;
|
||||
$_SESSION["ultimaBusquedaCandidatos"] = null;
|
||||
$_SESSION["ultimaBusquedaEmpleados"] = null;
|
||||
|
||||
session_set_cookie_params(0, "/", $HTTP_SERVER_VARS["HTTP_HOST"], 0);
|
||||
//cambiamos la duración a la cookie de la sesión
|
||||
$_SESSION["autentificado"]= "SI";
|
||||
//defino la sesión que demuestra que el usuario está autorizado
|
||||
$_SESSION["ultimoAcceso"]= date("Y-n-j H:i:s");
|
||||
|
||||
header ("Location: aplicacion.php");
|
||||
}
|
||||
}else {
|
||||
//si no existe le mando otra vez a la portada
|
||||
header("Location: index.php?errorusuario=si");
|
||||
}
|
||||
?>
|
||||
BIN
src/css/2flecha_mas.gif
Normal file
|
After Width: | Height: | Size: 71 B |
BIN
src/css/2flecha_menos.gif
Normal file
|
After Width: | Height: | Size: 71 B |
BIN
src/css/Thumbs.db
Normal file
BIN
src/css/accept.png
Normal file
|
After Width: | Height: | Size: 781 B |
BIN
src/css/add_coment.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/css/admin_alarmas.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/css/admin_backup.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/css/admin_bd.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_candidatos.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_clientes.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_festivos.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/css/admin_festivos_locales.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/css/admin_informes.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/css/admin_partes.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_pedidos.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_permisos.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_roles.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_salarios.gif
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/css/admin_sistema.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_usuarios.gif
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/css/admin_vacaciones.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/css/agenda.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/css/anular_vacaciones.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/css/arrow-left.png
Normal file
|
After Width: | Height: | Size: 367 B |
BIN
src/css/arrow-right.png
Normal file
|
After Width: | Height: | Size: 368 B |
BIN
src/css/asc.png
Normal file
|
After Width: | Height: | Size: 213 B |
BIN
src/css/aviso.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/css/banner.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/css/brick_go.png
Normal file
|
After Width: | Height: | Size: 790 B |
BIN
src/css/coment.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/css/cuadro-base.gif
Normal file
|
After Width: | Height: | Size: 1.6 KiB |