function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $prix, $notice_id, $info_996, $info_995, $info_001, $info_345_d;
    global $bulletin_id;
    global $id_expl_fournisseur_opsys, $id_expl_inventaire_opsys;
    // Afin de ne pas remettre en cause le script programmé en 995 :
    $info_995 = $info_996;
    // lu en 010$d de la notice
    $price = $prix[0];
    // prix dvd et video
    if ($info_345_d[0]) {
        $price = $info_345_d[0];
    }
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['notice'] = $notice_id;
        $expl['cb'] = $info_995[$nb_expl]['f'];
        $expl['cote'] = $info_995[$nb_expl]['k'];
        $expl['note'] = $info_995[$nb_expl]['u'] . $info_995[$nb_expl]['5'];
        $expl['prix'] = $price;
        $expl['cote_mandatory'] = 0;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        // propriétaire
        $owner = array();
        $owner['lender_libelle'] = $info_995[$nb_expl]['a'];
        if (!$owner['lender_libelle']) {
            $owner['lender_libelle'] = $info_995[$nb_expl]['b'];
        }
        if (!$owner['lender_libelle']) {
            $owner['lender_libelle'] = 'defaut';
        }
        $expl['expl_owner'] = lender::import($owner);
        $book_lender_id = $expl['expl_owner'];
        // docs_location
        $data_doc = array();
        $data_doc['location_libelle'] = $info_995[$nb_expl]['v'];
        $data_doc['locdoc_codage_import'] = $info_995[$nb_expl]['w'];
        if (!$data_doc['locdoc_codage_import']) {
            $data_doc['locdoc_codage_import'] = $data_doc['location_libelle'];
        }
        //$data_doc['locdoc_owner'] = $book_lender_id ;
        $data_doc['locdoc_owner'] = 0;
        $expl['location'] = docs_location::import($data_doc);
        // docs_section
        $data_doc = array();
        $data_doc['section_libelle'] = $info_995[$nb_expl]['x'];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['y'];
        if (!$data_doc['sdoc_codage_import']) {
            $data_doc['sdoc_codage_import'] = $data_doc['section_libelle'];
        }
        //$data_doc['sdoc_owner'] = $book_lender_id ;
        $data_doc['sdoc_owner'] = 0;
        $expl['section'] = docs_section::import($data_doc);
        // typedoc
        $data_doc = array();
        $data_doc['tdoc_libelle'] = $info_995[$nb_expl]['e'];
        if (!$data_doc['tdoc_libelle']) {
            $data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r'];
        }
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        if (!$data_doc['tdoc_codage_import']) {
            $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['e'];
        }
        $data_doc['duree_pret'] = 28;
        /* valeur par défaut */
        $data_doc['tdoc_owner'] = $book_lender_id;
        $expl['typdoc'] = docs_type::import($data_doc);
        // statut doc
        $data_doc = array();
        $data_doc['statut_libelle'] = $info_995[$nb_expl]['1'];
        $data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['2'];
        if (!$data_doc['statusdoc_codage_import']) {
            $data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['1'];
        }
        $data_doc['pret_flag'] = $info_995[$nb_expl]['3'];
        $data_doc['statusdoc_owner'] = $book_lender_id;
        $expl['statut'] = docs_statut::import($data_doc);
        // codestat
        //$expl['codestat'] = 10 ;
        $data_codestat['codestat_libelle'] = strtolower($info_995[$nb_expl]['x']);
        $expl['codestat'] = docs_codestat::import($data_codestat);
        // quoi_faire
        // $que_faire vient du formulaire de chargement, à utiliser en attente de l'info dans la zone 996
        global $que_faire;
        if ($que_faire == "") {
            if ($info_995[$nb_expl]['0']) {
                $expl['quoi_faire'] = $info_995[$nb_expl]['0'];
            } else {
                $expl['quoi_faire'] = 2;
            }
        } else {
            $expl['quoi_faire'] = $que_faire;
        }
        // 0 : supprimer, 1 ou vide : Mettre à jour ou ajouter, 2 : ajouter si possible, sinon rien.
        //print "<pre>";print_r($info_995);print_r($expl);print "</pre>";
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        list($num_opsys, $type_opsys) = explode(" ", $info_001[0]);
        if ($type_opsys == 'UMO:13') {
            $requete = "update exemplaires set expl_notice='0', expl_bulletin='{$bulletin_id}' where expl_id='{$expl_id}' ";
            //print "$requete <br />";
            pmb_mysql_query($requete);
        }
        if (!$id_expl_fournisseur_opsys) {
            $rqt = "select idchamp from expl_custom where name='fournisseur'";
            $res = pmb_mysql_query($rqt, $dbh);
            if ($res && ($r = pmb_mysql_fetch_object($res))) {
                $id_expl_fournisseur_opsys = $r->idchamp;
            }
        }
        if (!$id_expl_inventaire_opsys) {
            $rqt = "select idchamp from expl_custom where name='inventaire'";
            $res = pmb_mysql_query($rqt, $dbh);
            if ($res && ($r = pmb_mysql_fetch_object($res))) {
                $id_expl_inventaire_opsys = $r->idchamp;
            }
        }
        //inventaire en champ perso
        if ($field = $info_995[$nb_expl]['6']) {
            $requete = "insert into expl_custom_values (expl_custom_champ,expl_custom_origine,expl_custom_small_text) values({$id_expl_inventaire_opsys},{$expl_id},'" . addslashes($field) . "')";
            pmb_mysql_query($requete);
        }
        //Fournisseur en champ perso
        if ($field = $info_995[$nb_expl]['7']) {
            $requete = "insert into expl_custom_values (expl_custom_champ,expl_custom_origine,expl_custom_small_text) values({$id_expl_fournisseur_opsys},{$expl_id},'" . addslashes($field) . "')";
            pmb_mysql_query($requete);
        }
        //Date de création
        if ($field = $info_995[$nb_expl]['8']) {
            $requete = "update exemplaires set create_date='{$field} 12:00:00' where expl_id='{$expl_id}' ";
            //print $requete;
            pmb_mysql_query($requete);
        }
    }
    // fin for
}
Exemplo n.º 2
0
function traite_exemplaires()
{
    global $nb_expl_ignores, $bulletin_ex;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        if ($bulletin_ex) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        // $expl['typdoc']     = $info_995[$nb_expl]['r']; à chercher dans docs_typdoc
        $data_doc = array();
        //$data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r']." -Type doc importé (".$book_lender_id.")";
        $data_doc['tdoc_libelle'] = $typdoc_995[$info_995[$nb_expl]['r']];
        if (!$data_doc['tdoc_libelle']) {
            $data_doc['tdoc_libelle'] = "\$r non conforme -" . $info_995[$nb_expl]['r'] . "-";
        }
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        // $expl['section']    = $info_995[$nb_expl]['q']; à chercher dans docs_section
        $data_doc = array();
        $info_995[$nb_expl]['q'] = trim($info_995[$nb_expl]['q']);
        if (!$info_995[$nb_expl]['q']) {
            $info_995[$nb_expl]['q'] = "u";
        }
        $data_doc['section_libelle'] = $section_995[$info_995[$nb_expl]['q']];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        /* $expl['statut']     à chercher dans docs_statut */
        /* TOUT EST COMMENTE ICI, le statut est maintenant choisi lors de l'import
        		if ($info_995[$nb_expl]['o']=="") $info_995[$nb_expl]['o'] = "e";
        		$data_doc=array();
        		$data_doc['statut_libelle'] = $info_995[$nb_expl]['o']." -Statut importé (".$book_lender_id.")";
        		$data_doc['pret_flag'] = 1 ; 
        		$data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['o'] ;
        		$data_doc['statusdoc_owner'] = $book_lender_id ;
        		$expl['statut'] = docs_statut::import($data_doc);
        		FIN TOUT COMMENTE */
        $expl['statut'] = $book_statut_id;
        $expl['location'] = $book_location_id;
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        //$data_doc['codestat_libelle'] = $info_995[$nb_expl]['q']." -Pub visé importé (".$book_lender_id.")";
        $data_doc['codestat_libelle'] = $codstatdoc_995[$info_995[$nb_expl]['q']];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($statisdoc_codage) {
            $data_doc['statisdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['statisdoc_owner'] = 0;
        }
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        // quoi_faire
        if ($info_995[$nb_expl]['0']) {
            $expl['quoi_faire'] = $info_995[$nb_expl]['0'];
        } else {
            $expl['quoi_faire'] = 2;
        }
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
Exemplo n.º 3
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $bulletin_ex;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // lu en 010$d de la notice
    //$price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        if ($bulletin_ex == -1) {
            return;
        } elseif ($bulletin_ex) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        /* préparation du tableau à passer à la méthode */
        $cbarre = $info_995[$nb_expl]['f'];
        if (!$cbarre) {
            $cbarre = "ind";
        }
        $pb = 1;
        $num_login = 1;
        $expl['cb'] = $cbarre;
        while ($pb == 1) {
            $q = "SELECT expl_cb FROM exemplaires WHERE expl_cb='" . $expl['cb'] . "' LIMIT 1 ";
            $r = pmb_mysql_query($q, $dbh);
            //echo "requete : ".$q."<br>";
            $nb = pmb_mysql_num_rows($r);
            if ($nb) {
                $expl['cb'] = $cbarre . "-" . $num_login;
                $num_login++;
            } else {
                $pb = 0;
            }
        }
        // $expl['typdoc']     = $info_995[$nb_expl]['r']; à chercher dans docs_typdoc
        $data_doc = array();
        //$data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r']." -Type doc importé (".$book_lender_id.")";
        $data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r'];
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        if (!$data_doc['tdoc_libelle']) {
            $data_doc['tdoc_libelle'] = "Indéterminé";
            $data_doc['tdoc_codage_import'] = "Indéterminé";
        }
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_owner'] = 0;
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        if ($expl['cote'] == "") {
            $expl['cote'] = "Indetermine";
        }
        // $expl['section']    = $info_995[$nb_expl]['q']; à chercher dans docs_section
        /*$data_doc=array();
        		$info_995[$nb_expl]['q']=trim($info_995[$nb_expl]['q']);
        		if (!$info_995[$nb_expl]['q']) 
        			$info_995[$nb_expl]['q'] = "u";
        		*/
        $data_doc = array();
        $data_doc['section_libelle'] = $info_995[$nb_expl]['q'];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if (!$data_doc['section_libelle']) {
            $data_doc['section_libelle'] = "Indéterminé";
            $data_doc['sdoc_codage_import'] = "Indéterminé";
        }
        $data_doc['sdoc_owner'] = 0;
        $expl['section'] = docs_section::import($data_doc);
        if (!$info_995[$nb_expl]['o']) {
            $expl['statut'] = $book_statut_id;
        } else {
            $info_995[$nb_expl]['o'] = "Indéterminé";
            $data_doc = array();
            $data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['o'];
            $data_doc['statut_libelle'] = $info_995[$nb_expl]['o'];
            $data_doc['statusdoc_owner'] = 0;
            $expl['statut'] = docs_statut::import($data_doc);
        }
        //$expl['statut'] = $book_statut_id;
        if ($info_995[$nb_expl]['a'] != "") {
            $data_doc = array();
            $data_doc['locdoc_codage_import'] = $info_995[$nb_expl]['a'];
            $data_doc['location_libelle'] = $info_995[$nb_expl]['a'];
            $data_doc['locdoc_owner'] = 0;
            $expl['location'] = docs_location::import($data_doc);
        } else {
            $expl['location'] = $book_location_id;
        }
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        $data_doc['codestat_libelle'] = $info_995[$nb_expl]['q'];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if (!$data_doc['codestat_libelle']) {
            $data_doc['codestat_libelle'] = "Indéterminé";
            $data_doc['statisdoc_codage_import'] = "Indéterminé";
        }
        $data_doc['statisdoc_owner'] = 0;
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['comment'] = $info_995[$nb_expl]['u'];
        $expl['note'] = "";
        $expl['prix'] = $prix[0];
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $data['date_depot'] = "";
        // Attention il faut en post migration mette cette info dans la date de création de l'exemplaire
        // quoi_faire
        $expl['quoi_faire'] = 2;
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        } else {
        }
    }
    // fin for
}
Exemplo n.º 4
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory;
    global $bulletin_ex;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        $unique = false;
        $cb = $expl['cb'];
        $cb1 = $cb;
        $n_cb = 2;
        while (!$unique) {
            $requete = "select 1 from exemplaires where expl_cb='" . addslashes($cb1) . "'";
            $resultat = mysql_query($requete);
            if (mysql_num_rows($resultat)) {
                $cb1 = $cb . " " . $n_cb;
                $n_cb++;
            } else {
                $unique = true;
            }
        }
        $expl['cb'] = $cb1;
        if ($bulletin_ex) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        // $expl['typdoc']     = $info_995[$nb_expl]['r']; à chercher dans docs_typdoc
        $data_doc = array();
        //$data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r']." -Type doc importé (".$book_lender_id.")";
        //$data_doc['tdoc_libelle'] = $typdoc_995[$info_995[$nb_expl]['r']];
        //if (!$data_doc['tdoc_libelle']) $data_doc['tdoc_libelle'] = "\$r non conforme -".$info_995[$nb_expl]['r']."-" ;
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        $data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        if (!trim($expl['cote'])) {
            $expl['cote'] = "SC";
        }
        // $expl['section']    = $info_995[$nb_expl]['q']; à chercher dans docs_section
        $data_doc = array();
        if (!$info_995[$nb_expl]['t']) {
            $info_995[$nb_expl]['t'] = "inconnu";
        }
        $data_doc['section_libelle'] = $info_995[$nb_expl]['t'];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['t'];
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        $expl['statut'] = $book_statut_id;
        // $expl['location']   = $info_995[$nb_expl]['']; à fixer par combo_box
        // figé dans le code ici pour l'instant :
        //$info_995[$nb_expl]['localisation']="Bib princip"; /* biblio principale */
        $data_doc = array();
        $data_doc['location_libelle'] = "inconnu";
        if ($info_995[$nb_expl]['a']) {
            $data_doc['location_libelle'] = $info_995[$nb_expl]['a'];
            $data_doc['locdoc_codage_import'] = $info_995[$nb_expl]['a'];
        } else {
            $data_doc['locdoc_codage_import'] = "Centre de documentation";
        }
        if ($locdoc_codage) {
            $data_doc['locdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['locdoc_owner'] = 0;
        }
        $expl['location'] = docs_location::import($data_doc);
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        //$data_doc['codestat_libelle'] = $info_995[$nb_expl]['q']." -Pub visé importé (".$book_lender_id.")";
        if (!$info_995[$nb_expl]['q']) {
            $info_995[$nb_expl]['q'] = "inconnu";
        }
        $data_doc['codestat_libelle'] = $info_995[$nb_expl]['q'];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($statisdoc_codage) {
            $data_doc['statisdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['statisdoc_owner'] = 0;
        }
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
    }
    // fin for
}
Exemplo n.º 5
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory;
    global $info_461, $bulletin_ex;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        if ($bulletin_ex && is_array($info_461)) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        $data_doc = array();
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        $data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r'];
        $data_doc['tdoc_owner'] = 0;
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        if (!trim($expl['cote'])) {
            $expl['cote'] = "INDETERMINE";
        }
        $data_doc = array();
        if (!$info_995[$nb_expl]['q']) {
            $info_995[$nb_expl]['q'] = "INDETERMINE";
        }
        $data_doc['section_libelle'] = $info_995[$nb_expl]['q'];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['q'];
        $data_doc['sdoc_owner'] = 0;
        $expl['section'] = docs_section::import($data_doc);
        $expl['statut'] = $book_statut_id;
        $data_doc = array();
        $data_doc['location_libelle'] = "CDI";
        $data_doc['locdoc_codage_import'] = "CDI";
        $data_doc['locdoc_owner'] = 0;
        $expl['location'] = docs_location::import($data_doc);
        $data_doc = array();
        if (!$info_995[$nb_expl]['q']) {
            $info_995[$nb_expl]['q'] = "IN";
        }
        $data_doc['codestat_libelle'] = $info_995[$nb_expl]['q'];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        $data_doc['statisdoc_owner'] = 0;
        $expl['codestat'] = docs_codestat::import($data_doc);
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
Exemplo n.º 6
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;
     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;
 }
