示例#1
0
function do_retour($stuff, $confirmed = 1)
{
    global $dbh;
    global $msg;
    global $alert_sound_list, $pmb_play_pret_sound;
    global $pmb_gestion_amende, $pmb_gestion_financiere, $pmb_blocage_retard, $pmb_blocage_max, $pmb_blocage_delai, $pmb_blocage_coef;
    global $deflt_docs_location;
    $erreur_affichage = '';
    if (!is_object($stuff)) {
        die("erreur dans le module ./circ/retour.inc [do_retour()]. Contactez l'admin");
    }
    // récupération localisation exemplaire
    $query = "SELECT t.tdoc_libelle as type_doc";
    $query .= ", l.location_libelle as location";
    $query .= ", s.section_libelle as section";
    $query .= " FROM docs_type t";
    $query .= ", docs_location l";
    $query .= ", docs_section s";
    $query .= " WHERE t.idtyp_doc=" . $stuff->expl_typdoc;
    $query .= " AND l.idlocation=" . $stuff->expl_location;
    $query .= " AND s.idsection=" . $stuff->expl_section;
    $query .= " LIMIT 1";
    $result = mysql_query($query, $dbh);
    $info_doc = mysql_fetch_object($result);
    print pmb_bidi("<br /><form><div class='row'><div class='left'><strong>" . $stuff->libelle . "</strong></div>");
    // flag confirm retour
    if (!$confirmed and $stuff->pret_idempr) {
        print "\n\t\t\t<div class='right'>\n\t\t\t<input type='button' class='bouton' \n\t\t\t\t\tname='confirm_ret' value='" . $msg['retour_confirm'] . "'\n\t\t\t\t\tonClick=\"document.location='./circ.php?categ=retour&cb_expl=" . $stuff->expl_cb . "'\">\n\t\t\t</div>";
    } elseif ($stuff->pret_idempr) {
        print "\n\t\t\t\t<div class='right'>\n\t\t\t\t\t<font color='RED'><b>{$msg['retour_ok']}</b></font>\n\t\t\t\t</div>";
    }
    print "</div>";
    print pmb_bidi("<br /><b>" . $stuff->expl_cb . "</b> " . $info_doc->type_doc);
    print pmb_bidi('.&nbsp;' . $info_doc->location);
    print pmb_bidi('.&nbsp;' . $info_doc->section);
    print pmb_bidi('.&nbsp;' . $stuff->expl_cote);
    print "&nbsp;&nbsp;<input class='bouton' type='button' value=\"" . $msg[375] . "\" onClick=\"document.location='circ.php?categ=visu_ex&form_cb_expl=" . $stuff->expl_cb . "';\" />";
    print "</form>";
    //Champs personalisés
    $p_perso = new parametres_perso("expl");
    $perso_aff = "";
    if (!$p_perso->no_special_fields) {
        $perso_ = $p_perso->show_fields($stuff->expl_id);
        for ($i = 0; $i < count($perso_["FIELDS"]); $i++) {
            $p = $perso_["FIELDS"][$i];
            if ($p["AFF"]) {
                $perso_aff .= "<br />" . $p["TITRE"] . " " . $p["AFF"];
            }
        }
    }
    if ($perso_aff) {
        print "<div class='row'>" . $perso_aff . "</div>";
    }
    $script_magnetique = "\n<script language='javascript' type='text/javascript'>\nvar requete = null;\n\nfunction creerRequette(){\n\tif(window.XMLHttpRequest) // Firefox\n\t\trequete = new XMLHttpRequest();\n\telse if(window.ActiveXObject) // Internet Explorer\n  \t\trequete = new ActiveXObject('Microsoft.XMLHTTP');\n\telse { // XMLHttpRequest non supporté par le navigateur\n   \t\talert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');\n    \treturn;\n\t}\n}\n\nfunction magnetise(commande){\n\tcreerRequette();\n\tif(netscape.security.PrivilegeManager)netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');\t\n\trequete.open('GET', 'http://localhost:30000/?send_value='+commande+'&command=Send', false);\n\trequete.send(null);\n\tif(requete.readyState != 4) alert('Requête antivol non effectuée !');\n}\n\n";
    global $pmb_antivol;
    if ($pmb_antivol > 0) {
        if ($stuff->type_antivol == 1) {
            // c'est un support non magnétique (livre, revue...)
            print "{$script_magnetique}" . "magnetise('RRR');</script>";
        }
        if ($stuff->type_antivol == 2) {
            //c'est un support magnétique (cassette)
            print "{$script_magnetique}" . "magnetise('SSS');</script>";
        }
    }
    //si le retour se passe sur un site différent de ce lui de l'exemplaire
    global $pmb_transferts_actif;
    $transfert_mauvais_site = false;
    if ($stuff->expl_location != $deflt_docs_location) {
        $alert_sound_list[] = "critique";
        $html_erreur_site = "<hr /><div class='erreur'>";
        //on agit pour faire l'action par defaut
        //et que c'est un retour d'emprunt
        if ($pmb_transferts_actif && $stuff->pret_idempr) {
            global $transferts_retour_action_defaut;
            global $transferts_retour_action_autorise_autre;
            $trans = new transfert();
            //pour afficher le site de l'exemplaire
            $rqtSite = "SELECT location_libelle FROM docs_location WHERE idlocation=" . $stuff->expl_location;
            $resSite = mysql_result(mysql_query($rqtSite), 0);
            //si on propose une autre action
            if ($transferts_retour_action_autorise_autre == "1") {
                $texte_change_loc = str_replace("!!lbl_site!!", $resSite, $msg["transferts_circ_retour_lbl_change_localisation"]);
            }
            $texte_change_loc = str_replace("!!liste_sections!!", "<select onchange='enregLoc(this)'>!!liste!!</select>", $texte_change_loc);
            //on genere la liste des sections
            $rqt = "SELECT idsection, section_libelle FROM docs_section ORDER BY section_libelle";
            $res_section = mysql_query($rqt);
            $liste_section = "";
            while ($value = mysql_fetch_object($res_section)) {
                $liste_section .= "<option value='" . $value->idsection . "'";
                if ($value->idsection == $stuff->expl_section) {
                    $liste_section .= " selected";
                    $expl_section_libelle = $value->section_libelle;
                }
                $liste_section .= ">" . $value->section_libelle . "</option>";
            }
            $texte_change_loc = addslashes(str_replace("!!liste!!", $liste_section, $texte_change_loc));
            $html_erreur_site .= "\n<form name='actionTrans'>\n<input type='hidden' name='typeTrans' value='" . $transferts_retour_action_defaut . "'>\n<input type='hidden' name='explTrans' value='" . $stuff->expl_id . "'>\n<script language='javascript'>\nmsg_inf_loc = '" . $texte_change_loc . "';\nmsg_bt_loc = '" . str_replace("'", "\\'", $msg["transferts_circ_retour_bt_retour_mauvaise_localisation"]) . "';\nmsg_inf_trans = '" . str_replace("'", "\\'", str_replace("!!lbl_site!!", $resSite, $msg["transferts_circ_retour_lbl_transfert"])) . "';\nmsg_bt_trans = '" . str_replace("'", "\\'", $msg["transferts_circ_retour_bt_changement_localisation"]) . "';\n\nfunction changeAction() {\n\n\tvar actionTrans = new http_request();\n\tvar url= './ajax.php?module=circ&categ=transferts&idexpl=' + document.actionTrans.explTrans.value + '&action=';\n\t\t\t\t\n\tswitch (document.actionTrans.typeTrans.value) {\n\t\tcase '0':\n\t\t\t//il y a eu un changement localisation\n\t\t\t//on propose un transfert\n\t\t\tif (confirm('" . addslashes($msg["transferts_circ_retour_confirm_gen_transfert"]) . "')) {\n\n\t\t\t\turl = url + 'gen_transfert&param=' + document.actionTrans.paramTrans.value ;\n\t\t\t\n\t\t\t\tif (actionTrans.request(url)) {\n\t\t\t\t\t// Il y a une erreur. Afficher le message retourné\n\t\t\t\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t//tout c'est bien passe\n\t\t\t\t\t\n\t\t\t\t\t//on recupere les infos\n\t\t\t\t\tdocument.actionTrans.typeTrans.value = '1';\n\t\t\t\t\tdocument.actionTrans.paramTrans.value = actionTrans.get_text();\n\t\t\t\t\t\n\t\t\t\t\t//on change les textes\n\t\t\t\t\tdocument.actionTrans.btActionTrans.value = msg_bt_trans;\n\t\t\t\t\tdocument.getElementById('libInfoTransfert').innerHTML = msg_inf_trans; \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}//if confirm\n\t\t\t\n\t\t\t\n\t\t\tbreak;\n\t\n\t\tcase '1':\n\t\t\t//il y a eu un transfert\n\t\t\t//on propose un changement de localisation\n\t\t\tif (confirm('" . addslashes($msg["transferts_circ_retour_confirm_change_loc"]) . "')) {\n\n\t\t\t\turl = url + 'change_loc&param=' + document.actionTrans.paramTrans.value ;\n\t\t\t\n\t\t\t\tif (actionTrans.request(url)) {\n\t\t\t\t\t// Il y a une erreur. Afficher le message retourné\n\t\t\t\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t//tout c'est bien passe\n\t\t\t\t\t\n\t\t\t\t\t//on recupere les infos\n\t\t\t\t\tdocument.actionTrans.typeTrans.value = '0';\n\t\t\t\t\tdocument.actionTrans.paramTrans.value = actionTrans.get_text();\n\t\t\t\t\t\n\t\t\t\t\t//on change les textes\n\t\t\t\t\tdocument.actionTrans.btActionTrans.value = msg_bt_loc;\n\t\t\t\t\tdocument.getElementById('libInfoTransfert').innerHTML = msg_inf_loc; \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t} //if confirm\n\t\t\tbreak;\n\t} //switch\n\t\t\n}\n\nfunction enregLoc(obj) {\n\tval = obj.options[obj.selectedIndex].value;\n\t\n\tvar actionTrans = new http_request();\n\tvar url= './ajax.php?module=circ&categ=transferts&idexpl=' + document.actionTrans.explTrans.value + '&action=change_section&param='+val;\n\t\n\tif (actionTrans.request(url)) {\n\t\t// Il y a une erreur. Afficher le message retourné\n\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t}\n}\n</script>";
            if ($stuff->resa_idempr) {
                // le doc en retour peut servir à valider une résa suivante
                if (!verif_cb_utilise($stuff->expl_cb)) {
                    $affect = affecte_cb($stuff->expl_cb);
                }
            }
            if (!$affect) {
                switch ($transferts_retour_action_defaut) {
                    case "0":
                        //change la localisation d'origine
                        $param = $trans->retour_exemplaire_change_localisation($stuff->expl_id);
                        //le message a l'ecran
                        $html_erreur_site .= "<div id='libInfoTransfert'>" . str_replace("!!lbl_site!!", $resSite, $msg["transferts_circ_retour_lbl_change_localisation"]) . "</div>";
                        if ($transferts_retour_action_autorise_autre == "1") {
                            //on propose de générer le transfert
                            $html_erreur_site .= "&nbsp;<input class='bouton' name='btActionTrans' type='button' value=\"" . $msg["transferts_circ_retour_bt_retour_mauvaise_localisation"] . "\" " . " onclick=\"changeAction();\"" . ">";
                        }
                        break;
                    case "1":
                        //genere le transfert automatique de l'exemplaire
                        $param = $trans->retour_exemplaire_genere_transfert_retour($stuff->expl_id);
                        //le message a l'ecran
                        $html_erreur_site .= "<div id='libInfoTransfert'>" . $msg["transferts_circ_retour_lbl_transfert"] . "</div>";
                        if ($transferts_retour_action_autorise_autre == "1") {
                            //on propose de changer la localisation
                            $html_erreur_site .= "&nbsp;<input class='bouton' name='btActionTrans' type='button' value=\"" . $msg["transferts_circ_retour_bt_changement_localisation"] . "\" " . " onclick=\"changeAction();\"" . ">";
                        }
                        break;
                }
                //switch
            }
            if ($transferts_retour_action_autorise_autre == "1") {
                $html_erreur_site .= "<input type='hidden' name='paramTrans' value='" . $param . "'></form>";
            }
            $html_erreur_site = str_replace("!!lbl_site!!", $resSite, $html_erreur_site);
            $html_erreur_site = str_replace("!!liste_sections!!", $expl_section_libelle, $html_erreur_site);
            $transfert_mauvais_site = true;
        } else {
            //if (($pmb_transferts_actif)&&($stuff->pret_idempr))
            //le message à l'écran
            $html_erreur_site .= $msg[expl_retour_bad_location];
        }
        $html_erreur_site .= "</div>";
        print pmb_bidi($html_erreur_site);
        // fin de if ($stuff->expl_location != $deflt_docs_location)
    }
    if ($stuff->expl_note) {
        $alert_sound_list[] = "critique";
        print pmb_bidi("<hr /><div class='erreur'>{$msg[377]} :</div><div class='message_important'>" . $stuff->expl_note . "</div>");
    } elseif ($pmb_play_pret_sound) {
        $alert_sound_list[] = "information";
    }
    // zone du dernier emrunteur
    if ($stuff->expl_lastempr) {
        $dernier_empr = "<hr /><div class='row'>{$msg['expl_prev_empr']} ";
        $link = "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($stuff->lastempr_cb) . "'>";
        $dernier_empr .= $link . $stuff->lastempr_prenom . ' ' . $stuff->lastempr_nom . ' (' . $stuff->lastempr_cb . ')</a>';
        $dernier_empr .= "</div><hr />";
    }
    if ($stuff->pret_idempr) {
        // l'exemplaire était effectivement emprunté
        // calcul du retard éventuel
        $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('{$stuff->pret_retour}'))) as retard ";
        $resultatdate = mysql_query($rqt_date);
        $resdate = mysql_fetch_object($resultatdate);
        $retard = $resdate->retard;
        if ($retard > 0) {
            //Calcul du vrai nombre de jours
            $date_debut = explode("-", $stuff->pret_retour);
            $ndays = calendar::get_open_days($date_debut[2], $date_debut[1], $date_debut[0], date("d"), date("m"), date("Y"));
            if ($ndays > 0) {
                $retard = (int) $ndays;
                print "<br /><div class='erreur'>" . $msg[369] . "&nbsp;: " . $retard . " " . $msg[370] . "</div>";
                $alert_sound_list[] = "critique";
            }
        }
        //Calcul du blocage
        if ($pmb_blocage_retard) {
            $date_debut = explode("-", $stuff->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 > 0) {
                //Le lecteur est-il déjà bloqué ?
                $date_fin_blocage_empr = mysql_result(mysql_query("select date_fin_blocage from empr where id_empr='" . $stuff->pret_idempr . "'"), 0, 0);
                //Calcul de la date de fin
                $date_fin = calendar::add_days(date("d"), date("m"), date("Y"), $ndays);
                if ($date_fin > $date_fin_blocage_empr) {
                    //Mise à jour
                    mysql_query("update empr set date_fin_blocage='" . $date_fin . "' where id_empr='" . $stuff->pret_idempr . "'");
                    print "<br /><div class='erreur'>" . sprintf($msg["blocage_retard_pret"], formatdate($date_fin)) . "</div>";
                    $alertsound_list[] = "critique";
                } else {
                    print "<br /><div class='erreur'>" . sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr)) . "</div>";
                    $alertsound_list[] = "critique";
                }
            }
        }
        //Vérification des amendes
        if ($pmb_gestion_financiere && $pmb_gestion_amende) {
            $amende = new amende($stuff->pret_idempr);
            $amende_t = $amende->get_amende($stuff->pret_idexpl);
            //Si il y a une amende, je la débite
            if ($amende_t["valeur"]) {
                print pmb_bidi("<br /><div class='erreur'>" . $msg["finance_retour_amende"] . "&nbsp;: " . comptes::format($amende_t["valeur"]));
                $alert_sound_list[] = "critique";
                $compte_id = comptes::get_compte_id_from_empr($stuff->pret_idempr, 2);
                if ($compte_id) {
                    $cpte = new comptes($compte_id);
                    if ($cpte->id_compte) {
                        $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $stuff->pret_idexpl), 0);
                        print " " . $msg["finance_retour_amende_recorded"];
                    }
                }
                print "</div>";
            }
        }
        // zone du dernier emrunteur
        print pmb_bidi($dernier_empr);
        // code de suppression prêt et la mise en table de stat
        if ($confirmed) {
            if (del_pret($stuff)) {
                if (!maj_stat_pret($stuff)) {
                    // impossible de maj en table stat
                    print "<div class='erreur'>{$msg[371]}</div>";
                }
            } else {
                // impossible de supprimer en table pret
                print "<div class='erreur'>{$msg[372]}</div>";
            }
            // traitement de l'éventuelle réservation
            if ($stuff->resa_idempr) {
                // le doc en retour peut servir à valider une résa suivante
                if (!verif_cb_utilise($stuff->expl_cb) || $affect) {
                    if (!$affect) {
                        $affect = affecte_cb($stuff->expl_cb);
                    }
                    // affichage message de réservation
                    if ($affect) {
                        $trans_en_cours = false;
                        $msg_trans = "";
                        if ($pmb_transferts_actif == "1" && !$transfert_mauvais_site) {
                            //si le transfert est actif et qu'un transfert n'est pas deja fait
                            $res_transfert = resa_transfert($affect, $stuff->expl_cb);
                            if ($res_transfert != 0) {
                                $rqt = "SELECT location_libelle FROM docs_location WHERE idlocation=" . $res_transfert;
                                $lib_loc = mysql_result(mysql_query($rqt), 0);
                                $msg_trans = "<strong>" . str_replace("!!site_dest!!", $lib_loc, $msg["transferts_circ_resa_validation_alerte"]) . "</strong><br />";
                                $trans_en_cours = true;
                            }
                        }
                        $query = "select distinct ";
                        $query .= "empr_prenom, empr_nom, empr_cb ";
                        $query .= "from (((resa LEFT JOIN notices AS notices_m ON resa_idnotice = notices_m.notice_id ) LEFT JOIN bulletins ON resa_idbulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), empr ";
                        $query .= "where id_resa in (" . $affect . ") and resa_idempr=id_empr";
                        $result = mysql_query($query, $dbh);
                        $empr = @mysql_fetch_object($result);
                        print pmb_bidi("<div class='message_important'>{$msg['352']}</div>\n\t\t\t\t\t\t\t<div class='row'>{$msg_trans}\n\t\t\t\t\t\t\t{$msg[373]}\n\t\t\t\t\t\t\t<strong><a href='./circ.php?categ=pret&form_cb=" . rawurlencode($empr->empr_cb) . "'>" . $empr->empr_prenom . "&nbsp;" . $empr->empr_nom . "</a></strong>\n\t\t\t\t\t\t\t&nbsp;({$empr->empr_cb} )\n\t\t\t\t\t\t\t</div>");
                        $alert_sound_list[] = "critique";
                        if (!$trans_en_cours) {
                            alert_empr_resa($affect);
                        }
                    }
                    // fin if affect
                }
                // fin if !verif_cb_utilise
            }
            // fin if resa
        }
        // fin confirmed
        $empr = new emprunteur($stuff->pret_idempr, $erreur_affichage, FALSE, 2);
        print pmb_bidi($empr->fiche_affichage);
    } else {
        print "<div class='erreur'>{$msg[605]}</div>";
        $alert_sound_list[] = "critique";
    }
    // show_report($stuff); // this stands for debugging
}
 function do_retour_doc()
 {
     global $dbh;
     global $msg;
     global $pmb_gestion_amende, $pmb_gestion_financiere, $pmb_blocage_retard, $pmb_blocage_max, $pmb_blocage_delai, $pmb_blocage_coef;
     // récupération localisation exemplaire
     $query = "select t.tdoc_libelle as type_doc";
     $query .= ", l.location_libelle as location";
     $query .= ", s.section_libelle as section";
     $query .= " from docs_type t";
     $query .= ", docs_location l";
     $query .= ", docs_section s";
     $query .= " where t.idtyp_doc=" . $this->expl_typdoc;
     $query .= " and l.idlocation=" . $this->expl_location;
     $query .= " and s.idsection=" . $this->expl_section;
     $query .= " limit 1";
     $result = pmb_mysql_query($query, $dbh);
     $info_doc = pmb_mysql_fetch_object($result);
     $this->type_doc = $info_doc->type_doc;
     if ($this->nbparts > 1) {
         $this->type_doc .= " (" . $this->nbparts . ")";
     }
     $this->location = $info_doc->location;
     $this->section = $info_doc->section;
     if ($this->expl_note) {
         $this->error_message = $msg[377];
     }
     if ($this->pret_idempr) {
         // calcul du retard éventuel
         $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('{$this->pret_retour}'))) as retard ";
         $resultatdate = pmb_mysql_query($rqt_date);
         $resdate = pmb_mysql_fetch_object($resultatdate);
         $retard = $resdate->retard;
         if ($retard > 0) {
             //Calcul du vrai nombre de jours
             $date_debut = explode("-", $this->pret_retour);
             $ndays = calendar::get_open_days($date_debut[2], $date_debut[1], $date_debut[0], date("d"), date("m"), date("Y"));
             if ($ndays > 0) {
                 $retard = (int) $ndays;
                 $this->error_message = $msg[369] . " : " . $retard . " " . $msg[370];
             } else {
                 $this->error_message = $msg["calendrier_active_aucun_retard"];
             }
         }
         //Calcul du blocage
         if ($pmb_blocage_retard) {
             $date_debut = explode("-", $this->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 > 0) {
                 //Le lecteur est-il déjà bloqué ?
                 $date_fin_blocage_empr = pmb_mysql_result(pmb_mysql_query("select date_fin_blocage from empr where id_empr='" . $this->pret_idempr . "'"), 0, 0);
                 //Calcul de la date de fin
                 $date_fin = calendar::add_days(date("d"), date("m"), date("Y"), $ndays);
                 if ($date_fin > $date_fin_blocage_empr) {
                     //Mise à jour
                     pmb_mysql_query("update empr set date_fin_blocage='" . $date_fin . "' where id_empr='" . $this->pret_idempr . "'");
                     $this->error_message = sprintf($msg["blocage_retard_pret"], formatdate($date_fin));
                 } else {
                     $this->error_message = sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr));
                 }
             }
         }
         //Vérification des amendes
         if ($pmb_gestion_financiere && $pmb_gestion_amende) {
             $amende = new amende($this->pret_idempr);
             $amende_t = $amende->get_amende($this->pret_idexpl);
             //Si il y a une amende, je la débite
             if ($amende_t["valeur"]) {
                 $this->error_message = $msg["finance_retour_amende"] . "&nbsp;: " . comptes::format($amende_t["valeur"]);
                 $compte_id = comptes::get_compte_id_from_empr($this->pret_idempr, 2);
                 if ($compte_id) {
                     $cpte = new comptes($compte_id);
                     if ($cpte->id_compte) {
                         $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $this->pret_idexpl), 0);
                         $this->error_message .= " " . $msg["finance_retour_amende_recorded"];
                     }
                 }
             }
         }
         // Suppression prêt et la mise en table de stat
         $query = "delete from pret where pret_idexpl = '" . $this->pret_idexpl . "' ";
         $result = pmb_mysql_query($query, $dbh);
         if ($result) {
             $this->retour_message = $msg["retour_ok"];
             if (!$this->maj_stat_pret()) {
                 // impossible de maj en table stat
                 $this->error_message = $msg[371];
             }
         } else {
             // impossible de supprimer en table pret
             $this->error_message = $msg[372];
         }
         // traitement de l'éventuelle réservation
         if ($this->resa_idempr) {
             // le doc en retour peut servir à valider une résa suivante
             if (!verif_cb_utilise($this->cb_expl)) {
                 $affect = affecte_cb($this->cb_expl);
                 // affichage message de réservation
                 if ($affect) {
                     $this->error_message = $msg["rfid_retour_document_reserve_message"];
                     $this->url_reservation = "./circ.php?categ=pret&form_cb=" . rawurlencode($this->cb_reservataire);
                 }
                 // fin if affect
             }
             // fin if !verif_cb_utilise
         }
         // fin if resa
     } else {
         $this->error_message = $msg[605];
     }
 }
