Exemplo n.º 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
}
Exemplo n.º 2
0
         $sql = "UPDATE exemplaires set expl_retloc='" . $obj->expl_location . "' where expl_cb='" . $obj->expl_cb . "' limit 1";
         pmb_mysql_query($sql);
     }
     $req = " update transferts,transferts_demande\r\n\t\t\t\tset etat_transfert=1,\n\t\t\t\tmotif=CONCAT(motif,'. Cloture, car reservation supprimee (gestion {$PMBuserid})') \r\n\t\t\t\twhere\r\n\t\t\t\tnum_transfert=id_transfert and etat_demande=0 and \r\n\t\t\t\tresa_trans='" . $suppr_id_resa[$i] . "'\r\n\t\t\t\t";
     pmb_mysql_query($req, $dbh);
 }
 // archivage resa
 $rqt_arch = "UPDATE resa_archive, resa SET resarc_anulee = 1 WHERE  id_resa = '" . $suppr_id_resa[$i] . "' AND resa_arc = resarc_id ";
 pmb_mysql_query($rqt_arch, $dbh);
 // suppression
 $rqt = "delete from resa where id_resa='" . $suppr_id_resa[$i] . "' ";
 $res = pmb_mysql_query($rqt, $dbh);
 // réaffectation du doc éventuellement
 if ($cb_recup) {
     if (!verif_cb_utilise($cb_recup)) {
         if (!($id_resa_validee = affecte_cb($cb_recup))) {
             if ($pmb_transferts_actif) {
                 $rqt = "SELECT id_transfert, sens_transfert, num_location_source, num_location_dest\n\t\t\t\t\t\t\t\tFROM transferts, transferts_demande, exemplaires\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tWHERE id_transfert=num_transfert and num_expl=expl_id  and expl_cb='" . $cb_recup . "' AND etat_transfert=0";
                 $res = pmb_mysql_query($rqt);
                 if (pmb_mysql_num_rows($res)) {
                     // Document à traiter au lieu de à ranger, car transfert en cours?
                     $sql = "UPDATE exemplaires set expl_retloc='" . $deflt_docs_location . "' where expl_cb='" . $cb_recup . "' limit 1";
                     pmb_mysql_query($sql);
                     $pas_ranger = 1;
                     $msg_a_pointer .= "<div class='row'>";
                     $msg_a_pointer .= "<div class='erreur'>" . $msg["circ_pret_piege_expl_todo"] . "</div>";
                 }
             }
             if (!$pas_ranger) {
                 //on vérifie que l'exemplaire existe toujours...
                 $rqt = "SELECT expl_id FROM exemplaires WHERE expl_cb='" . $cb_recup . "' ";
Exemplo n.º 3
0
function do_retour_secouru($stuff)
{
    global $dbh;
    global $msg;
    global $alert_sound_list;
    if (!is_object($stuff)) {
        die("erreur grave dans le module ./circ/retour_secouru.inc [do_retour_secouru()]. Contactez l'admin");
    }
    print pmb_bidi('<strong>' . $stuff->libelle . '</strong>');
    // 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 = pmb_mysql_query($query, $dbh);
    $info_doc = pmb_mysql_fetch_object($result);
    print pmb_bidi('<br />' . $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);
    if ($stuff->pret_idempr) {
        // l'exemplaire était effectivement emprunté
        // on affiche les infos de l'emprunteur
        print "<hr /><div class='row'>{$msg[368]} : </div>";
        print "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($stuff->empr_cb) . "'>";
        print pmb_bidi($stuff->empr_prenom . ' ' . $stuff->empr_nom . '</a>');
        if ($stuff->empr_msg) {
            $message_fiche_empr = "\n\t\t\t\t\t<div class='row'>\n\t\t\t\t\t<div class='colonne10'><img src='./images/info.png' /></div>\n\t\t\t\t\t<div class='colonne-suite'><span class='erreur'>{$stuff->empr_msg}</span></div>\n\t\t\t\t\t</div><br />";
            $alert_sound_list[] = "information";
            print $message_fiche_empr;
        }
        // calcul du retard éventuel
        $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('{$stuff->pret_retour}'))) as retard ";
        $resultatdate = pmb_mysql_query($rqt_date);
        $resdate = pmb_mysql_fetch_object($resultatdate);
        $retard = $resdate->retard;
        if ($retard > 0) {
            print "<hr /><div class='erreur'>{$msg[369]}&nbsp;: {$retard} {$msg[370]}</div>";
        }
        // zone du dernier emrunteur
        if ($stuff->expl_lastempr) {
            print "<hr /><div class='row'>{$msg['expl_prev_empr']} ";
            $link = "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($stuff->lastempr_cb) . "'>";
            print pmb_bidi($link . $stuff->lastempr_prenom . ' ' . $stuff->lastempr_nom . ' (' . $stuff->lastempr_cb . ')</a>');
            print "</div><hr />";
        }
        // code de suppression prêt et la mise en table de stat
        if (del_pret($stuff)) {
            if (!stat_stuff($stuff)) {
                // impossible d'insérer en table stat
                print "<div class='erreur'>{$msg[371]}</div>";
            }
        } else {
            // impossible de supprimer en table pret
            print "<div class='erreur'>{$msg[372]}</div>";
        }
    } else {
        print "<div class='erreur'>{$msg[605]}</div>";
    }
    if ($stuff->expl_note) {
        print pmb_bidi("<hr /><div class='erreur'>{$msg[377]} :</div><div class='message_important'>" . $stuff->expl_note . "</div>");
    }
    if ($stuff->expl_comment) {
        print pmb_bidi("<hr /><div class='erreur'>" . $msg[expl_zone_comment] . " :</div>" . $stuff->expl_comment . "<br />");
    }
    // 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 = affecte_cb($stuff->expl_cb);
            // affichage message de réservation
            if ($affect) {
                print pmb_bidi("<div class='erreur'>{$msg['352']}</div>\n\t\t\t\t\t<div class='row'>\n\t\t\t\t\t{$msg[373]}\n\t\t\t\t\t<strong><a href='./circ.php?categ=pret&form_cb=" . rawurlencode($stuff->cb_reservataire) . "'>" . $stuff->prenom_reservataire . "&nbsp;" . $stuff->nom_reservataire . "</a></strong>\n\t\t\t\t\t&nbsp;( {$stuff->cb_reservataire} )\n\t\t\t\t\t</div>");
                $alert_sound_list[] = "information";
                if ($affect) {
                    alert_empr_resa($affect);
                }
                // print "<script type='text/javascript'>window.open('./pdf.php?pdfdoc=lettre_resa&id_resa=$affect', 'lettre_confirm_resa', 'toolbar=no, dependent=yes, width=600, height=500, resizable=yes, scrollbars=yes');</script>";
            }
        }
    }
}
Exemplo n.º 4
0
 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];
     }
 }
