function update_notice_categories_from_form($id_notice = 0, $id_bulletin = 0)
{
    global $dbh;
    global $f_nb_categ;
    if (!$id_notice && $id_bulletin) {
        $query = "select * from bulletins where bulletin_id=" . $id_bulletin;
        $result = pmb_mysql_query($query, $dbh);
        if ($result) {
            $row = mysql_fetch_object($result);
            if ($row->num_notice) {
                $id_notice = $row->num_notice;
            } else {
                //on crée la notice de bulletin
                global $xmlta_doctype_bulletin, $deflt_notice_statut;
                pmb_mysql_query("INSERT INTO notices SET \n\t\t\t\t\ttit1 = '" . $row->bulletin_numero . ($row->mention_date ? " - " . $row->mention_date : "") . ($row->bulletin_titre ? " - " . $row->bulletin_titre : "") . "',\n\t\t\t\t\tstatut = '" . $deflt_notice_statut . "',\t\t\n\t\t\t\t\ttypdoc = '" . $xmlta_doctype_bulletin . "',\n\t\t\t\t\tcreate_date=sysdate(), update_date=sysdate() ", $dbh);
                $id_notice = pmb_mysql_insert_id($dbh);
                // Mise à jour des index de la notice
                notice::majNoticesTotal($id_notice);
                audit::insert_creation(AUDIT_NOTICE, $id_notice);
                //Mise à jour du bulletin
                $requete = "update bulletins set num_notice=" . $id_notice . " where bulletin_id=" . $id_bulletin;
                pmb_mysql_query($requete);
                //Mise à jour des liens bulletin -> notice mère
                $requete = "insert into notices_relations (num_notice,linked_notice,relation_type,rank) values(" . $id_notice . "," . $row->bulletin_notice . ",'b',1)";
                pmb_mysql_query($requete);
            }
        }
    }
    if (!$id_notice) {
        return;
    }
    $query = "SELECT max(ordre_categorie) as ordre FROM notices_categories WHERE notcateg_notice='" . $id_notice . "' ";
    $result = pmb_mysql_query($query);
    $ordre_categ = 0;
    if ($result) {
        $row = mysql_fetch_object($result);
        if (isset($row->ordre)) {
            $ordre_categ = $row->ordre;
        }
    }
    if ($f_nb_categ) {
        $rqt_ins = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ";
        for ($i = 0; $i < $f_nb_categ; $i++) {
            $var_categ = "f_categ{$i}";
            global ${$var_categ};
            if (${$var_categ}) {
                $var_categid = "f_categ_id{$i}";
                global ${$var_categid};
                $rqt_sel = "SELECT notcateg_notice FROM notices_categories WHERE notcateg_notice='" . $id_notice . "' and num_noeud='" . ${$var_categid} . "' ";
                $res_sel = pmb_mysql_query($rqt_sel, $dbh);
                if ($res_sel && !pmb_mysql_num_rows($res_sel)) {
                    $ordre_categ++;
                    $rqt = $rqt_ins . " ('" . $id_notice . "','" . ${$var_categid} . "',{$ordre_categ}) ";
                    $res_ins = @pmb_mysql_query($rqt, $dbh);
                }
            }
        }
    }
}
Example #2
0
 function save()
 {
     global $dbh;
     if (!$this->num_thesaurus) {
         die('Erreur de création noeud');
     }
     if ($this->id_noeud) {
         //Mise à jour noeud
         $q = 'update noeuds set autorite =\'' . addslashes($this->autorite) . '\', ';
         $q .= 'num_parent = \'' . $this->num_parent . '\', num_renvoi_voir = \'' . $this->num_renvoi_voir . '\', ';
         $q .= 'visible = \'' . $this->visible . '\', num_thesaurus = \'' . $this->num_thesaurus . '\', ';
         $q .= 'authority_import_denied = \'' . $this->authority_import_denied . '\', not_use_in_indexation = \'' . $this->not_use_in_indexation . '\' ';
         $q .= 'where id_noeud = \'' . $this->id_noeud . '\' ';
         mysql_query($q, $dbh);
         audit::insert_modif(AUDIT_CATEG, $this->id_noeud);
     } else {
         $q = 'insert into noeuds set autorite = \'' . addslashes($this->autorite) . '\', ';
         $q .= 'num_parent = \'' . $this->num_parent . '\', num_renvoi_voir = \'' . $this->num_renvoi_voir . '\', ';
         $q .= 'visible = \'' . $this->visible . '\', num_thesaurus = \'' . $this->num_thesaurus . '\', ';
         $q .= 'authority_import_denied = \'' . $this->authority_import_denied . '\', not_use_in_indexation = \'' . $this->not_use_in_indexation . '\' ';
         mysql_query($q, $dbh);
         $this->id_noeud = mysql_insert_id($dbh);
         audit::insert_creation(AUDIT_CATEG, $this->id_noeud);
     }
     // Mis à jour du path de lui-meme, et de tous les fils
     $thes = thesaurus::getByEltId($this->id_noeud);
     $id_top = $thes->num_noeud_racine;
     $path = '';
     $id_tmp = $this->id_noeud;
     while (true) {
         $q = "select num_parent from noeuds where id_noeud = '" . $id_tmp . "' limit 1";
         $r = mysql_query($q, $dbh);
         $id_tmp = $id_cur = mysql_result($r, 0, 0);
         if (!$id_cur || $id_cur == $id_top) {
             break;
         }
         if ($path) {
             $path = '/' . $path;
         }
         $path = $id_tmp . $path;
     }
     $this->process_categ_path($this->id_noeud, $path);
 }
Example #3
0
 function import($title)
 {
     global $dbh;
     // check sur la variable passée en paramètre
     if (!$title) {
         return 0;
     }
     // tentative de récupérer l'id associée dans la base (implique que l'autorité existe)
     // préparation de la requête
     $key = addslashes($title);
     $query = "SELECT serie_id FROM series WHERE serie_name='" . rtrim(substr($key, 0, 255)) . "' LIMIT 1 ";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT series " . $query);
     }
     // résultat
     // récupération du résultat de la recherche
     $tserie = mysql_fetch_object($result);
     // du résultat et récupération éventuelle de l'id
     if ($tserie->serie_id) {
         return $tserie->serie_id;
     }
     // id non-récupérée, il faut créer la forme.
     $index = addslashes(strip_empty_words($title));
     $query = "INSERT INTO series SET serie_name='{$key}', serie_index=' {$index} '";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into series" . $query);
     }
     $id = mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_SERIE, $id);
     return $id;
 }
Example #4
0
function create_expl($f_ex_cb, $id, $f_ex_typdoc, $f_ex_cote, $f_ex_section, $f_ex_statut, $f_ex_location, $f_ex_cstat, $f_ex_note, $f_ex_prix, $f_ex_owner, $f_ex_comment = '')
{
    global $dbh;
    $new_expl = 0;
    $expl_retour = 0;
    $requete = "SELECT expl_id FROM exemplaires WHERE expl_cb='{$f_ex_cb}' ";
    $res = pmb_mysql_query($requete, $dbh);
    $nbr_lignes = @pmb_mysql_num_rows($res);
    if ($nbr_lignes) {
        $valid_requete = 0;
        $lu = pmb_mysql_fetch_array($res);
        $expl_retour = $lu['expl_id'];
    } else {
        $valid_requete = 1;
    }
    if ($valid_requete) {
        $requete = 'INSERT INTO exemplaires SET create_date=sysdate(), ';
        $requete .= "expl_cb='{$f_ex_cb}'";
        $requete .= ", expl_notice={$id}";
        $requete .= ", expl_typdoc={$f_ex_typdoc}";
        $requete .= ", expl_cote='{$f_ex_cote}'";
        $requete .= ", expl_section={$f_ex_section}";
        $requete .= ", expl_statut={$f_ex_statut}";
        $requete .= ", expl_location={$f_ex_location}";
        $requete .= ", expl_codestat={$f_ex_cstat}";
        $requete .= ", expl_note='" . ${f_ex_note} . "'";
        $requete .= ", expl_comment='" . ${f_ex_comment} . "'";
        $requete .= ", expl_prix='{$f_ex_prix}'";
        $requete .= ", expl_owner='{$f_ex_owner}'";
        $result = pmb_mysql_query($requete, $dbh);
        $expl_retour = pmb_mysql_insert_id();
        audit::insert_creation(AUDIT_EXPL, $expl_retour);
        $new_expl = 1;
    }
    $retour = array($new_expl, $expl_retour);
    return $retour;
}
 static function import($data)
 {
     // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
     //	$data['name'] 	Nom de la collection
     //	$data['parent']	id de l'éditeur parent de la collection
     //	$data['issn']	numéro ISSN de la collection
     global $dbh;
     // check sur le type de  la variable passée en paramètre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         return 0;
     }
     // check sur les éléments du tableau (data['name'] est requis).
     $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT collection_name FROM collections limit 1"), 0);
     $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
     //si on a pas d'id, on peut avoir les infos de l'éditeur
     if (!$data['parent']) {
         if ($data['publisher']) {
             //on les a, on crée l'éditeur
             $data['parent'] = editeur::import($data['publisher']);
         }
     }
     if ($data['name'] == "" || $data['parent'] == 0) {
         /* il nous faut impérativement un éditeur */
         return 0;
     }
     // préparation de la requête
     $key0 = addslashes($data['name']);
     $key1 = $data['parent'];
     $key2 = addslashes($data['issn']);
     /* vérification que l'éditeur existe bien ! */
     $query = "SELECT ed_id FROM publishers WHERE ed_id='{$key1}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT publishers " . $query);
     }
     if (pmb_mysql_num_rows($result) == 0) {
         return 0;
     }
     /* vérification que la collection existe */
     $query = "SELECT collection_id FROM collections WHERE collection_name='{$key0}' AND collection_parent='{$key1}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT collections " . $query);
     }
     $collection = pmb_mysql_fetch_object($result);
     /* la collection existe, on retourne l'ID */
     if ($collection->collection_id) {
         return $collection->collection_id;
     }
     // id non-récupérée, il faut créer la forme.
     $query = 'INSERT INTO collections SET collection_name="' . $key0 . '", ';
     $query .= 'collection_parent="' . $key1 . '", ';
     $query .= 'collection_issn="' . $key2 . '", ';
     $query .= 'index_coll=" ' . strip_empty_words($key0) . ' ' . strip_empty_words($key2) . ' ", ';
     $query .= 'collection_comment = "' . addslashes($data['comment']) . '" ';
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into database");
     }
     $id = pmb_mysql_insert_id($dbh);
     if ($data['subcollections']) {
         for ($i = 0; $i < count($data['subcollections']); $i++) {
             $subcoll = $data['subcollections'][$i];
             $subcoll['coll_parent'] = $id;
             subcollection::import($subcoll);
         }
     }
     audit::insert_creation(AUDIT_COLLECTION, $id);
     //update authority informations
     $authority = new authority(0, $id, AUT_TABLE_COLLECTIONS);
     $authority->set_num_statut($data['statut']);
     $authority->update();
     collection::update_index($id);
     return $id;
 }
Example #6
0
 function analysis_update($values, $other_fields = "")
 {
     global $dbh, $pmb_notice_img_folder_id, $opac_url_base, $pmb_notice_img_pics_max_size;
     global $pmb_map_activate, $pmb_newrecord_timeshift;
     // clean des vieilles nouveautés
     if ($pmb_newrecord_timeshift) {
         $req_old = "UPDATE notices SET notice_date_is_new ='', notice_is_new=0, update_date=update_date where notice_date_is_new !='0000-00-00 00:00:00' and (notice_date_is_new < now() - interval {$pmb_newrecord_timeshift} day )";
         mysql_query($req_old, $dbh);
     }
     if (is_array($values)) {
         $this->analysis_biblio_level = 'a';
         $this->analysis_hierar_level = '2';
         $this->analysis_typdoc = $values['typdoc'];
         $this->analysis_statut = $values['statut'];
         $this->analysis_commentaire_gestion = $values['f_commentaire_gestion'];
         $this->analysis_thumbnail_url = $values['f_thumbnail_url'];
         $this->analysis_tit1 = $values['f_tit1'];
         $this->analysis_tit2 = $values['f_tit2'];
         $this->analysis_tit3 = $values['f_tit3'];
         $this->analysis_tit4 = $values['f_tit4'];
         $this->analysis_n_gen = $values['f_n_gen'];
         $this->analysis_n_contenu = $values['f_n_contenu'];
         $this->analysis_n_resume = $values['f_n_resume'];
         $this->analysis_indexint = $values['f_indexint_id'];
         $this->analysis_index_l = $values['f_indexation'];
         $this->analysis_lien = $values['f_lien'];
         $this->analysis_eformat = $values['f_eformat'];
         $this->analysis_pages = $values['pages'];
         $this->analysis_signature = $values['signature'];
         $this->analysis_indexation_lang = $values['indexation_lang'];
         $this->notice_is_new = $values['notice_is_new'];
         // insert de year à partir de la date de parution du bulletin
         if ($this->date_date) {
             $this->analysis_year = substr($this->date_date, 0, 4);
         }
         $this->date_parution_perio = $this->date_date;
         // construction de la requête :
         $data = "typdoc='" . $this->analysis_typdoc . "'";
         $data .= ", statut='" . $this->analysis_statut . "'";
         $data .= ", tit1='" . $this->analysis_tit1 . "'";
         $data .= ", tit3='" . $this->analysis_tit3 . "'";
         $data .= ", tit4='" . $this->analysis_tit4 . "'";
         $data .= ", year='" . $this->analysis_year . "'";
         $data .= ", npages='" . $this->analysis_pages . "'";
         $data .= ", n_contenu='" . $this->analysis_n_contenu . "'";
         $data .= ", n_gen='" . $this->analysis_n_gen . "'";
         $data .= ", n_resume='{$this->analysis_n_resume}'";
         $data .= ", lien='" . $this->analysis_lien . "'";
         $data .= ", eformat='" . $this->analysis_eformat . "'";
         $data .= ", indexint='" . $this->analysis_indexint . "'";
         $data .= ", index_l='" . clean_tags($this->analysis_index_l) . "'";
         $data .= ", niveau_biblio='" . $this->analysis_biblio_level . "'";
         $data .= ", niveau_hierar='" . $this->analysis_hierar_level . "'";
         $data .= ", commentaire_gestion='" . $this->analysis_commentaire_gestion . "'";
         $data .= ", thumbnail_url='" . $this->analysis_thumbnail_url . "'";
         $data .= ", signature='" . $this->analysis_signature . "'";
         $data .= ", date_parution='" . $this->date_parution_perio . "'";
         $data .= ", indexation_lang='" . $this->analysis_indexation_lang . "'";
         $data .= ", notice_is_new='" . $this->notice_is_new . "' \n\t\t\t{$other_fields}";
         $result = 0;
         if (!$this->analysis_id) {
             // si c'est une création
             // fabrication de la requête finale
             $requete = "INSERT INTO notices SET {$data} , create_date=sysdate(), update_date=sysdate() ";
             $myQuery = pmb_mysql_query($requete, $dbh);
             $this->analysis_id = pmb_mysql_insert_id($dbh);
             if ($myQuery) {
                 $result = $this->analysis_id;
             }
             // si l'insertion est OK, il faut créer l'entrée dans la table 'analysis'
             if ($this->analysis_id) {
                 // autorité personnalisées
                 $authperso = new authperso_notice($this->analysis_id);
                 $authperso->save_form();
                 // map
                 if ($pmb_map_activate) {
                     $map = new map_edition_controler(TYPE_RECORD, $this->analysis_id);
                     $map->save_form();
                     $map_info = new map_info($this->analysis_id);
                     $map_info->save_form();
                 }
                 // Mise à jour des index de la notice
                 notice::majNoticesTotal($this->analysis_id);
                 audit::insert_creation(AUDIT_NOTICE, $this->analysis_id);
                 $requete = 'INSERT INTO analysis SET';
                 $requete .= ' analysis_bulletin=' . $this->id_bulletinage;
                 $requete .= ', analysis_notice=' . $this->analysis_id;
                 $myQuery = pmb_mysql_query($requete, $dbh);
             }
         } else {
             $requete = "UPDATE notices SET {$data} , update_date=sysdate() WHERE notice_id='" . $this->analysis_id . "' LIMIT 1";
             $myQuery = pmb_mysql_query($requete, $dbh);
             // autorité personnalisées
             $authperso = new authperso_notice($this->analysis_id);
             $authperso->save_form();
             // map
             if ($pmb_map_activate) {
                 $map = new map_edition_controler(TYPE_RECORD, $this->analysis_id);
                 $map->save_form();
                 $map_info = new map_info($this->analysis_id);
                 $map_info->save_form();
             }
             // Mise à jour des index de la notice
             notice::majNoticesTotal($this->analysis_id);
             audit::insert_modif(AUDIT_NOTICE, $this->analysis_id);
             if ($myQuery) {
                 $result = $this->analysis_id;
             }
         }
         // vignette de la notice uploadé dans un répertoire
         $id = $this->analysis_id;
         if ($_FILES['f_img_load']['name'] && $pmb_notice_img_folder_id) {
             $poids_fichier_max = 1024 * 1024;
             //Limite la taille de l'image à 1 Mo
             $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'";
             $res = pmb_mysql_query($req, $dbh);
             if (pmb_mysql_num_rows($res)) {
                 $rep = pmb_mysql_fetch_object($res);
                 $filename_output = $rep->repertoire_path . "img_" . $id;
             }
             if (($fp = @fopen($_FILES['f_img_load']['tmp_name'], "rb")) && $filename_output) {
                 $image = "";
                 $size = 0;
                 $flag = true;
                 while (!feof($fp)) {
                     $image .= fread($fp, 4096);
                     $size = strlen($image);
                     if ($size > $poids_fichier_max) {
                         $flag = false;
                         break;
                     }
                 }
                 if ($flag) {
                     if ($img = imagecreatefromstring($image)) {
                         if (!($pmb_notice_img_pics_max_size * 1)) {
                             $pmb_notice_img_pics_max_size = 100;
                         }
                         $redim = false;
                         if (imagesx($img) >= imagesy($img)) {
                             if (imagesx($img) <= $pmb_notice_img_pics_max_size) {
                                 $largeur = imagesx($img);
                                 $hauteur = imagesy($img);
                             } else {
                                 $redim = true;
                                 $largeur = $pmb_notice_img_pics_max_size;
                                 $hauteur = $largeur * imagesy($img) / imagesx($img);
                             }
                         } else {
                             if (imagesy($img) <= $pmb_notice_img_pics_max_size) {
                                 $hauteur = imagesy($img);
                                 $largeur = imagesx($img);
                             } else {
                                 $redim = true;
                                 $hauteur = $pmb_notice_img_pics_max_size;
                                 $largeur = $hauteur * imagesx($img) / imagesy($img);
                             }
                         }
                         if ($redim) {
                             $dest = imagecreatetruecolor($largeur, $hauteur);
                             imagecopyresampled($dest, $img, 0, 0, 0, 0, $largeur, $hauteur, imagesx($img), imagesy($img));
                             imagepng($dest, $filename_output);
                             imagedestroy($dest);
                         } else {
                             imagepng($img, $filename_output);
                         }
                         imagedestroy($img);
                         $thumbnail_url = $opac_url_base . "getimage.php?noticecode=&vigurl=&notice_id=" . $id;
                         $req = "update notices set  thumbnail_url='" . $thumbnail_url . "' where notice_id ='" . $id . "'";
                         $res = pmb_mysql_query($req, $dbh);
                     }
                 }
             }
         }
         return $result;
     }
     //if(is_array($values))
 }
