Incam_Intranet/addCandidato.php

291 lines
12 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* P<EFBFBD>gina que ofrece un formulario para agregar candidatos y contiene la l<EFBFBD>gica
* para agregar un candidato
*
* Hay que tener cuidado porque todas las variables que se le pasan por post son agregadas.
*/
include("seguridad.php");
include("functions.php");
if(!$usuario->tieneRol("4")
&& !$usuario->tieneRol("1")){
header("Location: aplicacion.php?e=permiso");
exit;
}
$errores=array();
if(stripinput($_POST['action'])=="add"){
$errores_persona = "";
$mensaje = "";
include_once("campos_persona.php");
if(count($provincia_deseada)==0){
$errores_persona .= $locale['1708']."<br />";
$errores[]="22";
}
if((count($perfil)==1) && ($perfil["0"]=="")){
$errores_persona .= $locale['1705']."<br />";
$errores[]="23";
}
include_once("verificar_candidato.php");
if(count($errores)==0){
$arrayInsert=array();
include_once("Objects/ListaCandidatos.php");
$listaCandidatos=new ListaCandidatos($usuario,"","","10");
$fecha_nacimiento_ini = stripinput($_POST['anyonac'])."-".stripinput($_POST['mesnac'])."-".stripinput($_POST['dianac']);
$fecha_entrevista = stripinput($_POST['anyoentre'])."-".stripinput($_POST['mesentre'])."-".stripinput($_POST['diaentre']);
$camposQuitar=array();
$camposQuitar["dianac"]=stripinput($_POST['dianac']);
$camposQuitar["mesnac"]=stripinput($_POST['mesnac']);
$camposQuitar["anyonac"]=stripinput($_POST['anyonac']);
$camposQuitar["diaalta"]=stripinput($_POST['diaalta']);
$camposQuitar["mesalta"]=stripinput($_POST['mesalta']);
$camposQuitar["anyoalta"]=stripinput($_POST['anyoalta']);
$camposQuitar["MAX_FILE_SIZE"]=stripinput($_POST['MAX_FILE_SIZE']);
$camposQuitar["tecnologia"]=$_POST['tecnologia'];
$camposQuitar["idiomas"]=$_POST['idiomas'];
$camposQuitar["titulaciones"]=$_POST['titulaciones'];
$camposQuitar["provincia_deseada"]=$_POST['provincia_deseada'];
$camposQuitar["perfil"]=$_POST['perfil'];
$camposQuitar["action"]=stripinput($_POST['action']);
$camposQuitar["diaentre"]=stripinput($_POST['diaentre']);
$camposQuitar["mesentre"]=stripinput($_POST['mesentre']);
$camposQuitar["anyoentre"]=stripinput($_POST['anyoentre']);
$camposInsertar=array_diff_assoc($_POST,$camposQuitar);
$camposInsertar["fecha_nacimiento"]=$fecha_nacimiento_ini;
$camposInsertar["procedenciaCV"]=$_POST['procedenciaCV'][0];
if($fecha_entrevista!="2008-1-1")
$camposInsertar["fecha_entrevista"]=$fecha_entrevista;
$vacio=array();
$vacio['0']="";
$_POST['tecnologia']=array_diff_assoc($_POST['tecnologia'],$vacio);
$_POST['idiomas']=array_diff_assoc($_POST['idiomas'],$vacio);
$_POST['titulaciones']=array_diff_assoc($_POST['titulaciones'],$vacio);
$_POST['perfil']=array_diff_assoc($_POST['perfil'],$vacio);
foreach($camposInsertar as $nombre_campo => $valor){
if($valor!="")
$arrayInsert[$nombre_campo]=$valor;
}
// Insertamos el nuevo candidato
try{
$errorInsert=false;
$idCandidatoNew=$listaCandidatos->addCandidato($arrayInsert);
if($idCandidatoNew!="-1"){
include_once("Objects/Candidato.php");
$candidatoNew=new Candidato($usuario,$idCandidatoNew);
$candidatoNew->addTecnologias($_POST['tecnologia']);
$candidatoNew->addIdiomas($_POST['idiomas']);
$candidatoNew->addTitulaciones($_POST['titulaciones']);
if($_POST['provincia_deseada']==""){
$_POST['provincia_deseada']=array();
}
//$candidatoNew->addLocalidadesDeseadas($_POST['localidad_deseada']);
$candidatoNew->addProvinciasDeseadas($_POST['provincia_deseada']);
$candidatoNew->addPerfiles($_POST['perfil']);
$candidatoNew->addCurriculum($_FILES['userfile']);
header("Location: detalle_candidato.php?oid=".$idCandidatoNew);
} else {
$tipomsg="error";
$mensaje="No se ha podido insertar";
}
} catch (Exception $e){
$tipomsg="error";
$mensaje=$e->getMessage();
}
} else {
$tipomsg="error";
$mensaje=$errores_persona;
}
}
include_once("html/cabecera.php");
include_once("Objects/HTML.php");
$html=new HTML($locale);
$html->menuCandidatos();
echo "<h2>".$locale['802']."</h2>";
if($mensaje!=""){
// Mostramos el mensaje
echo "<div class=\"aviso ".$tipomsg."\">".$mensaje."</div>";
}
echo $locale['286'];
$tipo="usuario";
if($errorInsert){
}
echo "<form action=\"addCandidato.php\" method=\"POST\" enctype=\"multipart/form-data\">";
echo "<input type=\"hidden\" name=\"action\" value=\"add\" />";
//Datos personales:
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
echo '<div class="encabezado">'.$locale['1548'].'</div>';
echo '<table align="center" width="100%">';
echo '<tr>
<td ';
if(in_array("1",$errores)) echo " class=\"errorcampo\"";
echo $en.' width="25%" textalign="right">'.$locale['100'].'<br><input type="text" name="nombre" value="'.$_POST['nombre'].'" size="20" maxlength="50"><br></td>
<td ';
if(in_array("2",$errores)) echo " class=\"errorcampo\"";
echo ' width="25%" textalign="right">'.$locale['101'].'<br><input type="text" name="apellidos" value="'.$_POST['apellidos'].'" size="30" maxlength="150"></td>
<td width="25%" textalign="right">'.$locale['116'].'<br>';
rellena_fecha_select($fecha_nacimiento, "nac");
echo '</td>';
echo '<td ';
if(in_array("4",$errores)) echo " class=\"errorcampo\"";
echo ' width="25%" '.$edni.' textalign="right">'.$locale['1539'].'<br><input type="text" name="dni" value="'.$_POST['dni'].'" size="9" maxlength="9"></td></tr>';
echo '<tr>
<td ';
if(in_array("5",$errores)) echo ' class="errorcampo"';
echo ' width="25%">'.$locale['103'].'<input type="text" name="email" value="'.$_POST['email'].'" size="30" maxlength="50"></td>
<td ';
if(in_array("6",$errores)) echo " class=\"errorcampo\"";
echo ' width="25%" '.$etm.' textalign="right" width=20%>'.$locale['107'].'<input type="text" name="t_movil" value="'.$_POST['t_movil'].'" size="9" maxlength="9"></td>
<td ';
if(in_array("7",$errores)) echo " class=\"errorcampo\"";
echo ' width="25%" '.$etc.' textalign="right" width=20%>'.$locale['108'].'<input type="text" name="t_casa" value="'.$_POST['t_casa'].'" size="9" maxlength="9"></td>
<td ';
echo ' width="25%" '.$ett.' textalign="right" width=20%></td>
</tr>';
echo '<tr>
<td ';
if(in_array("13",$errores)) echo " class=\"errorcampo\"";
echo $em.' textalign="right">'.$locale['114'.$tipo.''].'';
rellena_desplegable_localidad($_POST['localidad'], "localidad");
echo '</td>';
// Ticket #558 -> En la pantalla de alta/edici<63>n/ver de un candidato, ocultar los campos 'V<>A', 'NOMBRE V<>A', 'N<>MERO', 'PISO', 'PUERTA' y 'CP'
echo '<td></td><td></td><td></td>';
/*
echo '<td '.$dir.' textalign="right">'.$locale['128'].'';
$auxiliar = '<option value="">-</option>';
rellena_desplegable_select("tipo_via","tipo_via",$auxiliar,$_POST['tipo_via']);
echo '<br>'.$locale['110'].'<input type="text" name="direccion" value="'.$_POST['direccion'].'" size="20" maxlength="50"></td>
<td textalign="right" '.$enum.'>'.$locale['111'].'
<input type="text" name="numero" value="'.$_POST['numero'].'" size="5" maxlength="25"><br>
'.$locale['112'].'
<input type="text" name="piso" value="'.$_POST['piso'].'" size="5" maxlength="25"><br>
'.$locale['113'].'
<input type="text" name="puerta" value="'.$_POST['puerta'].'" size="5" maxlength="25">
</td>
<td ';
if(in_array("12",$errores)) echo " class=\"errorcampo\"";
echo ' textalign="right" '.$ecp.'>'.$locale['115'].'
<input type="text" name="cp" value="'.$_POST['cp'].'" size="3" maxlength="5">
</td>
*/
echo '</tr>';
echo '<tr>
<td colspan="4" align="center">'.$locale['126'].'<br><textarea name="descripcion" rows="4" cols="40" style="overflow: auto;width:100%; height:150px"">'.$_POST['descripcion'].'</textarea></td></tr></table>';
//Datos laborales:
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
echo '<div class="encabezado">'.$locale['1550'].'</div>';
echo '<table align="center" width="100%">';
echo '<td ';
if(in_array("20",$errores)) echo " class=\"errorcampo\"";
echo ' width="33%" textalign="right">'.$locale['1800'].'* : ';
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
rellena_procedencias("procedencia",$auxiliar,$_POST['procedencia']);
echo '</td>';
echo '<td>'.$locale['1576']." ";
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
rellena_desplegable_select_oid("incorporaciones","incorporacion","",$_POST['incorporacion']);
echo '</td>';
echo "<td></td>";
echo '</tr>';
echo '<tr>';
echo '<td width="33%" textalign="right">';
if ($_POST['fecha_entrevista']!="0000-00-00"){
echo $locale['1095']." : ";
echo rellena_fecha_select($_POST['fecha_entrevista'],"entre");
}
echo '</td>';
echo '<td width="33%" textalign="right">';
echo $locale['1800']." ".$locale['1091'].":";
echo $html->listaSelect("procedencia_cv","id","nombre","procedenciaCV",array("","-"),array($_POST['procedenciaCV']),true,false,"1");
echo '</td>';
echo '<td textalign="right">'.$locale['129'];
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
rellena_desplegable_select_oidCol("salario","id","nombre","salario_min",$auxiliar,$_POST['salario_min']);
echo "<br />".$locale['130'];
$auxiliar = '<option value="">'.$locale['ns'].'</option>';
rellena_desplegable_select_oidCol("salario","id","nombre","salario_max",$auxiliar,$_POST['salario_max']);
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td ';
if(in_array("23",$errores)) echo " class=\"errorcampo\"";
echo ' textalign="right" '.$eper.'><div style="float:left ">'.$locale['121'].'</div><div style="float:left ">';
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
echo $html->listaSelect("perfil","oid","id","perfil",array("",$locale['ns']),$_POST['perfil'],true,true,"15");
echo '</div></td>
<td textalign="right"><div style="float:left ">'.$locale['1561'].'</div><div style="float:left ">';
echo $html->listaSelect("provincias","oid","id","provincia_deseada",array("",$locale['ns']),$_POST['provincia_deseada'],true,true,"15");
echo '</div></td>';
echo "<td></td>";
echo '</tr>';
echo '<tr>
<td colspan="3" align="center">'.$locale['135'].'<br><textarea name="observaciones" rows="7" cols="50" style="overflow: auto;width:100%; height:150px"">'.$_POST['observaciones'].'</textarea></td></tr><tr>';
echo '</tr></table>';
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
// CURRICULUM
echo '<div class="encabezado">'.$locale['1549'].'</div>';
echo '<table align="center" width="100%">';
echo '<tr align="center">
<td textalign="right">'.$locale['122'].'</td><td>';
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
echo $html->listaSelect("tecnologia","oid","id","tecnologia",array("",$locale['ns']),$_POST['tecnologia'],true,true,"15");
echo '</td>
<td align="right">'.$locale['123'].'</td><td>';
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
echo $html->listaSelect("idiomas","oid","id","idiomas",array("",$locale['ns']),$_POST['idiomas'],true,true,"15");
echo '</td>
<td align="right">'.$locale['124'].'</td><td>';
$auxiliar = '<option selected value="">'.$locale['ns'].'</option>';
echo $html->listaSelect("titulaciones","oid","id","titulaciones",array("",$locale['ns']),$_POST['titulaciones'],true,true,"15");
echo '</td>
</tr>';
echo '<tr><td colspan="6">';
menu_curriculums($_GET['oid'], "candidato");
echo '</td></tr><tr>';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<td colspan="6" textalign="right">'.$locale['125'].'<br>';
echo '<input name="userfile" type="file">';
echo '</td></tr></table>';
echo '</table>';
echo '<input type="submit" value="'.$locale['802'].'" class="button">';
echo "</form>";
include_once("html/pie.php");
?>