" ;
$nom_fichier_transfert_ftp = "unimarc".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic";
$tmp_file = $_FILES['userfile']['tmp_name'];
if (!isset($from_file)) $from_file = $_FILES['userfile']['name'];
$to_file = $base_path.'/temp/'.basename($tmp_file);
if ($sub == "import_expl") {
echo window_title($msg[520].$msg[1003].$msg[1001]);
/* the name of the lender is read in the table */
if ($book_lender_id!="") {
$sql_rech="select lender_libelle from lenders where idlender = '".$book_lender_id."' ";
$sql_result_rech = mysql_query($sql_rech) or die ("Couldn't select lenders ! = ".$sql_rech);
if (mysql_num_rows($sql_result_rech)==0) {
$book_lender_name = $msg[561];
} else {
$book_lender_name = mysql_result ($sql_result_rech,0,"lender_libelle");
}
} else {
$book_lender_name = $msg[561];
}
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
} else if ($sub == "import_reb"){
echo window_title($msg["import_reb"].$msg[1003].$msg[1001]);
// ------------------------------------- FIN LLIUREX 02/02/2015 --------------------------------
}else{
echo window_title($msg[500].$msg[1003].$msg[1001]);
}
switch ($action) {
case 'beforeupload':
if ($sub == "import_expl") {
$book_lender_id = "";
$book_statut_id = "";
print $tpl_beforeupload_expl ;
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
} else if ($sub == "import_reb") {
print $tpl_beforeupload_reb ;
// ------------------------------------- FIN LLIUREX 02/02/2015----------------------------------
} else {
// import de notice
print $tpl_beforeupload_notices ;
}
break;
case 'afterupload':
if (!$statutnot) $statutnot = 1 ;
if ($sub == "import_expl") {
if ($book_lender_id==0 || $book_lender_id=="") {
print $msg[561];
break;
}
if ($book_statut_id==0 || $book_statut_id=="") {
print $msg[561];
break;
}
if ($tmp_file=="") {
printf ($msg[503],$from_file); /* wrong permissions to copy the file %s ... Contact your admin... */
break;
}
if (!move_uploaded_file($tmp_file,$to_file)) {
printf ($msg[504],$from_file); /* Fail to copy %s, Contact your admin... */
} else {
printf ($msg[505],$from_file); /* File transfered, Loading is about to go on */
print "
";
print "";
}
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
} else if ($sub == "import_reb") {
// import de rebeca
if ($to_file=="") {
printf ($msg[503],$from_file); /* wrong permissions to copy the file %s ... Contact your admin... */
break;
}
//if (strrpos(strtolower($from_file), ".reb") == false) {
// printf ($msg['import_reb_fail_reb'],$from_file); /* wrong rebeca file %s ... Contact your admin... */
// break;
//}
if (!move_uploaded_file($tmp_file,$to_file)) {
printf ($msg[504],$from_file); /* Fail to copy %s, Contact your admin... */
} else {
printf ($msg[505],$from_file); /* File transfered, Loading is about to go on */
print "";
print "";
}
// ------------------------------------- FIN LLIUREX 02/02/2015--------------------------------------
} else {
// import de notice
if ($to_file=="") {
printf ($msg[503],$from_file); /* wrong permissions to copy the file %s ... Contact your admin... */
break;
}
if (!move_uploaded_file($tmp_file,$to_file)) {
printf ($msg[504],$from_file); /* Fail to copy %s, Contact your admin... */
} else {
printf ($msg[505],$from_file); /* File transfered, Loading is about to go on */
print "";
print "";
}
}
break;
case 'preload':
if ($sub == "import_expl") {
/* Does the file exist ? */
if ($file_submit=="") {
/* l'utilisateur n'est pas passé par le téléchargement du fichier */
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
// Cambiando la ruta de lectura del fichero a leer
// Previamente se ha modificado folow_import.php para escribir en esta nueva ruta
//$filename = $base_path."/admin/import/".$nom_fichier_transfert_ftp;
$filename = $base_path."/temp/".$nom_fichier_transfert_ftp;
// ------------------------------------- FIN LLIUREX 02/02/2015--------------------------------------
$from_file = "unimarc".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic";
} else {
$filename=$file_submit;
}
if ($book_lender_id=="" || $book_statut_id=="" || $isbn_mandatory=="" || $cote_mandatory=="" || $book_location_id=="" || $statutnot=="") {
/* l'utilisateur n'est pas passé par le téléchargement du fichier, il faut qu'il choisisse un prêteur s'il n'en a pas communiqué auparavant */
print "
";
break;
}
loadfile_in_table() ;
if ($pb_fini=="EOF") {
$formulaire="";
printf ($msg[512], $from_file); /* File %s... . End of preload... */
$fo = fopen("$base_path/temp/liste_id".SESSid.".txt","w");
fwrite($fo,"");
fclose($fo);
//file_put_contents("$base_path/temp/liste_id".SESSid.".txt","");
$script = "";
} else {
$formulaire="";
$script = "";
}
print $formulaire;
print $script;
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
} else if ($sub == "import_reb") {
// import de notice
/* Does the file exist ? */
if ($file_submit=="") $filename = "unimarc".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic"; else $filename=$file_submit;
if ($noticenumber=="") $noticenumber=0;
if (!file_exists($filename)) {
printf ($msg[506],$filename); /* The file %s doesn't exist... */
return;
}
if (filesize($filename)==0) {
printf ($msg[507],$filename); /* The file % is empty, it's going to be deleted */
unlink ($filename);
return;
}
$handle = fopen ($filename, "rb");
if (!$handle) {
printf ($msg[508],$filename); /* Unable to open the file %s ... */
return;
}
exec("yaz-marcdump -o marc -s ".$base_path."/temp/rebdump ".$filename." >/dev/null", $output, $return_var);
if ($return_var) {
printf ($msg['import_reb_fail_dump'],$filename); /* dump failed */
unlink ($filename);
return;
}
$formulaire="";
printf ($msg[509].$msg[512], $filename, $filename); /* File %s... . End of preload... */
$script = "";
print $formulaire;
print $script;
// ------------------------------------- FIN LLIUREX 02/02/2015--------------------------------------
} else {
// import de notice
/* Does the file exist ? */
if ($file_submit=="") {
// ------------------------------------- LLIUREX 02/02/2015--------------------------------------
// Cambiando la ruta de lectura del fichero a leer
// Previamente se ha modificado folow_import.php para escribir en esta nueva ruta
//$filename = $base_path."/admin/import/".$nom_fichier_transfert_ftp;
$filename = $base_path."/temp/".$nom_fichier_transfert_ftp;
// ------------------------------------- FIN LLIUREX 02/02/2015--------------------------------------
$from_file = "unimarc".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic";
} else {
$filename=$file_submit;
}
if ($isbn_mandatory=="") {
/* l'utilisateur n'est pas passé par le téléchargement du fichier, il faut qu'il nous dise si l'ISBN est obligatoire */
print "