Example #7
0
 function save()
 {
     global $dbh, $sujet, $idetat, $titre, $id_theme, $id_type;
     global $date_debut, $date_fin, $date_prevue, $idempr;
     global $iduser, $progression, $demandes_statut_notice, $pmb_type_audit;
     global $gestion_acces_active, $gestion_acces_user_notice, $gestion_acces_empr_notice;
     if ($this->id_demande) {
         //MODIFICATION
         $req = "update demandes set sujet_demande='" . $sujet . "',  \n\t\t\t\tnum_demandeur='" . $idempr . "', \n\t\t\t\tdate_demande='" . $date_debut . "', \n\t\t\t\tdeadline_demande='" . $date_fin . "',\n\t\t\t\tdate_prevue='" . $date_prevue . "', \n\t\t\t\tprogression='" . $progression . "',\n\t\t\t\ttitre_demande='" . $titre . "',\n\t\t\t\ttype_demande='" . $id_type . "',\n\t\t\t\ttheme_demande='" . $id_theme . "'";
         if ($idetat == 4 || $idetat == 5) {
             $req .= " ,num_user_cloture='" . SESSuserid . "'";
         }
         $req .= " where id_demande='" . $this->id_demande . "'";
         mysql_query($req, $dbh);
         $this->titre_demande = stripslashes($titre);
         $this->sujet_demande = stripslashes($sujet);
         $this->date_demande = $date_debut;
         $this->date_prevue = $date_prevue;
         $this->deadline_demande = $date_fin;
         $this->num_user = $iduser;
         $this->progression = $progression;
         $this->num_demandeur = $idempr;
         $this->type_demande = $id_type;
         $this->theme_demande = $id_theme;
     } else {
         //CREATION de la notice associée
         $req = "insert into notices set \n\t\t\t\ttit1='" . $titre . "',\n\t\t\t\tn_contenu='" . $sujet . "',\n\t\t\t\tstatut ='" . $demandes_statut_notice . "'\n\t\t\t\t";
         mysql_query($req, $dbh);
         $id_notice = mysql_insert_id();
         notice::majNotices($id_notice);
         if ($pmb_type_audit) {
             audit::insert_creation(AUDIT_NOTICE, $id_notice);
         }
         //droits d'acces
         if ($gestion_acces_active == 1) {
             $ac = new acces();
             //traitement des droits acces user_notice
             if ($gestion_acces_user_notice == 1) {
                 $dom_1 = $ac->setDomain(1);
                 $dom_1->storeUserRights(0, $id_notice);
             }
             //traitement des droits acces empr_notice
             if ($gestion_acces_empr_notice == 1) {
                 $dom_2 = $ac->setDomain(2);
                 $dom_2->storeUserRights(0, $id_notice);
             }
         }
         //CREATION de la demande
         $req = "insert into demandes set sujet_demande='" . $sujet . "', \n\t\t\t\tetat_demande='" . $idetat . "', \n\t\t\t\tnum_demandeur='" . $idempr . "', \n\t\t\t\tdate_demande='" . $date_debut . "', \n\t\t\t\tdate_prevue='" . $date_prevue . "', \n\t\t\t\tdeadline_demande='" . $date_fin . "', \n\t\t\t\tprogression='" . $progression . "',\n\t\t\t\ttitre_demande='" . $titre . "',\n\t\t\t\ttype_demande='" . $id_type . "',\n\t\t\t\ttheme_demande='" . $id_theme . "',\n\t\t\t\tnum_notice='" . $id_notice . "'";
         mysql_query($req, $dbh);
     }
     //Affectation du libellé du thème et du type
     $this->id_demande ? $id = $this->id_demande : ($id = mysql_insert_id());
     $req = "select libelle_theme, libelle_type from demandes d, demandes_type dy , demandes_theme dt where dt.id_theme=d.theme_demande and dy.id_type=d.type_demande and id_demande='" . $id . "'";
     $res = mysql_query($req, $dbh);
     $row = mysql_fetch_object($res);
     $this->type_libelle = $row->libelle_type;
     $this->theme_libelle = $row->libelle_theme;
     //Enregistrement dans demandes_users
     $date_creation = date("Y-m-d", time());
     if ($this->id_demande && $iduser) {
         $req = "update demandes_users set users_statut=0 where num_user not in (" . implode(',', $iduser) . ") and num_demande='" . $this->id_demande . "'";
         mysql_query($req, $dbh);
         $req = "update demandes_users set users_statut=1 where num_user in (" . implode(',', $iduser) . ") and num_demande='" . $this->id_demande . "'";
         mysql_query($req, $dbh);
         for ($i = 0; $i < sizeof($iduser); $i++) {
             $req = "insert into demandes_users set num_user='******', num_demande='" . $this->id_demande . "', date_creation='" . $date_creation . "', users_statut=1";
             mysql_query($req, $dbh);
         }
     } else {
         if ($iduser) {
             for ($i = 0; $i < sizeof($iduser); $i++) {
                 $req = "insert into demandes_users set num_user='******', num_demande='" . $id . "', date_creation='" . $date_creation . "', users_statut=1";
                 mysql_query($req, $dbh);
             }
         }
     }
     $req = "select num_user, concat(prenom,' ',nom) as nom, username from demandes_users, users where num_user=userid and num_demande='" . $id . "' and users_statut=1";
     $res = mysql_query($req, $dbh);
     $i = 0;
     if (mysql_num_rows($res)) {
         $this->users = array();
         while ($user = mysql_fetch_object($res)) {
             $this->users[$i]['nom'] = trim($user->nom) ? $user->nom : $user->username;
             $this->users[$i]['id'] = $user->num_user;
             $i++;
         }
     }
 }
Example #8
0
 static function save(&$note)
 {
     global $dbh;
     global $demandes_email_demandes, $pmb_type_audit;
     if ($note->id_note) {
         //MODIFICATION
         $query = "UPDATE demandes_notes SET \n\t\t\tcontenu='" . $note->contenu . "',\n\t\t\tdate_note='" . $note->date_note . "',\n\t\t\tprive='" . $note->prive . "',\n\t\t\trapport='" . $note->rapport . "',\n\t\t\tnum_action='" . $note->num_action . "',\n\t\t\tnotes_num_user='******',\n\t\t\tnotes_type_user='******',\n\t\t\tnum_note_parent='" . $note->num_note_parent . "',\n\t\t\tnotes_read_gestion='1',\n\t\t\tnotes_read_opac='" . $note->notes_read_opac . "'\n\t\t\tWHERE id_note='" . $note->id_note . "'";
         pmb_mysql_query($query, $dbh);
         if ($pmb_type_audit) {
             audit::insert_modif(AUDIT_NOTE, $note->id_note);
         }
     } else {
         //CREATION
         $query = "INSERT INTO demandes_notes SET\n\t\t\tcontenu='" . $note->contenu . "',\n\t\t\tdate_note='" . $note->date_note . "',\n\t\t\tprive='" . $note->prive . "',\n\t\t\trapport='" . $note->rapport . "',\n\t\t\tnum_action='" . $note->num_action . "',\n\t\t\tnotes_num_user='******',\n\t\t\tnotes_type_user='******',\n\t\t\tnum_note_parent='" . $note->num_note_parent . "', \n\t\t\tnotes_read_gestion='1',\n\t\t\tnotes_read_opac='" . $note->notes_read_opac . "'";
         pmb_mysql_query($query, $dbh);
         $note->id_note = pmb_mysql_insert_id($dbh);
         if ($pmb_type_audit) {
             audit::insert_creation(AUDIT_NOTE, $note->id_note);
         }
         if (!$note->prive) {
             if ($demandes_email_demandes) {
                 $note->fetch_data($note->id_note, $note->num_action);
                 $note->send_alert_by_mail($note->notes_num_user, $note);
             }
         }
     }
 }
 static function import($value, $from_form = 0)
 {
     global $dbh;
     // Si vide on sort
     if (trim($value['name']) == '') {
         return FALSE;
     }
     if (!$from_form) {
         $value['name'] = addslashes($value['name']);
         $value['num_author'] = addslashes($value['num_author']);
         $value['form'] = addslashes($value['form']);
         $value['date'] = addslashes($value['date']);
         $value['subject'] = addslashes($value['subject']);
         $value['place'] = addslashes($value['place']);
         $value['history'] = addslashes($value['history']);
         $value['characteristic'] = addslashes($value['characteristic']);
         $value['intended_termination'] = addslashes($value['intended_termination']);
         $value['intended_audience'] = addslashes($value['intended_audience']);
         $value['context'] = addslashes($value['context']);
         $value['equinox'] = addslashes($value['equinox']);
         $value['coordinates'] = addslashes($value['coordinates']);
         $value['tonalite'] = addslashes($value['tonalite']);
         $value['comment'] = addslashes($value['comment']);
         $value['databnf_uri'] = addslashes($value['databnf_uri']);
         for ($i = 0; $i < count($value['distrib']); $i++) {
             $value['distrib'][$i] = addslashes($value['distrib'][$i]);
         }
         for ($i = 0; $i < count($value['ref']); $i++) {
             $value['ref'][$i] = addslashes($value['ref'][$i]);
         }
         for ($i = 0; $i < count($value['subdiv']); $i++) {
             $value['subdiv'][$i] = addslashes($value['subdiv'][$i]);
         }
         for ($i = 0; $i < count($value['authors']); $i++) {
             // les champs auteurs sont addslashes dans import auteur
             $value['authors'][$i]['type'] = addslashes($value['authors'][$i]['type']);
             $value['authors'][$i]['fonction'] = addslashes($value['authors'][$i]['fonction']);
         }
     }
     $marc_key = new marc_list("music_key");
     $marc_form = new marc_list("music_form");
     $flag_form = false;
     $flag_key = false;
     foreach ($marc_form->table as $value_form => $libelle_form) {
         if ($value_form == $value['form']) {
             $flag_form = true;
         }
     }
     foreach ($marc_key->table as $value_key => $libelle_key) {
         if ($value_key == $value['tonalite']) {
             $flag_key = true;
         }
     }
     if (count($value['authors'])) {
         for ($i = 0; $i < count($value['authors']); $i++) {
             if ($value['authors'][$i]['id']) {
                 $tu_auteur = new auteur($value['authors'][$i]['id']);
                 if (!$tu_auteur->id) {
                     // id non valide
                     $value['authors'][$i]['id'] = 0;
                 }
             }
             if (!$value['authors'][$i]['id']) {
                 // création ou déjà existant. auteur::import addslashes les champs
                 $value['authors'][$i]['id'] = auteur::import($value['authors'][$i]);
             }
         }
     }
     // $value déjà addslashes plus haut -> 1
     $titre = titre_uniforme::import_tu_exist($value, 1);
     if ($titre) {
         return $titre;
     }
     $requete = "INSERT INTO titres_uniformes SET ";
     $requete .= "tu_name='" . $value["name"] . "', ";
     $requete .= "tu_num_author='" . $value["num_author"] . "', ";
     $requete .= (!$flag_form ? "tu_forme='" : "tu_forme_marclist='") . $value['form'] . "', ";
     $requete .= "tu_date='" . $value["date"] . "', ";
     $requete .= "tu_sujet='" . $value["subject"] . "', ";
     $requete .= "tu_lieu='" . $value["place"] . "', ";
     $requete .= "tu_histoire='" . $value["history"] . "', ";
     $requete .= "tu_caracteristique='" . $value["characteristic"] . "', ";
     $requete .= "tu_completude='" . $value["intended_termination"] . "', ";
     $requete .= "tu_public='" . $value["intended_audience"] . "', ";
     $requete .= "tu_contexte='" . $value["context"] . "', ";
     $requete .= "tu_equinoxe='" . $value["equinox"] . "', ";
     $requete .= "tu_coordonnees='" . $value["coordinates"] . "', ";
     $requete .= (!$flag_key ? "tu_tonalite='" : "tu_tonalite_marclist='") . $value['tonalite'] . "', ";
     $requete .= "tu_comment='" . $value["comment"] . "', ";
     $requete .= "tu_databnf_uri='" . $value["databnf_uri"] . "' ";
     // insertion du titre uniforme	et mise à jour de l'index tu
     if (pmb_mysql_query($requete, $dbh)) {
         $tu_id = pmb_mysql_insert_id();
     } else {
         return FALSE;
     }
     if (count($value['authors'])) {
         $ordre = 0;
         $rqt_ins = "INSERT INTO responsability_tu (responsability_tu_author_num, responsability_tu_num, responsability_tu_fonction, responsability_tu_type, responsability_tu_ordre) VALUES ";
         foreach ($value['authors'] as $author) {
             if ($author['id']) {
                 $rqt = $rqt_ins . " ('" . $author['id'] . "','" . $tu_id . "','" . $author['fonction'] . "','" . $author['type'] . "', {$ordre}) ";
                 $res_ins = @pmb_mysql_query($rqt);
                 $ordre++;
             }
         }
     }
     // Distribution instrumentale et vocale (pour la musique)
     for ($i = 0; $i < count($value['distrib']); $i++) {
         $requete = "INSERT INTO tu_distrib SET\n\t\t\tdistrib_num_tu='{$tu_id}',\n\t\t\tdistrib_name='" . $value['distrib'][$i] . "',\n\t\t\tdistrib_ordre='{$i}' ";
         pmb_mysql_query($requete, $dbh);
     }
     // Référence numérique (pour la musique)
     for ($i = 0; $i < count($value['ref']); $i++) {
         $requete = "INSERT INTO tu_ref SET\n\t\t\tref_num_tu='{$tu_id}',\n\t\t\tref_name='" . $value['ref'][$i] . "',\n\t\t\tref_ordre='{$i}' ";
         pmb_mysql_query($requete, $dbh);
     }
     // Subdivision de forme
     for ($i = 0; $i < count($value['subdiv']); $i++) {
         $requete = "INSERT INTO tu_subdiv SET\n\t\t\tsubdiv_num_tu='{$tu_id}',\n\t\t\tsubdiv_name='" . $value['subdiv'][$i] . "',\n\t\t\tsubdiv_ordre='{$i}' ";
         pmb_mysql_query($requete, $dbh);
     }
     audit::insert_creation(AUDIT_TITRE_UNIFORME, $tu_id);
     //update authority informations
     $authority = new authority(0, $tu_id, AUT_TABLE_TITRES_UNIFORMES);
     $authority->set_num_statut($value["statut"]);
     $authority->update();
     // mise à jour du champ index du titre uniforme
     if ($tu_id) {
         titre_uniforme::update_index_tu($tu_id);
         titre_uniforme::tu_enrichment($tu_id);
     }
     return $tu_id;
 }
