2011-06-01 18:24:45 +00:00
< ? php
//FICHERO DE IDIOMAS
define ( " LOCALE " , " idiomas/ " );
define ( " LOCALESET " , " sp/ " );
include LOCALE . LOCALESET . " lenguaje.php " ;
?>
<! 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 >
2011-06-06 16:34:39 +00:00
< base target = " _self " />
2011-06-01 18:24:45 +00:00
< 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 " );
include_once ( " Objects/CapacidadProfesional.php " );
$html = new HTML ( $locale );
2011-06-02 12:00:58 +00:00
$mensaje = " " ;
$errores = array ();
$errores_capacidad = " " ;
2011-06-01 18:24:45 +00:00
$action = " " ;
2011-06-02 12:00:58 +00:00
if ( ! Empty ( $_POST [ 'action' ])){
2011-06-01 18:24:45 +00:00
$action = $_POST [ 'action' ];
} else {
2011-06-02 12:00:58 +00:00
if ( ! Empty ( $_GET [ 'action' ])){
2011-06-01 18:24:45 +00:00
$action = $_GET [ 'action' ];
}
}
$id_capacidad = " " ;
2011-06-02 12:00:58 +00:00
if ( ! Empty ( $_POST [ 'id' ])){
2011-06-01 18:24:45 +00:00
$id_capacidad = $_POST [ 'id' ];
} else {
2011-06-02 12:00:58 +00:00
if ( ! Empty ( $_GET [ 'id' ])){
$id_capacidad = $_GET [ 'id' ];
2011-06-01 18:24:45 +00:00
}
}
$capacidad = new CapacidadProfesional ( $id_capacidad , " candidato " );
$camposCapacidad = $capacidad -> getCampos ();
switch ( $action ) {
case " edit " :
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-06-01 18:24:45 +00:00
if ( count ( $errores ) == 0 ){
$arrayInsert = array ();
$camposQuitar = array ();
$camposQuitar [ " action " ] = stripinput ( $_POST [ 'action' ]);
$camposQuitar [ " id_perfil_tecnico " ] = stripinput ( $_POST [ 'id_perfil_tecnico' ]);
$camposQuitar [ " id_perfil_funcional " ] = stripinput ( $_POST [ 'id_perfil_funcional' ]);
2011-06-02 12:00:58 +00:00
$camposQuitar [ " tecnologias " ] = $_POST [ 'tecnologias' ];
2011-06-01 18:24:45 +00:00
$camposInsertar = array_diff_assoc ( $_POST , $camposQuitar );
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
$tecnologias = array_diff_assoc ( $tecnologias , $vacio );
2011-06-01 18:24:45 +00:00
foreach ( $camposInsertar as $nombre_campo => $valor ){
if ( $valor != " " )
$arrayInsert [ $nombre_campo ] = $valor ;
}
// Modificamos la capacidad profesional
try {
$errorInsert = false ;
$capacidad -> modificarCapacidad ( $arrayInsert );
2011-06-02 12:00:58 +00:00
//El proceso es eliminar todas las tecnologias de la capacidad y volverlas a insertar
//por lo que a las tecnologias nuevas pasados por el POST hay que añadir las ya existentes con sus meses
2011-06-01 18:24:45 +00:00
$tec_aux = $capacidad -> getTecnologias ();
foreach ( $tec_aux as $fila ){
2011-06-02 12:00:58 +00:00
$tecnologias [] = $fila [ " id_tecnologia " ];
2011-06-01 18:24:45 +00:00
}
2011-06-02 12:00:58 +00:00
//Metemos los meses de cada tecnologia si los tuviera
for ( $i = 0 ; $i < count ( $tecnologias ); $i ++ ){
$caption = " meses_ " . $tecnologias [ $i ];
$tecnologias [ $i ] = $tecnologias [ $i ] . " - " . $_POST [ $caption ];
2011-06-01 18:24:45 +00:00
}
2011-06-02 12:00:58 +00:00
if ( count ( $tecnologias ) > 0 )
$capacidad -> addTecnologias ( $tecnologias );
2011-06-01 18:24:45 +00:00
$mensaje = $locale [ 'Capacidades010' ];
$tipomsg = " ok " ;
} catch ( Exception $e ){
$tipomsg = " error " ;
$mensaje = $e -> getMessage ();
}
} else {
$tipomsg = " error " ;
$mensaje = $errores_persona ;
}
break ;
case " dellTec " :
2011-06-02 12:00:58 +00:00
$idTec = $_GET [ 'id_tec' ];
$capacidad -> removeTecnologia ( $id_capacidad , $idTec );
$mensaje = $locale [ '1064' ];
$tipomsg = " ok " ;
2011-06-01 18:24:45 +00:00
break ;
default :
break ;
}
2011-06-02 12:00:58 +00:00
//Refrescamos la clase para que se recogan los posibles cambios realizados en el switch
$capacidad = new CapacidadProfesional ( $id_capacidad , " candidato " );
$camposCapacidad = $capacidad -> getCampos ();
2011-06-01 18:24:45 +00:00
echo " <h2> " . $locale [ 'Capacidades011' ] . " </h2> " ;
if ( $mensaje != " " ){
// Mostramos el mensaje
echo " <div class= \" aviso " . $tipomsg . " \" > " . $mensaje . " </div> " ;
}
echo $locale [ '286' ];
echo " <form action= \" gestionCapacidadProfesional.php \" method= \" POST \" enctype= \" multipart/form-data \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" edit \" /> " ;
2011-06-02 12:00:58 +00:00
echo " <input type= \" hidden \" name= \" id \" value= \" " . $id_capacidad . " \" /> " ;
2011-06-01 18:24:45 +00:00
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="50%"' ;
2011-06-01 18:24:45 +00:00
if ( in_array ( " 23 " , $errores )) echo " class= \" errorcampo \" " ;
2011-06-02 12:00:58 +00:00
echo '>' . $locale [ '121' ] . '<br>' ;
2011-06-01 18:24:45 +00:00
echo $html -> listaSelect ( " perfil " , " oid " , " id " , " id_perfil_tecnico " , array ( " " , $locale [ 'ns' ]), array ( $camposCapacidad [ '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="' . $camposCapacidad [ 'meses_tecnico' ] . '" size="10" maxlength="10"></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>' . $locale [ '122' ] . '<br>' ;
2011-06-01 18:24:45 +00:00
$tecnologias = $capacidad -> getTecnologias ();
$arrayseleccion = array ();
2011-06-02 12:00:58 +00:00
echo $html -> listaSelect ( " tecnologia " , " oid " , " id " , " tecnologias " , array ( " " , $locale [ 'ns' ]), $arrayseleccion , true , true , " 15 " );
echo '</td>' ;
echo '<td>' ;
2011-06-01 18:24:45 +00:00
foreach ( $tecnologias as $tecnologia ) {
$arrayseleccion [] = array ( $tecnologia [ 'id_tecnologia' ], $tecnologia [ 'id' ]);
2011-06-02 12:00:58 +00:00
echo '<input type="text" name="meses_' . $tecnologia [ " id_tecnologia " ] . '" value="' . $tecnologia [ 'meses' ] . '" size="10" maxlength="10"> ' ;
echo $tecnologia [ 'id' ] . " <a href= \" gestionCapacidadProfesional.php?id= " . $id_capacidad . " &action=dellTec&id_tec= " . $tecnologia [ 'id_tecnologia' ] . " \" >Borrar</a><br /> " ;
2011-06-01 18:24:45 +00:00
}
2011-06-02 12:00:58 +00:00
echo '</td>' ;
echo '</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%">' ;
2011-06-02 17:33:20 +00:00
echo '<td width="50%">' . $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' ]), array ( $camposCapacidad [ '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="' . $camposCapacidad [ 'meses_funcional' ] . '" size="10" maxlength="10"></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"">' . $camposCapacidad [ 'observaciones' ] . '</textarea></td></tr>' ;
2011-06-01 18:24:45 +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-06-01 18:24:45 +00:00
echo " </form> " ;
?>
</ body >