Пример #1
0
                for ($j = round($loc->note); $j <= $cpt_star; $j++) {
                    $etoiles .= "<img border=0 src='images/star_unlight.png' align='absmiddle' />";
                }
            }
            if ($pmb_avis_note_display_mode == 3) {
                $note = $etoiles . "<br />" . $categ_avis;
            } else {
                $note = $etoiles . $categ_avis;
            }
        } else {
            $note = "";
        }
        if (!$loc->valide) {
            $res_final .= "<font color='#CC0000'><span >{$note}<b>" . htmlentities($loc->sujet, ENT_QUOTES, $charset) . "</b></span></font>";
        } else {
            $res_final .= "<font color='#00BB00'><span >{$note}<b>" . htmlentities($loc->sujet, ENT_QUOTES, $charset) . "</b></span></font>";
        }
        if ($charset != "utf-8") {
            $loc->commentaire = cp1252Toiso88591($loc->commentaire);
        }
        $res_final .= ", " . $loc->ladate . "  {$loc->empr_prenom} {$loc->empr_nom} \n\t\t\t\t</div>\n\n\t\t\t\t<div class='row'>\n\t\t\t\t\t" . do_bbcode($loc->commentaire) . "\n\t\t\t\t</div>\n\t\t\t</div><div id='update_{$loc->id_avis}'></div>\n\t\t\t<br />";
    }
    $res_final .= "</ul><br />";
    print $res_final;
}
print aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true);
echo "</div>";
echo "\n\t\t<div class='row'>\n\t\t\t<div class='left'>\n\t\t\t\t<input type='hidden' name='quoifaire' value='' />\n\t\t\t\t<input type='button' class='bouton' name='valider' value='" . $msg[avis_bt_valider] . "' onclick='this.form.quoifaire.value=\"valider\"; this.form.submit()' />&nbsp;\n\t\t\t\t<input type='button' class='bouton' name='invalider' value='" . $msg[avis_bt_invalider] . "' onclick='this.form.quoifaire.value=\"invalider\"; this.form.submit()' />&nbsp;\n\t\t\t\t<input type='button' class='bouton' name='supprimer' value='" . $msg[avis_bt_supprimer] . "' onclick='this.form.quoifaire.value=\"supprimer\"; this.form.submit()' />&nbsp;\n\t\t\t\t</div>\n\t\t\t<div class='right'>\n\t\t\t\t<input type='button' class='bouton' name='selectionner' value='" . $msg[avis_bt_selectionner] . "' onClick=\"setCheckboxes('validation_avis', 'valid_id_avis', true); return false;\" />&nbsp;\n\t\t\t\t</div>\n\t\t\t</div>\n<div class='row'></div>\n\t\t\t</form>";
jscript_checkbox();
?>
		