Example #10
0
 function import($data)
 {
     // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
     // $data['type'] type de l'autorité (70 , 71 ou 72)
     // $data['name'] élément d'entrée de l'autorité
     // $data['rejete'] élément rejeté
     // $data['date'] dates de l'autorité
     // $data['lieu'] lieu du congrès 210$e
     // $data['ville'] ville du congrès
     // $data['pays'] pays du congrès
     // $data['subdivision'] 210$b
     // $data['numero'] numero du congrès 210$d
     // $data['voir_id'] id de la forme retenue (sans objet pour l'import de notices)
     // $data['author_comment'] commentaire
     // $data['authority_number'] Numéro d'autortité
     // TODO gestion du dédoublonnage !
     global $dbh;
     global $opac_enrichment_bnf_sparql;
     // check sur le type de la variable passée en paramètre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         return 0;
     }
     // check sur les éléments du tableau (data['name'] ou data['rejete'] est requis).
     $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT author_name FROM authors limit 1"), 0);
     $long_maxi_rejete = pmb_mysql_field_len(pmb_mysql_query("SELECT author_rejete FROM authors limit 1"), 0);
     $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
     $data['rejete'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['rejete']))), 0, $long_maxi_rejete));
     if (!$data['name'] && !$data['rejete']) {
         return 0;
     }
     // check sur le type d'autorité
     if (!$data['type'] == 70 && !$data['type'] == 71 && !$data['type'] == 72) {
         return 0;
     }
     // tentative de récupérer l'id associée dans la base (implique que l'autorité existe)
     // préparation de la requête
     $key0 = $data['type'];
     $key1 = addslashes($data['name']);
     $key2 = addslashes($data['rejete']);
     $key3 = addslashes($data['date']);
     $key4 = addslashes($data['subdivision']);
     $key5 = addslashes($data['lieu']);
     $key6 = addslashes($data['ville']);
     $key7 = addslashes($data['pays']);
     $key8 = addslashes($data['numero']);
     $data['lieu'] = addslashes($data['lieu']);
     $data['ville'] = addslashes($data['ville']);
     $data['pays'] = addslashes($data['pays']);
     $data['subdivision'] = addslashes($data['subdivision']);
     $data['numero'] = addslashes($data['numero']);
     $data['author_comment'] = addslashes($data['author_comment']);
     $data['author_web'] = addslashes($data['author_web']);
     $query = "SELECT author_id FROM authors WHERE author_type='{$key0}' AND author_name='{$key1}' AND author_rejete='{$key2}' AND author_date='{$key3}'";
     if ($data["type"] > 70) {
         $query .= " and author_subdivision='{$key4}' and author_lieu='{$key5}' and author_ville='{$key6}' and author_pays='{$key7}' and author_numero='{$key8}'";
     }
     $query .= " LIMIT 1";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT in database");
     }
     // résultat
     // récupération du résultat de la recherche
     $aut = pmb_mysql_fetch_object($result);
     // du résultat et récupération éventuelle de l'id
     if ($aut->author_id) {
         return $aut->author_id;
     }
     // id non-récupérée, il faut créer l'auteur
     $query = "INSERT INTO authors SET author_type='{$key0}', ";
     $query .= "author_name='{$key1}', ";
     $query .= "author_rejete='{$key2}', ";
     $query .= "author_date='{$key3}', ";
     $query .= "author_lieu='" . $data['lieu'] . "', ";
     $query .= "author_ville='" . $data['ville'] . "', ";
     $query .= "author_pays='" . $data['pays'] . "', ";
     $query .= "author_subdivision='" . $data['subdivision'] . "', ";
     $query .= "author_numero='" . $data['numero'] . "', ";
     $query .= "author_web='" . $data['author_web'] . "', ";
     $query .= "author_comment='" . $data['author_comment'] . "', ";
     $word_to_index = $key1 . " " . $key2 . " " . $data['lieu'] . " " . $data['ville'] . " " . $data['pays'] . " " . $data['numero'] . " " . $data["subdivision"];
     if ($key0 == "72") {
         $word_to_index .= " " . $key3;
     }
     $query .= "index_author=' " . strip_empty_chars($word_to_index) . " ' ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into table authors :<br /><b>{$query}</b> ");
     }
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_AUTHOR, $id);
     return $id;
 }
Example #11
0
function creer_lien_notice_bulletin($ancien_id = 0, $id_perio = 0, $id_bulletin = 0, $id_not_bull = 0, $titre_not_bull = "", $bulletin)
{
    global $dbh, $msg, $isbn_OK, $tit_200a, $notice_id, $notices_crees, $statutnot;
    //On control que ce bulletin n'a pas déjà une notice
    $requete = "select num_notice from bulletins where bulletin_id='" . $id_bulletin . "'";
    if ($id_not_bull) {
        $requete .= " and num_notice!='" . $id_not_bull . "'";
    }
    $res = mysql_query($requete, $dbh);
    if (mysql_num_rows($res) && mysql_result($res, 0, 0)) {
        //Si j'ai déja une notice associé à ce bulletin je la récupère
        if ($id_not_bull) {
            //Si j'ai aussi un identifiant de notice de bulletin, je supprime le plus récent
            notice::del_notice($id_not_bull);
            mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[542] . " {$id_unimarc} " . " {$isbn_OK} " . addslashes(clean_string(implode(" ; ", $tit_200a))) . "') ", $dbh);
            $id_notice_bulletin = mysql_result($res, 0, 0);
            //A voir pr modif
        } else {
            $id_notice_bulletin = mysql_result($res, 0, 0);
        }
        $notice_id = $id_notice_bulletin;
    } else {
        if ($titre_not_bull) {
            //Si j'ai un titre je créé la notice de bulletin
            $requete = "insert into notices (tit1,niveau_biblio, niveau_hierar,statut) values ('" . addslashes(clean_string($titre_not_bull)) . "', 'b', '2','" . $statutnot . "')";
            mysql_query($requete, $dbh);
            $id_notice_bulletin = mysql_insert_id();
            audit::insert_creation(AUDIT_NOTICE, $id_notice_bulletin);
            //calcul des droits d'accès s'ils sont activés
            calc_notice_acces_rights($id_notice_bulletin);
            // Mise à jour des index de la notice
            notice::majNotices($id_notice_bulletin);
            // Mise à jour de la table "notices_global_index"
            notice::majNoticesGlobalIndex($id_notice_bulletin);
            // Mise à jour de la table "notices_mots_global_index"
            notice::majNoticesMotsGlobalIndex($id_notice_bulletin);
        } else {
            $id_notice_bulletin = $id_not_bull;
        }
        //On créer le lien entre le bulletin et la notice de bulletin
        $requete = "update bulletins set num_notice='" . $id_notice_bulletin . "' where bulletin_id='" . $id_bulletin . "'";
        mysql_query($requete, $dbh);
    }
    $notices_crees[$ancien_id] = $id_notice_bulletin;
    //Lien entre la notice de bulletin et la notice de periodique
    $requete = "insert into notices_relations(num_notice,linked_notice,relation_type) values ('" . $id_notice_bulletin . "','" . $id_perio . "','b')";
    mysql_query($requete);
    if ($id_notice_bulletin && $bulletin["date"]) {
        $requete = "UPDATE notices SET year='" . addslashes(substr($bulletin["date"], 0, 4)) . "', date_parution='" . addslashes($bulletin["date"]) . "' WHERE notice_id='" . $id_notice_bulletin . "'";
        mysql_query($requete);
    }
    return $id_notice_bulletin;
}
Example #12
0
 function insert_in_database($addslashes = false)
 {
     global $dbh;
     global $class_path;
     global $gestion_acces_active, $gestion_acces_user_notice, $gestion_acces_empr_notice;
     global $res_prf, $chk_rights;
     global $pmb_synchro_rdf;
     $new_notice = 0;
     $notice_retour = 0;
     $long_maxi = mysql_field_len(mysql_query("SELECT code FROM notices limit 1"), 0);
     $isbn = rtrim(substr($this->isbn, 0, $long_maxi));
     if ($isbn != "") {
         if (isISBN($isbn)) {
             if (strlen($isbn) == 13) {
                 $isbn1 = formatISBN($isbn, 13);
             } else {
                 $isbn1 = formatISBN($isbn, 10);
             }
         }
         $sql_rech = "select notice_id from notices where code = '" . $isbn . "' ";
         if ($isbn1) {
             $sql_rech .= " or code='" . $isbn1 . "' ";
         }
         $sql_result_rech = mysql_query($sql_rech) or die("Couldn't select notice ! = " . $sql_rech);
         if (mysql_num_rows($sql_result_rech) == 0) {
             $new_notice = 1;
         } else {
             $new_notice = 0;
             $lu = mysql_fetch_array($sql_result_rech);
             $notice_retour = $lu['notice_id'];
         }
     } else {
         $new_notice = 1;
     }
     if ($new_notice == 0) {
         $retour = array($new_notice, $notice_retour);
         return $retour;
     }
     for ($i = 0; $i < 2; $i++) {
         if ($this->editors[$i]['id']) {
             $editor_ids[$i] = $this->editors[$i]['id'];
         } else {
             $editor_ids[$i] = editeur::import($this->editors[$i]);
         }
     }
     $this->collection['parent'] = $editor_ids[0];
     if ($this->collection["id"]) {
         $collection_id = $this->collection["id"];
     } else {
         $collection_id = collection::import($this->collection);
     }
     $this->subcollection['coll_parent'] = $collection_id;
     if ($this->subcollection["id"]) {
         $subcollection_id = $this->subcollection["id"];
     } else {
         $subcollection_id = subcollection::import($this->subcollection);
     }
     $serie_id = serie::import(stripslashes($this->serie));
     /* traitement de Dewey */
     if (!$this->internal_index) {
         if (!$this->dewey["new_comment"]) {
             $this->dewey["new_comment"] = "";
         }
         if (!$this->dewey["new_pclass"]) {
             $this->dewey["new_pclass"] = "";
         }
         $this->internal_index = indexint::import(clean_string($this->dewey[0]), clean_string($this->dewey["new_comment"]), clean_string($this->dewey["new_pclass"]));
     }
     $date_parution_z3950 = notice::get_date_parution($this->year);
     /* Origine de la notice */
     $this->orinot_id = origine_notice::import($this->origine_notice);
     if ($this->orinot_id == 0) {
         $this->orinot_id = 1;
     }
     if ($addslashes) {
         $this->document_type = addslashes($this->document_type);
         $this->isbn = addslashes($this->isbn);
         $this->titles[0] = addslashes($this->titles[0]);
         $this->titles[1] = addslashes($this->titles[1]);
         $this->titles[2] = addslashes($this->titles[2]);
         $this->titles[3] = addslashes($this->titles[3]);
         $this->nbr_in_serie = addslashes($this->nbr_in_serie);
         $this->year = addslashes($this->year);
         $this->page_nbr = addslashes($this->page_nbr);
         $this->illustration = addslashes($this->illustration);
         $this->size = addslashes($this->size);
         $this->accompagnement = addslashes($this->accompagnement);
         $this->nbr_in_collection = addslashes($this->nbr_in_collection);
         $this->mention_edition = addslashes($this->mention_edition);
         $this->general_note = addslashes($this->general_note);
         $this->content_note = addslashes($this->content_note);
         $this->abstract_note = addslashes($this->abstract_note);
         $this->commentaire_gestion = addslashes($this->commentaire_gestion);
         $this->indexation_lang = addslashes($this->indexation_lang);
         $this->thumbnail_url = addslashes($this->thumbnail_url);
         $this->free_index = addslashes($this->free_index);
         $this->link_url = addslashes($this->link_url);
         $this->link_format = addslashes($this->link_format);
         $this->prix = addslashes($this->prix);
         //les oubliés du premier tour
         $serie_id = addslashes($serie_id);
         $this->bibliographic_level = addslashes($this->bibliographic_level);
         $this->hierarchic_level = addslashes($this->hierarchic_level);
         $date_parution_z3950 = addslashes($date_parution_z3950);
     }
     $sql_ins = "insert into notices (\n\t\t\ttypdoc          ,\n\t\t\tcode        \t,\n\t\t\ttit1            ,\n\t\t\ttit2            ,\n\t\t\ttit3            ,\n\t\t\ttit4            ,\n\t\t\ttparent_id      ,\n\t\t\ttnvol           ,\n\t\t\ted1_id          ,\n\t\t\ted2_id          ,\n\t\t\tyear            ,\n\t\t\tnpages          ,\n\t\t\till             ,\n\t\t\tsize            ,\n\t\t\taccomp          ,\n\t\t\tcoll_id         ,\n\t\t\tsubcoll_id      ,\n\t\t\tnocoll          ,\n\t\t\tmention_edition ,\n\t\t\tn_gen           ,\n\t\t\tn_contenu       ,\n\t\t\tn_resume        ,\n\t\t\tindexint,\n\t\t\tstatut,\n\t\t\tcommentaire_gestion,\n\t\t\tsignature,\n\t\t\tthumbnail_url,\n\t\t\tindex_l,\n\t\t\tniveau_biblio,\n\t\t\tniveau_hierar,\n\t\t\tlien,\n\t\t\teformat,\n\t\t\torigine_catalogage,\n\t\t\tprix,\n\t\t\tcreate_date,\n\t\t\tdate_parution,\n\t\t\tindexation_lang\n\t\t\t) values (\n\t\t\t'" . $this->document_type . "',\t\n\t\t\t'" . $this->isbn . "',\t\n\t\t\t'" . $this->titles[0] . "',\n\t\t\t'" . $this->titles[1] . "',\n\t\t\t'" . $this->titles[2] . "',\n\t\t\t'" . $this->titles[3] . "',\n\t\t\t'" . $serie_id . "',\n\t\t\t'" . $this->nbr_in_serie . "',\n\t\t\t" . $editor_ids[0] . " ,\n\t\t\t" . $editor_ids[1] . " ,\n\t\t\t'" . $this->year . "',\n\t\t\t'" . $this->page_nbr . "',\n\t\t\t'" . $this->illustration . "',\n\t\t\t'" . $this->size . "',\n\t\t\t'" . $this->accompagnement . "',\n\t\t\t" . $collection_id . " ,\n\t\t\t" . $subcollection_id . " ,\n\t\t\t'" . $this->nbr_in_collection . "',\n\t\t\t'" . $this->mention_edition . "',\n\t\t\t'" . $this->general_note . "',\n\t\t\t'" . $this->content_note . "',\n\t\t\t'" . $this->abstract_note . "',\n\t\t\t'" . $this->internal_index . "',\n\t\t\t'" . $this->statut . "',\n\t\t\t'" . $this->commentaire_gestion . "',\n\t\t\t'" . $this->signature . "',\n\t\t\t'" . $this->thumbnail_url . "',\n\t\t\t'" . clean_tags($this->free_index) . "',\n\t\t\t'" . $this->bibliographic_level . "',\n\t\t\t'" . $this->hierarchic_level . "',\n\t\t\t'" . $this->link_url . "',\n\t\t\t'" . $this->link_format . "',\n\t\t\t'" . $this->orinot_id . "',\n\t\t\t'" . $this->prix . "',\n\t\t\tsysdate(),\n\t\t\t'" . $date_parution_z3950 . "',\n\t\t\t'" . $this->indexation_lang . "'\n\t\t )";
     $sql_result_ins = mysql_query($sql_ins) or die("Couldn't insert into table notices : " . $sql_ins);
     $notice_retour = mysql_insert_id();
     audit::insert_creation(AUDIT_NOTICE, $notice_retour);
     if ($gestion_acces_active == 1) {
         $ac = new acces();
         //traitement des droits acces user_notice
         if ($gestion_acces_user_notice == 1) {
             $dom_1 = $ac->setDomain(1);
             $dom_1->storeUserRights(0, $notice_retour);
         }
         //traitement des droits acces empr_notice
         if ($gestion_acces_empr_notice == 1) {
             $dom_2 = $ac->setDomain(2);
             $dom_2->storeUserRights(0, $notice_retour);
         }
     }
     // purge de la base des responsabilités de la notice intégrée...
     if ($notice_retour) {
         $rqt_del = "delete from responsability where responsability_notice='{$notice_retour}'";
         $sql_result_del = mysql_query($rqt_del) or die("Couldn't purge table responsability : " . $rqt_del);
     }
     $rqt_ins = "insert into responsability (responsability_author, responsability_notice, responsability_fonction, responsability_type, responsability_ordre ) VALUES ";
     for ($i = 0; $i < sizeof($this->aut_array); $i++) {
         $aut['id'] = clean_string($this->aut_array[$i]['id']);
         $aut['name'] = clean_string($this->aut_array[$i]['entree']);
         $aut['rejete'] = clean_string($this->aut_array[$i]['rejete']);
         $aut['date'] = clean_string($this->aut_array[$i]['date']);
         $aut['type'] = $this->aut_array[$i]['type_auteur'];
         $aut['subdivision'] = clean_string($this->aut_array[$i]['subdivision']);
         $aut['numero'] = clean_string($this->aut_array[$i]['numero']);
         $aut['lieu'] = clean_string($this->aut_array[$i]['lieu']);
         $aut['ville'] = clean_string($this->aut_array[$i]['ville']);
         $aut['pays'] = clean_string($this->aut_array[$i]['pays']);
         $aut['web'] = clean_string($this->aut_array[$i]['web']);
         $aut['author_comment'] = clean_string($this->aut_array[$i]['author_comment']);
         $aut['authority_number'] = clean_string($this->aut_array[$i]['authority_number']);
         /* Origine de l'autorité : on reprend les infos d'origine de la notice pour les attribuées aux origines des autorités */
         $id_origine_auth = 0;
         $id_origine_auth = origin_authorities::import($this->origine_notice);
         if ($id_origine_auth == 0) {
             $id_origine_auth = 1;
         }
         // import de l'autorité auteur si elle existe et conservation des infos sur l'origine de l'autorité
         if ($aut['authority_number'] != '' && $id_origine_auth) {
             $this->aut_array[$i]["id"] = $this->insert_authority_infos($aut['authority_number'], "author", $id_origine_auth, $aut);
         }
         if (!$this->aut_array[$i]["id"]) {
             $this->aut_array[$i]["id"] = auteur::import($aut);
         }
         if ($this->aut_array[$i]["id"]) {
             $rqt = $rqt_ins . " (" . $this->aut_array[$i]["id"] . "," . $notice_retour . ",'" . $this->aut_array[$i]['fonction'] . "'," . $this->aut_array[$i]['responsabilite'] . "," . $i . ") ";
             $res_ins = mysql_query($rqt, $dbh);
         }
     }
     // traitement des titres uniformes
     global $pmb_use_uniform_title;
     if ($pmb_use_uniform_title) {
         if (count($this->titres_uniformes)) {
             $ntu = new tu_notice($notice_retour);
             $ntu->update($this->titres_uniformes);
         }
     }
     // traitement des langues
     // langues de la publication
     $rqt_del = "delete from notices_langues where num_notice='{$notice_retour}' ";
     $res_del = mysql_query($rqt_del, $dbh);
     if (is_array($this->language_code) && count($this->language_code)) {
         $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES ";
         foreach ($this->language_code as $ordre_lang => $code_lang) {
             if ($code_lang) {
                 $rqt = $rqt_ins . " ('{$notice_retour}',0, '{$code_lang}', {$ordre_lang}) ";
                 $res_ins = @mysql_query($rqt, $dbh);
             }
         }
     }
     // langues originales
     if (is_array($this->original_language_code) && count($this->original_language_code)) {
         $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES ";
         foreach ($this->original_language_code as $ordre_lang => $code_lang) {
             if ($code_lang) {
                 $rqt = $rqt_ins . " ('{$notice_retour}',1, '{$code_lang}', {$ordre_lang}) ";
                 $res_ins = @mysql_query($rqt, $dbh);
             }
         }
     }
     // traitement des categories
     if ($this->categorisation_type == "categorisation_auto") {
         traite_categories_enreg($notice_retour, $this->categories);
     } else {
         $rqt_del = "delete from notices_categories where notcateg_notice='{$notice_retour}' ";
         $res_del = @mysql_query($rqt_del, $dbh);
         $rqt_ins = "insert into notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ";
         $rqt_ins_values = array();
         foreach ($this->categories as $i => $category) {
             $id_categ = $category['categ_id'];
             if ($id_categ) {
                 $rqt_ins_values[] = " ('{$notice_retour}','{$id_categ}', {$i}) ";
             }
         }
         $rqt_ins .= implode(",", $rqt_ins_values);
         $res_ins = @mysql_query($rqt_ins, $dbh);
     }
     //Traitement des champs personnalisés (du formulaire !!!)
     $p_perso = new parametres_perso("notices");
     $nberrors = $p_perso->check_submited_fields();
     $p_perso->rec_fields_perso($notice_retour);
     //Traitement import perso
     global $notice_id, $notice_org, $notice_type_org;
     if (function_exists('z_recup_noticeunimarc_suite') && function_exists('z_import_new_notice_suite')) {
         $notice_id = $notice_retour;
         if (!$notice_org) {
             $notice_tmp = $this->notice;
         }
         z_recup_noticeunimarc_suite($notice_tmp ? $notice_tmp : $notice_org);
         z_import_new_notice_suite();
         $notice_tmp = "";
     }
     // Mise à jour des index de la notice
     notice::majNotices($notice_retour);
     // Mise à jour de la table notices_global_index
     notice::majNoticesGlobalIndex($notice_retour);
     // Mise à jour de la table notices_mots_global_index
     notice::majNoticesMotsGlobalIndex($notice_retour);
     //Calcul de la signature
     $sign = new notice_doublon();
     $val = $sign->gen_signature($notice_retour);
     mysql_query("update notices set signature='{$val}' where notice_id=" . $notice_retour, $dbh);
     //Documents numériques
     foreach ($this->doc_nums as $doc_num) {
         if (!$doc_num['a']) {
             continue;
         }
         if ($doc_num['__nodownload__']) {
             explnum_add_url($notice_retour, $doc_num['b'], $doc_num['a']);
         } else {
             explnum_add_from_url($notice_retour, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p']);
         }
     }
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
     }
     //Si on catalogue un article on recrée l'arborescence
     global $biblio_notice;
     if ($biblio_notice == 'art') {
         //Perios
         if (!$this->perio_id) {
             $new_perio = new serial();
             $values = array();
             $values['tit1'] = $this->perio_titre;
             $values['code'] = $this->perio_issn;
             $values['niveau_biblio'] = "s";
             $values['niveau_hierar'] = "1";
             $this->perio_id = $new_perio->update($values);
             //synchro_rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf->addRdf($this->perio_id, 0);
             }
         }
         //Bulletin
         if ($this->bull_id) {
             $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "', \n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'";
             mysql_query($req_art, $dbh);
             $req = "update bulletins set bulletin_notice='" . $this->perio_id . "' where bulletin_id='" . $this->bull_id . "'";
             mysql_query($req, $dbh);
         } else {
             $new_bull = new bulletinage(0, $this->perio_id);
             $values = array();
             $values['bul_no'] = $this->bull_num;
             $values['bul_date'] = $this->bull_mention;
             $values['date_date'] = $this->bull_date;
             $values['bul_titre'] = $this->bull_titre;
             $new_bull->update($values);
             $this->bull_id = $new_bull->bulletin_id;
             $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "', \n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'";
             mysql_query($req_art, $dbh);
             //synchro_rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf->addRdf(0, $this->bull_id);
             }
         }
     }
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf->addRdf($notice_retour, 0);
     }
     $retour = array($new_notice, $notice_retour);
     return $retour;
 }
 static function save(&$note)
 {
     global $dbh;
     global $demandes_email_demandes, $pmb_type_audit, $PMBuserid;
     if ($note->id_note) {
         //MODIFICATION
         $query = "UPDATE demandes_notes SET \n\t\t\tcontenu='" . $note->contenu . "',\n\t\t\tdate_note='" . $note->date_note . "',\n\t\t\tprive='" . $note->prive . "',\n\t\t\trapport='" . $note->rapport . "',\n\t\t\tnum_action='" . $note->num_action . "',\n\t\t\tnotes_num_user='******',\n\t\t\tnotes_type_user='******',\n\t\t\tnum_note_parent='" . $note->num_note_parent . "',\n\t\t\tnotes_read_gestion='" . $note->notes_read_gestion . "',\n\t\t\tnotes_read_opac='1' \n\t\t\tWHERE id_note='" . $note->id_note . "'";
         pmb_mysql_query($query, $dbh);
         if ($pmb_type_audit) {
             audit::insert_modif(AUDIT_NOTE, $note->id_note);
         }
     } else {
         //CREATION
         $query = "INSERT INTO demandes_notes SET\n\t\t\tcontenu='" . $note->contenu . "',\n\t\t\tdate_note='" . $note->date_note . "',\n\t\t\tprive='" . $note->prive . "',\n\t\t\trapport='" . $note->rapport . "',\n\t\t\tnum_action='" . $note->num_action . "',\n\t\t\tnotes_num_user='******',\n\t\t\tnotes_type_user='******',\n\t\t\tnum_note_parent='" . $note->num_note_parent . "', \n\t\t\tnotes_read_gestion='" . $note->notes_read_gestion . "',\n\t\t\tnotes_read_opac='1'";
         pmb_mysql_query($query, $dbh);
         $note->id_note = pmb_mysql_insert_id($dbh);
         if ($pmb_type_audit) {
             audit::insert_creation(AUDIT_NOTE, $note->id_note);
         }
         if (!$note->prive) {
             if ($demandes_email_demandes) {
                 $note->fetch_data($note->id_note, $note->num_action);
                 $note->send_alert_by_mail($note->notes_num_user, $note);
             }
         }
     }
     // Générer la réponse finale de la demande avec cette note
     if ($note->demande_end) {
         global $f_message;
         $f_message = $note->contenu;
         $demande = new demandes($note->num_demande);
         $demande->save_repfinale($note->id_note);
         demandes_notes::note_majParent($note->id_note, $note->num_action, $note->num_demande, "_gestion");
     }
 }
