Пример #1
0
 function get_form($action, $id_notice = 0, $retour = 'link', $article = false)
 {
     // construit le formulaire de catalogage pré-rempli
     global $msg, $dbh, $charset, $current_module;
     global $include_path;
     global $base_path;
     global $znotices_id;
     global $item;
     $fonction = new marc_list('function');
     $this->action = $action;
     include "{$include_path}/templates/z3950_form.tpl.php";
     global $bt_undo;
     // mise à jour de l'entête du formulaire
     $form_notice = str_replace('!!libelle_form!!', $this->libelle_form, $form_notice);
     // mise à jour des flags de niveau hiérarchique
     $form_notice = str_replace('!!b_level!!', $this->bibliographic_level, $form_notice);
     $form_notice = str_replace('!!h_level!!', $this->hierarchic_level, $form_notice);
     for ($i = 0; $i < 4; $i++) {
         z3950_notice::substitute("title_{$i}", $this->titles[$i], $ptab[0]);
     }
     z3950_notice::substitute("serie", $this->serie, $ptab[0]);
     z3950_notice::substitute("nbr_in_serie", $this->nbr_in_serie, $ptab[0]);
     $form_notice = str_replace('!!tab0!!', $ptab[0], $form_notice);
     // mise à jour de l'onglet 1
     // constitution de la mention de responsabilité
     $nb_autres_auteurs = 0;
     $nb_auteurs_secondaires = 0;
     //print "<pre>";print_r($this->aut_array);print "</pre>";
     for ($as = 0; $as < sizeof($this->aut_array); $as++) {
         if ($this->aut_array[$as]["responsabilite"] === 0) {
             $numrows = 0;
             if ($this->aut_array[$as]["date"]) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "' AND author_date ='" . addslashes($this->aut_array[$as]["date"]) . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if (!$numrows) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if ($numrows == 1) {
                 $existing_author = pmb_mysql_fetch_array($res);
                 $existing_author_id = $existing_author["author_id"];
             } else {
                 $existing_author_id = 0;
             }
             z3950_notice::substitute("author0_type_use_existing", $existing_author_id ? "checked" : "", $ptab[1]);
             z3950_notice::substitute("author0_type_insert_new", $existing_author_id ? "" : "checked", $ptab[1]);
             if ($existing_author_id) {
                 z3950_notice::substitute("f_author_name_0_existing", $existing_author["author_name"] . ", " . $existing_author["author_rejete"] . ($existing_author["author_date"] ? " (" . $existing_author["author_date"] . ")" : ""), $ptab[1]);
                 z3950_notice::substitute("f_aut0_existing_id", $existing_author_id, $ptab[1]);
             } else {
                 z3950_notice::substitute("f_author_name_0_existing", '', $ptab[1]);
                 z3950_notice::substitute("f_aut0_existing_id", 0, $ptab[1]);
             }
             z3950_notice::substitute("author_name_0", $this->aut_array[$as]["entree"], $ptab[1]);
             z3950_notice::substitute("author_rejete_0", $this->aut_array[$as]["rejete"], $ptab[1]);
             z3950_notice::substitute("author_date_0", $this->aut_array[$as]["date"], $ptab[1]);
             z3950_notice::substitute("author_function_0", $this->aut_array[$as]["fonction"], $ptab[1]);
             z3950_notice::substitute("author_function_label_0", $fonction->table[$this->aut_array[$as]["fonction"]], $ptab[1]);
             z3950_notice::substitute("author_lieu_0", $this->aut_array[$as]["lieu"], $ptab[1]);
             z3950_notice::substitute("author_pays_0", $this->aut_array[$as]["pays"], $ptab[1]);
             z3950_notice::substitute("author_comment_0", $this->aut_array[$as]["author_comment"], $ptab[1]);
             z3950_notice::substitute("author_ville_0", $this->aut_array[$as]["ville"], $ptab[1]);
             z3950_notice::substitute("author_subdivision_0", $this->aut_array[$as]["subdivision"], $ptab[1]);
             z3950_notice::substitute("author_numero_0", $this->aut_array[$as]["numero"], $ptab[1]);
             z3950_notice::substitute("author_web_0", $this->aut_array[$as]["web"], $ptab[1]);
             z3950_notice::substitute("authority_number_0", $this->aut_array[$as]["authority_number"], $ptab[1]);
             for ($type = 70; $type <= 72; $type++) {
                 if ($this->aut_array[$as]["type_auteur"] == $type) {
                     $sel = " selected";
                 } else {
                     $sel = "";
                 }
                 z3950_notice::substitute("author_type_" . $type . "_0", $sel, $ptab[1]);
                 if ($this->aut_array[$as]["type_auteur"] == '70') {
                     z3950_notice::substitute('display_0', 'none', $ptab[1]);
                 } else {
                     z3950_notice::substitute('display_0', '', $ptab[1]);
                 }
             }
         }
         if ($this->aut_array[$as]["responsabilite"] == 1) {
             if ($this->aut_array[$as]["entree"] == "") {
                 continue;
             }
             $ptab_aut_autres = str_replace('!!iaut!!', $nb_autres_auteurs, $ptab[11]);
             $numrows = 0;
             if ($this->aut_array[$as]["date"]) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "' AND author_date ='" . addslashes($this->aut_array[$as]["date"]) . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if (!$numrows) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if ($numrows == 1) {
                 $existing_author = pmb_mysql_fetch_array($res);
                 $existing_author_id = $existing_author["author_id"];
             } else {
                 $existing_author_id = 0;
             }
             z3950_notice::substitute("author1_type_use_existing_", $existing_author_id ? "checked" : "", $ptab_aut_autres);
             z3950_notice::substitute("author1_type_insert_new_", $existing_author_id ? "" : "checked", $ptab_aut_autres);
             if ($existing_author_id) {
                 z3950_notice::substitute("f_aut1", $existing_author["author_name"] . ", " . $existing_author["author_rejete"] . ($existing_author["author_date"] ? " (" . $existing_author["author_date"] . ")" : ""), $ptab_aut_autres);
                 z3950_notice::substitute("f_aut1_id", $existing_author_id, $ptab_aut_autres);
             } else {
                 z3950_notice::substitute("f_aut1", '', $ptab_aut_autres);
                 z3950_notice::substitute("f_aut1_id", '', $ptab_aut_autres);
             }
             z3950_notice::substitute("author_name_1", $this->aut_array[$as]["entree"], $ptab_aut_autres);
             z3950_notice::substitute("author_rejete_1", $this->aut_array[$as]["rejete"], $ptab_aut_autres);
             z3950_notice::substitute("author_date_1", $this->aut_array[$as]["date"], $ptab_aut_autres);
             z3950_notice::substitute("author_function_1", $this->aut_array[$as]["fonction"], $ptab_aut_autres);
             z3950_notice::substitute("author_function_label_1", $fonction->table[$this->aut_array[$as]["fonction"]], $ptab_aut_autres);
             z3950_notice::substitute("author_lieu_1", $this->aut_array[$as]["lieu"], $ptab_aut_autres);
             z3950_notice::substitute("author_pays_1", $this->aut_array[$as]["pays"], $ptab_aut_autres);
             z3950_notice::substitute("author_comment_1", $this->aut_array[$as]["author_comment"], $ptab_aut_autres);
             z3950_notice::substitute("author_ville_1", $this->aut_array[$as]["ville"], $ptab_aut_autres);
             z3950_notice::substitute("author_subdivision_1", $this->aut_array[$as]["subdivision"], $ptab_aut_autres);
             z3950_notice::substitute("author_numero_1", $this->aut_array[$as]["numero"], $ptab_aut_autres);
             z3950_notice::substitute("author_web_1", $this->aut_array[$as]["web"], $ptab_aut_autres);
             z3950_notice::substitute("authority_number_1", $this->aut_array[$as]["authority_number"], $ptab_aut_autres);
             for ($type = 70; $type <= 72; $type++) {
                 if ($this->aut_array[$as]["type_auteur"] == $type) {
                     $sel = " selected";
                 } else {
                     $sel = "";
                 }
                 z3950_notice::substitute("author_type_" . $type . "_1", $sel, $ptab_aut_autres);
                 if ($this->aut_array[$as]["type_auteur"] == '70') {
                     z3950_notice::substitute('display_1' . $nb_autres_auteurs, 'none', $ptab_aut_autres);
                 } else {
                     z3950_notice::substitute('display_1' . $nb_autres_auteurs, '', $ptab_aut_autres);
                 }
             }
             $autres_auteurs .= $ptab_aut_autres;
             $nb_autres_auteurs++;
         }
         if ($this->aut_array[$as]["responsabilite"] == 2) {
             if ($this->aut_array[$as]["entree"] == "") {
                 continue;
             }
             $ptab_aut_autres = str_replace('!!iaut!!', $nb_auteurs_secondaires, $ptab[12]);
             $numrows = 0;
             if ($this->aut_array[$as]["date"]) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "' AND author_date ='" . addslashes($this->aut_array[$as]["date"]) . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if (!$numrows) {
                 $sql_author_find = "SELECT author_id, author_name, author_rejete, author_date FROM authors WHERE author_name = '" . addslashes($this->aut_array[$as]["entree"]) . "' AND author_rejete = '" . addslashes($this->aut_array[$as]["rejete"]) . "' AND author_type = '" . $this->aut_array[$as]["type_auteur"] . "'";
                 $res = pmb_mysql_query($sql_author_find);
                 $numrows = pmb_mysql_num_rows($res);
             }
             if ($numrows == 1) {
                 $existing_author = pmb_mysql_fetch_array($res);
                 $existing_author_id = $existing_author["author_id"];
             } else {
                 $existing_author_id = 0;
             }
             z3950_notice::substitute("author2_type_use_existing_", $existing_author_id ? "checked" : "", $ptab_aut_autres);
             z3950_notice::substitute("author2_type_insert_new_", $existing_author_id ? "" : "checked", $ptab_aut_autres);
             if ($existing_author_id) {
                 z3950_notice::substitute("f_aut2", $existing_author["author_name"] . ", " . $existing_author["author_rejete"] . ($existing_author["author_date"] ? " (" . $existing_author["author_date"] . ")" : ""), $ptab_aut_autres);
                 z3950_notice::substitute("f_aut2_id", $existing_author_id, $ptab_aut_autres);
             } else {
                 z3950_notice::substitute("f_aut2", '', $ptab_aut_autres);
                 z3950_notice::substitute("f_aut2_id", 0, $ptab_aut_autres);
             }
             z3950_notice::substitute("author_name_2", $this->aut_array[$as]["entree"], $ptab_aut_autres);
             z3950_notice::substitute("author_rejete_2", $this->aut_array[$as]["rejete"], $ptab_aut_autres);
             z3950_notice::substitute("author_date_2", $this->aut_array[$as]["date"], $ptab_aut_autres);
             z3950_notice::substitute("author_function_2", $this->aut_array[$as]["fonction"], $ptab_aut_autres);
             z3950_notice::substitute("author_function_label_2", $fonction->table[$this->aut_array[$as]["fonction"]], $ptab_aut_autres);
             z3950_notice::substitute("author_lieu_2", $this->aut_array[$as]["lieu"], $ptab_aut_autres);
             z3950_notice::substitute("author_pays_2", $this->aut_array[$as]["pays"], $ptab_aut_autres);
             z3950_notice::substitute("author_comment_2", $this->aut_array[$as]["author_comment"], $ptab_aut_autres);
             z3950_notice::substitute("author_ville_2", $this->aut_array[$as]["ville"], $ptab_aut_autres);
             z3950_notice::substitute("author_subdivision_2", $this->aut_array[$as]["subdivision"], $ptab_aut_autres);
             z3950_notice::substitute("author_numero_2", $this->aut_array[$as]["numero"], $ptab_aut_autres);
             z3950_notice::substitute("author_web_2", $this->aut_array[$as]["web"], $ptab_aut_autres);
             z3950_notice::substitute("authority_number_2", $this->aut_array[$as]["authority_number"], $ptab_aut_autres);
             for ($type = 70; $type <= 72; $type++) {
                 if ($this->aut_array[$as]["type_auteur"] == $type) {
                     $sel = " selected";
                 } else {
                     $sel = "";
                 }
                 z3950_notice::substitute("author_type_" . $type . "_2", $sel, $ptab_aut_autres);
                 if ($this->aut_array[$as]["type_auteur"] == '70') {
                     z3950_notice::substitute('display_2' . $nb_auteurs_secondaires, 'none', $ptab_aut_autres);
                 } else {
                     z3950_notice::substitute('display_2' . $nb_auteurs_secondaires, '', $ptab_aut_autres);
                 }
             }
             $auteurs_secondaires .= $ptab_aut_autres;
             $nb_auteurs_secondaires++;
         }
     }
     // au cas ou pas d'auteur principal : on fait le ménage dans le formulaire
     z3950_notice::substitute("author_name_0", "", $ptab[1]);
     z3950_notice::substitute("author_rejete_0", "", $ptab[1]);
     z3950_notice::substitute("author_date_0", "", $ptab[1]);
     z3950_notice::substitute("author_function_0", "", $ptab[1]);
     z3950_notice::substitute("author_function_label_0", "", $ptab[1]);
     z3950_notice::substitute("f_author_name_0_existing", "", $ptab[1]);
     z3950_notice::substitute("f_aut0_existing_id", "", $ptab[1]);
     z3950_notice::substitute("author0_type_use_existing", "", $ptab[1]);
     z3950_notice::substitute("author0_type_insert_new", "checked", $ptab[1]);
     z3950_notice::substitute("author_lieu_0", "", $ptab[1]);
     z3950_notice::substitute("author_pays_0", "", $ptab[1]);
     z3950_notice::substitute("author_comment_0", "", $ptab[1]);
     z3950_notice::substitute("author_ville_0", "", $ptab[1]);
     z3950_notice::substitute("author_subdivision_0", "", $ptab[1]);
     z3950_notice::substitute("author_numero_0", "", $ptab[1]);
     z3950_notice::substitute("author_web_0", "", $ptab[1]);
     z3950_notice::substitute("authority_number_0", "", $ptab[1]);
     z3950_notice::substitute('display_0', 'none', $ptab[1]);
     $ptab[1] = str_replace('!!max_aut1!!', $nb_autres_auteurs + 1, $ptab[1]);
     $ptab[1] = str_replace('!!iaut_added1!!', $nb_autres_auteurs, $ptab[1]);
     $ptab[1] = str_replace('!!max_aut2!!', $nb_auteurs_secondaires + 1, $ptab[1]);
     $ptab[1] = str_replace('!!iaut_added2!!', $nb_auteurs_secondaires, $ptab[1]);
     $ptab[1] = str_replace('!!autres_auteurs!!', $autres_auteurs, $ptab[1]);
     $ptab[1] = str_replace('!!auteurs_secondaires!!', $auteurs_secondaires, $ptab[1]);
     $form_notice = str_replace('!!tab1!!', $ptab[1], $form_notice);
     //Editeur 1
     //On tente avec toutes les infos
     if ($this->editors[0]['name'] && $this->editors[0]['ville']) {
         $sql_find_publisher = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[0]['name']) . "' AND ed_ville = '" . addslashes($this->editors[0]['ville']) . "'";
         $res = pmb_mysql_query($sql_find_publisher);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher = pmb_mysql_fetch_array($res);
             $existing_publisher_id = $existing_publisher["ed_id"];
         }
     }
     //Non? Le nom sans ville peut être alors?
     if (!$existing_publisher_id && $this->editors[0]['name']) {
         $sql_find_publisher = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[0]['name']) . "' AND ed_ville = ''";
         $res = pmb_mysql_query($sql_find_publisher);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher = pmb_mysql_fetch_array($res);
             $existing_publisher_id = $existing_publisher["ed_id"];
         }
     }
     //Juste le nom alors?
     if (!$existing_publisher_id && $this->editors[0]['name'] && !$this->editors[0]['ville']) {
         $sql_find_publisher = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[0]['name']) . "'";
         $res = pmb_mysql_query($sql_find_publisher);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher = pmb_mysql_fetch_array($res);
             $existing_publisher_id = $existing_publisher["ed_id"];
         }
     }
     if (!$existing_publisher_id) {
         $existing_publisher_id = 0;
     }
     z3950_notice::substitute("editor_type_use_existing", $existing_publisher_id ? 'checked' : '', $ptab[2]);
     z3950_notice::substitute("editor_type_insert_new", $existing_publisher_id ? '' : 'checked', $ptab[2]);
     if ($existing_publisher_id) {
         $editor = new editeur($existing_publisher_id);
         $editor_display = $editor->display;
         if (!$editor_display) {
             $info_ville = $existing_publisher["ed_ville"] ? ' (' . $existing_publisher["ed_ville"] . ')' : "";
             $editor_display = $existing_publisher["ed_name"] . $info_ville;
         }
         z3950_notice::substitute("f_ed1", $editor_display, $ptab[2]);
         z3950_notice::substitute("f_ed1_id", $existing_publisher_id, $ptab[2]);
     } else {
         z3950_notice::substitute("f_ed1", '', $ptab[2]);
         z3950_notice::substitute("f_ed1_id", '', $ptab[2]);
     }
     z3950_notice::substitute("editor_name_0", $this->editors[0]['name'], $ptab[2]);
     z3950_notice::substitute("editor_ville_0", $this->editors[0]['ville'], $ptab[2]);
     //Editeur 2
     //On tente avec toutes les infos
     if ($this->editors[1]['name'] && $this->editors[1]['ville']) {
         $sql_find_publisher2 = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[1]['name']) . "' AND ed_ville = '" . addslashes($this->editors[1]['ville']) . "'";
         $res = pmb_mysql_query($sql_find_publisher2);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher2 = pmb_mysql_fetch_array($res);
             $existing_publisher_id2 = $existing_publisher2["ed_id"];
         }
     }
     //Non? Le nom sans ville peut être alors?
     if (!$existing_publisher_id2 && $this->editors[1]['name']) {
         $sql_find_publisher2 = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[1]['name']) . "' AND ed_ville = ''";
         $res = pmb_mysql_query($sql_find_publisher2);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher2 = pmb_mysql_fetch_array($res);
             $existing_publisher_id2 = $existing_publisher2["ed_id"];
         }
     }
     //Juste le nom alors?
     if (!$existing_publisher_id2 && $this->editors[1]['name'] && !$this->editors[1]['ville']) {
         $sql_find_publisher2 = "SELECT ed_id,ed_ville,ed_name FROM publishers WHERE ed_name = '" . addslashes($this->editors[1]['name']) . "'";
         $res = pmb_mysql_query($sql_find_publisher2);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_publisher2 = pmb_mysql_fetch_array($res);
             $existing_publisher_id2 = $existing_publisher2["ed_id"];
         }
     }
     if (!$existing_publisher_id2) {
         $existing_publisher_id2 = 0;
     }
     z3950_notice::substitute("editor1_type_use_existing", $existing_publisher_id2 ? 'checked' : '', $ptab[2]);
     z3950_notice::substitute("editor1_type_insert_new", $existing_publisher_id2 ? '' : 'checked', $ptab[2]);
     if ($existing_publisher_id2) {
         $editor = new editeur($existing_publisher_id2);
         $editor_display = $editor->display;
         if (!$editor_display) {
             $info_ville = $existing_publisher2["ed_ville"] ? ' (' . $existing_publisher2["ed_ville"] . ')' : "";
             $editor_display = $existing_publisher2["ed_name"] . $info_ville;
         }
         z3950_notice::substitute("f_ed11", $editor_display, $ptab[2]);
         z3950_notice::substitute("f_ed11_id", $existing_publisher_id2, $ptab[2]);
     } else {
         z3950_notice::substitute("f_ed11", '', $ptab[2]);
         z3950_notice::substitute("f_ed11_id", '', $ptab[2]);
     }
     z3950_notice::substitute("editor_name_1", $this->editors[1]['name'], $ptab[2]);
     z3950_notice::substitute("editor_ville_1", $this->editors[1]['ville'], $ptab[2]);
     //Collection
     if ($existing_publisher_id && $this->collection['name']) {
         $sql_collection_find = "SELECT collection_id, collection_name FROM collections WHERE collection_name = '" . addslashes($this->collection['name']) . "' AND collection_parent = '" . $existing_publisher_id . "'";
         $res = pmb_mysql_query($sql_collection_find);
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_collection = pmb_mysql_fetch_array($res);
             $existing_collection_id = $existing_collection["collection_id"];
         } else {
             $existing_collection_id = 0;
         }
     } else {
         $existing_collection_id = 0;
     }
     z3950_notice::substitute("collection_type_use_existing", $existing_collection_id ? 'checked' : '', $ptab[2]);
     z3950_notice::substitute("collection_type_insert_new", $existing_collection_id ? '' : 'checked', $ptab[2]);
     if ($existing_collection_id) {
         z3950_notice::substitute("f_coll_existing", $existing_collection["collection_name"], $ptab[2]);
         z3950_notice::substitute("f_coll_existing_id", $existing_collection_id, $ptab[2]);
     } else {
         z3950_notice::substitute("f_coll_existing", '', $ptab[2]);
         z3950_notice::substitute("f_coll_existing_id", '0', $ptab[2]);
     }
     z3950_notice::substitute("collection_name", $this->collection['name'], $ptab[2]);
     z3950_notice::substitute("collection_issn", $this->collection['issn'], $ptab[2]);
     //Sous Collection
     if ($existing_collection_id && $this->subcollection['name']) {
         $sql_subcollection_find = "SELECT sub_coll_id, sub_coll_name FROM sub_collections WHERE sub_coll_name = '" . addslashes($this->subcollection['name']) . "' AND sub_coll_parent = '" . $existing_collection_id . "'";
         $res = pmb_mysql_query($sql_subcollection_find) or die(pmb_mysql_error() . "<br />{$sql_subcollection_find}");
         if (pmb_mysql_num_rows($res) == 1) {
             $existing_subcollection = pmb_mysql_fetch_array($res);
             $existing_subcollection_id = $existing_subcollection["sub_coll_id"];
         } else {
             $existing_subcollection_id = 0;
         }
     } else {
         $existing_subcollection_id = 0;
     }
     z3950_notice::substitute("subcollection_type_use_existing", $existing_subcollection_id ? 'checked' : '', $ptab[2]);
     z3950_notice::substitute("subcollection_type_insert_new", $existing_subcollection_id ? '' : 'checked', $ptab[2]);
     if ($existing_subcollection_id) {
         z3950_notice::substitute("f_subcoll_existing", $existing_subcollection["sub_coll_name"], $ptab[2]);
         z3950_notice::substitute("f_subcoll_existing_id", $existing_subcollection_id, $ptab[2]);
     } else {
         z3950_notice::substitute("f_subcoll_existing", '', $ptab[2]);
         z3950_notice::substitute("f_subcoll_existing_id", '0', $ptab[2]);
     }
     z3950_notice::substitute("subcollection_name", $this->subcollection['name'], $ptab[2]);
     z3950_notice::substitute("subcollection_issn", $this->subcollection['issn'], $ptab[2]);
     z3950_notice::substitute("nbr_in_collection", $this->nbr_in_collection, $ptab[2]);
     z3950_notice::substitute("year", $this->year, $ptab[2]);
     z3950_notice::substitute("mention_edition", $this->mention_edition, $ptab[2]);
     $form_notice = str_replace('!!tab2!!', $ptab[2], $form_notice);
     z3950_notice::substitute("isbn", $this->isbn, $ptab[3]);
     $form_notice = str_replace('!!tab3!!', $ptab[3], $form_notice);
     z3950_notice::substitute("page_nbr", $this->page_nbr, $ptab[4]);
     z3950_notice::substitute("illustration", $this->illustration, $ptab[4]);
     z3950_notice::substitute("prix", $this->prix, $ptab[4]);
     z3950_notice::substitute("accompagnement", $this->accompagnement, $ptab[4]);
     z3950_notice::substitute("size", $this->size, $ptab[4]);
     $form_notice = str_replace('!!tab4!!', $ptab[4], $form_notice);
     z3950_notice::substitute("general_note", $this->general_note, $ptab[5]);
     z3950_notice::substitute("content_note", $this->content_note, $ptab[5]);
     z3950_notice::substitute("abstract_note", $this->abstract_note, $ptab[5]);
     $form_notice = str_replace('!!tab5!!', $ptab[5], $form_notice);
     // indexation interne
     $pclassement_sql = "SELECT * FROM pclassement";
     $res = pmb_mysql_query($pclassement_sql);
     $pclassement_count = pmb_mysql_num_rows($res);
     if (!$pclassement_count) {
         $pclassement_count = 1;
     }
     if ($pclassement_count > 1) {
         $pclassements = array();
         while ($row = pmb_mysql_fetch_assoc($res)) {
             $pclassements[] = array("id" => $row["id_pclass"], "name" => $row["name_pclass"]);
         }
         $pclassement_combobox = '<select name="f_indexint_new_pclass">';
         foreach ($pclassements as $pclassement) {
             $pclassement_combobox .= '<option value="' . $pclassement["id"] . '">' . $pclassement["name"] . '</option>';
         }
         $pclassement_combobox .= '</select>';
     } else {
         $pclassement_combobox = "";
     }
     $ptab[6] = str_replace("!!multiple_pclass_combo_box!!", $pclassement_combobox, $ptab[6]);
     $index_int_sql = "SELECT indexint_name, indexint_comment, indexint_id, name_pclass FROM indexint LEFT JOIN pclassement ON (pclassement.id_pclass = indexint.num_pclass) WHERE indexint_name = '" . addslashes($this->dewey[0]) . "'";
     $res = pmb_mysql_query($index_int_sql, $dbh);
     $num_rows = pmb_mysql_num_rows($res);
     if ($num_rows == 1) {
         $the_row = pmb_mysql_fetch_assoc($res);
         z3950_notice::substitute("indexint", $the_row["indexint_name"] . ': ' . $the_row["indexint_comment"], $ptab[6]);
         z3950_notice::substitute("indexint_id", $the_row["indexint_id"], $ptab[6]);
         z3950_notice::substitute("indexint_type_use_existing", 'checked', $ptab[6]);
         z3950_notice::substitute("indexint_type_insert_new", '', $ptab[6]);
         z3950_notice::substitute("multiple_index_int_propositions", '', $ptab[6]);
     } else {
         if ($num_rows > 1) {
             $index_ints = array();
             while ($row = pmb_mysql_fetch_assoc($res)) {
                 $index_ints[] = array("id" => $row["indexint_id"], "name" => $row["indexint_name"], "comment" => $row["indexint_comment"], "pclass" => $row["name_pclass"]);
             }
             $form_indexint_proposition = "<ul>";
             foreach ($index_ints as $index_int) {
                 $form_indexint_proposition .= "<li><b>[" . $index_int["pclass"] . "]</b> " . $index_int["name"] . ": " . $index_int["comment"] . '&nbsp;';
                 $jsaction = "document.getElementById('indexint_type_use_existing').checked=1; document.getElementById('f_indexint').value='" . addslashes($index_int["name"] . ' - ' . $index_int["comment"]) . "'; document.getElementById('f_indexint_id').value='" . addslashes($index_int["id"]) . "'";
                 $form_indexint_proposition .= '<input type="button" class="bouton" value="' . $msg["notice_integre_indexint_use"] . '" onclick="' . $jsaction . '">';
                 $form_indexint_proposition .= '</li>';
             }
             $form_indexint_proposition .= "</ul>";
             $ptab[6] = str_replace("!!multiple_index_int_propositions!!", $form_indexint_proposition, $ptab[6]);
             z3950_notice::substitute("indexint", "", $ptab[6]);
             z3950_notice::substitute("indexint_id", "", $ptab[6]);
             z3950_notice::substitute("indexint_type_use_existing", 'checked', $ptab[6]);
             z3950_notice::substitute("indexint_type_insert_new", '', $ptab[6]);
         } else {
             z3950_notice::substitute("indexint", "", $ptab[6]);
             z3950_notice::substitute("indexint_id", "", $ptab[6]);
             z3950_notice::substitute("indexint_type_use_existing", '', $ptab[6]);
             z3950_notice::substitute("indexint_type_insert_new", 'checked', $ptab[6]);
             z3950_notice::substitute("multiple_index_int_propositions", '', $ptab[6]);
         }
     }
     z3950_notice::substitute("indexint_new_name", $this->dewey[0], $ptab[6]);
     z3950_notice::substitute("indexint_new_comment", "", $ptab[6]);
     // indexation libre
     z3950_notice::substitute("f_free_index", $this->free_index, $ptab[6]);
     global $pmb_keyword_sep;
     $sep = "'{$pmb_keyword_sep}'";
     if (!$pmb_keyword_sep) {
         $sep = "' '";
     }
     if (ord($pmb_keyword_sep) == 0xa || ord($pmb_keyword_sep) == 0xd) {
         $sep = $msg['catalogue_saut_de_ligne'];
     }
     $ptab[6] = str_replace("!!sep!!", htmlentities($sep, ENT_QUOTES, $charset), $ptab[6]);
     $form_notice = str_replace('!!tab6!!', $ptab[6], $form_notice);
     // Gestion des titres uniformes
     $nb_tu = sizeof($this->tu_500);
     for ($i = 0; $i < $nb_tu; $i++) {
         $value_tu[$i]['name'] = $this->tu_500[$i]['a'];
         $ntu_data[$i]->tu->name = $this->tu_500[$i]['a'];
         $value_tu[$i]['tonalite'] = $this->tu_500[$i]['u'];
         for ($j = 0; $j < count($this->tu_500_r[$i]); $j++) {
             $value_tu[$i]['distrib'][$j] = $this->tu_500_r[$i][$j];
         }
         for ($j = 0; $j < count($this->tu_500_s[$i]); $j++) {
             $value_tu[$i]['ref'][$j] = $this->tu_500_s[$i][$j];
         }
         if ($tu_id = titre_uniforme::import_tu_exist($value_tu, 1)) {
             // 	le titre uniforme est déjà existant
             $ntu_data[$i]->num_tu = $tu_id;
         } else {
             // le titre uniforme n'est pas existant
             for ($j = 0; $j < count($this->tu_500_n[$i]); $j++) {
                 $value_tu[$i]['comment'] .= $this->tu_500_r[$i][$j];
                 if ($j + 1 < count($this->tu_500_n[$i])) {
                     $value_tu[$i]['comment'] .= "\n";
                 }
             }
             for ($j = 0; $j < count($this->tu_500_j[$i]); $j++) {
                 $value_tu[$i]['subdiv'][$j] = $this->tu_500_j[$i][$j];
             }
         }
         // memorisation du niveau biblio de ce titre uniforme
         for ($j = 0; $j < count($this->tu_500_i[$i]); $j++) {
             $ntu_data[$i]->titre .= $this->tu_500_i[$i][$j];
             if ($j + 1 < count($this->tu_500_i[$i])) {
                 $ntu_data[$i]->titre .= "; ";
             }
         }
         $ntu_data[$i]->date = $this->tu_500[$i]['k'];
         for ($j = 0; $j < count($this->tu_500_l[$i]); $j++) {
             $ntu_data[$i]->sous_vedette .= $this->tu_500_l[$i][$j];
             if ($j + 1 < count($this->tu_500_l[$i])) {
                 $ntu_data[$i]->sous_vedette .= "; ";
             }
         }
         $ntu_data[$i]->langue = $this->tu_500[$i]['m'];
         $ntu_data[$i]->version = $this->tu_500[$i]['q'];
         $ntu_data[$i]->mention = $this->tu_500[$i]['w'];
     }
     // serialisation des champs de l'autorité titre uniforme
     global $pmb_use_uniform_title;
     if ($pmb_use_uniform_title) {
         $memo_value_tu = "<input type='hidden' name='memo_value_tu' value=\"" . rawurlencode(serialize($value_tu)) . "\">";
         $ptab[230] = str_replace("!!titres_uniformes!!", $memo_value_tu . tu_notice::get_form_import("notice", $ntu_data), $ptab[230]);
         $form_notice = str_replace('!!tab230!!', $ptab[230], $form_notice);
     }
     // mise à jour de l'onglet 7 : langues
     // langues répétables
     $lang = new marc_list('lang');
     if (sizeof($this->language_code) == 0) {
         $max_lang = 1;
     } else {
         $max_lang = sizeof($this->language_code);
     }
     for ($i = 0; $i < $max_lang; $i++) {
         if ($i) {
             $ptab_lang = str_replace('!!ilang!!', $i, $ptab[701]);
         } else {
             $ptab_lang = str_replace('!!ilang!!', $i, $ptab[70]);
         }
         if (sizeof($this->language_code) == 0) {
             $ptab_lang = str_replace('!!lang_code!!', '', $ptab_lang);
             $ptab_lang = str_replace('!!lang!!', '', $ptab_lang);
         } else {
             $ptab_lang = str_replace('!!lang_code!!', $this->language_code[$i], $ptab_lang);
             $ptab_lang = str_replace('!!lang!!', htmlentities($lang->table[$this->language_code[$i]], ENT_QUOTES, $charset), $ptab_lang);
         }
         $lang_repetables .= $ptab_lang;
     }
     $ptab[7] = str_replace('!!max_lang!!', $max_lang, $ptab[7]);
     $ptab[7] = str_replace('!!langues_repetables!!', $lang_repetables, $ptab[7]);
     // langues originales répétables
     if (sizeof($this->original_language_code) == 0) {
         $max_langorg = 1;
     } else {
         $max_langorg = sizeof($this->original_language_code);
     }
     for ($i = 0; $i < $max_langorg; $i++) {
         if ($i) {
             $ptab_lang = str_replace('!!ilangorg!!', $i, $ptab[711]);
         } else {
             $ptab_lang = str_replace('!!ilangorg!!', $i, $ptab[71]);
         }
         if (sizeof($this->original_language_code) == 0) {
             $ptab_lang = str_replace('!!langorg_code!!', '', $ptab_lang);
             $ptab_lang = str_replace('!!langorg!!', '', $ptab_lang);
         } else {
             $ptab_lang = str_replace('!!langorg_code!!', $this->original_language_code[$i], $ptab_lang);
             $ptab_lang = str_replace('!!langorg!!', htmlentities($lang->table[$this->original_language_code[$i]], ENT_QUOTES, $charset), $ptab_lang);
         }
         $langorg_repetables .= $ptab_lang;
     }
     $ptab[7] = str_replace('!!max_langorg!!', $max_langorg, $ptab[7]);
     $ptab[7] = str_replace('!!languesorg_repetables!!', $langorg_repetables, $ptab[7]);
     $form_notice = str_replace('!!tab7!!', $ptab[7], $form_notice);
     z3950_notice::substitute("link_url", $this->link_url, $ptab[8]);
     z3950_notice::substitute("link_format", $this->link_format, $ptab[8]);
     $form_notice = str_replace('!!tab8!!', $ptab[8], $form_notice);
     // définition de la page cible du form
     $form_notice = str_replace('!!action!!', $this->action, $form_notice);
     // ajout des selecteurs
     $select_doc = new marc_select('doctype', 'typdoc', $this->document_type);
     $form_notice = str_replace('!!document_type!!', $select_doc->display, $form_notice);
     if ($article) {
         $form_notice = str_replace('!!checked_mono!!', "", $form_notice);
         $form_notice = str_replace('!!checked_perio!!', "", $form_notice);
         $form_notice = str_replace('!!checked_art!!', "selected=\"selected\"", $form_notice);
     } else {
         if ($this->bibliographic_level == 's') {
             $form_notice = str_replace('!!checked_mono!!', "", $form_notice);
             $form_notice = str_replace('!!checked_perio!!', "selected=\"selected\"", $form_notice);
             $form_notice = str_replace('!!checked_art!!', "", $form_notice);
         } else {
             $form_notice = str_replace('!!checked_mono!!', "selected=\"selected\"", $form_notice);
             $form_notice = str_replace('!!checked_perio!!', "", $form_notice);
             $form_notice = str_replace('!!checked_art!!', "", $form_notice);
         }
     }
     //Zone des perios et des bulletins pour les articles
     $zone_article_form = str_replace("!!perio_titre!!", $this->perio_titre[0], $zone_article_form);
     $zone_article_form = str_replace("!!perio_issn!!", $this->perio_issn[0], $zone_article_form);
     $zone_article_form = str_replace("!!bull_date!!", $this->bull_mention[0], $zone_article_form);
     $zone_article_form = str_replace("!!bull_titre!!", $this->bull_titre[0], $zone_article_form);
     $zone_article_form = str_replace("!!bull_num!!", $this->bull_num[0], $zone_article_form);
     if ($this->bull_date[0]) {
         $date_date_formatee = formatdate_input($this->bull_date[0]);
         $date_date_hid = $this->bull_date[0];
     } else {
         $date_date_formatee = '';
         $date_date_hid = '';
     }
     $date_clic = "onClick=\"openPopUp('./select.php?what=calendrier&caller=notice&date_caller=&param1=f_bull_new_date&param2=date_date_lib&auto_submit=NO&date_anterieure=YES', 'date_date', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\"  ";
     $date_date = "<input type='hidden' id='f_bull_new_date' name='f_bull_new_date' value='{$date_date_hid}' />\n\t\t\t<input class='saisie-10em' type='text' name='date_date_lib' value='" . $date_date_formatee . "' placeholder='" . $msg["format_date_input_placeholder"] . "' />\n\t\t\t<input class='bouton' type='button' name='date_date_lib_bouton' value='" . $msg["bouton_calendrier"] . "' " . $date_clic . " />";
     $zone_article_form = str_replace("!!date_date!!", $date_date, $zone_article_form);
     //On cherche si le perio existe
     if ($this->perio_titre[0] && $this->perio_issn[0]) {
         $req = "select notice_id, tit1 from notices where niveau_biblio='s' and niveau_hierar='1' \n\t\t\t\t\tand tit1='" . addslashes($this->perio_titre[0]) . "'\n\t\t\t\t\tand code='" . addslashes($this->perio_issn[0]) . "' limit 1";
         $res_perio = pmb_mysql_query($req, $dbh);
         $num_rows_perio = pmb_mysql_num_rows($res_perio);
     }
     if (!$num_rows_perio) {
         if ($this->perio_titre[0]) {
             $req = "select notice_id, tit1 from notices where niveau_biblio='s' and niveau_hierar='1' \n\t\t\t\t\tand tit1='" . addslashes($this->perio_titre[0]) . "'\n\t\t\t\t\tlimit 1";
             $res_perio = pmb_mysql_query($req, $dbh);
             $num_rows_perio = pmb_mysql_num_rows($res_perio);
         }
     }
     if (!$num_rows_perio) {
         if ($this->perio_issn[0]) {
             $req = "select notice_id, tit1 from notices where niveau_biblio='s' and niveau_hierar='1' \n\t\t\t\t\t\tand code='" . addslashes($this->perio_issn[0]) . "' limit 1";
             $res_perio = pmb_mysql_query($req, $dbh);
             $num_rows_perio = pmb_mysql_num_rows($res_perio);
         }
     }
     if ($num_rows_perio == 1) {
         $perio_found = pmb_mysql_fetch_object($res_perio);
         $idperio = $perio_found->notice_id;
         $zone_article_form = str_replace("!!f_perio_existing!!", htmlentities($perio_found->tit1, ENT_QUOTES, $charset), $zone_article_form);
         $zone_article_form = str_replace("!!f_perio_existing_id!!", $perio_found->notice_id, $zone_article_form);
         $zone_article_form = str_replace("!!perio_type_new!!", "", $zone_article_form);
         $zone_article_form = str_replace("!!perio_type_use_existing!!", "checked", $zone_article_form);
     } else {
         $idperio = 0;
         $zone_article_form = str_replace("!!f_perio_existing!!", "", $zone_article_form);
         $zone_article_form = str_replace("!!f_perio_existing_id!!", "", $zone_article_form);
         $zone_article_form = str_replace("!!perio_type_new!!", "checked", $zone_article_form);
         $zone_article_form = str_replace("!!perio_type_use_existing!!", "", $zone_article_form);
     }
     //On cherche si le bulletin existe
     $num_rows_bull = 0;
     if ($this->bull_num[0] && $idperio) {
         $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and  bulletin_numero like '%" . addslashes($this->bull_num[0]) . "%' ";
         $res_bull = pmb_mysql_query($req, $dbh);
         $num_rows_bull = pmb_mysql_num_rows($res_bull);
     }
     if (!$num_rows_bull && $this->bull_date[0] && $idperio) {
         $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and date_date='" . addslashes($this->bull_date[0]) . "' ";
         $res_bull = pmb_mysql_query($req, $dbh);
         $num_rows_bull = pmb_mysql_num_rows($res_bull);
     } elseif ($num_rows_bull > 1 && $this->bull_date[0] && $idperio) {
         $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and date_date='" . addslashes($this->bull_date[0]) . "' and  bulletin_numero like '%" . addslashes($this->bull_num[0]) . "%' ";
         $res_bull = pmb_mysql_query($req, $dbh);
         $num_rows_bull = pmb_mysql_num_rows($res_bull);
     }
     if (!$num_rows_bull && $this->bull_mention[0] && $idperio) {
         $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and mention_date='" . addslashes($this->bull_mention[0]) . "' ";
         $res_bull = pmb_mysql_query($req, $dbh);
         $num_rows_bull = pmb_mysql_num_rows($res_bull);
     } elseif ($num_rows_bull > 1 && $this->bull_mention[0] && $idperio) {
         if ($this->bull_date[0]) {
             $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and date_date='" . addslashes($this->bull_date[0]) . "' and mention_date='" . addslashes($this->bull_mention[0]) . "' ";
         } else {
             $req = "select bulletin_id, bulletin_numero,date_date,mention_date from bulletins where bulletin_notice='" . $idperio . "' and mention_date='" . addslashes($this->bull_mention[0]) . "' and  bulletin_numero like '%" . addslashes($this->bull_num[0]) . "%' ";
         }
         $res_bull = pmb_mysql_query($req, $dbh);
         $num_rows_bull = pmb_mysql_num_rows($res_bull);
     }
     if ($num_rows_bull) {
         $bull_found = pmb_mysql_fetch_object($res_bull);
         $f_bull_existing = trim($bull_found->bulletin_numero);
         if (!$f_bull_existing && trim($bull_found->date_date)) {
             $f_bull_existing = "[" . trim($bull_found->date_date) . "]";
         } elseif (!$f_bull_existing && trim($bull_found->mention_date)) {
             $f_bull_existing = "(" . trim($bull_found->mention_date) . ")";
         }
         $zone_article_form = str_replace("!!f_bull_existing!!", htmlentities($f_bull_existing, ENT_QUOTES, $charset), $zone_article_form);
         $zone_article_form = str_replace("!!f_bull_existing_id!!", $bull_found->bulletin_id, $zone_article_form);
         $zone_article_form = str_replace("!!bull_type_new!!", $num_rows_bull ? '' : "checked='checked'", $zone_article_form);
         $zone_article_form = str_replace("!!bull_type_use_existing!!", $num_rows_bull ? "checked='checked'" : '', $zone_article_form);
     } else {
         $zone_article_form = str_replace("!!f_bull_existing!!", "", $zone_article_form);
         $zone_article_form = str_replace("!!f_bull_existing_id!!", "", $zone_article_form);
         $zone_article_form = str_replace("!!bull_type_new!!", "checked='checked'", $zone_article_form);
         $zone_article_form = str_replace("!!bull_type_use_existing!!", "", $zone_article_form);
     }
     $form_notice = str_replace("!!zone_article!!", $zone_article_form, $form_notice);
     if ($article) {
         $form_notice = str_replace("!!display_zone_article!!", "", $form_notice);
     } else {
         $form_notice = str_replace("!!display_zone_article!!", "none", $form_notice);
     }
     if ($item) {
         $form_notice = str_replace('!!notice_entrepot!!', "<input type='hidden' name='item' value='{$item}' />", $form_notice);
     } else {
         $form_notice = str_replace('!!notice_entrepot!!', "", $form_notice);
     }
     $form_notice = str_replace('!!orinot_nom!!', $this->origine_notice[nom], $form_notice);
     $form_notice = str_replace('!!orinot_pays!!', $this->origine_notice[pays], $form_notice);
     //Traitement du 503 "titre de forme" pour le Musée des beaux arts de Nantes
     global $tableau_503;
     $tableau_503 = array("info_503" => $this->info_503, "info_503_d" => $this->info_503_d, "info_503_j" => $this->info_503_j);
     // traitement des catégories : affichage dans le formulaire
     $tableau_600 = array("info_600_3" => $this->info_600_3, "info_600_a" => $this->info_600_a, "info_600_b" => $this->info_600_b, "info_600_c" => $this->info_600_c, "info_600_d" => $this->info_600_d, "info_600_f" => $this->info_600_f, "info_600_g" => $this->info_600_g, "info_600_j" => $this->info_600_j, "info_600_p" => $this->info_600_p, "info_600_t" => $this->info_600_t, "info_600_x" => $this->info_600_x, "info_600_y" => $this->info_600_y, "info_600_z" => $this->info_600_z);
     $tableau_601 = array("info_601_3" => $this->info_601_3, "info_601_a" => $this->info_601_a, "info_601_b" => $this->info_601_b, "info_601_c" => $this->info_601_c, "info_601_d" => $this->info_601_d, "info_601_e" => $this->info_601_e, "info_601_f" => $this->info_601_f, "info_601_g" => $this->info_601_g, "info_601_h" => $this->info_601_h, "info_601_j" => $this->info_601_j, "info_601_t" => $this->info_601_t, "info_601_x" => $this->info_601_x, "info_601_y" => $this->info_601_y, "info_601_z" => $this->info_601_z);
     $tableau_602 = array("info_602_3" => $this->info_602_3, "info_602_a" => $this->info_602_a, "info_602_f" => $this->info_602_f, "info_602_j" => $this->info_602_j, "info_602_t" => $this->info_602_t, "info_602_x" => $this->info_602_x, "info_602_y" => $this->info_602_y, "info_602_z" => $this->info_602_z);
     $tableau_604 = array("info_604_3" => $this->info_604_3, "info_604_a" => $this->info_604_a, "info_604_h" => $this->info_604_h, "info_604_i" => $this->info_604_i, "info_604_j" => $this->info_604_j, "info_604_k" => $this->info_604_k, "info_604_l" => $this->info_604_l, "info_604_x" => $this->info_604_x, "info_604_y" => $this->info_604_y, "info_604_z" => $this->info_604_z);
     $tableau_605 = array("info_605_3" => $this->info_605_3, "info_605_a" => $this->info_605_a, "info_605_h" => $this->info_605_h, "info_605_i" => $this->info_605_i, "info_605_k" => $this->info_605_k, "info_605_l" => $this->info_605_l, "info_605_m" => $this->info_605_m, "info_605_n" => $this->info_605_n, "info_605_q" => $this->info_605_q, "info_605_r" => $this->info_605_r, "info_605_s" => $this->info_605_s, "info_605_u" => $this->info_605_u, "info_605_w" => $this->info_605_w, "info_605_j" => $this->info_605_j, "info_605_x" => $this->info_605_x, "info_605_y" => $this->info_605_y, "info_605_z" => $this->info_605_z);
     $tableau_606 = array("info_606_3" => $this->info_606_3, "info_606_a" => $this->info_606_a, "info_606_j" => $this->info_606_j, "info_606_x" => $this->info_606_x, "info_606_y" => $this->info_606_y, "info_606_z" => $this->info_606_z);
     $tableau_607 = array("info_607_3" => $this->info_607_3, "info_607_a" => $this->info_607_a, "info_607_j" => $this->info_607_j, "info_607_x" => $this->info_607_x, "info_607_y" => $this->info_607_y, "info_607_z" => $this->info_607_z);
     $tableau_608 = array("info_608_3" => $this->info_608_3, "info_608_a" => $this->info_608_a, "info_608_j" => $this->info_608_j, "info_608_x" => $this->info_608_x, "info_608_y" => $this->info_608_y, "info_608_z" => $this->info_608_z);
     // catégories
     $max_categ = 1;
     $ptab_categ = str_replace('!!icateg!!', 0, $ptab[60]);
     $ptab_categ = str_replace('!!categ_id!!', 0, $ptab_categ);
     $ptab_categ = str_replace('!!categ_libelle!!', '', $ptab_categ);
     $ptab[6] = str_replace("!!categories_repetables!!", $ptab_categ, $ptab[6]);
     $ptab[6] = str_replace('!!tab_categ_order!!', "", $ptab[6]);
     $traitement_rameau = traite_categories_for_form($tableau_600, $tableau_601, $tableau_602, $tableau_605, $tableau_606, $tableau_607, $tableau_608);
     if (!is_array($traitement_rameau)) {
         $traitement_rameau = array("form" => $traitement_rameau, "message" => "");
     }
     $form_notice = str_replace('!!message_rameau!!', $traitement_rameau["message"], $form_notice);
     $form_notice = str_replace('!!traitement_rameau!!', $traitement_rameau["form"], $form_notice);
     $manual_categorisation_form = get_manual_categorisation_form($tableau_600, $tableau_601, $tableau_602, $tableau_604, $tableau_605, $tableau_606, $tableau_607, $tableau_608);
     $form_notice = str_replace('!!manual_categorisation!!', $manual_categorisation_form, $form_notice);
     //Mise à jour de l'onglet 9
     $p_perso = new parametres_perso("notices");
     if (function_exists("param_perso_form")) {
         param_perso_form($p_perso);
     }
     //pour Pubmed et DOI, on regarde si on peut remplir un champ résolveur...
     if (count($this->others_ids) > 0) {
         foreach ($p_perso->t_fields as $key => $t_field) {
             if ($t_field['TYPE'] == "resolve") {
                 $field_options = _parser_text_no_function_("<?xml version='1.0' encoding='" . $charset . "'?>\n" . $t_field['OPTIONS'], "OPTIONS");
                 foreach ($field_options['RESOLVE'] as $resolve) {
                     //pubmed = 1 | DOI = 2
                     foreach ($this->others_ids as $other_id) {
                         if ($other_id['b'] == "PMID" && $resolve['ID'] == "1") {
                             //on a le champ perso résolveur PubMed
                             $p_perso->values[$key][] = $other_id['a'] . "|1";
                         } else {
                             if ($other_id['b'] == "DOI" && $resolve['ID'] == "2") {
                                 //on a le champ perso résolveur DOI
                                 $p_perso->values[$key][] = $other_id['a'] . "|2";
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$p_perso->no_special_fields) {
         $perso_ = $p_perso->show_editable_fields($id_notice, true);
         $perso = "";
         for ($i = 0; $i < count($perso_["FIELDS"]); $i++) {
             $p = $perso_["FIELDS"][$i];
             $perso .= "<div class='row'>\n\t\t\t\t\t<label for='" . $p["NAME"] . "' class='etiquette'>" . $p["TITRE"] . " </label>" . $p["COMMENT_DISPLAY"] . "\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='row'>\n\t\t\t\t\t" . $p["AFF"] . "\n\t\t\t\t\t</div>\n\t\t\t\t\t";
         }
         $perso .= $perso_["CHECK_SCRIPTS"];
         $ptab[9] = str_replace("!!champs_perso!!", $perso, $ptab[9]);
     } else {
         $ptab[9] = "\n<script type='text/javascript' >function check_form() { return true; }</script>\n";
     }
     $form_notice = str_replace('!!tab9!!', $ptab[9], $form_notice);
     // champs de gestion
     global $pmb_notice_img_folder_id;
     $message_folder = "";
     if ($pmb_notice_img_folder_id) {
         $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'";
         $res = pmb_mysql_query($req);
         if (pmb_mysql_num_rows($res)) {
             $rep = pmb_mysql_fetch_object($res);
             if (!is_dir($rep->repertoire_path)) {
                 $notice_img_folder_error = 1;
             }
         } else {
             $notice_img_folder_error = 1;
         }
         if ($notice_img_folder_error) {
             if (SESSrights & ADMINISTRATION_AUTH) {
                 $requete = "select * from parametres where gestion=0 and type_param='pmb' and sstype_param='notice_img_folder_id' ";
                 $res = pmb_mysql_query($requete);
                 $i = 0;
                 if ($param = pmb_mysql_fetch_object($res)) {
                     $message_folder = " <a class='erreur' href='./admin.php?categ=param&action=modif&id_param=" . $param->id_param . "' >" . $msg['notice_img_folder_admin_no_access'] . "</a> ";
                 }
             } else {
                 $message_folder = $msg['notice_img_folder_no_access'];
             }
         }
     }
     $ptab[10] = str_replace('!!message_folder!!', $message_folder, $ptab[10]);
     // langue de la notice
     global $lang, $xmlta_indexation_lang;
     $user_lang = $this->indexation_lang;
     if (!$user_lang) {
         $user_lang = $xmlta_indexation_lang;
     }
     //	if(!$user_lang) $user_lang="fr_FR";
     $langues = new XMLlist("{$include_path}/messages/languages.xml");
     $langues->analyser();
     $clang = $langues->table;
     $combo = "<select name='indexation_lang' id='indexation_lang' class='saisie-20em' >";
     if (!$user_lang) {
         $combo .= "<option value='' selected>--</option>";
     } else {
         $combo .= "<option value='' >--</option>";
     }
     while (list($cle, $value) = each($clang)) {
         // arabe seulement si on est en utf-8
         if ($charset != 'utf-8' and $user_lang != 'ar' or $charset == 'utf-8') {
             if (strcmp($cle, $user_lang) != 0) {
                 $combo .= "<option value='{$cle}'>{$value} ({$cle})</option>";
             } else {
                 $combo .= "<option value='{$cle}' selected>{$value} ({$cle})</option>";
             }
         }
     }
     $combo .= "</select>";
     $ptab[10] = str_replace('!!indexation_lang!!', $combo, $ptab[10]);
     $form_notice = str_replace('!!indexation_lang_sel!!', $user_lang, $form_notice);
     global $deflt_integration_notice_statut;
     if ($id_notice) {
         $rqt_statut = "select statut from notices where notice_id='{$id_notice}' ";
         $res_statut = pmb_mysql_query($rqt_statut);
         $stat = pmb_mysql_fetch_object($res_statut);
         $select_statut = gen_liste_multiple("select id_notice_statut, gestion_libelle from notice_statut order by 2", "id_notice_statut", "gestion_libelle", "id_notice_statut", "form_notice_statut", "", $stat->statut, "", "", "", "", 0);
     } else {
         $select_statut = gen_liste_multiple("select id_notice_statut, gestion_libelle from notice_statut order by 2", "id_notice_statut", "gestion_libelle", "id_notice_statut", "form_notice_statut", "", $deflt_integration_notice_statut, "", "", "", "", 0);
     }
     $ptab[10] = str_replace('!!notice_statut!!', $select_statut, $ptab[10]);
     $ptab[10] = str_replace('!!commentaire_gestion!!', htmlentities($this->commentaire_gestion, ENT_QUOTES, $charset), $ptab[10]);
     $ptab[10] = str_replace('!!thumbnail_url!!', htmlentities($this->thumbnail_url, ENT_QUOTES, $charset), $ptab[10]);
     $form_notice = str_replace('!!tab10!!', $ptab[10], $form_notice);
     // Documents Numériques
     $docnum_infos = "";
     $count = 0;
     $upload_doc_num = "";
     if ($this->source_id) {
         $requete = "select * from connectors_sources where source_id=" . $this->source_id . "";
         $resultat = pmb_mysql_query($requete);
         if (pmb_mysql_num_rows($resultat)) {
             $r = pmb_mysql_fetch_object($resultat);
             if (!$r->upload_doc_num) {
                 $upload_doc_num = "checked";
             }
         }
     }
     if (count($this->doc_nums)) {
         global $deflt_explnum_statut;
         $statutlist = gen_liste_multiple("select id_explnum_statut, gestion_libelle from explnum_statut order by 2", "id_explnum_statut", "gestion_libelle", "id_explnum_statut", "doc_num_statut!!docnumid!!", "", $deflt_explnum_statut, "", "", "", "", 0);
         foreach ($this->doc_nums as $doc_num) {
             $docnum_info = $ptab[1111];
             // 				$alink = '<a target="_blank" href="'.htmlspecialchars($doc_num["a"]).'">'.htmlspecialchars($doc_num["a"]).'</a>';
             $docnum_info = str_replace('!!docnum_url!!', htmlspecialchars($doc_num["a"], ENT_QUOTES, $charset), $docnum_info);
             $docnum_info = str_replace('!!docnum_caption!!', htmlspecialchars($doc_num["b"], ENT_QUOTES, $charset), $docnum_info);
             $docnum_info = str_replace('!!docnum_filename!!', htmlspecialchars($doc_num["f"], ENT_QUOTES, $charset), $docnum_info);
             $docnum_info = str_replace('!!docnum_statutlist!!', $statutlist, $docnum_info);
             $docnum_info = str_replace('!!docnumid!!', $count, $docnum_info);
             $docnum_info = str_replace('!!upload_doc_num!!', $upload_doc_num, $docnum_info);
             $docnum_infos .= $docnum_info;
             $count++;
         }
     }
     if (!$docnum_infos) {
         $docnum_infos = $msg["noticeintegre_nodocnum"];
     }
     $ptab[1110] = str_replace('!!docnum_count!!', $count, $ptab[1110]);
     $ptab[1110] = str_replace('!!docnums!!', $docnum_infos, $ptab[1110]);
     $form_notice = str_replace('!!tab11!!', $ptab[1110], $form_notice);
     $aac = explode('&', $action);
     $retact = '&' . $aac[2] . '&' . $aac[5] . '&' . $aac[6];
     global $force;
     $retares = '';
     switch ($retour) {
         case 'button':
             if ($this->message_retour) {
                 $retares = "<input type='button' class='bouton' onclick='history.go(-1);' value='" . $this->message_retour . "' />";
             } else {
                 if ($force == 1) {
                     $retares = "<a href='javascript:history.go(-2);'>" . $msg['z3950_retour_a_resultats'] . "</a>";
                 } else {
                     $retares = "<a href='javascript:history.go(-1);'>" . $msg['z3950_retour_a_resultats'] . "</a>";
                 }
             }
             break;
         case 'link':
             $retares = "<a href='./catalog.php?categ=z3950&action=display" . $retact . "'>" . $msg['z3950_retour_a_resultats'] . "</a>";
             break;
         default:
             break;
     }
     $form_notice = str_replace('!!retour_a_resultats!!', $retares, $form_notice);
     if (!$this->bt_integr_value) {
         if (!$id_notice) {
             $form_notice = str_replace('!!bouton_integration!!', $msg['z3950_integr_not_seule'], $form_notice);
         } else {
             $form_notice = str_replace('!!bouton_integration!!', $msg['notice_z3950_remplace_catal'], $form_notice);
         }
     } else {
         $form_notice = str_replace('!!bouton_integration!!', $this->bt_integr_value, $form_notice);
     }
     if ($this->bt_undo_value && $this->bt_undo_action) {
         $bt_undo = str_replace('!!value!!', $this->bt_undo_value, $bt_undo);
         $bt_undo = str_replace('!!action!!', $this->bt_undo_action, $bt_undo);
         $form_notice = str_replace('<!-- bt_undo -->', $bt_undo, $form_notice);
     }
     $form_notice = str_replace('!!id_notice!!', $id_notice, $form_notice);
     $form_notice = str_replace('!!notice!!', $znotices_id, $form_notice);
     $form_notice = str_replace('!!notice_type!!', $this->notice_type, $form_notice);
     return $form_notice;
 }