Ejemplo n.º 1
0
function check_quota_resa($id_empr, $id_notice, $id_bulletin)
{
    global $dbh;
    global $msg;
    global $pmb_quotas_avances;
    global $_quotas_elements_;
    global $pmb_resa_quota_pret_depasse;
    //Initialisation résultat
    $error = array();
    $error["ERROR"] = false;
    //Si les quotas avancés sont autorisés
    if ($pmb_quotas_avances) {
        $struct = array();
        //Quota de notice ou bulletin ?
        if ($id_notice) {
            $quota_type = "BOOK_NMBR_QUOTA";
            $struct["NOTI"] = $id_notice;
            $elt_name = "NOTICETYPE";
        } else {
            $quota_type = "BOOK_NMBR_SERIAL_QUOTA";
            $struct["BULL"] = $id_bulletin;
            $elt_name = "BULLETINTYPE";
        }
        //Initialisation du quota
        $qt = new quota($quota_type);
        $struct["READER"] = $id_empr;
        //Si résa bloquée en cas de dépassement de quota de prêt
        if (!$pmb_resa_quota_pret_depasse) {
            //Le quota de prêt est-il atteint pour cette notice ou bulletin
            //Récupération de l'élément indirect à tester
            $elt = $qt->get_element_by_name($elt_name);
            //Récupération de l'exemplaire le plus défavorable associé à la réservation
            $object_id = $qt->get_object_for_indirect_element($_quotas_elements_[$elt], $struct);
            //Initialisation du quota de prêt
            $qt_pret = new quota("LEND_NMBR_QUOTA");
            $struct_pret["READER"] = $id_empr;
            $struct_pret["EXPL"] = $object_id;
            $r = $qt_pret->check_quota($struct_pret);
        } else {
            $r = false;
        }
        //Si quota de prêt non violé alors on regarde les quotas de réservation
        if (!$r) {
            //Vérification
            $r = $qt->check_quota($struct);
            //Si quota violé
            if ($r) {
                $error["ERROR"] = true;
                //Erreur
                $error["MESSAGE"] = $qt->error_message;
                //Peut-on forcer ou pas la résa
                $error["FORCE"] = $qt->force;
                return $error;
            }
        } else {
            $error["ERROR"] = true;
            //Erreur
            $error["MESSAGE"] = $qt_pret->error_message . "<br />" . $msg["resa_quota_pret_error"];
            //Peut-on forcer ou pas la résa
            $r_force = $qt->check_quota($struct);
            if ($r_force) {
                $error["FORCE"] = $qt->force;
            } else {
                $error["FORCE"] = 0;
            }
            return $error;
        }
        return $error;
    } else {
        return $error;
    }
}