Example #14
0
 if ($pe_isbn) {
     $requete = "select notice_id from notices where code='" . addslashes($pe_isbn) . "' " . $suite_rqt . " and niveau_biblio='m' and niveau_hierar='0' ";
     $result = mysql_query($requete, $dbh);
     if ($tmp_not = mysql_fetch_object($result)) {
         $id_notice = $tmp_not->notice_id;
         $acreer = 0;
     }
 }
 if ($acreer) {
     $requete = "INSERT INTO notices SET code='" . addslashes($pe_isbn) . "', tit1='{$pe_titre}', statut='{$pmb_pret_express_statut}', niveau_biblio='m', niveau_hierar='0', create_date=sysdate() ";
     $result = mysql_query($requete, $dbh);
     if (!$result) {
         die('ERROR PE: insert into notice');
     }
     $id_notice = mysql_insert_id();
     audit::insert_creation(AUDIT_NOTICE, $id_notice);
     notice::majNotices($id_notice);
     notice::majNoticesGlobalIndex($id_notice, 1);
     notice::majNoticesMotsGlobalIndex($id_notice);
     if ($gestion_acces_active == 1) {
         require_once "{$class_path}/acces.class.php";
         $ac = new acces();
         //traitement des droits acces user_notice
         if ($gestion_acces_user_notice == 1) {
             $dom_1 = $ac->setDomain(1);
             $dom_1->storeUserRights(0, $id_notice);
         }
         //traitement des droits acces empr_notice
         if ($gestion_acces_empr_notice == 1) {
             $dom_2 = $ac->setDomain(2);
             $dom_2->storeUserRights(0, $id_notice);
Example #15
0
 function import($data)
 {
     // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
     //	$data['name'] 	Nom de la collection
     //	$data['coll_parent']	id de l'éditeur parent de la collection
     //	$data['issn']	numéro ISSN de la collection
     global $dbh;
     // check sur le type de  la variable passée en paramètre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         return 0;
     }
     // check sur les éléments du tableau (data['name'] est requis).
     $long_maxi_name = mysql_field_len(mysql_query("SELECT sub_coll_name FROM sub_collections limit 1"), 0);
     $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
     //si on a pas d'id, on peut avoir les infos de la collection
     if (!$data['coll_parent']) {
         if ($data['collection']) {
             //on les a, on crée l'éditeur
             $data['coll_parent'] = collection::import($data['collection']);
         }
     }
     if ($data['name'] == "" || $data['coll_parent'] == 0) {
         /* il nous faut impérativement une collection parente */
         return 0;
     }
     // préparation de la requête
     $key0 = addslashes($data['name']);
     $key1 = $data['coll_parent'];
     $key2 = addslashes($data['issn']);
     /* vérification que la collection existe bien ! */
     $query = "SELECT collection_id FROM collections WHERE collection_id='{$key1}' LIMIT 1 ";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT colections " . $query);
     }
     if (mysql_num_rows($result) == 0) {
         return 0;
     }
     /* vérification que la sous-collection existe */
     $query = "SELECT sub_coll_id FROM sub_collections WHERE sub_coll_name='{$key0}' AND sub_coll_parent='{$key1}' LIMIT 1 ";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT sub_collections " . $query);
     }
     $subcollection = mysql_fetch_object($result);
     /* la sous-collection existe, on retourne l'ID */
     if ($subcollection->sub_coll_id) {
         return $subcollection->sub_coll_id;
     }
     // id non-récupérée, il faut créer la forme.
     $query = "INSERT INTO sub_collections SET sub_coll_name='{$key0}', ";
     $query .= "sub_coll_parent='{$key1}', ";
     $query .= "sub_coll_issn='{$key2}', ";
     $query .= "subcollection_web='" . addslashes($data["subcollection_web"]) . "', ";
     $query .= "subcollection_comment='" . addslashes($data["comment"]) . "', ";
     $query .= "index_sub_coll=' " . strip_empty_words($key0) . " " . strip_empty_words($key2) . " ' ";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into sub_collections" . $query);
     }
     $id = mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_COLLECTION, $id);
     return $id;
 }
 function insert_in_database($addslashes = false)
 {
     global $dbh;
     global $class_path;
     global $gestion_acces_active, $gestion_acces_user_notice, $gestion_acces_empr_notice;
     global $res_prf, $chk_rights;
     global $pmb_synchro_rdf;
     global $opac_url_base, $pmb_notice_img_folder_id;
     if ($this->bibliographic_level == "s" && $this->hierarchic_level == "2") {
         $this->bibliographic_level = "b";
     }
     $new_notice = 0;
     $notice_retour = 0;
     $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT code FROM notices limit 1"), 0);
     $isbn = rtrim(substr($this->isbn, 0, $long_maxi));
     if ($isbn != "") {
         if (isISBN($isbn)) {
             if (strlen($isbn) == 13) {
                 $isbn1 = formatISBN($isbn, 13);
             } else {
                 $isbn1 = formatISBN($isbn, 10);
             }
         }
         $sql_rech = "select notice_id from notices where code = '" . $isbn . "' ";
         if ($isbn1) {
             $sql_rech .= " or code='" . $isbn1 . "' ";
         }
         $sql_result_rech = pmb_mysql_query($sql_rech) or die("Couldn't select notice ! = " . $sql_rech);
         if (pmb_mysql_num_rows($sql_result_rech) == 0) {
             $new_notice = 1;
         } else {
             $new_notice = 0;
             $lu = pmb_mysql_fetch_array($sql_result_rech);
             $notice_retour = $lu['notice_id'];
         }
     } else {
         $new_notice = 1;
     }
     if ($new_notice == 0) {
         $retour = array($new_notice, $notice_retour);
         return $retour;
     }
     for ($i = 0; $i < 2; $i++) {
         if ($this->editors[$i]['id']) {
             $editor_ids[$i] = $this->editors[$i]['id'];
         } else {
             $editor_ids[$i] = editeur::import($this->editors[$i]);
         }
     }
     $this->collection['parent'] = $editor_ids[0];
     if ($this->collection["id"]) {
         $collection_id = $this->collection["id"];
     } else {
         $collection_id = collection::import($this->collection);
     }
     $this->subcollection['coll_parent'] = $collection_id;
     if ($this->subcollection["id"]) {
         $subcollection_id = $this->subcollection["id"];
     } else {
         $subcollection_id = subcollection::import($this->subcollection);
     }
     $serie_id = serie::import(stripslashes($this->serie));
     /* traitement de Dewey */
     if (!$this->internal_index) {
         if (!$this->dewey["new_comment"]) {
             $this->dewey["new_comment"] = "";
         }
         if (!$this->dewey["new_pclass"]) {
             $this->dewey["new_pclass"] = "";
         }
         $this->internal_index = indexint::import(clean_string($this->dewey[0]), clean_string($this->dewey["new_comment"]), clean_string($this->dewey["new_pclass"]));
     }
     $date_parution_z3950 = notice::get_date_parution($this->year);
     /* Origine de la notice */
     $this->orinot_id = origine_notice::import($this->origine_notice);
     if ($this->orinot_id == 0) {
         $this->orinot_id = 1;
     }
     if ($addslashes) {
         $this->document_type = addslashes($this->document_type);
         $this->isbn = addslashes($this->isbn);
         $this->titles[0] = addslashes($this->titles[0]);
         $this->titles[1] = addslashes($this->titles[1]);
         $this->titles[2] = addslashes($this->titles[2]);
         $this->titles[3] = addslashes($this->titles[3]);
         $this->nbr_in_serie = addslashes($this->nbr_in_serie);
         $this->year = addslashes($this->year);
         $this->page_nbr = addslashes($this->page_nbr);
         $this->illustration = addslashes($this->illustration);
         $this->size = addslashes($this->size);
         $this->accompagnement = addslashes($this->accompagnement);
         $this->nbr_in_collection = addslashes($this->nbr_in_collection);
         $this->mention_edition = addslashes($this->mention_edition);
         $this->general_note = addslashes($this->general_note);
         $this->content_note = addslashes($this->content_note);
         $this->abstract_note = addslashes($this->abstract_note);
         $this->commentaire_gestion = addslashes($this->commentaire_gestion);
         $this->indexation_lang = addslashes($this->indexation_lang);
         $this->thumbnail_url = addslashes($this->thumbnail_url);
         $this->free_index = addslashes($this->free_index);
         $this->link_url = addslashes($this->link_url);
         $this->link_format = addslashes($this->link_format);
         $this->prix = addslashes($this->prix);
         //les oubliés du premier tour
         $serie_id = addslashes($serie_id);
         $this->bibliographic_level = addslashes($this->bibliographic_level);
         $this->hierarchic_level = addslashes($this->hierarchic_level);
         $date_parution_z3950 = addslashes($date_parution_z3950);
     }
     $sql_ins = "insert into notices (\n\t\t\ttypdoc          ,\n\t\t\tcode        \t,\n\t\t\ttit1            ,\n\t\t\ttit2            ,\n\t\t\ttit3            ,\n\t\t\ttit4            ,\n\t\t\ttparent_id      ,\n\t\t\ttnvol           ,\n\t\t\ted1_id          ,\n\t\t\ted2_id          ,\n\t\t\tyear            ,\n\t\t\tnpages          ,\n\t\t\till             ,\n\t\t\tsize            ,\n\t\t\taccomp          ,\n\t\t\tcoll_id         ,\n\t\t\tsubcoll_id      ,\n\t\t\tnocoll          ,\n\t\t\tmention_edition ,\n\t\t\tn_gen           ,\n\t\t\tn_contenu       ,\n\t\t\tn_resume        ,\n\t\t\tindexint,\n\t\t\tstatut,\n\t\t\tcommentaire_gestion,\n\t\t\tsignature,\n\t\t\tthumbnail_url,\n\t\t\tindex_l,\n\t\t\tniveau_biblio,\n\t\t\tniveau_hierar,\n\t\t\tlien,\n\t\t\teformat,\n\t\t\torigine_catalogage,\n\t\t\tprix,\n\t\t\tcreate_date,\n\t\t\tdate_parution,\n\t\t\tindexation_lang\n\t\t\t) values (\n\t\t\t'" . $this->document_type . "',\t\n\t\t\t'" . $this->isbn . "',\t\n\t\t\t'" . $this->titles[0] . "',\n\t\t\t'" . $this->titles[1] . "',\n\t\t\t'" . $this->titles[2] . "',\n\t\t\t'" . $this->titles[3] . "',\n\t\t\t'" . $serie_id . "',\n\t\t\t'" . $this->nbr_in_serie . "',\n\t\t\t" . $editor_ids[0] . " ,\n\t\t\t" . $editor_ids[1] . " ,\n\t\t\t'" . $this->year . "',\n\t\t\t'" . $this->page_nbr . "',\n\t\t\t'" . $this->illustration . "',\n\t\t\t'" . $this->size . "',\n\t\t\t'" . $this->accompagnement . "',\n\t\t\t" . $collection_id . " ,\n\t\t\t" . $subcollection_id . " ,\n\t\t\t'" . $this->nbr_in_collection . "',\n\t\t\t'" . $this->mention_edition . "',\n\t\t\t'" . $this->general_note . "',\n\t\t\t'" . $this->content_note . "',\n\t\t\t'" . $this->abstract_note . "',\n\t\t\t'" . $this->internal_index . "',\n\t\t\t'" . $this->statut . "',\n\t\t\t'" . $this->commentaire_gestion . "',\n\t\t\t'" . $this->signature . "',\n\t\t\t'" . $this->thumbnail_url . "',\n\t\t\t'" . clean_tags($this->free_index) . "',\n\t\t\t'" . $this->bibliographic_level . "',\n\t\t\t'" . $this->hierarchic_level . "',\n\t\t\t'" . $this->link_url . "',\n\t\t\t'" . $this->link_format . "',\n\t\t\t'" . $this->orinot_id . "',\n\t\t\t'" . $this->prix . "',\n\t\t\tsysdate(),\n\t\t\t'" . $date_parution_z3950 . "',\n\t\t\t'" . $this->indexation_lang . "'\n\t\t )";
     $sql_result_ins = pmb_mysql_query($sql_ins) or die("Couldn't insert into table notices : " . $sql_ins);
     $notice_retour = pmb_mysql_insert_id();
     audit::insert_creation(AUDIT_NOTICE, $notice_retour);
     if ($gestion_acces_active == 1) {
         $ac = new acces();
         //traitement des droits acces user_notice
         if ($gestion_acces_user_notice == 1) {
             $dom_1 = $ac->setDomain(1);
             $dom_1->storeUserRights(0, $notice_retour);
         }
         //traitement des droits acces empr_notice
         if ($gestion_acces_empr_notice == 1) {
             $dom_2 = $ac->setDomain(2);
             $dom_2->storeUserRights(0, $notice_retour);
         }
     }
     // purge de la base des responsabilités de la notice intégrée...
     if ($notice_retour) {
         $rqt_del = "delete from responsability where responsability_notice='{$notice_retour}'";
         $sql_result_del = pmb_mysql_query($rqt_del) or die("Couldn't purge table responsability : " . $rqt_del);
     }
     $rqt_ins = "insert into responsability (responsability_author, responsability_notice, responsability_fonction, responsability_type, responsability_ordre ) VALUES ";
     for ($i = 0; $i < sizeof($this->aut_array); $i++) {
         $aut['id'] = clean_string($this->aut_array[$i]['id']);
         $aut['name'] = clean_string($this->aut_array[$i]['entree']);
         $aut['rejete'] = clean_string($this->aut_array[$i]['rejete']);
         $aut['date'] = clean_string($this->aut_array[$i]['date']);
         $aut['type'] = $this->aut_array[$i]['type_auteur'];
         $aut['subdivision'] = clean_string($this->aut_array[$i]['subdivision']);
         $aut['numero'] = clean_string($this->aut_array[$i]['numero']);
         $aut['lieu'] = clean_string($this->aut_array[$i]['lieu']);
         $aut['ville'] = clean_string($this->aut_array[$i]['ville']);
         $aut['pays'] = clean_string($this->aut_array[$i]['pays']);
         $aut['web'] = clean_string($this->aut_array[$i]['web']);
         $aut['author_comment'] = clean_string($this->aut_array[$i]['author_comment']);
         $aut['authority_number'] = clean_string($this->aut_array[$i]['authority_number']);
         /* Origine de l'autorité : on reprend les infos d'origine de la notice pour les attribuées aux origines des autorités */
         $id_origine_auth = 0;
         $id_origine_auth = origin_authorities::import($this->origine_notice);
         if ($id_origine_auth == 0) {
             $id_origine_auth = 1;
         }
         // import de l'autorité auteur si elle existe et conservation des infos sur l'origine de l'autorité
         if ($aut['authority_number'] != '' && $id_origine_auth) {
             $this->aut_array[$i]["id"] = $this->insert_authority_infos($aut['authority_number'], "author", $id_origine_auth, $aut);
         }
         if (!$this->aut_array[$i]["id"]) {
             $this->aut_array[$i]["id"] = auteur::import($aut);
         }
         if ($this->aut_array[$i]["id"]) {
             $rqt = $rqt_ins . " (" . $this->aut_array[$i]["id"] . "," . $notice_retour . ",'" . $this->aut_array[$i]['fonction'] . "'," . $this->aut_array[$i]['responsabilite'] . "," . $i . ") ";
             $res_ins = pmb_mysql_query($rqt, $dbh);
         }
     }
     // traitement des titres uniformes
     global $pmb_use_uniform_title;
     if ($pmb_use_uniform_title) {
         if (count($this->titres_uniformes)) {
             $ntu = new tu_notice($notice_retour);
             $ntu->update($this->titres_uniformes);
         }
     }
     // traitement des langues
     // langues de la publication
     $rqt_del = "delete from notices_langues where num_notice='{$notice_retour}' ";
     $res_del = pmb_mysql_query($rqt_del, $dbh);
     if (is_array($this->language_code) && count($this->language_code)) {
         $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES ";
         foreach ($this->language_code as $ordre_lang => $code_lang) {
             if ($code_lang) {
                 $rqt = $rqt_ins . " ('{$notice_retour}',0, '{$code_lang}', {$ordre_lang}) ";
                 $res_ins = @pmb_mysql_query($rqt, $dbh);
             }
         }
     }
     // langues originales
     if (is_array($this->original_language_code) && count($this->original_language_code)) {
         $rqt_ins = "insert into notices_langues (num_notice, type_langue, code_langue, ordre_langue) VALUES ";
         foreach ($this->original_language_code as $ordre_lang => $code_lang) {
             if ($code_lang) {
                 $rqt = $rqt_ins . " ('{$notice_retour}',1, '{$code_lang}', {$ordre_lang}) ";
                 $res_ins = @pmb_mysql_query($rqt, $dbh);
             }
         }
     }
     // traitement des categories
     if ($this->categorisation_type == "categorisation_auto") {
         traite_categories_enreg($notice_retour, $this->categories);
     } else {
         $rqt_del = "delete from notices_categories where notcateg_notice='{$notice_retour}' ";
         $res_del = @pmb_mysql_query($rqt_del, $dbh);
         $rqt_ins = "insert into notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ";
         $rqt_ins_values = array();
         foreach ($this->categories as $i => $category) {
             $id_categ = $category['categ_id'];
             if ($id_categ) {
                 $rqt_ins_values[] = " ('{$notice_retour}','{$id_categ}', {$i}) ";
             }
         }
         $rqt_ins .= implode(",", $rqt_ins_values);
         $res_ins = @pmb_mysql_query($rqt_ins, $dbh);
     }
     //Traitement des champs personnalisés (du formulaire !!!)
     $p_perso = new parametres_perso("notices");
     $nberrors = $p_perso->check_submited_fields();
     $p_perso->rec_fields_perso($notice_retour);
     //Traitement import perso
     global $notice_id, $notice_org, $notice_type_org;
     if (function_exists('z_recup_noticeunimarc_suite') && function_exists('z_import_new_notice_suite')) {
         $notice_id = $notice_retour;
         if (!$notice_org) {
             $notice_tmp = $this->notice;
         }
         z_recup_noticeunimarc_suite($notice_tmp ? $notice_tmp : $notice_org);
         z_import_new_notice_suite();
         $notice_tmp = "";
     }
     //Recherche du titre uniforme automatique
     //global $opac_enrichment_bnf_sparql;
     //$opac_enrichment_bnf_sparql=1;
     $titre_uniforme = notice::getAutomaticTu($notice_retour);
     //Traitement upload vignette
     if (trim($this->flag_upload_vignette)) {
         $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'";
         $res = pmb_mysql_query($req, $dbh);
         if (pmb_mysql_num_rows($res)) {
             $rep = pmb_mysql_fetch_object($res);
         }
         //le fichier
         if (file_exists($rep->repertoire_path . $this->flag_upload_vignette)) {
             rename($rep->repertoire_path . $this->flag_upload_vignette, $rep->repertoire_path . "img_" . $notice_retour);
         }
         //le champ
         $rqt_upd = "UPDATE notices SET thumbnail_url='" . addslashes($opac_url_base . "getimage.php?noticecode=&vigurl=&notice_id=" . $notice_retour) . "' WHERE notice_id=" . $notice_retour;
         $res_ins = @pmb_mysql_query($rqt_upd, $dbh);
     }
     // Mise à jour des index de la notice
     notice::majNotices($notice_retour);
     // Mise à jour de la table notices_global_index
     notice::majNoticesGlobalIndex($notice_retour);
     // Mise à jour de la table notices_mots_global_index
     notice::majNoticesMotsGlobalIndex($notice_retour);
     //Calcul de la signature
     $sign = new notice_doublon();
     $val = $sign->gen_signature($notice_retour);
     pmb_mysql_query("update notices set signature='{$val}' where notice_id=" . $notice_retour, $dbh);
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf = new synchro_rdf();
     }
     //Si on catalogue un article on recrée l'arborescence
     global $biblio_notice;
     //TODO AR
     //gérer le cas du bulletin (revient à intégrer le pério uniquement)
     if ($biblio_notice == 'art') {
         //Perios
         if (!$this->perio_id) {
             $new_perio = new serial();
             $values = array();
             $values['tit1'] = $this->perio_titre;
             $values['code'] = $this->perio_issn;
             $values['niveau_biblio'] = "s";
             $values['niveau_hierar'] = "1";
             $this->perio_id = $new_perio->update($values);
             //synchro_rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf->addRdf($this->perio_id, 0);
             }
         }
         //Bulletin
         if ($this->bull_id) {
             $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "',\n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'";
             pmb_mysql_query($req_art, $dbh);
             $req = "update bulletins set bulletin_notice='" . $this->perio_id . "' where bulletin_id='" . $this->bull_id . "'";
             pmb_mysql_query($req, $dbh);
         } else {
             $new_bull = new bulletinage(0, $this->perio_id);
             $values = array();
             $values['bul_no'] = $this->bull_num;
             $values['bul_date'] = $this->bull_mention;
             $values['date_date'] = $this->bull_date;
             $values['bul_titre'] = $this->bull_titre;
             $new_bull->update($values);
             $this->bull_id = $new_bull->bulletin_id;
             $req_art = "insert into analysis set analysis_bulletin='" . $this->bull_id . "',\n\t\t\t\t\tanalysis_notice='" . $notice_retour . "'";
             pmb_mysql_query($req_art, $dbh);
             //synchro_rdf
             if ($pmb_synchro_rdf) {
                 $synchro_rdf->addRdf(0, $this->bull_id);
             }
         }
     } else {
         if ($biblio_notice == "bull") {
             //Perios
             if (!$this->perio_id) {
                 $new_perio = new serial();
                 $values = array();
                 $values['tit1'] = $this->perio_titre;
                 $values['code'] = $this->perio_issn;
                 $values['niveau_biblio'] = "s";
                 $values['niveau_hierar'] = "1";
                 $this->perio_id = $new_perio->update($values);
                 //synchro_rdf
                 if ($pmb_synchro_rdf) {
                     $synchro_rdf->addRdf($this->perio_id, 0);
                 }
             }
             if (!$this->bull_id) {
                 $new_bull = new bulletinage(0, $this->perio_id);
                 $values = array();
                 $values['bul_no'] = $this->bull_num;
                 $values['bul_date'] = $this->bull_mention;
                 $values['date_date'] = $this->bull_date;
                 $values['bul_titre'] = $this->bull_titre;
                 $new_bull->update($values);
                 $this->bull_id = $new_bull->bulletin_id;
                 //synchro_rdf
                 if ($pmb_synchro_rdf) {
                     $synchro_rdf->addRdf(0, $this->bull_id);
                 }
                 // 				$req = "update bulletins set bulletin_notice='".$this->perio_id."',num_notice='".$notice_retour."'  where bulletin_id='".$this->bull_id."'";
                 // 				pmb_mysql_query($req,$dbh);				//Faire un update en mettant l'id de la notice crée
                 //file_put_contents('php://stderr', print_r($this->bull_id, true));
             }
             if ($this->bull_notice) {
                 $notice_bulletin = new notice();
                 $notice_bulletin->del_notice($notice_retour);
                 $notice_retour = $this->bull_notice;
             }
             //Mise à jour de la table bulletins, ajout de la relation entre le bulletins et sa notice
             $req = "update bulletins set bulletin_notice='" . $this->perio_id . "',num_notice='" . $notice_retour . "'  where bulletin_id='" . $this->bull_id . "'";
             pmb_mysql_query($req, $dbh);
             //Insertion dans la table notices_relation, ajout de la relatioin entre la notice de bulletin et la notice de perio
             $req = "insert into notices_relations (num_notice, linked_notice, relation_type,rank) values('" . $notice_retour . "', '" . $this->perio_id . "', 'b','1')";
             pmb_mysql_query($req, $dbh);
         }
     }
     //file_put_contents('php://stderr', print_r($notice_retour."\n", true));
     //Exemplaires
     if (count($this->exemplaires)) {
         //			global $section_995, $typdoc_995, $codstatdoc_995;
         // 			, $nb_expl_ignores;
         $section_995_ = new marc_list("section_995");
         $section_995 = $section_995_->table;
         $typdoc_995_ = new marc_list("typdoc_995");
         $typdoc_995 = $typdoc_995_->table;
         $codstatdoc_995_ = new marc_list("codstatdoc_995");
         $codstatdoc_995 = $codstatdoc_995_->table;
         // 			$nb_expl_ignores=0;
         global $deflt_docs_statut, $deflt_docs_location, $deflt_lenders;
         foreach ($this->exemplaires as $info_expl) {
             /* RAZ expl */
             $expl = array();
             if ($notice_retour) {
                 /* préparation du tableau à passer à la méthode */
                 $expl['cb'] = $info_expl['f'];
                 //TODO AR
                 // les raccrocher au bulletin et non sa notice
                 // dans un second temps
                 if ($this->bibliographic_level == "s" && $this->hierarchic_level == "2") {
                     if ($this->bull_id) {
                         $expl['notice'] = 0;
                         $expl['bulletin'] = $this->bull_id;
                     } else {
                         if (!$this->bull_id && $notice_retour) {
                             $expl['notice'] = $notice_retour;
                             $expl['bulletin'] = 0;
                         }
                     }
                 } else {
                     $expl['notice'] = $notice_retour;
                     $expl['bulletin'] = 0;
                 }
                 //$expl['bulletin']	= 0;
                 // $expl['typdoc']     = $info_995['r']; à chercher dans docs_typdoc
                 $data_doc = array();
                 //$data_doc['tdoc_libelle'] = $info_995['r']." -Type doc importé (".$book_lender_id.")";
                 $data_doc['tdoc_libelle'] = $typdoc_995[$info_expl['r']];
                 if (!$data_doc['tdoc_libelle']) {
                     $data_doc['tdoc_libelle'] = "\$r non conforme -" . $info_expl['r'] . "-";
                 }
                 $data_doc['duree_pret'] = 0;
                 /* valeur par défaut */
                 $data_doc['tdoc_codage_import'] = $info_expl['r'];
                 if ($tdoc_codage) {
                     $data_doc['tdoc_owner'] = $deflt_lenders;
                 } else {
                     $data_doc['tdoc_owner'] = 0;
                 }
                 $expl['typdoc'] = docs_type::import($data_doc);
                 $expl['cote'] = $info_expl['k'];
                 // $expl['section']    = $info_995['q']; à chercher dans docs_section
                 $data_doc = array();
                 $info_expl['q'] = trim($info_expl['q']);
                 if (!$info_expl['q']) {
                     $info_expl['q'] = "u";
                 }
                 $data_doc['section_libelle'] = $section_995[$info_expl['q']];
                 $data_doc['sdoc_codage_import'] = $info_expl['q'];
                 if ($sdoc_codage) {
                     $data_doc['sdoc_owner'] = $deflt_lenders;
                 } else {
                     $data_doc['sdoc_owner'] = 0;
                 }
                 $expl['section'] = docs_section::import($data_doc);
                 $expl['statut'] = $deflt_docs_statut;
                 if ($info_expl['a']) {
                     $expl['location'] = $info_expl['a'];
                 } else {
                     $expl['location'] = $deflt_docs_location;
                 }
                 // $expl['codestat']   = $info_995['q']; 'q' utilisé, éventuellement à fixer par combo_box
                 $data_doc = array();
                 //$data_doc['codestat_libelle'] = $info_995['q']." -Pub visé importé (".$book_lender_id.")";
                 $data_doc['codestat_libelle'] = $codstatdoc_995[$info_expl['q']];
                 $data_doc['statisdoc_codage_import'] = $info_expl['q'];
                 if ($statisdoc_codage) {
                     $data_doc['statisdoc_owner'] = $deflt_lenders;
                 } else {
                     $data_doc['statisdoc_owner'] = 0;
                 }
                 $expl['codestat'] = docs_codestat::import($data_doc);
                 $expl['note'] = $info_expl['u'];
                 $expl['expl_owner'] = $deflt_lenders;
                 if ($info_expl['m']) {
                     $expl['date_depot'] = substr($info_expl['m'], 0, 4) . "-" . substr($info_expl['m'], 4, 2) . "-" . substr($info_expl['m'], 6, 2);
                 }
                 if ($info_expl['n']) {
                     $expl['date_retour'] = substr($info_expl['n'], 0, 4) . "-" . substr($info_expl['n'], 4, 2) . "-" . substr($info_expl['n'], 6, 2);
                 }
                 exemplaire::import($expl);
             }
         }
     }
     //Documents numériques
     global $deflt_explnum_statut;
     foreach ($this->doc_nums as $doc_num) {
         if (!$doc_num['a']) {
             continue;
         }
         if (!$doc_num['s']) {
             $doc_num['s'] = $deflt_explnum_statut;
         }
         if ($doc_num['__nodownload__']) {
             if ($this->bibliographic_level == "b" && $this->hierarchic_level == "2") {
                 explnum_add_url($notice_retour, $this->bull_id, $doc_num['b'], $doc_num['a'], $doc_num['s']);
             } else {
                 explnum_add_url($notice_retour, 0, $doc_num['b'], $doc_num['a'], $doc_num['s']);
             }
         } else {
             if ($this->bibliographic_level == "b" && $this->hierarchic_level == "2") {
                 explnum_add_from_url($notice_retour, $this->bull_id, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p'], $doc_num['s']);
             } else {
                 explnum_add_from_url($notice_retour, 0, $doc_num['b'], $doc_num['a'], true, $this->source_id, $doc_num['f'], $doc_num['p'], $doc_num['s']);
             }
         }
     }
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         $synchro_rdf->addRdf($notice_retour, 0);
     }
     $retour = array($new_notice, $notice_retour);
     return $retour;
 }
