From c713dd4dcac8c299e983d688c989901161821bb7 Mon Sep 17 00:00:00 2001 From: roberto Date: Mon, 26 Mar 2012 17:07:21 +0000 Subject: [PATCH] Cambios varios del parte de trabajo num. 29 git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk@132 e2b1556b-49f8-d141-9351-52d6861a72d9 --- src/Objects/HTML.php | 2 +- src/Objects/Oferta.php | 64 +++++++++++++++++++++++++------------ src/Objects/Pedido.php | 50 ++++++++++++++++++++++------- src/addOferta.php | 17 +++++----- src/database/selfor.sql | 25 +++------------ src/proponerCandidato.php | 2 +- src/ver_lista_ofertas.php | 14 +++++--- src/ver_lista_pedidos.php | 67 +++++++++++++++++++++++++++------------ src/ver_oferta.php | 3 +- 9 files changed, 156 insertions(+), 88 deletions(-) diff --git a/src/Objects/HTML.php b/src/Objects/HTML.php index dfb958e..bd3730b 100644 --- a/src/Objects/HTML.php +++ b/src/Objects/HTML.php @@ -95,7 +95,7 @@ } echo ''.$this->locale['5100'].''; if($usuario->tieneRol("3") ||$usuario->tieneRol("1")){ - echo ''.$this->locale['5101'].''; +// echo ''.$this->locale['5101'].''; } /*echo ''.$this->locale['5102'].'';*/ /* diff --git a/src/Objects/Oferta.php b/src/Objects/Oferta.php index da8f881..bef2dfa 100644 --- a/src/Objects/Oferta.php +++ b/src/Objects/Oferta.php @@ -30,26 +30,32 @@ class Oferta { } } + function esEliminable() { + return ($oferta->getValor("estado") == 100); + } + function eliminar() { - //Antes de nada quitamos el candidato asociado a la oferta para que se haga la lógica que corresponda - $idCand = $this->getValor("candidato"); - if (!empty($idCand)) { - if (!$this->quitarCandidato()) { - return false; - } - } + return false; + if ($this->esEliminable()) { + //Antes de nada quitamos el candidato asociado a la oferta para que se haga la lógica que corresponda + $idCand = $this->getValor("candidato"); + if (!empty($idCand)) { + if (!$this->quitarCandidato()) { + return false; + } + } - // eliminamos en la oferta de la BD - $consulta = "DELETE FROM candidato_pedido WHERE oid = ".$this->campos['oid']; - - $bd = new BD(); - if (!$bd->execQuery($consulta)) { - return false; - } else { - $mensaje = "Oferta eliminada"; - $this->actualizarHistorial($mensaje); - return true; - } + // eliminamos en la oferta de la BD + $consulta = "DELETE FROM candidato_pedido WHERE oid = ".$this->campos['oid']; + $bd = new BD(); + if (!$bd->execQuery($consulta)) { + return false; + } else { + $mensaje = "Oferta eliminada"; + $this->actualizarHistorial($mensaje); + return true; + } + } } function actualizarHistorial($mensaje) { @@ -72,6 +78,10 @@ class Oferta { return $this->campos[$nombre]; } else { switch ($nombre) { + case "nombre_gerente":$idGerente = $this->getValor("gerente"); + $consulta = "SELECT CONCAT(nombre,\" \",apellidos) FROM usuarios WHERE oid=\"" . $idGerente . "\""; + break; + case "nombre_estado": $idEstado = $this->getValor("estado"); $idioma = $this->usuario->getValor("idioma"); @@ -154,9 +164,9 @@ class Oferta { } /** - * En configuración -> Configurada + * En proceso -> presentada */ - private function ejecutar110120() { + private function ejecutar100120() { // Comprobamos que haya un candidato asignado. $candidato = $this->getValor("candidato"); if (!empty($candidato)) { @@ -169,6 +179,7 @@ class Oferta { } } + function setCampo($nombre, $valor) { // PERMISOS: /* @@ -176,6 +187,7 @@ class Oferta { * 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) { @@ -199,6 +211,16 @@ if ($nombre == "estado") { $estado_nuevo = $this->darNombreEstado($valor, "sp"); $historial = "Cambio de estado (". $estado_viejo ." a ". $estado_nuevo .")"; $this->actualizarHistorial($historial); + +//Una vez cambiado de estado la oferta, si el nuevo estado es Rechazado o Retirada, liberamos al candidato + if (($valor=='160')||($valor=='170')) { + $idCand = $this->getValor("candidato"); + if (!empty($idCand)) { + if (!$this->quitarCandidato()) { + return false; + } + } + } } } @@ -282,11 +304,11 @@ if ($nombre == "estado") { function quitarCandidato() { $idCand = $this->getValor("candidato"); + $this->setCampo("candidato", ""); if (!empty($idCand)) { $candidato = new Candidato($this->usuario, $idCand); $estadoCand = $candidato->getValor("estado"); $numOfertasCandidato = $this->getNumOfertasCandidato($idCand); -echo "Ofertas del coandidato:".$this->getNumOfertasCandidato($idCand); switch ($estadoCand) { //TODO CANDIDATO ASOCIADO A UNA OFERTA (este como este su situación) pasará a En proceso:disponible si no tiene alguna otra oferta, //el estado del candidato no cambia si está asociado a alguna otra oferta. se cambia a los nuevos estados #723 Peticion diff --git a/src/Objects/Pedido.php b/src/Objects/Pedido.php index dc37f71..27d9864 100644 --- a/src/Objects/Pedido.php +++ b/src/Objects/Pedido.php @@ -12,6 +12,7 @@ include_once("Objects/Afinidad.php"); include_once("Objects/Automata.php"); include_once("Objects/Oferta.php"); include_once("ListaCapacidadesProfesionales.php"); +include_once("Objects/ListaOfertas.php"); class Pedido { @@ -22,6 +23,7 @@ class Pedido { /* Contiene una lista con todos los atributos y su valor */ private $campos = array(); private $listaOfertas = null; + private $totalOfertas = 0; /* Lista de perfiles */ @@ -273,15 +275,29 @@ if ($nombre == "estado") { * 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)) { - $oid = $this->getValor("oid"); - $consulta = "DELETE FROM pedidos WHERE oid='$oid'"; - $bd = new BD(); - return $bd->execQuery($consulta); - } else { - return false; + + //Recogemos todas las ofertas del pedido para proceder a eliminarlas y dejar su candidato libre + $cond = array(); + $cond[] = "pedido = '".$this->getValor("oid")."'"; + $orden = array(); + $orden[] = "referencia"; + $listaOfertas = new ListaOfertas($this->usuario, $cond, $orden); + $ofertas = $listaOfertas->getOfertas(); + $totalOfertas = count($ofertas); + for ($i = 0; $i < $totalOfertas; $i++) + $ofertas[$i]->eliminar(); + + if (count($listaOfertas->getOfertas()) == 0) { + $gerente = $this->getValor("gerente"); + $sesion = $this->usuario->getValor("oid"); + if ($this->usuario->tieneRol(1) || ($this->usuario->tieneRol(3) && $sesion == $gerente)) { + $oid = $this->getValor("oid"); + $consulta = "DELETE FROM pedidos WHERE oid='$oid'"; + $bd = new BD(); + return $bd->execQuery($consulta); + } else { + return false; + } } } @@ -899,7 +915,7 @@ if ($nombre == "estado") { $pesoPerfil = $this->getValor("pesoPerfil"); // Eliminamos a los usuario de la tabla de candidatos en pedido que se encuentren // en proceso para este pedido. - $consulta = "DELETE FROM candidato_pedido WHERE pedido='$id' AND estado='110'"; + $consulta = "DELETE FROM candidato_pedido WHERE pedido='$id' AND estado='100'"; $bd = new BD(); $bd->execQuery($consulta); // Si el pedido no está cerrado calculamos su afinidad para los usuarios: @@ -929,7 +945,7 @@ if ($nombre == "estado") { $afi = $afinidad->calculaAfinidad($pesoIdioma, $pesoPerfil, $pesoTecno); echo $afi . "
"; if ($afi > 0) { - $consulta = "INSERT INTO candidato_pedido (candidato, pedido, afinidad, estado, fecha) VALUES('$idUsuario', '$id', '$afi', '110', curdate())"; + $consulta = "INSERT INTO candidato_pedido (candidato, pedido, afinidad, estado, fecha) VALUES('$idUsuario', '$id', '$afi', '100', curdate())"; $bd = new BD(); $bd->execQuery($consulta); @@ -1124,6 +1140,18 @@ if ($nombre == "estado") { return $resultado; } + + function getListaOfertas() { + //Recogemos todas las ofertas del pedido para proceder a eliminarlas y dejar su candidato libre + $cond = array(); + $cond[] = "pedido = '".$this->getValor("oid")."'"; + $orden = array(); + $orden[] = "referencia"; + $Ofertas = new ListaOfertas($this->usuario, $cond, $orden); + $listaOfertas = $Ofertas->getOfertas(); + $totalOfertas = count($ofertas); + return $listaOfertas; + } } diff --git a/src/addOferta.php b/src/addOferta.php index 3ccdc0f..ce8a12b 100644 --- a/src/addOferta.php +++ b/src/addOferta.php @@ -8,14 +8,14 @@ include_once("Objects/Pedido.php"); include_once("Objects/HTML.php"); $html = new HTML($locale); - $errores = array(); +$usuario = $_SESSION["usuario"]; +$solicitud=$_GET['solicitud']; // Todas las variables if (!empty($_POST)) { print_r($_POST); - $solicitud = ""; if (!empty($_POST['solicitud'])) { $solicitud = $_POST['solicitud'][0]; } @@ -34,6 +34,7 @@ if (!empty($_POST)) { $idiomas=$_POST['idiomas']; $provincias=$_POST['provincias']; */ $observaciones = $_POST['observaciones']; + $gerente=$usuario->getValor("oid"); /* $pesoTec=$_POST['pesoTec']; $pesoIdi=$_POST['pesoIdi']; $pesoPer=$_POST['pesoPer']; @@ -42,7 +43,7 @@ if (!empty($_POST)) { if($usuario->tieneRol("1")){ $gerente=$_POST['gerente']; } else { - $gerente=$usuario->getValor("oid"); + } */ if ($_POST['action'] == "add") { @@ -58,18 +59,18 @@ if (!empty($_POST)) { $arrayInsert = array(); $arrayInsert["pedido"] = $solicitud; $arrayInsert["obsGerente"] = $observaciones; - $arrayInsert["estado"] = "110"; + $arrayInsert["estado"] = "100"; + $arrayInsert["gerente"]=$gerente; /* $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["estado"]="100"; $arrayInsert["pesoIdioma"]=$pesoIdi; $arrayInsert["pesoPerfil"]=$pesoPer; $arrayInsert["pesoTecno"]=$pesoTec; */ @@ -98,7 +99,7 @@ if (!empty($_POST)) { } } else { $referencia = ""; - $solicitud = ""; + $gerente = $usuario->getValor("oid"); $observaciones = ""; } @@ -121,7 +122,7 @@ if (in_array("1", $errores)) echo " class=\"errorcampo\""; echo ">" . $locale['1025'] . ":
"; - +echo "holaaa"; rellena_desplegable_pedidos_estado("solicitud", "130, 140", array($solicitud)); echo " "; diff --git a/src/database/selfor.sql b/src/database/selfor.sql index d31f83b..82a10cf 100644 --- a/src/database/selfor.sql +++ b/src/database/selfor.sql @@ -218,14 +218,13 @@ INSERT INTO `candidaturas_estados` (`cod`, `idioma`, `nombre`) VALUES (20, 'sp', 'Aceptado'), (30, 'sp', 'En proceso'), (40, 'sp', 'RRHH'), -(100, 'sp', 'En configuración'), -(110, 'sp', 'Preparada oferta'), -(120, 'sp', 'Presentada'), -(130, 'sp', 'Solicitada entrevista'), +(100, 'sp', 'En proceso (EP)'), +(120, 'sp', 'Presentada (PR)'), +(130, 'sp', 'Solicitada Entrevista (SE)'), (140, 'sp', 'Realizada entrevista'), (150, 'sp', 'Aprobada'), (160, 'sp', 'Rechazada'), -(170, 'sp', 'Retirada'); +(170, 'sp', 'Retirada (RT)'); -- -------------------------------------------------------- @@ -247,57 +246,43 @@ CREATE TABLE IF NOT EXISTS `candidaturas_transiciones` ( -- INSERT INTO `candidaturas_transiciones` (`inicial`, `final`, `transicion`, `rol`) VALUES -(100, 110, 0, '1.4'), -(100, 120, 0, '1.4'), +(100, 120, 100120, '1.3'), (100, 130, 0, '1.4'), (100, 140, 0, '1.4'), (100, 150, 0, '1.4'), (100, 160, 0, '1.4'), (100, 170, 0, '1.4'), -(110, 100, 0, '1.4'), -(110, 120, 110120, '1.3'), -(110, 130, 0, '1.4'), -(110, 140, 0, '1.4'), -(110, 150, 0, '1.4'), -(110, 160, 0, '1.4'), -(110, 170, 0, '1.4'), (120, 100, 0, '1.4'), -(120, 110, 0, '1.3'), (120, 130, 0, '1.3'), (120, 140, 0, '1.4'), (120, 150, 0, '1.4'), (120, 160, 0, '1.4'), (120, 170, 0, '1.4'), (130, 100, 0, '1.4'), -(130, 110, 0, '1.4'), (130, 120, 0, '1.4'), (130, 140, 130140, ''), (130, 150, 0, '1.4'), (130, 160, 0, '1.4'), (130, 170, 0, '1.4'), (140, 100, 0, '1.4'), -(140, 110, 0, '1.4'), (140, 120, 0, '1.4'), (140, 130, 140130, ''), (140, 150, 0, '1.4'), (140, 160, 0, '1.4'), (140, 170, 0, '1.4'), (150, 100, 0, '1.4'), -(150, 110, 0, '1.4'), (150, 120, 0, '1.4'), (150, 130, 0, '1.4'), (150, 140, 0, '1.4'), (150, 160, 0, '1.4'), (150, 170, 0, '1.4'), (160, 100, 0, '1.4'), -(160, 110, 0, '1.4'), (160, 120, 0, '1.4'), (160, 130, 0, '1.4'), (160, 140, 0, '1.4'), (160, 150, 0, '1.4'), (160, 170, 0, '1.4'), (170, 100, 0, '1.4'), -(170, 110, 0, '1.4'), (170, 120, 0, '1.4'), (170, 130, 0, '1.4'), (170, 140, 0, '1.4'), diff --git a/src/proponerCandidato.php b/src/proponerCandidato.php index 2e65f84..ca9beaf 100644 --- a/src/proponerCandidato.php +++ b/src/proponerCandidato.php @@ -25,7 +25,7 @@ $arrayInsert = array(); foreach($pedidos as $codigo) { $arrayInsert["pedido"] = $codigo; $arrayInsert["obsGerente"] = $observacion; - $arrayInsert["estado"] = "110"; + $arrayInsert["estado"] = "100"; $arrayInsert["candidato"] = $idCandidato; diff --git a/src/ver_lista_ofertas.php b/src/ver_lista_ofertas.php index 39265e0..a0f134c 100644 --- a/src/ver_lista_ofertas.php +++ b/src/ver_lista_ofertas.php @@ -14,9 +14,9 @@ if (stripos($destinoURL, "?") > 0) { // Comprobamos mensajes que pueden llegar hasta aqui if (isset($_GET['msg'])) { switch ($_GET['msg']) { - case "1":$mensaje = "
" . $locale['1059'] . "
"; + case "1":$mensaje = "
Se ha eliminado correctamente la oferta
"; break; - case "2":$mensaje = "
" . $locale['1060'] . "
"; + case "2":$mensaje = "
No se ha podido eliminar la solicitud de oferta
La oferta está presentada
"; break; default: break; @@ -36,9 +36,6 @@ else echo "inactivo"; ?>">">
  • ">">
  • -
  • ">">
  • " . $locale['704'].":" . "
    " . " " . " "; +// Gerente +$orderView = "gerente"; +echo " " . $locale['1027'].":" . "
    " . +" " . +" "; + // Afinidad /*$orderView = "afinidad"; echo " " . $locale['5104'] . "
    " . @@ -139,6 +142,7 @@ if (count($listadeOfertas) == 0) { echo '' . $ofertaAct->getValor("nombre_estado") . ''; echo '' . $ofertaAct->getValor("nombre_solicitud") . ''; echo '' . $ofertaAct->getValor("nombre_candidato") . ''; + echo '' . $ofertaAct->getValor("nombre_gerente") . ''; //echo '' . $ofertaAct->getValor("afinidad") . ''; echo ""; } diff --git a/src/ver_lista_pedidos.php b/src/ver_lista_pedidos.php index d2c4480..073c099 100644 --- a/src/ver_lista_pedidos.php +++ b/src/ver_lista_pedidos.php @@ -17,7 +17,7 @@ if (isset($_GET['msg'])) { switch ($_GET['msg']) { case "1":$mensaje="
    ".$locale['1059']."
    "; break; - case "2":$mensaje="
    ".$locale['1060']."
    "; + case "2":$mensaje="
    ".$locale['1060']."
    Tiene ofertas presentadas.
    "; break; default: break; @@ -76,10 +76,10 @@ echo ""; echo " ".$locale['2014'].""; // Código -$orderView="oid"; -echo " ".$locale['1029']."
    " . - "
    " . - " "; +//$orderView="oid"; +//echo " ".$locale['1029']."
    " . +// " " . +// " "; // Fecha $orderView="fecha"; echo " ".$locale['1021']."
    " . @@ -109,16 +109,23 @@ echo " ".$locale['1023']."
    " . " " . " "; -// Capacidad profesional -$orderView="perfil"; -echo " ".$locale['Capacidades016'].""; - -// Número de ofertas -$orderView="empleados"; -echo " ".$locale['287']."
    " . +// Gerente +$orderView="gerente"; +echo " ".$locale['1027']."
    " . " " . " "; +echo " ".$locale['Ofertas009'].""; +// Capacidad profesional +//$orderView="perfil"; +//echo " ".$locale['Capacidades016'].""; + +// Número de ofertas +//$orderView="empleados"; +//echo " ".$locale['287']."
    " . +// " " . +// " "; + echo ""; // Vamos mostrando petición por petición @@ -153,25 +160,45 @@ if(count($listadePedidos)==0){ echo ''; } echo ''; - echo ''.$pedidoAct->getValor("oid").''; +// echo ''.$pedidoAct->getValor("oid").''; echo ''.$pedidoAct->getValor("fecha").''; /*echo ''.discretiza_prioridad($pedidoAct->getValor("prioridad")).'';*/ echo ''.$pedidoAct->getValor("nombre").''; echo ''.$pedidoAct->getValor("nombre_estado").''; echo ''.nombre_cliente($pedidoAct->getValor("cliente")).''; + echo ''.$pedidoAct->getValor("nombre_gerente").''; - echo ''; +////////////////////////////////////// +//OFERTAS///////////////////////////// +////////////////////////////////////// +echo ''; +$listaOfertas = $pedidoAct->getListaOfertas(); +if (($pedidoAct->getValor("estado")=='130')||($pedidoAct->getValor("estado")=='140')) + echo '
    '; + +for ($j = 0; $j < count($listaOfertas); $j++) { + $ofertaAct = $listaOfertas[$j]; + echo ''.$ofertaAct->getValor("referencia").' :  '.$ofertaAct->getValor("nombre_estado").'  '; + if ($ofertaAct->getValor("nombre_candidato")=="") { + echo "No asignado"; + } + else { + echo '' . $ofertaAct->getValor("nombre_candidato"). ''; + } + echo '  "'. $ofertaAct->getValor("nombre_gerente").'"
    '; +} +echo ''; +// echo ''; /////////////////////////// //CAPACIDADES PROFESIONALES /////////////////////////// -echo ''; -$CapacidadesProfesionales = $pedidoAct->getCapacidadesProfesionales(); -VerListaCapacidadesProfesionales($CapacidadesProfesionales, "lista_Solicitudes"); +//echo ''; +//$CapacidadesProfesionales = $pedidoAct->getCapacidadesProfesionales(); +//VerListaCapacidadesProfesionales($CapacidadesProfesionales, "lista_Solicitudes"); +//echo ''; - echo ''; - - echo ''.$pedidoAct->getValor("empleados").''; +// echo ''.$pedidoAct->getValor("empleados").''; echo ""; } // Comprobamos si tenemos que mostar una paginación diff --git a/src/ver_oferta.php b/src/ver_oferta.php index 20f3bac..0789338 100644 --- a/src/ver_oferta.php +++ b/src/ver_oferta.php @@ -99,7 +99,7 @@ if (!empty($action)) { -if (($oferta->getValor("estado") == 110) || ($oferta->getValor("estado") == 120)) { +if (($oferta->getValor("estado") == 120)) { echo $html->menuOfertas($usuario, array("")); } else echo $html->menuOfertas($usuario, "gestionar"); @@ -160,6 +160,7 @@ echo $mensaje; +    getValor("nombre_gerente"); ?>
     getValor("observaciones")); ?>