Exemplo n.º 7
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_bdp43, $sec_search_bdp43, $corresp_bdp43, $section_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        $expl['notice'] = $notice_id;
        // $expl['typdoc']     = $info_995[$nb_expl]['r']; à chercher dans docs_typdoc
        $data_doc = array();
        //$data_doc['tdoc_libelle'] = $info_995[$nb_expl]['r']." -Type doc importé (".$book_lender_id.")";
        $data_doc['tdoc_libelle'] = $typdoc_995[$info_995[$nb_expl]['r']];
        if (!$data_doc['tdoc_libelle']) {
            $data_doc['tdoc_libelle'] = "\$r non conforme -" . $info_995[$nb_expl]['r'] . "-";
        }
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        // traitement des sections en fonction de la cote
        // recherche début dans le tableau bien ordonné afin de trouvé les DA avant les D
        // 		si trouvé : on va le chercher dans le tableau de tableau,
        //			ça donne l'index avec lequel on va chercher le libellé
        reset($sec_search_bdp43);
        $flag = 0;
        while (list($cle_tab, $val_tab) = each($sec_search_bdp43)) {
            $p = strpos((string) $info_995[$nb_expl]['k'], (string) $val_tab);
            if ($p !== false && $p == 0) {
                $flag = 1;
                break;
            }
        }
        if ($flag == 1) {
            //Recherche de la section
            for ($i = 0; $i < count($corresp_bdp43); $i++) {
                $as = array_search($val_tab, $corresp_bdp43[$i]);
                if ($as !== null && $as !== false) {
                    $codage_section_lu = $i + 1;
                    $libelle_section_lu = $section_bdp43[$i];
                }
            }
        } else {
            $codage_section_lu = "INCONNU";
            $libelle_section_lu = "Section inconnue";
        }
        $data_doc = array();
        $data_doc['section_libelle'] = $libelle_section_lu;
        $data_doc['sdoc_codage_import'] = $codage_section_lu;
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        /* $expl['statut']     à chercher dans docs_statut */
        /* TOUT EST COMMENTE ICI, le statut est maintenant choisi lors de l'import
        		if ($info_995[$nb_expl]['o']=="") $info_995[$nb_expl]['o'] = "e";
        		$data_doc=array();
        		$data_doc['statut_libelle'] = $info_995[$nb_expl]['o']." -Statut importé (".$book_lender_id.")";
        		$data_doc['pret_flag'] = 1 ; 
        		$data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['o'] ;
        		$data_doc['statusdoc_owner'] = $book_lender_id ;
        		$expl['statut'] = docs_statut::import($data_doc);
        		FIN TOUT COMMENTE */
        $expl['statut'] = $book_statut_id;
        $expl['location'] = $book_location_id;
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        //$data_doc['codestat_libelle'] = $info_995[$nb_expl]['q']." -Pub visé importé (".$book_lender_id.")";
        $data_doc['codestat_libelle'] = $codstatdoc_995[$info_995[$nb_expl]['q']];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($statisdoc_codage) {
            $data_doc['statisdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['statisdoc_owner'] = 0;
        }
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        // quoi_faire
        if ($info_995[$nb_expl]['0']) {
            $expl['quoi_faire'] = $info_995[$nb_expl]['0'];
        } else {
            $expl['quoi_faire'] = 2;
        }
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
Exemplo n.º 8
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $prix, $notice_id, $info_852, $tdoc_codage, $book_lender_id, $sdoc_codage, $book_statut_id, $locdoc_codage, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // débuggage
    /*	echo "<pre>" ;
    	print_r($info_852) ;
    	echo "</pre>" ;
    	exit ;
    	 */
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 852 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_852); $nb_expl++) {
        if ($info_852[$nb_expl]['b'] == "IDC") {
            /* préparation du tableau à passer à la méthode */
            /* RAZ expl */
            $expl = array();
            $expl['cb'] = $info_852[$nb_expl]['p'];
            $expl['cote'] = $info_852[$nb_expl]['h'];
            $expl['notice'] = $notice_id;
            // $expl['section']    = $info_852[$nb_expl]['h']; à chercher dans docs_section
            $data_doc = array();
            $pos_section = strpos($info_852[$nb_expl]['h'], " ");
            if ($pos_section) {
                $section = substr($info_852[$nb_expl]['h'], 0, $pos_section);
            } else {
                $section = "XXX";
            }
            if ($section == "XXX") {
                $data_doc['section_libelle'] = "SECTION INDETERMINEE";
            } else {
                $data_doc['section_libelle'] = "Libellé pour " . $section;
            }
            $data_doc['sdoc_codage_import'] = $section;
            if ($sdoc_codage) {
                $data_doc['sdoc_owner'] = $book_lender_id;
            } else {
                $data_doc['sdoc_owner'] = 0;
            }
            $expl['section'] = docs_section::import($data_doc);
            // $expl['typdoc']
            $data_doc = array();
            $data_doc['tdoc_libelle'] = "Type doc indéterminé";
            $data_doc['duree_pret'] = 15;
            /* valeur par défaut */
            $data_doc['tdoc_codage_import'] = "XXX";
            if ($tdoc_codage) {
                $data_doc['tdoc_owner'] = $book_lender_id;
            } else {
                $data_doc['tdoc_owner'] = 0;
            }
            $expl['typdoc'] = docs_type::import($data_doc);
            $expl['statut'] = $book_statut_id;
            $expl['location'] = $book_location_id;
            // $expl['codestat']
            $data_doc = array();
            $data_doc['codestat_libelle'] = "AUCUN CODE STATISTIQUE";
            $data_doc['statisdoc_codage_import'] = "XXX";
            if ($statisdoc_codage) {
                $data_doc['statisdoc_owner'] = $book_lender_id;
            } else {
                $data_doc['statisdoc_owner'] = 0;
            }
            $expl['codestat'] = docs_codestat::import($data_doc);
            $expl['note'] = "";
            $expl['prix'] = $price;
            $expl['expl_owner'] = $book_lender_id;
            $expl['cote_mandatory'] = $cote_mandatory;
            $expl_id = exemplaire::import($expl);
            if ($expl_id == 0) {
                $nb_expl_ignores++;
            }
        }
    }
    // fin for
}
Exemplo n.º 9
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id, $nb_expl_ignores;
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['a'];
        if (!$expl['cb']) {
            $expl['cb'] = "NOTI-" . $notice_id;
        }
        $expl['notice'] = $notice_id;
        $expl['cote'] = $info_995[$nb_expl]['f'];
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $info_995[$nb_expl]['B'];
        $expl['date_depot'] = today();
        $expl['date_retour'] = today();
        // type de support
        $data_doc = array();
        $data_doc['tdoc_libelle'] = "Type doc - " . $info_995[$nb_expl]['c'];
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['c'];
        $data_doc['tdoc_owner'] = 0;
        $expl['typdoc'] = docs_type::import($data_doc);
        // $expl['section']    = $info_995[$nb_expl]['x']; à chercher dans docs_section
        $data_doc = array();
        $data_doc['section_libelle'] = $info_995[$nb_expl]['x'];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['x'];
        $data_doc['sdoc_owner'] = 0;
        $expl['section'] = docs_section::import($data_doc);
        if (!$expl['section']) {
            $expl['section'] = 31;
        }
        // $expl['statut']
        $data_doc = array();
        $data_doc['statut_libelle'] = "Statut - " . $info_995[$nb_expl]['y'];
        $data_doc['pret_flag'] = 1;
        $data_doc['statusdoc_codage_import'] = $info_995[$nb_expl]['y'];
        $data_doc['statusdoc_owner'] = 0;
        $expl['statut'] = docs_statut::import($data_doc);
        // $expl['location']
        $data_doc = array();
        $data_doc['location_libelle'] = "Localisation - " . $info_995[$nb_expl]['w'];
        $data_doc['locdoc_codage_import'] = $info_995[$nb_expl]['w'];
        $data_doc['locdoc_owner'] = 0;
        $expl['location'] = docs_location::import($data_doc);
        // $expl['codestat']   = $info_995[$nb_expl]['O']; (O majuscule, pas zéro)
        $data_doc = array();
        $data_doc['codestat_libelle'] = "Code stat - " . $info_995[$nb_expl]['O'];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['O'];
        $data_doc['statisdoc_owner'] = 0;
        $expl['codestat'] = docs_codestat::import($data_doc);
        if (!$expl['codestat']) {
            $expl['codestat'] = 38;
        }
        // $expl['expl_owner']
        $data_doc = array();
        $data_doc['lender_libelle'] = $info_995[$nb_expl]['R'];
        $expl['expl_owner'] = lender::import($data_doc);
        if (!$expl['expl_owner']) {
            $expl['expl_owner'] = 3;
        }
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        // Numéro du jeu
        if ($info_995[$nb_expl]['v'] && $expl_id) {
            $requete = "insert into expl_custom_values (expl_custom_champ,expl_custom_origine,expl_custom_small_text) values(1,{$expl_id},'" . addslashes($info_995[$nb_expl]['v']) . "')";
            mysql_query($requete);
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
function traite_exemplaires()
{
    global $nb_expl_ignores, $bulletin_ex;
    global $prix, $notice_id, $info_996, $info_999, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    global $suffix;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_996); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        $data = array();
        /*if(!$info_996[$nb_expl]['a'])$info_996[$nb_expl]['a'] ="Indéterminé";
        		$data['lender_libelle']=$info_996[$nb_expl]['a'];
        		$book_lender_id=lender::import($data);*/
        //Propriétaire
        if (trim($info_996[$nb_expl]['a'])) {
            $requete = "SELECT idlender FROM lenders WHERE lender_libelle LIKE '" . addslashes($info_996[$nb_expl]['a']) . "'";
            $res = mysql_query($requete);
            if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
                $local_book_lender_id = $id;
            } else {
                $local_book_lender_id = $book_lender_id;
            }
        } else {
            $local_book_lender_id = $book_lender_id;
        }
        /* préparation du tableau à passer à la méthode */
        $cbarre = $info_996[$nb_expl]['f'];
        if (!$cbarre) {
            $cbarre = "ind";
        }
        $pb = 1;
        $num_login = 1;
        $expl['cb'] = $cbarre;
        while ($pb == 1) {
            $q = "SELECT expl_cb FROM exemplaires WHERE expl_cb='" . addslashes($expl['cb']) . "' LIMIT 1 ";
            $r = mysql_query($q);
            $nb = mysql_num_rows($r);
            if ($nb) {
                $expl['cb'] = $cbarre . "-" . $num_login;
                $num_login++;
            } else {
                $pb = 0;
            }
        }
        if ($info_996[$nb_expl]['f'] != $expl['cb']) {
            $mon_msg = "ERREUR : l'exemplaire avec le code barres : " . $info_996[$nb_expl]['f'] . " existe déjà donc il ne sera pas créé";
            mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') ");
            continue;
        }
        if ($bulletin_ex) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        $data_doc = array();
        $data_doc['tdoc_libelle'] = $info_996[$nb_expl]['e'];
        if (!$data_doc['tdoc_libelle']) {
            $data_doc['tdoc_libelle'] = "Indéterminé";
        }
        $requete = "SELECT idtyp_doc FROM docs_type WHERE tdoc_libelle LIKE '" . addslashes($data_doc['tdoc_libelle']) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['typdoc'] = $id;
        } else {
            $data_doc['duree_pret'] = 0;
            /* valeur par défaut */
            $data_doc['tdoc_codage_import'] = $data_doc['tdoc_libelle'];
            if ($tdoc_codage) {
                $data_doc['tdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['tdoc_owner'] = 0;
            }
            $expl['typdoc'] = docs_type::import($data_doc);
        }
        $expl['cote'] = $info_996[$nb_expl]['k'];
        if (!$info_996[$nb_expl]['x']) {
            $info_996[$nb_expl]['x'] = "Indéterminé";
        }
        $requete = "SELECT idsection FROM docs_section WHERE section_libelle LIKE '" . addslashes($info_996[$nb_expl]['x']) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['section'] = $id;
        } else {
            $data_doc = array();
            $data_doc['section_libelle'] = $info_996[$nb_expl]['x'];
            $data_doc['sdoc_codage_import'] = $info_996[$nb_expl]['x'];
            if ($sdoc_codage) {
                $data_doc['sdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['sdoc_owner'] = 0;
            }
            $expl['section'] = docs_section::import($data_doc);
        }
        if (!$info_996[$nb_expl]['1']) {
            $info_996[$nb_expl]['1'] = "Indéterminé";
        }
        $requete = "SELECT  idstatut FROM docs_statut WHERE statut_libelle LIKE '" . addslashes($info_996[$nb_expl]['1']) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['statut'] = $id;
        } else {
            $data_doc = array();
            $data_doc['statut_libelle'] = $info_996[$nb_expl]['1'];
            $data_doc['pret_flag'] = 1;
            $data_doc['statusdoc_codage_import'] = $info_996[$nb_expl]['1'];
            if ($sdoc_codage) {
                $data_doc['statusdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['statusdoc_owner'] = 0;
            }
            $expl['statut'] = docs_statut::import($data_doc);
        }
        $requete = "SELECT idlocation FROM docs_location WHERE location_libelle LIKE '" . addslashes($info_996[$nb_expl]['v']) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['location'] = $id;
        } else {
            $expl['location'] = $book_location_id;
        }
        if (!$info_996[$nb_expl]['c']) {
            $info_996[$nb_expl]['c'] = "Indéterminé";
        }
        $requete = "SELECT idcode FROM docs_codestat WHERE codestat_libelle  LIKE '" . addslashes($info_996[$nb_expl]['c']) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['codestat'] = $id;
        } else {
            $data_doc = array();
            $data_doc['codestat_libelle'] = $info_996[$nb_expl]['c'];
            $data_doc['statisdoc_codage_import'] = $info_996[$nb_expl]['c'];
            if ($statisdoc_codage) {
                $data_doc['statisdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['statisdoc_owner'] = 0;
            }
            $expl['codestat'] = docs_codestat::import($data_doc);
        }
        if ($info_996[$nb_expl]['4']) {
            $expl['creation'] = $info_996[$nb_expl]['4'];
        }
        $expl['note'] = $info_996[$nb_expl]['u'];
        $expl['comment'] = $info_996[$nb_expl]['z'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $local_book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_996[$nb_expl]['m'], 0, 4) . "-" . substr($info_996[$nb_expl]['m'], 4, 2) . "-" . substr($info_996[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_996[$nb_expl]['n'], 0, 4) . "-" . substr($info_996[$nb_expl]['n'], 4, 2) . "-" . substr($info_996[$nb_expl]['n'], 6, 2);
        // quoi_faire
        $expl['quoi_faire'] = 2;
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        } else {
            //Champ perso d'exemplaire
            //echo "Passe ici<br>";
            foreach ($info_999 as $key => $value) {
                if ($value["f"] == $info_996[$nb_expl]['f']) {
                    //Je suis bien sur un cp de cet exemplaire
                    if (!renseigne_cp($value["n"], $value["a"], $expl_id, "expl")) {
                        $mon_msg = "La valeur  : " . $value["a"] . " n'a pas été reprise dans le champ personalisé : " . $value["n"] . " car le champ n'existe pas";
                        mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') ");
                    } else {
                        unset($info_999[$key]);
                    }
                }
            }
        }
    }
    // fin for
}
Exemplo n.º 11
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $bdp02section_995, $bdp02typdoc_995, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        $expl['notice'] = $notice_id;
        // $expl['typdoc']     = $info_995[$nb_expl]['9']; à chercher dans docs_typdoc
        $data_doc = array();
        $data_doc['tdoc_libelle'] = $bdp02typdoc_995[$info_995[$nb_expl]['9']];
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['9'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        // $expl['section']    = $info_995['8']; à chercher dans docs_section
        $data_doc = array();
        $data_doc['section_libelle'] = $bdp02section_995[$info_995[$nb_expl]['8']];
        $data_doc['sdoc_codage_import'] = $info_995[$nb_expl]['8'];
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        // echo "Section : ".$bdp02section_995[$info_995[$nb_expl]['8']]." - ".$info_995[$nb_expl]['8']."<br />" ;
        // echo "TypDoc : ".$bdp02typdoc_995[$info_995[$nb_expl]['9']]." - ".$info_995[$nb_expl]['9']."<br />" ;
        // le statut est choisi lors de l'import
        $expl['statut'] = $book_statut_id;
        $expl['location'] = $book_location_id;
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        //$data_doc['codestat_libelle'] = $info_995[$nb_expl]['q']." -Pub visé importé (".$book_lender_id.")";
        $data_doc['codestat_libelle'] = $codstatdoc_995[$info_995[$nb_expl]['q']];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($statisdoc_codage) {
            $data_doc['statisdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['statisdoc_owner'] = 0;
        }
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
Exemplo n.º 12
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $prix, $notice_id, $info_995, $typdoc_995, $tdoc_codage, $book_lender_id, $section_bdp19, $sec_search_bdp19, $corresp_bdp19, $sdoc_codage, $book_statut_id, $locdoc_codage, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($info_995); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        $expl['cb'] = $info_995[$nb_expl]['f'];
        $expl['notice'] = $notice_id;
        // $expl['typdoc']     = $info_995[$nb_expl]['r']; chargé en base lors de l'installation, voir plus haut
        $data_doc = array();
        $data_doc['tdoc_libelle'] = "Libellé créé " . $info_995[$nb_expl]['r'];
        $data_doc['duree_pret'] = 15;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_995[$nb_expl]['r'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        $expl['cote'] = $info_995[$nb_expl]['k'];
        // traitement des sections en fonction de la cote
        // cote[1] ?? G L ou U
        // -Non
        //		trouver le début de la cote dans le tableau
        //		créer la section si besoin
        // -Oui
        //		tronquer de cette première lettre
        //		trouver le nouveau début dans le tableau
        //		remettre la première lettre
        //		créer la section si besoin
        $car = (string) $info_995[$nb_expl]['k'][0];
        switch ($car) {
            case 'U':
                $prefix = "";
                $suffixe_libelle = "";
                $info_995[$nb_expl]['k'] = substr((string) $info_995[$nb_expl]['k'], 1);
                break;
            default:
                $prefix = "";
                $suffixe_libelle = "";
                break;
        }
        reset($sec_search_bdp19);
        $flag = 0;
        while (list($cle_tab, $val_tab) = each($sec_search_bdp19)) {
            $p = strpos((string) $info_995[$nb_expl]['k'], (string) $val_tab);
            if ($p !== false && $p == 0) {
                $flag = 1;
                break;
            }
        }
        if ($flag == 1) {
            //Recherche de la section
            for ($i = 0; $i < count($corresp_bdp19); $i++) {
                $as = array_search($val_tab, $corresp_bdp19[$i]);
                if ($as !== null && $as !== false) {
                    $codage_section_lu = $i + 1;
                    $libelle_section_lu = $section_bdp19[$i];
                }
            }
        } else {
            $codage_section_lu = "INCONNU";
            $libelle_section_lu = "Section inconnue";
        }
        // $expl['section']    = $info_995['8']; à chercher dans docs_section
        $data_doc = array();
        $data_doc['section_libelle'] = $libelle_section_lu;
        $data_doc['sdoc_codage_import'] = $codage_section_lu;
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        // le statut est choisi lors de l'import
        $expl['statut'] = $book_statut_id;
        $expl['location'] = $book_location_id;
        // $expl['codestat']   = $info_995[$nb_expl]['q']; 'q' utilisé, éventuellement à fixer par combo_box
        $data_doc = array();
        //$data_doc['codestat_libelle'] = $info_995[$nb_expl]['q']." -Pub visé importé (".$book_lender_id.")";
        $data_doc['codestat_libelle'] = $codstatdoc_995[$info_995[$nb_expl]['q']];
        $data_doc['statisdoc_codage_import'] = $info_995[$nb_expl]['q'];
        if ($statisdoc_codage) {
            $data_doc['statisdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['statisdoc_owner'] = 0;
        }
        $expl['codestat'] = docs_codestat::import($data_doc);
        // $expl['creation']   = $info_995[$nb_expl]['']; à préciser
        // $expl['modif']      = $info_995[$nb_expl]['']; à préciser
        $expl['note'] = $info_995[$nb_expl]['u'];
        $expl['prix'] = $price;
        $expl['expl_owner'] = $book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = substr($info_995[$nb_expl]['m'], 0, 4) . "-" . substr($info_995[$nb_expl]['m'], 4, 2) . "-" . substr($info_995[$nb_expl]['m'], 6, 2);
        $expl['date_retour'] = substr($info_995[$nb_expl]['n'], 0, 4) . "-" . substr($info_995[$nb_expl]['n'], 4, 2) . "-" . substr($info_995[$nb_expl]['n'], 6, 2);
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        }
        //debug : affichage zone 995
        /*
        echo "995\$a =".$info_995[$nb_expl]['a']."<br />";
        echo "995\$b =".$info_995[$nb_expl]['b']."<br />";
        echo "995\$c =".$info_995[$nb_expl]['c']."<br />";
        echo "995\$d =".$info_995[$nb_expl]['d']."<br />";
        echo "995\$f =".$info_995[$nb_expl]['f']."<br />";
        echo "995\$k =".$info_995[$nb_expl]['k']."<br />";
        echo " section $codage_section_lu <br />";
        echo "995\$m =".$info_995[$nb_expl]['m']."<br />";
        echo "995\$n =".$info_995[$nb_expl]['n']."<br />";
        echo "995\$o =".$info_995[$nb_expl]['o']."<br />";
        echo "995\$q =".$info_995[$nb_expl]['q']."<br />";
        echo "995\$r =".$info_995[$nb_expl]['r']."<br />";
        echo "995\$u =".$info_995[$nb_expl]['u']."<br /><br />";
        */
    }
    // fin for
}
Exemplo n.º 13
0
function traite_exemplaires()
{
    global $nb_expl_ignores, $bulletin_ex;
    global $prix, $notice_id, $info_996_9, $info_999, $typdoc_995, $tdoc_codage, $book_lender_id, $section_995, $sdoc_codage, $book_statut_id, $codstatdoc_995, $statisdoc_codage, $cote_mandatory, $book_location_id;
    global $suffix;
    // lu en 010$d de la notice
    $price = $prix[0];
    $exemplaires = array();
    for ($i = 0; $i < count($info_996_9); $i++) {
        foreach ($info_996_9[$i] as $value) {
            if (preg_match("/^(.*?):(.*)\$/", $value, $matches)) {
                $exemplaires[$i][$matches[1]] = $matches[2];
            }
        }
    }
    // la zone 995 est répétable
    for ($nb_expl = 0; $nb_expl < sizeof($exemplaires); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        $data = array();
        /*if(!$info_996[$nb_expl]['a'])$info_996[$nb_expl]['a'] ="Indéterminé";
        		$data['lender_libelle']=$info_996[$nb_expl]['a'];
        		$book_lender_id=lender::import($data);*/
        //Propriétaire
        if ($tmp = trim($exemplaires[$nb_expl]["lender_libelle"])) {
            $requete = "SELECT idlender FROM lenders WHERE lender_libelle LIKE '" . addslashes($tmp) . "'";
            $res = mysql_query($requete);
            if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
                $local_book_lender_id = $id;
            } else {
                $local_book_lender_id = $book_lender_id;
            }
        } else {
            $local_book_lender_id = $book_lender_id;
        }
        /* préparation du tableau à passer à la méthode */
        $cbarre = $exemplaires[$nb_expl]["expl_cb"];
        if (!$cbarre) {
            $mon_msg = "ERREUR : J'ai un exemplaire sans code barres il ne sera donc pas créé";
            affiche_mes_erreurs($mon_msg);
            continue;
        }
        $pb = 1;
        $num_login = 1;
        $expl['cb'] = $cbarre;
        while ($pb == 1) {
            $q = "SELECT expl_cb FROM exemplaires WHERE expl_cb='" . addslashes($expl['cb']) . "' LIMIT 1 ";
            $r = mysql_query($q);
            $nb = mysql_num_rows($r);
            if ($nb) {
                $expl['cb'] = $cbarre . "-" . $num_login;
                $num_login++;
            } else {
                $pb = 0;
            }
        }
        if ($cbarre != $expl['cb']) {
            $mon_msg = "ERREUR : l'exemplaire avec le code barres : " . $cbarre . " existe déjà donc il ne sera pas créé";
            affiche_mes_erreurs($mon_msg);
            continue;
        }
        if ($bulletin_ex) {
            $expl['bulletin'] = $bulletin_ex;
            $expl['notice'] = 0;
        } else {
            $expl['notice'] = $notice_id;
            $expl['bulletin'] = 0;
        }
        //Support exemplaire
        $data_doc = array();
        $data_doc['tdoc_libelle'] = $exemplaires[$nb_expl]["tdoc_libelle"];
        //if (!$data_doc['tdoc_libelle']) $data_doc['tdoc_libelle'] = "Indéterminé" ;
        $requete = "SELECT idtyp_doc FROM docs_type WHERE tdoc_libelle LIKE '" . addslashes($data_doc['tdoc_libelle']) . "'";
        $res = mysql_query($requete);
        if ($data_doc['tdoc_libelle'] && mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['typdoc'] = $id;
        } else {
            $data_doc['duree_pret'] = 0;
            /* valeur par défaut */
            $data_doc['tdoc_codage_import'] = $exemplaires[$nb_expl]["tdoc_codage_import"];
            if ($tdoc_codage) {
                $data_doc['tdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['tdoc_owner'] = 0;
            }
            $expl['typdoc'] = docs_type::import($data_doc);
        }
        $expl['cote'] = $exemplaires[$nb_expl]["expl_cote"];
        //Section
        $data_doc = array();
        $data_doc['section_libelle'] = $exemplaires[$nb_expl]["section_libelle"];
        $requete = "SELECT idsection FROM docs_section WHERE section_libelle LIKE '" . addslashes($data_doc['section_libelle']) . "'";
        $res = mysql_query($requete);
        if ($data_doc['section_libelle'] && mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['section'] = $id;
        } else {
            $data_doc['sdoc_codage_import'] = $exemplaires[$nb_expl]["sdoc_codage_import"];
            if ($sdoc_codage) {
                $data_doc['sdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['sdoc_owner'] = 0;
            }
            $expl['section'] = docs_section::import($data_doc);
        }
        //Statut
        $data_doc = array();
        $data_doc['statut_libelle'] = $exemplaires[$nb_expl]["statut_libelle"];
        $requete = "SELECT  idstatut FROM docs_statut WHERE statut_libelle LIKE '" . addslashes($data_doc['statut_libelle']) . "'";
        $res = mysql_query($requete);
        if ($data_doc['statut_libelle'] && mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['statut'] = $id;
        } elseif ($exemplaires[$nb_expl]["statusdoc_codage_import"]) {
            $data_doc['pret_flag'] = 1;
            $data_doc['statusdoc_codage_import'] = $exemplaires[$nb_expl]["statusdoc_codage_import"];
            if ($sdoc_codage) {
                $data_doc['statusdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['statusdoc_owner'] = 0;
            }
            $expl['statut'] = docs_statut::import($data_doc);
        } else {
            $expl['statut'] = $book_statut_id;
        }
        //Localisation
        $requete = "SELECT idlocation FROM docs_location WHERE location_libelle LIKE '" . addslashes($exemplaires[$nb_expl]["location_libelle"]) . "'";
        $res = mysql_query($requete);
        if (mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['location'] = $id;
        } else {
            $expl['location'] = $book_location_id;
        }
        //Code stat
        $data_doc = array();
        $data_doc['codestat_libelle'] = $exemplaires[$nb_expl]["codestat_libelle"];
        $requete = "SELECT idcode FROM docs_codestat WHERE codestat_libelle  LIKE '" . addslashes($data_doc['codestat_libelle']) . "'";
        $res = mysql_query($requete);
        if ($data_doc['codestat_libelle'] && mysql_num_rows($res) && ($id = mysql_result($res, 0, 0))) {
            $expl['codestat'] = $id;
        } else {
            $data_doc['statisdoc_codage_import'] = $exemplaires[$nb_expl]["statisdoc_codage_import"];
            if ($statisdoc_codage) {
                $data_doc['statisdoc_owner'] = $local_book_lender_id;
            } else {
                $data_doc['statisdoc_owner'] = 0;
            }
            $expl['codestat'] = docs_codestat::import($data_doc);
        }
        $expl['creation'] = $exemplaires[$nb_expl]["create_date"];
        $expl['note'] = $exemplaires[$nb_expl]["expl_note"];
        $expl['comment'] = $exemplaires[$nb_expl]["expl_comment"];
        $expl['prix'] = $exemplaires[$nb_expl]["expl_prix"];
        $expl['expl_owner'] = $local_book_lender_id;
        $expl['cote_mandatory'] = $cote_mandatory;
        $expl['date_depot'] = $exemplaires[$nb_expl]["date_depot"];
        $expl['date_retour'] = $exemplaires[$nb_expl]["date_retour"];
        // quoi_faire
        $expl['quoi_faire'] = 2;
        $expl_id = exemplaire::import($expl);
        if ($expl_id == 0) {
            $nb_expl_ignores++;
        } else {
            //Champ perso d'exemplaire
            //echo "Passe ici<br>";
            foreach ($info_999 as $key => $value) {
                if ($value["f"] == $cbarre) {
                    //Je suis bien sur un cp de cet exemplaire
                    if (!renseigne_cp($value, $expl_id, "expl")) {
                        $mon_msg = "La valeur  : " . $value["a"] . " n'a pas été reprise dans le champ personnalisé : " . $value["n"] . " car le champ n'existe pas";
                        affiche_mes_erreurs($mon_msg);
                    } else {
                        unset($info_999[$key]);
                    }
                }
            }
        }
    }
    // fin for
}