Example #17
0
 function create_notice()
 {
     global $dbh, $iddemande;
     global $demandes_statut_notice, $pmb_type_audit;
     // creation notice à partir de la demande
     $req = "insert into notices set\n\t\t\t\ttit1='" . $this->titre_demande . "',\n\t\t\t\tn_contenu='" . $this->sujet_demande . "',\n\t\t\t\tstatut ='" . $demandes_statut_notice . "'\n\t\t\t\t";
     pmb_mysql_query($req, $dbh);
     $id_notice = pmb_mysql_insert_id();
     notice::majNotices($id_notice);
     if ($pmb_type_audit) {
         audit::insert_creation(AUDIT_NOTICE, $id_notice);
     }
     // mise à jour de la demande
     $req = "UPDATE demandes SET num_notice=" . $id_notice . " WHERE id_demande=" . $this->id_demande;
     pmb_mysql_query($req, $dbh);
     $this->num_notice = $id_notice;
 }
Example #18
0
 function import($data)
 {
     global $dbh;
     // check sur le type de  la variable passee en parametre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         return 0;
     }
     // tentative de recuperer l'id associee dans la base (implique que l'autorite existe)
     // preparation de la requeªte
     $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT ed_name FROM publishers limit 1"), 0);
     $key = addslashes(rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi)));
     $ville = addslashes(trim($data['ville']));
     $adr = addslashes(trim($data['adr']));
     $adr2 = addslashes(trim($data['adr2']));
     $cp = addslashes(trim($data['cp']));
     $pays = addslashes(trim($data['pays']));
     $web = addslashes(trim($data['web']));
     $ed_comment = addslashes(trim($data['ed_comment']));
     if ($key == "") {
         return 0;
     }
     /* on laisse tomber les editeurs sans nom !!! exact. FL*/
     $query = "SELECT ed_id FROM publishers WHERE ed_name='{$key}' and ed_ville = '{$ville}' ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT publisher " . $query);
     }
     // resultat
     // recuperation du resultat de la recherche
     $tediteur = pmb_mysql_fetch_object($result);
     // et recuperation eventuelle de l'id
     if ($tediteur->ed_id) {
         return $tediteur->ed_id;
     }
     // id non-recuperee, il faut creer la forme.
     $query = "INSERT INTO publishers SET ed_name='{$key}', ed_ville = '{$ville}', ed_adr1 = '{$adr}', ed_comment='" . $ed_comment . "', ed_adr2='" . $adr2 . "', ed_cp='" . $cp . "', ed_pays='" . $pays . "', ed_web='" . $web . "', index_publisher=' " . strip_empty_chars($key) . " ' ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into publisher : " . $query);
     }
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_PUBLISHER, $id);
     return $id;
 }
