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, $info_464;
    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'];
        if ($bulletin_ex && is_array($info_464)) {
            $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'] = "ARCHIVES";
        }
        // $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']     à 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']   = $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'] = "cdi";
        }
        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++;
        }
        //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
}
예제 #2
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
}
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
}
예제 #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 $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
}
예제 #5
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
}
예제 #6
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
}
예제 #7
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $nb_expl_ignores;
    global $prix, $notice_id, $info_996, $info_995;
    // 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];
    // 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'];
        $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'];
        }
        $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'];
        $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'] = 1;
        // 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.
        $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
}
예제 #8
0
function maj_lect_par_lect($tab, $dbh, $statut, $id_lect)
{
    global $lect_modif, $lect_erreur;
    /*Les informations qui sont mise à jour sont :
     * l'adresse, le code postal, la ville, le pays, le telephone, emailPerso, la locatisation et le groupe
     */
    $requete = "update empr set ";
    $requete .= "empr_cp='" . addslashes($tab[5]) . "'";
    $requete .= ", empr_ville='" . addslashes(ucfirst(mb_strtolower($tab[6]))) . "'";
    $requete .= ", empr_adr1='" . addslashes($tab[4]) . "'";
    $requete .= ", empr_pays='" . addslashes($tab[7]) . "'";
    $requete .= ", empr_tel1='" . addslashes($tab[8]) . "'";
    $requete .= ", empr_tel2='" . addslashes($tab[9]) . "'";
    $requete .= ", empr_mail='" . addslashes($tab[10]) . "'";
    if (count($tab) == 18) {
        //Si on a 18 champs c'est un etudiant
        $requete .= ", empr_login='******'";
    } else {
        //Sinon c'est un prof
        $requete .= ", empr_login='******'";
    }
    if ($tab[14]) {
        $data2 = array();
        $data2['location_libelle'] = $tab[14];
        $data2['locdoc_codage_import'] = $tab[14];
        $data2['locdoc_owner'] = 0;
        $localisation = docs_location::import($data2);
        $requete .= ", empr_location='" . $localisation . "'";
    }
    if ($statut) {
        //On repasse le statut de tous les lecteurs à "Indétermiè" et on remet les dates
        $requete .= ", empr_date_adhesion='" . addslashes(date('Y-m-j')) . "'";
        $requete .= ", empr_modif='" . addslashes(date('Y-m-j')) . "'";
        if ($result = mysql_query("SELECT DATE_ADD('" . addslashes(date('Y-m-j')) . "', INTERVAL 1 YEAR)")) {
            if ($row = mysql_fetch_row($result)) {
                $requete .= ", empr_date_expiration='" . addslashes($row[0]) . "'";
            }
        }
        $q = "select idstatut from empr_statut where statut_libelle='Importé' limit 1";
        $r = mysql_query($q, $dbh);
        if (mysql_num_rows($r)) {
            $requete .= ", empr_statut='" . mysql_result($r, 0, 0) . "'";
        } else {
            $q = "insert into empr_statut (statut_libelle) values ('Importé') ";
            $r = mysql_query($q, $dbh);
            $requete .= ", empr_statut='" . mysql_insert_id($dbh) . "'";
        }
    } else {
        $requete .= ", empr_modif='" . addslashes(date('Y-m-j')) . "'";
    }
    $requete .= " where id_empr='" . $id_lect . "'";
    if (mysql_query($requete)) {
        $lect_modif++;
    } else {
        $lect_erreur++;
        echo "Requete echoué : " . $requete . "<br>";
    }
    //Traitement des groupes
    $requete = "delete from empr_groupe where empr_id='" . $id_lect . "'";
    if (!mysql_query($requete)) {
        echo "Requete echoué : " . $requete . "<br>";
    }
    if (trim($tab[15])) {
        //On créer le groupe si il n'existe pas et on y affecte le lecteur
        $requete = "select id_groupe from groupe where libelle_groupe='" . addslashes(trim($tab[15])) . "'";
        $r = mysql_query($requete, $dbh);
        if (mysql_num_rows($r)) {
            $id_grp = mysql_result($r, 0, 0);
        } else {
            $q = "insert into groupe (libelle_groupe) values ('" . addslashes(trim($tab[15])) . "') ";
            $r = mysql_query($q, $dbh);
            $id_grp = mysql_insert_id($dbh);
        }
        $requete = "insert into empr_groupe(empr_id,groupe_id) values ('" . $id_lect . "','" . $id_grp . "')";
        if (!mysql_query($requete)) {
            echo "Requete echoué : " . $requete . "<br>";
        }
    }
    if (trim($tab[16]) and trim($tab[16]) != trim($tab[15])) {
        //On créer le groupe si il n'existe pas et on y affecte le lecteur
        $requete = "select id_groupe from groupe where libelle_groupe='" . addslashes(trim($tab[16])) . "'";
        $r = mysql_query($requete, $dbh);
        if (mysql_num_rows($r)) {
            $id_grp = mysql_result($r, 0, 0);
        } else {
            $q = "insert into groupe (libelle_groupe) values ('" . addslashes(trim($tab[16])) . "') ";
            $r = mysql_query($q, $dbh);
            $id_grp = mysql_insert_id($dbh);
        }
        $requete = "insert into empr_groupe(empr_id,groupe_id) values ('" . $id_lect . "','" . $id_grp . "')";
        if (!mysql_query($requete)) {
            echo "Requete echoué : " . $requete . "<br>";
        }
    }
    if ($tab[13] and count($tab) == 18) {
        //Traitement du champs perso email
        $q = "select idchamp from empr_custom where name='email_perso' limit 1";
        $r = mysql_query($q, $dbh);
        if (mysql_num_rows($r)) {
            $idchamp = mysql_result($r, 0, 0);
            //On supprime l'ancien
            $requete = "delete from empr_custom_values where empr_custom_origine='" . $id_lect . "' and empr_custom_champ='" . $idchamp . "'";
            if (!mysql_query($requete)) {
                echo "Requete echoué : " . $requete . "<br>";
            }
            //On créer le nouveau
            $q = "insert into empr_custom_values (empr_custom_champ, empr_custom_origine, empr_custom_small_text) ";
            $q .= "values('" . $idchamp . "', '" . $id_lect . "','" . addslashes($tab[13]) . "' ) ";
            mysql_query($q, $dbh);
        }
    }
}
예제 #9
0
function traite_exemplaires()
{
    global $msg, $dbh;
    global $prix, $notice_id, $tdoc_codage, $book_lender_id, $sdoc_codage, $book_statut_id, $locdoc_codage, $statisdoc_codage, $cote_mandatory;
    global $info_997;
    global $idcode_stat_expl;
    // lu en 010$d de la notice
    $price = $prix[0];
    // la zone 997 est répétable ?
    for ($nb_expl = 0; $nb_expl < sizeof($info_997); $nb_expl++) {
        /* RAZ expl */
        $expl = array();
        /* préparation du tableau à passer à la méthode */
        if (!$info_997[$nb_expl]['a']) {
            $expl['cb'] = "ABS {$notice_id}";
        } else {
            $expl['cb'] = $info_997[$nb_expl]['a'];
        }
        $expl['notice'] = $notice_id;
        // Type de document
        $data_doc = array();
        $data_doc['tdoc_libelle'] = $info_997[$nb_expl]['t'] . " -Importé";
        $data_doc['duree_pret'] = 0;
        /* valeur par défaut */
        $data_doc['tdoc_codage_import'] = $info_997[$nb_expl]['t'];
        if ($tdoc_codage) {
            $data_doc['tdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['tdoc_owner'] = 0;
        }
        $expl['typdoc'] = docs_type::import($data_doc);
        // cote du document : $3 ?
        $expl['cote'] = $info_997[$nb_expl]['3'];
        // Section
        $data_doc = array();
        $data_doc['section_libelle'] = $info_997[$nb_expl]['d'] . " -Importé";
        $data_doc['sdoc_codage_import'] = $info_997[$nb_expl]['d'];
        if ($sdoc_codage) {
            $data_doc['sdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['sdoc_owner'] = 0;
        }
        $expl['section'] = docs_section::import($data_doc);
        // Statut : choisi lors de l'import
        $expl['statut'] = $book_statut_id;
        // Localisation
        $data_doc = array();
        $data_doc['location_libelle'] = $info_997[$nb_expl]['c'] . "-Importé";
        $data_doc['locdoc_codage_import'] = $info_997[$nb_expl]['c'];
        if ($locdoc_codage) {
            $data_doc['locdoc_owner'] = $book_lender_id;
        } else {
            $data_doc['locdoc_owner'] = 0;
        }
        $expl['location'] = docs_location::import($data_doc);
        // Code statistique : fixé dans le paramétrage
        $expl['codestat'] = $idcode_stat_expl;
        $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
}
예제 #10
0
 function import($data)
 {
     //champs de data : nom, prenom, cb, adr1, adr2,cp, ville, pays, mail, tel1, sms, tel2, year, sexe, login, password, date_adhesion, date_fin_blocage, date_expiration, date_creation
     //date_modif, prof, total_loans,last_loan_date, lang, msg, type_abt,
     //Pour la localisation : location, location_libelle, location_libelle_create, locdoc_owner
     //Pour la categorie : categ, categ_libelle, categ_libelle_create;
     //Pour le codestat: codestat, codestat_libelle, codestat_libelle_create;
     //Pour le statut: statut, statut_libelle, statut_libelle_create;
     global $dbh, $lang;
     // 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 si le lecteur a au moin un nom ou un prenom
     if (!$data['nom']) {
         return 0;
     }
     //Check si le code barre n'est pas déja utilisé
     $this->cb = addslashes($data['cb']);
     $query = "SELECT id_empr FROM empr WHERE empr_cb='" . $this->cb . "' LIMIT 1 ";
     $result = @mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT in database");
     }
     //On prepare les paramètres
     $this->empr_location = 0;
     if (!$data['location'] and !$data['location_libelle'] and $data['location_libelle_create'] != '') {
         //Dans la cas ou l'on veut creer la location
         $data2 = array();
         $data2['location_libelle'] = $data['location_libelle_create'];
         $data2['locdoc_codage_import'] = $data['location_libelle_create'];
         $data2['locdoc_owner'] = $data['locdoc_owner'];
         $this->empr_location = docs_location::import($data2);
     } elseif ($data['location_libelle'] != '') {
         $q = "select idlocation from docs_location where location_libelle='" . addslashes($data['location_libelle']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->empr_location = mysql_result($r, 0, 0);
         }
     } else {
         $q = "select idlocation from docs_location where idlocation='" . addslashes($data['location']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->empr_location = mysql_result($r, 0, 0);
         }
     }
     if (!$this->empr_location) {
         return 0;
     }
     $this->categ = 0;
     if (!$data['categ'] and !$data['categ_libelle'] and $data['categ_libelle_create'] != '') {
         //Dans la cas ou l'on veut creer la location
         $q = "select id_categ_empr from empr_categ where libelle='" . addslashes($data['categ_libelle_create']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->categ = mysql_result($r, 0, 0);
         } else {
             $q = "insert into empr_categ (libelle) values ('" . addslashes($data['categ_libelle_create']) . "') ";
             $r = mysql_query($q, $dbh);
             $this->categ = mysql_insert_id($dbh);
         }
     } elseif ($data['categ_libelle'] != '') {
         $q = "select id_categ_empr from empr_categ where libelle='" . addslashes($data['categ_libelle']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->categ = mysql_result($r, 0, 0);
         }
     } else {
         $q = "select id_categ_empr from empr_categ where id_categ_empr='" . addslashes($data['categ']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->categ = mysql_result($r, 0, 0);
         }
     }
     if (!$this->categ) {
         return 0;
     }
     $this->cstat = 0;
     if (!$data['codestat'] and !$data['codestat_libelle'] and $data['codestat_libelle_create'] != '') {
         //Dans la cas ou l'on veut creer la location
         $q = "select idcode from empr_codestat where libelle='" . addslashes($data['codestat_libelle_create']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->cstat = mysql_result($r, 0, 0);
         } else {
             $q = "insert into empr_codestat (libelle) values ('" . addslashes($data['codestat_libelle_create']) . "') ";
             $r = mysql_query($q, $dbh);
             $this->cstat = mysql_insert_id($dbh);
         }
     } elseif ($data['codestat_libelle'] != '') {
         $q = "select idcode from empr_codestat where libelle='" . addslashes($data['codestat_libelle']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->cstat = mysql_result($r, 0, 0);
         }
     } else {
         $q = "select idcode from empr_codestat where idcode='" . addslashes($data['codestat']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->cstat = mysql_result($r, 0, 0);
         }
     }
     if (!$this->cstat) {
         return 0;
     }
     $this->empr_statut = 0;
     if (!$data['statut'] and !$data['statut_libelle'] and $data['statut_libelle_create'] != '') {
         //Dans la cas ou l'on veut creer la location
         $q = "select idstatut from empr_statut where statut_libelle='" . addslashes($data['statut_libelle_create']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->empr_statut = mysql_result($r, 0, 0);
         } else {
             $q = "insert into empr_statut (statut_libelle) values ('" . addslashes($data['statut_libelle_create']) . "') ";
             $r = mysql_query($q, $dbh);
             $this->empr_statut = mysql_insert_id($dbh);
         }
     } elseif ($data['statut_libelle'] != '') {
         $q = "select idstatut from empr_statut where statut_libelle='" . addslashes($data['statut_libelle']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->empr_statut = mysql_result($r, 0, 0);
         }
     } else {
         $q = "select idstatut from empr_statut where idstatut='" . addslashes($data['statut']) . "' limit 1";
         $r = mysql_query($q, $dbh);
         if (mysql_num_rows($r)) {
             $this->empr_statut = mysql_result($r, 0, 0);
         }
     }
     if (!$this->empr_statut) {
         return 0;
     }
     $this->nom = addslashes($data['nom']);
     $this->prenom = addslashes($data['prenom']);
     $this->adr1 = addslashes($data['adr1']);
     $this->adr2 = addslashes($data['adr2']);
     $this->cp = addslashes($data['cp']);
     $this->ville = addslashes($data['ville']);
     $this->pays = addslashes($data['pays']);
     $this->mail = addslashes($data['mail']);
     $this->tel1 = addslashes($data['tel1']);
     $this->sms = addslashes($data['sms']);
     $this->tel2 = addslashes($data['tel2']);
     if ($data['sexe'] === 0 or $data['sexe'] == 1 or $data['sexe'] == 2) {
         $this->sexe = $data['sexe'];
     } else {
         $this->sexe = 0;
     }
     $this->birth = addslashes($data['year']);
     $this->date_adhesion = addslashes($data['date_adhesion']);
     $this->date_blocage = addslashes($data['date_fin_blocage']);
     $this->date_expiration = addslashes($data['date_expiration']);
     if (!$data['date_creation']) {
         $this->cdate = today();
     } else {
         $this->cdate = addslashes($data['date_creation']);
     }
     if (!$data['date_modif']) {
         $this->mdate = today();
     } else {
         $this->mdate = addslashes($data['date_modif']);
     }
     $this->pwd = addslashes($data['password']);
     $this->prof = addslashes($data['prof']);
     $this->total_loans = addslashes($data['total_loans']);
     $this->last_loan_date = addslashes($data['last_loan_date']);
     if (!$data['lang']) {
         $this->empr_lang = $lang;
     } else {
         $this->empr_lang = addslashes($data['lang']);
     }
     $this->empr_msg = addslashes($data['msg']);
     $this->type_abt = addslashes($data['type_abt']);
     $this->login = addslashes($data['login']);
     $q = "insert into empr (empr_cb, empr_nom, empr_prenom, empr_adr1, empr_cp, empr_ville, empr_pays, ";
     $q .= "empr_mail, empr_tel1, empr_sms, empr_categ, empr_codestat, empr_sexe, empr_login, empr_date_adhesion, ";
     $q .= "empr_date_expiration, empr_lang, empr_location,empr_msg,empr_year,empr_creation,empr_adr2,empr_tel2, empr_modif,empr_password,empr_prof,type_abt,empr_statut,total_loans,last_loan_date,date_fin_blocage) ";
     $q .= "values ('" . $this->cb . "', '" . $this->nom . "', '" . $this->prenom . "', '" . $this->adr1 . "', '" . $this->cp . "', '" . $this->ville . "', '" . $this->pays . "', ";
     $q .= "'" . $this->mail . "', '" . $this->tel1 . "', '" . $this->sms . "', '" . $this->categ . "', '" . $this->cstat . "', '" . $this->sexe . "', '" . $this->login . "', '" . $this->date_adhesion . "', ";
     $q .= "'" . $this->date_expiration . "', '" . $this->empr_lang . "', '" . $this->empr_location . "', '" . $this->empr_msg . "', '" . $this->birth . "', '" . $this->cdate . "', '" . $this->adr2 . "', '" . $this->tel2 . "', '" . $this->mdate . "', '" . $this->pwd . "', '" . $this->prof . "','" . $this->type_abt . "','" . $this->empr_statut . "','" . $this->total_loans . "', '" . $this->last_loan_date . "', '" . $this->date_blocage . "') ";
     $r = mysql_query($q, $dbh);
     return mysql_insert_id($dbh);
 }