" ;
$nom_fichier_transfert_ftp = "unimarc".(defined("LOCATION")?"_".constant("LOCATION"):"").".fic";
$tmp_file = (isset($_FILES['userfile']['tmp_name']) ? $_FILES['userfile']['tmp_name'] : '');
if (!isset($from_file)) $from_file = (isset($_FILES['userfile']['name']) ? $_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 = pmb_mysql_query($sql_rech) or die ("Couldn't select lenders ! = ".$sql_rech);
if (pmb_mysql_num_rows($sql_result_rech)==0) {
$book_lender_name = $msg[561];
} else {
$book_lender_name = pmb_mysql_result($sql_result_rech,0,"lender_libelle");
}
} else {
$book_lender_name = $msg[561];
}
//------------------------------------- LLIUREX 22/02/2018--------------------------------------
} else if ($sub == "import_reb"){
echo window_title($msg["import_reb"].$msg[1003].$msg[1001]);
// ------------------------------------- FIN LLIUREX 22/02/2018 ------------
} 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 22/02/2018--------------------------------------
} else if ($sub == "import_reb") {
print $tpl_beforeupload_reb ;
// ----------------------------FIN LLIUREX 22/02/2018----------------------------------
} else {
// import de notice
print $tpl_beforeupload_notices ;
}
break;
case 'afterupload':
if (!$statutnot) $statutnot = 1 ;
if(!isset($que_faire)) $que_faire = '';
if(!isset($isbn_only)) $isbn_only = '';
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 import_expl::get_hidden_form('afterupload', 'preload');
print "";
}
// -------------------------------- LLIUREX 22/02/2018--------------------------------------
} 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 22/02/2018------------------------------------
} 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 import_records::get_hidden_form('afterupload', 'preload');
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 22/02/2018--------------------------------------
// Cambiando la ruta de lectura del fichero a leer
// Previamente se ha modificado folow_import.php para esc
#$filename = $base_path."/admin/import/".$nom_fichier_transfert_ftp;
$filename = $base_path."/temp/".$nom_fichier_transfert_ftp;
// --------------------------------- FIN LLIUREX 22/02/2018------------------------------------
$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 = import_expl::get_hidden_form('load', 'load');
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 = import_expl::get_hidden_form('preload', 'preload');
$script = "";
}
print $formulaire;
print $script;
// ----------------------------------- LLIUREX 22/02/2018--------------------------------------
} 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 22/02/2018 ---------------------------
} else {
// import de notice
/* Does the file exist ? */
if ($file_submit=="") {
// ---------------------------------- LLIUREX 22/02/2018--------------------------------------
// 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 22/02/2018--------------------------------------
$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 "