Ejemplo n.º 1
0
function resa_list($idnotice = 0, $idbulletin = 0, $idempr = 0, $order = "", $where = "", $info_gestion = NO_INFO_GESTION, $url_gestion = "", $ancre = "")
{
    global $dbh, $msg, $charset;
    global $montrerquoi;
    global $current_module;
    global $pdflettreresa_priorite_email_manuel;
    global $deflt2docs_location, $pmb_lecteurs_localises, $empr_location_id;
    global $pmb_transferts_actif, $f_loc, $transferts_choix_lieu_opac;
    global $resa_liste_jscript_GESTION_INFO_GESTION, $ajout_resa_jscript_choix_loc_retrait, $deflt_resas_location;
    global $tdoc, $transferts_site_fixe, $pmb_location_reservation;
    $aff_final = '';
    if (!$montrerquoi) {
        $montrerquoi = 'all';
    }
    if (!$order) {
        $order = "notices_m.index_sew, resa_idnotice, resa_idbulletin, resa_date";
    }
    if ($pmb_lecteurs_localises && !$idempr) {
        if ($f_loc == "") {
            $f_loc = $deflt_resas_location;
        }
        if ($f_loc) {
            $sql_expl_loc = " and expl_location='" . $f_loc . "' ";
        }
    }
    if ($pmb_transferts_actif == "1" && $f_loc && !$idempr) {
        switch ($transferts_choix_lieu_opac) {
            case "1":
                //retrait de la resa sur lieu choisi par le lecteur
                $sql_suite .= " AND resa_loc_retrait='" . $f_loc . "' ";
                break;
            case "2":
                //retrait de la resa sur lieu fixé
                if ($f_loc != $transferts_site_fixe) {
                    $sql_suite .= " AND 0";
                }
                break;
            case "3":
                //retrait de la resa sur lieu exemplaire
                // On affiche les résa que peut satisfaire la loc
                // respecter les droits de réservation du lecteur
                if ($pmb_location_reservation) {
                    $sql_loc_resa .= " and empr_location=resa_emprloc and resa_loc='" . $f_loc . "' ";
                    $sql_loc_resa_from = ", resa_loc ";
                }
                if ($f_loc && !$idempr) {
                    $sql_expl_loc = " and expl_location='" . $f_loc . "' ";
                }
                break;
            default:
                //retrait de la resa sur lieu lecteur
                $sql_suite .= " AND empr_location='" . $f_loc . "' ";
                if ($f_loc && !$idempr) {
                    $sql_expl_loc = " and expl_location='" . $f_loc . "' ";
                }
                break;
        }
    } elseif ($pmb_location_reservation && $f_loc && !$idempr) {
        $sql_loc_resa .= " and empr_location=resa_emprloc and resa_loc='" . $f_loc . "' ";
        $sql_loc_resa_from = ", resa_loc ";
    }
    $sql = "SELECT resa_idnotice, resa_idbulletin, resa_date, resa_date_debut, resa_date_fin, resa_cb, resa_confirmee, resa_idempr, ifnull(expl_cote,'') as expl_cote, empr_nom, empr_prenom, empr_cb, location_libelle, resa_loc_retrait, resa_planning_id_resa,";
    $sql .= " trim(concat(if(series_m.serie_name <>'', if(notices_m.tnvol <>'', concat(series_m.serie_name,', ',notices_m.tnvol,'. '), concat(series_m.serie_name,'. ')), if(notices_m.tnvol <>'', concat(notices_m.tnvol,'. '),'')), ";
    $sql .= " if(series_s.serie_name <>'', if(notices_s.tnvol <>'', concat(series_s.serie_name,', ',notices_s.tnvol,'. '), series_s.serie_name), if(notices_s.tnvol <>'', concat(notices_s.tnvol,'. '),'')), ";
    $sql .= "\tifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, id_resa, ";
    $sql .= " ifnull(notices_m.typdoc,notices_s.typdoc) as typdoc, ";
    $sql .= " IF(resa_date_fin>=sysdate() or resa_date_fin='0000-00-00',0,1) as perimee,";
    $sql .= " date_format(resa_date_debut, '" . $msg["format_date"] . "') as aff_resa_date_debut,";
    $sql .= " if(resa_date_fin='0000-00-00', '', date_format(resa_date_fin, '" . $msg["format_date"] . "')) as aff_resa_date_fin,";
    $sql .= " date_format(resa_date, '" . $msg["format_date"] . "') as aff_resa_date ";
    $sql .= " FROM ((((resa LEFT JOIN notices AS notices_m ON resa_idnotice = notices_m.notice_id ";
    $sql .= " LEFT JOIN series AS series_m ON notices_m.tparent_id = series_m.serie_id ) ";
    $sql .= " LEFT JOIN bulletins ON resa_idbulletin = bulletins.bulletin_id) ";
    $sql .= " LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id ";
    $sql .= " LEFT JOIN series AS series_s ON notices_s.tparent_id = series_s.serie_id ) ";
    $sql .= " LEFT JOIN exemplaires ON resa_cb = exemplaires.expl_cb), ";
    $sql .= " empr, docs_location {$sql_loc_resa_from} ";
    $sql .= " WHERE resa_idempr = id_empr AND idlocation = empr_location ";
    $sql .= $sql_suite;
    if ($idempr) {
        $sql .= " AND id_empr='{$idempr}'";
    }
    if ($montrerquoi == 'validees') {
        $sql .= " AND resa_cb<>''";
    }
    if ($montrerquoi == 'invalidees') {
        $sql .= " AND resa_cb=''";
    }
    if ($montrerquoi == 'valid_noconf') {
        $sql .= " AND resa_cb!=''";
        $sql .= " AND resa_confirmee=0";
    }
    if ($where) {
        $sql .= " AND " . $where;
    }
    $sql .= " {$sql_loc_resa} GROUP BY resa_idnotice, resa_idbulletin, resa_idempr ";
    $sql .= " ORDER BY " . $order;
    if ($idnotice || $idbulletin) {
        $sql = "SELECT resa_idnotice, resa_idbulletin, resa_date, resa_date_debut, resa_date_fin, resa_cb, resa_confirmee, resa_idempr, ifnull(expl_cote,'') as expl_cote, empr_nom, empr_prenom, empr_cb, location_libelle, resa_loc_retrait, ";
        $sql .= " trim(concat(if(series_m.serie_name <>'', if(notices_m.tnvol <>'', concat(series_m.serie_name,', ',notices_m.tnvol,'. '), concat(series_m.serie_name,'. ')), if(notices_m.tnvol <>'', concat(notices_m.tnvol,'. '),'')), ";
        $sql .= " if(series_s.serie_name <>'', if(notices_s.tnvol <>'', concat(series_s.serie_name,', ',notices_s.tnvol,'. '), series_s.serie_name), if(notices_s.tnvol <>'', concat(notices_s.tnvol,'. '),'')), ";
        $sql .= "\tifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, id_resa, ";
        $sql .= " ifnull(notices_m.typdoc,notices_s.typdoc) as typdoc, ";
        $sql .= " IF(resa_date_fin>=sysdate() or resa_date_fin='0000-00-00',0,1) as perimee, date_format(resa_date_debut, '" . $msg["format_date"] . "') as aff_resa_date_debut, if(resa_date_fin='0000-00-00', '', date_format(resa_date_fin, '" . $msg["format_date"] . "')) as aff_resa_date_fin, date_format(resa_date, '" . $msg["format_date"] . "') as aff_resa_date ";
        $sql .= " FROM ((((resa LEFT JOIN notices AS notices_m ON resa_idnotice = notices_m.notice_id ";
        $sql .= " LEFT JOIN series AS series_m ON notices_m.tparent_id = series_m.serie_id ) ";
        $sql .= " LEFT JOIN bulletins ON resa_idbulletin = bulletins.bulletin_id) ";
        $sql .= " LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id ";
        $sql .= " LEFT JOIN series AS series_s ON notices_s.tparent_id = series_s.serie_id) ";
        $sql .= " LEFT JOIN exemplaires ON resa_cb = exemplaires.expl_cb), ";
        $sql .= " empr, docs_location  ";
        $sql .= " WHERE resa_idempr = id_empr AND idlocation = empr_location  AND resa_idnotice = '{$idnotice}' AND resa_idbulletin='{$idbulletin}' ";
        $sql .= " ORDER BY  resa_date";
        $f_loc = 0;
    }
    $req = pmb_mysql_query($sql, $dbh) or die("Erreur SQL !<br />" . $sql . "<br />" . pmb_mysql_error());
    switch ($info_gestion) {
        case GESTION_INFO_GESTION:
            $aff_final .= "<script type=\"text/javascript\">\n\t\t\t\t\tfunction confirm_delete() {\n\t\t\t\t\t\tresult = confirm('" . $msg["resa_confirm_suppr"] . "');\n\t\t       \t\t\tif(result)\n\t\t           \t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t</script>\n\t\t\t\t<form class='form-{$current_module}' name='check_resa' action='{$url_gestion}' method='post'><div class='left'>";
            //les boutons radios
            $aff_final .= "<span class='usercheckbox'><input type='radio' name='montrerquoi' value='all' id='all' onclick='this.form.submit();' ";
            if ($montrerquoi == 'all') {
                $aff_final .= "checked";
            }
            $aff_final .= "><label for='all'>" . $msg['resa_show_all'] . "</label></span>&nbsp;<span class='usercheckbox'><input type='radio' name='montrerquoi' value='validees' id='validees' onclick='this.form.submit();' ";
            if ($montrerquoi == 'validees') {
                $aff_final .= "checked";
            }
            $aff_final .= "><label for='validees'>" . $msg['resa_show_validees'] . "</label></span>&nbsp;<span class='usercheckbox'><input type='radio' name='montrerquoi' value='invalidees' id='invalidees' onclick='this.form.submit();' ";
            if ($montrerquoi == 'invalidees') {
                $aff_final .= "checked";
            }
            $aff_final .= "><label for='invalidees'>" . $msg['resa_show_invalidees'] . "</label></span>&nbsp;<span class='usercheckbox'><input type='radio' name='montrerquoi' value='valid_noconf' id='valid_noconf' onclick='this.form.submit();' ";
            if ($montrerquoi == 'valid_noconf') {
                $aff_final .= "checked";
            }
            $aff_final .= "><label for='valid_noconf'>" . $msg['resa_show_non_confirmees'] . "</label></span>";
            if ($pmb_transferts_actif == "1" || $pmb_location_reservation) {
                //la liste de sélection de la localisation
                $aff_final .= "<br />" . $msg["transferts_circ_resa_lib_localisation"];
                $aff_final .= "<select name='f_loc' onchange='document.check_resa.submit();'>";
                $res = pmb_mysql_query("SELECT idlocation, location_libelle FROM docs_location order by location_libelle");
                $aff_final .= "<option value='0'>" . $msg["all_location"] . "</option>";
                //on parcours la liste des options
                while ($value = pmb_mysql_fetch_array($res)) {
                    //debut de l'option
                    $aff_final .= "<option value='" . $value[0] . "'";
                    if ($value[0] == $f_loc) {
                        //c'est l'option par défaut
                        $aff_final .= " selected";
                    }
                    //fin de l'option
                    $aff_final .= ">" . $value[1] . "</option>";
                }
                $aff_final .= "</select>";
            }
            //le lien pour l'edition
            if (SESSrights & EDIT_AUTH) {
                $lien_edit_resa_traiter = "<a href='./edit.php?categ=notices&sub=resa'>" . $msg['1100'] . " : " . $msg['edit_resa_menu'] . "</a> / <a href='./edit.php?categ=notices&sub=resa_a_traiter'>" . $msg['1100'] . " : " . $msg['edit_resa_menu_a_traiter'] . "</a>";
            }
            $aff_final .= "</div><div class='right'>" . $lien_edit_resa_traiter . "</div>";
            $aff_final .= "<div class='row'>&nbsp;</div>";
            jscript_checkbox();
            break;
        case LECTEUR_INFO_GESTION:
            if ($pmb_transferts_actif == "1" && $transferts_choix_lieu_opac == "1") {
                $aff_final .= $ajout_resa_jscript_choix_loc_retrait;
            }
            break;
        default:
        case NO_INFO_GESTION:
            break;
    }
    if (!pmb_mysql_num_rows($req)) {
        switch ($info_gestion) {
            case GESTION_INFO_GESTION:
                $aff_final .= "</form>";
                break;
            case LECTEUR_INFO_GESTION:
                break;
            default:
            case NO_INFO_GESTION:
                break;
        }
        return $aff_final;
    }
    $aff_final .= "\n\t<script type='text/javascript' src='./javascript/sorttable.js'></script>\n\t<table  class='sortable' width='100%'>";
    $aff_final .= "<tr>";
    if (!$idnotice && !$idbulletin) {
        $aff_final .= "<th>{$msg['233']}</th>";
    }
    $aff_final .= "<th>{$msg['296']}</th>";
    if (!$idempr) {
        $aff_final .= "<th>{$msg['empr_nom_prenom']}</th>";
        if ($pmb_lecteurs_localises) {
            $aff_final .= "<th>{$msg['empr_location']}</th>";
        }
    }
    $aff_final .= "<th>{$msg['366']}</th>" . "<th>{$msg['374']}</th>" . "<th>{$msg['resa_condition']}</th>" . "<th>{$msg['resa_date_fin']}</th>";
    switch ($info_gestion) {
        case GESTION_INFO_GESTION:
            $aff_final .= "<th>" . $msg["resa_validee"] . "</th>";
            $aff_final .= "<th>" . $msg["resa_confirmee"] . "</th>";
            if ($pmb_transferts_actif == "1") {
                $aff_final .= "<th>" . $msg["resa_loc_retrait"] . "</th>";
            }
            $aff_final .= "<th>" . $msg["resa_selectionner"] . "</th>";
            if ($pmb_transferts_actif == "1") {
                $aff_final .= "<th>&nbsp;</th>";
            }
            break;
        case LECTEUR_INFO_GESTION:
            $aff_final .= "<th>" . $msg["resa_confirmee"] . "</th>";
            if ($pmb_transferts_actif == "1") {
                $aff_final .= "<th>" . $msg["resa_loc_retrait"] . "</th>";
            }
            $aff_final .= "<th class='sorttable_nosort'>" . $msg["resa_suppr_th"] . "</th>";
            break;
        default:
        case NO_INFO_GESTION:
            break;
    }
    $aff_final .= "</tr>";
    $odd_even = 0;
    //on parcours la liste des réservations
    while ($data = pmb_mysql_fetch_array($req)) {
        $resa_idnotice = $data['resa_idnotice'];
        $resa_idbulletin = $data['resa_idbulletin'];
        $resa_idempr = $data['resa_idempr'];
        $precedenteresa_idbulletin = 0;
        $precedenteresa_idnotice = 0;
        $no_aff = 0;
        if (!($idnotice || $idbulletin)) {
            if ($f_loc && !$idempr && $data['resa_cb'] && $data['resa_confirmee']) {
                // Dans la liste des résa à traiter, on n'affiche pas la résa qui a été affecté par un autre site
                $query = "SELECT expl_location FROM exemplaires WHERE expl_cb='" . $data['resa_cb'] . "' ";
                $res = @pmb_mysql_query($query, $dbh);
                if ($data_expl = pmb_mysql_fetch_array($res)) {
                    if ($data_expl['expl_location'] != $f_loc) {
                        $no_aff = 1;
                        continue;
                    }
                }
            }
        }
        if ($idempr) {
            $f_loc = 0;
        }
        $rank = recupere_rang($resa_idempr, $resa_idnotice, $resa_idbulletin, $f_loc);
        $resa = new reservation($resa_idempr, $resa_idnotice, $resa_idbulletin);
        $resa->get_resa_cb();
        if ($resa_idnotice != $precedenteresa_idnotice || $resa_idbulletin != $precedenteresa_idbulletin) {
            $precedenteresa_idnotice = $resa_idnotice;
            $precedenteresa_idbulletin = $resa_idbulletin;
            // détermination de la date à afficher dans la case retour pour le rang 1
            // disponible, réservé ou date de retour du premier exemplaire
            // on compte le nombre total d'exemplaires prêtables pour la notice
            $query = "SELECT count(1) FROM exemplaires, docs_statut WHERE expl_statut=idstatut AND statut_allow_resa=1 {$sql_expl_loc} ";
            if ($resa_idnotice) {
                $query .= " AND expl_notice=" . $resa_idnotice;
            } elseif ($resa_idbulletin) {
                $query .= " AND expl_bulletin=" . $resa_idbulletin;
            }
            $tresult = @pmb_mysql_query($query, $dbh);
            $total_ex = pmb_mysql_result($tresult, 0, 0);
            if ($sql_expl_loc && !$total_ex) {
                $no_aff = 1;
            }
            // on compte le nombre d'exemplaires sortis
            $query = "SELECT count(1) as qte FROM exemplaires , pret WHERE pret_idexpl=expl_id {$sql_expl_loc} ";
            if ($resa_idnotice) {
                $query .= " and expl_notice=" . $resa_idnotice;
            } elseif ($resa_idbulletin) {
                $query .= " and expl_bulletin=" . $resa_idbulletin;
            }
            $tresult = @pmb_mysql_query($query, $dbh);
            $total_sortis = pmb_mysql_result($tresult, 0, 0);
            // on en déduit le nombre d'exemplaires disponibles
            $total_dispo = $total_ex - $total_sortis;
            $lien_transfert = false;
            if ($total_dispo > 0) {
                // un exemplaire est disponible pour le réservataire (affichage : disponible)
                $situation = "<strong>" . $msg['expl_resa_available'] . "</strong>";
                if ($data['resa_cb'] && $data['aff_resa_date_fin']) {
                    $situation = "<strong>" . $msg['expl_reserve'] . "</strong>";
                } elseif ($rank > $total_dispo) {
                    $situation = "<strong>" . $msg['expl_resa_already_reserved'] . "</strong>";
                }
                if ($pmb_transferts_actif == "1" && $info_gestion == GESTION_INFO_GESTION) {
                    $dest_loc = resa_loc_retrait($data['id_resa']);
                    if ($dest_loc != 0) {
                        $query = "SELECT count(1) FROM exemplaires, docs_statut WHERE expl_statut=idstatut AND statut_allow_resa=1";
                        $query .= " AND expl_location=" . $dest_loc;
                        if ($resa_idnotice) {
                            $query .= " AND expl_notice=" . $resa_idnotice;
                        } elseif ($resa_idbulletin) {
                            $query .= " AND expl_bulletin=" . $resa_idbulletin;
                        }
                        $tresult = pmb_mysql_query($query, $dbh);
                        $total_ex = pmb_mysql_result($tresult, 0);
                        if ($total_ex == 0) {
                            //on a pas d'exemplaires sur le site de retrait
                            //on regarde si on en ailleurs
                            $query = "SELECT count(1) FROM exemplaires, docs_statut WHERE expl_statut=idstatut AND statut_allow_resa=1";
                            $query .= " AND expl_location<>" . $dest_loc;
                            if ($resa_idnotice) {
                                $query .= " AND expl_notice=" . $resa_idnotice;
                            } elseif ($resa_idbulletin) {
                                $query .= " AND expl_bulletin=" . $resa_idbulletin;
                            }
                            $tresult = pmb_mysql_query($query, $dbh);
                            $total_ex = pmb_mysql_result($tresult, 0);
                            if ($total_ex != 0) {
                                //on en a au moins un ailleurs!
                                //on regarde si un des exemplaires n'est pas en transfert pour cette resa !
                                $query = "SELECT count(1) FROM transferts WHERE etat_transfert=0 AND origine=4 AND origine_comp=" . $data['id_resa'];
                                $tresult = pmb_mysql_query($query, $dbh);
                                $nb_trans = pmb_mysql_result($tresult, 0);
                                if ($nb_trans != 0) {
                                    //on a un transfert en cours
                                    $situation = "<strong>" . $msg["transferts_circ_resa_lib_en_transfert"] . "</strong>";
                                } elseif ($total_ex >= $rank) {
                                    $lien_transfert = true;
                                    if (transfert_resa_dispo($resa_idnotice, $resa_idbulletin, $dest_loc)) {
                                        $situation = $msg["resa_expl_dispo_other_location"];
                                    }
                                }
                            }
                        }
                        //if ($total_ex==0)
                    }
                    //if ($dest_loc!=0)
                }
                //if ( ($pmb_transferts_actif=="1") && ($info_gestion==GESTION_INFO_GESTION) )
            } else {
                if ($total_dispo) {
                    // un ou des exemplaires sont disponibles, mais pas pour ce réservataire (affichage : reservé)
                    $situation = $msg["resa_expl_reserve"];
                } else {
                    // rien n'est disponible, on trouve la date du premier retour
                    $query = "SELECT date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour from pret p, exemplaires e ";
                    if ($resa_idnotice) {
                        $query .= " WHERE e.expl_notice=" . $resa_idnotice;
                    } elseif ($resa_idbulletin) {
                        $query .= " WHERE e.expl_bulletin=" . $resa_idbulletin;
                    }
                    $query .= " AND e.expl_id=p.pret_idexpl";
                    $query .= " ORDER BY p.pret_retour LIMIT 1";
                    $tresult = pmb_mysql_query($query, $dbh);
                    if (pmb_mysql_num_rows($tresult)) {
                        $situation = pmb_mysql_result($tresult, 0, 0);
                        $info_retour_prevu = $situation;
                    } else {
                        $situation = $msg["resa_no_expl"];
                    }
                    if ($pmb_transferts_actif == "1" && $transferts_choix_lieu_opac != 3) {
                        // && ($f_loc!=0) ?
                        //on regarde si un des exemplaires n'est pas en transfert pour cette resa !
                        $query = "SELECT count(1) FROM transferts WHERE etat_transfert=0 AND origine=4 AND origine_comp=" . $data['id_resa'];
                        $no_aff = 0;
                        $tresult = pmb_mysql_query($query, $dbh);
                        $nb_trans = pmb_mysql_result($tresult, 0);
                        if ($nb_trans != 0) {
                            //on a un transfert en cours
                            $situation = "<strong>" . $msg["transferts_circ_resa_lib_en_transfert"] . "</strong>";
                        } else {
                            $query = "SELECT count(1) FROM exemplaires, docs_statut WHERE expl_statut=idstatut AND statut_allow_resa=1";
                            $query .= " AND expl_location<>" . $f_loc;
                            if ($resa_idnotice) {
                                $query .= " AND expl_notice=" . $resa_idnotice;
                            } elseif ($resa_idbulletin) {
                                $query .= " AND expl_bulletin=" . $resa_idbulletin;
                            }
                            $tresult = pmb_mysql_query($query, $dbh);
                            $total_ex = pmb_mysql_result($tresult, 0);
                            if ($total_ex != 0) {
                                //on en a au moins un ailleurs!
                                // sont-il déjà prêtés ou réservé
                                $query = "SELECT count(1) FROM exemplaires, docs_statut\n\t\t\t\t\t\t\t\t WHERE expl_statut=idstatut AND statut_allow_resa=1";
                                $query .= " AND expl_location<>" . $f_loc;
                                /*
                                if ($resa_idnotice)  $query .= " AND expl_notice=".$resa_idnotice;
                                elseif ($resa_idbulletin) $query .= " AND expl_bulletin=".$resa_idbulletin;
                                $query .= " and expl_id not in(select 	pret_idexpl from pret, exemplaires where pret_idexpl=expl_id ";
                                if ($resa_idnotice)  $query .= " AND expl_notice=".$resa_idnotice;
                                elseif ($resa_idbulletin) $query .= " AND expl_bulletin=".$resa_idbulletin;
                                $query .= ")";
                                $query .= " and expl_cb not in(select resa_cb from resa, exemplaires where resa_cb=expl_cb ";
                                if ($resa_idnotice)  $query .= " AND expl_notice=".$resa_idnotice;
                                elseif ($resa_idbulletin) $query .= " AND expl_bulletin=".$resa_idbulletin;
                                $query .= ")";
                                */
                                $tresult = pmb_mysql_query($query, $dbh);
                                $nb_trans = pmb_mysql_result($tresult, 0);
                                if (!$nb_trans) {
                                    $situation = $msg["resa_no_expl"];
                                } elseif ($total_ex >= $rank) {
                                    $lien_transfert = true;
                                    if (transfert_resa_dispo($resa_idnotice, $resa_idbulletin, $f_loc)) {
                                        $situation = $msg["resa_expl_dispo_other_location"];
                                        if ($info_retour_prevu) {
                                            $situation = $msg["resa_condition"] . " : " . $info_retour_prevu . "<br>{$situation}";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            $situation = '';
        }
        if (!$no_aff || ($idnotice || $idbulletin)) {
            // on affiche les résultats
            $ancre_aff = "";
            if ($ancre == $data['id_resa']) {
                $ancre_aff = " id='ancre_resa' ";
            }
            if ($odd_even == 0) {
                $aff_final .= "\n<tr {$ancre_aff} class='odd' onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='odd'\">";
                $odd_even = 1;
            } else {
                if ($odd_even == 1) {
                    $aff_final .= "\n<tr {$ancre_aff} class='even' onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='even'\">";
                    $odd_even = 0;
                }
            }
            //$type_doc_aff=" [".$tdoc->table[$data['typdoc']]."] ";
            $type_doc_aff = "alt='" . htmlentities($tdoc->table[$data['typdoc']], ENT_QUOTES, $charset) . "' title='" . htmlentities($tdoc->table[$data['typdoc']], ENT_QUOTES, $charset) . "' ";
            if (SESSrights & CATALOGAGE_AUTH) {
                if ($resa_idnotice) {
                    $link = "<a href='./catalog.php?categ=isbd&id=" . $resa_idnotice . "' {$type_doc_aff}>" . $data['tit'] . "</a>";
                } elseif ($resa_idbulletin) {
                    $link = "<a href='./catalog.php?categ=serials&sub=bulletinage&action=view&bul_id=" . $resa_idbulletin . "' {$type_doc_aff}>" . $data['tit'] . "</a>";
                }
            } else {
                $link = $data['tit'];
            }
            if (!$idnotice && !$idbulletin) {
                $aff_final .= "<td><b>{$link}</b></td>";
            }
            $aff_final .= "<td>" . $data['expl_cote'] . "</td>";
            if (!$idempr) {
                if (SESSrights & CIRCULATION_AUTH) {
                    $aff_final .= "<td><a href=\"./circ.php?categ=pret&form_cb=" . rawurlencode($data['empr_cb']) . "\">" . $data['empr_nom'] . ", " . $data['empr_prenom'] . "</a></td>";
                } else {
                    $aff_final .= "<td>" . $data['empr_nom'] . ", " . $data['empr_prenom'] . "</td>";
                }
                if ($pmb_lecteurs_localises) {
                    $aff_final .= "<td>" . $data['location_libelle'] . "</td>";
                }
            }
            $aff_final .= "<td><center>" . $rank . "</center></td>";
            $aff_final .= "<td><center>" . $data['aff_resa_date'] . "</center></td>";
            $aff_final .= "<td><center>" . $situation . "</center></td>";
            $aff_final .= "<td><center>" . $data['aff_resa_date_fin'] . "</center></td>";
            // gestion du formulaire de validation/suppression
            switch ($info_gestion) {
                case GESTION_INFO_GESTION:
                    $aff_final .= "\n<td style='text-align:center;'>";
                    if ($data['resa_cb']) {
                        $aff_final .= "<font color='red'><b>X</b></font>";
                    } else {
                        $aff_final .= "&nbsp;";
                    }
                    $aff_final .= "</td>\n";
                    $aff_final .= "\n<td style='text-align:center;'>";
                    if ($data['resa_confirmee']) {
                        $aff_final .= "<font color='red'><b>X</b></font>";
                    } else {
                        $aff_final .= "&nbsp;";
                    }
                    $aff_final .= "</td>";
                    if ($pmb_transferts_actif == "1") {
                        $loc_retrait = resa_loc_retrait($data["id_resa"]);
                        $rqt = "SELECT location_libelle FROM docs_location WHERE idlocation='" . $loc_retrait . "'";
                        $libloc = @pmb_mysql_result(pmb_mysql_query($rqt), 0);
                        $aff_final .= "<td>" . $libloc . "</td>";
                    }
                    $aff_final .= "<td style='text-align:center;'><input type='checkbox' name='suppr_id_resa[]' value='" . $data['id_resa'] . "' id='suppr_resa' /></td>";
                    if ($pmb_transferts_actif == "1") {
                        if ($lien_transfert) {
                            if (transfert_resa_dispo($resa_idnotice, $resa_idbulletin, $f_loc)) {
                                $img = "./images/peb_in.png";
                            } else {
                                $img = "./images/peb_out.png";
                            }
                            $aff_final .= "<td><a href='#' onclick=\"choisiExpl(this);return(false);\" id_resa=\"" . $data['id_resa'] . "\" idnotice=\"{$resa_idnotice}\" idbul=\"{$resa_idbulletin}\" loc=\"{$f_loc}\" alt=\"" . $msg["transferts_circ_resa_lib_choix_expl"] . "\" title=\"" . $msg["transferts_circ_resa_lib_choix_expl"] . "\">" . "<img src='{$img}'></a></td>";
                        } else {
                            $aff_final .= "<td>&nbsp;</td>";
                        }
                    }
                    break;
                case LECTEUR_INFO_GESTION:
                    $aff_final .= "\n<td style='text-align:center;'>";
                    if ($data['resa_confirmee']) {
                        $aff_final .= "<font color='red'><b>X</b></font>";
                    } else {
                        $aff_final .= "&nbsp;";
                    }
                    $aff_final .= "</td>";
                    if ($pmb_transferts_actif == "1") {
                        if ($transferts_choix_lieu_opac == "1" && $data['aff_resa_date_fin'] == "") {
                            //choix du lieu de retrait
                            $rqt = "SELECT idlocation, location_libelle FROM docs_location ORDER BY location_libelle";
                            $res_loc = pmb_mysql_query($rqt);
                            $liste_loc = "";
                            while ($value = pmb_mysql_fetch_object($res_loc)) {
                                $liste_loc .= "<option value='" . $value->idlocation . "'";
                                if ($value->idlocation == $data['resa_loc_retrait']) {
                                    $liste_loc .= " selected";
                                }
                                $liste_loc .= ">" . $value->location_libelle . "</option>";
                            }
                            $aff_final .= str_replace("!!liste_loc!!", $liste_loc, "<td><select onchange=\"chgLocRetrait(" . $data['id_resa'] . ", this.options[this.selectedIndex].value)\">!!liste_loc!!</select></td>");
                        } else {
                            //on affiche le lieu de retrait
                            $loc_retrait = resa_loc_retrait($data['id_resa']);
                            $rqt = "SELECT location_libelle FROM docs_location WHERE idlocation='" . $loc_retrait . "'";
                            $res = pmb_mysql_query($rqt);
                            if (pmb_mysql_num_rows($res)) {
                                $libloc = pmb_mysql_result($res, 0);
                            }
                            $aff_final .= "<td>" . $libloc . "</td>";
                        }
                    }
                    $aff_final .= "\n<td style='text-align:center;'>";
                    $aff_final .= "<input type='button' class='bouton' name='suppr_resa' value='" . $msg['raz'] . "' id='suppr_resa' ";
                    $aff_final .= "onClick=\"document.location='./circ.php?categ=pret&sub=suppr_resa_from_fiche&action=suppr_resa&suppr_id_resa[]=" . $data['id_resa'] . "&id_empr={$idempr}'\" />";
                    $aff_final .= "</td>";
                    break;
                default:
                case NO_INFO_GESTION:
                    break;
            }
            $aff_final .= "</tr>\n";
        }
        if ($ancre == $data['id_resa']) {
            $aff_final .= "<a name='ancre_resa'></a>";
        }
    }
    //fin du while
    $aff_final .= "</table>";
    if ($ancre) {
        $aff_final .= "\n\t\t<script language=javascript>\n\t\t\tdocument.location='#ancre_resa';\n\t\t</script>\n\t\t";
    }
    switch ($info_gestion) {
        case GESTION_INFO_GESTION:
            $aff_final .= "<table style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;'>\n\t\t\t\t\t<tr><td style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;text-align:left;'>";
            if ($pdflettreresa_priorite_email_manuel != 3) {
                $aff_final .= "<input type='hidden' name='impression_confirmation' value='0' /><input type='button' class='bouton' value='" . $msg[resa_impression_confirmation] . "' onclick=\"this.form.action.value='suppr_resa'; this.form.impression_confirmation.value=1; this.form.submit();\"/></td>";
            }
            $aff_final .= "<input type='hidden' name='action' value='' />";
            $aff_final .= "<td style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;text-align:left;'><input type='button' class='bouton' value='" . $msg[resa_valider_suppression] . "'  onclick=\"if(confirm_delete()){this.form.action.value='suppr_resa'; this.form.submit();}\" />";
            $aff_final .= "</td><td style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;text-align:right;'>";
            $aff_final .= "<input type='button' class='bouton' onClick=\"setCheckboxes('check_resa', 'suppr_id_resa', true); return false;\" value='" . $msg['resa_tout_cocher'] . "' />";
            $aff_final .= "</td></tr></table></form>";
            break;
        case LECTEUR_INFO_GESTION:
            break;
        default:
        case NO_INFO_GESTION:
            break;
    }
    pmb_mysql_free_result($req);
    return $aff_final;
}
Ejemplo n.º 2
0
 $tmpString = str_replace("!!liste_statuts!!", do_liste_statut($statut_defaut), $tmpString);
 $liste_sel = "<option value=0>" . $msg["transferts_circ_reception_meme_section"] . "</option>" . do_liste_section(0);
 //on remplit le select avec la liste des sections
 $tmpString = str_replace("!!liste_sections!!", $liste_sel, $tmpString);
 echo $tmpString;
 if ($form_cb_expl != "") {
     //enregistrement de la reception
     $res_rcp = $obj_transfert->enregistre_reception_cb($form_cb_expl, $statut_reception, $section_reception, $info);
     $motif = $info[0]["motif"];
     if ($res_rcp == false) {
         // reception pas valide
         echo $transferts_reception_erreur;
     } else {
         // reception est faite
         echo str_replace("!!cb_expl!!", $form_cb_expl, $transferts_reception_OK);
         $resa = new reservation(0, 0, 0, $form_cb_expl);
         if ($empr_resa = $resa->get_empr_info_cb()) {
             $motif = $obj_transfert->get_motif($res_rcp);
             echo str_replace("!!empr_link!!", $empr_resa, "<div class='row' align='center'><span class='erreur'>" . $msg["transferts_circ_reception_accepte_resa"] . "</span><br /><b>" . $msg["transferts_circ_reception_resa_par"] . " : !!empr_link!!</b></div>");
         }
         if ($motif) {
             echo "<div class='row' align='center'><b>" . $motif . "</b></div>";
         }
     }
 }
 // les filtres à afficher
 $filtres = "&nbsp;" . $msg["transferts_circ_reception_filtre_source"] . str_replace("!!nom_liste!!", "f_source", $transferts_liste_localisations_tous);
 $filtres = str_replace("!!liste_localisations!!", do_liste_localisation($f_source), $filtres);
 $req = "FROM transferts " . "INNER JOIN transferts_demande ON id_transfert=num_transfert " . "INNER JOIN exemplaires ON num_expl=expl_id " . "INNER JOIN lenders ON idlender=expl_owner " . "INNER JOIN docs_location ON num_location_source=idlocation " . "LEFT JOIN resa ON resa_trans=id_resa " . "LEFT JOIN empr ON resa_idempr=id_empr " . "WHERE etat_transfert=0 " . "AND etat_demande=2 " . "AND num_location_dest=" . $deflt_docs_location;
 //pour le site de l'utilisateur
 //on applique le filtre sélectionner
            $seat = $row_array[$i] . $col_array[$i];
            $pos = strpos($seats_booked, $seat);
            if ($pos === FALSE) {
            } else {
                return FALSE;
            }
        }
        for ($i = 0; $i < $num; $i++) {
            $seat = $row_array[$i] . $col_array[$i];
            $seats_booked = $seats_booked . "," . $seat;
        }
        $sql = mysqli_query($con, "UPDATE flight_availability SET seat_booked='{$seats_booked}' WHERE flight_id='{$flight_id}'");
        return TRUE;
    }
}
$user_object = new reservation();
if (isset($_POST['cancel'])) {
    $ticket_id = $_GET['id'];
    echo "<script>alert('Confirm Cancellation')</script>";
    $cancel_check = $user_object->cancel_ticket($con, $ticket_id);
    if (!$cancel_check) {
        echo "Could not cancel ticket.";
    } else {
        header("Location:cancel_successful.php");
    }
} else {
    if (isset($_POST['book'])) {
        $name = $_SESSION['name_array'];
        $dob = $_SESSION['dob_array'];
        $gender = $_SESSION['gender_array'];
        $nationality = $_SESSION['nationality_array'];
Ejemplo n.º 4
0
 function delete_diffusion($expl_id)
 {
     global $dbh;
     $status = 1;
     if (!$this->info_expl[$expl_id]) {
         return 0;
     }
     // Traitement des résa
     $req = "select num_serialcirc_circ_empr from serialcirc_circ where serialcirc_circ_hold_asked=2 and num_serialcirc_circ_expl={$expl_id}\n\t\torder by serialcirc_circ_order";
     $res = mysql_query($req);
     if (mysql_num_rows($res)) {
         while ($r = mysql_fetch_object($res)) {
             $resa = new reservation($r->num_serialcirc_circ_empr, 0, $this->info_expl[$expl_id]['bulletin_id']);
             $resa->add();
         }
     }
     $req = "delete from serialcirc_expl where num_serialcirc_expl_id ={$expl_id}";
     mysql_query($req);
     $req = "delete from serialcirc_circ where num_serialcirc_circ_expl ={$expl_id}";
     mysql_query($req);
     // on change le statut si demandé
     if ($this->info_expl[$expl_id]['serialcirc_diff']->expl_statut_circ_after) {
         $req = "update exemplaires set expl_statut=" . $this->info_expl[$expl_id]['serialcirc_diff']->expl_statut_circ_after . " where expl_id=" . $expl_id;
         mysql_query($req);
     }
     // traitement résa
     $query = "select count(1) from resa where resa_idbulletin=" . $this->info_expl[$expl_id]['bulletin_id'];
     $result = @mysql_query($query, $dbh);
     if (@mysql_result($result, 0, 0)) {
         $status = 2;
         // mail de résa sera envoyé à l'affectation dans résa à traiter
     }
     return $status;
 }
Ejemplo n.º 5
0
 function add_resa($session_id, $id_notice, $id_bulletin, $location)
 {
     global $dbh, $msg;
     $results = array();
     if (!$session_id) {
         $results["error"] = "no_session_id";
         $results["status"] = FALSE;
         return $results;
     }
     $session_info = $this->retrieve_session_information($session_id);
     $empr_id = $session_info["empr_id"];
     if (!$empr_id) {
         $results["error"] = "no_empr_id";
         $results["status"] = FALSE;
         return $results;
     }
     $resa = new reservation($empr_id, $id_notice, $id_bulletin);
     if ($resa->add($location) == FALSE) {
         $results["error"] = $resa->service->error;
         $results["message"] = $resa->service->message;
         $results["status"] = FALSE;
     } else {
         $results["status"] = TRUE;
     }
     return $results;
 }
Ejemplo n.º 6
0
 $id_resa_ajoutee = 0;
 $requete2 = "SELECT COUNT(1) FROM resa WHERE resa_idempr=" . $_SESSION["id_empr_session"] . " AND resa_idnotice='" . $id_notice . "' and resa_idbulletin='" . $id_bulletin . "' ";
 $result2 = @pmb_mysql_query($requete2, $dbh);
 $nb = pmb_mysql_result($result2, 0, 0);
 if ($nb) {
     // on ne peut pas réserver deux fois un même ouvrage
     $message_resa = $msg["resa_doc_deja_reserve"] . " ";
 } else {
     $has_expl = 1;
     if ($pmb_location_reservation) {
         $rqt = "SELECT expl_id FROM exemplaires WHERE expl_notice='" . $id_notice . "'\n\t\t\t\t\t\t\t\t\tAND expl_bulletin='" . $id_bulletin . "' and expl_location in (select resa_loc from resa_loc where resa_emprloc={$empr_location})";
         $res_expl = pmb_mysql_query($rqt, $dbh);
         $has_expl = 0;
         if (pmb_mysql_num_rows($res_expl)) {
             while ($obj_expl = pmb_mysql_fetch_object($res_expl)) {
                 if (reservation::check_expl_reservable($obj_expl->expl_id)) {
                     // cette localisation possède un exemplaire pouvant répondre à sa demande de réservation
                     $has_expl = 1;
                 }
             }
         }
     }
     if ($has_expl) {
         if ($pmb_transferts_actif == "1" && $transferts_choix_lieu_opac == "1") {
             //les transferts sont activés et un lieu a été choisi
             $requete3 = "INSERT INTO resa (resa_idempr, resa_idnotice, resa_idbulletin, resa_date, resa_loc_retrait) ";
             $requete3 .= "VALUES ('" . $_SESSION["id_empr_session"] . "','{$id_notice}','{$id_bulletin}', SYSDATE(), {$idloc})";
         } else {
             $requete3 = "INSERT INTO resa (resa_idempr, resa_idnotice, resa_idbulletin, resa_date) ";
             $requete3 .= "VALUES ('" . $_SESSION["id_empr_session"] . "','{$id_notice}','{$id_bulletin}', SYSDATE())";
         }
Ejemplo n.º 7
0
            }
        }
    } else {
        $resa_cart_display = "<table><tr><th colspan=2>" . $msg["empr_menu_resa"] . " : </th></tr>";
        foreach ($notices as $notice_id) {
            $resa_cart_display .= "<tr>";
            $bulletin_id = 0;
            //On vérifi si notre notice n'est pas une notice de bulletin.
            $query = 'SELECT bulletin_id FROM bulletins WHERE num_notice=' . $notice_id;
            $result = pmb_mysql_query($query, $dbh);
            if (pmb_mysql_num_rows($result)) {
                while ($line = pmb_mysql_fetch_array($result, MYSQL_ASSOC)) {
                    $bulletin_id = $line['bulletin_id'];
                }
            }
            $resa = new reservation($id_empr, $notice_id, $bulletin_id);
            if ($resa->add($_SESSION['empr_location'])) {
                $resa_cart_display .= "<td>" . $resa->notice . "</td><td>" . $resa->message . "</td>";
            } else {
                $resa_cart_display .= "<td>" . $resa->notice . "</td><td>" . $resa->message . "</td>";
            }
            $resa_cart_display .= "</tr>";
        }
        $resa_cart_display .= "</table>";
        if (!$opac_resa_popup) {
            require_once $base_path . '/includes/show_cart.inc.php';
        }
    }
} else {
    print "<script>document.location='" . $base_path . "/index.php';</script>";
}
Ejemplo n.º 8
0
        $resa->add();
        $erreur_affichage = "<div class='row'><div class='colonne10'><img src='./images/info.png' /></div>\n\t\t\t\t\t<div class='colonne-suite'>";
        $erreur_affichage .= "<span class='erreur'>" . $resa->message . "</span>";
        $erreur_affichage .= "</div>";
        if ($resa->force) {
            $erreur_affichage .= "<input type='button' class='bouton' value='" . $msg["resa_force"] . "' onClick=\"document.location='circ.php?categ=resa&id_empr={$id_empr}&id_notice={$id_notice}&id_bulletin={$id_bulletin}&quota_resa=1'\">";
        }
        $erreur_affichage .= "</div>\n";
        $empr = new emprunteur($id_empr, $erreur_affichage, FALSE, 1, $resa->id);
        print pmb_bidi($empr->fiche);
    } else {
        // c'est une suppression
        if ($id_notice) {
            $resa = new reservation($id_empr, $id_notice);
        } else {
            $resa = new reservation($id_empr, 0, $id_bulletin);
        }
        $resa->delete();
        $erreur_affichage = "<table border='0' cellpadding='1' height='40' border='1'><tr><td width='33'><span><img src='./images/info.png' /></span></td>\n\t\t\t\t\t<td width='100%'>";
        $erreur_affichage .= "<span class='erreur'>" . $resa->message . "</span>";
        $erreur_affichage .= "</td></tr></table>";
        $empr = new emprunteur($id_empr, $erreur_affichage, FALSE, 1);
        print pmb_bidi($empr->fiche);
    }
} else {
    if ($groupID) {
        print "<script type='text/javascript'>document.location=\"./circ.php&categ=groups&groupID={$groupID}\";</script>";
    } else {
        print "<script type='text/javascript'>document.location=\"./circ.php\";</script>";
    }
}