示例#3
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);
 }
 function del_pret()
 {
     global $dbh;
     global $msg, $pmb_blocage_retard, $pmb_blocage_delai, $pmb_blocage_coef, $pmb_blocage_max, $pmb_gestion_financiere, $pmb_gestion_amende;
     global $selfservice_retour_retard_msg, $selfservice_retour_blocage_msg, $selfservice_retour_amende_msg;
     global $alertsound_list;
     if (!$this->expl->pret_idempr) {
         return '';
     }
     // calcul du retard éventuel
     $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('" . $this->expl->pret_retour . "'))) as retard ";
     $resultatdate = pmb_mysql_query($rqt_date);
     $resdate = pmb_mysql_fetch_object($resultatdate);
     $retard = $resdate->retard;
     if ($retard > 0) {
         //Calcul du vrai nombre de jours
         $date_debut = explode("-", $this->expl->pret_retour);
         $ndays = calendar::get_open_days($date_debut[2], $date_debut[1], $date_debut[0], date("d"), date("m"), date("Y"));
         if ($ndays > 0) {
             $retard = (int) $ndays;
             $message .= "<br /><div class='erreur'>" . $msg[369] . "&nbsp;: " . $retard . " " . $msg[370] . "</div>";
             $alertsound_list[] = "critique";
             $this->message_retard = $selfservice_retour_retard_msg . " " . $msg[369] . " : " . $retard . " " . $msg[370];
         }
     }
     //Calcul du blocage
     if ($pmb_blocage_retard) {
         $date_debut = explode("-", $this->expl->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 > 0) {
             //Le lecteur est-il déjà bloqué ?
             $date_fin_blocage_empr = pmb_mysql_result(pmb_mysql_query("select date_fin_blocage from empr where id_empr='" . $this->expl->pret_idempr . "'"), 0, 0);
             //Calcul de la date de fin
             $date_fin = calendar::add_days(date("d"), date("m"), date("Y"), $ndays);
             if ($date_fin > $date_fin_blocage_empr) {
                 //Mise à jour
                 pmb_mysql_query("update empr set date_fin_blocage='" . $date_fin . "' where id_empr='" . $this->expl->pret_idempr . "'");
                 $message .= "<br /><div class='erreur'>" . sprintf($msg["blocage_retard_pret"], formatdate($date_fin)) . "</div>";
                 $alertsound_list[] = "critique";
                 $this->message_blocage = sprintf($selfservice_retour_blocage_msg, formatdate($date_fin));
             } else {
                 $message .= "<br /><div class='erreur'>" . sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr)) . "</div>";
                 $alertsound_list[] = "critique";
                 $this->message_blocage = sprintf($selfservice_retour_blocage_msg, formatdate($date_fin_blocage_empr));
             }
         }
     }
     //Vérification des amendes
     if ($pmb_gestion_financiere && $pmb_gestion_amende) {
         $amende = new amende($this->expl->pret_idempr);
         $amende_t = $amende->get_amende($this->expl_id);
         //Si il y a une amende, je la débite
         if ($amende_t["valeur"]) {
             $message .= pmb_bidi("<br /><div class='erreur'>" . $msg["finance_retour_amende"] . "&nbsp;: " . comptes::format($amende_t["valeur"]));
             $this->message_amende = $selfservice_retour_amende_msg . " : " . comptes::format($amende_t["valeur"]);
             $alertsound_list[] = "critique";
             $compte_id = comptes::get_compte_id_from_empr($this->expl->pret_idempr, 2);
             if ($compte_id) {
                 $cpte = new comptes($compte_id);
                 if ($cpte->id_compte) {
                     $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $this->expl_id), 0);
                     $message .= " " . $msg["finance_retour_amende_recorded"];
                 }
             }
             $message .= "</div>";
             $req = "delete from cache_amendes where id_empr=" . $this->expl->pret_idempr;
             pmb_mysql_query($req);
         }
     }
     $query = "delete from pret where pret_idexpl=" . $this->expl_id;
     if (!pmb_mysql_query($query, $dbh)) {
         return '';
     }
     $query = "update empr set last_loan_date=sysdate() where id_empr='" . $this->expl->pret_idempr . "' ";
     @pmb_mysql_query($query, $dbh);
     $query = "update exemplaires set expl_lastempr='" . $this->expl->pret_idempr . "', last_loan_date=sysdate() where expl_id='" . $this->expl->expl_id . "' ";
     if (!pmb_mysql_query($query, $dbh)) {
         return '';
     }
     $this->maj_stat_pret();
     $this->empr = new emprunteur($this->expl->pret_idempr, $erreur_affichage, FALSE, 2);
     $this->expl->pret_idempr = 0;
     $this->flag_rendu = 1;
     return $message;
 }
