2011-04-04 15:16:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
include("seguridad.php");
|
|
|
|
|
|
include("functions.php");
|
|
|
|
|
|
if (!comprobar_permisos("AC")){
|
|
|
|
|
|
header("Location: aplicacion.php?e=permiso");
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
include_once("html/cabecera.php");
|
|
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
//??????????????????????menu_candidatos("");
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
|
|
|
|
|
echo "<h2>".$locale['1542']."</h2>";
|
|
|
|
|
|
|
|
|
|
|
|
//Cogemos el fichero de texto y lo abrimos.
|
|
|
|
|
|
$archivo = $_FILES['userfile'];
|
|
|
|
|
|
$tamano_archivo = $archivo['size'];
|
|
|
|
|
|
|
|
|
|
|
|
//Vamos l<>nea por l<>nea registrando al candidato.
|
|
|
|
|
|
$fp = fopen ( $archivo["tmp_name"] , "r" );
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
$a = 0;
|
|
|
|
|
|
while (( $data = fgetcsv ( $fp , 1000 , "," )) !== FALSE ) { // Mientras hay l<>neas que leer...
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data as $row) {
|
|
|
|
|
|
$aciertos = "";
|
|
|
|
|
|
$errores = "";
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$datos = explode(";",$row);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$nombre = $datos[0];
|
|
|
|
|
|
$apellidos = $datos[1];
|
|
|
|
|
|
$email = $datos[2];
|
|
|
|
|
|
$t_movil = $datos[3];
|
|
|
|
|
|
|
|
|
|
|
|
$existe = existe(NULL, $nombre, $apellidos, $email, NULL);
|
|
|
|
|
|
|
2011-04-04 15:16:10 +00:00
|
|
|
|
//Registramos al candidato
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if ($link = conectar()) {
|
|
|
|
|
|
//include_once("existe_persona.php");
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
if (($existe[0] == 1) || ($existe[1] == 1) || ($existe[2] == 1)) {
|
2011-04-04 15:16:10 +00:00
|
|
|
|
$errores .= $locale['1516'];
|
2011-04-06 18:00:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
$inserto = "tipo,email,nombre,apellidos,t_movil,fecha_alta,fecha_modificacion,procedencia";
|
|
|
|
|
|
$valores = "'candidato','$email','$nombre','$apellidos','$t_movil',curdate(),curdate(),'1'";
|
2011-04-04 15:16:10 +00:00
|
|
|
|
$consulta = "insert into usuarios ($inserto) values ($valores)";
|
|
|
|
|
|
$resultado = mysql_query($consulta,$link);
|
|
|
|
|
|
if ($resultado){
|
|
|
|
|
|
$aciertos .= $locale['1517'];
|
|
|
|
|
|
$ultimo_id = mysql_insert_id();
|
|
|
|
|
|
$autor = $_SESSION["nombre"];
|
|
|
|
|
|
$cambios = $locale['1517'];
|
|
|
|
|
|
|
|
|
|
|
|
$consulta = "insert into historial_usuario (oid_h, fecha_h, persona_h, texto_h) values ('$ultimo_id', now(), '$autor', '$cambios')";
|
|
|
|
|
|
|
|
|
|
|
|
if ($resultado = mysql_query($consulta,$link)){
|
|
|
|
|
|
$aciertos .= $locale['168'];
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$errores .= $locale['169'];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2011-04-06 18:00:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
$errores .= $locale['010'].mysql_error();
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
2011-04-06 18:00:22 +00:00
|
|
|
|
|
2011-04-04 15:16:10 +00:00
|
|
|
|
if($errores == ""){
|
|
|
|
|
|
$i = $i+1;
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$resu = "$nombre $apellidos ".$locale['1543'].".";
|
2011-04-04 15:16:10 +00:00
|
|
|
|
echo mostrar_aciertos($resu);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$a = $a+1;
|
2011-04-06 18:00:22 +00:00
|
|
|
|
$resu = "$nombre $apellidos ".$locale['1544']." $errores.";
|
2011-04-04 15:16:10 +00:00
|
|
|
|
echo mostrar_errores($resu);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Finalmente, el resumen del n<>mero de registros que se han importado y los que han fallado.
|
2011-04-06 18:00:22 +00:00
|
|
|
|
echo $locale['1545']." $i<br/>";
|
|
|
|
|
|
echo $locale['1546']." $a<br/>";
|
2011-04-04 15:16:10 +00:00
|
|
|
|
|
2011-04-06 18:00:22 +00:00
|
|
|
|
fclose ( $fp );
|
2011-04-04 15:16:10 +00:00
|
|
|
|
?>
|