Example #1
0
function get_relance($id_empr)
{
    global $dbh, $charset, $msg, $pmb_gestion_financiere, $pmb_gestion_amende;
    global $pmb_lecteurs_localises;
    // liste des relances
    if ($pmb_gestion_financiere && $pmb_gestion_amende) {
        $amende = new amende($id_empr);
        $level = $amende->get_max_level();
        $niveau_min = $level["level_min"];
        $id_expl = $level["level_min_id_expl"];
        $total_amende = $amende->get_total_amendes();
    }
    $niveau_suppose = $level["level_normal"];
    $cpt_id = comptes::get_compte_id_from_empr($id_empr, 2);
    $cpt = new comptes($cpt_id);
    $frais_relance = $cpt->summarize_transactions("", "", 0, $realisee = -1);
    if ($frais_relance < 0) {
        $frais_relance = -$frais_relance;
    } else {
        $frais_relance = 0;
    }
    $empr = new emprunteur($id_empr, '', FALSE, 0);
    //Groupes
    if (count($empr->groupes)) {
        $lib_groupes = strip_tags(implode(" / ", $empr->groupes));
    } else {
        $lib_groupes = "";
    }
    $info_empr = "\n\t<td>" . $empr->cb . "</td>\n\t<td>" . $empr->nom . "</td>\n\t<td>" . $empr->prenom . "</td>\n\t<td>" . $empr->adr1 . "</td>\n\t<td>" . $empr->adr2 . "</td>\n\t<td>" . $empr->cp . "</td>\n\t<td>" . $empr->ville . "</td>\n\t<td>" . $empr->mail . "</td>\n\t<td>" . $empr->tel1 . "</td>\n\t<td>" . $empr->tel2 . "</td>\n\t" . ($pmb_lecteurs_localises ? "<td>" . $empr->empr_location_l . "</td>" : "") . "\n\t<td>" . $empr->cat_l . "</td>\n\t<td>" . $empr->cstat_l . "</td>\n\t<td>" . $empr->empr_statut_libelle . "</td>\n\t<td>" . $lib_groupes . "</td>\n\t<td>" . $niveau_suppose . "</td>\n\t<td>" . $total_amende . "</td>\n\t<td>" . $frais_relance . "</td>\n\t";
    $reqexpl = "select pret_idexpl as expl from pret where pret_retour<CURDATE() and pret_idempr={$id_empr}";
    $resexple = pmb_mysql_query($reqexpl, $dbh);
    while ($liste = pmb_mysql_fetch_object($resexple)) {
        $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour ";
        $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_id, expl_cb,expl_cote, pret_date, pret_retour,\n\t\tniveau_relance,\n\t\tdate_relance,\n\t\tprinted,\t\t\n\t\ttdoc_libelle, section_libelle, location_libelle, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date!='', concat(' (',mention_date,')') ,''))) as tit, " . $dates_resa_sql . ", ";
        $requete .= " notices_m.tparent_id, notices_m.tnvol ";
        $requete .= " FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), docs_type, docs_section, docs_location, pret ";
        $requete .= " WHERE expl_id='" . $liste->expl . "' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id  ";
        $res_det_expl = pmb_mysql_query($requete);
        $expl = pmb_mysql_fetch_object($res_det_expl);
        $amd = $amende->get_amende($liste->expl);
        $reqlog = "select sum(log.log_printed) as printed, sum(log.log_mail) as mail\n\t\t\tfrom log_retard as log, log_expl_retard  as expl where log.idempr={$id_empr} and  log.niveau_reel='" . $expl->niveau_relance . "'\n\t\t \tand expl.num_log_retard=log.id_log and expl_id='" . $liste->expl . "' ";
        $reslog = pmb_mysql_query($reqlog);
        if ($log = pmb_mysql_fetch_object($reslog)) {
            $printed = $log->printed;
            $mail = $log->mail;
        } else {
            $printed = 0;
            $mail = 0;
        }
        $info .= "\n\t\t<tr>\n\t\t\t{$info_empr}\n\t\t\t<td>" . htmlentities($expl->tit, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($expl->expl_cb, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . format_date($expl->pret_date) . "</td>\n\t\t\t<td>" . format_date($expl->pret_retour) . "</td>\n\t\t\t<td>" . $expl->niveau_relance . "</td>\n\t\t\t<td>" . format_date($expl->date_relance) . "</td>\n\t\t\t<td>" . htmlentities($mail, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($printed, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($amd["valeur"], ENT_QUOTES, $charset) . "</td>\n\t\t</tr>\n\t\t";
    }
    return $info;
}
Example #2
0
function print_relance($id_empr, $mail = true)
{
    global $mailretard_priorite_email, $mailretard_priorite_email_3;
    global $dbh, $charset, $msg, $pmb_gestion_financiere, $pmb_gestion_amende;
    global $mail_sended;
    $mail_sended = 0;
    $not_mail = 0;
    if ($pmb_gestion_financiere && $pmb_gestion_amende) {
        $req = "delete from cache_amendes where id_empr=" . $id_empr;
        pmb_mysql_query($req);
        $amende = new amende($id_empr);
        $level = $amende->get_max_level();
        $niveau_min = $level["level_min"];
        $id_expl = $level["level_min_id_expl"];
        $total_amende = $amende->get_total_amendes();
    }
    //Si mail de rappel affecté au groupe, on envoi au responsable
    $requete = "select id_groupe,resp_groupe from groupe,empr_groupe where id_groupe=groupe_id and empr_id={$id_empr} and resp_groupe and mail_rappel limit 1";
    $res = pmb_mysql_query($requete);
    if (pmb_mysql_num_rows($res) > 0) {
        $requete = "select empr_mail from empr where id_empr='" . pmb_mysql_result($res, 0, 1) . "'";
        $res = pmb_mysql_query($requete);
        if (@pmb_mysql_num_rows($res)) {
            list($empr_mail) = pmb_mysql_fetch_row($res);
        }
    } else {
        $requete = "select empr_mail from empr where id_empr={$id_empr}";
        $resultat = pmb_mysql_query($requete);
        if (@pmb_mysql_num_rows($resultat)) {
            list($empr_mail) = pmb_mysql_fetch_row($resultat);
        }
    }
    if ($niveau_min) {
        //Si c'est un mail
        if (($mailretard_priorite_email == 1 || $mailretard_priorite_email == 2) && $empr_mail && ($niveau_min < 3 || $mailretard_priorite_email_3) && $mail) {
            if (send_mail($id_empr, $niveau_min)) {
                $requete = "update pret set printed=1 where pret_idexpl=" . $id_expl;
                pmb_mysql_query($requete, $dbh);
                $mail_sended = 1;
            }
        } else {
            $requete = "update pret set printed=2 where pret_idexpl=" . $id_expl;
            pmb_mysql_query($requete, $dbh);
            $not_mail = 1;
            //Débit du compte lecteur
            /*$frais="finance_relance_".$niveau_min;
            		global $$frais;
            		if ($$frais) {
            			$id_compte=comptes::get_compte_id_from_empr($id_empr,2);
            			if ($id_compte) {
            				$cpte=new comptes($id_compte);
            				$cpte->record_transaction("",$$frais,-1,sprintf($msg["relance_frais_relance_level"],$niveau_min));
            			}
            		}*/
        }
    }
    $req = "delete from cache_amendes where id_empr=" . $id_empr;
    pmb_mysql_query($req);
    //On loggue les infos de la lettre
    $niveau_courant = $niveau_min;
    if ($niveau_courant) {
        $niveau_suppose = $level["level_normal"];
        $cpt_id = comptes::get_compte_id_from_empr($id_empr, 2);
        $cpt = new comptes($cpt_id);
        $solde = $cpt->update_solde();
        $frais_relance = $cpt->summarize_transactions("", "", 0, $realisee = -1);
        if ($frais_relance < 0) {
            $frais_relance = -$frais_relance;
        } else {
            $frais_relance = 0;
        }
        $req = "insert into log_retard (niveau_reel,niveau_suppose,amende_totale,frais,idempr,log_printed,log_mail) values('" . $niveau_courant . "','" . $niveau_suppose . "','" . $total_amende . "','" . $frais_relance . "','" . $id_empr . "', '" . $not_mail . "', '" . $mail_sended . "')";
        pmb_mysql_query($req, $dbh);
        $id_log_ret = pmb_mysql_insert_id();
        $reqexpl = "select pret_idexpl as expl from pret where pret_retour<\tCURDATE() and pret_idempr={$id_empr}";
        $resexple = pmb_mysql_query($reqexpl, $dbh);
        while ($liste = pmb_mysql_fetch_object($resexple)) {
            $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour ";
            $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_id, expl_cb,expl_cote, pret_date, pret_retour, tdoc_libelle, section_libelle, location_libelle, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date!='', concat(' (',mention_date,')') ,''))) as tit, " . $dates_resa_sql . ", ";
            $requete .= " notices_m.tparent_id, notices_m.tnvol ";
            $requete .= " FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), docs_type, docs_section, docs_location, pret ";
            $requete .= " WHERE expl_id='" . $liste->expl . "' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id  ";
            $res_det_expl = pmb_mysql_query($requete);
            $expl = pmb_mysql_fetch_object($res_det_expl);
            if ($pmb_gestion_financiere && $pmb_gestion_amende) {
                $amd = $amende->get_amende($liste->expl);
            }
            $req_ins = "insert into log_expl_retard (titre,expl_id,expl_cb,date_pret,date_retour,amende,num_log_retard) values('" . addslashes($expl->tit) . "','" . $expl->expl_id . "','" . $expl->expl_cb . "','" . $expl->pret_date . "','" . $expl->pret_retour . "','" . $amd["valeur"] . "','" . $id_log_ret . "')";
            pmb_mysql_query($req_ins, $dbh);
        }
    }
    return $not_mail;
}
 function fetch_data()
 {
     global $dbh;
     global $msg;
     global $charset;
     global $val_list_empr;
     global $pmb_gestion_financiere, $pmb_gestion_abonnement, $pmb_gestion_tarif_prets, $pmb_gestion_amende;
     global $deflt_docs_location;
     if (!$this->id_empr || !$dbh) {
         return FALSE;
     }
     $requete = "SELECT e.*, c.libelle AS code1, s.libelle AS code2, es.statut_libelle AS empr_statut_libelle, allow_loan, allow_book, allow_opac, allow_dsi, allow_dsi_priv, allow_sugg, allow_prol, d.location_libelle as localisation, date_format(empr_date_adhesion, '" . $msg["format_date"] . "') as aff_empr_date_adhesion, date_format(empr_date_expiration, '" . $msg["format_date"] . "') as aff_empr_date_expiration FROM empr e left join docs_location as d on e.empr_location=d.idlocation, empr_categ c, empr_codestat s, empr_statut es ";
     $requete .= " WHERE e.id_empr='" . $this->id_empr . "' ";
     $requete .= " AND c.id_categ_empr=e.empr_categ";
     $requete .= " AND s.idcode=e.empr_codestat";
     $requete .= " AND es.idstatut=e.empr_statut";
     $requete .= " LIMIT 1";
     $result = pmb_mysql_query($requete, $dbh) or die(pmb_mysql_error() . " " . $requete);
     if (!pmb_mysql_num_rows($result)) {
         return FALSE;
     }
     $empr = pmb_mysql_fetch_object($result);
     // affectation des propriétés
     $this->empr_cb = $empr->empr_cb;
     // code barre emprunteur
     $this->empr_nom = $empr->empr_nom;
     // nom emprunteur
     $this->empr_prenom = $empr->empr_prenom;
     // prénom mprunteur
     $this->empr_adr1 = $empr->empr_adr1;
     // adresse ligne 1
     $this->empr_adr2 = $empr->empr_adr2;
     // adresse ligne 2
     $this->empr_cp = $empr->empr_cp;
     // code postal
     $this->empr_ville = $empr->empr_ville;
     // ville
     $this->empr_pays = $empr->empr_pays;
     // ville
     $this->empr_mail = $empr->empr_mail;
     // adresse email
     $this->empr_tel1 = $empr->empr_tel1;
     // téléphone 1
     $this->empr_tel2 = $empr->empr_tel2;
     // téléphone 2
     $this->empr_prof = $empr->empr_prof;
     // profession
     $this->empr_year = $empr->empr_year;
     // année de naissance
     $this->empr_categ = $empr->empr_categ;
     // catégorie emprunteur
     $this->empr_codestat = $empr->empr_codestat;
     // code statistique
     $this->empr_creation = $empr->empr_creation;
     // date de création
     $this->empr_modif = $empr->empr_modif;
     // date de modification
     $this->empr_sexe = $empr->empr_sexe;
     // sexe de l'emprunteur
     $this->empr_login = $empr->empr_login;
     // login pour services OPAC
     $this->empr_password = $empr->empr_password;
     // mot de passe OPAC
     $this->empr_ldap = $empr->empr_ldap;
     $this->type_abt = $empr->type_abt;
     // type d'abonnement
     $this->empr_location = $empr->empr_location;
     // localisation
     $this->empr_location_l = $empr->localisation;
     // localisation
     $this->date_fin_blocage = $empr->date_fin_blocage;
     // Date de fin de blocage de l'emprunteur
     $this->empr_statut = $empr->empr_statut;
     $this->empr_statut_l = $empr->empr_statut_libelle;
     $this->total_loans = $empr->total_loans;
     $this->date_adhesion = $empr->empr_date_adhesion;
     // début adhésion
     $this->date_expiration = $empr->empr_date_expiration;
     // fin adhésion
     $this->aff_date_adhesion = $empr->aff_empr_date_adhesion;
     // début adhésion
     $this->aff_date_expiration = $empr->aff_empr_date_expiration;
     // fin adhésion
     $this->empr_msg = $empr->empr_msg;
     // message emprunteur
     $this->cat_l = $empr->code1;
     // libellé catégorie emprunteur
     $this->cstat_l = $empr->code2;
     // libellé code statistique. voir ce bug avec Eric
     $this->allow_loan = $empr->allow_loan;
     $this->allow_book = $empr->allow_book;
     $this->allow_opac = $empr->allow_opac;
     $this->allow_dsi = $empr->allow_dsi;
     $this->allow_dsi_priv = $empr->allow_dsi_priv;
     $this->allow_sugg = $empr->allow_sugg;
     $this->allow_prol = $empr->allow_prol;
     global $selector_prop_ajout_caddie_empr, $empr_show_caddie;
     if ($empr_show_caddie) {
         $this->img_ajout_empr_caddie = "<img src='./images/basket_empr.gif' align='middle' alt='basket' title=\"{$msg[400]}\" onClick=\"openPopUp('./cart.php?object_type=EMPR&item=" . $this->id . "', 'cart', 600, 700, -2, -2, '{$selector_prop_ajout_caddie_empr}')\">";
     } else {
         $this->img_ajout_empr_caddie = "";
     }
     $this->lien_nom_prenom = "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($this->cb) . "'>{$this->nom},&nbsp;{$this->prenom}</a>";
     $date_blocage = array();
     $date_blocage = explode("-", $this->date_fin_blocage);
     if (mktime(0, 0, 0, $date_blocage[1], $date_blocage[2], $date_blocage[0]) > time()) {
         $this->blocage_active = true;
     }
     //Groupes
     $requete = "select id_groupe, libelle_groupe from groupe, empr_groupe where empr_id='" . $this->id . "' and id_groupe=groupe_id";
     $result = pmb_mysql_query($requete);
     if (pmb_mysql_num_rows($result)) {
         while ($grp_temp = pmb_mysql_fetch_object($result)) {
             $this->groupes[] = "<a href='./circ.php?categ=groups&action=showgroup&groupID=" . $grp_temp->id_groupe . "'>" . htmlentities($grp_temp->libelle_groupe, ENT_QUOTES, $charset) . "</a>";
         }
     } else {
         $this->groupes = array();
     }
     //Paramètres perso
     //Liste des champs
     $p_perso = new parametres_perso("empr");
     $perso_ = $p_perso->show_fields($this->id_empr);
     $perso = "";
     $class = "colonne3";
     $c = 0;
     if (count($perso_["FIELDS"])) {
         for ($i = 0; $i < count($perso_["FIELDS"]); $i++) {
             $p = $perso_["FIELDS"][$i];
             $perso .= "<div class='{$class}'>";
             $perso .= "<div class='row'>" . $p["TITRE"];
             $perso .= $p["AFF"] . "</div>";
             $perso .= "</div>";
             if ($c == 0) {
                 $c = 1;
             } else {
                 if ($c == 1) {
                     $class = "colonne_suite";
                     $c = 2;
                 } else {
                     if ($c == 2) {
                         $class = "colonne3";
                         $c = 0;
                     }
                 }
             }
         }
         $reste = 2 - $c;
         if ($c != 0) {
             for ($i = 0; $i < $reste; $i++) {
                 $perso .= "<div class='colonne3'>&nbsp;</div>";
                 $c++;
             }
             $perso .= "<div class='colonne_suite'>&nbsp;</div>";
         }
     }
     $this->perso = $perso;
     //Comptes si gestion financiere
     if ($pmb_gestion_financiere) {
         $compte = "";
         $n_c = 0;
         $neg = "<span class='erreur'>%s</span>";
         $pos = "%s";
         $compte .= "<div class='row'><hr /></div><div class='row'>";
         if ($pmb_gestion_abonnement) {
             $cpt_id = comptes::get_compte_id_from_empr($this->id, 1);
             $cpt = new comptes($cpt_id);
             $solde = $cpt->update_solde();
             $novalid = $cpt->summarize_transactions("", "", 0, 0);
             if ($cpt_id) {
                 $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=1'>" . $msg["finance_solde_abt"] . "</a></strong> " . comptes::format($solde) . "</div>";
                 if ($novalid) {
                     $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>";
                 }
                 $compte .= "</div>";
             }
             $n_c++;
         }
         if ($pmb_gestion_tarif_prets) {
             $cpt_id = comptes::get_compte_id_from_empr($this->id, 3);
             $cpt = new comptes($cpt_id);
             $solde = $cpt->update_solde();
             $novalid = $cpt->summarize_transactions("", "", 0, 0);
             if ($cpt_id) {
                 $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=3'>" . $msg["finance_solde_pret"] . "</a></strong> " . comptes::format($solde) . "</div>";
                 if ($novalid) {
                     $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>";
                 }
                 $compte .= "</div>";
             }
             $n_c++;
         }
         if ($pmb_gestion_amende) {
             $cpt_id = comptes::get_compte_id_from_empr($this->id, 2);
             $cpt = new comptes($cpt_id);
             $solde = $cpt->update_solde();
             $novalid = $cpt->summarize_transactions("", "", 0, 0);
             if ($cpt_id) {
                 //Calcul des amendes
                 $amende = new amende($this->id);
                 $total_amende = $amende->get_total_amendes();
                 $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=2'>" . $msg["finance_solde_amende"] . "</a></strong> " . comptes::format($solde) . "</div>";
                 if ($novalid) {
                     $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>";
                 }
                 if ($total_amende) {
                     $compte .= "<div> " . $msg["finance_pret_amende_en_cours"] . " : " . comptes::format($total_amende) . "</div>";
                 }
                 $compte .= "</div>";
             }
             $n_c++;
         }
         if ($n_c < 2) {
             for ($i = $n_c; $i < 3; $i++) {
                 $compte .= "<div class='colonne3'>&nbsp;</div>";
             }
         }
         $compte .= "</div><div class='row'></div>";
     }
     $this->compte = $compte;
 }
