";
$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 (!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 = mysql_result(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=mysql_query($requete);
$msg_a_pointer = "";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(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(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=mysql_query($requete);
$msg_a_pointer = "";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(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(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_location"]."
";
$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 = mysql_query($rqt);
if (mysql_num_rows($res)) {
$id_resa = 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 = mysql_result(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 = mysql_result(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 (mysql_num_rows($res))
} // if ($form_cb_expl) else
} //if ($sub == 'encours')
break;
case 'suppr_resa':
// récupérer les items
for ($i=0 ; $i < sizeof($suppr_id_resa) ; $i++) {
// récup éventuelle du cb
$cb_recup = recupere_cb ($suppr_id_resa[$i]) ;
if($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 = mysql_query ( $rqt );
if (mysql_num_rows($res)){
$obj = 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 = mysql_query($rqt);
$obj_data = mysql_fetch_object($res);
//on met à jour
$rqt = "UPDATE exemplaires SET expl_statut=".$obj_data->statut_origine." WHERE expl_id=".$obj_data->num_expl;
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 = mysql_query ( $req );
if (mysql_num_rows($res)){
$obj = 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";
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]."'
";
mysql_query($req, $dbh);
}
// archivage resa
$rqt_arch = "UPDATE resa_archive, resa SET resarc_anulee = 1 WHERE id_resa = '".$suppr_id_resa[$i]."' AND resa_arc = resarc_id ";
mysql_query ($rqt_arch, $dbh);
// suppression
$rqt = "delete from resa where id_resa='".$suppr_id_resa[$i]."' ";
$res = mysql_query ($rqt, $dbh) ;
// réaffectation du doc éventuellement
if($cb_recup){
if (!verif_cb_utilise ($cb_recup)) {
if (!($id_resa_validee=affecte_cb ($cb_recup))) {
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 = mysql_query ( $rqt );
if (mysql_num_rows($res)){
// Document à traiter au lieu de à ranger, car transfert en cours?
$sql = "UPDATE exemplaires set expl_retloc='".$deflt_docs_location."' where expl_cb='".$cb_recup."' limit 1";
mysql_query($sql);
$pas_ranger=1;
$msg_a_pointer .= "";
$msg_a_pointer .="
".$msg["circ_pret_piege_expl_todo"]."
";
}
}
if(!$pas_ranger){
// 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 = mysql_query ($rqt, $dbh) ;
}
} 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=mysql_query($requete);
$msg_a_pointer .= "
";
$msg_a_pointer .="
".$msg["circ_retour_ranger_resa"]."
";
$msg_a_pointer .= "
".$msg["circ_retour_resa_par"]." : ".htmlentities(mysql_result($res,0,1),ENT_QUOTES,$charset).", ".htmlentities(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(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 = mysql_query ($rqt, $dbh) ;
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 = mysql_query($query, $dbh);
if(!mysql_num_rows($result)) {
// exemplaire inconnu
$aff_a_ranger .= "$form_cb_expl : ${msg[367]}
";
} else {
$expl_lu = 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 = mysql_query ($rqt, $dbh) ;
if (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;
}
switch($sub) {
case '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", 1);
print $msg_a_ranger.$aff_a_ranger ;
print "
".$msg['resa_liste_docranger']."
" ;
print pmb_bidi(resa_ranger_list ()) ;
break;
case 'depassee':
print "
$msg[resa_menu] > ".$msg["resa_menu_liste_".$sub]."
" ;
print pmb_bidi(resa_list (0, 0, 0,"","resa_date_fin < CURDATE() and resa_date_fin<>'0000-00-00' ",1,"./circ.php?categ=listeresa&sub=$sub")) ;
break;
case 'suppr_resa_from_fiche':
break;
default:
case 'encours':
print "
$msg[resa_menu] > ".$msg["resa_menu_liste_".$sub]."
" ;
get_cb_expl("", $msg[661], $msg[resa_pointage_doc], "./circ.php?categ=listeresa&sub=$sub&action=valide_cb&f_loc=$f_loc", 1);
//un message à afficher
print $msg_a_pointer ;
//la clause de restriction
$cl_where = "(resa_date_fin >= CURDATE() or resa_date_fin='0000-00-00')";
//on affiche la liste
echo $resa_liste_jscript_GESTION_INFO_GESTION;
print pmb_bidi(resa_list (0, 0, 0,"", $cl_where,1,"./circ.php?categ=listeresa&sub=$sub",$ancre)) ;
break;
}