function resa_list_resa_a_traiter() { /* Traitement : chercher toutes les réservations non traitées (resa_cb ="") construire le tableau avec le titre de l'ouvrage, le nom du réservataire et son rang */ global $dbh; global $msg; global $pmb_lecteurs_localises; global $deflt_resas_location; global $pmb_location_reservation; global $pmb_transferts_actif, $transferts_choix_lieu_opac, $transferts_site_fixe; global $f_loc, $f_dispo_loc; $tableau_final = array(); $order = "tit, resa_idnotice, resa_idbulletin, resa_date"; $sql_expl_loc = ""; if ($pmb_lecteurs_localises) { if ($f_loc == "") { $f_loc = $deflt_resas_location; } if ($f_loc && $f_dispo_loc) { $sql_expl_loc = " and (expl_location='" . $f_loc . "' or expl_location='" . $f_dispo_loc . "') "; } elseif ($f_dispo_loc) { $sql_expl_loc = " and expl_location='" . $f_dispo_loc . "' "; } } if ($pmb_transferts_actif == "1" && $f_loc) { 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 && $f_dispo_loc) { $sql_expl_loc = " and (expl_location='" . $f_loc . "' or expl_location='" . $f_dispo_loc . "') "; } elseif ($f_dispo_loc) { $sql_expl_loc = " and expl_location='" . $f_dispo_loc . "' "; } break; default: //retrait de la resa sur lieu lecteur $sql_suite .= " AND empr_location='" . $f_loc . "' "; if ($f_loc && $f_dispo_loc) { $sql_expl_loc = " and (expl_location='" . $f_loc . "' or expl_location='" . $f_dispo_loc . "') "; } elseif ($f_dispo_loc) { $sql_expl_loc = " and expl_location='" . $f_dispo_loc . "' "; } break; } } elseif ($pmb_location_reservation && $f_loc) { $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_fin, resa_cb, resa_idempr, empr_nom, empr_prenom, empr_cb, empr_location, "; $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 .= " LEFT JOIN exemplaires ON resa_cb = exemplaires.expl_cb), empr {$sql_loc_resa_from} "; $sql .= " where resa_idempr=id_empr and (resa_cb='' or resa_cb is null) "; $sql .= $sql_suite; $sql .= " group by resa_idnotice, resa_idbulletin, resa_idempr "; $sql .= " order by " . $order; $req = pmb_mysql_query($sql) or die("Erreur SQL !<br />" . $sql . "<br />" . pmb_mysql_error()); if (!pmb_mysql_num_rows($req)) { return $tableau_final; } while ($data = pmb_mysql_fetch_array($req)) { if ($pmb_lecteurs_localises) { $requete = "SELECT location_libelle as empr_loc_libelle FROM docs_location WHERE idlocation= '" . $data['empr_location'] . "' "; $result = @pmb_mysql_query($requete, $dbh); $res_empr = pmb_mysql_fetch_object($result); } $resa_idnotice = $data['resa_idnotice']; $resa_idbulletin = $data['resa_idbulletin']; // 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); // 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; // on a au moins UN dispo : if ($total_dispo > 0) { $available = true; $rank = recupere_rang($data['resa_idempr'], $resa_idnotice, $resa_idbulletin); if ($rank > $total_dispo) { $available = false; } if ($pmb_transferts_actif == "1") { $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 $available = false; } elseif ($total_ex >= $rank) { if (!transfert_resa_dispo($resa_idnotice, $resa_idbulletin, $dest_loc)) { //non disponible dans une autre localisation $available = false; } } } } } } // un exemplaire est disponible pour cette resa if ($available) { $rank = recupere_rang($data['resa_idempr'], $resa_idnotice, $resa_idbulletin); 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_retrait = @pmb_mysql_result(pmb_mysql_query($rqt), 0); } else { $libloc_retrait = ""; } $tableau_final[] = array('resa_tit' => $data['tit'], 'resa_idnotice' => $resa_idnotice, 'resa_idbulletin' => $resa_idbulletin, 'resa_idempr' => $data['resa_idempr'], 'resa_empr' => $data['empr_nom'] . " " . $data['empr_prenom'], 'resa_empr_loc_libelle' => $res_empr->empr_loc_libelle, 'rank' => $rank, 'loc_retrait_libelle' => $libloc_retrait); } } } // fin while pmb_mysql_free_result($req); return $tableau_final; }
function list_resas($session_id) { global $dbh, $msg; if (!$session_id) { return array(); } $session_info = $this->retrieve_session_information($session_id); $empr_id = $session_info["empr_id"]; if (!$empr_id) { return array(); } $results = array(); $requete3 = "SELECT id_resa, resa_idempr, resa_idnotice, resa_idbulletin, resa_date, resa_date_fin, resa_cb, IF(resa_date_fin>=sysdate() or resa_date_fin='0000-00-00',0,1) as perimee, date_format(resa_date_fin, '" . $msg["format_date"] . "') as aff_date_fin, resa_loc_retrait, location_libelle FROM resa LEFT JOIN docs_location ON (idlocation = resa_loc_retrait) WHERE resa_idempr=" . $empr_id; $result3 = @mysql_query($requete3, $dbh); while ($resa = mysql_fetch_array($result3)) { $message_null_resa = ""; $id_resa = $resa['id_resa']; $resa_idempr = $resa['resa_idempr']; $resa_idnotice = $resa['resa_idnotice']; $resa_idbulletin = $resa['resa_idbulletin']; $resa_date = $resa['resa_date']; $resa_retrait_location_id = $resa["resa_loc_retrait"]; $resa_retrait_location = $resa["location_libelle"]; if ($resa['resa_cb']) { $resa_dateend = $resa['aff_date_fin']; } else { $resa_dateend = ""; } $rang = recupere_rang($resa_idempr, $resa_idnotice, $resa_idbulletin); $aresult = array("resa_id" => $id_resa, "empr_id" => $empr_id, "notice_id" => $resa_idnotice, "bulletin_id" => $resa_idbulletin, "resa_rank" => $rang, "resa_dateend" => $resa_dateend, "resa_retrait_location" => utf8_normalize($resa_retrait_location), "resa_retrait_location_id" => $resa_retrait_location_id); $results[] = $aresult; } return $results; }
function resa_list_resa_a_traiter() { /* Traitement : chercher toutes les réservations non traitées (resa_cb ="") construire le tableau avec le titre de l'ouvrage, le nom du réservataire et son rang */ global $dbh; global $msg; $tableau_final = array(); $order = "tit, resa_idnotice, resa_idbulletin, resa_date"; $sql = "SELECT resa_idnotice, resa_idbulletin, resa_date, 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), empr "; $sql .= " where resa_idempr=id_empr and (resa_cb='' or resa_cb is null) "; $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 (!mysql_num_rows($req)) { return $tableau_final; } while ($data = mysql_fetch_array($req)) { $rank = recupere_rang($data['resa_idempr'], $data['resa_idnotice'], $data['resa_idbulletin']); $tableau_final[] = array('resa_tit' => $data['tit'], 'resa_idnotice' => $data['resa_idnotice'], 'resa_idbulletin' => $data['resa_idbulletin'], 'resa_idempr' => $data['resa_idempr'], 'resa_empr' => $data['empr_nom'] . " " . $data['empr_prenom'], 'rank' => $rank); } // fin while mysql_free_result($req); return $tableau_final; }
} else { // c'est un bulletin donc j'affiche le nom de périodique et le nom du bulletin (date ou n°) $requete = "SELECT bulletin_id, bulletin_numero, bulletin_notice, mention_date, date_date, date_format(date_date, '" . $msg["format_date_sql"] . "') as aff_date_date FROM bulletins WHERE bulletin_id='{$resa_idbulletin}'"; $res = pmb_mysql_query($requete, $dbh); $obj = pmb_mysql_fetch_object($res); $notice3 = new notice($obj->bulletin_notice); $titre = pmb_bidi($notice3->print_resume(1, $css)); // affichage de la mention de date utile : mention_date si existe, sinon date_date if ($obj->mention_date) { $titre .= pmb_bidi("(" . $obj->mention_date . ")\n"); } elseif ($obj->date_date) { $titre .= pmb_bidi("(" . $obj->aff_date_date . ")\n"); } $link_del = "<a href='empr.php?tab=loan_reza&lvl=all&delete=1&id_bulletin=" . $resa_idbulletin . "#empr-resa'>" . $msg['resa_effacer_resa'] . "</a>"; } $rang = recupere_rang($resa_idempr, $resa_idnotice, $resa_idbulletin); $rank_texte = sprintf($msg[rank], $rang); if (!$resa['perimee']) { if ($resa['resa_cb']) { $rank_texte .= " " . sprintf($msg["expl_reserved_til"], $resa['aff_date_fin']) . " "; } else { $rank_texte .= " " . $msg["resa_attente_validation"]; } } else { $rank_texte .= " " . $msg["resa_overtime"]; } if ($parity++ % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; }