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']."
";
$errores[]="22";
}
if((count($perfil)==1) && ($perfil["0"]=="")){
$errores_persona .= $locale['1705']."
";
$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 "