Incam_Intranet/src/buscar_candidato.php

168 lines
5.0 KiB
PHP
Raw Normal View History

<?php
include("seguridad.php");
include("functions.php");
// S<>lo los administradores y rrhh pueden buscar
if(!$usuario->tieneRol("1")
&& !$usuario->tieneRol("4")){
header("Location: aplicacion.php?e=permiso");
exit;
}
include_once("html/cabecera.php");
include_once("Objects/HTML.php");
$html=new HTML($locale);
echo $html->menuCandidatos();
$errores = "";
include_once("Objects/ListaCandidatos.php");
$listaCandidatos=new ListaCandidatos($usuario,"","","10");
$resultado=$listaCandidatos->getCamposBusqueda();
////////////////////////////
// Proceso del Formulario
///////////////////////////
if(isset($_POST['buscar'])) {
$palabra=$_POST['palabra'];
$campos=$_POST['campo'];
$whereCampos="";
$tablas = "usuarios";
foreach($campos as $campo)
if ($campo != "") {
if ($whereCampos != "") {
$whereCampos = $whereCampos . " or ";
}
$whereCampos = $whereCampos . "usuarios.". $campo ." like '%". $palabra ."%'";
}
if (($palabra != "") && ($whereCampos == "")) {
$errores = $locale['01903'];
}
$SemaforoPerfilTec = false;
$perfiles_tec = $_POST["id_perfil_tecnico"];
$wherePerfilesTec="";
foreach($perfiles_tec as $perfil)
if ($perfil != "") {
if(!$SemaforoPerfilTec)
$tablas .= ", capacidades capacidades1";
$SemaforoPerfilTec = true;
if ($wherePerfilesTec != "") {
$wherePerfilesTec = $wherePerfilesTec . " or ";
}
$wherePerfilesTec = $wherePerfilesTec . "(capacidades1.id_perfil_tecnico = ". $perfil ." and capacidades1.id_usuario = usuarios.oid)";
}
$SemaforoPerfilFun = false;
$perfiles_fun = $_POST["id_perfil_funcional"];
$wherePerfilesFun="";
foreach($perfiles_fun as $perfil)
if ($perfil != "") {
if(!$SemaforoPerfilFun)
$tablas .= ", capacidades capacidades2";
$SemaforoPerfilFun = true;
if ($wherePerfilesFun != "") {
$wherePerfilesFun = $wherePerfilesFun . " or ";
}
$wherePerfilesFun = $wherePerfilesFun . "(capacidades2.id_perfil_funcional = ". $perfil ." and capacidades2.id_usuario = usuarios.oid)";
}
$SemaforoTecnologias = false;
$tecnologias = $_POST["tecnologias"];
$whereTecnologias="";
foreach($tecnologias as $tecnologia)
if ($tecnologia != "") {
if(!$SemaforoTecnologias)
$tablas .= ", capacidades capacidades3, capacidades_perfil_tecnologias";
$SemaforoTecnologias = true;
if ($whereTecnologias != "") {
$whereTecnologias = $whereTecnologias . " or ";
}
$whereTecnologias = $whereTecnologias . "(capacidades_perfil_tecnologias.id_tecnologia = ". $tecnologia ." and capacidades_perfil_tecnologias.id_capacidad = capacidades3.id and capacidades3.id_usuario = usuarios.oid)";
}
if ($errores == "") {
$query = "SELECT distinct usuarios.* from ". $tablas ." where (usuarios.tipo = 'candidato')";
if ($whereCampos != "")
$query = $query . " and (". $whereCampos .")";
if ($wherePerfilesTec != "")
$query = $query . " and (". $wherePerfilesTec .")";
if ($wherePerfilesFun != "")
$query = $query . " and (". $wherePerfilesFun .")";
if ($whereTecnologias != "")
$query = $query . " and (". $whereTecnologias .")";
//echo $query;
$listaCandidatos=new ListaCandidatos($usuario,"",$query,"");
}
}
?>
<form name="buscador" method="post" action="buscar_candidato.php"><br>
<h2><?php echo $locale['820']; ?></h2>
<?php
if($errores!=""){
// Mostramos el mensaje
echo "<div class=\"aviso error\">".$errores."</div>";
}
?>
<div class="encabezado"><?php echo $locale['Candidato007']; ?></div>
<table align="center" width="100%" border="0">
<tr>
<td width="10%">
<?php echo $locale['01901']; ?> <br><input type="text" name="palabra">
</td>
<td width="90%">
<?php echo $locale['01902']; ?> <br><select multiple name="campo[]" id="campo" size="10">
<?php
while($row = mysql_fetch_row($resultado)) {
?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[0]; ?></option>
<?php
}
?>
</select>
</td>
</tr></table>
<div class="encabezado"><?php echo $locale['Capacidades004']; ?></div>
<table align="center" width="100%" border="0">
<tr>
<td width="20%">
<?php
echo $locale['202']. "<br>";
echo $html->listaSelect("perfil","oid","id","id_perfil_tecnico",array("",$locale['ns']),$_POST['id_perfil_tecnico'],true,true,"15");
?>
</td>
<td width="20%">
<?php
echo $locale['203'].'<br>';
echo $html->listaSelect("tecnologia","oid","id","tecnologias",array("",$locale['ns']),$_POST['tecnologias'],true,true,"15");
?>
</td>
<td width="60%">
<?php
echo $locale['202_2'].'<br>';
echo $html->listaSelect("perfil_funcional","oid","id","id_perfil_funcional",array("",$locale['ns']),$_POST['id_perfil_funcional'],true,true,"15");
?>
</td>
</tr>
</table>
<br>
<input type="submit" value="Buscar" name="buscar">
</form>
<?php
if(count($listaCandidatos)==0)
include_once("ver_lista_candidatos.php");
include_once("html/pie.php");
?>