Exemplo n.º 5
0
function del_resa($id_empr, $id_notice, $id_bulletin, $cb_encours_de_pret)
{
    global $dbh;
    if (!$id_empr || !$id_notice && !$id_bulletin) {
        return FALSE;
    }
    if (!$id_notice) {
        $id_notice = 0;
    }
    if (!$id_bulletin) {
        $id_bulletin = 0;
    }
    $rqt = "select resa_cb, id_resa, resa_planning_id_resa from resa where resa_idnotice='" . $id_notice . "' and resa_idbulletin='" . $id_bulletin . "'  and resa_idempr='" . $id_empr . "' ";
    $res = pmb_mysql_query($rqt, $dbh);
    $obj = pmb_mysql_fetch_object($res);
    $cb_recup = $obj->resa_cb;
    $id_resa = $obj->id_resa;
    // suppression resa
    $rqt = "delete from resa where id_resa='" . $id_resa . "' ";
    $res = pmb_mysql_query($rqt, $dbh);
    // suppression de la prévision associée à la resa
    resa_planning::delete($obj->resa_planning_id_resa);
    // si on delete une resa à partir d'un prêt, on invalide la résa qui était validée avec le cb, mais on ne change pas les dates, ça sera fait par affect_cb
    $rqt_invalide_resa = "update resa set resa_cb='' where resa_cb='" . $cb_encours_de_pret . "' ";
    $res = pmb_mysql_query($rqt_invalide_resa, $dbh);
    // réaffectation du doc éventuellement
    if ($cb_recup != $cb_encours_de_pret) {
        // les cb sont différents
        if (!verif_cb_utilise($cb_recup)) {
            // le cb qui était affecté à la résa qu'on vient de supprimer n'est pas utilisé
            // on va affecter le cb_récupéré à une resa non validée
            $res_affectation = affecte_cb($cb_recup);
            if (!$res_affectation && $cb_recup) {
                // cb non réaffecté, il faut transférer les infos de la résa dans la table des docs à ranger
                $rqt = "insert into resa_ranger (resa_cb) values ('" . $cb_recup . "') ";
                $res = pmb_mysql_query($rqt, $dbh);
            }
        }
    }
    // Au cas où il reste des résa invalidées par resa_cb, on leur colle les dates comme il faut...
    $rqt_invalide_resa = "update resa set resa_date_debut='0000-00-00', resa_date_fin='0000-00-00' where resa_cb='' ";
    $res = pmb_mysql_query($rqt_invalide_resa, $dbh);
    return TRUE;
}
Exemplo n.º 6
0
 function enregistre_reception($listeTransferts, $idStatut, $listeSections, &$info = array())
 {
     global $deflt_docs_location;
     $tabTrans = explode(",", $listeTransferts);
     $tabSections = explode(",", $listeSections);
     $idSection = current($tabSections);
     $nb = 0;
     foreach ($tabTrans as $transId) {
         //on recupere l'id de l'exemplaire
         $noEx = $this->_transid_2_explid($transId, 2);
         $info[$nb] = array();
         //le sens du transfert
         $rqt = "SELECT sens_transfert, type_transfert, origine, origine_comp, motif\n\t\t\t\t\tFROM transferts INNER JOIN transferts_demande ON id_transfert=num_transfert \n\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
         $res = mysql_query($rqt);
         $value = mysql_fetch_array($res);
         $sensTrans = $value[0];
         $typeTrans = $value[1];
         $origine = $value[2];
         $origineComp = $value[3];
         $info[$nb]["motif"] = $value[4];
         if ($sensTrans == 1) {
             //c'est un retour !
             //on cloture le transfert
             $rqt = "UPDATE transferts SET etat_transfert=1 WHERE id_transfert=" . $transId;
             mysql_query($rqt);
             if ($typeTrans == 1) {
                 //si c'est un aller/retour
                 //on restaure la localisation sauvegardé de l'exemplaire
                 $this->_restaure_localisation($transId);
             }
             if ($idSection) {
                 $rqt = "UPDATE exemplaires INNER JOIN transferts_demande ON num_expl=expl_id INNER JOIN transferts ON id_transfert=num_transfert \n\t\t\t\t\t\t\t\tSET expl_section=" . $idSection . " \n\t\t\t\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
                 mysql_query($rqt);
             } else {
                 //on restaure le section sauvegardé de l'exemplaire
                 $this->_restaure_section($transId);
             }
             if ($idStatut) {
                 //on met à jour le statut et la localisation de l'exemplaire
                 $rqt = "UPDATE exemplaires INNER JOIN transferts_demande ON num_expl=expl_id INNER JOIN transferts ON id_transfert=num_transfert \n\t\t\t\t\t\t\tSET expl_statut=" . $idStatut . ", expl_location = num_location_dest \n\t\t\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
                 mysql_query($rqt);
             } else {
                 //on restaure le statut sauvegardé de l'exemplaire
                 $this->_restaure_statut($transId);
             }
         } else {
             //c'est un transfert
             // aller simple ?
             if ($typeTrans == 0) {
                 //on cloture le transfert => pas de gestion du retour
                 $rqt = "UPDATE transferts SET etat_transfert=1 WHERE id_transfert=" . $transId;
                 mysql_query($rqt);
             } else {
                 //c'est l'aller donc
                 if ($origine == 4) {
                     //c'est un transfert suite a une resa donc
                     //on recupere le cb pour
                     $explcb = $this->_transid_2_explcb($transId, 2);
                 }
                 $id_section = $idSection;
                 if ($idSection == 0) {
                     //chercher la meme section dans le nouveau site
                     $rqt = "SELECT idsection \n\t\t\t\t\t\t\t\tFROM exemplaires INNER JOIN docs_section ON expl_section=idsection INNER JOIN docsloc_section ON idsection=num_section \n\t\t\t\t\t\t\t\tWHERE expl_id=" . $noEx . " AND num_location=" . $deflt_docs_location;
                     $res = mysql_query($rqt);
                     if (mysql_num_rows($res) == 0) {
                         //la section n'existe pas pour cette localisation !
                         //on cherche la premiere section dispo
                         $rqt = "SELECT idsection \n\t\t\t\t\t\t\t\t\tFROM docs_section INNER JOIN docsloc_section ON idsection=num_section \n\t\t\t\t\t\t\t\t\tWHERE num_location=" . $deflt_docs_location . " LIMIT 1";
                         $res = mysql_query($rqt);
                         $id_section = mysql_result($res, 0);
                     } else {
                         $id_section = mysql_result($res, 0);
                     }
                 }
                 $rqt = "UPDATE exemplaires INNER JOIN transferts_demande ON num_expl=expl_id INNER JOIN transferts ON id_transfert=num_transfert \n\t\t\t\t\t\t\tSET expl_section=" . $id_section . " \n\t\t\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
                 mysql_query($rqt);
             }
             //fin du else de if ($typeTrans == 0)
             //on met à jour le statut et la localisation de l'exemplaire
             if ($idStatut) {
                 $rqt = "UPDATE exemplaires INNER JOIN transferts_demande ON num_expl=expl_id INNER JOIN transferts ON id_transfert=num_transfert \n\t\t\t\t\t\t\tSET expl_statut=" . $idStatut . ", expl_location = num_location_dest \n\t\t\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
                 mysql_query($rqt);
             } else {
                 //on restaure le statut sauvegardé de l'exemplaire
                 $this->_restaure_statut($transId);
             }
             // Traitement de la résa
             if ($origine == 4 && $typeTrans) {
                 //c'est un transfert suite a une resa donc
                 //valider la resa
                 $id_resa_validee = affecte_cb($explcb, $origineComp);
                 //on genere la lettre de confirmation
                 alert_empr_resa($id_resa_validee);
             }
         }
         //fin du else de if ($sensTrans == 0)
         //on met a jour l'etat de la demande => on passe en receptionné et terminer
         $rqt = "UPDATE transferts INNER JOIN transferts_demande ON id_transfert=num_transfert \n\t\t\t\t\tSET etat_demande=3, date_reception=NOW() \n\t\t\t\t\tWHERE id_transfert=" . $transId . " AND etat_demande = 2";
         mysql_query($rqt);
         //on passe à la section suivante
         $idSection = next($tabSections);
         $nb++;
     }
     //fin du while
 }