示例#5
0
 function get_amende($id_expl)
 {
     global $pmb_amende_comptabilisation;
     $requete = "select pret_date, pret_retour, niveau_relance, date_relance from pret where pret_idexpl={$id_expl}";
     $resultat = pmb_mysql_query($requete);
     $amende = array();
     $amende["valeur"] = 0;
     $amende["recouvrement"] = false;
     if (@pmb_mysql_num_rows($resultat)) {
         $r = pmb_mysql_fetch_object($resultat);
         $dr = explode("-", $r->pret_retour);
         //$calendar=new calendar();
         $njours = calendar::get_open_days($dr[2], $dr[1], $dr[0], date("d"), date("m"), date("Y"));
         $amende_param = $this->get_parameters($id_expl);
         if ($njours > 0) {
             $amende["njours"] = $njours;
             if ($njours > $amende_param["delai_avant_amende"]) {
                 //En recouvrement ?
                 if ($r->niveau_relance == 3) {
                     $drel = explode("-", $r->date_relance);
                     $njours_recouvrement = calendar::get_open_days($drel[2], $drel[1], $drel[0], date("d"), date("m"), date("Y"));
                     if ($njours_recouvrement > $amende_param["delai_recouvrement"]) {
                         $amende["recouvrement"] = true;
                         $njours = calendar::get_open_days($dr[2], $dr[1], $dr[0], $drel[2], $drel[1], $drel[0]);
                     }
                 }
                 //Calcul de l'amende à partir du délai de grâce ?
                 if ($pmb_amende_comptabilisation) {
                     $amende["njours"] = $njours - $amende_param["delai_avant_amende"];
                 }
                 //Montant maximum dépassé ?
                 $amende["valeur"] = $amende["njours"] * $amende_param["amende_jour"];
                 if ($amende["valeur"] > $amende_param["amende_maximum"] && $amende_param["amende_maximum"] > 0) {
                     $amende["valeur"] = $amende_param["amende_maximum"];
                 }
             }
         }
         //Calcul du niveau théorique de l'exemplaire
         //calcul de Date retour+delai_avant_amende
         $date_1 = calendar::add_days($dr[2], $dr[1], $dr[0], $amende_param["delai_avant_amende"]);
         //calcul de Date retour+delai_avant_amende+delai_1_2
         $dr1 = explode("-", $date_1);
         $date_2 = calendar::add_days($dr1[2], $dr1[1], $dr1[0], $amende_param["delai_1_2"]);
         //calcul de Date retour+delai_avant_amende+delai_1_2+delai_2_3
         $dr2 = explode("-", $date_2);
         $date_3 = calendar::add_days($dr2[2], $dr2[1], $dr2[0], $amende_param["delai_2_3"]);
         //calcul de Date retour+delai_avant_amende+delai_1_2+delai_2_3+delai_recouvrement
         $dr3 = explode("-", $date_3);
         $date_recouvrement = calendar::add_days($dr3[2], $dr3[1], $dr3[0], $amende_param["delai_recouvrement"]);
         $time = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
         $niveau = 0;
         if ($time > calendar::maketime($date_1) && $time <= calendar::maketime($date_2)) {
             $niveau = 1;
         } else {
             if ($time > calendar::maketime($date_2) && $time <= calendar::maketime($date_3)) {
                 $niveau = 2;
             } else {
                 if ($time > calendar::maketime($date_3) && $time <= calendar::maketime($date_recouvrement)) {
                     $niveau = 3;
                 } else {
                     if ($time > calendar::maketime($date_recouvrement)) {
                         $niveau = 4;
                     }
                 }
             }
         }
         $amende["niveau"] = $niveau;
         $amende["date_pret"] = $r->pret_date;
         $amende["date_retour"] = $r->pret_retour;
         $amende["niveau_relance"] = $r->niveau_relance;
         $amende["date_relance"] = $r->date_relance;
     }
     return $amende;
 }