function import_new_notice_suite() { global $dbh; global $notice_id; global $hl, $bl; global $info_461, $info_463; global $info_606; global $id_unimarc; global $delphe_convert; //Récupération des id de thésaurus $thesEntreprise = identifiants_thesaurus("Entreprise"); $thesDelphes = identifiants_thesaurus("Mot clé Delphes"); $thesAciege = identifiants_thesaurus("Aciege"); //les notices ne sont que des articles... if ($hl == 2 && $bl == "a") { $bulletin = array('date' => decoupe_date($info_463[0]['d']), 'num' => clean_string($info_463[0]['v'])); $perio = array('titre' => clean_string($info_461[0])); notice_to_article($perio, $bulletin); } //les descripteurs if (count($delphe_convert) == 0) { init_delphe_term_convert(); } $lang = "fr_FR"; $ordre_categ = 0; foreach ($info_606 as $terms) { $categ_id = 0; $term = $terms['a']; switch ($terms['2']) { case "local": $id_thesaurus = $thesEntreprise[TOP]; $non_classes = $thesEntreprise[NONCLASSES]; $categ_id = find_categ($term, $id_thesaurus, $lang); if ($categ_id == 0) { $categ_id = add_categ($term, $id_thesaurus, $non_classes, $lang); } break; default: //on regarde par défault dans Aciège... $id_thesaurus = $thesAciege[TOP]; $non_classes = $thesAciege[NONCLASSES]; $categ_id = find_categ($term, $id_thesaurus, $lang); if ($categ_id == 0) { //pas trouvé dans aciège, on regarde dans delphes $id_thesaurus = $thesDelphes[TOP]; $non_classes = $thesDelphes[NONCLASSES]; $categ_id = find_categ($term, $id_thesaurus, $lang); if ($categ_id == 0) { //pas trouvé dans delphe, on regarde la table de correspondance if (isset($delphe_convert[$term]['aciege']) && $delphe_convert[$term]['aciege'] != "") { //on reprend la correspondance dans Aciège //on peut avoir plusieurs termes séparés par un +... $terms_to_keep = explode("+", $delphe_convert[$term]['aciege']); if (count($terms_to_keep) > 1) { foreach ($terms_to_keep as $term_to_keep) { $term_to_keep = trim($term_to_keep); $categ_id = find_categ($term_to_keep, 1, $lang); if ($categ_id) { save_categ($categ_id, $ordre_categ); $ordre_categ++; } $categ_id = 0; } } else { $categ_id = find_categ($delphe_convert[$term]['aciege'], 1, $lang); } } else { if (isset($delphe_convert[$term]['aciege']) && $delphe_convert[$term]['delphes'] != "") { //ou dans delphes $categ_id = find_categ($delphe_convert[$term]['delphes'], $id_thesaurus, $lang); } else { if (!isset($delphe_convert[$term])) { //si le terme est présent dans le fichier sans aucunes correspondances,on veut juste pas le traiter du tout, sinon reprise en non classé... $categ_id = add_categ($term, $id_thesaurus, $non_classes, $lang); } } } } } break; } if ($categ_id) { save_categ($categ_id, $ordre_categ); $ordre_categ++; } } //on renseigne le champ perso indexpresse avec le 001... //on récup l'id du champ $rqt = "select idchamp, datatype from notices_custom where name ='cp_index' "; $res = pmb_mysql_query($rqt); if (pmb_mysql_num_rows($res)) { $cp_indexpresse = pmb_mysql_fetch_object($res); $insert = "insert into notices_custom_values set notices_custom_champ=" . $cp_indexpresse->idchamp . ", notices_custom_origine=" . $notice_id . ", notices_custom_" . $cp_indexpresse->datatype . " = '" . $id_unimarc . "'"; pmb_mysql_query($insert) or die(pmb_mysql_error()); } }
function renseigne_cp_agro($val, $notice_id, $type = "notices") { $nom = $val["n"]; $valeur = $val["a"]; if (!trim($nom) || !trim($valeur) || !$notice_id) { return false; } //on va chercher les informations sur le champs $rqt = "SELECT idchamp, type, datatype FROM " . $type . "_custom WHERE name='" . addslashes(trim($nom)) . "'"; $res = mysql_query($rqt); if (!mysql_num_rows($res)) { return false; } $cp = mysql_fetch_object($res); if ($cp->type != $val["t"]) { return false; } //On enregistre la valeur au bon endroit switch ($cp->type) { case "list": //On est sur une liste switch ($cp->datatype) { case "integer": $requete = "select " . $type . "_custom_list_value from " . $type . "_custom_lists where " . $type . "_custom_list_lib='" . addslashes(trim($valeur)) . "' and " . $type . "_custom_champ='" . $cp->idchamp . "' "; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value2 = mysql_result($resultat, 0, 0); } else { $requete = "select max(" . $type . "_custom_list_value*1) from " . $type . "_custom_lists where " . $type . "_custom_champ='" . $cp->idchamp . "' "; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "insert into " . $type . "_custom_lists (" . $type . "_custom_champ," . $type . "_custom_list_value," . $type . "_custom_list_lib) values('" . $cp->idchamp . "',{$n},'" . addslashes(trim($valeur)) . "')"; if (!mysql_query($requete)) { return false; } $value2 = $n; } $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_integer) values('" . $cp->idchamp . "','" . $notice_id . "','" . $value2 . "')"; if (!mysql_query($requete)) { return false; } break; default: $requete = "select " . $type . "_custom_list_value from " . $type . "_custom_lists where " . $type . "_custom_list_lib='" . addslashes(trim($valeur)) . "' and " . $type . "_custom_champ='" . $cp->idchamp . "' "; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value2 = mysql_result($resultat, 0, 0); } else { $requete = "select " . $type . "_custom_list_value from " . $type . "_custom_lists where " . $type . "_custom_list_value='" . addslashes(trim($valeur)) . "' and " . $type . "_custom_champ='" . $cp->idchamp . "' "; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value2 = mysql_result($resultat, 0, 0); } else { $requete = "insert into " . $type . "_custom_lists (" . $type . "_custom_champ," . $type . "_custom_list_value," . $type . "_custom_list_lib) values('" . $cp->idchamp . "','" . addslashes(trim($valeur)) . "','" . addslashes($valeur) . "')"; if (!mysql_query($requete)) { return false; } $value2 = trim($valeur); } } $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_" . $cp->datatype . ") values('" . $cp->idchamp . "','" . $notice_id . "','" . $value2 . "')"; if (!mysql_query($requete)) { return false; } break; } break; case "url": $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_" . $cp->datatype . ") values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes(trim($val["c"])) . "')"; if (!mysql_query($requete)) { return false; } break; case "resolve": $mes_pp = new parametres_perso($type); if ($mes_pp->get_formatted_output(array($val["c"]), $cp->idchamp) == $val["b"]) { $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_" . $cp->datatype . ") values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes($val["c"]) . "')"; if (!mysql_query($requete)) { return false; } } else { return false; } break; case "query_list": case "query_auth": $mes_pp = new parametres_perso($type); if ($mes_pp->get_formatted_output(array($val["c"]), $cp->idchamp) == $valeur) { $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_" . $cp->datatype . ") values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes($val["c"]) . "')"; if (!mysql_query($requete)) { return false; } } else { return false; } break; default: switch ($cp->datatype) { case "small_text": $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_small_text) values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes(trim($valeur)) . "')"; if (!mysql_query($requete)) { return false; } break; case "int": case "integer": $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_integer) values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes(trim($valeur)) . "')"; if (!mysql_query($requete)) { return false; } break; case "text": $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_text) values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes(trim($valeur)) . "')"; if (!mysql_query($requete)) { return false; } break; case "date": $requete = "insert into " . $type . "_custom_values (" . $type . "_custom_champ," . $type . "_custom_origine," . $type . "_custom_date) values('" . $cp->idchamp . "','" . $notice_id . "','" . addslashes(decoupe_date(trim($valeur))) . "')"; if (!mysql_query($requete)) { return false; } break; } break; } return true; }
function import_new_notice_suite() { global $id_unimarc, $info_100, $notice_id, $info_606_a, $info_606_9, $info_900; global $suffix, $isbn_OK, $from_file; if (trim($info_100[0])) { $date = decoupe_date(substr($info_100[0], 0, 8)); $requete = "update notices set create_date = '" . addslashes($date) . "' where notice_id='" . $notice_id . "' "; mysql_query($requete); /*if(!mysql_query($requete)){ echo "requete echoué : ".$requete."<br>"; }*/ } $incr_categ = 0; for ($i = 0; $i < count($info_606_a); $i++) { if (trim($info_606_a[$i][0])) { //echo "ici : ".$info_606[$i]["a"]."<br>"; $trouve = false; $id_noeud = 0; foreach ($info_606_9[$i] as $value) { if (preg_match("/^id:([0-9]+)\$/", $value, $matches)) { $id_noeud = $matches[1]; break; } } if ($id_noeud) { if (categories::exists($id_noeud, "fr_FR")) { //echo "la : ".$info_606[$i]["a"]."<br>"; $categ = new categories($id_noeud, "fr_FR"); if ($categ->libelle_categorie == $info_606_a[$i][0]) { //echo "ou la : ".$info_606[$i]["a"]."<br>"; // ajout de l'indexation à la notice dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ->num_noeud . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; $trouve = true; } } } if (!$trouve) { $mon_msg = "Catégorie non reprise car l'identifant n'existe pas dans PMB : " . $info_606_a[$i][0]; mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') "); } } } for ($i = 0; $i < count($info_900); $i++) { if (trim($info_900[$i]["a"])) { if (!renseigne_cp($info_900[$i]["n"], $info_900[$i]["a"], $notice_id)) { $mon_msg = "La valeur : " . $info_900[$i]["a"] . " n'a pas été reprise dans le champ personalisé : " . $info_900[$i]["n"] . " car le champ n'existe pas"; mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') "); /*echo "Erreur à l'enregistrement du champ perso<br>"; echo "<pre>"; print_r($info_900[$i]); echo "</pre>";*/ } } } }
function import_new_notice_suite() { global $info_461, $info_463, $info_530; global $info_900, $info_901, $tit_200a; global $info_215, $titre_ppal_200, $champ_210, $titre_perio_530a; global $info_606_a, $info_897; global $notice_id; global $bull_id; global $bl, $hl; echo "<pre>"; $bull_id = 0; //cas d'un article if ($bl == "a" && $hl == "2") { //on peut pas découper une date, on a pas de date mais une mention if (decoupe_date($info_463[0]["d"]) == 0 && clean_string($info_463[0]["e"]) == "") { $info_463[0]["e"] = $info_463[0]["d"]; $info_463[0]["d"] = ""; } $bulletin = array('titre' => clean_string($info_463[0]["t"]), 'date' => decoupe_date($info_463[0]["d"]), 'mention' => clean_string($info_463[0]["e"]), 'num' => clean_string($info_463[0]["v"])); $perio = array('titre' => $info_461[0]['t'], 'code' => $info_461[0]['x']); notice_to_article($perio, $bulletin); $update = " update notices set typdoc='t' where notice_id = {$notice_id}"; mysql_query($update); //cas d'un bulletin } else { if ($bl == "s" && $hl == "2") { if (decoupe_date($champ_210[0]['h']) == 0 && clean_string($titre_ppal_200[0]['h']) == "") { $titre_ppal_200[0]['h'] = $champ_210[0]['h']; $champ_210[0]['h'] = ""; } $bulletin = array('titre' => clean_string($titre_ppal_200[0]['i']), 'date' => decoupe_date($champ_210[0]['h']), 'mention' => clean_string($champ_210[0]['d']), 'num' => clean_string($titre_ppal_200[0]['h'])); $perio = array('titre' => $info_461[0]['t'], 'code' => $info_461[0]['x']); $bull_id = genere_bulletin($perio, $bulletin); $update = " update notices set typdoc='t' where notice_id = {$notice_id}"; mysql_query($update); } } //on s'occupe des descripteurs; $id_thesaurus = 1; $non_classes = 3; $lang = "fr_FR"; $ordre_categ = 0; foreach ($info_606_a as $terms) { foreach ($terms as $term) { $categ_id = categories::searchLibelle(addslashes($term), $id_thesaurus, $lang); if ($categ_id) { //le terme existe $noeud = new noeuds($categ_id); if ($noeud->num_renvoi_voir) { $categ_to_index = $noeud->num_renvoi_voir; } else { $categ_to_index = $categ_id; } } else { //le terme est à créé $n = new noeuds(); $n->num_thesaurus = $id_thesaurus; $n->num_parent = $non_classes; $n->save(); $c = new categories($n->id_noeud, $lang); $c->libelle_categorie = $term; $c->index_categorie = ' ' . strip_empty_words($term) . ' '; $c->save(); $categ_to_index = $n->id_noeud; } $requete = "INSERT INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) VALUES({$notice_id},{$categ_to_index},{$ordre_categ})"; mysql_query($requete); $ordre_categ++; } } //on traite le commentaire de gestion $up = "update notices set commentaire_gestion = '" . addslashes($info_901[0][0]) . "' where notice_id = {$notice_id}"; mysql_query($up); //traitement des Champs perso //classique on commence par cherché l'id foreach ($info_900 as $champperso) { $champ = array('libelle' => $champperso['l'], 'nom' => $champperso['n'], 'value' => $champperso['a']); recup_champ_perso($champ, "notices", $notice_id); } //gestion des 897$... foreach ($info_897 as $docnum) { //si on a pas d'url, on traite pas if ($docnum['u']) { //on reprend pas les site web... if ($docnum['m'] != "text/html") { $doc = array('titre' => clean_string($docnum['a']), 'mimetype' => $docnum['m'], 'nom_fic' => clean_string($docnum['f']), 'url' => $docnum['u']); create_docnum($doc); } } } echo "</pre>"; }
function import_new_notice_suite() { global $id_unimarc, $info_100, $notice_id, $info_606_a, $info_606_9, $info_900, $info_950, $info_951; global $suffix, $isbn_OK, $from_file, $thesaurus_defaut; global $bibliographic_level, $hierarchic_level; if (trim($info_100[0])) { $date = decoupe_date(substr($info_100[0], 0, 8)); $requete = "update notices set create_date = '" . addslashes($date) . "' where notice_id='" . $notice_id . "' "; mysql_query($requete); /*if(!mysql_query($requete)){ echo "requete echoué : ".$requete."<br>"; }*/ } $incr_categ = 0; if (count($info_606_a)) { $thes = new thesaurus($thesaurus_defaut); for ($i = 0; $i < count($info_606_a); $i++) { if ($libelle = trim($info_606_a[$i][0])) { //echo "ici : ".$info_606[$i]["a"]."<br>"; $trouve = false; $id_noeud = 0; foreach ($info_606_9[$i] as $value) { if (preg_match("/^id:([0-9]+)\$/", $value, $matches)) { $id_noeud = $matches[1]; break; } } if ($id_noeud) { if (categories::exists($id_noeud, "fr_FR")) { //echo "la : ".$info_606[$i]["a"]."<br>"; $categ = new categories($id_noeud, "fr_FR"); if ($categ->libelle_categorie == $libelle) { //echo "ou la : ".$info_606[$i]["a"]."<br>"; // ajout de l'indexation à la notice dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ->num_noeud . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; $trouve = true; } } } if (!$trouve) { //Je regarde si il y a une autre catégorie avec ce libellé dans les thésaurus $q = "SELECT id_noeud from noeuds JOIN categories ON noeuds.id_noeud = categories.num_noeud WHERE categories.libelle_categorie = '" . addslashes($libelle) . "'"; $res = mysql_query($q); if ($res) { if (mysql_num_rows($res) == 1) { $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . mysql_result($res, 0, 0) . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; } elseif (mysql_num_rows($res) > 1) { $mon_msg = "Catégorie non reprise car elle est présente plusieurs fois dans les thésaurus de PMB: " . $libelle; affiche_mes_erreurs($mon_msg); } else { $n = new noeuds(); $n->num_parent = $thes->num_noeud_racine; $n->num_thesaurus = $thesaurus_defaut; $n->save(); $resultat = $id_n = $n->id_noeud; $c = new categories($id_n, $thes->langue_defaut); $c->libelle_categorie = $libelle; $c->save(); $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $id_n . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; $mon_msg = "Catégorie créée à la racine du thésaurus par défaut: " . $libelle; affiche_mes_erreurs($mon_msg); } } } } } } if ($bibliographic_level == "s" && $hierarchic_level == "1" && count($info_950)) { foreach ($info_950 as $value) { //Emplacement if (!$value["c"]) { $mon_msg = "Etat de collection non importé car pas d'emplacement pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archempla_id FROM arch_emplacement WHERE archempla_libelle='" . addslashes($value["c"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_empl = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_emplacement(archempla_libelle) VALUES('" . addslashes($value["c"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_empl = mysql_insert_id(); } } //Statut if (!$value["h"] && !$value["k"]) { $mon_msg = "Etat de collection non importé car pas de statut pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archstatut_id FROM arch_statut WHERE archstatut_gestion_libelle='" . addslashes($value["k"]) . "' AND archstatut_opac_libelle='" . addslashes($value["h"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_statut = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_statut(archstatut_gestion_libelle,archstatut_opac_libelle) VALUES('" . addslashes($value["k"]) . "','" . addslashes($value["h"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_statut = mysql_insert_id(); } } //Support if (!$value["d"]) { $mon_msg = "Etat de collection non importé car pas de support pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archtype_id FROM arch_type WHERE archtype_libelle='" . addslashes($value["d"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_support = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_type(archtype_libelle) VALUES('" . addslashes($value["d"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_support = mysql_insert_id(); } } //Localisation if (!$value["a"]) { $mon_msg = "Etat de collection non importé car pas de localisation pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT idlocation FROM docs_location WHERE location_libelle='" . addslashes($value["a"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_loc = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO docs_location(location_libelle) VALUES('" . addslashes($value["a"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_loc = mysql_insert_id(); } } $stat = $value["b"]; $cote = $value["f"]; $archive = $value["g"]; $origine = $value["e"]; $note = $value["j"]; $lacune = $value["i"]; $requete = "insert into collections_state(id_serial,location_id,state_collections,collstate_emplacement,collstate_type,collstate_origine,collstate_cote,collstate_archive,collstate_statut,collstate_lacune,collstate_note) values (" . "'" . $notice_id . "','" . $id_loc . "','" . addslashes($stat) . "','" . $id_empl . "','" . $id_support . "','" . addslashes($origine) . "','" . addslashes($cote) . "','" . addslashes($archive) . "','" . $id_statut . "','" . addslashes($lacune) . "','" . addslashes($note) . "'" . ")"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requete: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_coll_stat = mysql_insert_id(); if (count($info_951)) { foreach ($info_951 as $cle => $val) { if ($val["f"] == $id_coll_stat) { //Je suis bien sur un cp de cet exemplaire if (!renseigne_cp($val, $id_coll_stat, "collstate")) { $mon_msg = "La valeur : " . $value["a"] . " n'a pas été reprise dans le champ personnalisé : " . $value["n"] . " car le champ n'existe pas"; affiche_mes_erreurs($mon_msg); } else { unset($info_951[$cle]); } } } } } } } if (count($info_900)) { for ($i = 0; $i < count($info_900); $i++) { if (trim($info_900[$i]["a"])) { if (!renseigne_cp($info_900[$i], $notice_id)) { $mon_msg = "La valeur : " . $info_900[$i]["a"] . " n'a pas été reprise dans le champ personnalisé : " . $info_900[$i]["n"] . " car le champ n'existe pas ou n'est pas défini de la même façon"; affiche_mes_erreurs($mon_msg); } } } } }