diff --git a/Objects/ListaCandidatos.php b/Objects/ListaCandidatos.php index dc9b9ec..6387822 100644 --- a/Objects/ListaCandidatos.php +++ b/Objects/ListaCandidatos.php @@ -13,6 +13,7 @@ class ListaCandidatos extends ListaPersonas { //Atributos: //Constructor: //Funciones: + public $estados = array(); /** * Crea una lista de candidatos. @@ -24,6 +25,7 @@ class ListaCandidatos extends ListaPersonas { parent::ListaPersonas($usuario, $orden, $sql); $this->tipo = "candidato"; $this->estado = $estado; + $this->estados = explode(",", $estado); } /** @@ -62,17 +64,37 @@ class ListaCandidatos extends ListaPersonas { */ function getCandidatos() { $candidatos = array(); + $value = ""; if ($this->sql != "") { // metemos el estado si es > 0 - if ($this->estado > 0) { + if (count($this->estados) > 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 "; + + $sqlConEstado = "WHERE usuarios.estado in ("; + $i=1; + foreach ($this->estados as $value) { + $sqlConEstado = $sqlConEstado. "'". $value . "'"; + if ($i != count($this->estados)) + $sqlConEstado = $sqlConEstado. ","; + $i++; + + } + $sqlConEstado = $sqlConEstado. ") and "; + $sqlNueva = $sqlAntesWhere . $sqlConEstado . $sqlDespuesWhere; } else { - $sqlConEstado = "WHERE usuarios.estado='" . $this->estado . "' "; + $sqlConEstado = "WHERE usuarios.estado in ("; + $i=1; + foreach ($this->estados as $value) { + $sqlConEstado = $sqlConEstado. "'". $value . "'"; + if ($i != count($this->estados)) + $sqlConEstado = $sqlConEstado. ","; + $i++; + } + $sqlConEstado = $sqlConEstado. ") "; $sqlNueva = $this->sql . $sqlConEstado; } } else { @@ -80,14 +102,22 @@ class ListaCandidatos extends ListaPersonas { } $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; + if (count($this->estados) > 0) { + $consulta = "SELECT oid from usuarios WHERE tipo='" . $this->tipo . "' and estado in ("; + $i=1; + foreach ($this->estados as $value) { + $consulta = $consulta. "'". $value . "'"; + if ($i != count($this->estados)) + $consulta = $consulta. ","; + $i++; + } + $consulta = $consulta. ")". $this->orden; + } else { $consulta = "SELECT oid from usuarios WHERE tipo='" . $this->tipo . "'" . $this->orden . ""; } } - $bd = new BD(); $resultado = $bd->execQuery($consulta); diff --git a/Objects/ListaPersonas.php b/Objects/ListaPersonas.php index 3397911..abe439b 100644 --- a/Objects/ListaPersonas.php +++ b/Objects/ListaPersonas.php @@ -7,6 +7,7 @@ */ include_once("Candidato.php"); include_once("Empleado.php"); + class ListaPersonas{ //Atributos: @@ -30,7 +31,7 @@ include_once("Empleado.php"); protected $order_by = ""; protected $estado = ""; - + //Constructor: /** diff --git a/Objects/Oferta.php b/Objects/Oferta.php index bc0f979..7a4c606 100644 --- a/Objects/Oferta.php +++ b/Objects/Oferta.php @@ -205,10 +205,10 @@ class Oferta { } /** - * Devuelve una lista de candidatos disponibles para una oferta + * Devuelve una lista de candidatos disponibles para una oferta, que son todos menos los no disponibles #679 Peticion */ function getCandidatosDisponibles() { - return $this->getCandidatos("540"); + return $this->getCandidatos("510,521,522,523,540,550"); } /**