Exemplo n.º 7
0
 function delete_resa($session_id, $resa_id)
 {
     global $dbh;
     if (!$session_id) {
         return FALSE;
     }
     $session_info = $this->retrieve_session_information($session_id);
     $empr_id = $session_info["empr_id"];
     if (!$empr_id) {
         return FALSE;
     }
     $resa_id += 0;
     if (!$resa_id) {
         return FALSE;
     }
     // *** Traitement de la suppression d'une résa affectée
     $recup_id_resa = "select id_resa, resa_cb FROM resa WHERE resa_idempr=" . $empr_id;
     $recup_id_resa .= " AND id_resa = {$resa_id}";
     $resrecup_id_resa = mysql_query($recup_id_resa, $dbh);
     $obj_recupidresa = mysql_fetch_object($resrecup_id_resa);
     $suppr_id_resa = $obj_recupidresa->id_resa;
     // récup éventuelle du cb
     $cb_recup = $obj_recupidresa->resa_cb;
     // archivage resa
     $rqt_arch = "UPDATE resa_archive, resa SET resarc_anulee = 1 WHERE id_resa = '" . $suppr_id_resa . "' AND resa_arc = resarc_id ";
     mysql_query($rqt_arch, $dbh);
     // suppression
     $rqt = "delete from resa where id_resa='" . $suppr_id_resa . "' ";
     $res = mysql_query($rqt, $dbh);
     $nb_resa_suppr = mysql_affected_rows();
     // réaffectation du doc éventuellement
     if ($cb_recup) {
         if (!affecte_cb($cb_recup) && $cb_recup) {
             // cb non réaffecté, il faut transférer les infos de la résa dans la table des docs à ranger
             $rqt = "insert into resa_ranger (resa_cb) values ('" . $cb_recup . "') ";
             $res = mysql_query($rqt, $dbh);
         }
     }
     return TRUE;
 }