Example #19
0
 static function import($title, $statut = 1)
 {
     global $dbh;
     // check sur la variable passée en paramètre
     if (!$title) {
         return 0;
     }
     // tentative de récupérer l'id associée dans la base (implique que l'autorité existe)
     // préparation de la requête
     $key = addslashes($title);
     $query = "SELECT serie_id FROM series WHERE serie_name='" . rtrim(substr($key, 0, 255)) . "' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT series " . $query);
     }
     // résultat
     // récupération du résultat de la recherche
     $tserie = pmb_mysql_fetch_object($result);
     // du résultat et récupération éventuelle de l'id
     if ($tserie->serie_id) {
         return $tserie->serie_id;
     }
     // id non-récupérée, il faut créer la forme.
     $index = addslashes(strip_empty_words($title));
     $query = 'INSERT INTO series SET serie_name="' . $key . '", serie_index=" ' . $index . ' "';
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into series" . $query);
     }
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_SERIE, $id);
     //update authority informations
     $authority = new authority(0, $id, AUT_TABLE_SERIES);
     $authority->set_num_statut($statut);
     $authority->update();
     serie::update_index($id);
     return $id;
 }
Example #20
0
 $requete .= ", niveau_hierar='{$t_notice['h_level']}'";
 $requete .= ", statut='{$t_notice['statut']}'";
 $requete .= ", commentaire_gestion='{$t_notice['commentaire_gestion']}'";
 $requete .= ", thumbnail_url='{$t_notice['thumbnail_url']}'";
 $requete .= ", signature='{$t_notice['signature']}'";
 $requete .= ", date_parution='{$date_parution_notice}'";
 $requete .= ", indexation_lang='{$t_notice['indexation_lang']}'";
 $requete .= ", notice_is_new='{$t_notice['notice_is_new']}'";
 $requete .= $req_notice_date_is_new;
 $requete .= $postrequete;
 $result = pmb_mysql_query($requete, $dbh);
 //traitement audit
 if (!$id) {
     $sav_id = 0;
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_NOTICE, $id);
 } else {
     $sav_id = $id;
     audit::insert_modif(AUDIT_NOTICE, $id);
 }
 // autorité personnalisées
 $authperso = new authperso_notice($id);
 $authperso->save_form();
 // map
 global $pmb_map_activate;
 if ($pmb_map_activate) {
     $map = new map_edition_controler(TYPE_RECORD, $id);
     $map->save_form();
     $map_info = new map_info($id);
     $map_info->save_form();
 }
Example #21
0
 }
 if (!$id_notice) {
     die('ERROR PE: aucun id_notice pour exemplaire...');
 }
 // exemplaire express
 if ($pe_excb == "") {
     $pe_excb = 'PE' . rand(0, 100000);
 }
 $requete = "INSERT INTO exemplaires\n\t\t\t\t\t\t\t\tSET expl_cb='{$pe_excb}',\n\t\t\t\t\t\t\t\t\texpl_notice='{$id_notice}',\n\t\t\t\t\t\t\t\t\texpl_typdoc='{$pe_tdoc}',\n\t\t\t\t\t\t\t\t\texpl_location='{$deflt_docs_location}',\n\t\t\t\t\t\t\t\t\texpl_section='{$deflt_docs_section}',\n\t\t\t\t\t\t\t\t\texpl_statut='{$deflt_docs_statut}',\n\t\t\t\t\t\t\t\t\texpl_codestat='{$deflt_docs_codestat}',\n\t\t\t\t\t\t\t\t\texpl_owner='{$deflt_lenders}',\n\t\t\t\t\t\t\t\t\tcreate_date=CURRENT_TIMESTAMP()\n\t\t\t\t\t\t\t\t\t";
 $result = pmb_mysql_query($requete, $dbh);
 if (!$result) {
     error_message($msg[350], $msg['pecb_already_exist'], 1, '');
     exit;
 }
 $id_expl = pmb_mysql_insert_id();
 audit::insert_creation(AUDIT_EXPL, $id_expl);
 if (preg_match('/^PE/', $pe_excb)) {
     //redefine exemplaires.expl_cb if $pe_excb is random
     $pe_excb = 'PE' . $id_expl;
     $requete = "UPDATE exemplaires SET expl_cb='{$pe_excb}' WHERE expl_id='{$id_expl}'";
     $result = pmb_mysql_query($requete, $dbh);
     if (!$result) {
         die('ERROR PE: update exemplaires');
     }
 }
 $cb_doc = $pe_excb;
 $rqtstatut = "select gestion_libelle from notice_statut where id_notice_statut='{$pmb_pret_express_statut}' ";
 $resstatut = pmb_mysql_fetch_object(pmb_mysql_query($rqtstatut, $dbh));
 $noteexpress = addslashes($resstatut->gestion_libelle);
 $requete = "UPDATE exemplaires SET expl_note='{$noteexpress}' WHERE expl_id='{$id_expl}'";
 $result = pmb_mysql_query($requete, $dbh);
