";
//Champs personalisés
$p_perso=new parametres_perso("expl");
$perso_aff = "" ;
if (!$p_perso->no_special_fields) {
$perso_=$p_perso->show_fields($stuff->expl_id);
for ($i=0; $i".$perso_aff."" ;
$script_magnetique="
";
if($stuff->type_antivol ==2)//c'est un support magnétique (cassette)
print "$script_magnetique"."magnetise('SSS');";
}
//si le retour se passe sur un site différent de ce lui de l'exemplaire
global $pmb_transferts_actif;
$transfert_mauvais_site = false;
if ($stuff->expl_location != $deflt_docs_location) {
$alert_sound_list[]="critique";
$html_erreur_site = "
";
//on agit pour faire l'action par defaut
//et que c'est un retour d'emprunt
if (($pmb_transferts_actif)&&($stuff->pret_idempr)) {
global $transferts_retour_action_defaut;
global $transferts_retour_action_autorise_autre;
$trans = new transfert();
//pour afficher le site de l'exemplaire
$rqtSite = "SELECT location_libelle FROM docs_location WHERE idlocation=".$stuff->expl_location;
$resSite = mysql_result(mysql_query($rqtSite),0);
//si on propose une autre action
if ($transferts_retour_action_autorise_autre=="1") {
$texte_change_loc = str_replace("!!lbl_site!!", $resSite,$msg["transferts_circ_retour_lbl_change_localisation"]);
}
$texte_change_loc = str_replace("!!liste_sections!!","", $texte_change_loc);
//on genere la liste des sections
$rqt = "SELECT idsection, section_libelle FROM docs_section ORDER BY section_libelle";
$res_section = mysql_query($rqt);
$liste_section = "";
while($value = mysql_fetch_object($res_section)) {
$liste_section .= "";
}
$texte_change_loc = addslashes(str_replace("!!liste!!", $liste_section, $texte_change_loc));
$html_erreur_site .= "
";
$html_erreur_site = str_replace("!!lbl_site!!", $resSite, $html_erreur_site);
$html_erreur_site = str_replace("!!liste_sections!!", $expl_section_libelle, $html_erreur_site);
$transfert_mauvais_site = true;
} else { //if (($pmb_transferts_actif)&&($stuff->pret_idempr))
//le message à l'écran
$html_erreur_site .= $msg[expl_retour_bad_location];
}
$html_erreur_site .= "
";
print pmb_bidi($html_erreur_site);
// fin de if ($stuff->expl_location != $deflt_docs_location)
}
if ($stuff->expl_note) {
$alert_sound_list[]="critique";
print pmb_bidi("
${msg[377]} :
".$stuff->expl_note."
");
} elseif($pmb_play_pret_sound) $alert_sound_list[]="information";
// zone du dernier emrunteur
if ($stuff->expl_lastempr) {
$dernier_empr = "
";
}
if ($stuff->pret_idempr) {
// l'exemplaire était effectivement emprunté
// calcul du retard éventuel
$rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('$stuff->pret_retour'))) as retard ";
$resultatdate=mysql_query($rqt_date);
$resdate=mysql_fetch_object($resultatdate);
$retard = $resdate->retard;
if($retard > 0) {
//Calcul du vrai nombre de jours
$date_debut=explode("-",$stuff->pret_retour);
$ndays=calendar::get_open_days($date_debut[2],$date_debut[1],$date_debut[0],date("d"),date("m"),date("Y"));
if ($ndays>0) {
$retard = (int)$ndays;
print "
".$msg[369]." : ".$retard." ".$msg[370]."
";
$alert_sound_list[]="critique";
}
}
//Calcul du blocage
if ($pmb_blocage_retard) {
$date_debut=explode("-",$stuff->pret_retour);
$ndays=calendar::get_open_days($date_debut[2],$date_debut[1],$date_debut[0],date("d"),date("m"),date("Y"));
if ($ndays>$pmb_blocage_delai) {
$ndays=$ndays*$pmb_blocage_coef;
if (($ndays>$pmb_blocage_max)&&($pmb_blocage_max!=0)) {
$ndays=$pmb_blocage_max;
}
} else $ndays=0;
if ($ndays>0) {
//Le lecteur est-il déjà bloqué ?
$date_fin_blocage_empr = mysql_result(mysql_query("select date_fin_blocage from empr where id_empr='".$stuff->pret_idempr."'"),0,0);
//Calcul de la date de fin
$date_fin=calendar::add_days(date("d"),date("m"),date("Y"),$ndays);
if ($date_fin > $date_fin_blocage_empr) {
//Mise à jour
mysql_query("update empr set date_fin_blocage='".$date_fin."' where id_empr='".$stuff->pret_idempr."'");
print "
";
$alertsound_list[]="critique";
}
}
}
//Vérification des amendes
if (($pmb_gestion_financiere) && ($pmb_gestion_amende)) {
$amende=new amende($stuff->pret_idempr);
$amende_t=$amende->get_amende($stuff->pret_idexpl);
//Si il y a une amende, je la débite
if ($amende_t["valeur"]) {
print pmb_bidi("
";
}
}
// zone du dernier emrunteur
print pmb_bidi($dernier_empr) ;
// code de suppression prêt et la mise en table de stat
if ($confirmed){
if (del_pret($stuff)) {
if (!maj_stat_pret($stuff)) {
// impossible de maj en table stat
print "
${msg[371]}
";
}
} else {
// impossible de supprimer en table pret
print "
${msg[372]}
";
}
// traitement de l'éventuelle réservation
if ($stuff->resa_idempr) {
// le doc en retour peut servir à valider une résa suivante
if (!verif_cb_utilise ($stuff->expl_cb) || $affect) {
if(!$affect)$affect = affecte_cb ($stuff->expl_cb) ;
// affichage message de réservation
if ($affect) {
$trans_en_cours = false;
$msg_trans = "";
if (($pmb_transferts_actif=="1")&&(!$transfert_mauvais_site)) {
//si le transfert est actif et qu'un transfert n'est pas deja fait
$res_transfert = resa_transfert($affect,$stuff->expl_cb);
if ($res_transfert!=0) {
$rqt = "SELECT location_libelle FROM docs_location WHERE idlocation=".$res_transfert;
$lib_loc = mysql_result(mysql_query($rqt),0);
$msg_trans = "".str_replace("!!site_dest!!",$lib_loc,$msg["transferts_circ_resa_validation_alerte"])." ";
$trans_en_cours = true;
}
}
$query = "select distinct ";
$query .= "empr_prenom, empr_nom, empr_cb ";
$query .= "from (((resa LEFT JOIN notices AS notices_m ON resa_idnotice = notices_m.notice_id ) LEFT JOIN bulletins ON resa_idbulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), empr ";
$query .= "where id_resa in (".$affect.") and resa_idempr=id_empr";
$result = mysql_query($query, $dbh);
$empr=@mysql_fetch_object($result);
print pmb_bidi("
");
$alert_sound_list[]="critique" ;
if (!$trans_en_cours)
alert_empr_resa($affect) ;
} // fin if affect
} // fin if !verif_cb_utilise
} // fin if resa
}// fin confirmed
$empr = new emprunteur($stuff->pret_idempr, $erreur_affichage, FALSE, 2);
print pmb_bidi($empr -> fiche_affichage);
} else {
print "
${msg[605]}
";
$alert_sound_list[]="critique";
}
// show_report($stuff); // this stands for debugging
}
// mise en table stat des infos du prêt
function stat_stuff ($stuff) {
global $dbh, $empr_archivage_prets, $empr_archivage_prets_purge;
if(!is_object($stuff)) die ("Pb in ./circ/pret_func.inc.php [stat_stuff()].");
$query = "insert into pret_archive set ";
$query .= "arc_debut='".$stuff->pret_date."', ";
$query .= "arc_fin='".$stuff->pret_retour."', ";
if ($empr_archivage_prets) $query .= "arc_id_empr='".addslashes($stuff->id_empr) ."', ";
$query .= "arc_empr_cp='". addslashes($stuff->empr_cp) ."', ";
$query .= "arc_empr_ville='". addslashes($stuff->empr_ville) ."', ";
$query .= "arc_empr_prof='". addslashes($stuff->empr_prof) ."', ";
$query .= "arc_empr_year='". addslashes($stuff->empr_year) ."', ";
$query .= "arc_empr_categ='". $stuff->empr_categ ."', ";
$query .= "arc_empr_codestat='". $stuff->empr_codestat ."', ";
$query .= "arc_empr_sexe='". $stuff->empr_sexe ."', ";
$query .= "arc_empr_statut='". $stuff->empr_statut ."', ";
$query .= "arc_empr_location='". $stuff->empr_location ."', ";
$query .= "arc_type_abt='". $stuff->type_abt ."', ";
$query .= "arc_expl_typdoc='". $stuff->expl_typdoc ."', ";
$query .= "arc_expl_id='". $stuff->expl_id ."', ";
$query .= "arc_expl_notice='". $stuff->expl_notice ."', ";
$query .= "arc_expl_bulletin='". $stuff->expl_bulletin ."', ";
$query .= "arc_expl_cote='". addslashes($stuff->expl_cote) ."', ";
$query .= "arc_expl_statut='". $stuff->expl_statut ."', ";
$query .= "arc_expl_location='". $stuff->expl_location ."', ";
$query .= "arc_expl_section='". $stuff->expl_section ."', ";
$query .= "arc_expl_codestat='". $stuff->expl_codestat ."', ";
$query .= "arc_expl_owner='". $stuff->expl_owner ."', ";
$query .= "arc_groupe='". addslashes($stuff->groupes)."', ";
$query .= "arc_niveau_relance='". $stuff->niveau_relance ."', ";
$query .= "arc_date_relance='". $stuff->date_relance ."', ";
$query .= "arc_printed='". $stuff->printed ."', ";
$query .= "arc_cpt_prolongation='". $stuff->cpt_prolongation ."', ";
$query .= "arc_short_loan_flag='". $stuff->short_loan_flag ."' ";
$res = mysql_query($query, $dbh);
$id_arc_insere = mysql_insert_id() ;
// purge des vieux trucs
if ($empr_archivage_prets_purge) {
//on ne purge qu'une fois par session et par jour
if (!isset($_SESSION["last_empr_archivage_prets_purge_day"]) || ($_SESSION["last_empr_archivage_prets_purge_day"] != date("m.d.y"))) {
mysql_query("update pret_archive set arc_id_empr=0 where arc_id_empr!=0 and date_add(arc_fin, interval $empr_archivage_prets_purge day) < sysdate()") or die(mysql_error()." "."update pret_archive set arc_id_empr=0 where arc_id_empr!=0 and date_add(arc_fin, interval $empr_archivage_prets_purge day) < sysdate()");
$_SESSION["last_empr_archivage_prets_purge_day"] = date("m.d.y");
}
}
return $id_arc_insere ;
}
// mise à jour des stat des infos du prêt
function maj_stat_pret ($stuff) {
global $dbh, $empr_archivage_prets, $empr_archivage_prets_purge;
if(!is_object($stuff)) die ("Pb in ./circ/pret_func.inc.php [maj_stat_pret()].");
$query = "update pret_archive set ";
$query .= "arc_debut='".$stuff->pret_date."', ";
$query .= "arc_fin=now(), ";
if ($empr_archivage_prets) $query .= "arc_id_empr='".addslashes($stuff->id_empr)."', ";
$query .= "arc_empr_cp='". addslashes($stuff->empr_cp) ."', ";
$query .= "arc_empr_ville='". addslashes($stuff->empr_ville) ."', ";
$query .= "arc_empr_prof='". addslashes($stuff->empr_prof) ."', ";
$query .= "arc_empr_year='". addslashes($stuff->empr_year) ."', ";
$query .= "arc_empr_categ='". $stuff->empr_categ ."', ";
$query .= "arc_empr_codestat='". $stuff->empr_codestat ."', ";
$query .= "arc_empr_sexe='". $stuff->empr_sexe ."', ";
$query .= "arc_empr_statut='". $stuff->empr_statut ."', ";
$query .= "arc_empr_location='". $stuff->empr_location ."', ";
$query .= "arc_type_abt='". $stuff->type_abt ."', ";
$query .= "arc_expl_typdoc='". $stuff->expl_typdoc ."', ";
$query .= "arc_expl_id='". $stuff->expl_id ."', ";
$query .= "arc_expl_notice='". $stuff->expl_notice ."', ";
$query .= "arc_expl_bulletin='". $stuff->expl_bulletin ."', ";
$query .= "arc_expl_cote='". addslashes($stuff->expl_cote) ."', ";
$query .= "arc_expl_statut='". $stuff->expl_statut ."', ";
$query .= "arc_expl_location='". $stuff->expl_location ."', ";
$query .= "arc_expl_section='". $stuff->expl_section ."', ";
$query .= "arc_expl_codestat='". $stuff->expl_codestat ."', ";
$query .= "arc_expl_owner='". $stuff->expl_owner ."', ";
$query .= "arc_niveau_relance='". $stuff->niveau_relance ."', ";
$query .= "arc_date_relance='". $stuff->date_relance ."', ";
$query .= "arc_printed='". $stuff->printed ."', ";
$query .= "arc_cpt_prolongation='". $stuff->cpt_prolongation ."', ";
$query .= "arc_short_loan_flag='". $stuff->short_loan_flag ."' ";
$query .= " where arc_id='".$stuff->pret_arc_id."' ";
$res = mysql_query($query, $dbh);
audit::insert_modif (AUDIT_PRET, $stuff->pret_arc_id) ;
// purge des vieux trucs
if ($empr_archivage_prets_purge) {
//on ne purge qu'une fois par session et par jour
if (!isset($_SESSION["last_empr_archivage_prets_purge_day"]) || ($_SESSION["last_empr_archivage_prets_purge_day"] != date("m.d.y"))) {
mysql_query("update pret_archive set arc_id_empr=0 where arc_id_empr!=0 and date_add(arc_fin, interval $empr_archivage_prets_purge day) < sysdate()") or die(mysql_error()." "."update pret_archive set arc_id_empr=0 where arc_id_empr!=0 and date_add(arc_fin, interval $empr_archivage_prets_purge day) < sysdate()");
$_SESSION["last_empr_archivage_prets_purge_day"] = date("m.d.y");
}
}
return $res ;
}
// suppression du prêt (table prêt)
function del_pret($stuff) {
global $dbh;
//return 1 ; // debug mode ;-)
if(!is_object($stuff))
die("serious application error occured in ./circ/retour.inc [del_pret()]. Please contact developpment team");
$query = "delete from pret where pret_idexpl=".$stuff->expl_id;
if (!mysql_query($query, $dbh)) return 0 ;
$query = "update empr set last_loan_date=sysdate() where id_empr='".$stuff->pret_idempr."' ";
@mysql_query($query, $dbh);
$query = "update exemplaires set expl_lastempr='".$stuff->pret_idempr."', last_loan_date=sysdate() where expl_id='".$stuff->expl_id."' ";
if (!mysql_query($query, $dbh)) return 0 ;
else return 1 ;
}
// teste l'existence de l'exemplaire et le cas échéant,
// retourne les infos exemplaire sous forme d'objet
function check_barcode($cb) {
global $dbh;
$expl->expl_cb = $cb ;
$query = "select * from exemplaires where expl_cb='$cb' ";
$result = mysql_query($query, $dbh);
$expl = mysql_fetch_object($result);
if(!$expl->expl_id) {
// exemplaire inconnu
return FALSE;
} else {
// récupération des infos exemplaires
if ($expl->expl_notice) {
$notice = new mono_display($expl->expl_notice, 0);
$expl->libelle = $notice->header;
} else {
$bulletin = new bulletinage_display($expl->expl_bulletin);
$expl->libelle = $bulletin->display ;
}
if ($expl->expl_lastempr) {
// récupération des infos emprunteur
$query_last_empr = "select empr_cb, empr_nom, empr_prenom from empr where id_empr='".$expl->expl_lastempr."' ";
$result_last_empr = mysql_query($query_last_empr, $dbh);
if(mysql_num_rows($result_last_empr)) {
$last_empr = mysql_fetch_object($result_last_empr);
$expl->lastempr_cb = $last_empr->empr_cb;
$expl->lastempr_nom = $last_empr->empr_nom;
$expl->lastempr_prenom = $last_empr->empr_prenom;
}
}
}
return $expl;
}
function pret_construit_infos_stat ($id_expl) {
global $dbh;
$query = "select * from exemplaires where expl_id='$id_expl' ";
$result = mysql_query($query, $dbh);
$stuff = mysql_fetch_object($result);
if(!$stuff->expl_id) {
// exemplaire inconnu
return FALSE;
}
$stuff = check_pret($stuff);
$stuff = check_resa($stuff);
return $stuff ;
}
function insert_in_stat($stuf) {
}
// envoi d'un mail de ticket de prêt
// reçoit : id_empr et éventuellement cb_doc
function electronic_ticket($id_empr, $cb_doc="") {
global $dbh, $msg, $charset ;
global $PMBusernom;
global $PMBuserprenom;
global $PMBuseremail,$PMBuseremailbcc;
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=".$charset."\n";
// info site
global $biblio_name, $biblio_logo, $biblio_adr1, $biblio_adr2, $biblio_cp, $biblio_town, $biblio_state, $biblio_country, $biblio_phone, $biblio_email, $biblio_website, $biblio_commentaire ;
global $empr_electronic_loan_ticket_obj, $empr_electronic_loan_ticket_msg ;
$empr_electronic_loan_ticket_obj = str_replace("!!biblio_name!!", $biblio_name, $empr_electronic_loan_ticket_obj) ;
$empr_electronic_loan_ticket_obj = str_replace("!!date!!", formatdate(today()), $empr_electronic_loan_ticket_obj) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_name!!", $biblio_name, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!date!!", formatdate(today()), $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_website!!", $biblio_website, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_phone!!", $biblio_phone, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_adr1!!", $biblio_adr1, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_adr2!!", $biblio_adr2, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_cp!!", $biblio_cp, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_town!!", $biblio_town, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_email!!", $biblio_email, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!biblio_commentaire!!", $biblio_commentaire, $empr_electronic_loan_ticket_msg) ;
$message_resas = "";
$message_prets = "";
if ($cb_doc == "") {
$rqt = "select expl_cb from pret, exemplaires where pret_idempr='".$id_empr."' and pret_idexpl=expl_id order by pret_date " ;
$req = mysql_query($rqt) or die($msg['err_sql'].' '.$rqt.' '.mysql_error());
$message_prets = $msg["prets_en_cours"];
while ($data = mysql_fetch_array($req)) {
$message_prets .= electronic_loan_ticket_expl_info ($data['expl_cb']);
}
// Impression des réservations en cours
$rqt = "select resa_idnotice, resa_idbulletin from resa where resa_idempr='".$id_empr."' " ;
$req = mysql_query($rqt) or die($msg['err_sql'].' '.$rqt.' '.mysql_error());
if (mysql_num_rows($req) > 0) {
$message_resas = $msg["documents_reserves"];
while ($data = mysql_fetch_array($req)) {
$message_resas .= electronic_loan_ticket_not_bull_info_resa ($id_empr, $data['resa_idnotice'],$data['resa_idbulletin']);
}
} // fin if résas
} else {
$message_prets = $msg["prets_en_cours"];
$message_prets .= electronic_loan_ticket_expl_info ($cb_doc);
}
$empr_electronic_loan_ticket_msg = str_replace("!!all_reservations!!", $message_resas, $empr_electronic_loan_ticket_msg) ;
$empr_electronic_loan_ticket_msg = str_replace("!!all_loans!!", $message_prets, $empr_electronic_loan_ticket_msg) ;
$requete = "select id_empr, empr_mail, empr_nom, empr_prenom from empr where id_empr='$id_empr' ";
$res = mysql_query($requete, $dbh);
$empr=mysql_fetch_object($res);
//remplacement nom et prenom
$empr_electronic_loan_ticket_msg=str_replace("!!empr_name!!", $empr->empr_nom,$empr_electronic_loan_ticket_msg);
$empr_electronic_loan_ticket_msg=str_replace("!!empr_first_name!!", $empr->empr_prenom,$empr_electronic_loan_ticket_msg);
if ($empr->empr_mail) {
// function mailpmb($to_nom="", $to_mail, $obj="", $corps="", $from_name="", $from_mail, $headers, $copie_CC="", $copie_BCC="", $faire_nl2br=0, $pieces_jointes=array()) {
$res_envoi=@mailpmb($empr->empr_prenom." ".$empr->empr_nom, $empr->empr_mail,$empr_electronic_loan_ticket_obj,$empr_electronic_loan_ticket_msg, $PMBuserprenom." ".$PMBusernom, $PMBuseremail, $headers, "", $PMBuseremailbcc, 1, "");
}
}
function electronic_loan_ticket_expl_info($cb_doc) {
global $msg, $dbh ;
$requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, expl_cb, expl_cote, pret_date, pret_retour, tdoc_libelle, section_libelle, location_libelle, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, ";
$requete.= " date_format(pret_date, '".$msg["format_date"]."') as aff_pret_date, ";
$requete.= " date_format(pret_retour, '".$msg["format_date"]."') as aff_pret_retour, ";
$requete.= " IF(pret_retour>sysdate(),0,1) as retard, notices_m.tparent_id, notices_m.tnvol " ;
$requete.= " FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), docs_type, docs_section, docs_location, pret ";
$requete.= " WHERE expl_cb='".addslashes($cb_doc)."' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id ";
$res = mysql_query($requete, $dbh) or die (" ".mysql_error());
$expl = mysql_fetch_object($res);
$responsabilites = get_notice_authors(($expl->m_id+$expl->s_id)) ;
$as = array_search ("0", $responsabilites["responsabilites"]) ;
if ($as!== FALSE && $as!== NULL) {
$auteur_0 = $responsabilites["auteurs"][$as] ;
$auteur = new auteur($auteur_0["id"]);
$header_aut .= $auteur->isbd_entry;
} else {
$aut1_libelle=array();
$as = array_keys ($responsabilites["responsabilites"], "1" ) ;
for ($i = 0 ; $i < count($as) ; $i++) {
$indice = $as[$i] ;
$auteur_1 = $responsabilites["auteurs"][$indice] ;
$auteur = new auteur($auteur_1["id"]);
$aut1_libelle[]= $auteur->isbd_entry;
}
$header_aut .= implode (", ",$aut1_libelle) ;
}
$header_aut ? $auteur=" / ".$header_aut : $auteur="";
// récupération du titre de série
if ($expl->tparent_id && $expl->m_id) {
$parent = new serie($expl->tparent_id);
$tit_serie = $parent->name;
if($expl->tnvol)
$tit_serie .= ', '.$expl->tnvol;
}
if($tit_serie) {
$expl->tit = $tit_serie.'. '.$expl->tit;
}
$ret = "