break; case 'raz_conf_resa': for ($i = 0; $i < count($resa_check); $i++) { $key = $resa_check[$i]; $rqt_maj = 'update resa_planning set resa_confirmee=0 where id_resa in (' . $resa_check[$i] . ')'; if ($id_empr[$resa_check[$i]]) { $rqt_maj .= ' and resa_idempr=' . $id_empr[$resa_check[$i]]; } pmb_mysql_query($rqt_maj, $dbh); } print planning_list(0, 0, 0, '', '', GESTION_INFO_GESTION); break; case 'to_resa': if (count($resa_check)) { foreach ($resa_check as $k => $id_rp) { $rp = new resa_planning($id_rp); $rp->to_resa(); } } print planning_list(0, 0, 0, '', '', GESTION_INFO_GESTION); break; default: print planning_list(0, 0, 0, '', '', GESTION_INFO_GESTION); break; } break; case 'pret': switch ($action) { case 'suppr_resa': //Suppression réservation depuis fiche lecteur resa_planning::delete($id_resa);
function resa_planning($deb = TRUE) { global $dbh, $msg, $charset; global $id_notice, $id_bulletin; global $liens_opac; global $form_resa_dates, $form_resa_ok; global $popup_resa, $opac_max_resa; global $resa_deb, $resa_fin; print "<h3><span>" . $msg['resa_resa_titre_add'] . "</span></h3>"; if ($deb) { // test au cas où tentative de passer une résa hors URL de résa autorisée... $requete_resa = "SELECT count(1) FROM resa_planning WHERE resa_idnotice='{$id_notice}' and resa_idbulletin='{$id_bulletin}'"; $result_resa = pmb_mysql_query($requete_resa, $dbh); if ($result_resa) { $nb_resa_encours = pmb_mysql_result($result_resa, 0, 0); } else { $nb_resa_encours = 0; } if ($opac_max_resa && $nb_resa_encours >= $opac_max_resa) { $id_notice = 0; $id_bulletin = 0; } } if (!$id_notice && !$id_bulletin) { return $msg['resa_planning_unknown_record']; } $tab_loc_retrait = resa_planning::get_available_locations($_SESSION['id_empr_session'], $id_notice, $id_bulletin); if (count($tab_loc_retrait) >= 1) { $form_loc_retrait = '<table ><tbody><tr><th>' . $msg['resa_planning_loc_retrait'] . '</th><th>' . $msg['resa_planning_qty_requested'] . '</th></tr>'; foreach ($tab_loc_retrait as $k => $v) { $form_loc_retrait .= '<tr><td width="50%">' . htmlentities($v['location_libelle'], ENT_QUOTES, $charset) . '</td>'; $form_loc_retrait .= '<td><select name="location[' . $v['location_id'] . ']">'; for ($i = 0; $i < $v['location_nb'] * 1 + 1; $i++) { $form_loc_retrait .= '<option value=' . $i . '>' . $i . '</option>'; } $form_loc_retrait .= '</select></td>'; $form_loc_retrait .= '</tr>'; } $form_loc_retrait .= '</tbody></table>'; } else { return $msg['resa_planning_no_item_available']; } $form_resa_dates = str_replace('!!resa_loc_retrait!!', $form_loc_retrait, $form_resa_dates); print $form_resa_dates; if ($id_notice) { $opac_notices_depliable = 0; $liens_opac = array(); $ouvrage_resa = aff_notice($id_notice, 1); } else { $ouvrage_resa = bulletin_affichage_reduit($id_bulletin, 1); } if (!$deb) { $form_resa_ok = str_replace('!!date_deb!!', formatdate($resa_deb), $form_resa_ok); $form_resa_ok = str_replace('!!date_fin!!', formatdate($resa_fin), $form_resa_ok); print $form_resa_ok; } print $ouvrage_resa; //Affichage des previsions sur le document courant par le lecteur courant $q3 = "SELECT id_resa, resa_idnotice, resa_idbulletin, resa_date_debut, resa_date_fin, "; $q3 .= "if(resa_date_fin < sysdate() or resa_date_fin='0000-00-00',1,0) as resa_perimee, resa_validee, resa_confirmee, "; $q3 .= "resa_qty, resa_loc_retrait, location_libelle "; $q3 .= "FROM resa_planning left join docs_location on resa_loc_retrait=idlocation "; $q3 .= "WHERE id_resa not in (select resa_planning_id_resa from resa where resa_idempr=" . $_SESSION['id_empr_session'] . ") "; $q3 .= "and resa_idempr='" . $_SESSION['id_empr_session'] . "' and resa_idnotice={$id_notice} and resa_idbulletin={$id_bulletin} "; $q3 .= "ORDER by resa_date_debut asc, resa_date_fin asc"; $r3 = @pmb_mysql_query($q3, $dbh); if (pmb_mysql_num_rows($r3)) { $tableau_resa = '<h3>' . $msg['resa_planning_current'] . '</h3>'; $tableau_resa .= '<table class="tab_resa_planning">'; $tableau_resa .= '<tr><th>' . $msg['resa_planning_dates'] . '</th> <th>' . $msg['resa_planning_qty'] . '</th><th>' . $msg['resa_planning_loc_retrait'] . '</th></tr>'; while ($resa = pmb_mysql_fetch_array($r3)) { $id_resa = $resa['id_resa']; $resa_idnotice = $resa['resa_idnotice']; $resa_idbulletin = $resa['resa_idbulletin']; $resa_date_debut = formatdate($resa['resa_date_debut']); $resa_date_fin = formatdate($resa['resa_date_fin']); $resa_qty = $resa['resa_qty']; $resa_loc_retrait = $resa['location_libelle']; $txt_dates = $msg['resa_planning_date_debut'] . $resa_date_debut . '<br />'; $txt_dates .= $msg['resa_planning_date_fin'] . $resa_date_fin . '<br />'; if ($resa['resa_perimee']) { $txt_dates .= $msg['resa_planning_overtime']; } else { $txt_dates .= $msg['resa_planning_attente_validation']; } if ($parity++ % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $tableau_resa .= "<tr class='{$pair_impair}'>\n\t\t\t\t<td>{$txt_dates}</td><td>{$resa_qty}</td>\n\t\t\t\t<td>" . htmlentities($resa_loc_retrait, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t</tr>"; } $tableau_resa .= "</table>"; print $tableau_resa; } }
function del_resa($id_empr, $id_notice, $id_bulletin, $cb_encours_de_pret) { global $dbh; if (!$id_empr || !$id_notice && !$id_bulletin) { return FALSE; } if (!$id_notice) { $id_notice = 0; } if (!$id_bulletin) { $id_bulletin = 0; } $rqt = "select resa_cb, id_resa, resa_planning_id_resa from resa where resa_idnotice='" . $id_notice . "' and resa_idbulletin='" . $id_bulletin . "' and resa_idempr='" . $id_empr . "' "; $res = pmb_mysql_query($rqt, $dbh); $obj = pmb_mysql_fetch_object($res); $cb_recup = $obj->resa_cb; $id_resa = $obj->id_resa; // suppression resa $rqt = "delete from resa where id_resa='" . $id_resa . "' "; $res = pmb_mysql_query($rqt, $dbh); // suppression de la prévision associée à la resa resa_planning::delete($obj->resa_planning_id_resa); // si on delete une resa à partir d'un prêt, on invalide la résa qui était validée avec le cb, mais on ne change pas les dates, ça sera fait par affect_cb $rqt_invalide_resa = "update resa set resa_cb='' where resa_cb='" . $cb_encours_de_pret . "' "; $res = pmb_mysql_query($rqt_invalide_resa, $dbh); // réaffectation du doc éventuellement if ($cb_recup != $cb_encours_de_pret) { // les cb sont différents if (!verif_cb_utilise($cb_recup)) { // le cb qui était affecté à la résa qu'on vient de supprimer n'est pas utilisé // on va affecter le cb_récupéré à une resa non validée $res_affectation = affecte_cb($cb_recup); if (!$res_affectation && $cb_recup) { // cb non réaffecté, il faut transférer les infos de la résa dans la table des docs à ranger $rqt = "insert into resa_ranger (resa_cb) values ('" . $cb_recup . "') "; $res = pmb_mysql_query($rqt, $dbh); } } } // Au cas où il reste des résa invalidées par resa_cb, on leur colle les dates comme il faut... $rqt_invalide_resa = "update resa set resa_date_debut='0000-00-00', resa_date_fin='0000-00-00' where resa_cb='' "; $res = pmb_mysql_query($rqt_invalide_resa, $dbh); return TRUE; }
/** * Retourne les informations de réservation * @return array $this->resas_datas = array('nb_resas', 'href', 'onclick', 'flag_max_resa', 'flag_resa_visible') */ public function get_resas_datas() { if (!isset($this->resas_datas)) { global $dbh, $msg; global $opac_resa; global $opac_max_resa; global $opac_show_exemplaires; global $popup_resa; global $opac_resa_popup; // la résa se fait-elle par popup ? global $opac_resa_planning; // la résa est elle planifiée global $allow_book; global $opac_show_exemplaires_analysis; $this->resas_datas = array('nb_resas' => 0, 'href' => "#", 'onclick' => "", 'flag_max_resa' => false, 'flag_resa_visible' => true, 'flag_resa_possible' => true); $bul_info = $this->get_bul_info(); $bulletin_id = $bul_info['bulletin_id']; if ($bulletin_id) { $requete_resa = "SELECT count(1) FROM resa WHERE resa_idbulletin='{$bulletin_id}' "; } else { $requete_resa = "SELECT count(1) FROM resa WHERE resa_idnotice='{$this->id}' "; } $this->resas_datas['nb_resas'] = pmb_mysql_result(pmb_mysql_query($requete_resa, $dbh), 0, 0); if (is_null($this->dom_2) && $opac_show_exemplaires && $this->is_visu_expl() && (!$this->is_visu_expl_abon() || $this->is_visu_expl_abon() && $_SESSION["user_code"]) || $this->get_rights() & 8) { if (!$opac_resa_planning) { if ($bulletin_id) { $resa_check = check_statut(0, $bulletin_id); } else { $resa_check = check_statut($this->id, 0); } // vérification si exemplaire réservable if ($resa_check) { if (($this->get_niveau_biblio() == "m" || $this->get_niveau_biblio() == "b" || $this->get_niveau_biblio() == "a" && $opac_show_exemplaires_analysis) && ($_SESSION["user_code"] && $allow_book) && $opac_resa && !$popup_resa) { if ($opac_max_resa == 0 || $opac_max_resa > $this->resas_datas['nb_resas']) { if ($opac_resa_popup) { $this->resas_datas['onclick'] = "if(confirm('" . $msg["confirm_resa"] . "')){w=window.open('./do_resa.php?lvl=resa&id_notice=" . $this->id . "&id_bulletin=" . $bulletin_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;}else return false;"; } else { $this->resas_datas['href'] = "./do_resa.php?lvl=resa&id_notice=" . $this->id . "&id_bulletin=" . $bulletin_id . "&oresa=popup"; $this->resas_datas['onclick'] = "return confirm('" . $msg["confirm_resa"] . "')"; } } else { $this->resas_datas['flag_max_resa'] = true; } } elseif (($this->get_niveau_biblio() == "m" || $this->get_niveau_biblio() == "b" || $this->get_niveau_biblio() == "a" && $opac_show_exemplaires_analysis) && !$_SESSION["user_code"] && $opac_resa && !$popup_resa) { // utilisateur pas connecté // préparation lien réservation sans être connecté if ($opac_resa_popup) { $this->resas_datas['onclick'] = "if(confirm('" . $msg["confirm_resa"] . "')){w=window.open('./do_resa.php?lvl=resa&id_notice=" . $this->id . "&id_bulletin=" . $bulletin_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;}else return false;"; } else { $this->resas_datas['href'] = "./do_resa.php?lvl=resa&id_notice=" . $this->id . "&id_bulletin=" . $bulletin_id . "&oresa=popup"; $this->resas_datas['onclick'] = "return confirm('" . $msg["confirm_resa"] . "')"; } } } else { $this->resas_datas['flag_resa_possible'] = false; } // fin if resa_check } else { // planning de réservations $this->resas_datas['nb_resas'] = resa_planning::count_resa($this->id); if ($this->get_niveau_biblio() == "m" && ($_SESSION["user_code"] && $allow_book) && $opac_resa && !$popup_resa) { if ($opac_max_resa == 0 || $opac_max_resa > $this->resas_datas['nb_resas']) { if ($opac_resa_popup) { $this->resas_datas['onclick'] = "w=window.open('./do_resa.php?lvl=resa_planning&id_notice=" . $this->id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;"; } else { $this->resas_datas['href'] = "./do_resa.php?lvl=resa_planning&id_notice=" . $this->id . "&oresa=popup"; } } else { $this->resas_datas['flag_max_resa'] = true; } } elseif ($this->get_niveau_biblio() == "m" && !$_SESSION["user_code"] && $opac_resa && !$popup_resa) { // utilisateur pas connecté // préparation lien réservation sans être connecté if ($opac_resa_popup) { $this->resas_datas['onclick'] = "w=window.open('./do_resa.php?lvl=resa_planning&id_notice=" . $this->id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;"; } else { $this->resas_datas['href'] = "./do_resa.php?lvl=resa_planning&id_notice=" . $this->id . "&oresa=popup"; } } } } else { $this->resas_datas['flag_resa_visible'] = false; } } return $this->resas_datas; }
$tresa_date_debut[2] = '0' . $tresa_date_debut[2]; } if (strlen($tresa_date_debut[1]) == 1) { $tresa_date_debut[1] = '0' . $tresa_date_debut[1]; } $resa_date_debut = implode('', $tresa_date_debut); $tresa_date_fin = explode('-', extraitdate($resa_date_fin)); if (strlen($tresa_date_fin[2]) == 1) { $tresa_date_fin[2] = '0' . $tresa_date_fin[2]; } if (strlen($tresa_date_fin[1]) == 1) { $tresa_date_fin[1] = '0' . $tresa_date_fin[1]; } $resa_date_fin = implode('', $tresa_date_fin); if (@checkdate($tresa_date_debut[1], $tresa_date_debut[2], $tresa_date_debut[0]) && @checkdate($tresa_date_fin[1], $tresa_date_fin[2], $tresa_date_fin[0]) && strlen($resa_date_debut) == 8 && strlen($resa_date_fin) == 8 && $resa_date_debut >= $d && $resa_date_debut < $resa_date_fin) { $r = new resa_planning(); $r->resa_idempr = $_SESSION['id_empr_session']; $r->resa_idnotice = $id_notice; $r->resa_date_debut = implode('-', $tresa_date_debut); $r->resa_date_fin = implode('-', $tresa_date_fin); $r->save(); print resa_planning(FALSE); } else { print resa_planning(); } } } else { //Sinon, affichage ou suppression des résas de l'emprunteur $nb_resa_suppr = 0; if ($delete) { // *** Traitement de la suppression d'une résa planifiée
function aff_resa_expl() { global $opac_resa; global $opac_max_resa; global $opac_show_exemplaires; global $msg; global $dbh; global $popup_resa; global $opac_resa_popup; // la résa se fait-elle par popup ? global $opac_resa_planning; // la résa est elle planifiée global $allow_book; global $opac_show_exemplaires_analysis; // afin d'éviter de recalculer un truc déjà calculé... if ($this->affichage_resa_expl_flag) { return $this->affichage_resa_expl; } if (is_null($this->dom_2) && $opac_show_exemplaires && $this->visu_expl && (!$this->visu_expl_abon || $this->visu_expl_abon && $_SESSION["user_code"]) || $this->rights & 8) { if (!$opac_resa_planning) { if ($this->bulletin_id) { $resa_check = check_statut(0, $this->bulletin_id); } else { $resa_check = check_statut($this->notice_id, 0); } // vérification si exemplaire réservable if ($resa_check) { // déplacé dans le IF, si pas visible : pas de bouton résa if ($this->bulletin_id) { $requete_resa = "SELECT count(1) FROM resa WHERE resa_idbulletin='{$this->bulletin_id}' "; } else { $requete_resa = "SELECT count(1) FROM resa WHERE resa_idnotice='{$this->notice_id}' "; } $nb_resa_encours = mysql_result(mysql_query($requete_resa, $dbh), 0, 0); if ($nb_resa_encours) { $message_nbresa = str_replace("!!nbresa!!", $nb_resa_encours, $msg["resa_nb_deja_resa"]); } if (($this->notice->niveau_biblio == "m" || $this->notice->niveau_biblio == "b" || $this->notice->niveau_biblio == "a" && $opac_show_exemplaires_analysis) && ($_SESSION["user_code"] && $allow_book) && $opac_resa && !$popup_resa) { $ret .= "<h3>" . $msg["bulletin_display_resa"] . "</h3>"; if ($opac_max_resa == 0 || $opac_max_resa > $nb_resa_encours) { if ($opac_resa_popup) { $ret .= "<a href='#' onClick=\"if(confirm('" . $msg["confirm_resa"] . "')){w=window.open('./do_resa.php?lvl=resa&id_notice=" . $this->notice_id . "&id_bulletin=" . $this->bulletin_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;}else return false;\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } else { $ret .= "<a href='./do_resa.php?lvl=resa&id_notice=" . $this->notice_id . "&id_bulletin=" . $this->bulletin_id . "&oresa=popup' onClick=\"return confirm('" . $msg["confirm_resa"] . "')\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } $ret .= $message_nbresa; } else { $ret .= str_replace("!!nb_max_resa!!", $opac_max_resa, $msg["resa_nb_max_resa"]); } $ret .= "<br />"; } elseif (($this->notice->niveau_biblio == "m" || $this->notice->niveau_biblio == "b" || $this->notice->niveau_biblio == "a" && $opac_show_exemplaires_analysis) && !$_SESSION["user_code"] && $opac_resa && !$popup_resa) { // utilisateur pas connecté // préparation lien réservation sans être connecté $ret .= "<h3>" . $msg["bulletin_display_resa"] . "</h3>"; if ($opac_resa_popup) { $ret .= "<a href='#' onClick=\"if(confirm('" . $msg["confirm_resa"] . "')){w=window.open('./do_resa.php?lvl=resa&id_notice=" . $this->notice_id . "&id_bulletin=" . $this->bulletin_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;}else return false;\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } else { $ret .= "<a href='./do_resa.php?lvl=resa&id_notice=" . $this->notice_id . "&id_bulletin=" . $this->bulletin_id . "&oresa=popup' onClick=\"return confirm('" . $msg["confirm_resa"] . "')\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } $ret .= $message_nbresa; $ret .= "<br />"; } } // fin if resa_check $temp = $this->expl_list($this->notice->niveau_biblio, $this->notice->notice_id, $this->bulletin_id); $ret .= $temp; $this->affichage_expl = $temp; } else { // planning de réservations $nb_resa_encours = resa_planning::countResa($this->notice_id); if ($nb_resa_encours) { $message_nbresa = str_replace("!!nbresa!!", $nb_resa_encours, $msg["resa_nb_deja_resa"]); } if ($this->notice->niveau_biblio == "m" && ($_SESSION["user_code"] && $allow_book) && $opac_resa && !$popup_resa) { $ret .= "<h3>" . $msg["bulletin_display_resa"] . "</h3>"; if ($opac_max_resa == 0 || $opac_max_resa > $nb_resa_encours) { if ($opac_resa_popup) { $ret .= "<a href='#' onClick=\"w=window.open('./do_resa.php?lvl=resa_planning&id_notice=" . $this->notice_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } else { $ret .= "<a href='./do_resa.php?lvl=resa_planning&id_notice=" . $this->notice_id . "&oresa=popup' id='bt_resa'>" . $msg["bulletin_display_place_resa"] . "</a>"; } $ret .= $message_nbresa; } else { $ret .= str_replace("!!nb_max_resa!!", $opac_max_resa, $msg["resa_nb_max_resa"]); } $ret .= "<br />"; } elseif ($this->notice->niveau_biblio == "m" && !$_SESSION["user_code"] && $opac_resa && !$popup_resa) { // utilisateur pas connecté // préparation lien réservation sans être connecté $ret .= "<h3>" . $msg["bulletin_display_resa"] . "</h3>"; if ($opac_resa_popup) { $ret .= "<a href='#' onClick=\"w=window.open('./do_resa.php?lvl=resa_planning&id_notice=" . $this->notice_id . "&oresa=popup','doresa','scrollbars=yes,width=500,height=600,menubar=0,resizable=yes'); w.focus(); return false;\" id=\"bt_resa\">" . $msg["bulletin_display_place_resa"] . "</a>"; } else { $ret .= "<a href='./do_resa.php?lvl=resa_planning&id_notice=" . $this->notice_id . "&oresa=popup' id='bt_resa'>" . $msg["bulletin_display_place_resa"] . "</a>"; } $ret .= $message_nbresa; $ret .= "<br />"; } $temp = $this->expl_list($this->notice->niveau_biblio, $this->notice->notice_id, $this->bulletin_id); $ret .= $temp; $this->affichage_expl = $temp; } } //affichage exemplaires numeriques if ($this->docnum_allowed) { $ret .= $this->aff_explnum(); } if ($autres_lectures = $this->autres_lectures($this->notice_id, $this->bulletin_id)) { $ret .= $autres_lectures; } $this->affichage_resa_expl = $ret; $this->affichage_resa_expl_flag = 1; return $ret; }