Пример #2
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;
}
Пример #3
0
function resa_list($idnotice = 0, $idbulletin = 0, $idempr = 0, $order = "", $where = "", $info_gestion = 0, $url_gestion = "")
{
    global $dbh;
    global $msg;
    global $montrerquoi;
    global $current_module;
    if (!$montrerquoi) {
        $montrerquoi = 'all';
    }
    if (!$order) {
        $order = "tit, resa_idnotice, resa_idbulletin, resa_date";
    }
    $sql = "SELECT resa_idnotice, resa_idbulletin, resa_date, resa_date_debut, resa_date_fin, resa_cb, resa_idempr, empr_nom, empr_prenom, empr_cb, ";
    $sql .= " trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, id_resa, ";
    $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 bulletins ON resa_idbulletin = bulletins.bulletin_id) ";
    $sql .= " LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), ";
    $sql .= " empr ";
    if ($idempr) {
        $sql .= " where id_empr='{$idempr}' AND resa_idempr = id_empr ";
    } elseif ($idnotice || $idbulletin) {
        $sql .= " where resa_idnotice = '{$idnotice}' AND resa_idbulletin='{$idbulletin}' and resa_idempr = id_empr ";
    } else {
        $sql .= " where resa_idempr = id_empr ";
    }
    if ($where) {
        $sql .= " AND " . $where;
    }
    $sql .= " group by resa_idnotice, resa_idbulletin, resa_idempr ";
    $sql .= " order by " . $order;
    $req = mysql_query($sql) or die("Erreur SQL !<br />" . $sql . "<br />" . mysql_error());
    if ($info_gestion) {
        $aff_final .= "<br /><form class='form-{$current_module}' name='check_resa' action='{$url_gestion}' method='post'>";
        $aff_final .= $msg['resa_show_all'] . "<input type='radio' name='montrerquoi' value='all' onclick='this.form.submit();' ";
        if ($montrerquoi == 'all') {
            $aff_final .= "checked";
        }
        $aff_final .= ">&nbsp;&nbsp;&nbsp;" . $msg['resa_show_validees'] . "<input type='radio' name='montrerquoi' value='validees' onclick='this.form.submit();' ";
        if ($montrerquoi == 'validees') {
            $aff_final .= "checked";
        }
        $aff_final .= ">&nbsp;&nbsp;&nbsp;" . $msg['resa_show_invalidees'] . "<input type='radio' name='montrerquoi' value='invalidees' onclick='this.form.submit();' ";
        if ($montrerquoi == 'invalidees') {
            $aff_final .= "checked";
        }
        $aff_final .= "><br />";
        jscript_checkbox();
    }
    if (!mysql_num_rows($req)) {
        if ($info_gestion) {
            $aff_final .= "</form>";
        }
        return $aff_final;
    }
    $aff_final .= "<table width='100%'>";
    $aff_final .= "<tr>";
    if (!$idnotice && !$idbulletin) {
        $aff_final .= "<th>{$msg['233']}</th>";
    }
    if (!$idempr) {
        $aff_final .= "<th>{$msg['empr_nom_prenom']}</th>";
    }
    $aff_final .= "<th>{$msg['366']}</th>\n \t<th>{$msg['374']}</th>\n \t<th>{$msg['654']}</th>\n \t<th>{$msg['resa_date_fin']}</th>";
    if ($info_gestion) {
        $aff_final .= "<th>{$msg['resa_validee']}</th><th>{$msg['resa_selectionner']}</th>";
    }
    $aff_final .= "</tr>";
    $odd_even = 0;
    $precedenteresa_idnotice = 0;
    $precedenteresa_idbulletin = 0;
    $rank = 0;
    while ($data = mysql_fetch_array($req)) {
        $resa_idnotice = $data['resa_idnotice'];
        $resa_idbulletin = $data['resa_idbulletin'];
        $resa_idempr = $data['resa_idempr'];
        if ($resa_idnotice != $precedenteresa_idnotice || $resa_idbulletin != $precedenteresa_idbulletin) {
            $rank = 1;
            $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 réservables et visibles pour la notice
            $query = "select count(1) from exemplaires, docs_statut";
            if ($resa_idnotice) {
                $query .= " where expl_notice=" . $resa_idnotice;
            } elseif ($resa_idbulletin) {
                $query .= " where expl_bulletin=" . $resa_idbulletin;
            }
            $query .= " and expl_statut=idstatut and statut_allow_resa=1 and statut_visible_opac=1";
            $tresult = @mysql_query($query, $dbh);
            $total_ex = mysql_result($tresult, 0, 0);
            // on compte le nombre d'exemplaires sortis
            $query = "select count(1) as qte from exemplaires e, pret p";
            if ($resa_idnotice) {
                $query .= " where e.expl_notice=" . $resa_idnotice;
            } elseif ($resa_idbulletin) {
                $query .= " where e.expl_bulletin=" . $resa_idbulletin;
            }
            $query .= " and p.pret_idexpl=e.expl_id";
            $tresult = @mysql_query($query, $dbh);
            $total_sortis = mysql_result($tresult, 0, 0);
            // on en déduit le nombre d'exemplaires disponibles
            $total_dispo = $total_ex - $total_sortis;
            if ($rank <= $total_dispo) {
                // un exemplaire est disponible pour le réservataire (affichage : disponible)
                $situation = "<strong>{$msg['359']}</strong>";
            } else {
                if ($total_dispo) {
                    // un ou des exemplaires sont disponibles, mais pas pour ce réservataire (affichage : reservé)
                    $situation = 'reservé';
                } 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 = mysql_query($query, $dbh);
                    if (mysql_num_rows($tresult)) {
                        $situation = mysql_result($tresult, 0, 0);
                    } else {
                        $situation = $msg['resa_no_expl'];
                    }
                }
            }
        } else {
            $rank++;
            $situation = '';
        }
        if ($montrerquoi == 'validees' && $data['resa_cb'] || $montrerquoi == 'invalidees' && !$data['resa_cb'] || $montrerquoi == 'all') {
            $rank = recupere_rang($resa_idempr, $resa_idnotice, $resa_idbulletin);
            // on affiche les résultats
            if ($odd_even == 0) {
                $aff_final .= "\n<tr class='odd'>";
                $odd_even = 1;
            } else {
                if ($odd_even == 1) {
                    $aff_final .= "\n<tr class='even'>";
                    $odd_even = 0;
                }
            }
            if (SESSrights & CATALOGAGE_AUTH) {
                if ($resa_idnotice) {
                    $link = "<a href='./catalog.php?categ=isbd&id=" . $resa_idnotice . "'>" . $data['tit'] . "</a>";
                } elseif ($resa_idbulletin) {
                    $link = "<a href='./catalog.php?categ=serials&sub=bulletinage&action=view&bul_id=" . $resa_idbulletin . "'>" . $data['tit'] . "</a>";
                }
            } else {
                $link = $data['tit'];
            }
            if (!$idnotice && !$idbulletin) {
                $aff_final .= "<td><b>{$link}</b></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>";
                }
            }
            $aff_final .= "<td>" . $rank . "</td>";
            $aff_final .= "<td>" . $data['aff_resa_date'] . "</td>";
            $aff_final .= "<td>" . $situation . "</td>";
            $aff_final .= "<td>" . $data['aff_resa_date_fin'] . "</td>";
            // gestion du formulaire de validation/suppression
            if ($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<td style='text-align:center;'><input type='checkbox' name='suppr_id_resa[]' value='" . $data['id_resa'] . "' id='suppr_resa' /></td>";
            }
            $aff_final .= "</tr>\n";
        }
    }
    $aff_final .= "</table>";
    if ($info_gestion) {
        $aff_final .= "<table style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;'>\n\t\t\t<tr><td style='background:none;border-right:0px;border-left:0px;border-bottom:0px;border-top:0px;text-align:left;'><input type='submit' class='bouton' value='" . $msg[resa_valider_suppression] . "' /></td>";
        $aff_final .= "<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>";
    }
    mysql_free_result($req);
    return $aff_final;
}