2011-05-27 18:47:51 +00:00
< ? php
//FICHERO DE IDIOMAS
define ( " LOCALE " , " idiomas/ " );
define ( " LOCALESET " , " sp/ " );
include LOCALE . LOCALESET . " lenguaje.php " ;
?>
2011-06-01 18:24:45 +00:00
2011-05-27 18:47:51 +00:00
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
< title >< ? php echo $locale [ 'Capacidades004' ]; ?> </title>
< meta http - equiv = " Content-Type " content = " text/html; charset=iso-8859-1 " />
< link rel = " shortcut icon " href = " css/favicon.ico " >
< link rel = " stylesheet " type = " text/css " href = " css/style.css " />
< link rel = " stylesheet " type = " text/css " href = " css/tablas.css " />
</ head >
< body >
< ? php
/**
* Página que ofrece un formulario para agregar capacidades profesionales
*
* Hay que tener cuidado porque todas las variables que se le pasan por post son agregadas .
*/
include ( " functions.php " );
include_once ( " Objects/HTML.php " );
$html = new HTML ( $locale );
2011-06-02 12:00:58 +00:00
$mensaje = " " ;
2011-05-27 18:47:51 +00:00
$errores = array ();
2011-06-02 12:00:58 +00:00
$errores_capacidad = " " ;
//Al ser añadir sabemos siempre que viene de la pantalla del candidato con el id del canidato pasado por get
2011-05-27 18:47:51 +00:00
$id_candidato = $_GET [ 'id_candidato' ];
2011-06-02 12:00:58 +00:00
//Cuando se da a guardar todo viene por POST
2011-05-27 18:47:51 +00:00
if ( stripinput ( $_POST [ 'action' ]) == " add " ){
$id_candidato = $_POST [ " id_candidato " ];
2011-06-02 12:00:58 +00:00
$perfil_tecnico = $_POST [ " id_perfil_tecnico " ];
$perfil_funcional = $_POST [ " id_perfil_funcional " ];
$tecnologias = $_POST [ " tecnologias " ];
//VALIDACIONES
include ( " verificarCapacidadProfesional.php " );
2011-05-27 18:47:51 +00:00
if ( count ( $errores ) == 0 ){
$arrayInsert = array ();
$camposQuitar = array ();
$camposQuitar [ " action " ] = stripinput ( $_POST [ 'action' ]);
$camposQuitar [ " id_candidato " ] = stripinput ( $_POST [ 'id_candidato' ]);
$camposQuitar [ " id_perfil_tecnico " ] = stripinput ( $_POST [ 'id_perfil_tecnico' ]);
2011-06-01 18:24:45 +00:00
$camposQuitar [ " id_perfil_funcional " ] = stripinput ( $_POST [ 'id_perfil_funcional' ]);
2011-06-02 12:00:58 +00:00
$camposQuitar [ " tecnologias " ] = $_POST [ 'tecnologias' ];
2011-05-27 18:47:51 +00:00
$camposInsertar = array_diff_assoc ( $_POST , $camposQuitar );
$camposInsertar [ " id_usuario " ] = $_POST [ 'id_candidato' ];
2011-06-02 12:00:58 +00:00
$camposInsertar [ " id_perfil_tecnico " ] = $perfil_tecnico [ 0 ]; //Sabemos que siempre va a tener un unico elemento el array ya que no le dejamos seleccionar mas de uno
$camposInsertar [ " id_perfil_funcional " ] = $perfil_funcional [ 0 ]; //Sabemos que siempre va a tener un unico elemento el array ya que no le dejamos seleccionar mas de uno
2011-06-01 18:24:45 +00:00
$vacio = array ();
$vacio [ '0' ] = " " ;
2011-06-02 12:00:58 +00:00
$_POST [ 'tecnologias' ] = array_diff_assoc ( $_POST [ 'tecnologias' ], $vacio );
2011-06-01 18:24:45 +00:00
2011-05-27 18:47:51 +00:00
foreach ( $camposInsertar as $nombre_campo => $valor ){
if ( $valor != " " )
$arrayInsert [ $nombre_campo ] = $valor ;
}
// Insertamos la nueva capacidad
try {
$errorInsert = false ;
2011-06-01 18:24:45 +00:00
include_once ( " Objects/CapacidadProfesional.php " );
$CapacidadProfesional = new CapacidadProfesional ( - 1 , " candidato " );
$idCapacidadNew = $CapacidadProfesional -> addCapacidad ( $arrayInsert );
$CapacidadProfesional = new CapacidadProfesional ( $idCapacidadNew , " candidato " );
if ( $idCapacidadNew != " -1 " ){
2011-06-02 12:00:58 +00:00
//Este proceso se hace para que se agregen bien las tecnologías ya que en la edicion se espera despues del id de la tecnologia -meses de la misma
for ( $i = 0 ; $i < count ( $tecnologias ); $i ++ )
$tecnologias [ $i ] = $tecnologias [ $i ] . " - " ;
$CapacidadProfesional -> addTecnologias ( $tecnologias );
header ( " Location: gestionCapacidadProfesional.php?id= " . $idCapacidadNew );
2011-06-01 18:24:45 +00:00
} else {
$tipomsg = " error " ;
$mensaje = " No se ha podido insertar " ;
}
2011-05-27 18:47:51 +00:00
} catch ( Exception $e ){
$tipomsg = " error " ;
$mensaje = $e -> getMessage ();
}
2011-06-02 12:00:58 +00:00
} else {
$tipomsg = " error " ;
$mensaje = $errores_capacidad ;
2011-05-27 18:47:51 +00:00
}
}
2011-06-02 12:00:58 +00:00
echo " <h2> " . $locale [ 'Capacidades014' ] . " </h2> " ;
if ( $mensaje != " " ){
// Mostramos el mensaje
echo " <div class= \" aviso " . $tipomsg . " \" > " . $mensaje . " </div> " ;
}
echo $locale [ '286' ];
2011-05-27 18:47:51 +00:00
echo " <form action= \" addCapacidadProfesional.php \" method= \" POST \" enctype= \" multipart/form-data \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" add \" /> " ;
echo " <input type= \" hidden \" name= \" id_candidato \" value= \" " . $id_candidato . " \" /> " ;
echo '<div class="encabezado">' . $locale [ 'Capacidades005' ] . '</div>' ;
echo '<table align="center" width="100%">' ;
2011-06-02 12:00:58 +00:00
echo '<tr align="left">' ;
echo '<td width="75%" ' ;
if ( in_array ( " 1 " , $errores )) echo " class= \" errorcampo \" " ;
echo '>' . $locale [ '121' ] . '<br>' ;
2011-05-27 18:47:51 +00:00
echo $html -> listaSelect ( " perfil " , " oid " , " id " , " id_perfil_tecnico " , array ( " " , $locale [ 'ns' ]), $_POST [ 'id_perfil_tecnico' ], true , false , " 1 " );
2011-06-02 12:00:58 +00:00
echo '</td>' ;
2011-06-01 18:24:45 +00:00
//MESES_TECNICO
2011-06-02 12:00:58 +00:00
echo '<td>' . $locale [ 'Capacidades008' ] . '<br><input type="text" name="meses_tecnico" value="' . $_POST [ 'meses_tecnico' ] . '" size="10" maxlength="10"><br></td>' ;
2011-06-01 18:24:45 +00:00
echo '</tr>' ;
2011-06-02 12:00:58 +00:00
echo '<tr align="left">' ;
echo '<td colspan="2" >' . $locale [ '122' ] . '<br>' ;
echo $html -> listaSelect ( " tecnologia " , " oid " , " id " , " tecnologias " , array ( " " , $locale [ 'ns' ]), $_POST [ 'tecnologias' ], true , true , " 15 " );
echo '</td></tr>' ;
2011-06-01 18:24:45 +00:00
echo '</table>' ;
echo '<div class="encabezado">' . $locale [ 'Capacidades007' ] . '</div>' ;
2011-06-02 12:00:58 +00:00
echo '<table align="left" width="100%">' ;
echo '<tr>' ;
echo '<td width="75%"' ;
if ( in_array ( " 2 " , $errores )) echo " class= \" errorcampo \" " ;
2011-06-02 17:33:20 +00:00
echo '>' . $locale [ 'Capacidades002_0' ] . '<br>' ;
2011-06-01 18:24:45 +00:00
echo $html -> listaSelect ( " perfil_funcional " , " oid " , " id " , " id_perfil_funcional " , array ( " " , $locale [ 'ns' ]), $_POST [ 'id_perfil_funcional' ], true , false , " 1 " );
2011-06-02 12:00:58 +00:00
echo '</td>' ;
2011-06-01 18:24:45 +00:00
//MESES_FUNCIONAL
2011-06-02 12:00:58 +00:00
echo '<td>' . $locale [ 'Capacidades008' ] . '<br><input type="text" name="meses_funcional" value="' . $_POST [ 'meses_funcional' ] . '" size="10" maxlength="10"><br></td>' ;
2011-06-01 18:24:45 +00:00
echo '</tr>' ;
// CAMPO OBSERVACIONES
2011-06-02 12:00:58 +00:00
echo '<tr><td colspan="2">' . $locale [ '135' ] . '<br><textarea name="observaciones" rows="7" cols="50" style="overflow: auto;width:100%; height:100px"">' . $_POST [ 'observaciones' ] . '</textarea></td></tr>' ;
2011-05-27 18:47:51 +00:00
echo '</table>' ;
echo '<input type="submit" value="' . $locale [ 'gu' ] . '" class="button">' ;
2011-06-02 12:00:58 +00:00
echo ' ' ;
echo '<input type="button" value=" ' . $locale [ 'cerrar' ] . ' " class="button" onclick="window.close()">' ;
2011-05-27 18:47:51 +00:00
echo " </form> " ;
?>
</ body >