Exemplo n.º 8
0
     */
     // si demande de transfert, transferts validé (donc pas parti), on cloture
     $req = " select expl_location, expl_cb from transferts,transferts_demande, exemplaires\r\n\t\t\twhere\r\n\t\t\tnum_transfert=id_transfert and etat_demande=0 and num_expl=expl_id and\r\n\t\t\tresa_trans='" . $suppr_id_resa . "' ";
     $res = pmb_mysql_query($req);
     if (pmb_mysql_num_rows($res)) {
         $obj = pmb_mysql_fetch_object($res);
         // dans à traité pour effectuer le transfert
         $sql = "UPDATE exemplaires set expl_retloc='" . $obj->expl_location . "' where expl_cb='" . $obj->expl_cb . "' limit 1";
         pmb_mysql_query($sql);
     }
     $req = " update transferts,transferts_demande\r\n\t\t\tset etat_transfert=1,\r\n\t\t\tmotif=CONCAT(motif,'. Cloture, car reservation supprimee (opac)')\r\n\t\t\twhere\r\n\t\t\tnum_transfert=id_transfert and\r\n\t\t\tresa_trans='" . $suppr_id_resa . "' and etat_demande=0\r\n\t\t\t";
     pmb_mysql_query($req, $dbh);
 }
 // réaffectation du doc éventuellement
 if ($cb_recup) {
     if (!affecte_cb($cb_recup)) {
         if ($pmb_transferts_actif) {
             $rqt = "SELECT expl_location\n\t\t\t\t\t\tFROM transferts, transferts_demande, exemplaires\n\t\t\t\t\t\tWHERE id_transfert=num_transfert and num_expl=expl_id  and expl_cb='" . $cb_recup . "' AND etat_transfert=0";
             $res = pmb_mysql_query($rqt);
             if (pmb_mysql_num_rows($res)) {
                 $obj_expl = pmb_mysql_fetch_object($res);
                 // Document à traiter au lieu de à ranger, car transfert en cours?
                 $sql = "UPDATE exemplaires set expl_retloc='" . $obj_expl->expl_location . "' where expl_cb='" . $cb_recup . "' limit 1";
                 pmb_mysql_query($sql);
                 $pas_ranger = 1;
             }
         }
         if (!$pas_ranger) {
             // cb non réaffecté, il faut transférer les infos de la résa dans la table des docs à ranger
             $rqt = "insert into resa_ranger (resa_cb) values ('" . $cb_recup . "') ";
             $res = pmb_mysql_query($rqt, $dbh);