Example #4
0
 function do_fiche()
 {
     global $empr_tmpl, $empr_pret_allowed;
     global $msg, $charset;
     global $groupID;
     global $biblio_email;
     global $pmb_lecteurs_localises;
     global $pmb_gestion_abonnement, $pmb_gestion_financiere, $pmb_gestion_tarif_prets, $pmb_gestion_amende;
     global $finance_blocage_abt, $finance_blocage_amende, $finance_blocage_pret, $pmb_blocage_retard, $pmb_blocage_retard_force;
     global $force_finance;
     global $pmb_resa_planning;
     global $dbh;
     global $pmb_blocage_retard, $pmb_blocage_coef, $pmb_blocage_max, $pmb_blocage_delai;
     global $empr_fiche_depliee;
     global $pmb_opac_view_activate;
     global $pmb_sur_location_activate;
     global $alert_sound_list;
     // l'utilisateur veut-il les sons d'alerte
     global $pmb_short_loan_management;
     $this->fiche = $empr_tmpl;
     $this->fiche = str_replace('!!cb!!', $this->cb, $this->fiche);
     $this->fiche = str_replace('!!nom!!', pmb_strtoupper($this->nom), $this->fiche);
     $this->fiche = str_replace('!!prenom!!', $this->prenom, $this->fiche);
     $this->fiche = str_replace('!!image_caddie_empr!!', $this->img_ajout_empr_caddie, $this->fiche);
     $this->fiche = str_replace('!!info_nb_pret!!', $this->nb_pret, $this->fiche);
     $this->fiche = str_replace('!!info_nb_resa!!', $this->nb_reservations, $this->fiche);
     if ($pmb_resa_planning) {
         $this->fiche = str_replace('!!info_resa_planning!!', $msg[empr_nb_resa_planning] . ":" . $this->nb_previsions, $this->fiche);
     } else {
         $this->fiche = str_replace('!!info_resa_planning!!', "", $this->fiche);
     }
     $this->fiche = str_replace('!!info_authldap!!', $this->ldap, $this->fiche);
     $this->fiche = str_replace('!!id!!', $this->id, $this->fiche);
     $this->fiche = str_replace('!!adr1!!', $this->adr1, $this->fiche);
     $this->fiche = str_replace('!!adr2!!', $this->adr2, $this->fiche);
     $this->fiche = str_replace('!!tel1!!', $this->tel1, $this->fiche);
     $this->fiche = str_replace('!!sms!!', $this->sms, $this->fiche);
     $this->fiche = str_replace('!!tel2!!', $this->tel2, $this->fiche);
     $this->fiche = str_replace('!!cp!!', $this->cp, $this->fiche);
     $this->fiche = str_replace('!!ville!!', $this->ville, $this->fiche);
     $this->fiche = str_replace('!!pays!!', $this->pays, $this->fiche);
     $emails = array();
     $email_final = array();
     $emails = explode(';', $this->mail);
     for ($i = 0; $i < count($emails); $i++) {
         $email_final[] = "<a href='mailto:" . $emails[$i] . "'>" . $emails[$i] . "</a>";
     }
     $this->fiche = str_replace('!!mail_all!!', implode("&nbsp;", $email_final), $this->fiche);
     $this->fiche = str_replace('!!prof!!', $this->prof, $this->fiche);
     $this->fiche = str_replace('!!date!!', $this->birth, $this->fiche);
     $this->fiche = str_replace('!!categ!!', $this->cat_l, $this->fiche);
     $this->fiche = str_replace('!!codestat!!', $this->cstat_l, $this->fiche);
     $this->fiche = str_replace('!!adhesion!!', $this->aff_date_adhesion, $this->fiche);
     $this->fiche = str_replace('!!expiration!!', $this->aff_date_expiration, $this->fiche);
     $this->fiche = str_replace('!!last_loan_date!!', $this->aff_last_loan_date, $this->fiche);
     $this->fiche = str_replace('!!perso!!', $this->perso, $this->fiche);
     $this->fiche = str_replace('!!header_format!!', $this->header_format, $this->fiche);
     $this->fiche = str_replace('!!empr_login!!', $this->login, $this->fiche);
     if ($this->pwd) {
         $this->fiche = str_replace('!!empr_pwd!!', "<i><strong>" . $msg["empr_pwd_opac_affected"] . "</strong></i>", $this->fiche);
     } else {
         $this->fiche = str_replace('!!empr_pwd!!', "", $this->fiche);
     }
     $this->fiche = str_replace('!!comptes!!', $this->compte, $this->fiche);
     $this->fiche = str_replace('!!empr_statut_libelle!!', $this->empr_statut_libelle, $this->fiche);
     $this->fiche = str_replace('!!empr_picture!!', $this->picture_empr($this->cb), $this->fiche);
     if ($empr_fiche_depliee == "1") {
         $this->fiche = str_replace('!!depliee!!', " startOpen=\"Yes\"", $this->fiche);
     } else {
         $this->fiche = str_replace('!!depliee!!', "", $this->fiche);
     }
     if ($pmb_lecteurs_localises) {
         $this->fiche = str_replace("<!-- !!localisation!! -->", "<div class='row'><strong>{$msg['empr_location']} : </strong>" . $this->empr_location_l . "</div>", $this->fiche);
         $resume_localisation = $this->empr_location_l;
     }
     if ($pmb_opac_view_activate) {
     }
     //Groupes
     if (count($this->groupes)) {
         $this->fiche = str_replace('!!groupes!!', "<strong>" . $msg[groupes_empr] . " : </strong>" . implode(" / ", $this->groupes) . "\n", $this->fiche);
         $resume_groupe = implode(" / ", $this->groupes);
     } else {
         $this->fiche = str_replace('!!groupes!!', "&nbsp;", $this->fiche);
     }
     // Ajout d'infos complémentaires lorsque la fiche lecteur est repliée par défaut
     $empr_resume = '';
     if ($empr_fiche_depliee == "0") {
         //localisation
         if ($resume_localisation) {
             $empr_resume = $resume_localisation . " - ";
         }
         //categ
         if ($this->cat_l) {
             $empr_resume .= $this->cat_l . " - ";
         }
         //groupe
         if ($resume_groupe) {
             $empr_resume .= $resume_groupe . " - ";
         }
     }
     $this->fiche = str_replace('!!empr_resume!!', $empr_resume, $this->fiche);
     //Pret autorisé ou non ?
     $pret_ok = 0;
     if ($pmb_gestion_financiere && $force_finance == 0) {
         $message_pret = "";
         if ($pmb_gestion_abonnement) {
             //Vérification du compte
             $cpte_abt_id = comptes::get_compte_id_from_empr($this->id, 1);
             if ($cpte_abt_id) {
                 $cpte_abt = new comptes($cpte_abt_id);
                 $solde_neg = $cpte_abt->get_solde();
                 if ($finance_blocage_abt && $solde_neg * 1 < 0) {
                     if ($pret_ok < 2) {
                         $pret_ok = $finance_blocage_abt;
                     }
                     $message_pret .= sprintf($msg["finance_pret_solde_abt"], comptes::format($solde_neg)) . "<br />";
                     $this->blocage_abt = $finance_blocage_abt;
                 }
                 if ($solde_neg * 1 < 0) {
                     $this->compte_abt = abs($solde_neg);
                 }
             }
         }
         if ($pmb_gestion_tarif_prets) {
             //Vérification du compte
             $cpte_pret_id = comptes::get_compte_id_from_empr($this->id, 3);
             if ($cpte_pret_id) {
                 $cpte_pret = new comptes($cpte_pret_id);
                 $solde_neg = $cpte_pret->get_solde();
                 if ($finance_blocage_pret && $solde_neg * 1 < 0) {
                     if ($pret_ok < 2) {
                         $pret_ok = $finance_blocage_pret;
                     }
                     $message_pret .= sprintf($msg["finance_pret_solde_pret"], comptes::format($solde_neg)) . "<br />";
                     $this->blocage_tarifs = $finance_blocage_pret;
                 }
                 if ($solde_neg * 1 < 0) {
                     $this->compte_tarifs = abs($solde_neg);
                 }
             }
         }
         if ($pmb_gestion_amende) {
             //Vérification du compte
             $cpte_amende_id = comptes::get_compte_id_from_empr($this->id, 2);
             if ($cpte_amende_id) {
                 $cpte_amende = new comptes($cpte_amende_id);
                 $solde_neg = $cpte_amende->get_solde();
                 $amende = new amende($this->id, true);
                 $amende_neg = $amende->get_total_amendes();
                 if ($finance_blocage_amende && ($solde_neg * 1 < 0 || $amende_neg * 1)) {
                     $this->blocage_amendes = $finance_blocage_amende;
                     if ($pret_ok < 2) {
                         $pret_ok = $finance_blocage_amende;
                     }
                     if ($solde_neg * 1 < 0) {
                         $message_pret .= sprintf($msg["finance_pret_solde_amende"], comptes::format($solde_neg)) . "<br />";
                     }
                     if ($amende_neg * 1) {
                         $message_pret .= sprintf($msg["finance_pret_amende_en_cours_blocage"], comptes::format($amende_neg)) . "<br />";
                     }
                 }
                 if ($solde_neg * 1 < 0) {
                     $this->compte_amendes = abs($solde_neg);
                 }
                 if ($amende_neg * 1) {
                     $this->amendes_en_cours = abs($amende_neg);
                 }
             }
         }
     }
     if ($pmb_blocage_retard && $force_finance == 0) {
         if ($this->date_blocage && $this->blocage_active) {
             $this->blocage_retard = $pmb_blocage_retard_force;
             //pas de forçage possible
             if ($pmb_blocage_retard_force == 2) {
                 $message_pret .= sprintf($msg["blocage_retard_pret"], formatdate($this->date_blocage)) . "<br />";
             } else {
                 $message_pret .= sprintf($msg["blocage_retard_pret"], formatdate($this->date_blocage)) . "&nbsp;<input type='button' value='" . $msg["blocage_params"] . "' class='bouton' onClick=\"openPopUp('./circ/blocage.php?id_empr=" . $this->id . "','blocage_params',400,200,-2,-2,'toolbar=no, dependent=yes,resizable=yes');\"/><br />";
             }
             if ($pret_ok < 2) {
                 $pret_ok = $pmb_blocage_retard_force;
             }
         }
     }
     // Ajout de l'impossibilité d'effectuer un prêt si un document n'est pas rendu
     // alors qu'il a dépassé le délai de blocage (NG72) .
     if ($pmb_blocage_retard && $force_finance == 0) {
         // Recherche la date de retour du document la plus petite, soit le plus gros retard potentiel
         $requete = "select MIN(pret_retour)as pret_retour";
         $requete .= " from pret p";
         $requete .= " where p.pret_idempr=" . $this->id;
         $result = mysql_query($requete, $dbh);
         while ($bloca = mysql_fetch_object($result)) {
             if ($bloca->pret_retour) {
                 $pret_retour = $bloca->pret_retour;
                 $date_debut = explode("-", $pret_retour);
                 $ndays = calendar::get_open_days($date_debut[2], $date_debut[1], $date_debut[0], date("d"), date("m"), date("Y"));
                 if ($ndays > $pmb_blocage_delai) {
                     $ndays = $ndays * $pmb_blocage_coef;
                     if ($ndays > $pmb_blocage_max && $pmb_blocage_max != 0) {
                         $ndays = $pmb_blocage_max;
                     }
                 } else {
                     $ndays = 0;
                 }
                 if ($ndays) {
                     // Interdire alors de nouveau pret
                     if ($pret_ok < 2) {
                         $pret_ok = $pmb_blocage_retard_force;
                     }
                     $this->blocage_retard = $pmb_blocage_retard_force;
                 }
             }
         }
     }
     if (!$pret_ok && $this->allow_loan) {
         $this->fiche = str_replace("!!empr_case_pret!!", $empr_pret_allowed, $this->fiche);
         $this->fiche = str_replace('!!id!!', $this->id, $this->fiche);
     } else {
         if ($pret_ok == 1 && $this->allow_loan) {
             $message_pret .= "<input type='button' class='bouton' value=\"" . $msg["finance_pret_force_pret"] . "\" onClick=\"this.form.force_finance.value=1; this.form.submit();\">";
         } elseif ($this->allow_loan) {
             $message_pret .= "<div class='erreur'>" . $msg["finance_pret_bloque"] . "</div>";
         } else {
             $message_pret .= "<div class='erreur'>" . $msg["empr_no_allow_loan"] . "</div>";
         }
         $this->fiche = str_replace("!!empr_case_pret!!", $message_pret, $this->fiche);
     }
     $abonnement = "";
     if ($pmb_gestion_financiere && $pmb_gestion_abonnement == 2) {
         if ($this->type_abt) {
             $requete = "select type_abt_libelle from type_abts where id_type_abt='" . $this->type_abt . "'";
             $resultat_type_abt = mysql_query($requete);
             if (@mysql_num_rows($resultat_type_abt)) {
                 $abonnement = mysql_result($resultat_type_abt, 0, 0);
             }
         }
     }
     if ($abonnement) {
         $this->fiche = str_replace("!!abonnement!!", "<div class='row'><strong>" . $msg["finance_type_abt"] . " : </strong>" . htmlentities($abonnement, ENT_QUOTES, $charset) . "</div>\n", $this->fiche);
     } else {
         $this->fiche = str_replace("!!abonnement!!", "", $this->fiche);
     }
     // message
     if ($this->empr_msg) {
         $message_fiche_empr = "\n\t\t\t\t\t<hr />\n\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t<div class='colonne10'><img src='./images/info.png' /></div>\n\t\t\t\t\t\t<div class='colonne-suite'><span class='erreur'>{$this->empr_msg}</span></div>\n\t\t\t\t\t\t</div><br />";
         $alert_sound_list[] = "information";
         $this->fiche = str_replace('!!empr_msg!!', $message_fiche_empr, $this->fiche);
     } else {
         $this->fiche = str_replace('!!empr_msg!!', "", $this->fiche);
     }
     // on distingue les messages de prêts du message sur l'emprunteur
     $this->fiche = str_replace('!!pret_msg!!', $this->message, $this->fiche);
     if ($this->adhesion_renouv_proche()) {
         $message_date_depassee = $msg[empr_date_renouv_proche];
     } elseif ($this->adhesion_depassee()) {
         $message_date_depassee = $msg[empr_date_depassee];
     } else {
         $message_date_depassee = "";
     }
     if ($message_date_depassee) {
         $alert_sound_list[] = "critique";
     }
     $this->fiche = str_replace('!!empr_date_depassee!!', $message_date_depassee, $this->fiche);
     if ($this->age_categ_change()) {
         $message_categ_age_change = $msg[empr_categ_age_change];
     } else {
         $message_categ_age_change = "";
     }
     if ($message_categ_age_change) {
         $alert_sound_list[] = "information";
     }
     $this->fiche = str_replace('!!empr_categ_age_change!!', $message_categ_age_change, $this->fiche);
     $group_zone = "<a href='./circ.php'>{$msg['64']}</a>";
     if ($groupID) {
         $group_zone .= "&nbsp;&nbsp;&nbsp;<a href='./circ.php?categ=groups&action=showgroup&groupID={$groupID}'>{$msg['grp_autre_lecteur']}</a>";
     }
     $this->fiche = str_replace('!!group_zone!!', $group_zone, $this->fiche);
     $fsexe[0] = $msg[128];
     $fsexe[1] = $msg[126];
     $fsexe[2] = $msg[127];
     $this->fiche = str_replace('!!sexe!!', $fsexe[$this->sexe], $this->fiche);
     // valeur pour les champ hidden du prêt. L'id empr est pris en charge plus haut (voir Eric)
     $this->fiche = str_replace('!!cb!!', $this->cb, $this->fiche);
     // traitement liste exemplaires en prêt
     $this->fiche = str_replace('!!nb_prets_encours!!', $this->nb_pret, $this->fiche);
     //On affiche le bouton de mail si le destinataire a une adresse mail
     if ($this->mail) {
         $mail_click = "onclick=\"if (confirm('" . $msg["mail_pret_confirm"] . "')) { openPopUp('./pdf.php?pdfdoc=mail_liste_pret&id_empr=" . $this->id . "', 'print_PDF', 600, 500, -2, -2, '{$PDF_win_prop}');} return(false) \"";
         $bouton_mail_liste_pret = "<input type='button' name='maillistedocs' class='bouton' value='{$msg['email']}' {$mail_click} />";
     } else {
         $bouton_mail_liste_pret = "";
     }
     $this->fiche = str_replace("!!mail_liste_pret!!", $bouton_mail_liste_pret, $this->fiche);
     //Si mail de rappel affecté au responsable du groupe
     $requete = "select id_groupe,resp_groupe from groupe,empr_groupe where id_groupe=groupe_id and empr_id=" . $this->id . " and resp_groupe and mail_rappel limit 1";
     $res = mysql_query($requete);
     if (mysql_num_rows($res) > 0) {
         $requete = "select id_empr, empr_mail from empr where id_empr='" . mysql_result($res, 0, 1) . "'";
         $result = mysql_query($requete);
         $has_mail = mysql_result($result, 0, 1) ? 1 : 0;
     } else {
         $has_mail = $this->mail ? 1 : 0;
     }
     //Si retard sur un document, proposer la lettre de retard ou l'email de retard
     if ($this->retard >= 1) {
         $imprime_click = "onclick=\"openPopUp('./pdf.php?pdfdoc=lettre_retard&id_empr=" . $this->id . "', 'lettre', 600, 500, -2, -2, 'toolbar=no, dependent=yes, resizable=yes'); return(false) \"";
         $bouton_lettre_retard = $msg['retard'] . "&nbsp;<input type=\"button\" class=\"bouton\" value=\"" . $msg["lettre_retard"] . "\" " . $imprime_click . ">";
         if ($has_mail && $biblio_email) {
             $mail_click = "onclick=\"if (confirm('" . $msg["mail_retard_confirm"] . "')) { openPopUp('./mail.php?type_mail=mail_retard&id_empr=" . $this->id . "', 'mail', 600, 500, -2,- 2, 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes');} return(false) \"";
             $bouton_mail_retard = "<input type=\"button\" class=\"bouton\" value=\"" . $msg["mail_retard"] . "\" " . $mail_click . ">";
         } else {
             $bouton_mail_retard = "";
         }
     } else {
         $bouton_lettre_retard = "";
         $bouton_mail_retard = "";
     }
     $this->fiche = str_replace("!!lettre_retard!!", $bouton_lettre_retard, $this->fiche);
     $this->fiche = str_replace("!!mail_retard!!", $bouton_mail_retard, $this->fiche);
     $voir_tout_pret = "";
     //separation prets classiques et prets courts
     $prets_list = array('0' => '', '1' => '');
     if (!count($this->prets)) {
         // dans ce cas, le lecteur n'a rien en prêt
         $prets_list[0] = "<tr><td colspan='9'>{$msg['650']}</td></tr>";
         $prets_list[1] = '';
     } else {
         // constitution du code HTML
         $vdr = 0;
         $id_bloc = $id_inpret = '';
         $odd_even = 0;
         // Gestion de limitation de la visualisation de la liste de pret.
         global $pmb_pret_aff_limitation;
         global $pmb_pret_aff_nombre;
         global $see_all_pret;
         global $current_module;
         while (list($cle, $valeur) = each($this->prets)) {
             $id_inpret .= $valeur['id'] . '|';
             if ($valeur['pret_retard'] == 1) {
                 $tit_color = "color='RED'";
             } else {
                 $tit_color = "";
             }
             //Affichage des prolongations
             global $pmb_pret_restriction_prolongation, $pmb_pret_nombre_prolongation, $pmb_utiliser_calendrier;
             $pret_nombre_prolongation = 0;
             $forcage_prolongation = TRUE;
             $duree_prolongation = 0;
             // Limitation simple du pret
             if ($pmb_pret_restriction_prolongation == 1) {
                 $pret_nombre_prolongation = $pmb_pret_nombre_prolongation;
             } elseif ($pmb_pret_restriction_prolongation == 2) {
                 // Limitation du pret par les quotas
                 //Initialisation des quotas pour nombre de prolongations
                 $qt = new quota("PROLONG_NMBR_QUOTA");
                 //Tableau de passage des paramètres
                 $struct["READER"] = $this->id;
                 $struct["EXPL"] = $valeur['id'];
                 $pret_nombre_prolongation = $qt->get_quota_value($struct);
                 $forcage_prolongation = $qt->get_force_value($struct);
                 //Initialisation des quotas de durée de prolongation
                 $qt = new quota("PROLONG_TIME_QUOTA");
                 $struct["READER"] = $this->id;
                 $struct["EXPL"] = $valeur['id'];
                 $duree_prolongation = $qt->get_quota_value($struct);
             }
             //$forcage_prolongation=FALSE;
             /* on prépare la date de début*/
             $pret_date = $valeur['sql_date_retour'];
             $rqt_date = "select date_add('" . $pret_date . "', INTERVAL '{$duree_prolongation}' DAY) as date_prolongation ";
             $resultatdate = mysql_query($rqt_date);
             $res = mysql_fetch_object($resultatdate);
             $date_prolongation = str_replace('-', "", $res->date_prolongation);
             if ($pmb_utiliser_calendrier) {
                 $req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='" . $valeur["idlocation"] . "' and DATEDIFF(date_ouverture,'{$date_prolongation}')>=0 order by date_ouverture asc limit 1";
                 $res_date_calendrier = mysql_query($req_date_calendrier);
                 if (mysql_num_rows($res_date_calendrier) > 0) {
                     $date_prolongation = str_replace('-', "", mysql_result($res_date_calendrier, 0, 0));
                 }
             }
             if ($odd_even == 0) {
                 $pair_impair = "odd";
                 $odd_even = 1;
             } else {
                 if ($odd_even == 1) {
                     $pair_impair = "even";
                     $odd_even = 0;
                 }
             }
             $expl_sur_loc = "";
             if ($pmb_sur_location_activate) {
                 $expl_sur_loc = "<td><center>" . $valeur["sur_location"] . "</center></td>";
             }
             $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\"";
             $prets_list[$valeur['short_loan_flag']] .= "\n\t\t\t\t\t<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t\t<form class='form-{$current_module}' name=prolong" . $valeur['id'] . " action='circ.php'>\n\t\t\t\t\t\t<td class='empr-expl'><a href='./circ.php?categ=visu_ex&form_cb_expl=" . rawurlencode($valeur['cb']) . "'>\n\t\t\t\t\t\t\t{$valeur['cb']}</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td size='70%'>\n\t\t\t\t\t\t\t<font {$tit_color}>" . strip_tags($valeur['libelle']) . "</font>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['typdoc']}</center>\n\t\t\t\t\t\t</td>{$expl_sur_loc}\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['location']}<br />{$valeur['section']}</center>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['date_pret']}</center>\n\t\t\t\t\t\t</td>\t\t\t\t\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['retour_initial']}</center>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>";
             if ($pmb_pret_restriction_prolongation == 0) {
                 $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['cpt_prolongation']}</center>";
             } else {
                 $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['cpt_prolongation']}/{$pret_nombre_prolongation}</center>";
             }
             $prets_list[$valeur['short_loan_flag']] .= "</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type='hidden' name='categ' value='pret'>\n\t\t\t\t\t\t\t<input type='hidden' name='sub' value='pret_prolongation'>\n\t\t\t\t\t\t\t<input type='hidden' name='form_cb' value='{$this->cb}'>\n\t\t\t\t\t\t\t<input type='hidden' name='cb_doc' value='{$valeur['cb']}'>\n\t\t\t\t\t\t\t<input type='hidden' name='id_doc' value='{$valeur['id']}'>\n\t\t\t\t\t\t\t<input type='hidden' name='date_retour' value=\"\">";
             $vdr = max($vdr, $date_prolongation);
             // 				$vdr=max($vdr,$valeur['org_ret_date']);
             if ($forcage_prolongation == FALSE && $valeur['cpt_prolongation'] >= $pret_nombre_prolongation) {
                 $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['date_retour']}</center>" . "</td>" . "</form><td>&nbsp;</td></tr>";
             } else {
                 $date_clic = " onClick=\"openPopUp('./select.php?what=calendrier";
                 $date_clic .= "&caller=prolong" . $valeur['id'];
                 $date_clic .= "&date_caller={$date_prolongation}";
                 $date_clic .= "&param1=date_retour&param2=date_retour_lib&auto_submit=YES',";
                 $date_clic .= " 'date_retour', 250, 300, -2, -2,";
                 $date_clic .= " 'toolbar=no, dependent=yes, resizable=yes')\"";
                 $prets_list[$valeur['short_loan_flag']] .= "\n\t\t\t\t\t\t<center><input type='button' name='date_retour_lib' class='bouton' value='{$valeur['date_retour']}' " . $date_clic . " sorttable_customkey='{$valeur['date_retour']}' /></center>\n\t\t\t\t\t\t</td><td><center>";
                 $prets_list[$valeur['short_loan_flag']] .= "<input type='checkbox' id='prol_" . $valeur['id'] . "' name='cbox_prol'  onClick='check_cb(this.form)'/>";
                 $prets_list[$valeur['short_loan_flag']] .= "</center></td>\n\t\t\t\t\t\t</form></tr>";
             }
             // Gestion de limitation de la visualisation de la liste de pret.
             if ($pmb_pret_aff_limitation == 1 && $pmb_pret_aff_nombre && !$see_all_pret && $cle + 1 >= $pmb_pret_aff_nombre) {
                 break;
             }
         }
         // Gestion de limitation de la visualisation de la liste de pret.
         if ($pmb_pret_aff_limitation == 1 && $pmb_pret_aff_nombre && !$see_all_pret && $this->nb_pret > $pmb_pret_aff_nombre) {
             // le bouton 'Voir tous les prets' n'a pas été posté et on arrive à la limite imposée
             //Affichage du bouton 'Voir tous les prets'
             $tout_voir_click = "onclick=\"document.location='circ.php?categ=pret&see_all_pret=1&form_cb=" . $this->cb . "'\"";
             $voir_tout_pret = "<input type='button' name='see_all_pret' class='bouton' value='" . $msg['pret_liste_voir_tout'] . "'  {$tout_voir_click}/>";
         }
     }
     /* 1ere option */
     //$prets_list = $prets_list[0].(($pmb_short_loan_management==1 && count($prets_list[1]))?("<tr ><th colspan='9'>".$msg['short_loans']."</th></tr>".$prets_list[1]):'');
     /* 2eme option*/
     $id_inpret = substr($id_inpret, 0, -1);
     $date_format_SQL = substr($vdr, 0, 4) . '-' . substr($vdr, 4, 2) . '-' . substr($vdr, 6, 2);
     $svdr = formatdate($date_format_SQL);
     $date_prol = " onClick=\"openPopUp('./select.php?what=calendrier";
     $date_prol .= "&caller=prolong_bloc";
     $date_prol .= "&date_caller={$vdr}";
     $date_prol .= "&param1=date_retbloc&param2=date_retbloc_lib&auto_submit=YES',";
     $date_prol .= " 'date_retbloc',";
     $date_prol .= " 250,260,-2,-2,'toolbar=no, dependent=yes, resizable=yes')\"";
     $butt_prol = "\n\t\t\t<input type='button' name='date_retbloc_lib' class='bouton' value='{$svdr}' " . $date_prol . " />\n\t\t\t<input type='hidden' name='categ' value='pret'>\n\t\t\t<input type='hidden' name='sub' value='pret_prolongation_bloc'>\n\t\t\t<input type='hidden' name='form_cb' value='{$this->cb}'>\n\t\t\t<input type='hidden' name='date_retbloc' value=\"\">\n\t\t\t<input type='hidden' name='id_bloc' value=\"\">";
     $this->fiche = str_replace('!!id_inpret!!', $id_inpret, $this->fiche);
     if ($vdr) {
         $this->fiche = str_replace('!!prol_date!!', $butt_prol, $this->fiche);
         $this->fiche = str_replace('!!bouton_cocher_prolong!!', "<input type='button' name='bloc_all' value='+' class='bouton' title='{$msg['resa_tout_cocher']}'  onClick='check_allcb(this.form)'/>", $this->fiche);
     } else {
         $this->fiche = str_replace('!!prol_date!!', "", $this->fiche);
         $this->fiche = str_replace('!!bouton_cocher_prolong!!', "&nbsp;", $this->fiche);
     }
     $this->fiche = str_replace('!!voir_tout_pret!!', $voir_tout_pret, $this->fiche);
     /* 1ere option */
     //$this->fiche = str_replace('!!pret_list!!', $prets_list, $this->fiche);
     /* 2eme option */
     $this->fiche = str_replace('!!pret_list!!', $prets_list[0], $this->fiche);
     if ($pmb_short_loan_management == 1) {
         if (count($prets_list[1])) {
             $this->fiche = str_replace('!!short_loan_list!!', $prets_list[1], $this->fiche);
         } else {
             $this->fiche = str_replace('!!short_loan_list!!', '', $this->fiche);
         }
     }
     //tableau des relances
     $this->fiche = str_replace('!!relance!!', $this->relance, $this->fiche);
     if ($pmb_gestion_amende && $pmb_gestion_financiere) {
         $bt_histo_relance = "&nbsp;<input type='button' class='bouton' id='see_late' name='see_late' value=\"" . $msg['empr_see_late'] . "\" onclick=\"document.location='./circ.php?categ=pret&sub=show_late&id={$this->id}' \" />";
     } else {
         $bt_histo_relance = "";
     }
     $this->fiche = str_replace('!!bt_histo_relance!!', $bt_histo_relance, $this->fiche);
     // mise à jour de la liste des réservations
     $this->fiche = str_replace('!!resa_list!!', $this->fetch_resa(), $this->fiche);
     if ($pmb_resa_planning) {
         // mise à jour de la liste des réservations plannifiées
         $this->fiche = str_replace('!!resa_planning_list!!', $this->fetch_resa_planning(), $this->fiche);
     } else {
         $this->fiche = str_replace('!!resa_planning_list!!', '', $this->fiche);
     }
     if ($this->allow_sugg && SESSrights & ACQUISITION_AUTH) {
         $req = "select count(id_suggestion) as nb from suggestions, suggestions_origine where num_suggestion=id_suggestion and origine='" . $this->id . "' and type_origine='1'  ";
         $res = mysql_query($req, $dbh);
         $btn_sug = "";
         $sug = mysql_fetch_object($res);
         if ($sug->nb) {
             $btn_sug = "<input type='button' class='bouton' id='see_sug' name='see_sug' value='" . $msg['acquisition_lecteur_see_sugg'] . "' onclick=\"document.location='./acquisition.php?categ=sug&action=list&user_id={$this->id}&user_statut=1' \" />";
         }
         $this->fiche = str_replace('!!voir_sugg!!', $btn_sug, $this->fiche);
     } else {
         $this->fiche = str_replace('!!voir_sugg!!', "", $this->fiche);
     }
     // mise à jour de la liste des abonnement de circulation de pério
     $this->fiche = str_replace('!!serialcirc_empr!!', $this->fetch_serial_circ(), $this->fiche);
 }