Example #22
0
 function import($data)
 {
     global $msg;
     // cette méthode prend en entrée un tableau constitué des informations exemplaires suivantes :
     //	$data['cb']
     //	$data['notice']
     //  $data['bulletin']
     //	$data['typdoc']
     //	$data['cote']
     //	$data['section']
     //	$data['statut']
     //	$data['location']
     //	$data['codestat']
     //	$data['creation']
     //	$data['modif']
     //	$data['note']
     //	$data['prix']
     //	$data['expl_owner']
     //	$data['cote_mandatory'] cote obligatoire = 1, non obligatoire = 0
     //	$data['quoi_faire'] que faire de cet exemplaire :
     //		0 : supprimer, 1 ou vide : Mettre à jour ou ajouter, 2 : ajouter si possible, sinon rien.
     global $dbh;
     // check sur le type de  la variable passée en paramètre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[544] . "') ");
         return 0;
     }
     if ($data['quoi_faire'] == "") {
         $data['quoi_faire'] = "2";
     }
     if ((string) $data['quoi_faire'] == "0") {
         $sql_del = "delete from exemplaires where expl_cb='" . addslashes($data['cb']) . "' ";
         pmb_mysql_query($sql_del);
         return -1;
     }
     // check sur les éléments du tableau (cb, cote, notice, typdoc, section, statut, location, codestat, owner sont requis).
     $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT expl_cb FROM exemplaires limit 1"), 0);
     $data['cb'] = rtrim(substr(trim($data['cb']), 0, $long_maxi));
     $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT expl_cote FROM exemplaires limit 1"), 0);
     $data['cote'] = rtrim(substr(trim($data['cote']), 0, $long_maxi));
     $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT expl_prix FROM exemplaires limit 1"), 0);
     $data['prix'] = rtrim(substr(trim($data['prix']), 0, $long_maxi));
     if ($data['expl_owner'] == "") {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', 'No lender given') ");
         return 0;
     }
     if ($data['cb'] == "") {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[545] . "') ");
         return 0;
     }
     if ($data['cote'] == "") {
         if ($data['cote_mandatory'] == 1) {
             $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[546] . "') ");
             return 0;
         } else {
             $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[567] . "') ");
         }
     }
     if ($data['notice'] == 0) {
         if ($data['bulletin'] == 0) {
             $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[547] . "') ");
             return 0;
         }
     }
     if ($data['typdoc'] == 0) {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[548] . "') ");
         return 0;
     }
     if ($data['section'] == 0) {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[549] . "') ");
         return 0;
     }
     if ($data['statut'] == 0) {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[550] . "') ");
         return 0;
     }
     if ($data['location'] == 0) {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[551] . "') ");
         return 0;
     }
     if ($data['codestat'] == 0) {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[552] . "') ");
         return 0;
     }
     if ($data['type_antivol'] == "") {
         $data['type_antivol'] = "1";
     }
     // préparation de la requête
     $key0 = addslashes($data['cb']);
     $key1 = addslashes($data['cote']);
     /* vérification que l'exemplaire existe ou pas */
     $exe = new stdClass();
     $query = "SELECT expl_id FROM exemplaires WHERE expl_cb='{$key0}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT exemplaires " . $query);
     }
     if (pmb_mysql_num_rows($result)) {
         $exe = pmb_mysql_fetch_object($result);
     }
     if (!$data['date_depot']) {
         $data['date_depot'] = "sysdate()";
     } else {
         $data['date_depot'] = "'" . $data['date_depot'] . "'";
     }
     if (!$data['date_retour']) {
         $data['date_retour'] = "sysdate()";
     } else {
         $data['date_retour'] = "'" . $data['date_retour'] . "'";
     }
     // l'exemplaire existe et on ne pouvait que l'ajouter, on retourne l'ID
     if ($exe->expl_id != "" && $data['quoi_faire'] == "2") {
         $sql_log = pmb_mysql_query("insert into error_log (error_origin, error_text) values ('expl_" . addslashes(SESSid) . ".class', '" . $msg[553] . $data['cb'] . "') ");
         return $exe->expl_id;
     }
     // l'exemplaire existe et on doit le mettre à jour
     if ($exe->expl_id != "" && $data['quoi_faire'] == "1") {
         $sql_a_faire = "update exemplaires SET ";
         $sql_a_faire_suite = " where expl_cb='" . addslashes($data['cb']) . "' ";
     }
     // l'exemplaire n'existe pas : on doit le créer
     if ($exe->expl_id == "") {
         $sql_a_faire = "insert into exemplaires SET ";
         $sql_a_faire_suite = "";
     }
     $query = $sql_a_faire;
     $query .= "expl_cb='" . $key0 . "', ";
     $query .= "expl_notice='" . $data['notice'] . "', ";
     $query .= "expl_bulletin='" . $data['bulletin'] . "', ";
     $query .= "expl_typdoc='" . $data['typdoc'] . "', ";
     $query .= "expl_cote=trim('" . $key1 . "'), ";
     $query .= "expl_section='" . $data['section'] . "', ";
     $query .= "expl_statut='" . $data['statut'] . "', ";
     $query .= "expl_location='" . $data['location'] . "', ";
     $query .= "expl_codestat='" . $data['codestat'] . "', ";
     $query .= "expl_note='" . addslashes($data['note']) . "', ";
     $query .= "expl_comment='" . addslashes($data['comment']) . "', ";
     $query .= "expl_prix='" . addslashes($data['prix']) . "', ";
     $query .= "expl_owner='" . $data['expl_owner'] . "', ";
     $query .= "expl_date_depot=" . $data['date_depot'] . ", ";
     $query .= "expl_date_retour=" . $data['date_retour'] . ", ";
     $query .= "transfert_location_origine = " . $data['location'] . ", ";
     $query .= "transfert_statut_origine=" . $data['statut'] . ", ";
     $query .= "transfert_section_origine=" . $data['section'] . ", ";
     //$query .= "type_antivol=".$data['type_antivol'].", ";
     if ($data['creation']) {
         $query .= "create_date='" . $data['creation'] . "'";
     } else {
         $query .= "create_date=sysdate() ";
     }
     $query .= $sql_a_faire_suite;
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into exemplaires " . $query);
     }
     if ($exe->expl_id = "") {
         audit::insert_creation(AUDIT_EXPL, pmb_mysql_insert_id($dbh));
         return pmb_mysql_insert_id($dbh);
     } else {
         $sql_id = pmb_mysql_query("select expl_id from exemplaires where expl_cb='" . addslashes($data['cb']) . "' ");
         $exe = pmb_mysql_fetch_object($sql_id);
         audit::insert_modif(AUDIT_EXPL, $exe->expl_id);
         return $exe->expl_id;
     }
 }
function add_pret($id_empr, $id_expl, $cb_doc)
{
    // le lien MySQL
    global $dbh;
    global $msg;
    global $pmb_quotas_avances;
    /* on prépare la date de début*/
    $pret_date = time();
    /* on cherche la durée du prêt */
    if ($pmb_quotas_avances) {
        //Initialisation de la classe
        $qt = new quota("LEND_TIME_QUOTA");
        $struct["READER"] = $id_empr;
        $struct["EXPL"] = $id_expl;
        $duree_pret = $qt->get_quota_value($struct);
        if ($duree_pret == -1) {
            $duree_pret = 0;
        }
    } else {
        $query = "SELECT duree_pret";
        $query .= " FROM exemplaires, docs_type";
        $query .= " WHERE expl_id='" . $id_expl;
        $query .= "' and idtyp_doc=expl_typdoc LIMIT 1";
        $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query);
        $expl_properties = pmb_mysql_fetch_object($result);
        $duree_pret = $expl_properties->duree_pret;
    }
    // calculer la date de retour prévue
    $pret_retour = $pret_date + 3600 * 24 * $duree_pret;
    // insérer le prêt
    $query = "INSERT INTO pret SET ";
    $query .= "pret_idempr = '" . $id_empr . "', ";
    $query .= "pret_idexpl = '" . $id_expl . "', ";
    $query .= "pret_date   = sysdate(), ";
    $query .= "pret_retour = '" . date("Y-m-d", $pret_retour) . "', ";
    $query .= "retour_initial = '" . date("Y-m-d", $pret_retour) . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die(pmb_mysql_error() . "<br />can't INSERT into pret" . $query);
    // insérer la trace en stat, récupérer l'id et le mettre dans la table des prêts pour la maj ultérieure
    $stat_avant_pret = pret_construit_infos_stat($id_expl);
    $stat_id = stat_stuff($stat_avant_pret);
    $query = "update pret SET pret_arc_id='{$stat_id}' where ";
    $query .= "pret_idempr = '" . $id_empr . "' and ";
    $query .= "pret_idexpl = '" . $id_expl . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update pret for stats " . $query);
    audit::insert_creation(AUDIT_PRET, $stat_id);
    //enregistrer les champs perso pret
    $p_perso = new pret_parametres_perso("pret");
    $p_perso->rec_fields_perso($stat_id);
    $query = "update exemplaires SET ";
    $query .= "last_loan_date = sysdate() ";
    $query .= "where expl_id= '" . $id_expl . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in exemplaires : " . $query);
    $query = "update empr SET ";
    $query .= "last_loan_date = sysdate() ";
    $query .= "where id_empr= '" . $id_empr . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in empr : " . $query);
}
Example #24
0
 function save()
 {
     global $dbh, $num_cde, $num_dev;
     if (!$this->num_entite || !$this->num_fournisseur) {
         die("Erreur de création actes");
     }
     //récupération du libelle fournisseur
     $q = "select raison_sociale from entites where id_entite = '" . $this->num_fournisseur . "' ";
     $r = mysql_query($q, $dbh);
     $fou = mysql_result($r, 0, 0);
     if ($this->type_acte == TYP_ACT_CDE) {
         $num = trim($num_cde);
     } else {
         if ($this->type_acte == TYP_ACT_DEV) {
             $num = trim($num_dev);
         }
     }
     if ($this->id_acte) {
         if ($num != '') {
             $this->numero = $num;
         } else {
             $this->numero = addslashes($this->numero);
         }
         $q = "update actes set ";
         $q .= "numero = '" . $this->numero . "', ";
         $q .= "nom_acte = '" . $this->nom_acte . "', ";
         $q .= "statut = '" . $this->statut . "', ";
         $q .= "date_paiement = '" . $this->date_paiement . "', ";
         $q .= "num_paiement = '" . $this->num_paiement . "', ";
         $q .= "num_fournisseur = '" . $this->num_fournisseur . "', ";
         $q .= "num_contact_livr = '" . $this->num_contact_livr . "', ";
         $q .= "num_contact_fact = '" . $this->num_contact_fact . "', ";
         //TODO Voir suppression num_exercice
         $q .= "num_exercice = '" . $this->num_exercice . "', ";
         $q .= "commentaires = '" . $this->commentaires . "', ";
         $q .= "reference = '" . $this->reference . "', ";
         $q .= "commentaires_i = '" . $this->commentaires_i . "', ";
         $q .= "devise = '" . $this->devise . "', ";
         $q .= "date_ech = '" . $this->date_ech . "', ";
         $q .= "index_acte = ' " . $this->numero . " " . strip_empty_words($fou) . " " . strip_empty_words($this->commentaires) . " " . strip_empty_words($this->reference) . " ' ";
         $q .= "where id_acte = '" . $this->id_acte . "' ";
         $r = mysql_query($q, $dbh);
         audit::insert_modif(AUDIT_ACQUIS, $this->id_acte);
     } else {
         if ($num != '') {
             $this->numero = $num;
         } else {
             $this->calc();
         }
         $q = "insert into actes set type_acte = '" . $this->type_acte . "', ";
         $q .= "date_acte = '" . today() . "', ";
         $q .= "numero = '" . $this->numero . "', ";
         $q .= "nom_acte = '" . $this->nom_acte . "', ";
         $q .= "statut = '" . $this->statut . "', ";
         $q .= "date_paiement = '" . $this->date_paiement . "', ";
         $q .= "num_paiement = '" . $this->num_paiement . "', ";
         $q .= "num_entite = '" . $this->num_entite . "', ";
         $q .= "num_fournisseur = '" . $this->num_fournisseur . "', ";
         $q .= "num_contact_livr = '" . $this->num_contact_livr . "', ";
         $q .= "num_contact_fact = '" . $this->num_contact_fact . "', ";
         //TODO Voir suppression num_exercice
         $q .= "num_exercice = '" . $this->num_exercice . "', ";
         $q .= "commentaires = '" . $this->commentaires . "' , ";
         $q .= "reference = '" . $this->reference . "', ";
         $q .= "commentaires_i = '" . $this->commentaires_i . "', ";
         $q .= "devise = '" . $this->devise . "', ";
         $q .= "date_ech = '" . $this->date_ech . "', ";
         $q .= "index_acte = ' " . strip_empty_words($this->numero) . " " . strip_empty_words($fou) . " " . strip_empty_words($this->commentaires) . " " . strip_empty_words($this->reference) . " ' ";
         $r = mysql_query($q, $dbh);
         $this->id_acte = mysql_insert_id($dbh);
         audit::insert_creation(AUDIT_ACQUIS, $this->id_acte);
     }
 }
     $values .= ", expl_typdoc='{$expl_typdoc}'";
     $values .= ", expl_cote='{$expl_cote}'";
     $values .= ", expl_section='{$expl_section}'";
     $values .= ", expl_statut='{$expl_statut}'";
     $values .= ", expl_location='{$expl_location}' {$transfert_origine} ";
     $values .= ", expl_codestat='{$expl_codestat}'";
     $values .= ", expl_note='{$expl_note}'";
     $values .= ", expl_comment='{$expl_comment}'";
     $values .= ", expl_prix='{$expl_prix}'";
     $values .= ", expl_owner='{$expl_owner}'";
     $values .= ", type_antivol='{$type_antivol}'";
     $values .= ", expl_nbparts='{$f_ex_nbparts}'";
     $requete = "INSERT INTO exemplaires set {$values} , create_date=sysdate() ";
     $myQuery = pmb_mysql_query($requete, $dbh);
     $expl_id = pmb_mysql_insert_id();
     audit::insert_creation(AUDIT_EXPL, $expl_id);
 }
 if ($abt_id && $serial_circ_add) {
     $serialcirc_diff = new serialcirc_diff(0, $abt_id);
 }
 // Si c'est à faire circuler
 if ($serialcirc_diff->id) {
     $serialcirc_diff->add_circ_expl($expl_id);
 }
 // traitement des concepts
 if ($thesaurus_concepts_active == 1) {
     $index_concept = new index_concept($expl_id, TYPE_EXPL);
     $index_concept->save();
 }
 //Insertion des champs personalises
 $p_perso->rec_fields_perso($expl_id);
