Tarea #647 -> Nueva entrada de menú para ver la lista de ofertas

Tarea #646 -> Crear la acción "Creación de oferta" que cree una oferta relacionada con la solicitud de oferta que se está mostrando.
Tarea #607 -> Nueva entidad 'Oferta' con estados nuevos
Tarea #606 -> Nuevos estados y transiciones para una solicitud de oferta
Tarea #601 -> Nuevos estados y transiciones para un candidato
Tarea #599 -> Repasar los registros que se meten en el historial de cambios
Tarea #586 -> Cuando una solicitud tiene varios perfiles, hay que visualizarlos ocupando las menos filas posibles
Tarea #585 -> Cuando un candidato tiene varios perfiles, hay que visualizarlos ocupando las menos filas posibles

git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk/src@65 e2b1556b-49f8-d141-9351-52d6861a72d9
This commit is contained in:
David Arranz 2011-05-19 08:46:58 +00:00
parent ec58065e0c
commit 9e87e5eb38
30 changed files with 3693 additions and 3025 deletions

View File

@ -17,10 +17,12 @@ include_once("Conexion.php");
function execQuery($query){ function execQuery($query){
$res = mysql_query($query); $res = mysql_query($query);
//$mensaje = $query." - ".$res."\r\n";
//$fichero = fopen("querys.log","a"); /*$mensaje = $query." - ".$res."\r\n";
//fputs($fichero,$mensaje); $fichero = fopen("querys.log","a");
//fclose($fichero); fputs($fichero,$mensaje);
fclose($fichero);*/
return $res; return $res;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* Clase Candidato * Clase Candidato
* *
@ -9,6 +10,8 @@
*/ */
include_once("BD.php"); include_once("BD.php");
include_once("Persona.php"); include_once("Persona.php");
include_once("Automata.php");
class Candidato extends Persona { class Candidato extends Persona {
private $usuario; private $usuario;
@ -91,6 +94,7 @@
@param $estado - Estado del pedido. @param $estado - Estado del pedido.
@return array codPedido => nombre o vacío. @return array codPedido => nombre o vacío.
*/ */
function getPedidosByEstado($estado) { function getPedidosByEstado($estado) {
/* SELECT P.oid,P.nombre /* SELECT P.oid,P.nombre
FROM pedidos P,candidato_pedido CP FROM pedidos P,candidato_pedido CP
@ -151,6 +155,7 @@
$idioma = $this->usuario->getValor("idioma"); $idioma = $this->usuario->getValor("idioma");
$rol = $this->usuario->getValor("rol"); $rol = $this->usuario->getValor("rol");
$a = new Automata("candidatos", $idioma, $rol); $a = new Automata("candidatos", $idioma, $rol);
$transita = $a->getTransicion($origen, $destino); $transita = $a->getTransicion($origen, $destino);
if (($transita == "") || !($transita >= 0)) { if (($transita == "") || !($transita >= 0)) {
@ -172,7 +177,8 @@
private function ejecutaTransicion($codigo, $argumentos) { private function ejecutaTransicion($codigo, $argumentos) {
//Si no hace nada al transitar salimos sin más. //Si no hace nada al transitar salimos sin más.
if($codigo == 0) return true; if ($codigo == 0)
return true;
$funcion = "ejecutar$codigo"; $funcion = "ejecutar$codigo";
$res = call_user_func(array("Candidato", $funcion), $argumentos); $res = call_user_func(array("Candidato", $funcion), $argumentos);
@ -371,6 +377,7 @@
return false; return false;
} }
/** /**
* Entrevistado a En proceso(entrevistado). * Entrevistado a En proceso(entrevistado).
* Admin, RRHH * Admin, RRHH
@ -380,7 +387,6 @@
EFECTOS: EFECTOS:
- Se cambia el estado del candidato de en proceso(entrevistado) - Se cambia el estado del candidato de en proceso(entrevistado)
*/ */
private function ejecutar5070() { private function ejecutar5070() {
$this->setCampos(array("estado" => "70")); $this->setCampos(array("estado" => "70"));
$this->campos["estado_usuario"] = "70"; $this->campos["estado_usuario"] = "70";
@ -388,4 +394,5 @@
} }
} }
?> ?>

View File

@ -81,6 +81,32 @@
echo '<a href="pedido.php?idPedido='.$_GET['idPedido'].'" class="menuOption" style="color:#000000">'.$this->locale['1077'].'</a>'; echo '<a href="pedido.php?idPedido='.$_GET['idPedido'].'" class="menuOption" style="color:#000000">'.$this->locale['1077'].'</a>';
} }
} }
if(in_array("nueva_oferta",$opcionesThis)){
echo '<a href="addOferta.php" class="menuOption" style="color:#000000">'.'Nueva oferta'.'</a>';
}
}
function menuOfertas($usuario, $opciones){
if(!is_array($opciones)){
$opcionesThis = array();
} else {
$opcionesThis = $opciones;
}
echo '<a href="lista_ofertas.php" class="menuOption" style="color:#000000">'.$this->locale['5100'].'</a>';
if($usuario->tieneRol("3") ||$usuario->tieneRol("1")){
echo '<a href="addOferta.php" class="menuOption" style="color:#000000">'.$this->locale['5101'].'</a>';
}
/*echo '<a href="buscar_oferta.php" class="menuOption" style="color:#000000">'.$this->locale['5102'].'</a>';*/
if(!in_array("gestionar", $opcionesThis)){
if(substr_count($_SERVER['REQUEST_URI'],"/oferta.php?idOferta")==1){
echo '<a href="gestion_oferta.php?idOferta='.$_GET['idOferta'].'" class="menuOption" style="color:#000000">'.$this->locale['284'].'</a>';
}
if(substr_count($_SERVER['REQUEST_URI'],"/gestion_oferta.php?idOferta")==1){
echo '<a href="oferta.php?idOferta='.$_GET['idOferta'].'" class="menuOption" style="color:#000000">'.$this->locale['5103'].'</a>';
}
}
} }
function menuCandidatos(){ function menuCandidatos(){
@ -211,10 +237,15 @@
if (!strcmp($opcion, "Gestión de candidatos")) { if (!strcmp($opcion, "Gestión de candidatos")) {
echo '<li><a title="'.$opcion.'" href="lista_candidatos.php">'.$opcion.'</a></li>'; echo '<li><a title="'.$opcion.'" href="lista_candidatos.php">'.$opcion.'</a></li>';
} elseif (!strcmp($opcion, "Mis datos")) { } elseif (!strcmp($opcion, "Mis datos")) {
$PonerAlFinal = '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>'; $PonerAlFinal .= '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>';
} elseif (!strcmp($opcion, "Mantenimiento del sistema")) {
$PonerAlFinal .= '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>';
} elseif (!strcmp($opcion, "Solicitudes de oferta")) { } elseif (!strcmp($opcion, "Solicitudes de oferta")) {
// Ticket 640 -> Entrada automatica a la lista de solicitudes de oferta. // Ticket 640 -> Entrada automatica a la lista de solicitudes de oferta.
echo '<li><a title="'.$opcion.'" href="lista_pedidos.php">'.$opcion.'</a></li>'; echo '<li><a title="'.$opcion.'" href="lista_pedidos.php">'.$opcion.'</a></li>';
} elseif (!strcmp($opcion, "Ofertas")) {
// Ticket 647 -> Nueva entrada de menú para ver la lista de ofertas
echo '<li><a title="'.$opcion.'" href="lista_ofertas.php">'.$opcion.'</a></li>';
} else { } else {
echo '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>'; echo '<li><a title="'.$opcion.'" href="administracion_principal.php?rol='.$opcion.'">'.$opcion.'</a></li>';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* Clase ListaCandidatos * Clase ListaCandidatos
* *
@ -9,11 +10,8 @@
include_once("ListaPersonas.php"); include_once("ListaPersonas.php");
class ListaCandidatos extends ListaPersonas { class ListaCandidatos extends ListaPersonas {
//Atributos: //Atributos:
//Constructor: //Constructor:
//Funciones: //Funciones:
/** /**
@ -58,5 +56,51 @@
$candidato->actualizarHistorial($mensaje); $candidato->actualizarHistorial($mensaje);
return $id; return $id;
} }
/**
* Devuelve los candidatos
*/
function getCandidatos() {
$candidatos = array();
if ($this->sql != "") {
// metemos el estado si es > 0
if ($this->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));
$sqlConEstado = "WHERE usuarios.estado='" . $this->estado . "' and ";
$sqlNueva = $sqlAntesWhere . $sqlConEstado . $sqlDespuesWhere;
} else {
$sqlConEstado = "WHERE usuarios.estado='" . $this->estado . "' ";
$sqlNueva = $this->sql . $sqlConEstado;
} }
} else {
$sqlNueva = $this->sql;
}
$consulta = $sqlNueva . " " . $this->order_by;
} else {
if ($this->estado > 0) {
$consulta = "SELECT oid from usuarios WHERE tipo='" . $this->tipo . "' and estado='" . $this->estado . "'" . $this->orden;
} else {
$consulta = "SELECT oid from usuarios WHERE tipo='" . $this->tipo . "'" . $this->orden . "";
}
}
$bd = new BD();
$resultado = $bd->execQuery($consulta);
//Procesamos los candidatos.
if (mysql_num_rows($resultado) != 0) {
while ($rows = mysql_fetch_array($resultado)) {
$p = new Candidato($this->usuario, $rows["oid"]);
$candidatos[] = $p;
}
}
return $candidatos;
}
}
?> ?>

150
Objects/ListaOfertas.php Normal file
View File

@ -0,0 +1,150 @@
<?php
/*
* Clase ListaOfertas
*/
include_once("Objects/Oferta.php");
class ListaOfertas {
// Atributos:
/* Una lista de pedidos. */
private $ofertas = array();
/* Gestor dueño de la lista. */
private $gestor;
/* Campos por los que ordenar la lista. */
private $orden;
/* Condiciones para búsquedas. */
private $condiciones;
// Constructor:
/**
* Crea una lista de ofertas.
*
* @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 ListaOfertas($usuario, $condiciones=array(), $orden=array()) {
$this->gestor = $usuario;
$this->orden = $orden;
$this->condiciones = $condiciones;
}
/**
* Busca y devuelve todos los pedidos del usuario.
*/
function getOfertas() {
// sacado de http://patrickallaert.blogspot.com/2007/09/building-dynamic-sql-queries-elegant.html
$consulta = "SELECT * FROM candidato_pedido";
if (count($this->condiciones)) {
$consulta .= ' WHERE ' . implode(' AND ', $this->condiciones);
}
if (count($this->orden)) {
$consulta .= ' ORDER BY ' . implode(' , ', $this->orden);
}
$bd = new BD();
$resultado = $bd->execQuery($consulta);
// Procesamos las ofertas.
if (mysql_num_rows($resultado) == 0) {
$this->ofertas = array();
} else {
while ($rows = mysql_fetch_array($resultado)) {
$p = new Oferta($rows["oid"], $this->gestor);
$this->ofertas[] = $p;
}
}
return $this->ofertas;
}
/**
* 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 getEstadosOfertas() {
$consulta = "SELECT cod, nombre FROM candidaturas_estados";
$bd = new BD();
return $bd->keyValueQuery($consulta, "cod", "nombre");
}
/**
* Busca una oferta en función de su identificador.
*
* @return el pedido, en caso de encontrarlo y null en
* caso contrario.
*/
function buscarOferta($id) {
$lista = $this->getOfertas();
if ($lista) {
foreach ($lista as $elem) {
if ($elem->getValor("oid") == $id) {
return $elem;
}
}
}
return null;
}
function addOferta($campos) {
if (!$this->gestor->tieneRol(1) && !$this->gestor->tieneRol(3)) {
$error = "El usuario no tiene permisos para crear ofertas.";
throw new Exception($error);
}
// Calculamos el id
$referencia = $this->calculaReferencia($campos["pedido"]);
$inserto = "fecha, referencia";
$fecha = "'" . date("Y-m-d") . "'";
$valores = "$fecha, $referencia";
// Procesamos los datos
foreach ($campos as $key => $value) {
$inserto .= ", $key";
$valores .= ", '$value'";
}
// Insertamos en la BD
$consulta = "INSERT INTO candidato_pedido ($inserto) VALUES ($valores)";
$bd = new BD();
if (!$bd->execQuery($consulta)) {
return "-1";
} else {
$id = mysql_insert_id();
$p = new Oferta($id, $this->gestor);
$mensaje = "Nueva oferta";
$p->actualizarHistorial($mensaje);
}
return $id;
}
function calculaReferencia($solicitud) {
$bd = new BD();
$consulta = "select referencia from candidato_pedido where pedido = '$solicitud' order by oid desc limit 1";
if ($resultado = $bd->execQuery($consulta)) {
$rows = mysql_fetch_array($resultado);
echo "########################<br/>";
print_r($rows);
echo "########################<br/>";
$num = 1;
if (!empty($rows[0])) {
$num = substr($rows[0], strpos($rows[0], '/') + 1, strlen($rows[0]));
$num += 1;
}
return sprintf('\'%s/%s\'', $solicitud, $num);
} else {
return sprintf('\'%s/%s\'', $solicitud, 1);
}
}
}
?>

View File

@ -96,7 +96,7 @@ include_once("Objects/Pedido.php");
if($estado > 0){ if($estado > 0){
$consulta = "SELECT * from pedidos WHERE estado='".$estado."'".$this->orden ; $consulta = "SELECT * from pedidos WHERE estado='".$estado."'".$this->orden ;
}else{ }else{
$consulta = "SELECT * from pedidos WHERE estado IN (10, 20, 30) ".$this->orden.""; $consulta = "SELECT * from pedidos ".$this->orden."";
} }
} }
}else if($this->gestor->tieneRol(3)){ }else if($this->gestor->tieneRol(3)){
@ -123,7 +123,7 @@ include_once("Objects/Pedido.php");
if($estado > 0){ if($estado > 0){
$consulta = "SELECT * FROM pedidos WHERE gerente = '$id' AND estado='$estado'".$this->orden; $consulta = "SELECT * FROM pedidos WHERE gerente = '$id' AND estado='$estado'".$this->orden;
}else{ }else{
$consulta = "SELECT * FROM pedidos WHERE estado IN (10, 20, 30) AND gerente = '$id'".$this->orden; $consulta = "SELECT * FROM pedidos WHERE gerente = '$id'".$this->orden;
} }
} }
}else{ }else{
@ -188,6 +188,7 @@ include_once("Objects/Pedido.php");
//Insertamos en la BD //Insertamos en la BD
$consulta = "INSERT INTO pedidos ($inserto) VALUES ($valores)"; $consulta = "INSERT INTO pedidos ($inserto) VALUES ($valores)";
$bd = new BD(); $bd = new BD();
if(!$bd->execQuery($consulta)){ if(!$bd->execQuery($consulta)){
return -1; return -1;

View File

@ -154,7 +154,7 @@ include_once("Empleado.php");
//Insertamos en la BD //Insertamos en la BD
$consulta = "INSERT INTO usuarios ($inserto) VALUES ($valores)"; $consulta = "INSERT INTO usuarios ($inserto) VALUES ($valores)";
echo $consulta;
$bd = new BD(); $bd = new BD();
if(!$bd->execQuery($consulta)){ if(!$bd->execQuery($consulta)){
$error = "Campos del candidato incorrectos. Por favor, avise al webmaster de este error."; $error = "Campos del candidato incorrectos. Por favor, avise al webmaster de este error.";

298
Objects/Oferta.php Normal file
View File

@ -0,0 +1,298 @@
<?php
/*
* Clase Oferta
*/
include_once("BD.php");
include_once("Automata.php");
include_once("ListaCandidatos.php");
include_once("Candidato.php");
class Oferta {
// Atributos:
/* Usuario que tiene activa la sesión. */
private $usuario;
protected $campos = array();
// Constructores:
function Oferta($oid, $usuario) {
$this->usuario = $usuario;
$consulta = "SELECT oid FROM candidato_pedido WHERE oid = '$oid'";
$bd = new BD();
$num = $bd->numFilas($consulta);
if ($num > 0) {
$this->campos['oid'] = $oid;
} else {
$error = "Oferta no encontrada.";
throw new Exception($error);
}
}
function actualizarHistorial($mensaje) {
$oid = $this->getValor("oid");
$usuario = $this->usuario->getValor("nombre");
$consulta = "INSERT INTO historial_oferta (oid_h, fecha_h, persona_h, texto_h) VALUES('$oid', now(), '$usuario', '$mensaje')";
$bd = new BD();
return $bd->execQuery($consulta);
}
function getValor($nombre) {
if (array_key_exists($nombre, $this->campos)) {
// El campo ya lo habíamos recuperamos, lo mostramos
return $this->campos[$nombre];
} else {
switch ($nombre) {
case "nombre_estado":
$idEstado = $this->getValor("estado");
$idioma = $this->usuario->getValor("idioma");
$consulta = "SELECT nombre FROM candidaturas_estados WHERE cod=\"" . $idEstado . "\" AND idioma=\"" . $idioma . "\"";
break;
case "nombre_solicitud":
$oidPedido = $this->getValor("pedido");
$consulta = "SELECT nombre FROM pedidos WHERE oid=\"" . $oidPedido . "\"";
break;
case "nombre_candidato":
$oidCandidato = $this->getValor("candidato");
$consulta = "SELECT concat(nombre, ' ', apellidos) FROM usuarios WHERE oid=\"" . $oidCandidato . "\"";
break;
default: $consulta = "SELECT " . $nombre . " FROM candidato_pedido WHERE oid=\"" . $this->campos['oid'] . "\"";
break;
}
// Lo insertamos para nosotros
$bd = new BD();
$valor = $bd->getCampo($consulta);
// Lo insertamos para nosotros
$arrayAct = array($nombre => $valor);
$this->campos = $this->campos + $arrayAct;
return $valor;
}
}
/**
* Acceso a los campos del pedido.
*
* @return los campos del pedido.
*/
function getCampos() {
return $this->campos;
}
function getSiguientes() {
$estado = $this->getValor("estado");
$idioma = $this->usuario->getValor("idioma");
$rol = $this->usuario->getValor("rol");
$a = new Automata("candidaturas", $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("candidaturas", $idioma, $rol);
$transita = $a->getTransicion($origen, $destino);
if (($transita == "") || !($transita >= 0)) {
return false;
} else {
$res = $this->ejecutaTransicion($transita, $argumentos);
if ($res) {
$this->setAutomatico = true;
$this->setCampo("msgEstado", $argumentos);
$this->setCampo("estado", $destino);
$this->setAutomatico = false;
}
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("Oferta", $funcion), $argumentos);
return $res;
}
/**
* En configuración -> Configurada
*/
private function ejecutar110120() {
// Comprobamos que haya un candidato asignado.
$candidato = $this->getValor("candidato");
if (!empty($candidato)) {
return true;
} else {
$error = "No se puede cambiar de estado porque no hay ningún candidato asignado a esta oferta";
throw new Exception($error);
return false;
exit;
}
}
function setCampo($nombre, $valor) {
// PERMISOS:
/*
* Admin (1) - Todos
* Gestor (3) - Los suyos
* Otro - Excepción
*/
$gerente = $this->getValor("gerente");
$sesion = $this->usuario->getValor("oid");
if ($this->usuario->tieneRol(1) || ($this->usuario->tieneRol(3) && $sesion == $gerente) || $this->setAutomatico) {
$viejo = $this->getValor($nombre);
if ($viejo != $valor) {
// Comprobamos multivaluado y casos especiales antes del cambio:
$viejo = $this->getValorMulti($nombre, $viejo);
$this->campos[$nombre] = $valor;
$oid = $this->getValor("oid");
$consulta = "UPDATE candidato_pedido SET $nombre = '$valor' WHERE oid='$oid'";
$bd = new BD();
if ($bd->execQuery($consulta)) {
// Guardar en el historial
$valor = $this->getValorMulti($nombre, $valor);
if ($viejo == "" && $valor != "") {
$historial = "$nombre (de - a $valor)";
} else {
$historial = "$nombre (de $viejo a $valor)";
}
if ($nombre = "estado") {
$this->actualizarHistorial($historial);
}
}
}
} else {
$error = "El usuario no tiene permisos para editar la solicitud de oferta.";
throw new Exception($error);
}
}
private function getValorMulti($nombre, $antiguo) {
switch ($nombre) {
/* case "procedencia":
$valor = nombre_procedencia($antiguo);
break;
case "estado":
$valor = nombre_estado_pedido($antiguo);
break;
case "localidad":
$valor = nombre_localidad($antiguo);
break;
case "perfil":
$valor = nombre_perfil($antiguo);
break;
case "cliente":
$valor = nombre_cliente($antiguo);
break; */
default:
$valor = $antiguo;
break;
}
return $valor;
}
/**
* Devuelve una lista de candidatos disponibles para una oferta
*/
function getCandidatosDisponibles() {
return $this->getCandidatos("540");
}
/**
* Devuelve una lista de candidatos de un estado dado
*/
private function getCandidatos($estado) {
$lista = new ListaCandidatos($this->usuario, "", "", $estado);
return $lista;
}
function getHistorial() {
$historial = "";
$oid = $this->getValor("oid");
$consulta = "SELECT * FROM historial_oferta WHERE oid_h='$oid' ORDER BY fecha_h DESC";
$bd = new BD();
$resultado = $bd->execQuery($consulta);
while ($rows = mysql_fetch_array($resultado)) {
$fecha = $rows["fecha_h"];
$persona = $rows["persona_h"];
$texto = $rows["texto_h"];
$historial .= "[$fecha] $persona - $texto\n";
}
return $historial;
}
function quitarCandidato() {
$idCand = $this->getValor("candidato");
if (!empty($idCand)) {
$candidato = new Candidato($this->usuario, $idCand);
$estadoCand = $candidato->getValor("estado");
switch ($estadoCand) {
case "560":
$candidato->transita("540", "");
$nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos");
$mensaje = "Eliminado el candidato ".$nombre_candidato;
$this->actualizarHistorial($mensaje);
return true;
break;
default:
$error = "[quitarCandidato]. El candidato tiene un estado no permitido ('" . $estadoCand . "')";
throw new Exception($error);
}
}
}
function colocarCandidato($idCandidato) {
$idCand = $this->getValor("candidato");
if (!empty($idCand)) {
if (!$this->quitarCandidato()) {
return false;
}
}
$candidato = new Candidato($this->usuario, $idCandidato);
$estadoCand = $candidato->getValor("estado");
switch ($estadoCand) {
case "540":
if ($candidato->transita("560", "")) {
$this->setCampo("candidato", $idCandidato);
$nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos");
$mensaje = "Asignado el candidato ".$nombre_candidato;
$this->actualizarHistorial($mensaje);
return true;
}
else {
dbug("error");
}
break;
default:
$error = "El candidato tiene un estado no permitido ('" . $candidato->getValor("estado") . "')";
throw new Exception($error);
}
echo dbug('print');
}
}
?>

View File

@ -1,37 +1,27 @@
<?php <?php
/* /*
* Clase Pedido * Clase Pedido
*/ */
include_once("BD.php"); include_once("Objects/BD.php");
include_once("CandidatoPedido.php"); include_once("Objects/CandidatoPedido.php");
include_once("Candidato.php"); include_once("Objects/Candidato.php");
include_once("Empleado.php"); include_once("Objects/Empleado.php");
include_once("Afinidad.php"); include_once("Objects/Afinidad.php");
include_once("Automata.php"); include_once("Objects/Automata.php");
include_once("Objects/Oferta.php");
class Pedido { class Pedido {
// Atributos: // Atributos:
/* Usuario que tiene activa la sesión. */ /* Usuario que tiene activa la sesión. */
private $usuario; private $usuario;
/* Contiene una lista con todos los atributos y su valor */ /* Contiene una lista con todos los atributos y su valor */
private $campos = array(); private $campos = array();
private $listaOfertas = null;
/* Lista de candidatos propuestos*/
private $listaPropuestos = null;
/* Lista de candidatos propuestos por RRHH*/
private $listaPropuestosRRHH = null;
/* Lista de candidatos aceptados*/
private $listaAceptados = null;
/* Lista de candidatos rechazados*/
private $listaRechazados = null;
/* Lista de perfiles */ /* Lista de perfiles */
private $listaPerfiles = null; private $listaPerfiles = null;
@ -46,17 +36,17 @@ include_once("Automata.php");
private $listaProvincias = null; private $listaProvincias = null;
/* Parámetros que si se cambian recalculan la afinidad */ /* Parámetros que si se cambian recalculan la afinidad */
private $listaAfinidad = array("nombre", "perfil", "pesoTecno", "pesoIdioma", "pesoPerfil"); private $listaAfinidad = array("nombre", "perfil", "pesoTecno", "pesoIdioma", "pesoPerfil", "estado");
/* Booleano que indica si el cambio de un campo lo hace por razones automáticas y dejar realizar /* Booleano que indica si el cambio de un campo lo hace por razones automáticas y dejar realizar
* el camio */ * el cambio */
private $setAutomatico = false; private $setAutomatico = false;
// Constructor: // Constructor:
/** /**
* Recupera un pedido a partir de su identificador. * Recupera un pedido a partir de su identificador.
* @param id - datos necesarios para crear un pedido. *
* @param id $ - datos necesarios para crear un pedido.
*/ */
function Pedido($id, $usuario) { function Pedido($id, $usuario) {
$this->usuario = $usuario; $this->usuario = $usuario;
@ -73,10 +63,10 @@ include_once("Automata.php");
} }
// Funciones: // Funciones:
/** /**
* Calcula el número de candidatos asociados al pedido. * Calcula el número de candidatos asociados al pedido.
* @param tipo - estado del candidato en el pedido. *
* @param tipo $ - estado del candidato en el pedido.
* @return número de candidatos asociados a ese pedido. * @return número de candidatos asociados a ese pedido.
*/ */
function dameNumCand($tipo) { function dameNumCand($tipo) {
@ -99,12 +89,12 @@ include_once("Automata.php");
throw new Exception($error); throw new Exception($error);
} }
return $numero; return $numero;
} }
/** /**
* Procesa un array para añadir campos al pedido. * Procesa un array para añadir campos al pedido.
* @param array - datos a añadir al pedido. *
* @param array $ - datos a añadir al pedido.
*/ */
private function parseaArray($array) { private function parseaArray($array) {
foreach ($array as $campo) { foreach ($array as $campo) {
@ -114,7 +104,8 @@ include_once("Automata.php");
/** /**
* Procesa el resultado de una query para añadir campos al pedido. * Procesa el resultado de una query para añadir campos al pedido.
* @param resource - el resultado de la query. *
* @param resource $ - el resultado de la query.
*/ */
private function parseaResource($resource) { private function parseaResource($resource) {
$fila = mysql_fetch_array($resource); $fila = mysql_fetch_array($resource);
@ -128,14 +119,15 @@ include_once("Automata.php");
/** /**
* Devuelve el valor de un campo. * Devuelve el valor de un campo.
* @param nombre - nombre del campo por el que buscar. *
* @param nombre $ - nombre del campo por el que buscar.
* @return valor del campo buscado. * @return valor del campo buscado.
*/ */
function getValor($nombre) { function getValor($nombre) {
// No se controlan permisos porque se tienen que recuperar datos como el oid del gerente // No se controlan permisos porque se tienen que recuperar datos como el oid del gerente
// para verificar el resto de permisos. // para verificar el resto de permisos.
if (array_key_exists($nombre, $this->campos)) { if (array_key_exists($nombre, $this->campos)) {
// El campo ya lo habíamos recuperamos, lo mostramos // El campo ya lo habíamos recuperamos, lo mostramos
return $this->campos[$nombre]; return $this->campos[$nombre];
} else { } else {
switch ($nombre) { switch ($nombre) {
@ -160,7 +152,6 @@ include_once("Automata.php");
break; break;
default: $consulta = "SELECT " . $nombre . " FROM pedidos WHERE oid=\"" . $this->campos['oid'] . "\""; default: $consulta = "SELECT " . $nombre . " FROM pedidos WHERE oid=\"" . $this->campos['oid'] . "\"";
break; break;
} }
// Lo insertamos para nosotros // Lo insertamos para nosotros
$bd = new BD(); $bd = new BD();
@ -174,6 +165,7 @@ include_once("Automata.php");
/** /**
* Acceso a los campos del pedido. * Acceso a los campos del pedido.
*
* @return los campos del pedido. * @return los campos del pedido.
*/ */
function getCampos() { function getCampos() {
@ -182,8 +174,9 @@ include_once("Automata.php");
/** /**
* Asigna un nuevo campo al pedido. * Asigna un nuevo campo al pedido.
* @param nombre - nombre del campo a asignar. *
* @param valor - valor del campo. * @param nombre $ - nombre del campo a asignar.
* @param valor $ - valor del campo.
*/ */
function setCampo($nombre, $valor) { function setCampo($nombre, $valor) {
// PERMISOS: // PERMISOS:
@ -212,35 +205,6 @@ include_once("Automata.php");
$historial = "$nombre (de $viejo a $valor)"; $historial = "$nombre (de $viejo a $valor)";
} }
//$this->actualizarHistorial($historial); //$this->actualizarHistorial($historial);
//Si hago un update del perfil tengo que actualizar la afinidad:
if(in_array($nombre, $this->listaAfinidad)){
$this->calculaAfinidad();
//En este caso tengo que comprobar si cambio de estado
}else if($nombre == "empleados"){
$necesarios = $valor;
$actuales = count($this->getCandidatosAceptados());
$estado = $this->getValor("estado");
//Actualizo automáticamente el estado del pedido
switch($estado){
case 10:
if($actuales >= $necesarios){
$this->transita("20", "");
}
break;
case 20:
if($actuales < $necesarios){
$this->transita("10", "");
}
break;
case 30:
if($actuales < $necesarios){
$this->transita("10", "");
}
break;
default:
}
}
} }
} }
} else { } else {
@ -275,7 +239,8 @@ include_once("Automata.php");
/** /**
* Asigna nuevos campos al pedido. * Asigna nuevos campos al pedido.
* @param array - lista de campos a asignar de la forma campo => valor. *
* @param array $ - lista de campos a asignar de la forma campo => valor.
*/ */
function setCampos($array) { function setCampos($array) {
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
@ -322,47 +287,6 @@ include_once("Automata.php");
return $lista; return $lista;
} }
/**
* Devuelve una lista de candidatos propuestos para el pedido.
*/
function getCandidatosPropuestos(){
if($this->listaPropuestos == null){
$this->listaPropuestos = $this->getCandidatos("30");
}
return $this->listaPropuestos;
}
/**
* Devuelve una lista de candidatos aceptados para el pedido.
*/
function getCandidatosAceptados(){
if($this->listaAceptados == null){
$this->listaAceptados = $this->getCandidatos("20");
}
return $this->listaAceptados;
}
/**
* Devuelve una lista de candidatos rechazados para el pedido.
*/
function getCandidatosRechazados(){
if($this->listaRechazados == null){
$this->listaRechazados = $this->getCandidatos("10");
}
return $this->listaRechazados;
}
/**
* Devuelve una lista de candidatos propuestos por RRHH.
*/
function getCandidatosPropuestosRRHH(){
if($this->listaPropuestosRRHH == null){
$this->listaPropuestosRRHH = $this->getCandidatos("40");
}
return $this->listaPropuestosRRHH;
}
function proponerCandidato($id, $observacion) { function proponerCandidato($id, $observacion) {
$estadoP = $this->getValor("estado"); $estadoP = $this->getValor("estado");
if ($estadoP == 40) { if ($estadoP == 40) {
@ -393,13 +317,12 @@ include_once("Automata.php");
$candidato = new Empleado($this->usuario, $id); $candidato = new Empleado($this->usuario, $id);
} }
} }
// Actualizamos la BD y las listas; // Actualizamos la BD y las listas;
$nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos"); $nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos");
$nombre_usuario = $this->usuario->getValor("nombre"); $nombre_usuario = $this->usuario->getValor("nombre");
$mensaje = "El candidato $nombre_candidato ha sido propuesto por RRHH ($nombre_usuario)"; $mensaje = "El candidato $nombre_candidato ha sido propuesto por RRHH ($nombre_usuario)";
$this->actualizarHistorial($mensaje); $this->actualizarHistorial($mensaje);
$mensaje = "Propuesto en el pedido $oid por RRHH ($nombre_usuario)"; $mensaje = "Propuesto en la solicitud $oid por RRHH ($nombre_usuario)";
try { try {
$usuario = new Candidato($this->usuario, $id); $usuario = new Candidato($this->usuario, $id);
} catch (Exception $e) { } catch (Exception $e) {
@ -420,25 +343,29 @@ include_once("Automata.php");
*/ */
function aceptarCandidato($id) { function aceptarCandidato($id) {
$estadoP = $this->getValor("estado"); $estadoP = $this->getValor("estado");
if($estadoP == 40 || $estadoP == 50){ if ($estadoP != 130) {
return false; return false;
} }
$this->getCandidatosAceptados(); $this->getCandidatosAceptados();
// Podemos aceptar a candidatos propuestos por el sistema... // Podemos aceptar a candidatos propuestos por el sistema...
$candidato = $this->buscarCandidatoLista($id, $this->getCandidatosPropuestos()); $candidato = $this->buscarCandidatoLista($id, $this->getCandidatosPropuestos());
// a candidatos propuestos por RRHH... // a candidatos propuestos por RRHH...
$rrhh = false; /* $rrhh = false;
$rechazado = false; $rechazado = false;
if ($candidato == null) { if ($candidato == null) {
$candidato = $this->buscarCandidatoLista($id, $this->getCandidatosPropuestosRRHH()); $candidato = $this->buscarCandidatoLista($id, $this->getCandidatosPropuestosRRHH());
$rrhh = true; $rrhh = true;
} } */
// Y a candidatos rechazados. // Y a candidatos rechazados.
if ($candidato == null) { if ($candidato == null) {
$rrhh = false; $rrhh = false;
$candidato = $this->buscarCandidatoLista($id, $this->getCandidatosRechazados()); $candidato = $this->buscarCandidatoLista($id, $this->getCandidatosRechazados());
$rechazado = true; $rechazado = true;
} }
$oid = $this->getValor("oid"); $oid = $this->getValor("oid");
if ($candidato != null) { if ($candidato != null) {
$nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos"); $nombre_candidato = $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos");
@ -453,7 +380,7 @@ include_once("Automata.php");
} }
$usuario->actualizarHistorial($mensaje); $usuario->actualizarHistorial($mensaje);
$candidato->modFechaCandidatura(); $candidato->modFechaCandidatura();
$consulta = "UPDATE candidato_pedido SET estado = '20', fecha = curdate() WHERE candidato = '$id' AND pedido = '$oid'"; $consulta = "UPDATE candidato_pedido SET estado = '120', fecha = curdate() WHERE candidato = '$id' AND pedido = '$oid'";
$bd = new BD(); $bd = new BD();
$bd->execQuery($consulta); $bd->execQuery($consulta);
$lista_antigua = array(); $lista_antigua = array();
@ -482,11 +409,11 @@ include_once("Automata.php");
$this->listaPropuestos = $lista_final; $this->listaPropuestos = $lista_final;
} }
$this->listaAceptados[] = $candidato; $this->listaAceptados[] = $candidato;
// Compruebo el número de empleados: // Compruebo el número de empleados:
$necesarios = $this->getValor("empleados"); /* $necesarios = $this->getValor("empleados");
$actuales = count($this->listaAceptados); $actuales = count($this->listaAceptados);
$estado = $this->getValor("estado"); $estado = $this->getValor("estado");
//Actualizo automáticamente el estado del pedido //Actualizo automáticamente el estado del pedido
switch ($estado) { switch ($estado) {
case 10: case 10:
@ -496,18 +423,14 @@ include_once("Automata.php");
break; break;
default: default:
break; break;
} } */
$estadoC = $usuario->getValor("estado"); $estadoC = $usuario->getValor("estado");
// Actualizo automáticamente el estado del candidato // Actualizo automáticamente el estado del candidato
// Cambiar el estado del candidato. // Cambiar el estado del candidato.
switch ($estadoC) { switch ($estadoC) {
case 10: case 540:
$usuario->transita(30, ""); $usuario->transita(560, "");
break;
case 50:
$usuario->transita(70, "");
break; break;
default: default:
break; break;
@ -523,9 +446,10 @@ include_once("Automata.php");
*/ */
function rechazarCandidato($id) { function rechazarCandidato($id) {
$estadoP = $this->getValor("estado"); $estadoP = $this->getValor("estado");
if($estadoP == 40 || $estadoP == 50){ if ($estadoP != 130) {
return false; return false;
} }
$this->getCandidatosRechazados(); $this->getCandidatosRechazados();
$oid = $this->getValor("oid"); $oid = $this->getValor("oid");
$antiguo = 0; $antiguo = 0;
@ -556,7 +480,7 @@ include_once("Automata.php");
$consulta = "UPDATE candidato_pedido SET estado = '10', fecha = curdate() where candidato = '$id' AND pedido = '$oid'"; $consulta = "UPDATE candidato_pedido SET estado = '10', fecha = curdate() where candidato = '$id' AND pedido = '$oid'";
$bd = new BD(); $bd = new BD();
$bd->execQuery($consulta); $bd->execQuery($consulta);
//Si estaba en la lista de propuestos lo sacamos de ahí // Si estaba en la lista de propuestos lo sacamos de ahí
if ($antiguo == 0) { if ($antiguo == 0) {
$lista = $this->listaPropuestos; $lista = $this->listaPropuestos;
$this->listaPropuestos = null; $this->listaPropuestos = null;
@ -565,7 +489,7 @@ include_once("Automata.php");
$this->listaPropuestos[] = $elem; $this->listaPropuestos[] = $elem;
} }
} }
//Si no, si estaba en la lista de aceptados lo sacamos de ahí // Si no, si estaba en la lista de aceptados lo sacamos de ahí
} else if ($antiguo == 1) { } else if ($antiguo == 1) {
$lista = $this->listaAceptados; $lista = $this->listaAceptados;
$this->listaAceptados = null; $this->listaAceptados = null;
@ -584,7 +508,6 @@ include_once("Automata.php");
} }
} }
$this->listaRechazados[] = $candidato; $this->listaRechazados[] = $candidato;
// Compruebo el número de empleados: // Compruebo el número de empleados:
$necesarios = $this->getValor("empleados"); $necesarios = $this->getValor("empleados");
$actuales = count($this->listaAceptados); $actuales = count($this->listaAceptados);
@ -623,8 +546,9 @@ include_once("Automata.php");
/** /**
* Busca un candidato en una lista. * Busca un candidato en una lista.
* @param id - identificador del candidato a buscar. *
* @param lista - lista en la que buscar al candidato. * @param id $ - identificador del candidato a buscar.
* @param lista $ - lista en la que buscar al candidato.
*/ */
function buscarCandidatoLista($id, $lista) { function buscarCandidatoLista($id, $lista) {
if ($lista) { if ($lista) {
@ -638,7 +562,7 @@ include_once("Automata.php");
} }
/** /**
* Devuelve una lista de tecnologías asociadas al pedido. * Devuelve una lista de tecnologías asociadas al pedido.
*/ */
function getTecnologias() { function getTecnologias() {
if ($this->listaTecnologias == null) { if ($this->listaTecnologias == null) {
@ -697,22 +621,18 @@ include_once("Automata.php");
foreach ($array as $elem) { foreach ($array as $elem) {
$this->addTecnologia($elem); $this->addTecnologia($elem);
} }
$this->calculaAfinidad();
} }
function addIdiomas($array) { function addIdiomas($array) {
foreach ($array as $elem) { foreach ($array as $elem) {
$this->addIdioma($elem); $this->addIdioma($elem);
} }
$this->calculaAfinidad();
} }
function addProvincias($array) { function addProvincias($array) {
foreach ($array as $elem) { foreach ($array as $elem) {
$this->addProvincia($elem); $this->addProvincia($elem);
} }
$this->calculaAfinidad();
} }
function addPerfiles($array) { function addPerfiles($array) {
@ -720,12 +640,11 @@ include_once("Automata.php");
foreach ($array as $elem) { foreach ($array as $elem) {
$this->addPerfil($elem); $this->addPerfil($elem);
} }
$this->calculaAfinidad();
} }
} }
/** /**
* Asocia una nueva tecnología en la base de datos. * Asocia una nueva tecnología en la base de datos.
*/ */
private function addTecnologia($id) { private function addTecnologia($id) {
$oid = $this->getValor("oid"); $oid = $this->getValor("oid");
@ -808,7 +727,7 @@ include_once("Automata.php");
private function addProvincia($id) { private function addProvincia($id) {
$oid = $this->getValor("oid"); $oid = $this->getValor("oid");
$this->getProvincias(); $this->getProvincias();
if(!in_array($id, $this->listasProvincias)){ if (!in_array($id, $this->listaProvincias)) {
$consulta = "SELECT id FROM provincias WHERE oid='$id'"; $consulta = "SELECT id FROM provincias WHERE oid='$id'";
$bd = new BD(); $bd = new BD();
$nombre_provincia = $bd->getCampo($consulta); $nombre_provincia = $bd->getCampo($consulta);
@ -817,7 +736,7 @@ include_once("Automata.php");
if ($bd->execQuery($consulta)) { if ($bd->execQuery($consulta)) {
$mensaje = "Nueva provincia: $nombre_provincia"; $mensaje = "Nueva provincia: $nombre_provincia";
//$this->actualizarHistorial($mensaje); //$this->actualizarHistorial($mensaje);
$this->listasProvincias[$nombre_provincia] = $id; $this->listaProvincias[$nombre_provincia] = $id;
} else { } else {
return false; return false;
} }
@ -856,8 +775,6 @@ include_once("Automata.php");
} else { } else {
return false; return false;
} }
$this->calculaAfinidad();
return true; return true;
} }
@ -889,8 +806,6 @@ include_once("Automata.php");
} else { } else {
return false; return false;
} }
$this->calculaAfinidad();
return true; return true;
} }
@ -900,7 +815,7 @@ include_once("Automata.php");
function removeProvincia($id) { function removeProvincia($id) {
$oid = $this->getValor("oid"); $oid = $this->getValor("oid");
$this->getProvincias(); $this->getProvincias();
if(in_array($id, $this->listasProvincias)){ if (in_array($id, $this->listaProvincias)) {
$consulta = "SELECT id FROM provincias WHERE oid='$id'"; $consulta = "SELECT id FROM provincias WHERE oid='$id'";
$bd = new BD(); $bd = new BD();
$nombre_provincia = $bd->getCampo($consulta); $nombre_provincia = $bd->getCampo($consulta);
@ -909,11 +824,11 @@ include_once("Automata.php");
if ($bd->execQuery($consulta)) { if ($bd->execQuery($consulta)) {
$mensaje = "Eliminada provicia: $nombre_provincia"; $mensaje = "Eliminada provicia: $nombre_provincia";
//$this->actualizarHistorial($mensaje); //$this->actualizarHistorial($mensaje);
$lista = $this->listasProvincias; $lista = $this->listaProvincias;
$this->listasProvincias = null; $this->listaProvincias = null;
foreach ($lista as $key => $value) { foreach ($lista as $key => $value) {
if ($value != $id) { if ($value != $id) {
$this->listasProvincias[$key] = $value; $this->listaProvincias[$key] = $value;
} }
} }
} else { } else {
@ -922,8 +837,6 @@ include_once("Automata.php");
} else { } else {
return false; return false;
} }
$this->calculaAfinidad();
return true; return true;
} }
@ -955,15 +868,13 @@ include_once("Automata.php");
} else { } else {
return false; return false;
} }
$this->calculaAfinidad();
return true; return true;
} }
/** /**
* Calcula la afinidad del pedido con todos los candidatos del sistema. * Calcula la afinidad del pedido con todos los candidatos del sistema.
* @param id - identificador del usuario. *
* @param id $ - identificador del usuario.
*/ */
function calculaAfinidad() { function calculaAfinidad() {
// Recuperamos al pedido: // Recuperamos al pedido:
@ -973,14 +884,15 @@ include_once("Automata.php");
$pesoPerfil = $this->getValor("pesoPerfil"); $pesoPerfil = $this->getValor("pesoPerfil");
// Eliminamos a los usuario de la tabla de candidatos en pedido que se encuentren // Eliminamos a los usuario de la tabla de candidatos en pedido que se encuentren
// en proceso para este pedido. // en proceso para este pedido.
$consulta = "DELETE FROM candidato_pedido WHERE pedido='$id' AND estado='30'"; $consulta = "DELETE FROM candidato_pedido WHERE pedido='$id' AND estado='110'";
$bd = new BD(); $bd = new BD();
$bd->execQuery($consulta); $bd->execQuery($consulta);
// Si el pedido no está cerrado calculamos su afinidad para los usuarios: // Si el pedido no está cerrado calculamos su afinidad para los usuarios:
$estado = $this->getValor("estado"); $estado = $this->getValor("estado");
//Estados válidos: Todos menos cerrado (Pendiente). // Estados válidos: En configuración
if($estado == 10){ if ($estado == "130") {
$consulta = "SELECT email FROM usuarios WHERE tipo='candidato' AND estado IN ('10', '30', '50', '70')"; $consulta = "SELECT email FROM usuarios WHERE tipo='candidato' AND estado IN ('540', '560')";
$bd = new BD(); $bd = new BD();
$listaUsuarios = $bd->arrayQuery($consulta, "email"); $listaUsuarios = $bd->arrayQuery($consulta, "email");
// Calculamos la afinidad de cada usuario. // Calculamos la afinidad de cada usuario.
@ -996,16 +908,19 @@ include_once("Automata.php");
$perfilesUsuario = $usuario->getPerfiles(); $perfilesUsuario = $usuario->getPerfiles();
$provinciasPedido = $this->getProvincias(); $provinciasPedido = $this->getProvincias();
$provinciasDeseadas = $usuario->getProvinciasDeseadas(); $provinciasDeseadas = $usuario->getProvinciasDeseadas();
$provinciasNoDeseadas = $usuario->getProvinciasNoDeseadas();
$afinidad = new Afinidad($idiomasPedido, $idiomasUsuario, $tecnologiasPedido, $afinidad = new Afinidad($idiomasPedido, $idiomasUsuario, $tecnologiasPedido,
$tecnologiasUsuario, $perfilesPedido, $perfilesUsuario, $provinciasPedido, $provinciasDeseadas); $tecnologiasUsuario, $perfilesPedido, $perfilesUsuario, $provinciasPedido, $provinciasDeseadas, $provinciasNoDeseadas);
$afi = $afinidad->calculaAfinidad($pesoIdioma, $pesoPerfil, $pesoTecno); $afi = $afinidad->calculaAfinidad($pesoIdioma, $pesoPerfil, $pesoTecno);
echo $afi . "<br/>";
if ($afi > 0) { if ($afi > 0) {
$consulta = "INSERT INTO candidato_pedido (candidato, pedido, afinidad, estado, fecha) VALUES('$idUsuario', '$id', '$afi', '30', curdate())"; $consulta = "INSERT INTO candidato_pedido (candidato, pedido, afinidad, estado, fecha) VALUES('$idUsuario', '$id', '$afi', '110', curdate())";
$bd = new BD(); $bd = new BD();
$bd->execQuery($consulta); $bd->execQuery($consulta);
} }
} catch (Exception $e) { } catch (Exception $e) {
//Nunca debería entrar aquí. // Nunca debería entrar aquí.
} }
} }
} }
@ -1069,7 +984,8 @@ include_once("Automata.php");
private function ejecutaTransicion($codigo, $argumentos) { private function ejecutaTransicion($codigo, $argumentos) {
// Si no hace nada al transitar salimos sin más. // Si no hace nada al transitar salimos sin más.
if($codigo == 0) return true; if ($codigo == 0)
return true;
$funcion = "ejecutar$codigo"; $funcion = "ejecutar$codigo";
$res = call_user_func(array("Pedido", $funcion), $argumentos); $res = call_user_func(array("Pedido", $funcion), $argumentos);
@ -1077,229 +993,32 @@ include_once("Automata.php");
} }
/** /**
* Pendiente a asignado * Sin calificar -> En configuración
* Admin, Gestor
SE LLEGA DESDE:
- Al aceptar al candidato (pedido.aceptar).
- Editar el número de empleados del pedido.
PRECONDICIONES:
- Comprobar que el número de candidatos aceptados es mayor o igual que el de candidatos necesarios.
POSTCONDICIONES:
- Ninguna.
*/ */
private function ejecutar1020(){ private function ejecutar110130() {
$necesarios = $this->getValor("empleados");
$actuales = count($this->listaAceptados);
//PRECONDICIONES:
//- Comprobar que el número de candidatos aceptados es mayor o igual que el de candidatos necesarios.
if($actuales >= $necesarios){
return true; return true;
}else{
return false;
}
} }
/** /**
* Asignado a Pendiente * En configuración ->Sin calificar
* Admin, Gestor
SE LLEGA DESDE:
- Al rechazar al candidato (pedido.rechazar).
- Editar el número de empleados del pedido.
PRECONDICIONES:
- Comprobar que el número de candidatos aceptados es menor que el de candidatos necesarios.
POSTCONDICIONES:
- Ninguna.
*/ */
private function ejecutar2010(){ private function ejecutar130110() { // De *En configuración* a *Sin calificar*
$necesarios = $this->getValor("empleados");
$actuales = count($this->listaAceptados);
//Comprobamos que se dan las condiciones para transitar.
if($actuales < $necesarios){
return true;
}else{
return false;
}
}
/**
* Asignado a No contratado
* Pendiente a No contratado
* Tramitando contratación a No contratado
* Admin, Gestor
SE LLEGA DESDE:
- La vista del pedido al pulsar el botón de “Cambiar a No contratado”.
PRECONDICIONES:
- Mensaje indicando el motivo del cambio a No contratado.
POSTCONDICIONES:
- Se borra la lista de usuarios aceptados, rechazados y en proceso para este pedido y
para cada candidato cambia a su estado previo de disponible o entrevistado.
*/
private function ejecutar2050($mensaje){
if($mensaje == ""){
$error = "Debe introducir un motivo para pasar el pedido a Desactivado";
throw new Exception($error);
return false;
exit;
}
$id = $this->getValor("oid"); $id = $this->getValor("oid");
$bd = new BD(); $bd = new BD();
//Borro la tabla de candidaturas para este pedido.
// Borro la tabla de ofertas de este pedido
$consulta = "DELETE FROM candidato_pedido WHERE pedido='$id'"; $consulta = "DELETE FROM candidato_pedido WHERE pedido='$id'";
$bd->execQuery($consulta); $bd->execQuery($consulta);
//Cojo los candidatos y limpio las listas del pedido.
$candidatos = $this->getCandidatosAceptados();
if(count($candidatos) > 0){
//Voy empleado por empleado comprobando su estado y transitando.
foreach($candidatos as $c){
$candidato = new Candidato($this->usuario, $c->getValor("oid"));
$estado = $candidato->getValor("estado");
switch ($estado) {
case 30:
$candidato->transita(10, "");
break;
case 70:
$candidato->transita(50, "");
break;
default:
break;
}
}
}
$this->listaPropuestos = null;
$this->listaPropuestosRRHH = null;
$this->listaAceptados = null;
$this->listaRechazados = null;
return true; return true;
} }
/**
* Tramitando contratación a Contratado.
* Admin, Gestor
SE LLEGA DESDE:
- La vista del pedido, al pulsar el botón de “Cambiar a cerrado”.
PRECONDICIONES:
- Todos los candidatos aceptados están incorporados a la empresa.
POSTCONDICIONES:
- Se eliminan todos los candidatos propuestos por el sistema y por RRHH y rechazados
ESCENARIO ALTERNATIVO:
- Por cada candidato aceptado no incorporado a la empresa se generará
una alarma en forma de correo electrónico al personal de recursos humanos para que le incorpore.
*/
private function ejecutar3040(){
$lista = $this->getCandidatosAceptados();
$ok = true;
//Si encontramos algún aceptado que sea candidato tenemos error.
if(count($lista) <= 0){
$error = "No hay candidados aceptados para esta solicitud de oferta";
throw new Exception($error);
return false;
exit;
}
foreach($lista as $candidato){
$tipo = $candidato->getValor("tipo");
//Escenario alternativo
if($tipo != "usuario"){
$nombre = $candidato->getValor("nombre");
$oid = $candidato->getValor("oid");
//Enviar un mail a RRHH con los datos pidiendo incorporación.
$asunto = "Solicitud de contratación";
$direccion = constante("email");
$path = "http://portal.selforsistemas.net";
$link = "<a href='".$path."/detalle_candidato.php?oid=".$oid."'>".$nombre."</a>";
$email = "Se solicita la contratación para el candidato ".$link;
envia_correo($direccion, $asunto, $email);
$ok = false;
}
}
if($ok){
$bd = new BD();
//Borro la tabla de candidaturas para este pedido.
$consulta = "DELETE FROM candidato_pedido WHERE pedido='$id' AND estado IN ('10', '30', '40')";
$bd->execQuery($consulta);
$this->listaPropuestos = null;
$this->listaPropuestosRRHH = null;
}else{
$error = "No se puede contratar aprobar la oferta hasta que todos los candidatos hayan sido contratados.";
throw new Exception($error);
return false;
exit;
}
return $ok;
}
/**
* No contratado a Pendiente
* Admin, Gestor
SE LLEGA DESDE:
- La vista del pedido, al pulsar el botón de “Cambiar a pendiente”.
POSTCONDICIONES:
- Crea un nuevo pedido con los mismos datos cambiando el código y lo pone en “Pendiente”.
- Calcula las afinidades para ese nuevo pedido que está en "Pendiente".
*/
private function ejecutar5010(){
$l = new ListaPedido($this->usuario, "", "", "");
$this->getValor("procedencia");
$this->getValor("cliente");
$bd = new BD();
$miId = $this->getValor("oid");
$consulta = "SELECT * FROM pedidos WHERE oid='$miId'";
$res = $bd->execQuery($consulta);
$this->parseaResource($res);
$campos = array();
foreach($this->campos as $campo => $valor){
if($campo != "oid" && $campo != "fecha")
$campos[$campo] = $valor;
}
$campos["estado"] = 10;
$campos["msgEstado"] = "";
$id = $l->addPedido($campos);
$p = new Pedido($id, $this->usuario);
$p->addTecnologias($this->getTecnologias());
$p->addIdiomas($this->getIdiomas());
$p->addProvincias($this->getProvincias());
// echo '<script type="text/javascript">
// <!--
// if (confirm("Se acaba de crear un nuevo pedido con el codigo:'.$id.'. ¿Desea visualizar el nuevo pedido?")) {
// // Respuesta afirmativa...
// document.location="pedido.php?idPedido='.$id.'";
// }
// -->
// </script>';
$this->calculaAfinidad();
return false;
}
/** /**
* Añade un comentario por parte de un gerente hacia un candidato * Añade un comentario por parte de un gerente hacia un candidato
* @param idCandidato: oid del candidato *
* @param observacion: observacion a proponer * @param idCandidato $ : oid del candidato
* @param observacion $ : observacion a proponer
*/ */
function addComentarioPropuesta($idCandidato, $observacion) { function addComentarioPropuesta($idCandidato, $observacion) {
// Sólo lo puede hacer los gerentes // Sólo lo puede hacer los gerentes
@ -1324,7 +1043,6 @@ include_once("Automata.php");
$candidato = $this->buscarCandidatoLista($idCandidato, $this->getCandidatosAceptados()); $candidato = $this->buscarCandidatoLista($idCandidato, $this->getCandidatosAceptados());
} }
$candidato->modObsGerente($observacion); $candidato->modObsGerente($observacion);
} else { } else {
$error = "No se ha podido actualiar la observaci&oacute;n"; $error = "No se ha podido actualiar la observaci&oacute;n";
throw new Exception($error); throw new Exception($error);
@ -1335,8 +1053,9 @@ include_once("Automata.php");
/** /**
* Añade un comentario por parte de un RRHH hacia un candidato * Añade un comentario por parte de un RRHH hacia un candidato
* @param idCandidato: oid del candidato *
* @param observacion: observacion a proponer * @param idCandidato $ : oid del candidato
* @param observacion $ : observacion a proponer
*/ */
function addComentarioPropuestaRRHH($idCandidato, $observacion) { function addComentarioPropuestaRRHH($idCandidato, $observacion) {
// Sólo lo puede hacer los RRHH // Sólo lo puede hacer los RRHH
@ -1361,7 +1080,6 @@ include_once("Automata.php");
$candidato = $this->buscarCandidatoLista($idCandidato, $this->getCandidatosAceptados()); $candidato = $this->buscarCandidatoLista($idCandidato, $this->getCandidatosAceptados());
} }
$candidato->modObsRRHH($observacion); $candidato->modObsRRHH($observacion);
} else { } else {
$error = "No se ha podido actualiar la observaci&oacute;n"; $error = "No se ha podido actualiar la observaci&oacute;n";
throw new Exception($error); throw new Exception($error);

133
addOferta.php Normal file
View File

@ -0,0 +1,133 @@
<?php
include("seguridad.php");
include("functions.php");
include_once("Objects/ListaOfertas.php");
include_once("Objects/Oferta.php");
include_once("Objects/HTML.php");
$html = new HTML($locale);
$errores = array();
// Todas las variables
if (!empty($_POST)) {
print_r($_POST);
$solicitud = "";
if (!empty($_POST['solicitud'])) {
$solicitud = $_POST['solicitud'][0];
}
/*
$nombre=$_POST['nombre'];
$prioridad=$_POST['prioridad'];
$empleados=$_POST['empleados'];
$duracion=$_POST['duracion'];
$clientes=$_POST['clientes'];
$perfiles=$_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 (empty($solicitud)) {
$errores[] = "1";
}
// Si no hay errores insertamos el pedido
if (count($errores) == 0) {
$listaOfertas = new ListaOfertas($usuario, "", "", "0");
$arrayInsert = array();
$arrayInsert["pedido"] = $solicitud;
$arrayInsert["obsGerente"] = $observaciones;
$arrayInsert["estado"] = "110";
/* $arrayInsert["prioridad"]= $prioridad;
$arrayInsert["empleados"]=$empleados;
$arrayInsert["duracion"]=$duracion;
$arrayInsert["gerente"]=$gerente;
$arrayInsert["cliente"]=$clientes;
$arrayInsert["salario_min"]=$salario_min;
$arrayInsert["salario_max"]=$salario_max;
$arrayInsert["procedencia"]=$procedencia;
$arrayInsert["estado"]="110";
$arrayInsert["pesoIdioma"]=$pesoIdi;
$arrayInsert["pesoPerfil"]=$pesoPer;
$arrayInsert["pesoTecno"]=$pesoTec; */
$idOferta = $listaOfertas->addOferta($arrayInsert);
if ($idOferta == "-1") {
// Se he producido un fallo al insertar
$errores[] = "0";
$msg = "No se ha podido agregar la oferta";
$tipo = "error";
} else {
$oferta = $listaOfertas->buscarOferta($idOferta);
header("Location: oferta.php?idOferta=" . $idOferta . "&msg=1");
}
}
}
} else {
$referencia = "";
$solicitud = "";
$observaciones = "";
}
include("html/cabecera.php");
echo $html->menuOfertas($usuario, "");
echo "<h2>" . $locale['5105'] . "</h2>";
if (isset($msg) && ($msg != "")) {
echo "<div class=\"aviso " . $tipo . "\">" . $msg . "</div>";
}
echo '<form method="POST" action="addOferta.php" name="form_registro" enctype="multipart/form-data">';
echo "<input type=\"hidden\" name=\"action\" value=\"add\" />";
echo "<table id=\"addOferta\">" .
"<tr>" .
" <td";
if (in_array("1", $errores))
echo " class=\"errorcampo\"";
echo ">" . $locale['1025'] . ":<br/>";
rellena_desplegable_pedidos_estado("solicitud", "130", array($solicitud));
echo " </td>";
echo "</td></tr>";
echo "<tr>";
echo "</tr>";
echo '<tr>' .
'<td colspan="3" align="center">' . $locale['135'] .
'<br><textarea name="observaciones" rows="10" cols="120" style="overflow: auto; width:100%;">' . nl2br($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");
?>

View File

@ -84,7 +84,7 @@ if(!empty($_POST)) {
$arrayInsert["salario_max"]=$salario_max; $arrayInsert["salario_max"]=$salario_max;
$arrayInsert["procedencia"]=$procedencia; $arrayInsert["procedencia"]=$procedencia;
$arrayInsert["observaciones"]=$observaciones; $arrayInsert["observaciones"]=$observaciones;
$arrayInsert["estado"]="10"; $arrayInsert["estado"]="110";
$arrayInsert["pesoIdioma"]=$pesoIdi; $arrayInsert["pesoIdioma"]=$pesoIdi;
$arrayInsert["pesoPerfil"]=$pesoPer; $arrayInsert["pesoPerfil"]=$pesoPer;
$arrayInsert["pesoTecno"]=$pesoTec; $arrayInsert["pesoTecno"]=$pesoTec;
@ -96,7 +96,6 @@ if(!empty($_POST)) {
$tipo="error"; $tipo="error";
} else { } else {
$pedido=$listaPedidos->buscarPedido($idPedido); $pedido=$listaPedidos->buscarPedido($idPedido);
print_r($perfiles);
$pedido->addPerfiles($perfiles); $pedido->addPerfiles($perfiles);
$pedido->addTecnologias($tecnologias); $pedido->addTecnologias($tecnologias);
$pedido->addIdiomas($idiomas); $pedido->addIdiomas($idiomas);
@ -172,7 +171,7 @@ echo "</td><td";
if(in_array("5",$errores)) echo " class=\"errorcampo\""; if(in_array("5",$errores)) echo " class=\"errorcampo\"";
echo ">".$locale['121']."<br/>"; echo ">".$locale['121']."<br/>";
// Ticket #565 -> En una solicitud de oferta, se deben poder indicar varios perfiles técnicos // Ticket #565 -> En una solicitud de oferta, se deben poder indicar varios perfiles técnicos
echo $html->listaSelect("perfil","oid","id","perfil",array("",$locale['ns']),$tecnologias,true,true,"15"); echo $html->listaSelect("perfil","oid","id","perfil",array("",$locale['ns']),$perfiles,true,true,"15");
echo "</td><td>".$locale['132'].": ".$locale['2100']; echo "</td><td>".$locale['132'].": ".$locale['2100'];
echo "</td></tr>"; echo "</td></tr>";

View File

@ -8,7 +8,7 @@ if(!$_SESSION["oid"]){
//$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 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 $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 FROM usuarios U,pedidos P,candidato_pedido CP,candidaturas_estados CE
WHERE U.oid='".$persona->getValor("oid")."' WHERE U.oid='".$persona->getValor("oid")."'
AND CP.candidato=U.oid AND CP.candidato=U.oid
AND P.oid=CP.pedido AND P.oid=CP.pedido

View File

@ -75,6 +75,6 @@ if ($link=conectar()){
} }
}else { }else {
//si no existe le mando otra vez a la portada //si no existe le mando otra vez a la portada
header("Location: index.php?errorusuario=si"); // header("Location: index.php?errorusuario=si");
} }
?> ?>

View File

@ -102,15 +102,30 @@ INSERT INTO `candidatos_estados` (`cod`, `idioma`, `nombre`, `tipo`) VALUES
(523, 'sp', 'Rechazado 3', 'candidato'), (523, 'sp', 'Rechazado 3', 'candidato'),
(530, 'sp', 'No disponible', 'candidato'), (530, 'sp', 'No disponible', 'candidato'),
(540, 'sp', 'Disponible sin asignar', 'candidato'), (540, 'sp', 'Disponible sin asignar', 'candidato'),
(550, 'sp', 'Disponible asignado a solicitud histórica', 'candidato'), (550, 'sp', 'Disponible asignado a solicitud cerrada', 'candidato'),
(560, 'sp', 'Disponible asignado a solicitud abierta', 'candidato'); (560, 'sp', 'Disponible asignado a solicitud abierta', 'candidato');
-- -------------------------------------------------------- -- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidaturas_transiciones` (
`inicial` int(10) unsigned NOT NULL,
`final` int(10) unsigned NOT NULL,
`transicion` bigint(20) unsigned NOT NULL,
`rol` text NOT NULL,
PRIMARY KEY (`inicial`,`final`),
KEY `final` (`final`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `candidaturas_transiciones`
ADD CONSTRAINT `candidaturas_transiciones_ibfk_1` FOREIGN KEY (`inicial`) REFERENCES `candidaturas_estado` (`cod`),
ADD CONSTRAINT `candidaturas_transiciones_ibfk_2` FOREIGN KEY (`final`) REFERENCES `candidaturas_estado` (`cod`);
-- --
-- Estructura de tabla para la tabla `candidatos_transiciones` -- Estructura de tabla para la tabla `candidatos_transiciones`
-- --
CREATE TABLE IF NOT EXISTS `candidatos_transiciones` ( CREATE TABLE IF NOT EXISTS `candidatos_transiciones` (
`inicial` int(10) NOT NULL, `inicial` int(10) NOT NULL,
`final` int(10) NOT NULL, `final` int(10) NOT NULL,
@ -167,7 +182,8 @@ INSERT INTO `candidatos_transiciones` (`inicial`, `final`, `transicion`, `rol`)
CREATE TABLE IF NOT EXISTS `candidato_pedido` ( CREATE TABLE IF NOT EXISTS `candidato_pedido` (
`oid` int(10) unsigned NOT NULL AUTO_INCREMENT, `oid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`candidato` bigint(20) unsigned NOT NULL, `referencia` varchar(12) COLLATE latin1_spanish_ci NOT NULL,
`candidato` bigint(20) unsigned,
`pedido` varchar(8) COLLATE latin1_spanish_ci NOT NULL, `pedido` varchar(8) COLLATE latin1_spanish_ci NOT NULL,
`afinidad` float NOT NULL, `afinidad` float NOT NULL,
`estado` int(10) unsigned NOT NULL, `estado` int(10) unsigned NOT NULL,
@ -190,10 +206,10 @@ CREATE TABLE IF NOT EXISTS `candidato_pedido` (
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Estructura de tabla para la tabla `candidaturas_estado` -- Estructura de tabla para la tabla `candidaturas_estados`
-- --
CREATE TABLE IF NOT EXISTS `candidaturas_estado` ( CREATE TABLE IF NOT EXISTS `candidaturas_estados` (
`cod` int(10) unsigned NOT NULL, `cod` int(10) unsigned NOT NULL,
`idioma` varchar(3) COLLATE latin1_spanish_ci NOT NULL, `idioma` varchar(3) COLLATE latin1_spanish_ci NOT NULL,
`nombre` varchar(50) COLLATE latin1_spanish_ci NOT NULL, `nombre` varchar(50) COLLATE latin1_spanish_ci NOT NULL,
@ -201,10 +217,10 @@ CREATE TABLE IF NOT EXISTS `candidaturas_estado` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci; ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
-- --
-- Volcar la base de datos para la tabla `candidaturas_estado` -- Volcar la base de datos para la tabla `candidaturas_estados`
-- --
INSERT INTO `candidaturas_estado` (`cod`, `idioma`, `nombre`) VALUES INSERT INTO `candidaturas_estados` (`cod`, `idioma`, `nombre`) VALUES
(10, 'sp', 'Descartado'), (10, 'sp', 'Descartado'),
(20, 'sp', 'Aceptado'), (20, 'sp', 'Aceptado'),
(30, 'sp', 'En proceso'), (30, 'sp', 'En proceso'),
@ -359,10 +375,6 @@ CREATE TABLE IF NOT EXISTS `historial_pedido` (
KEY `oid_h` (`oid_h`) KEY `oid_h` (`oid_h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci; ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
--
-- Volcar la base de datos para la tabla `historial_pedido`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -378,10 +390,22 @@ CREATE TABLE IF NOT EXISTS `historial_usuario` (
KEY `oid_h` (`oid_h`) KEY `oid_h` (`oid_h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
-- --
-- Volcar la base de datos para la tabla `historial_usuario` -- Estructura de tabla para la tabla `historial_oferta`
-- --
CREATE TABLE IF NOT EXISTS `historial_oferta` (
`oid_h` bigint(20) unsigned NOT NULL,
`fecha_h` varchar(20) CHARACTER SET latin1 COLLATE latin1_spanish_ci NOT NULL,
`persona_h` varchar(20) CHARACTER SET latin1 COLLATE latin1_spanish_ci NOT NULL,
`texto_h` text CHARACTER SET latin1 COLLATE latin1_spanish_ci NOT NULL,
KEY `oid_h` (`oid_h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -759,9 +783,9 @@ INSERT INTO `pedidos_transiciones` (`inicial`, `final`, `transicion`, `rol`) VAL
(110, 120, 0, '1.3'), (110, 120, 0, '1.3'),
(110, 130, 110130, '1.3'), (110, 130, 110130, '1.3'),
(120, 110, 0, '1.3'), (120, 110, 0, '1.3'),
(130, 110, 0, '1.3'), (130, 110, 130110, '1.3'),
(130, 140, 0, ''), (130, 140, 130140, ''),
(140, 130, 0, ''); (140, 130, 140130, '');
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -1469,7 +1493,7 @@ ALTER TABLE `candidatos_estados`
ALTER TABLE `candidato_pedido` ALTER TABLE `candidato_pedido`
ADD CONSTRAINT `candidato_pedido_ibfk_1` FOREIGN KEY (`candidato`) REFERENCES `usuarios` (`oid`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `candidato_pedido_ibfk_1` FOREIGN KEY (`candidato`) REFERENCES `usuarios` (`oid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `candidato_pedido_ibfk_2` FOREIGN KEY (`pedido`) REFERENCES `pedidos` (`oid`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `candidato_pedido_ibfk_2` FOREIGN KEY (`pedido`) REFERENCES `pedidos` (`oid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `candidato_pedido_ibfk_3` FOREIGN KEY (`estado`) REFERENCES `candidaturas_estado` (`cod`) ON UPDATE CASCADE; ADD CONSTRAINT `candidato_pedido_ibfk_3` FOREIGN KEY (`estado`) REFERENCES `candidaturas_estados` (`cod`) ON UPDATE CASCADE;
-- --
-- Filtros para la tabla `clientes` -- Filtros para la tabla `clientes`

View File

@ -1,7 +1,8 @@
<?php <?php
/* Devuelve el nombre de un estado */ /* Devuelve el nombre de un estado */
function nombre_estado($oid){ function nombre_estado($oid)
{
$consulta = "select nombre from candidatos_estados where cod='$oid'"; $consulta = "select nombre from candidatos_estados where cod='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -9,7 +10,8 @@ function nombre_estado($oid){
} }
/* Devuelve el nombre de un estado de candidatura */ /* Devuelve el nombre de un estado de candidatura */
function nombre_estado_candidatura($orden){ function nombre_estado_candidatura($orden)
{
$consulta = "select id from estado_candidatura where oid='$orden'"; $consulta = "select id from estado_candidatura where oid='$orden'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -17,15 +19,25 @@ function nombre_estado_candidatura($orden){
} }
/* Devuelve el nombre de un estado de pedido */ /* Devuelve el nombre de un estado de pedido */
function nombre_estado_pedido($oid){ function nombre_estado_pedido($oid)
{
$consulta = "select nombre from pedidos_estados where cod='$oid'"; $consulta = "select nombre from pedidos_estados where cod='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
return $rows["nombre"]; return $rows["nombre"];
} }
function nombre_estado_oferta($oid)
{
$consulta = "select nombre from candidaturas_estados where cod='$oid'";
$resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado);
return $rows["nombre"];
}
/* Devuelve el nombre de una procedencia */ /* Devuelve el nombre de una procedencia */
function nombre_procedencia($id){ function nombre_procedencia($id)
{
$consulta = "select id from procedencia where num='$id'"; $consulta = "select id from procedencia where num='$id'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -33,7 +45,8 @@ function nombre_procedencia($id){
} }
/* Devuelve el nombre de una procedencia */ /* Devuelve el nombre de una procedencia */
function nombre_procedencia_cv($id){ function nombre_procedencia_cv($id)
{
$consulta = "select nombre from procedencia_cv where id='$id'"; $consulta = "select nombre from procedencia_cv where id='$id'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -41,7 +54,8 @@ function nombre_procedencia_cv($id){
} }
/* Devuelve el nombre de una localidad */ /* Devuelve el nombre de una localidad */
function nombre_localidad($oid){ function nombre_localidad($oid)
{
$consulta = "select id from localidades where oid='$oid'"; $consulta = "select id from localidades where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -49,7 +63,8 @@ function nombre_localidad($oid){
} }
/* Devuelve el nombre de una provincia */ /* Devuelve el nombre de una provincia */
function nombre_provincia($oid){ function nombre_provincia($oid)
{
$consulta = "select id from provincias where oid='$oid'"; $consulta = "select id from provincias where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -57,7 +72,8 @@ function nombre_provincia($oid){
} }
/* Devuelve el nombre de un perfil */ /* Devuelve el nombre de un perfil */
function nombre_perfil($oid){ function nombre_perfil($oid)
{
$consulta = "select id from perfil where oid='$oid'"; $consulta = "select id from perfil where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -65,7 +81,8 @@ function nombre_perfil($oid){
} }
/* Devuelve el nombre de un rol */ /* Devuelve el nombre de un rol */
function nombre_rol($oid){ function nombre_rol($oid)
{
$consulta = "select id from rol where oid='$oid'"; $consulta = "select id from rol where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -73,7 +90,8 @@ function nombre_rol($oid){
} }
/* Devuelve el nombre de un cliente */ /* Devuelve el nombre de un cliente */
function nombre_cliente($oid){ function nombre_cliente($oid)
{
$consulta = "select id from clientes where oid='$oid'"; $consulta = "select id from clientes where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -81,7 +99,8 @@ function nombre_cliente($oid){
} }
/* Devuelve el perfil de un pedido */ /* Devuelve el perfil de un pedido */
function perfil_pedido($oid){ function perfil_pedido($oid)
{
$consulta = "select perfil from pedidos where oid='$oid'"; $consulta = "select perfil from pedidos where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -89,7 +108,8 @@ function perfil_pedido($oid){
} }
/* Devuelve el nombre de un pedido */ /* Devuelve el nombre de un pedido */
function nombre_pedido($oid){ function nombre_pedido($oid)
{
$consulta = "select nombre from pedidos where oid='$oid'"; $consulta = "select nombre from pedidos where oid='$oid'";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);
@ -97,7 +117,8 @@ function nombre_pedido($oid){
} }
/* Devuelve el nombre de un salario */ /* Devuelve el nombre de un salario */
function nombre_salario($id){ function nombre_salario($id)
{
$consulta = "SELECT nombre FROM salario WHERE id='$id'"; $consulta = "SELECT nombre FROM salario WHERE id='$id'";
if ($resultado = mysql_query($consulta)) { if ($resultado = mysql_query($consulta)) {
$rows = mysql_fetch_array($resultado); $rows = mysql_fetch_array($resultado);

View File

@ -201,7 +201,7 @@ carpeta antiword en el ra
/* Devuelve la lista de currículums */ /* Devuelve la lista de currículums */
function menu_curriculums($oid, $tipo){ function menu_curriculums($oid, $tipo){
include LOCALE.LOCALESET."lenguaje.php"; include_once LOCALE.LOCALESET."lenguaje.php";
$consulta = "select * from curriculum_usuario where oid='$oid' order by fecha"; $consulta = "select * from curriculum_usuario where oid='$oid' order by fecha";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$num = @mysql_num_rows($resultado); $num = @mysql_num_rows($resultado);
@ -224,7 +224,7 @@ function menu_curriculums($oid, $tipo){
/* Muestra la lista de currículums */ /* Muestra la lista de currículums */
function ver_curriculums($oid, $tipo){ function ver_curriculums($oid, $tipo){
include LOCALE.LOCALESET."lenguaje.php"; include_once LOCALE.LOCALESET."lenguaje.php";
$consulta = "select * from curriculum_usuario where oid='$oid' order by fecha"; $consulta = "select * from curriculum_usuario where oid='$oid' order by fecha";
$resultado = mysql_query($consulta); $resultado = mysql_query($consulta);
$num = @mysql_num_rows($resultado); $num = @mysql_num_rows($resultado);

View File

@ -3,10 +3,45 @@
ini_set("memory_limit", "32M"); ini_set("memory_limit", "32M");
//require_once ('Excel/reader.php'); //require_once ('Excel/reader.php');
// Función para imprimir cosas
// Sacado de http://php.net/manual/de/debugger.php
// USO:
// > dbug(<loquesea>);
// > " "
// > echo dbug('print');
function dbug() {
static $output = '', $doc_root;
$args = func_get_args();
if (!empty($args) && $args[0] === 'print') {
$_output = $output;
$output = '';
return $_output;
}
// do not repeat the obvious (matter of taste)
if (!isset($doc_root)) {
$doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
}
$backtrace = debug_backtrace();
// you may want not to htmlspecialchars here
$line = htmlspecialchars($backtrace[0]['line']);
$file = htmlspecialchars(str_replace(array('\\', $doc_root), array('/', ''), $backtrace[0]['file']));
$class = !empty($backtrace[1]['class']) ? htmlspecialchars($backtrace[1]['class']) . '::' : '';
$function = !empty($backtrace[1]['function']) ? htmlspecialchars($backtrace[1]['function']) . '() ' : '';
$output .= "<b style='color: red;'>$class$function =&gt;$file #$line</b><pre style='color: red;'>";
ob_start();
foreach ($args as $arg) {
var_dump($arg);
}
$output .= htmlspecialchars(ob_get_contents(), ENT_COMPAT, 'UTF-8');
ob_end_clean();
$output .= '</pre>';
}
/* Conexión a la base de datos */ /* Conexión a la base de datos */
function conectar() function conectar()
{ {
include LOCALE.LOCALESET."lenguaje.php"; include_once LOCALE.LOCALESET."lenguaje.php";
if (!($puntero=mysql_connect("localhost","root","password"))) if (!($puntero=mysql_connect("localhost","root","password")))
{ {
echo $locale['bd']; echo $locale['bd'];
@ -24,8 +59,8 @@ function conectar()
/* Conexión a la base de datos de tablas */ /* Conexión a la base de datos de tablas */
function conectar_info() function conectar_info()
{ {
include LOCALE.LOCALESET."lenguaje.php"; include_once LOCALE.LOCALESET."lenguaje.php";
if (!($puntero=mysql_connect("localhost","root","0selfor0"))) if (!($puntero=mysql_connect("localhost","root","password")))
{ {
echo $locale['bd']; echo $locale['bd'];
return false; return false;

View File

@ -1,33 +1,31 @@
<?php <?php
/* extrae el nombre de fichero de una ruta */ /* extrae el nombre de fichero de una ruta */
function nombre_fichero ($cadena)
{ function nombre_fichero($cadena) {
$salida = split("/", $cadena); $salida = split("/", $cadena);
$i = count($salida); $i = count($salida);
return $salida[$i - 1]; return $salida[$i - 1];
} }
/* extrae el nombre de fichero de una ruta */ /* extrae el nombre de fichero de una ruta */
function nombre_directorio ($cadena)
{ function nombre_directorio($cadena) {
$salida = split("/", $cadena); $salida = split("/", $cadena);
$i = count($salida); $i = count($salida);
return $salida[$i - 2]; return $salida[$i - 2];
} }
/* extrae la extensión del archivo */ /* extrae la extensión del archivo */
function nombre_extension ($cadena)
{ function nombre_extension($cadena) {
$posicion = strrpos($cadena, ".") + 1; $posicion = strrpos($cadena, ".") + 1;
$extension = substr($cadena, $posicion); $extension = substr($cadena, $posicion);
return $extension; return $extension;
} }
/* Elimina los espacios en blanco de una cadena */ /* Elimina los espacios en blanco de una cadena */
function elimina_blancos($cadena) { function elimina_blancos($cadena) {
$salida = split(" ", $cadena); $salida = split(" ", $cadena);
$cadena_limpia = ""; $cadena_limpia = "";
@ -37,6 +35,7 @@ function elimina_blancos ($cadena){
} }
/* Devuelve la provincia a la que pertenece una localidad */ /* Devuelve la provincia a la que pertenece una localidad */
function provincia($localidad) { function provincia($localidad) {
if ($link = conectar()) { if ($link = conectar()) {
if ($resultado = consultar("select * from localidades where oid = '$localidad'", $link)) { if ($resultado = consultar("select * from localidades where oid = '$localidad'", $link)) {
@ -47,6 +46,7 @@ function provincia($localidad){
} }
/* Rellena una lista desplegable de colores */ /* Rellena una lista desplegable de colores */
function rellena_desplegable_color($name) { function rellena_desplegable_color($name) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -60,8 +60,8 @@ function rellena_desplegable_color($name){
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable con los empleados con un permiso concreto */ /* Rellena una lista desplegable con los empleados con un permiso concreto */
function rellena_personal_permiso($nombre, $permiso, $auxiliar, $empleado) { function rellena_personal_permiso($nombre, $permiso, $auxiliar, $empleado) {
include LOCALE . LOCALESET . "lenguaje.php"; include LOCALE . LOCALESET . "lenguaje.php";
$consulta = "select usuarios.oid as oid,nombre from usuarios,rol where usuarios.tipo='usuario' and usuarios.rol = rol.oid and (usuarios.permisos like '%.$permiso%' or usuarios.permisos like '%$permiso.%' or usuarios.permisos = '$permiso' or rol.permisos like '%.$permiso%' or rol.permisos like '%$permiso.%' or rol.permisos = '$permiso')"; $consulta = "select usuarios.oid as oid,nombre from usuarios,rol where usuarios.tipo='usuario' and usuarios.rol = rol.oid and (usuarios.permisos like '%.$permiso%' or usuarios.permisos like '%$permiso.%' or usuarios.permisos = '$permiso' or rol.permisos like '%.$permiso%' or rol.permisos like '%$permiso.%' or rol.permisos = '$permiso')";
@ -82,6 +82,7 @@ function rellena_personal_permiso($nombre, $permiso, $auxiliar, $empleado){
} }
/* Rellena una lista desplegable con los pedidos que puede ver el usuario */ /* Rellena una lista desplegable con los pedidos que puede ver el usuario */
function rellena_desplegable_pedidos($nombre) { function rellena_desplegable_pedidos($nombre) {
include LOCALE . LOCALESET . "lenguaje.php"; include LOCALE . LOCALESET . "lenguaje.php";
echo '<select multiple name="' . $nombre . '[]">'; echo '<select multiple name="' . $nombre . '[]">';
@ -103,6 +104,7 @@ function rellena_desplegable_pedidos($nombre){
} }
/* Rellena una lista desplegable con los pedidos que puede ver el usuario */ /* Rellena una lista desplegable con los pedidos que puede ver el usuario */
function rellena_desplegable_pedidos_ConParametros($nombre, $seleccionadas) { function rellena_desplegable_pedidos_ConParametros($nombre, $seleccionadas) {
include LOCALE . LOCALESET . "lenguaje.php"; include LOCALE . LOCALESET . "lenguaje.php";
echo '<select multiple name="' . $nombre . '[]">'; echo '<select multiple name="' . $nombre . '[]">';
@ -130,7 +132,33 @@ function rellena_desplegable_pedidos_ConParametros($nombre,$seleccionadas){
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable con los pedidos con un estado */
function rellena_desplegable_pedidos_estado($nombre, $estado, $seleccionadas) {
include LOCALE . LOCALESET . "lenguaje.php";
echo '<select multiple name="' . $nombre . '[]">';
if ($link = conectar()) {
$consulta = "select * from pedidos where estado = '$estado' order by prioridad DESC";
if ($resultado = consultar($consulta, $link)) {
if ($seleccionadas[0] == "")
echo '<option value="" selected>' . $locale['ns'] . '</option>';
else
echo '<option value="">' . $locale['ns'] . '</option>';
while ($row = mysql_fetch_array($resultado)) {
if (in_array($row["oid"], $seleccionadas)) {
echo '<option value="' . $row["oid"] . '" selected>' . $row["nombre"] . '</option>';
} else {
echo '<option value="' . $row["oid"] . '">' . $row["nombre"] . '</option>';
}
}
}
}
echo '</select>';
}
/* Rellena una lista desplegable con las localidades de una provincia seleccionando una provincia concreta */ /* Rellena una lista desplegable con las localidades de una provincia seleccionando una provincia concreta */
function rellena_desplegable_localidad($localidad, $nombre) { function rellena_desplegable_localidad($localidad, $nombre) {
include LOCALE . LOCALESET . "lenguaje.php"; include LOCALE . LOCALESET . "lenguaje.php";
echo '<select name="' . $nombre . '" >'; echo '<select name="' . $nombre . '" >';
@ -141,7 +169,8 @@ function rellena_desplegable_localidad($localidad, $nombre){
echo '<option value="" selected>' . $locale['ns'] . '</option>'; echo '<option value="" selected>' . $locale['ns'] . '</option>';
while ($row = mysql_fetch_array($resultado)) { while ($row = mysql_fetch_array($resultado)) {
if ($provincia != $row["provincia"]) { if ($provincia != $row["provincia"]) {
if($provincia != "") echo '</optgroup>'; if ($provincia != "")
echo '</optgroup>';
$provincia = $row["provincia"]; $provincia = $row["provincia"];
echo '<optgroup label="' . nombre_provincia($provincia) . '">'; echo '<optgroup label="' . nombre_provincia($provincia) . '">';
} }
@ -166,7 +195,8 @@ function rellena_desplegable_localidad_mult($localidad, $nombre){
//echo '<option value="" selected>'.$locale['ns'].'</option>'; //echo '<option value="" selected>'.$locale['ns'].'</option>';
while ($row = mysql_fetch_array($resultado)) { while ($row = mysql_fetch_array($resultado)) {
if ($provincia != $row["provincia"]) { if ($provincia != $row["provincia"]) {
if($provincia != "") echo '</optgroup>'; if ($provincia != "")
echo '</optgroup>';
$provincia = $row["provincia"]; $provincia = $row["provincia"];
echo '<optgroup label="' . nombre_provincia($provincia) . '">'; echo '<optgroup label="' . nombre_provincia($provincia) . '">';
} }
@ -190,7 +220,8 @@ function rellena_desplegable_localidad_multSel($localidad, $nombre){
//echo '<option value="" selected>'.$locale['ns'].'</option>'; //echo '<option value="" selected>'.$locale['ns'].'</option>';
while ($row = mysql_fetch_array($resultado)) { while ($row = mysql_fetch_array($resultado)) {
if ($provincia != $row["provincia"]) { if ($provincia != $row["provincia"]) {
if($provincia != "") echo '</optgroup>'; if ($provincia != "")
echo '</optgroup>';
$provincia = $row["provincia"]; $provincia = $row["provincia"];
echo '<optgroup label="' . nombre_provincia($provincia) . '">'; echo '<optgroup label="' . nombre_provincia($provincia) . '">';
} }
@ -203,10 +234,10 @@ function rellena_desplegable_localidad_multSel($localidad, $nombre){
} }
echo '</select>'; echo '</select>';
} }
} }
/* Rellena una lista desplegable */ /* Rellena una lista desplegable */
function rellena_desplegable($tabla, $name, $auxiliar) { function rellena_desplegable($tabla, $name, $auxiliar) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -221,6 +252,7 @@ function rellena_desplegable($tabla,$name,$auxiliar){
} }
/* Rellena una lista desplegable con oid e id */ /* Rellena una lista desplegable con oid e id */
function rellena_desplegable_oid($tabla, $name, $auxiliar) { function rellena_desplegable_oid($tabla, $name, $auxiliar) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -235,6 +267,7 @@ function rellena_desplegable_oid($tabla,$name,$auxiliar){
} }
/* Rellena una lista desplegable de perfiles */ /* Rellena una lista desplegable de perfiles */
function rellena_perfiles($tabla, $name, $auxiliar) { function rellena_perfiles($tabla, $name, $auxiliar) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
echo $auxiliar; echo $auxiliar;
@ -247,8 +280,8 @@ function rellena_perfiles($tabla,$name,$auxiliar){
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable tipo orden-id */ /* Rellena una lista desplegable tipo orden-id */
function rellena_desplegable_orden($tabla, $name, $auxiliar) { function rellena_desplegable_orden($tabla, $name, $auxiliar) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -263,6 +296,7 @@ function rellena_desplegable_orden($tabla,$name,$auxiliar){
} }
/* Rellena una lista desplegable tipo orden-id */ /* Rellena una lista desplegable tipo orden-id */
function rellena_desplegable_select_orden($tabla, $name, $auxiliar, $opcion) { function rellena_desplegable_select_orden($tabla, $name, $auxiliar, $opcion) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
if ($link = conectar()) { if ($link = conectar()) {
@ -279,8 +313,8 @@ function rellena_desplegable_select_orden($tabla,$name,$auxiliar,$opcion){
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable */ /* Rellena una lista desplegable */
function rellena_desplegable_multi($tabla, $name, $auxiliar) { function rellena_desplegable_multi($tabla, $name, $auxiliar) {
echo '<select multiple name="' . $name . '[]">'; echo '<select multiple name="' . $name . '[]">';
@ -369,8 +403,8 @@ function expande($array, $separador){
$valores = substr($valores, 0, strlen($valores) - 2); $valores = substr($valores, 0, strlen($valores) - 2);
} }
/* Rellena una lista desplegable seleccionando una opción */ /* Rellena una lista desplegable seleccionando una opción */
function rellena_desplegable_select($tabla, $name, $auxiliar, $opcion) { function rellena_desplegable_select($tabla, $name, $auxiliar, $opcion) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
echo $auxiliar; echo $auxiliar;
@ -388,6 +422,7 @@ function rellena_desplegable_select($tabla,$name,$auxiliar,$opcion){
} }
/* Rellena una lista desplegable tipo oid id seleccionando una opción */ /* Rellena una lista desplegable tipo oid id seleccionando una opción */
function rellena_desplegable_select_oid($tabla, $name, $auxiliar, $opcion) { function rellena_desplegable_select_oid($tabla, $name, $auxiliar, $opcion) {
$consulta = "select * from " . $tabla; $consulta = "select * from " . $tabla;
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -404,6 +439,7 @@ function rellena_desplegable_select_oid($tabla,$name,$auxiliar,$opcion){
} }
echo '</select>'; echo '</select>';
} }
// Rellena una lista desplegable dando una tabla, el id que quieres sacar, el valor por defecto // Rellena una lista desplegable dando una tabla, el id que quieres sacar, el valor por defecto
// y la opción que hay ahora seleccionada // y la opción que hay ahora seleccionada
function rellena_desplegable_select_oidCol($tabla, $Ccod, $Cnombre, $name, $auxiliar, $opcion) { function rellena_desplegable_select_oidCol($tabla, $Ccod, $Cnombre, $name, $auxiliar, $opcion) {
@ -424,6 +460,7 @@ function rellena_desplegable_select_oidCol($tabla,$Ccod,$Cnombre,$name,$auxiliar
} }
/* Rellena una lista desplegable de procedencias */ /* Rellena una lista desplegable de procedencias */
function rellena_procedencias($name, $auxiliar, $opcion) { function rellena_procedencias($name, $auxiliar, $opcion) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -442,8 +479,8 @@ function rellena_procedencias($name, $auxiliar, $opcion){
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable con más datos */ /* Rellena una lista desplegable con más datos */
function rellena_desplegable_datos($tabla, $name, $aux1, $aux2) { function rellena_desplegable_datos($tabla, $name, $aux1, $aux2) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
@ -461,6 +498,7 @@ function rellena_desplegable_datos($tabla,$name,$aux1, $aux2){
} }
/* Rellena una lista numérica desplegable */ /* Rellena una lista numérica desplegable */
function rellena_numerico($name, $menor, $num) { function rellena_numerico($name, $menor, $num) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
@ -470,40 +508,46 @@ function rellena_numerico($name, $menor, $num){
} }
/* Rellena una lista numérica desplegable seleccionando opción */ /* Rellena una lista numérica desplegable seleccionando opción */
function rellena_prioridad_select($name, $op) { function rellena_prioridad_select($name, $op) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
for ($i = 0; $i < 3; $i++) { for ($i = 0; $i < 3; $i++) {
echo '<option value="' . ($i + 1) . '"'; echo '<option value="' . ($i + 1) . '"';
if($op == ($i+1)) echo "selected"; if ($op == ($i + 1))
echo "selected";
echo '>' . ($i + 1) . ' (' . discretiza_prioridad($i + 1) . ')</option>'; echo '>' . ($i + 1) . ' (' . discretiza_prioridad($i + 1) . ')</option>';
} }
echo '</select>'; echo '</select>';
} }
/* Rellena una lista numérica desplegable seleccionando opción */ /* Rellena una lista numérica desplegable seleccionando opción */
function rellena_numerico_select($name, $menor, $num, $op) { function rellena_numerico_select($name, $menor, $num, $op) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
echo '<option value="' . ($menor + $i + 1) . '"'; echo '<option value="' . ($menor + $i + 1) . '"';
if($op == ($menor+$i+1)) echo "selected"; if ($op == ($menor + $i + 1))
echo "selected";
echo '>' . ($menor + $i + 1) . '</option>'; echo '>' . ($menor + $i + 1) . '</option>';
} }
echo '</select>'; echo '</select>';
} }
/* Rellena una lista desplegable con los días de la semana seleccionando */ /* Rellena una lista desplegable con los días de la semana seleccionando */
function rellena_semana_select($name, $activacion) { function rellena_semana_select($name, $activacion) {
echo '<select name="' . $name . '">'; echo '<select name="' . $name . '">';
for ($i = 0; $i < 7; $i++) { for ($i = 0; $i < 7; $i++) {
echo '<option value="' . ($i + 1) . '"'; echo '<option value="' . ($i + 1) . '"';
if($activacion == ($i+1)) echo "selected"; if ($activacion == ($i + 1))
echo "selected";
echo '>' . nombre_dia($i + 1) . '</option>'; echo '>' . nombre_dia($i + 1) . '</option>';
} }
echo '</select>'; echo '</select>';
} }
/* Rellena un desplegable para elegir fecha */ /* Rellena un desplegable para elegir fecha */
function rellena_fecha() { function rellena_fecha() {
$dia = date("j"); $dia = date("j");
$mes = date("n"); $mes = date("n");
@ -519,18 +563,21 @@ function rellena_fecha(){
} }
/* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro */ /* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro */
function rellena_fecha_nombre_select($fecha) { function rellena_fecha_nombre_select($fecha) {
rellena_fecha_select($fecha, ""); rellena_fecha_select($fecha, "");
} }
/* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro y nombre del select */ /* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro y nombre del select */
function rellena_fecha_select($fecha, $nombre) { function rellena_fecha_select($fecha, $nombre) {
include LOCALE . LOCALESET . "lenguaje.php"; include LOCALE . LOCALESET . "lenguaje.php";
$tiempo = explode("-", $fecha); $tiempo = explode("-", $fecha);
$dia = $tiempo[2]; $dia = $tiempo[2];
$mes = $tiempo[1]; $mes = $tiempo[1];
$anyo = $tiempo[0]; $anyo = $tiempo[0];
if($anyo <= 0) $anyo = date('Y'); if ($anyo <= 0)
$anyo = date('Y');
echo $locale['318']; echo $locale['318'];
rellena_numerico_select("dia" . $nombre, 0, 31, $dia); rellena_numerico_select("dia" . $nombre, 0, 31, $dia);
echo $locale['328']; echo $locale['328'];
@ -540,6 +587,7 @@ function rellena_fecha_select($fecha, $nombre){
} }
/* Rellena una lista a borrar */ /* Rellena una lista a borrar */
//function rellena_borrable($tabla, $tabla2, $nombre, $oid){ //function rellena_borrable($tabla, $tabla2, $nombre, $oid){
// if ($link = conectar()){ // if ($link = conectar()){
// $consulta = "select * from ".$tabla.",".$tabla2." where $tabla.$nombre = $tabla2.oid and oid_i = ".$oid.""; // $consulta = "select * from ".$tabla.",".$tabla2." where $tabla.$nombre = $tabla2.oid and oid_i = ".$oid."";
@ -565,7 +613,9 @@ function rellena_borrable_ConDestino($tabla, $tabla2, $nombre, $oid,$destino){
} }
/* Rellena una lista */ /* Rellena una lista */
function rellena_lista($tabla, $nombre, $oid) { function rellena_lista($tabla, $nombre, $oid) {
$res = array();
if ($link = conectar()) { if ($link = conectar()) {
$consulta = "select * from " . $tabla . " where oid_i = " . $oid . ""; $consulta = "select * from " . $tabla . " where oid_i = " . $oid . "";
if ($resultado = consultar($consulta, $link)) { if ($resultado = consultar($consulta, $link)) {
@ -579,9 +629,12 @@ function rellena_lista($tabla, $nombre, $oid){
} }
/* Rellena una lista */ /* Rellena una lista */
function rellena_lista_oid($tabla, $tabla2, $nombre, $oid) { function rellena_lista_oid($tabla, $tabla2, $nombre, $oid) {
$res = array();
if ($link = conectar()) { if ($link = conectar()) {
$consulta = "select * from " . $tabla . "," . $tabla2 . " where $tabla.$nombre = $tabla2.oid and oid_i = " . $oid . ""; $consulta = "select * from " . $tabla . "," . $tabla2 . " where $tabla.$nombre = $tabla2.oid and oid_i = " . $oid . "";
if ($resultado = consultar($consulta, $link)) { if ($resultado = consultar($consulta, $link)) {
while ($row = mysql_fetch_array($resultado)) { while ($row = mysql_fetch_array($resultado)) {
$res[] = $row["id"]; $res[] = $row["id"];
@ -593,6 +646,7 @@ function rellena_lista_oid($tabla, $tabla2, $nombre, $oid){
} }
/* Muestra los resultados */ /* Muestra los resultados */
function mostrar_resultados($errores, $aciertos) { function mostrar_resultados($errores, $aciertos) {
$oid = $_SESSION["oid"]; $oid = $_SESSION["oid"];
$errores = explode(".", $errores); $errores = explode(".", $errores);
@ -630,6 +684,7 @@ function mostrar_resultados($errores, $aciertos){
} }
/* Muestra los errores */ /* Muestra los errores */
function mostrar_errores($errores) { function mostrar_errores($errores) {
$errores = explode(".", $errores); $errores = explode(".", $errores);
foreach ($errores as $error) { foreach ($errores as $error) {
@ -638,6 +693,7 @@ function mostrar_errores($errores){
} }
/* Muestra los aciertos */ /* Muestra los aciertos */
function mostrar_aciertos($aciertos) { function mostrar_aciertos($aciertos) {
$aciertos = explode(".", $aciertos); $aciertos = explode(".", $aciertos);
foreach ($aciertos as $acierto) { foreach ($aciertos as $acierto) {
@ -646,6 +702,7 @@ function mostrar_aciertos($aciertos){
} }
/* Devuelve un array con los valores de un campo de una tabla */ /* Devuelve un array con los valores de un campo de una tabla */
function input_array_tabla($nombre, $tabla, $campo, $oid) { function input_array_tabla($nombre, $tabla, $campo, $oid) {
$consulta = "select " . $campo . " from " . $tabla . " where oid_i=" . $oid . ""; $consulta = "select " . $campo . " from " . $tabla . " where oid_i=" . $oid . "";
//echo ($consulta); //echo ($consulta);
@ -656,6 +713,7 @@ function input_array_tabla($nombre, $tabla, $campo, $oid){
} }
/* Devuelve el color de una procedencia */ /* Devuelve el color de una procedencia */
function color_procedencia($procedencia) { function color_procedencia($procedencia) {
if ($link = conectar()) { if ($link = conectar()) {
@ -664,7 +722,6 @@ function color_procedencia($procedencia){
return $row["color"]; return $row["color"];
} }
} }
} }
// Strip Input Function, prevents HTML in unwanted places // Strip Input Function, prevents HTML in unwanted places

View File

@ -294,7 +294,7 @@ $locale['283'] = "Selecci&oacute;n solicitudes de oferta";
$locale['284'] = "Editar"; $locale['284'] = "Editar";
$locale['285'] = "Mostrar"; $locale['285'] = "Mostrar";
$locale['286'] = "Nota: los campos marcados con * son obligatorios."; $locale['286'] = "Nota: los campos marcados con * son obligatorios.";
$locale['287'] = "Candidatos <br> asignados"; $locale['287'] = "N&uacute;mero<br/>de ofertas";
$locale['288'] = "Actualizar parte"; $locale['288'] = "Actualizar parte";
$locale['289'] = "Solicitar vacaciones"; $locale['289'] = "Solicitar vacaciones";
$locale['290'] = "Se ha solicitado correctamente los d&iacute;as "; $locale['290'] = "Se ha solicitado correctamente los d&iacute;as ";
@ -1013,4 +1013,14 @@ $locale['4048'] = "Cualquier perfil t&eacute;cnico";
$locale['5001'] = "Provincia no deseada:"; $locale['5001'] = "Provincia no deseada:";
$locale['5002'] = "Se ha eliminado la provincia no deseada correctamente"; $locale['5002'] = "Se ha eliminado la provincia no deseada correctamente";
$locale['5003'] = "Estado"; $locale['5003'] = "Estado";
$locale['5100'] = "Lista de ofertas";
$locale['5101'] = "Nueva oferta";
$locale['5102'] = "Buscar oferta";
$locale['5103'] = "Ver oferta";
$locale['5104'] = "Afinidad";
$locale['5105'] = "A&ntilde;adir nueva oferta";
$locale['5106'] = "Referencia";
$locale['5107'] = "Candidato";
?> ?>

View File

@ -139,6 +139,15 @@ function eliminaCapa(idCapa) {
function mostrarCapa(idCapa){ function mostrarCapa(idCapa){
document.getElementById(idCapa).style.visibility="visible"; document.getElementById(idCapa).style.visibility="visible";
} }
function ocultarCapa(idCapa){ function ocultarCapa(idCapa){
document.getElementById(idCapa).style.visibility="hidden"; document.getElementById(idCapa).style.visibility="hidden";
} }
function cambiarCandidato(lugar) {
var mensaje="Esta oferta ya tiene asignada un candidato. \xbfEst\xe1 seguro que desea sustituirlo?";
if(confirm(mensaje)){
document.location=lugar;
}
}

41
lista_ofertas.php Normal file
View File

@ -0,0 +1,41 @@
<?php
include("seguridad.php");
include("functions.php");
if (!$usuario->tieneRol("4") && !$usuario->tieneRol("1") && !$usuario->tieneRol("3")) {
header("Location: aplicacion.php?e=permiso&rol=" . $usuario->getValor("rol"));
exit;
}
include_once("html/cabecera.php");
/* LISTA_PROYECTOS.PHP */
$consulta = "";
include_once("Objects/ListaOfertas.php");
include_once("Objects/HTML.php");
$html = new HTML($locale);
echo $html->menuOfertas($usuario, "");
echo "<h2>" . "Lista de ofertas" . "</h2>";
$tipoOfertas = (!empty($_GET["byEstado"])) ? $_GET['byEstado'] : "";
$order_by = (!empty($_GET['order'])) ? $_GET['order'] : "";
$modo = (!empty($_GET['modo'])) ? $_GET["modo"] : "";
// sacado de http://patrickallaert.blogspot.com/2007/09/building-dynamic-sql-queries-elegant.html
$cond = array();
if ($tipoOfertas != "") {
$cond[] = "estado = '$tipoOfertas'";
}
$orden = array();
if ($order_by != "") {
$orden[] = $order_by.' '.$modo;
}
$listaOfertas = new ListaOfertas($usuario, $cond, $orden);
include_once("ver_lista_ofertas.php");
include_once("html/pie.php");
?>

View File

@ -30,7 +30,7 @@ if (isset($_GET["order"]) && ($_GET["order"]!="")) {
$modo = (isset($_GET["modo"])) ? stripinput($_GET["modo"]) : ""; $modo = (isset($_GET["modo"])) ? stripinput($_GET["modo"]) : "";
$tipoPedidos = (isset($_GET["byEstado"]) && ($_GET['byEstado'] != "")) ? $_GET['byEstado'] : "10"; $tipoPedidos = (isset($_GET["byEstado"]) && ($_GET['byEstado'] != "")) ? $_GET['byEstado'] : "0";
$listaPedidos=new ListaPedido($usuario,$order_by,"",$tipoPedidos); $listaPedidos=new ListaPedido($usuario,$order_by,"",$tipoPedidos);

15
oferta.php Normal file
View File

@ -0,0 +1,15 @@
<?php
include_once("seguridad.php");
include("functions.php");
$idOferta = isset($_GET["idOferta"]) ? stripinput($_GET["idOferta"]) : "";
$tabla = isset($_POST["tabla"]) ? stripinput($_POST["tabla"]) : "";
$where = isset($_POST["where"]) ? stripinput($_POST["where"]) : "";
$condicion = isset($_POST["condicion"]) ? stripinput($_POST["condicion"]) : "";
include_once("ver_oferta.php");
include_once("html/pie.php");
?>

View File

@ -4,9 +4,9 @@ include("seguridad.php");
include("functions.php"); include("functions.php");
$idPedido = isset($_GET["idPedido"]) ? stripinput($_GET["idPedido"]) : ""; $idPedido = isset($_GET["idPedido"]) ? stripinput($_GET["idPedido"]) : "";
if(!isset($tabla)) $tabla = stripinput($_POST["tabla"]); $tabla = isset($_POST["tabla"]) ? stripinput($_POST["tabla"]) : "";
if(!isset($where)) $where = stripinput($_POST["where"]); $where = isset($_POST["where"]) ? stripinput($_POST["where"]) : "";
if(!isset($condicion)) $condicion = stripinput($_POST["condicion"]); $condicion = isset($_POST["condicion"]) ? stripinput($_POST["condicion"]) : "";
include_once("ver_pedido.php"); include_once("ver_pedido.php");

View File

@ -6,7 +6,6 @@ ini_set("session.use_trans_sid","0");
//iniciamos la sesión //iniciamos la sesión
session_name("loginUsuario"); session_name("loginUsuario");
include_once("Objects/Usuario.php"); include_once("Objects/Usuario.php");
include_once("Objects/ListaPedido.php");
include_once("Objects/Semaforo.php"); include_once("Objects/Semaforo.php");
session_start(); session_start();
//FICHERO DE IDIOMAS //FICHERO DE IDIOMAS

155
ver_lista_ofertas.php Normal file
View File

@ -0,0 +1,155 @@
<?php
include_once("seguridad.php");
/**
* Muestra toda la lista de ofertas de $listaOfertas
*/
include("functions.php");
$destinoURL = substr($_SERVER['REQUEST_URI'], strripos($_SERVER['REQUEST_URI'], "/") + 1);
if (stripos($destinoURL, "?") > 0) {
$destinoURL = substr($destinoURL, 0, stripos($destinoURL, "?"));
}
// Comprobamos mensajes que pueden llegar hasta aqui
if (isset($_GET['msg'])) {
switch ($_GET['msg']) {
case "1":$mensaje = "<div class=\"aviso ok\">" . $locale['1059'] . "</div>";
break;
case "2":$mensaje = "<div class=\"aviso error\">" . $locale['1060'] . "</div>";
break;
default:
break;
}
}
if (isset($mensaje)) echo $mensaje;
if (!isset($variablesExtra)) $variablesExtra = "";
?>
<div style="float:left; padding-top:10px; border-top:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC;background-color:#F0F0F0">
<ul id="tabnav">
<li class="<?php if ($tipoOfertas == "") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=0" . $variablesExtra; ?>"><?php echo $locale['1067']; ?></a></li>
<li class="<?php if ($tipoOfertas == "110") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=110" . $variablesExtra; ?>"><?php echo nombre_estado_oferta("110"); ?></a></li>
<li class="<?php if ($tipoOfertas == "120") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=120" . $variablesExtra; ?>"><?php echo nombre_estado_oferta("120"); ?></a></li>
<li class="<?php if ($tipoOfertas == "130") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=130" . $variablesExtra; ?>"><?php echo nombre_estado_oferta("130"); ?></a></li>
<li class="<?php if ($tipoOfertas == "140") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=140" . $variablesExtra; ?>"><?php echo nombre_estado_oferta("140"); ?></a></li>
<li class="<?php if ($tipoOfertas == "150") echo "activo";
else echo "inactivo";
?>"><a href="<?php echo $destinoURL . "?byEstado=150" . $variablesExtra; ?>"><?php echo nombre_estado_oferta("150"); ?></a></li>
</ul>
</div>
<div style="height: 35px; border-bottom:1px solid #CCC"></div>
<div style="clear:both;"></div>
<?php
echo '<div id="ContTabul">';
// CABECERAS
echo "<table width=\"100%\"> ";
// Acciones
echo "<tr class=\"encabezado\">";
echo " <td align=\"center\" colspan=\"3\">" . $locale['2014'] . "</td>";
// denominacion
$orderView = "denominacion";
echo " <td align=\"center\">" . $locale['1042'].":" . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>";
// Fecha
$orderView = "fecha";
echo " <td align=\"center\">" . $locale['1021'] . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>" ;
// estado
$orderView = "estado";
echo " <td align=\"center\">" . $locale['1102'] . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>";
// solicitud
$orderView = "solicitud";
echo " <td align=\"center\">" . $locale['278'].":" . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>";
// Cliente
$orderView = "candidato";
echo " <td align=\"center\">" . $locale['704'].":" . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>";
// Afinidad
/*$orderView = "afinidad";
echo " <td align=\"center\">" . $locale['5104'] . "<br />" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=asc" . $variablesExtra . "\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"" . $destinoURL . "?byEstado=" . $tipoOfertas . "&order=" . $orderView . "&modo=desc" . $variablesExtra . "\" ><img src=\"css/desc.png\" /></a></td>";
*/
echo "</tr>";
// Vamos mostrando ofertas
$listadeOfertas = $listaOfertas->getOfertas();
$pagLista = "1";
if (!empty($_GET['pagLista']) && ($_GET['pagLista'] > 0)) {
$pagLista = $_GET['pagLista'];
}
// Vemos si tiene ofertas
if (count($listadeOfertas) == 0) {
echo "<tr><td colspan=\"11\" align=\"center\">no hay ofertas</td></tr></table>";
} else {
$inicio = ($pagLista - 1) * constante("lista");
if (count($listadeOfertas) > ($inicio + constante("lista"))) {
$final = $inicio + constante("lista");
} else {
$final = count($listadeOfertas);
}
for ($i = $inicio;$i < $final;$i++) {
// foreach($listadeOfertas as $ofertaAct){
$ofertaAct = $listadeOfertas[$i];
echo "<tr>";
if (($ofertaAct->getValor("gerente") == $usuario->getValor("oid")) || $usuario->tieneRol("1")) {
// Es el gerente de ese pedido, puede editarlo y eliminarlo
echo '<td align="center"><a href="gestion_pedido.php?idPedido=' . $ofertaAct->getValor("oid") . '"><img src="css/edit.png" title="' . $locale['2017'] . '"/></a></td>';
echo "<td align=\"center\"><a href=\"#\" onclick=eliminarPedido('" . $ofertaAct->getValor("oid") . "') ><img src=\"css/eliminar.png\" title=\"" . $locale['2016'] . "\"/></a></td>";
} else {
// No es el gerente no puede ni editarlo ni eliminarlo
echo '<td></td><td></td>';
}
echo '<td align="center"><a href="oferta.php?idOferta=' . $ofertaAct->getValor("oid") . '"><img src="css/brick_go.png" title="' . $locale['2015'] . '" /></a></td>';
echo '<td align="center">' . $ofertaAct->getValor("referencia") . '</td>';
echo '<td align="center">' . $ofertaAct->getValor("fecha") . '</td>';
echo '<td align="center">' . $ofertaAct->getValor("nombre_estado") . '</td>';
echo '<td align="center"><a href="/pedido.php?idPedido=' . $ofertaAct->getValor("pedido") . '">' . $ofertaAct->getValor("nombre_solicitud") . '</a></td>';
echo '<td align="center"><a href="/detalle_candidato.php?oid=' . $ofertaAct->getValor("candidato") . '">' . $ofertaAct->getValor("nombre_candidato") . '</td>';
//echo '<td align="center">' . $ofertaAct->getValor("afinidad") . '</td>';
echo "</tr>";
}
// Comprobamos si tenemos que mostar una paginación
$numPaginas = ceil(count($listadeOfertas) / constante("lista"));
echo "<td colspan=\"11\"><div id=\"cronopaginacion\">";
if (isset($_GET["order"]) && ($_GET["order"] != "")) {
if ($variablesExtra != "") {
$variablesExtra = "&" . $variablesExtra;
}
$variables = "byEstado=" . $tipoOfertas . "order=" . $_GET["order"] . "&modo=" . $_GET["modo"] . $variablesExtra;
echo $html->paginacion($numPaginas, $pagLista, $destinoURL, $variables, "pagLista");
} else {
$variables = "byEstado=" . $tipoOfertas . $variablesExtra;
echo $html->paginacion($numPaginas, $pagLista, $destinoURL, $variables, "pagLista");
}
echo "</div></td></tr>";
echo " </table> ";
}
echo '</div>';
?>

View File

@ -33,9 +33,10 @@ if (!isset($variablesExtra)) $variablesExtra = "";
<div style="float:left; padding-top:10px; border-top:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC;background-color:#F0F0F0"> <div style="float:left; padding-top:10px; border-top:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC;background-color:#F0F0F0">
<ul id="tabnav"> <ul id="tabnav">
<li class="<?php if ($tipoPedidos=="0") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=0".$variablesExtra; ?>"><?php echo $locale['1067']; ?></a></li> <li class="<?php if ($tipoPedidos=="0") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=0".$variablesExtra; ?>"><?php echo $locale['1067']; ?></a></li>
<li class="<?php if ($tipoPedidos=="10") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=10".$variablesExtra; ?>"><?php echo nombre_estado_pedido("10"); ?></a></li> <li class="<?php if ($tipoPedidos=="110") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=110".$variablesExtra; ?>"><?php echo nombre_estado_pedido("110"); ?></a></li>
<li class="<?php if ($tipoPedidos=="20") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=20".$variablesExtra; ?>"><?php echo nombre_estado_pedido("20"); ?></a></li> <li class="<?php if ($tipoPedidos=="120") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=120".$variablesExtra; ?>"><?php echo nombre_estado_pedido("120"); ?></a></li>
<li class="<?php if ($tipoPedidos=="30") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=30".$variablesExtra; ?>"><?php echo nombre_estado_pedido("30"); ?></a></li> <li class="<?php if ($tipoPedidos=="130") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=130".$variablesExtra; ?>"><?php echo nombre_estado_pedido("130"); ?></a></li>
<li class="<?php if ($tipoPedidos=="140") echo "activo"; else echo "inactivo";?>"><a href="<?php echo $destinoURL."?byEstado=140".$variablesExtra; ?>"><?php echo nombre_estado_pedido("140"); ?></a></li>
</ul> </ul>
</div> </div>
<div style="float:left;padding-top:11px;"> <div style="float:left;padding-top:11px;">
@ -113,24 +114,22 @@ echo " <td align=\"center\">".$locale['1524']."<br />" .
" <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=asc".$variablesExtra."\" ><img src=\"css/asc.png\" /></a>" . " <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=asc".$variablesExtra."\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=desc".$variablesExtra."\" ><img src=\"css/desc.png\" /></a></td>"; " <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=desc".$variablesExtra."\" ><img src=\"css/desc.png\" /></a></td>";
// Número de personas // Número de ofertas
$orderView="empleados"; $orderView="empleados";
echo " <td align=\"center\">".$locale['1024']."<br />" . echo " <td align=\"center\">".$locale['287']."<br />" .
" <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=asc".$variablesExtra."\" ><img src=\"css/asc.png\" /></a>" . " <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=asc".$variablesExtra."\" ><img src=\"css/asc.png\" /></a>" .
" <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=desc".$variablesExtra."\" ><img src=\"css/desc.png\" /></a></td>"; " <a href=\"".$destinoURL."?byEstado=".$tipoPedidos."&order=".$orderView."&modo=desc".$variablesExtra."\" ><img src=\"css/desc.png\" /></a></td>";
// Candidatos asignados
echo " <td align=\"center\">".$locale['287']."</td>";
echo "</tr>"; echo "</tr>";
// Vamos mostrando petición por petición // Vamos mostrando petición por petición
$listadePedidos=$listaPedidos->getPedidos(); $listadePedidos=$listaPedidos->getPedidos();
if($_GET['pagLista']>0){
$pagLista=$_GET['pagLista'];
}else{
$pagLista = "1"; $pagLista = "1";
if (!empty($_GET['pagLista']) && ($_GET['pagLista'] > 0)) {
$pagLista = $_GET['pagLista'];
} }
// Vemos si tiene pedidos // Vemos si tiene pedidos
if(count($listadePedidos)==0){ if(count($listadePedidos)==0){
echo "<tr><td colspan=\"11\" align=\"center\">no tiene solicitudes de oferta</td></tr></table>"; echo "<tr><td colspan=\"11\" align=\"center\">no tiene solicitudes de oferta</td></tr></table>";
@ -172,7 +171,6 @@ if(count($listadePedidos)==0){
echo '</td>'; echo '</td>';
echo '<td align="center">'.$pedidoAct->getValor("empleados").'</td>'; echo '<td align="center">'.$pedidoAct->getValor("empleados").'</td>';
echo '<td align="center">'.$pedidoAct->dameNumCand("Aceptado").'</td>';
echo "</tr>"; echo "</tr>";
} }
// Comprobamos si tenemos que mostar una paginación // Comprobamos si tenemos que mostar una paginación

271
ver_oferta.php Normal file
View File

@ -0,0 +1,271 @@
<?php
include_once("Objects/Oferta.php");
include_once("seguridad.php");
$usuario = $_SESSION['usuario'];
$oferta = new Oferta($idOferta, $usuario);
include_once("html/cabecera.php");
include_once("Objects/Administracion.php");
$administracion = new Administracion($usuario, $locale);
$constantes = $administracion->getItem("constantes");
$mostrarTabla = $constantes['candPagina'];
$altoScroll = 83 / 2 * $mostrarTabla;
?>
<?php
include_once("Objects/HTML.php");
$html = new HTML($locale);
// Comprogamos si hay error de semaforo activo
if (isset($_GET["msgSem"]) && ($_GET["msgSem"] != "")) {
$mensajeSemaforo = $semaforo->getMensaje($_GET["msgSem"]);
echo "<div class=\"aviso semaforo\">" . $mensajeSemaforo . "</div>";
}
$action = (isset($_GET['action']) && ($_GET['action'] != "")) ? $_GET['action'] : "";
if (!empty($action)) {
$error = false;
$mensaje = "";
switch ($action) {
case "aceptar":
if (!empty($_GET['idCand'])) {
try {
$idCand = $_GET['idCand'];
$estado = $oferta->colocarCandidato($idCand);
if ($estado) {
$tipo = "ok";
$mensaje = "El candidato se ha asignado a la oferta";
} else {
$tipo = "error";
$mensaje = "No se ha podido asignar el candidato a la oferta";
}
} catch (Exception $e) {
$mensaje = $e->getMessage();
$tipo = "error";
}
} else {
$tipo = "error";
$mensaje = $locale['1053'];
}
break;
case "cambEst": if (!empty($_GET['idEst'])) {
$idEstado = $_GET['idEst'];
try {
$camb = $oferta->transita($idEstado, "");
if ($camb) {
$tipo = "ok";
$mensaje = $locale['1072'];
} else {
$tipo = "error";
$mensaje = $locale['1073'];
}
} catch (Exception $e) {
$mensaje = $e->getMessage();
$tipo = "error";
}
}
break;
default: $error = true;
$mensaje = $locale['1057'];
break;
}
if ($mensaje != "") {
// Mostramos el mensaje
echo "<div class=\"aviso " . $tipo . "\">" . $mensaje . "</div>";
}
}
if (($oferta->getValor("estado") == 110) || ($oferta->getValor("estado") == 120)) {
echo $html->menuOfertas($usuario, array(""));
} else
echo $html->menuOfertas($usuario, "gestionar");
?>
<h2><?php echo $oferta->getValor("nombre"); ?></h2>
<?php
// Comprobamos mensajes que pueden llegar hasta aqui
if (isset($_GET["msg"])) {
switch ($_GET['msg']) {
case "1": $mensaje = "<div class=\"aviso ok\">" . $locale['1061'] . "</div>";
break;
default:
break;
}
} else {
$mensaje = "";
}
echo $mensaje;
?>
<table width="100%">
<tr><td>
<table width="100%">
<tr>
<td class="nombre"><?php echo $locale['5106']; ?></td>
<td><?php echo $oferta->getValor("referencia"); ?></td>
</tr>
<tr>
<td class="nombre"><?php echo $locale['1025']; ?></td>
<td><?php echo $oferta->getValor("nombre_solicitud"); ?></td>
</tr>
<tr>
<td class="nombre"><?php echo $locale['132']; ?></td>
<td><?php echo $oferta->getValor("nombre_estado"); ?>
<div id="obsCambioEst" class="obsCambioEst">
<form id="formCambEst" action="oferta.php?idOferta=<?php echo $oferta->getValor("oid"); ?>&action=cambEstObs" method="post" >
<input type="hidden" name="action" value="cambEstObs" />
<input type="hidden" name="idEstado" id="idEstado" />
</form>
</div>
<?php
if ($oferta->getValor("msgEstado") != "") {
echo " -> " . $oferta->getValor("msgEstado");
}
echo "<br />";
$estadosSiguientes = $oferta->getSiguientes();
foreach ($estadosSiguientes as $codEstado => $nombreEstado) {
?>
<input class="button" name="cambEstado" type="button" value="<?php echo $locale['2104'] . $nombreEstado; ?>"
onClick="javascript:document.location='oferta.php?idOferta=<?php echo $oferta->getValor("oid"); ?>&action=cambEst&idEst=<?php echo $codEstado; ?>'"
style="width:200px; margin-bottom:5px"><br />
<?php
}
?>
</td>
</tr>
<tr>
<td class="nombre"><?php echo $locale['5107']; ?></td>
<td><?php echo nl2br($oferta->getValor("nombre_candidato")); ?></td>
</tr>
<tr>
<td class="nombre"><?php echo $locale['135']; ?></td>
<td><?php echo nl2br($oferta->getValor("observaciones")); ?></td>
</tr>
</table>
</td></tr>
</table>
<br/>
<?php
if (($oferta->getValor("estado") == 110)) {
?>
<table width="100%">
<?php
$listaCandidatos = $oferta->getCandidatosDisponibles()->getCandidatos();
if (!empty($listaCandidatos)) {
?>
<tr> <!-- Tabla de candidatos -->
<td>
<h3><span class="nombre">Candidatos disponibles</span></h3>
<table width="100%" class="listaPropuestos">
<thead>
<tr class="nombre">
<th><?php echo $locale['2014']; ?></th>
<th><?php echo $locale['704']; ?></th>
<th><?php echo $locale['202']; ?></th>
<th><?php echo $locale['1052']; ?></th>
<th><?php echo $locale['203']; ?></th>
<th><?php echo $locale['206']; ?></th>
</tr>
</thead>
<?php
echo "<tbody>";
$final = count($listaCandidatos);
for ($i = 0; $i < $final; $i++) {
$candidato = $listaCandidatos[$i];
?>
<tr>
<td class="centrado">
<?php
$candActual = $oferta->getValor("candidato");
if (!empty($candActual)) {
echo "<a href=\"#\" onclick=\"cambiarCandidato('oferta.php?idOferta=".$oferta->getValor("oid")."&action=aceptar&idCand=".$candidato->getValor("oid")."')\">";
}
else {
echo "<a href='oferta.php?idOferta=".$oferta->getValor("oid")."&action=aceptar&idCand=".$candidato->getValor("oid")."'>";
}
?>
<img src='css/accept.png' title="<?php echo $locale['1047']; ?>" />
</a>
</td>
<td>
<a href="detalle_persona.php?oid=<?php echo $candidato->getValor("oid"); ?>" target=popup onclick=window.open('', 'popup', ',',',',',',',','width = 600, height = 800')><?php echo $candidato->getValor("nombre") . " " . $candidato->getValor("apellidos"); ?></a>
</td>
<td>
<?php
$perfiles = $candidato->getPerfiles();
$keylocalidades = array_values($perfiles);
// Mostramos la lista para borrar
foreach ($perfiles as $nombre => $valor) {
echo "- " . $nombre . "<br />";
}
?>
</td>
<td><?php echo $candidato->getValor("nombre_estado"); ?></td>
<td><?php
$tecnologias = rellena_lista_oid("tecnologia_usuario", "tecnologia", "tecnologia", $candidato->getValor("oid"));
if (gettype($tecnologias) != "NULL") {
foreach ($tecnologias as $tecno) {
echo $tecno . ",";
}
}
?></td>
<td>&nbsp;<?php
$idiomas = rellena_lista_oid("idioma_usuario", "idiomas", "idioma", $candidato->getValor("oid"));
if (gettype($idiomas) != "NULL") {
foreach ($idiomas as $tecno) {
echo $tecno . ",";
}
}
?></td>
</tr>
<?php
} // for
?>
</tbody>
</table>
<div id="cronopaginacion"><?php echo $html->paginacion($numPaginas, $pagAcept, "pedido.php", "idPedido=" . $oferta->getValor("oid"), "pagAcept"); ?></div>
</td>
</tr>
<?php
} // if
?>
<?php
}
?>
<tr align="center"> <!-- HISTORIAL -->
<td ><a name="historial"><?php echo $locale['127']; ?></a><br />
<textarea name="historial" readonly rows="8" cols="90" maxlength="300" style="overflow: auto;width:100%"><?php echo $oferta->getHistorial(); ?></textarea>
</td>
</tr>
</table>
<?php include_once("html/pie.php"); ?>

View File

@ -1,5 +1,6 @@
<?php <?php
include_once("Objects/Pedido.php"); include_once("Objects/Pedido.php");
include_once("Objects/ListaOfertas.php");
include_once("seguridad.php"); include_once("seguridad.php");
$usuario = $_SESSION['usuario']; $usuario = $_SESSION['usuario'];
//$pedido=new Pedido($idPedido,$usuario); //$pedido=new Pedido($idPedido,$usuario);
@ -18,6 +19,7 @@ $constantes=$administracion->getItem("constantes");
$mostrarTabla = $constantes['candPagina']; $mostrarTabla = $constantes['candPagina'];
$altoScroll = 83 / 2 * $mostrarTabla; $altoScroll = 83 / 2 * $mostrarTabla;
?> ?>
<style type="text/css"> <style type="text/css">
.listaPropuestos{ .listaPropuestos{
border-collapse:separate; border-collapse:separate;
@ -27,11 +29,13 @@ $altoScroll=83/2 * $mostrarTabla;
overflow-x:hidden; overflow-x:hidden;
} }
</style> </style>
<?php <?php
include_once("Objects/HTML.php"); include_once("Objects/HTML.php");
$html = new HTML($locale); $html = new HTML($locale);
// Constantes para la p<>gina // Constantes para la p<>gina
$pagAcept = isset($_GET["pagAcept"]) && ($_GET["pagAcept"] != "") ? $_GET["pagAcept"] : "1"; $pagAcept = isset($_GET["pagAcept"]) && ($_GET["pagAcept"] != "") ? $_GET["pagAcept"] : "1";
$pagProp = isset($_GET["pagProp"]) && ($_GET["pagProp"] != "") ? $_GET["pagProp"] : "1"; $pagProp = isset($_GET["pagProp"]) && ($_GET["pagProp"] != "") ? $_GET["pagProp"] : "1";
@ -42,39 +46,14 @@ if (isset($_GET["msgSem"]) && ($_GET["msgSem"]!="")) {
$mensajeSemaforo = $semaforo->getMensaje($_GET["msgSem"]); $mensajeSemaforo = $semaforo->getMensaje($_GET["msgSem"]);
echo "<div class=\"aviso semaforo\">" . $mensajeSemaforo . "</div>"; echo "<div class=\"aviso semaforo\">" . $mensajeSemaforo . "</div>";
} }
/* PROYECTOS.PHP */
//menu_pedidos("");
// MEN<45>
if($pedido->getValor("estado")==40){
echo $html->menuPedidos($usuario,array("gestionar"));
} elseif (!$usuario->tieneRol("3")) {
echo $html->menuPedidos($usuario,array("gestionar"));
}else
echo $html->menuPedidos($usuario,"");
// Comprobamos mensajes que pueden llegar hasta aqui
if (isset($_GET["msg"])) {
switch ($_GET['msg']) {
case "1": $mensaje="<div class=\"aviso ok\">".$locale['1061']."</div>";
break;
default:
break;
}
} else {
$mensaje = "";
}
?> ?>
<link href="css/tablas.css" rel="stylesheet" type="text/css">
<h2><?php echo $pedido->getValor("nombre"); ?></h2>
<?php echo $mensaje; <?php
// Comprobamos si tenemos que aceptar o rechazar un candidato // Comprobamos si tenemos que aceptar o rechazar un candidato
$action = (isset($_GET['action']) && ($_GET['action'] != "")) ? $_GET['action'] : ""; $action = (isset($_GET['action']) && ($_GET['action'] != "")) ? $_GET['action'] : "";
$action = (isset($_POST['action']) && ($_POST['action']!="")) ? $_POST['action'] : ""; //$action = (isset($_POST['action']) && ($_POST['action']!="")) ? $_POST['action'] : "";
if ($action != "") { if ($action != "") {
$error = false; $error = false;
@ -174,7 +153,39 @@ if($mensaje!=""){
} }
} }
?> ?>
<table width="100%"><tr><td>
<?php
//menu_pedidos("");
// MEN<45>
if ($pedido->getValor("estado") == 130) {
echo $html->menuPedidos($usuario, array("gestionar", "nueva_oferta"));
} elseif (!$usuario->tieneRol("3")) {
echo $html->menuPedidos($usuario, array("gestionar"));
} else
echo $html->menuPedidos($usuario, "");
?>
<h2><?php echo $pedido->getValor("nombre"); ?></h2>
<?php
// Comprobamos mensajes que pueden llegar hasta aqui
if (isset($_GET["msg"])) {
switch ($_GET['msg']) {
case "1": $mensaje = "<div class=\"aviso ok\">" . $locale['1061'] . "</div>";
break;
default:
break;
}
} else {
$mensaje = "";
}
echo $mensaje;
?>
<table width="100%">
<tr><td>
<table width="100%"> <table width="100%">
<tr> <tr>
<td class="nombre"><?php echo $locale['1010']; ?></td> <td class="nombre"><?php echo $locale['1010']; ?></td>
@ -250,7 +261,8 @@ if($mensaje!=""){
} }
} else { } else {
?> ?>
<span class="errorcampo"><?php if($pedido->getValor("pesoIdioma") > 0) echo $locale['1097'];?></span><br /> <span class="errorcampo"><?php if ($pedido->getValor("pesoIdioma") > 0)
echo $locale['1097']; ?></span><br />
<?php <?php
} }
?></td> ?></td>
@ -263,7 +275,8 @@ if($mensaje!=""){
} }
} else { } else {
?> ?>
<span class="errorcampo"><?php if($pedido->getValor("pesoTecno") > 0) echo $locale['1097'];?></span><br /> <span class="errorcampo"><?php if ($pedido->getValor("pesoTecno") > 0)
echo $locale['1097']; ?></span><br />
<?php <?php
} }
?></td> ?></td>
@ -288,7 +301,6 @@ if($mensaje!=""){
echo $locale['1078'] . "( " . $pedido->getValor("pesoTecno") . "% ) - "; echo $locale['1078'] . "( " . $pedido->getValor("pesoTecno") . "% ) - ";
echo $locale['1079'] . "( " . $pedido->getValor("pesoIdioma") . "% ) - "; echo $locale['1079'] . "( " . $pedido->getValor("pesoIdioma") . "% ) - ";
echo $locale['1080'] . "( " . $pedido->getValor("pesoPerfil") . "% )"; echo $locale['1080'] . "( " . $pedido->getValor("pesoPerfil") . "% )";
?></td> ?></td>
</tr> </tr>
<tr> <tr>
@ -297,430 +309,68 @@ if($mensaje!=""){
</tr> </tr>
</table> </table>
</td></tr> </td></tr>
<tr><td> </table>
<!-- Tabla de candidatos aceptados -->
<h3><span class="nombre"><?php echo $locale['1046']; ?></span></h3> <br/>
<table width="100%" class="listaPropuestos">
<h3><span class="nombre"><?php echo $locale['5100']; ?></span></h3>
<table width="100%">
<thead> <thead>
<tr class="nombre"> <tr class="nombre">
<th><?php echo $locale['704']; ?></th>
<th><?php echo $locale['202']; ?></th>
<th><?php echo $locale['1052']; ?></th>
<th><?php echo $locale['2105']; ?></th>
<th><?php echo $locale['203']; ?></th>
<th><?php echo $locale['206']; ?></th>
<th><?php echo $locale['1015']; ?></th>
<th><?php echo $locale['2014']; ?></th> <th><?php echo $locale['2014']; ?></th>
<th><?php echo $locale['5106']; ?></th>
<th><?php echo $locale['1021']; ?></th>
<th><?php echo $locale['1102']; ?></th>
<th><?php echo $locale['5107']; ?></th>
</tr> </tr>
</thead> </thead>
<?php <?php
$listaCandidatos = $pedido->getCandidatosAceptados(); $oidPedido = $pedido->getValor("oid");
if(gettype($listaCandidatos)=="NULL"){
?> // sacado de http://patrickallaert.blogspot.com/2007/09/building-dynamic-sql-queries-elegant.html
<tbody> $cond = array();
<tr> $cond[] = "pedido = '$oidPedido'";
<td colspan="8"><?php echo $locale['1049']; ?></td>
</tr> $orden = array();
<?php $orden[] = "referencia";
$listaOfertas = new ListaOfertas($usuario, $cond, $orden);
$ofertas = $listaOfertas->getOfertas();
// Vemos si tiene ofertas
$totalOfertas = count($ofertas);
if ($totalOfertas == 0) {
echo "<tr><td colspan=\"11\" align=\"center\">Esta solicitud no tiene ofertas</td></tr>";
} else { } else {
echo "<tbody>"; for ($i = 0; $i < $totalOfertas; $i++) {
/*if(count($listaCandidatos)<$mostrarTabla) $ofertaAct = $ofertas[$i];
echo "<tbody>";
else
echo "<tbody style=\"height: ".$altoScroll."px;\">";
*/
$final=count($listaCandidatos);
for($i=0;$i<$final;$i++){
$candidato=$listaCandidatos[$i];
?>
<tr>
<td>
<a onclick="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')" ondblclick="ocultarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="<?php echo (($candidato->getValor("obsGerente")!="") || ($candidato->getValor("obsRRHH")!=""))? "css/coment.png" : "css/add_coment.png"; ?>" /></a>
<div id="obs-<?php echo $candidato->getValor("oid"); ?>" class="capaObs" onmouseover="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="css/dell.png" onclick="ocultarCapa('obs-<?php echo $candidato->getValor("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%"><textarea name="obs" readonly class="obsPropuesta" ><?php echo $candidato->getValor("obsRRHH"); ?></textarea></td>
<td width="50%">
<form action="pedido.php?idPedido=<?php echo $idPedido; ?>" method="post">
<input type="hidden" name="action" value="addComent">
<input type="hidden" name="idCandidato" value="<?php echo $candidato->getValor("oid"); ?>">
<textarea name="obs" class="obsPropuesta" ><?php echo $candidato->getValor("obsGerente"); ?></textarea>
<input class="button" style="border-color:#000000; " type="submit" value="comentar" >
</form>
</td>
</tr>
</table>
</div>
<a href="detalle_persona.php?oid=<?php echo $candidato->getValor("oid"); ?>" target=popup onclick=window.open('', 'popup', ',',',',',',',','width = 600, height = 800')><?php echo $candidato->getValor("nombre")." ".$candidato->getValor("apellidos"); ?></a></td>
<td>&nbsp;
<?php
$perfiles=$candidato->getPerfiles();
$keylocalidades=array_values($perfiles);
// Mostramos la lista para borrar
foreach ($perfiles as $nombre =>$valor) {
echo "- ".$nombre."<br />";
}
?>
</td>
<td>&nbsp;<?php echo $candidato->getValor("estado_usuario"); ?></td>
<td>&nbsp;<?php echo $candidato->getValor("fecha"); ?></td>
<td>&nbsp;<?php
$tecnologias=rellena_lista_oid("tecnologia_usuario", "tecnologia", "tecnologia", $candidato->getValor("oid"));
if(gettype($tecnologias)!="NULL"){
foreach($tecnologias as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php
$idiomas=rellena_lista_oid("idioma_usuario", "idiomas", "idioma", $candidato->getValor("oid"));
if(gettype($idiomas)!="NULL"){
foreach($idiomas as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php echo $candidato->getValor("afinidad"); ?></td>
<td class="centrado"><a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=dell&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/dell.png" title="<?php echo $locale['1048'];?>" /></a>
</td>
</tr>
<?php echo "<tr>";
} // for
} // if /*if (($ofertaAct->getValor("gerente") == $usuario->getValor("oid")) || $usuario->tieneRol("1")) {
?> // Es el gerente de ese pedido, puede editarlo y eliminarlo
</tbody> echo '<td align="center"><a href="gestion_pedido.php?idPedido=' . $ofertaAct->getValor("oid") . '"><img src="css/edit.png" title="' . $locale['2017'] . '"/></a></td>';
</table> echo "<td align=\"center\"><a href=\"#\" onclick=eliminarPedido('" . $ofertaAct->getValor("oid") . "') ><img src=\"css/eliminar.png\" title=\"" . $locale['2016'] . "\"/></a></td>";
<div id="cronopaginacion"><?php echo $html->paginacion($numPaginas, $pagAcept,"pedido.php","idPedido=".$pedido->getValor("oid"),"pagAcept"); ?></div>
</td>
</tr>
<tr>
<td>
<!-- Lista de candidatos propuestos por RRHH -->
<h3><span class="nombre"><?php echo $locale['1071']; ?></span></h3>
<table width="100%" class="listaPropuestos">
<thead>
<tr class="nombre">
<th><?php echo $locale['704']; ?></th>
<th><?php echo $locale['202']; ?></th>
<th><?php echo $locale['1052']; ?></th>
<th><?php echo $locale['2106']; ?></th>
<th><?php echo $locale['203']; ?></th>
<th><?php echo $locale['206']; ?></th>
<th><?php echo $locale['1015']; ?></th>
<th><?php echo $locale['2014']; ?></th>
</tr>
</thead>
<?php
$listaCandidatos = $pedido->getCandidatosPropuestosRRHH();
if(gettype($listaCandidatos)=="NULL"){
?>
<tbody>
<tr>
<td colspan="8"><?php echo $locale['1050']; ?></td>
</tr>
<?php
} else { } else {
echo "<tbody>"; // No es el gerente no puede ni editarlo ni eliminarlo
/*if(count($listaCandidatos)<$mostrarTabla) echo '<td></td><td></td>';
echo "<tbody>"; }*/
else
echo "<tbody style=\"height: ".$altoScroll."px;\">";
*/
$final=count($listaCandidatos);
for($i=0;$i<$final;$i++){
$candidato=$listaCandidatos[$i];
?>
<tr>
<?php
echo '<td align="center"><a href="oferta.php?idOferta=' . $ofertaAct->getValor("oid") . '"><img src="css/brick_go.png" title="' . $locale['2015'] . '" /></a></td>';
echo '<td align="center"><a href="oferta.php?idOferta=' . $ofertaAct->getValor("referencia") . '">'.$ofertaAct->getValor("referencia").'</a></td>';
echo '<td align="center">' . $ofertaAct->getValor("fecha") . '</td>';
echo '<td align="center">' . $ofertaAct->getValor("nombre_estado") . '</td>';
echo '<td align="center"><a href="/detalle_candidato.php?oid=' . $ofertaAct->getValor("candidato") . '">' . $ofertaAct->getValor("nombre_candidato") . '</td>';
echo "</tr>";
}
}
?> ?>
<td>&nbsp;
<a onclick="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')" ondblclick="ocultarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="<?php echo (($candidato->getValor("obsGerente")!="") || ($candidato->getValor("obsRRHH")!=""))? "css/coment.png" : "css/add_coment.png"; ?>" /></a>
<div id="obs-<?php echo $candidato->getValor("oid"); ?>" class="capaObs" onmouseover="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="css/dell.png" onclick="ocultarCapa('obs-<?php echo $candidato->getValor("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%"><textarea name="obs" readonly class="obsPropuesta" ><?php echo $candidato->getValor("obsRRHH"); ?></textarea></td>
<td width="50%">
<form action="pedido.php?idPedido=<?php echo $idPedido; ?>" method="post">
<input type="hidden" name="action" value="addComent">
<input type="hidden" name="idCandidato" value="<?php echo $candidato->getValor("oid"); ?>">
<textarea name="obs" class="obsPropuesta" ><?php echo $candidato->getValor("obsGerente"); ?></textarea>
<input class="button" style="border-color:#000000; " type="submit" value="comentar" >
</form>
</td>
</tr>
</table> </table>
</div> <br/>
<a href="detalle_persona.php?oid=<?php echo $candidato->getValor("oid"); ?>" target=popup onclick=window.open('', 'popup', ',',',',',',',','width = 600, height = 800')><?php echo $candidato->getValor("nombre")." ".$candidato->getValor("apellidos"); ?></a></td> <table>
<td>&nbsp; <tr align="center"> <!-- HISTORIAL -->
<?php
$perfiles=$candidato->getPerfiles();
$keylocalidades=array_values($perfiles);
// Mostramos la lista para borrar
foreach ($perfiles as $nombre =>$valor) {
echo "- ".$nombre."<br />";
}
?>
</td>
<td>&nbsp;<?php echo $candidato->getValor("estado_usuario"); ?></td>
<td>&nbsp;<?php echo $candidato->getValor("fecha"); ?></td>
<td>&nbsp;<?php
$tecnologias=rellena_lista_oid("tecnologia_usuario", "tecnologia", "tecnologia", $candidato->getValor("oid"));
if(gettype($tecnologias)!="NULL"){
foreach($tecnologias as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php
$idiomas=rellena_lista_oid("idioma_usuario", "idiomas", "idioma", $candidato->getValor("oid"));
if(gettype($idiomas)!="NULL"){
foreach($idiomas as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php echo $candidato->getValor("afinidad"); ?></td>
<td class="centrado">
<a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=aceptar&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/accept.png" title="<?php echo $locale['1047']; ?>" /></a>
<a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=dell&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/dell.png" title="<?php echo $locale['1048'];?>" /></a>
</td>
</tr>
<?php
} // for
} // if
?>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<!-- Lista de candidatos propuestos por el sistema -->
<h3><span class="nombre"><?php echo $locale['1044']; ?></span></h3>
<table width="100%" class="listaPropuestos">
<thead>
<tr class="nombre">
<th><?php echo $locale['704']; ?></th>
<th><?php echo $locale['202']; ?></th>
<th><?php echo $locale['1052']; ?></th>
<th><?php echo $locale['2107']; ?></th>
<th><?php echo $locale['203']; ?></th>
<th><?php echo $locale['206']; ?></th>
<th><?php echo $locale['1015']; ?></th>
<th><?php echo $locale['2014']; ?></th>
</tr>
</thead>
<?php
$listaCandidatos = $pedido->getCandidatosPropuestos();
if(gettype($listaCandidatos)=="NULL"){
?>
<tbody>
<tr>
<td colspan="8"><?php echo $locale['1050']; ?></td>
</tr>
<?php
}else{
echo "<tbody>";
/*if(count($listaCandidatos)<$mostrarTabla)
echo "<tbody>";
else
echo "<tbody style=\"height: ".$altoScroll."px;\">";
*/
$final=count($listaCandidatos);
for($i=0;$i<$final;$i++){
$candidato=$listaCandidatos[$i];
?>
<tr>
<td>&nbsp;
<a onclick="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')" ondblclick="ocultarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="<?php echo (($candidato->getValor("obsGerente")!="") || ($candidato->getValor("obsRRHH")!=""))? "css/coment.png" : "css/add_coment.png"; ?>" /></a>
<div id="obs-<?php echo $candidato->getValor("oid"); ?>" class="capaObs" onmouseover="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="css/dell.png" onclick="ocultarCapa('obs-<?php echo $candidato->getValor("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%"><textarea name="obs" readonly class="obsPropuesta" ><?php echo $candidato->getValor("obsRRHH"); ?></textarea></td>
<td width="50%">
<form action="pedido.php?idPedido=<?php echo $idPedido; ?>" method="post">
<input type="hidden" name="action" value="addComent">
<input type="hidden" name="idCandidato" value="<?php echo $candidato->getValor("oid"); ?>">
<textarea name="obs" class="obsPropuesta" ><?php echo $candidato->getValor("obsGerente"); ?></textarea>
<input class="button" style="border-color:#000000; " type="submit" value="comentar" >
</form>
</td>
</tr>
</table>
</div>
<a href="detalle_persona.php?oid=<?php echo $candidato->getValor("oid"); ?>" target=popup onclick=window.open('', 'popup', ',',',',',',',','width = 600, height = 800')><?php echo $candidato->getValor("nombre")." ".$candidato->getValor("apellidos"); ?></a></td>
<td>
<?php
$perfiles=$candidato->getPerfiles();
$keylocalidades=array_values($perfiles);
// Mostramos la lista para borrar
foreach ($perfiles as $nombre =>$valor) {
echo "- ".$nombre."<br />";
}
?>
</td>
<td>&nbsp;<?php echo $candidato->getValor("estado_usuario"); ?></td>
<td>&nbsp;<?php echo $candidato->getValor("fecha"); ?></td>
<td>&nbsp;<?php
$tecnologias=rellena_lista_oid("tecnologia_usuario", "tecnologia", "tecnologia", $candidato->getValor("oid"));
if(gettype($tecnologias)!="NULL"){
foreach($tecnologias as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php
$idiomas=rellena_lista_oid("idioma_usuario", "idiomas", "idioma", $candidato->getValor("oid"));
if(gettype($idiomas)!="NULL"){
foreach($idiomas as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php echo $candidato->getValor("afinidad"); ?></td>
<td class="centrado">
<a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=aceptar&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/accept.png" title="<?php echo $locale['1047']; ?>" /></a>
<a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=dell&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/dell.png" title="<?php echo $locale['1048'];?>" /></a>
</td>
</tr>
<?php
} // for
} // if
?>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<!-- Lista de candidatos rechazados -->
<h3><span class="nombre"><?php echo $locale['1045']; ?></span></h3>
<table width="100%" class="listaPropuestos">
<thead>
<tr class="nombre">
<th><?php echo $locale['704']; ?></th>
<th><?php echo $locale['202']; ?></th>
<th><?php echo $locale['1052']; ?></th>
<th><?php echo $locale['2108']; ?></th>
<th><?php echo $locale['203']; ?></th>
<th><?php echo $locale['206']; ?></th>
<th><?php echo $locale['1015']; ?></th>
<th><?php echo $locale['2014']; ?></th>
</tr>
</thead>
<?php
$listaCandidatos = $pedido->getCandidatosRechazados();
if(gettype($listaCandidatos)=="NULL"){
?>
<tbody>
<tr>
<td colspan="8"><?php echo $locale['1051']; ?></td>
</tr>
<?php
}else{
echo "<tbody>";
/*if(count($listaCandidatos)<$mostrarTabla)
echo "<tbody>";
else
echo "<tbody style=\"height: ".$altoScroll."px;\">";
*/
$final=count($listaCandidatos);
for($i=0;$i<$final;$i++){
$candidato=$listaCandidatos[$i];
?>
<tr>
<td>&nbsp;
<a onclick="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')" ondblclick="ocultarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="<?php echo (($candidato->getValor("obsGerente")!="") || ($candidato->getValor("obsRRHH")!=""))? "css/coment.png" : "css/add_coment.png"; ?>" /></a>
<div id="obs-<?php echo $candidato->getValor("oid"); ?>" class="capaObs" onmouseover="mostrarCapa('obs-<?php echo $candidato->getValor("oid"); ?>')">
<img src="css/dell.png" onclick="ocultarCapa('obs-<?php echo $candidato->getValor("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%"><textarea name="obs" readonly class="obsPropuesta" ><?php echo $candidato->getValor("obsRRHH"); ?></textarea></td>
<td width="50%">
<form action="pedido.php?idPedido=<?php echo $idPedido; ?>" method="post">
<input type="hidden" name="action" value="addComent">
<input type="hidden" name="idCandidato" value="<?php echo $candidato->getValor("oid"); ?>">
<textarea name="obs" class="obsPropuesta" ><?php echo $candidato->getValor("obsGerente"); ?></textarea>
<input class="button" style="border-color:#000000; " type="submit" value="comentar" >
</form>
</td>
</tr>
</table>
</div>
<a href="detalle_persona.php?oid=<?php echo $candidato->getValor("oid"); ?>" target=popup onclick=window.open('', 'popup', ',',',',',',',','width = 600, height = 800')><?php echo $candidato->getValor("nombre")." ".$candidato->getValor("apellidos"); ?></a></td>
<td>&nbsp;
<?php
$perfiles=$candidato->getPerfiles();
$keylocalidades=array_values($perfiles);
// Mostramos la lista para borrar
foreach ($perfiles as $nombre =>$valor) {
echo "- ".$nombre."<br />";
}
?>
</td>
<td>&nbsp;<?php echo $candidato->getValor("estado_usuario"); ?></td>
<td>&nbsp;<?php echo $candidato->getValor("fecha"); ?></td>
<td>&nbsp;<?php
$tecnologias=rellena_lista_oid("tecnologia_usuario", "tecnologia", "tecnologia", $candidato->getValor("oid"));
if(gettype($tecnologias)!="NULL"){
foreach($tecnologias as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php
$idiomas=rellena_lista_oid("idioma_usuario", "idiomas", "idioma", $candidato->getValor("oid"));
if(gettype($idiomas)!="NULL"){
foreach($idiomas as $tecno){
echo $tecno.",";
}
}
?></td>
<td>&nbsp;<?php echo $candidato->getValor("afinidad"); ?></td>
<td class="centrado">
<a href="pedido.php?idPedido=<?php echo $pedido->getValor("oid"); ?>&action=aceptar&idCand=<?php echo $candidato->getValor("oid"); ?>" ><img src="css/accept.png" title="<?php echo $locale['1047']; ?>" /></a>
</td>
</tr>
<?php
} // for
} // if
?>
</tbody>
</table>
</td>
</tr>
<tr align="center">
<td ><a name="historial"><?php echo $locale['127']; ?></a><br /> <td ><a name="historial"><?php echo $locale['127']; ?></a><br />
<textarea name="historial" readonly rows="8" cols="90" maxlength="300" style="overflow: auto;width:100%"><?php echo $pedido->getHistorial(); ?></textarea> <textarea name="historial" readonly rows="8" cols="90" maxlength="300" style="overflow: auto;width:100%"><?php echo $pedido->getHistorial(); ?></textarea>
</td> </td>