";
$msg_a_pointer .= "$form_cb_expl : ${msg[367]}
";
$msg_a_pointer .= "
" ;
break ;
}
if (verif_cb_utilise_en_pret($form_cb_expl)) {
$msg_a_pointer = "
";
$msg_a_pointer .= "$form_cb_expl : ${msg[387]}
";
$msg_a_pointer .= "
" ;
break ;
}
if (verif_cb_utilise ($form_cb_expl)) {
$msg_a_pointer = "
";
$msg_a_pointer .= "$form_cb_expl: ".$msg["resa_doc_utilise"]."
";
$msg_a_pointer .= "
" ;
break ;
}
if (!reservation::verif_cb_resa_flag ($form_cb_expl)) {
$msg_a_pointer = "
";
$msg_a_pointer .= "$form_cb_expl: ".$msg["resa_statut_non_pretable"]."
";
$msg_a_pointer .= "
" ;
break ;
}
$id_resa_validee = affecte_cb ($form_cb_expl) ;
if ($id_resa_validee!=0) {
if ($pmb_transferts_actif=="1") {
//generation d'un transfert si nécéssaire
$res_transfert = resa_transfert($id_resa_validee,$form_cb_expl);
if ($res_transfert!=0) {
$rqt = "SELECT location_libelle FROM docs_location WHERE idlocation=".$res_transfert;
$lib_loc = pmb_mysql_result(pmb_mysql_query($rqt),0);
//desaffecte_cb($form_cb_expl,$id_resa_validee);
$msg_a_pointer = "
";
$msg_a_pointer .= "".$form_cb_expl.": ".str_replace("!!site_dest!!",$lib_loc,$msg["transferts_circ_resa_validation_alerte"])."
";
$msg_a_pointer .= "
" ;
} else{
//sinon on alerte l'emprunteur
alert_empr_resa($id_resa_validee) ;
$requete="SELECT empr_cb, empr_nom, empr_prenom, location_libelle FROM resa JOIN empr ON resa_idempr=id_empr JOIN docs_location ON resa_loc_retrait=idlocation WHERE id_resa=".$id_resa_validee."";
$res=pmb_mysql_query($requete);
$msg_a_pointer = "";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(pmb_mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(pmb_mysql_result($res,0,2),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["376"]." : ".htmlentities($form_cb_expl,ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["circ_retour_loc_retrait"]." : ".htmlentities(pmb_mysql_result($res,0,3),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
" ;
}
}else{
//sinon on alerte l'emprunteur
alert_empr_resa($id_resa_validee) ;
$requete="SELECT empr_cb, empr_nom, empr_prenom, location_libelle FROM resa JOIN empr ON resa_idempr=id_empr JOIN docs_location ON resa_loc_retrait=idlocation WHERE id_resa=".$id_resa_validee."";
$res=pmb_mysql_query($requete);
$msg_a_pointer = "";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(pmb_mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(pmb_mysql_result($res,0,2),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["376"]." : ".htmlentities($form_cb_expl,ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["circ_retour_loc_retrait"]." : ".htmlentities(pmb_mysql_result($res,0,3),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
" ;
}
} else { //if ($id_resa_validee)
$msg_a_pointer = "
";
$msg_a_pointer .= "$form_cb_expl: ".$msg["resa_doc_no_resa"]."
";
$msg_a_pointer .= "
" ;
break ;
}
} else {
/*
//c'est pour un transfert
$rqt = "SELECT id_resa ".
"FROM resa, exemplaires ".
"WHERE expl_notice= resa_idnotice ".
"AND expl_bulletin=resa_idbulletin ".
"AND expl_cb='" . $cb_trans . "' ".
"AND resa_cb='' ".
"AND resa_date_fin='0000-00-00' ";
print $rqt;
$res = pmb_mysql_query($rqt);
if (pmb_mysql_num_rows($res)) {
$id_resa = pmb_mysql_result($res,0);*/
/*
si la loc de l'exemplaire sélectionné est identique à la loc du retrait => pas de transfert
sinon on génère le transfert entre la loc de l'exemplaire et celle du retrait
*/
$loc_destination=resa_transfert($transfert_id_resa,$cb_trans);
if($loc_destination){
$rqt = "SELECT location_libelle FROM docs_location WHERE idlocation=".$loc_destination;
$lib_loc = pmb_mysql_result(pmb_mysql_query($rqt),0);
$msg_a_pointer= "
";
$msg_a_pointer.="" . $cb_trans . ": " . str_replace("!!site_dest!!", $lib_loc, $msg["transferts_circ_resa_validation_alerte"]) . "
";
$msg_a_pointer.="
";
} else {
$msg_a_pointer= "
";
$msg_a_pointer.="". str_replace("!!cb_trans!!", $cb_trans, $msg["transferts_resa_refus"]) . "
";
$msg_a_pointer.="
";
}
$ancre=$transfert_id_resa;
/*
$trans = new transfert();
$trans->transfert_pour_resa($cb_trans, $deflt_docs_location, $transfert_id_resa);
$rqt = "SELECT location_libelle FROM docs_location WHERE idlocation=".$deflt_docs_location;
$lib_loc = pmb_mysql_result(pmb_mysql_query($rqt),0);
//desaffecte_cb($form_cb_expl,$id_resa_validee);
$msg_a_pointer = "
";
$msg_a_pointer .= "" . $cb_trans . ": " . str_replace("!!site_dest!!", $lib_loc, $msg["transferts_circ_resa_validation_alerte"]) . "
";
$msg_a_pointer .= "
" ;
*/
//} //if (pmb_mysql_num_rows($res))
} // if ($form_cb_expl) else
} //if ($sub == 'encours')
break;
case 'suppr_resa':
// récupérer les items
$nb_suppr_id_resa = count($suppr_id_resa);
for ($i = 0; $i < $nb_suppr_id_resa; $i++) {
// récup éventuelle du cb
$cb_recup = reservation::get_cb_from_id($suppr_id_resa[$i]);
if (!empty($pmb_transferts_actif)) {
// on cloture que si etat_demande =0, le livre est en rayon, pas validé... https://mypmb.sigb.net/issues/3370
/*
// si transferts validé (en attente d'envoi), il faut restaurer le statut
$rqt = "SELECT id_transfert FROM transferts,transferts_demande
where
num_transfert=id_transfert and
etat_demande=0 and resa_trans='".$suppr_id_resa[$i]."' and etat_transfert=0";
$res = pmb_mysql_query( $rqt );
if (pmb_mysql_num_rows($res)){
$obj = pmb_mysql_fetch_object($res);
$idTrans=$obj->id_transfert;
//Récupération des informations d'origine
$rqt = "SELECT statut_origine, num_expl FROM transferts INNER JOIN transferts_demande ON id_transfert=num_transfert
WHERE id_transfert=".$idTrans." AND sens_transfert=0";
$res = pmb_mysql_query($rqt);
$obj_data = pmb_mysql_fetch_object($res);
//on met à jour
$rqt = "UPDATE exemplaires SET expl_statut=".$obj_data->statut_origine." WHERE expl_id=".$obj_data->num_expl;
pmb_mysql_query( $rqt );
}
*/
// si demande de transfert on cloture
$req=" select expl_location, expl_cb from transferts,transferts_demande, exemplaires
where
num_transfert=id_transfert and etat_demande=0 and num_expl=expl_id and
resa_trans='".$suppr_id_resa[$i]."' ";
$res = pmb_mysql_query( $req );
if (pmb_mysql_num_rows($res)){
$obj = pmb_mysql_fetch_object($res);
// dans à traité pour effectuer le transfert
$sql = "UPDATE exemplaires set expl_retloc='".$obj->expl_location."' where expl_cb='".$obj->expl_cb."' limit 1";
pmb_mysql_query($sql);
}
$req=" update transferts,transferts_demande
set etat_transfert=1,
motif=CONCAT(motif,'. Cloture, car reservation supprimee (gestion $PMBuserid)')
where
num_transfert=id_transfert and etat_demande=0 and
resa_trans='".$suppr_id_resa[$i]."'
";
pmb_mysql_query($req);
}
// archivage resa
$rqt_arch = "UPDATE resa_archive, resa SET resarc_anulee = 1 WHERE id_resa = '".$suppr_id_resa[$i]."' AND resa_arc = resarc_id ";
pmb_mysql_query($rqt_arch);
// suppression
$rqt = "delete from resa where id_resa='".$suppr_id_resa[$i]."' ";
$res = pmb_mysql_query($rqt) ;
// réaffectation du doc éventuellement
if($cb_recup){
if (!verif_cb_utilise ($cb_recup)) {
if (!($id_resa_validee=affecte_cb ($cb_recup))) {
$pas_ranger = 0;
if($pmb_transferts_actif){
$rqt = "SELECT id_transfert, sens_transfert, num_location_source, num_location_dest
FROM transferts, transferts_demande, exemplaires
WHERE id_transfert=num_transfert and num_expl=expl_id and expl_cb='".$cb_recup."' AND etat_transfert=0" ;
$res = pmb_mysql_query( $rqt );
if (pmb_mysql_num_rows($res)){
// Document à traiter au lieu de à ranger, car transfert en cours?
$sql = "UPDATE exemplaires set expl_retloc=expl_location where expl_cb='".$cb_recup."' limit 1";
pmb_mysql_query($sql);
$pas_ranger=1;
$msg_a_pointer .= "";
$msg_a_pointer .="
".$msg["circ_pret_piege_expl_todo"]."
";
}
}
if(!$pas_ranger){
//on vérifie que l'exemplaire existe toujours...
$rqt = "SELECT expl_id FROM exemplaires WHERE expl_cb='".$cb_recup."' ";
$res = pmb_mysql_query ($rqt) ;
if(pmb_mysql_num_rows($res)){
// 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) ;
}
}
} else {
alert_empr_resa($id_resa_validee) ;
$requete="SELECT empr_cb, empr_nom, empr_prenom, location_libelle FROM resa JOIN empr ON resa_idempr=id_empr JOIN docs_location ON resa_loc_retrait=idlocation WHERE id_resa=".$id_resa_validee."";
$res=pmb_mysql_query($requete);
$msg_a_pointer .= "
";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(pmb_mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(pmb_mysql_result($res,0,2),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["376"]." : ".htmlentities($form_cb_expl,ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
".$msg["circ_retour_loc_retrait"]." : ".htmlentities(pmb_mysql_result($res,0,3),ENT_QUOTES,$charset)."";
$msg_a_pointer .= "
" ;
}
}
}
}
break;
case 'imprimer_confirmation':
// récupérer les items
if (!$suppr_id_resa) $suppr_id_resa=array() ;
$tmp_in_resa = implode(",",$suppr_id_resa) ;
if ($tmp_in_resa) {
$rqt = "select id_resa, resa_idempr, resa_confirmee from resa where id_resa in (".$tmp_in_resa.") and resa_cb is not null and resa_cb!='' order by resa_idempr ";
$res = pmb_mysql_query($rqt) ;
alert_empr_resa ($tmp_in_resa);
} else print alert_jscript($msg['no_resa_selected']);
break;
case 'suppr_cb':
if (!$form_cb_expl) break ;
$msg_a_ranger = "
";
$aff_a_ranger .= "
" ;
// récupérer l'exemplaire
$query = "select expl_id from exemplaires where expl_cb='$form_cb_expl'";
$result = pmb_mysql_query($query);
if(!pmb_mysql_num_rows($result)) {
// exemplaire inconnu
$aff_a_ranger .= "$form_cb_expl : ${msg[367]}
";
} else {
$expl_lu = pmb_mysql_fetch_object($result) ;
if($stuff = get_expl_info($expl_lu->expl_id)) {
$stuff = check_pret($stuff);
$aff_a_ranger .= print_info($stuff,1,0,0)."
";
} else {
$aff_a_ranger .= "$form_cb_expl : ${msg[395]}
";
}
}
$rqt = "delete from resa_ranger where resa_cb='".$form_cb_expl."' ";
$res = pmb_mysql_query($rqt) ;
if (pmb_mysql_affected_rows()) $msg_a_ranger .= $msg['resa_docrange'] ;
else $msg_a_ranger .= $msg['resa_docrange_non'] ;
$msg_a_ranger = str_replace('!!cb!!', $form_cb_expl, $msg_a_ranger );
$msg_a_ranger .= "" ;
break;
default:
$evth = events_handler::get_instance();
$evt = new event_list_ui("listeresa", $action);
$evt->set_resa_id($suppr_id_resa);
$evth->send($evt);
break;
}
switch($sub) {
case 'docranger':
echo window_title($database_window_title.$msg["5"]." : ".$msg["resa_menu"]." ".$msg["resa_menu_liste_docranger"]);
print "
$msg[resa_menu] > ".$msg["resa_menu_liste_".$sub]."
" ;
get_cb_expl("", $msg[661], $msg['resa_suppr_doc'], "./circ.php?categ=listeresa&sub=$sub&action=suppr_cb");
print $msg_a_ranger.$aff_a_ranger ;
print "
".$msg['resa_liste_docranger']."
" ;
print pmb_bidi(resa_ranger_list ()) ;
break;
case 'depassee':
echo window_title($database_window_title.$msg["5"]." : ".$msg["resa_menu"]." ".$msg["resa_menu_liste_depassee"]);
$list_reservations_circ_outdated_ui = new list_reservations_circ_outdated_ui(array('id_notice' => 0, 'id_bulletin' => 0, 'id_empr' => 0, 'resa_state' => 'depassee'));
print $list_reservations_circ_outdated_ui->get_display_list();
break;
case 'suppr_resa_from_fiche':
break;
default:
case 'encours':
echo window_title($database_window_title.$msg["5"]." : ".$msg["resa_menu"]." ".$msg["resa_menu_liste_encours"]);
print "
$msg[resa_menu] > ".$msg["resa_menu_liste_".$sub]."
" ;
list_reservations_circ_ui::set_globals_from_selected_filters();
if(!isset($f_loc) || $f_loc=="") {
if ($pmb_lecteurs_localises){
$f_loc = $deflt_resas_location;
} else {
$f_loc = 0;
}
}
get_cb_expl("", $msg[661], $msg['resa_pointage_doc'], "./circ.php?categ=listeresa&sub=$sub&action=valide_cb&f_loc=$f_loc");
//un message à afficher
print $msg_a_pointer ;
//on affiche la liste
echo $resa_liste_jscript_GESTION_INFO_GESTION;
$list_reservations_circ_ui = new list_reservations_circ_ui(array('id_notice' => 0, 'id_bulletin' => 0, 'id_empr' => 0, 'resa_state' => 'encours', 'f_loc' => $f_loc));
$list_reservations_circ_ui->set_ancre($ancre);
print $list_reservations_circ_ui->get_display_list();
break;
}