Example #26
0
function add_pret($id_empr, $id_expl, $cb_doc, $resarc_id = 0, $short_loan = 0)
{
    // le lien MySQL
    global $dbh, $msg;
    global $pmb_quotas_avances, $pmb_utiliser_calendrier;
    global $pmb_gestion_financiere, $pmb_gestion_tarif_prets;
    global $include_path, $lang;
    global $deflt2docs_location;
    global $pmb_pret_date_retour_adhesion_depassee;
    global $pmb_short_loan_management;
    global $pmb_transferts_actif;
    global $pmb_resa_planning;
    $resarc_id += 0;
    /* on prépare la date de début*/
    $pret_date = today();
    $duree_pret = 0;
    // calcul de la duree du pret si la date de fin est definie par les previsions
    if ($resarc_id && $pmb_resa_planning == 1) {
        $q = 'select datediff(resarc_fin,"' . $pret_date . '") from resa_archive where resarc_id =' . $resarc_id . ' and resarc_resa_planning_id_resa!=0 limit 1';
        $r = pmb_mysql_query($q, $dbh);
        if (pmb_mysql_num_rows($r)) {
            $duree_pret = pmb_mysql_result($r, 0, 0);
        }
    }
    if (!$duree_pret) {
        /* on cherche la durée du prêt */
        if ($pmb_short_loan_management && $short_loan) {
            if ($pmb_quotas_avances) {
                //Initialisation de la classe
                $qt = new quota("SHORT_LOAN_TIME_QUOTA");
                $struct["READER"] = $id_empr;
                $struct["EXPL"] = $id_expl;
                $duree_pret = $qt->get_quota_value($struct);
                if ($duree_pret == -1) {
                    $duree_pret = 0;
                }
            } else {
                $query = "SELECT short_loan_duration as duree_pret";
                $query .= " FROM exemplaires, docs_type";
                $query .= " WHERE expl_id='" . $id_expl;
                $query .= "' and idtyp_doc=expl_typdoc LIMIT 1";
                $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query);
                $expl_properties = pmb_mysql_fetch_object($result);
                $duree_pret = $expl_properties->duree_pret;
            }
        } else {
            if ($pmb_quotas_avances) {
                //Initialisation de la classe
                $qt = new quota("LEND_TIME_QUOTA");
                $struct["READER"] = $id_empr;
                $struct["EXPL"] = $id_expl;
                $duree_pret = $qt->get_quota_value($struct);
                if ($duree_pret == -1) {
                    $duree_pret = 0;
                }
            } else {
                $query = "SELECT duree_pret";
                $query .= " FROM exemplaires, docs_type";
                $query .= " WHERE expl_id='" . $id_expl;
                $query .= "' and idtyp_doc=expl_typdoc LIMIT 1";
                $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query);
                $expl_properties = pmb_mysql_fetch_object($result);
                $duree_pret = $expl_properties->duree_pret;
            }
        }
    }
    // calculer la date de retour prévue, tenir compte de la date de fin d'adhésion
    if (!$duree_pret) {
        $duree_pret = '0';
    }
    if ($pmb_pret_date_retour_adhesion_depassee) {
        $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY) as date_retour from empr where id_empr='" . $id_empr . "'";
    } else {
        $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),empr_date_expiration) as date_retour from empr where id_empr='" . $id_empr . "'";
    }
    $resultatdate = pmb_mysql_query($rqt_date) or die(pmb_mysql_error() . "<br /><br />{$rqt_date}<br /><br />");
    $res = pmb_mysql_fetch_object($resultatdate);
    $date_retour = $res->date_retour;
    $pret_depasse_adhes = $res->pret_depasse_adhes;
    $empr_date_expiration = $res->empr_date_expiration;
    if ($pmb_utiliser_calendrier) {
        if ($pret_depasse_adhes == 0 || $pmb_pret_date_retour_adhesion_depassee) {
            $rqt_date = "select date_ouverture from ouvertures where ouvert=1 and to_days(date_ouverture)>=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture ";
            $resultatdate = pmb_mysql_query($rqt_date);
            $res = @pmb_mysql_fetch_object($resultatdate);
            if ($res->date_ouverture) {
                $date_retour = $res->date_ouverture;
            }
        } else {
            $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture DESC";
            $resultatdate = pmb_mysql_query($rqt_date);
            $res = @pmb_mysql_fetch_object($resultatdate);
            if ($res->date_ouverture) {
                $date_retour = $res->date_ouverture;
            }
        }
        // Si la date_retour, calculée ci-dessus d'après le calendrier, dépasse l'adhésion, alors que c'est interdit,
        // la date de retour doit etre le dernier jour ouvert
        if (!$pmb_pret_date_retour_adhesion_depassee) {
            $rqt_date = "SELECT DATEDIFF('{$empr_date_expiration}','{$date_retour}')as diff";
            $resultatdate = pmb_mysql_query($rqt_date);
            $res = @pmb_mysql_fetch_object($resultatdate);
            if ($res->diff < 0) {
                $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$empr_date_expiration}') and num_location={$deflt2docs_location} order by date_ouverture DESC";
                $resultatdate = pmb_mysql_query($rqt_date);
                $res = @pmb_mysql_fetch_object($resultatdate);
                if ($res->date_ouverture) {
                    $date_retour = $res->date_ouverture;
                }
            }
        }
    }
    // insérer le prêt
    $query = "INSERT INTO pret SET ";
    $query .= "pret_idempr = '" . $id_empr . "', ";
    $query .= "pret_idexpl = '" . $id_expl . "', ";
    $query .= "pret_date   = sysdate(), ";
    $query .= "pret_retour = '{$date_retour}', ";
    $query .= "retour_initial = '{$date_retour}', ";
    $query .= "short_loan_flag = " . ($pmb_short_loan_management && $short_loan ? "'1'" : "'0'");
    $result = @pmb_mysql_query($query, $dbh) or die(pmb_mysql_error() . "<br />can't INSERT into pret" . $query);
    // insérer la trace en stat, récupérer l'id et le mettre dans la table des prêts pour la maj ultérieure
    $stat_avant_pret = pret_construit_infos_stat($id_expl);
    $stat_id = stat_stuff($stat_avant_pret);
    $query = "update pret SET pret_arc_id='{$stat_id}' where ";
    $query .= "pret_idempr = '" . $id_empr . "' and ";
    $query .= "pret_idexpl = '" . $id_expl . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update pret for stats " . $query);
    audit::insert_creation(AUDIT_PRET, $stat_id);
    //enregistrer les champs perso pret
    $p_perso = new pret_parametres_perso("pret");
    $p_perso->rec_fields_perso($stat_id);
    if ($resarc_id) {
        $rqt_arch = "UPDATE resa_archive SET resarc_arcpretid = {$stat_id} WHERE resarc_id = '" . $resarc_id . "' ";
        @pmb_mysql_query($rqt_arch, $dbh);
    }
    $query = "update exemplaires SET ";
    $query .= "last_loan_date = sysdate() ";
    $query .= "where expl_id= '" . $id_expl . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in exemplaires : " . $query);
    $query = "update exemplaires SET ";
    $query .= "expl_retloc=0 ";
    $query .= "where expl_id= '" . $id_expl . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update expl_retloc in exemplaires : " . $query);
    $query = "update empr SET ";
    $query .= "last_loan_date = sysdate() ";
    $query .= "where id_empr= '" . $id_empr . "' ";
    $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in empr : " . $query);
    $query = "delete from resa_ranger ";
    $query .= "where resa_cb='" . $cb_doc . "'";
    $result = @pmb_mysql_query($query, $dbh) or die("can't delete cb_doc in resa_ranger : " . $query);
    //Débit du compte lecteur si nécessaire
    if ($pmb_gestion_financiere && $pmb_gestion_tarif_prets) {
        $tarif_pret = 0;
        switch ($pmb_gestion_tarif_prets) {
            case 1:
                //Gestion simple
                $query = "SELECT tarif_pret";
                $query .= " FROM exemplaires, docs_type";
                $query .= " WHERE expl_id='" . $id_expl;
                $query .= "' and idtyp_doc=expl_typdoc LIMIT 1";
                $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query);
                $expl_tarif = pmb_mysql_fetch_object($result);
                $tarif_pret = $expl_tarif->tarif_pret;
                break;
            case 2:
                //Gestion avancée
                //Initialisation Quotas
                global $_parsed_quotas_;
                $_parsed_quotas_ = false;
                $qt_tarif = new quota("COST_LEND_QUOTA", "{$include_path}/quotas/own/{$lang}/finances.xml");
                $struct["READER"] = $id_empr;
                $struct["EXPL"] = $id_expl;
                $tarif_pret = $qt_tarif->get_quota_value($struct);
                break;
        }
        $tarif_pret = $tarif_pret * 1;
        if ($tarif_pret) {
            $compte_id = comptes::get_compte_id_from_empr($id_empr, 3);
            if ($compte_id) {
                $cpte = new comptes($compte_id);
                $explaire = new exemplaire('', $id_expl);
                if ($explaire->id_notice == 0 && $explaire->id_bulletin) {
                    //C'est un exemplaire de bulletin
                    $bulletin = new bulletinage_display($explaire->id_bulletin);
                    $titre = strip_tags($bulletin->display);
                } elseif ($explaire->id_notice) {
                    $notice = new mono_display($explaire->id_notice);
                    $titre = strip_tags($notice->header);
                }
                $libelle_expl = strlen($titre) > 15 ? $explaire->cb . " " . $titre : $explaire->cb . " " . $titre;
                $cpte->record_transaction("", abs($tarif_pret), -1, sprintf($msg["finance_pret_expl"], $libelle_expl), 0);
            }
        }
    }
    if ($pmb_transferts_actif) {
        // si transferts validé (en attente d'envoi), il faut restaurer le statut
        global $PMBuserid;
        $rqt = "SELECT id_transfert FROM transferts,transferts_demande\r\n\t\twhere\r\n\t\tnum_transfert=id_transfert and\r\n\t\tetat_demande=1 and num_expl ={$id_expl} and etat_transfert=0 and sens_transfert=0";
        $res = pmb_mysql_query($rqt);
        if (pmb_mysql_num_rows($res)) {
            $obj = pmb_mysql_fetch_object($res);
            $idTrans = $obj->id_transfert;
            //Récupération des informations d'origine
            $rqt = "SELECT statut_origine, num_expl FROM transferts INNER JOIN transferts_demande ON id_transfert=num_transfert\r\n\t\t\tWHERE id_transfert=" . $idTrans . " AND sens_transfert=0";
            $res = pmb_mysql_query($rqt);
            $obj_data = pmb_mysql_fetch_object($res);
            //on met à jour
            $rqt = "UPDATE exemplaires SET expl_statut=" . $obj_data->statut_origine . " WHERE expl_id=" . $obj_data->num_expl;
            pmb_mysql_query($rqt);
        }
        // cloture les demandes de transfert pour résa, refusée ou pas
        // afin de générer les transfert en automatique dans le circuit classique des résa
        $req = " update transferts,transferts_demande\n\t\tset etat_transfert=1 ,\n\t\tmotif=CONCAT(motif,'. Cloture, car parti en pret (gestion {$PMBuserid}, {$id_empr})')\n\t\twhere\n\t\tnum_transfert=id_transfert and\n\t\t(etat_demande=4 or etat_demande=0 or etat_demande=1)and\n\t\tetat_demande != 3 and etat_demande!=2 and etat_demande!=5 and\n\t\tnum_expl ={$id_expl} and etat_transfert=0 and sens_transfert=0\n\t\t";
        pmb_mysql_query($req, $dbh);
    }
    // invalidation des résas avec ce code-barre, au cas où
    // $query = "update resa SET resa_cb='' where resa_cb='".$cb_doc."' ";
    // $result = @ pmb_mysql_query($query, $dbh) or die("can't update resa ".$query);
}
Example #27
0
 function update_from_form($id = 0)
 {
     global $dbh;
     global $thesaurus_concepts_active;
     global $authority_statut;
     $id += 0;
     if (!$id) {
         $requete = "insert into authperso_authorities set authperso_authority_authperso_num=" . $this->id;
         pmb_mysql_query($requete);
         $id = pmb_mysql_insert_id($dbh);
         audit::insert_creation($this->id + 1000, $id);
     } else {
         audit::insert_modif($this->id + 1000, $id);
     }
     if (!$id) {
         return;
     }
     //update authority informations
     $authority = new authority(0, $id, AUT_TABLE_AUTHPERSO);
     $authority->set_num_statut($authority_statut);
     $authority->update();
     $p_perso = new custom_parametres_perso("authperso", "authperso", $this->id);
     $p_perso->rec_fields_perso($id);
     $aut_link = new aut_link($this->id + 1000, $id);
     $aut_link->save_form();
     // Indexation concepts
     if ($thesaurus_concepts_active == 1) {
         $index_concept = new index_concept($id, TYPE_AUTHPERSO);
         $index_concept->save();
     }
     $this->update_global_index($id);
 }
 public function duplicate($recursive, $num_parent = 0)
 {
     global $dbh;
     if (!$num_parent) {
         $num_parent = $this->num_parent;
     }
     //on place la nouvelle rubrique à la fin par défaut
     $query = "SELECT id_section FROM cms_sections WHERE section_num_parent=" . addslashes($num_parent);
     $result = pmb_mysql_query($query, $dbh);
     if ($result) {
         $order = ",section_order = '" . (pmb_mysql_num_rows($result) + 1) . "' ";
     } else {
         $order = ",section_order = 1";
     }
     $insert = "insert into cms_sections set\r\n\t\tsection_title = '" . addslashes($this->title) . "',\r\n\t\tsection_resume = '" . addslashes($this->resume) . "',\n\t\tsection_logo = '" . addslashes($this->logo->data) . "',\r\n\t\tsection_publication_state ='" . addslashes($this->publication_state) . "',\r\n\t\tsection_start_date = '" . addslashes($this->start_date) . "',\r\n\t\tsection_end_date = '" . addslashes($this->end_date) . "',\r\n\t\tsection_num_parent = '" . addslashes($num_parent) . "' ,\r\n\t\tsection_num_type = '" . $this->num_type . "' ,\r\n\t\tsection_creation_date=sysdate() " . $order;
     pmb_mysql_query($insert, $dbh);
     $id = pmb_mysql_insert_id();
     //au tour des descripteurs...
     for ($i = 0; $i < count($this->descriptors); $i++) {
         $rqt = "insert into cms_sections_descriptors set num_section = '" . $id . "', num_noeud = '" . $this->descriptors[$i] . "',section_descriptor_order='" . $i . "'";
         pmb_mysql_query($rqt, $dbh);
     }
     //on crée la nouvelle instance
     $new_section = new cms_section($id);
     //enfin les éléments du type de contenu
     $types = new cms_editorial_types("section");
     $types->duplicate_type_form($this->num_type, $id, $this->id);
     $new_section->maj_indexation();
     $new_section->documents_linked = $this->documents_linked;
     $new_section->save_documents();
     //audit
     audit::insert_creation(AUDIT_EDITORIAL_SECTION, $id);
     if ($recursive) {
         //on duplique les rubriques enfants
         $query = "select id_section from cms_sections where section_num_parent = " . $this->id . " order by section_order";
         $result = pmb_mysql_query($query, $dbh);
         if ($result && pmb_mysql_num_rows($result)) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 $child = new cms_section($row->id_section);
                 $child->duplicate($recursive, $id);
             }
         }
         //on duplique les articles enfants
         $query = "select id_article from cms_articles where num_section = " . $this->id . " order by article_order";
         $result = pmb_mysql_query($query, $dbh);
         if ($result && pmb_mysql_num_rows($result)) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 $article = new cms_article($row->id_article);
                 $article->duplicate($id);
             }
         }
     }
 }
Example #29
0
 function import($name, $comment = "", $id_pclassement = "")
 {
     global $dbh;
     global $pmb_limitation_dewey;
     global $thesaurus_classement_defaut;
     // check sur la variable passée en paramètre
     if (!$name) {
         return 0;
     }
     if ($pmb_limitation_dewey < 0) {
         return 0;
     }
     if ($pmb_limitation_dewey) {
         $name = substr($name, 0, $pmb_limitation_dewey);
     }
     // tentative de récupérer l'id associée dans la base (implique que l'autorité existe)
     // préparation de la requête
     $key = addslashes($name);
     $comment = addslashes($comment);
     if (!$id_pclassement) {
         $num_pclass = $thesaurus_classement_defaut;
     } else {
         $num_pclass = $id_pclassement;
     }
     //On regarde si le plan de classement existe
     $query = "SELECT name_pclass FROM pclassement WHERE id_pclass='" . addslashes($num_pclass) . "' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT pclassement " . $query);
     }
     if (!pmb_mysql_num_rows($result)) {
         //Le plan de classement demandé n'existe pas
         return 0;
         // -> pas d'import
     }
     $query = "SELECT indexint_id FROM indexint WHERE indexint_name='" . rtrim(substr($key, 0, 255)) . "' and num_pclass='{$num_pclass}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT indexint " . $query);
     }
     // résultat
     // récupération du résultat de la recherche
     $tindexint = pmb_mysql_fetch_object($result);
     // du résultat et récupération éventuelle de l'id
     if ($tindexint->indexint_id) {
         return $tindexint->indexint_id;
     }
     // id non-récupérée >> création
     if (!$id_pclassement) {
         $num_pclass = $thesaurus_classement_defaut;
     } else {
         $num_pclass = $id_pclassement;
     }
     $query = "INSERT INTO indexint SET indexint_name='{$key}', indexint_comment='{$comment}', index_indexint=' " . strip_empty_words($key . " " . $comment) . " ', num_pclass={$num_pclass} ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into indexint " . $query);
     }
     $id = pmb_mysql_insert_id($dbh);
     audit::insert_creation(AUDIT_INDEXINT, $id);
     return $id;
 }
 public function duplicate($num_parent = 0)
 {
     global $dbh;
     if (!$num_parent) {
         $num_parent = $this->num_parent;
     }
     //on place le nouvel article à la fin par défaut
     $query = "SELECT id_article FROM cms_articles WHERE num_section=" . addslashes($num_parent);
     $result = pmb_mysql_query($query);
     if ($result) {
         $order = ",article_order = '" . (pmb_mysql_num_rows($result) + 1) . "' ";
     } else {
         $order = ",article_order = 1";
     }
     $insert = "insert into cms_articles set \n\t\tarticle_title = '" . addslashes($this->title) . "', \n\t\tarticle_resume = '" . addslashes($this->resume) . "', \n\t\tarticle_contenu = '" . addslashes($this->contenu) . "',\n\t\tarticle_logo = '" . addslashes($this->logo->data) . "',\n\t\tarticle_publication_state ='" . addslashes($this->publication_state) . "', \n\t\tarticle_start_date = '" . addslashes($this->start_date) . "', \n\t\tarticle_end_date = '" . addslashes($this->end_date) . "', \n\t\tnum_section = '" . addslashes($num_parent) . "', \n\t\tarticle_num_type = '" . $this->num_type . "',\n\t\tarticle_creation_date=sysdate() " . $order;
     pmb_mysql_query($insert, $dbh);
     $id = pmb_mysql_insert_id();
     //au tour des descripteurs...
     for ($i = 0; $i < count($this->descriptors); $i++) {
         $rqt = "insert into cms_articles_descriptors set num_article = '" . $id . "', num_noeud = '" . $this->descriptors[$i] . "',article_descriptor_order='" . $i . "'";
         pmb_mysql_query($rqt, $dbh);
     }
     //on crée la nouvelle instance
     $new_article = new cms_article($id);
     //enfin les éléments du type de contenu
     $types = new cms_editorial_types("article");
     $types->duplicate_type_form($this->num_type, $id, $this->id);
     $new_article->maj_indexation();
     $new_article->documents_linked = $this->documents_linked;
     $new_article->save_documents();
     //audit
     audit::insert_creation(AUDIT_EDITORIAL_ARTICLE, $id);
 }