function get_relance($id_empr) { global $dbh, $charset, $msg, $pmb_gestion_financiere, $pmb_gestion_amende; global $pmb_lecteurs_localises; // liste des relances if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amende = new amende($id_empr); $level = $amende->get_max_level(); $niveau_min = $level["level_min"]; $id_expl = $level["level_min_id_expl"]; $total_amende = $amende->get_total_amendes(); } $niveau_suppose = $level["level_normal"]; $cpt_id = comptes::get_compte_id_from_empr($id_empr, 2); $cpt = new comptes($cpt_id); $frais_relance = $cpt->summarize_transactions("", "", 0, $realisee = -1); if ($frais_relance < 0) { $frais_relance = -$frais_relance; } else { $frais_relance = 0; } $empr = new emprunteur($id_empr, '', FALSE, 0); //Groupes if (count($empr->groupes)) { $lib_groupes = strip_tags(implode(" / ", $empr->groupes)); } else { $lib_groupes = ""; } $info_empr = "\n\t<td>" . $empr->cb . "</td>\n\t<td>" . $empr->nom . "</td>\n\t<td>" . $empr->prenom . "</td>\n\t<td>" . $empr->adr1 . "</td>\n\t<td>" . $empr->adr2 . "</td>\n\t<td>" . $empr->cp . "</td>\n\t<td>" . $empr->ville . "</td>\n\t<td>" . $empr->mail . "</td>\n\t<td>" . $empr->tel1 . "</td>\n\t<td>" . $empr->tel2 . "</td>\n\t" . ($pmb_lecteurs_localises ? "<td>" . $empr->empr_location_l . "</td>" : "") . "\n\t<td>" . $empr->cat_l . "</td>\n\t<td>" . $empr->cstat_l . "</td>\n\t<td>" . $empr->empr_statut_libelle . "</td>\n\t<td>" . $lib_groupes . "</td>\n\t<td>" . $niveau_suppose . "</td>\n\t<td>" . $total_amende . "</td>\n\t<td>" . $frais_relance . "</td>\n\t"; $reqexpl = "select pret_idexpl as expl from pret where pret_retour<CURDATE() and pret_idempr={$id_empr}"; $resexple = pmb_mysql_query($reqexpl, $dbh); while ($liste = pmb_mysql_fetch_object($resexple)) { $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour "; $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_id, expl_cb,expl_cote, pret_date, pret_retour,\n\t\tniveau_relance,\n\t\tdate_relance,\n\t\tprinted,\t\t\n\t\ttdoc_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, " . $dates_resa_sql . ", "; $requete .= " 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_id='" . $liste->expl . "' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id "; $res_det_expl = pmb_mysql_query($requete); $expl = pmb_mysql_fetch_object($res_det_expl); $amd = $amende->get_amende($liste->expl); $reqlog = "select sum(log.log_printed) as printed, sum(log.log_mail) as mail\n\t\t\tfrom log_retard as log, log_expl_retard as expl where log.idempr={$id_empr} and log.niveau_reel='" . $expl->niveau_relance . "'\n\t\t \tand expl.num_log_retard=log.id_log and expl_id='" . $liste->expl . "' "; $reslog = pmb_mysql_query($reqlog); if ($log = pmb_mysql_fetch_object($reslog)) { $printed = $log->printed; $mail = $log->mail; } else { $printed = 0; $mail = 0; } $info .= "\n\t\t<tr>\n\t\t\t{$info_empr}\n\t\t\t<td>" . htmlentities($expl->tit, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($expl->expl_cb, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . format_date($expl->pret_date) . "</td>\n\t\t\t<td>" . format_date($expl->pret_retour) . "</td>\n\t\t\t<td>" . $expl->niveau_relance . "</td>\n\t\t\t<td>" . format_date($expl->date_relance) . "</td>\n\t\t\t<td>" . htmlentities($mail, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($printed, ENT_QUOTES, $charset) . "</td>\n\t\t\t<td>" . htmlentities($amd["valeur"], ENT_QUOTES, $charset) . "</td>\n\t\t</tr>\n\t\t"; } return $info; }
function show_lines_list() { global $id_empr, $msg, $charset; //Liste des recouvrements print "\n\t<div class='row'>\t\n\t<script type='text/javascript' src='./javascript/sorttable.js'></script>\n\t<table class='sortable'>\n\n\t\t<tr>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_date"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_type"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_titre"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_cb"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_cote"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_pret_date"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date1"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date2"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date3"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_prix_calcul"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_montant"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th></th>\n\t\t\t<th></th>\t\t\n\t\t</tr>"; $requete = "select recouvr_id,id_expl,date_rec,libelle,montant, expl_notice,expl_bulletin, recouvr_type, date_pret,date_relance1,date_relance2,date_relance3, expl_cote ,\texpl_cb\n\tfrom recouvrements left join exemplaires on expl_id=id_expl where empr_id={$id_empr} order by date_rec,recouvr_id"; $resultat = pmb_mysql_query($requete); $pair = false; while ($r = pmb_mysql_fetch_object($resultat)) { if (!$pair) { $pair_impair = "odd"; } else { $pair_impair = "even"; } $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" "; $pair = !$pair; if ($r->id_expl) { if ($r->expl_notice) { $notice = new mono_display($r->expl_notice); } elseif ($r->expl_bulletin) { $req = "select bulletin_notice from bulletins where bulletin_id={$r->expl_bulletin}"; $res = pmb_mysql_query($req); $id_bull_notice = pmb_mysql_result($res, 0, 0); $notice = new serial_display($id_bull_notice); } $libelle = strip_tags(html_entity_decode($notice->header, ENT_QUOTES, $charset)); } else { $libelle = $r->libelle; } if (!$r->recouvr_type) { print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t<td>" . format_date($r->date_rec) . "</td>\n\t\t\t\t<td>" . htmlentities($msg["relance_recouvrement_amende"], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($libelle, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td><a href='./circ.php?categ=visu_ex&form_cb_expl=" . $r->expl_cb . "'>" . $r->expl_cb . "</a></td>\n\t\t\t\t<td>" . htmlentities($r->expl_cote, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . format_date($r->date_pret) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance1) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance2) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance3) . "</td>\n\t\t\t\t<td></td>\n\t\t\t\t<td style='text-align:right'><span dynamics='circ,recouvr_prix' dynamics_params='text' id='prix_" . $r->recouvr_id . "'>" . comptes::format_simple($r->montant) . "</span></td>\n\t\t\t\t<td style='text-align:center'><input type='checkbox' name='recouvr_ligne[]' value='" . $r->recouvr_id . "'></td>\n\t\t\t\t<td>"); if (!$r->id_expl) { print "<input type='button' value='...' class='bouton' onClick=\"this.form.act_line.value='update_line'; this.form.recouvr_id.value='" . $r->recouvr_id . "'; this.form.submit();\"/>"; } else { print " "; } print "</td>"; print "</tr>"; } elseif ($r->id_expl) { $requete = "select expl_prix, prix from exemplaires, notices where (notice_id=expl_notice or notice_id=expl_bulletin) and expl_id =" . $r->id_expl; //http://localhost/~ngantier/pmb/circ.php?categ=visu_ex&form_cb_expl=p $res_prix = pmb_mysql_query($requete); $comment_prix = ''; if ($r_prix = pmb_mysql_fetch_object($res_prix)) { if (!($comment_prix = $r_prix->expl_prix)) { $comment_prix = $r_prix->prix; } } print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t<td>" . format_date($r->date_rec) . "</td>\n\t\t\t\t<td>" . htmlentities($msg["relance_recouvrement_prix"], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($libelle, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td><a href='./circ.php?categ=visu_ex&form_cb_expl=" . $r->expl_cb . "'>" . $r->expl_cb . "</a></td>\n\t\t\t\t<td>" . htmlentities($r->expl_cote, ENT_QUOTES, $charset) . "</td>\t\t\t\n\t\t\t\t<td>" . format_date($r->date_pret) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance1) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance2) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance3) . "</td>\n\t\t\t\t<td>" . htmlentities($comment_prix, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td style='text-align:right'><span dynamics='circ,recouvr_prix' dynamics_params='text' id='prix_" . $r->recouvr_id . "'>" . comptes::format_simple($r->montant) . "</span></td>\n\t\t\t\t<td style='text-align:center'><input type='checkbox' name='recouvr_ligne[]' value='" . $r->recouvr_id . "'></td>\n\t\t\t\t<td>"); print "</td>"; print "</tr>"; } } print "</table></div>"; print "\n\t\t<div class='row'></div>\n\t</div>\n\t<!--boutons -->\n\t<div class='row'>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_del_all_lines"] . "' class='bouton' onClick=\"if (confirm('" . $msg["relance_recouvrement_confirm_del"] . "')) { this.form.act_line.value='del_line'; this.form.submit(); }\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_add_line"] . "' class='bouton' onClick=\"this.form.act_line.value='update_line'; this.form.recouvr_id.value=''; this.form.submit();\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_export_tableur"] . "' class='bouton' onClick=\"document.location='./circ/relance/recouvr_reader_excel.php?id_empr={$id_empr}';\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_solder"] . "' class='bouton' onClick=\"if (confirm('" . $msg["relance_recouvrement_confirm_solder"] . "')) { this.form.act_line.value='solde'; this.form.submit(); }\"/>\n\t\t<input type='button' value='" . $msg["76"] . "' class='bouton' onClick=\"document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_liste'\"/>\n\t</div>"; }
function rec_abonnement($id, $type_abt, $empr_categ, $rec_caution = true) { global $pmb_gestion_financiere, $pmb_gestion_abonnement; if ($pmb_gestion_financiere) { //Récupération du tarif if ($pmb_gestion_abonnement == 1) { $requete = "select tarif_abt, libelle from empr_categ where id_categ_empr={$empr_categ}"; $resultat = pmb_mysql_query($requete); } else { if ($pmb_gestion_abonnement == 2) { $requete = "select tarif, type_abt_libelle, caution from type_abts where id_type_abt={$type_abt}"; $resultat = pmb_mysql_query($requete); } } if (@pmb_mysql_num_rows($resultat)) { $tarif = pmb_mysql_result($resultat, 0, 0); $libelle = pmb_mysql_result($resultat, 0, 1); if ($pmb_gestion_abonnement == 2) { $caution = pmb_mysql_result($resultat, 0, 2); } } $compte_id = comptes::get_compte_id_from_empr($id, 1); if ($compte_id) { $cpte = new comptes($compte_id); } if ($tarif * 1) { //Enregistrement de la transaction $cpte->record_transaction("", abs($tarif), -1, "Inscription : " . $libelle, 0); } if ($caution * 1 && $rec_caution) { $cpte->record_transaction("", abs($caution), -1, "Caution : " . $libelle, 0); $requete = "update empr set caution='" . abs($caution) . "' where id_empr={$id}"; pmb_mysql_query($requete); } } }
function encaisse_form($with_validated = false, $transacash_num = 0) { global $id_compte, $solde, $date_debut, $val_transactions, $somme, $cpte, $charset; global $pmb_gestion_devise, $msg, $charset; $solde = $cpte->get_solde(); if ($solde < 0) { print "<table>"; print "<tr><td style='text-align:right'>" . $msg["finance_enc_montant_valide"] . " : </td><td style='text-align:right'>" . comptes::format($somme * -1) . "</td></tr>"; if ($solde <= 0) { print "<tr class='erreur'><td style='text-align:right'>" . $msg["finance_enc_montant_a_enc"] . " : </td><td style='text-align:right'>"; } else { if ($solde > 0) { print "<td>" . $msg["finance_enc_compte_cred"] . " : </td><td style='text-align:right'>"; } } print comptes::format($solde * -1); print "</td></tr></table>"; print "<script type='text/javascript' >function check_somme(f) {\n\t\t\tmessage='';\n\t\t\tif (isNaN(f.somme.value)) {\n\t\t\t\tmessage='" . addslashes($msg["finance_enc_nan"]) . "';\n\t\t\t} else {\n\t\t\t\tif (f.somme.value<=0)\n\t\t\t\t\tmessage='" . addslashes($msg["finance_enc_mnt_neg"]) . "';\n\t\t\t}\n\t\t\tif (message) {\n\t\t\t\talert(message);\n\t\t\t\treturn false;\n\t\t\t} else return true;\n\t\t}\n\t\t</script>"; print "<form name='form_encaissement' action='encaissement.php?id_compte={$id_compte}&show_transactions={$show_transactions}&date_debut=" . rawurlencode(stripslashes($date_debut)) . "' method='post'>\n\t\t<input type='hidden' name='act' value='enc'/>\n\t\t<input type='hidden' name='transacash_num' value='{$transacash_num}'/>\n\t\t<input type='hidden' name='val_transactions' value=\"" . htmlentities($val_transactions, ENT_QUOTES, $charset) . "\"/>" . htmlentities($msg['finance_mnt_percu'], ENT_QUOTES, $charset) . " <input type='text' value='" . $solde * -1 . "' name='somme' class='saisie-5em' style='text-align:right'> " . $pmb_gestion_devise . "\n\t\t<input type='submit' value='" . $msg["finance_but_enc"] . "' class='bouton' onClick=\"return check_somme(this.form)\"/> <input type='button' value='" . $msg["76"] . "' class='bouton' onClick=\"document.form_encaissement.act.value=''; document.form_encaissement.submit();\"/>\n\t\t</form>\n\t\t"; } else { back_to_main(); } }
function do_retour($stuff, $confirmed = 1) { global $dbh; global $msg; global $alert_sound_list, $pmb_play_pret_sound; global $pmb_gestion_amende, $pmb_gestion_financiere, $pmb_blocage_retard, $pmb_blocage_max, $pmb_blocage_delai, $pmb_blocage_coef; global $deflt_docs_location; $erreur_affichage = ''; if (!is_object($stuff)) { die("erreur dans le module ./circ/retour.inc [do_retour()]. Contactez l'admin"); } // récupération localisation exemplaire $query = "SELECT t.tdoc_libelle as type_doc"; $query .= ", l.location_libelle as location"; $query .= ", s.section_libelle as section"; $query .= " FROM docs_type t"; $query .= ", docs_location l"; $query .= ", docs_section s"; $query .= " WHERE t.idtyp_doc=" . $stuff->expl_typdoc; $query .= " AND l.idlocation=" . $stuff->expl_location; $query .= " AND s.idsection=" . $stuff->expl_section; $query .= " LIMIT 1"; $result = mysql_query($query, $dbh); $info_doc = mysql_fetch_object($result); print pmb_bidi("<br /><form><div class='row'><div class='left'><strong>" . $stuff->libelle . "</strong></div>"); // flag confirm retour if (!$confirmed and $stuff->pret_idempr) { print "\n\t\t\t<div class='right'>\n\t\t\t<input type='button' class='bouton' \n\t\t\t\t\tname='confirm_ret' value='" . $msg['retour_confirm'] . "'\n\t\t\t\t\tonClick=\"document.location='./circ.php?categ=retour&cb_expl=" . $stuff->expl_cb . "'\">\n\t\t\t</div>"; } elseif ($stuff->pret_idempr) { print "\n\t\t\t\t<div class='right'>\n\t\t\t\t\t<font color='RED'><b>{$msg['retour_ok']}</b></font>\n\t\t\t\t</div>"; } print "</div>"; print pmb_bidi("<br /><b>" . $stuff->expl_cb . "</b> " . $info_doc->type_doc); print pmb_bidi('. ' . $info_doc->location); print pmb_bidi('. ' . $info_doc->section); print pmb_bidi('. ' . $stuff->expl_cote); print " <input class='bouton' type='button' value=\"" . $msg[375] . "\" onClick=\"document.location='circ.php?categ=visu_ex&form_cb_expl=" . $stuff->expl_cb . "';\" />"; print "</form>"; //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 < count($perso_["FIELDS"]); $i++) { $p = $perso_["FIELDS"][$i]; if ($p["AFF"]) { $perso_aff .= "<br />" . $p["TITRE"] . " " . $p["AFF"]; } } } if ($perso_aff) { print "<div class='row'>" . $perso_aff . "</div>"; } $script_magnetique = "\n<script language='javascript' type='text/javascript'>\nvar requete = null;\n\nfunction creerRequette(){\n\tif(window.XMLHttpRequest) // Firefox\n\t\trequete = new XMLHttpRequest();\n\telse if(window.ActiveXObject) // Internet Explorer\n \t\trequete = new ActiveXObject('Microsoft.XMLHTTP');\n\telse { // XMLHttpRequest non supporté par le navigateur\n \t\talert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');\n \treturn;\n\t}\n}\n\nfunction magnetise(commande){\n\tcreerRequette();\n\tif(netscape.security.PrivilegeManager)netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');\t\n\trequete.open('GET', 'http://localhost:30000/?send_value='+commande+'&command=Send', false);\n\trequete.send(null);\n\tif(requete.readyState != 4) alert('Requête antivol non effectuée !');\n}\n\n"; global $pmb_antivol; if ($pmb_antivol > 0) { if ($stuff->type_antivol == 1) { // c'est un support non magnétique (livre, revue...) print "{$script_magnetique}" . "magnetise('RRR');</script>"; } if ($stuff->type_antivol == 2) { //c'est un support magnétique (cassette) print "{$script_magnetique}" . "magnetise('SSS');</script>"; } } //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 = "<hr /><div class='erreur'>"; //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!!", "<select onchange='enregLoc(this)'>!!liste!!</select>", $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 .= "<option value='" . $value->idsection . "'"; if ($value->idsection == $stuff->expl_section) { $liste_section .= " selected"; $expl_section_libelle = $value->section_libelle; } $liste_section .= ">" . $value->section_libelle . "</option>"; } $texte_change_loc = addslashes(str_replace("!!liste!!", $liste_section, $texte_change_loc)); $html_erreur_site .= "\n<form name='actionTrans'>\n<input type='hidden' name='typeTrans' value='" . $transferts_retour_action_defaut . "'>\n<input type='hidden' name='explTrans' value='" . $stuff->expl_id . "'>\n<script language='javascript'>\nmsg_inf_loc = '" . $texte_change_loc . "';\nmsg_bt_loc = '" . str_replace("'", "\\'", $msg["transferts_circ_retour_bt_retour_mauvaise_localisation"]) . "';\nmsg_inf_trans = '" . str_replace("'", "\\'", str_replace("!!lbl_site!!", $resSite, $msg["transferts_circ_retour_lbl_transfert"])) . "';\nmsg_bt_trans = '" . str_replace("'", "\\'", $msg["transferts_circ_retour_bt_changement_localisation"]) . "';\n\nfunction changeAction() {\n\n\tvar actionTrans = new http_request();\n\tvar url= './ajax.php?module=circ&categ=transferts&idexpl=' + document.actionTrans.explTrans.value + '&action=';\n\t\t\t\t\n\tswitch (document.actionTrans.typeTrans.value) {\n\t\tcase '0':\n\t\t\t//il y a eu un changement localisation\n\t\t\t//on propose un transfert\n\t\t\tif (confirm('" . addslashes($msg["transferts_circ_retour_confirm_gen_transfert"]) . "')) {\n\n\t\t\t\turl = url + 'gen_transfert¶m=' + document.actionTrans.paramTrans.value ;\n\t\t\t\n\t\t\t\tif (actionTrans.request(url)) {\n\t\t\t\t\t// Il y a une erreur. Afficher le message retourné\n\t\t\t\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t//tout c'est bien passe\n\t\t\t\t\t\n\t\t\t\t\t//on recupere les infos\n\t\t\t\t\tdocument.actionTrans.typeTrans.value = '1';\n\t\t\t\t\tdocument.actionTrans.paramTrans.value = actionTrans.get_text();\n\t\t\t\t\t\n\t\t\t\t\t//on change les textes\n\t\t\t\t\tdocument.actionTrans.btActionTrans.value = msg_bt_trans;\n\t\t\t\t\tdocument.getElementById('libInfoTransfert').innerHTML = msg_inf_trans; \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}//if confirm\n\t\t\t\n\t\t\t\n\t\t\tbreak;\n\t\n\t\tcase '1':\n\t\t\t//il y a eu un transfert\n\t\t\t//on propose un changement de localisation\n\t\t\tif (confirm('" . addslashes($msg["transferts_circ_retour_confirm_change_loc"]) . "')) {\n\n\t\t\t\turl = url + 'change_loc¶m=' + document.actionTrans.paramTrans.value ;\n\t\t\t\n\t\t\t\tif (actionTrans.request(url)) {\n\t\t\t\t\t// Il y a une erreur. Afficher le message retourné\n\t\t\t\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t//tout c'est bien passe\n\t\t\t\t\t\n\t\t\t\t\t//on recupere les infos\n\t\t\t\t\tdocument.actionTrans.typeTrans.value = '0';\n\t\t\t\t\tdocument.actionTrans.paramTrans.value = actionTrans.get_text();\n\t\t\t\t\t\n\t\t\t\t\t//on change les textes\n\t\t\t\t\tdocument.actionTrans.btActionTrans.value = msg_bt_loc;\n\t\t\t\t\tdocument.getElementById('libInfoTransfert').innerHTML = msg_inf_loc; \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t} //if confirm\n\t\t\tbreak;\n\t} //switch\n\t\t\n}\n\nfunction enregLoc(obj) {\n\tval = obj.options[obj.selectedIndex].value;\n\t\n\tvar actionTrans = new http_request();\n\tvar url= './ajax.php?module=circ&categ=transferts&idexpl=' + document.actionTrans.explTrans.value + '&action=change_section¶m='+val;\n\t\n\tif (actionTrans.request(url)) {\n\t\t// Il y a une erreur. Afficher le message retourné\n\t\talert ( '" . addslashes($msg["540"]) . " : ' + actionTrans.get_text() );\t\t\t\n\t}\n}\n</script>"; if ($stuff->resa_idempr) { // le doc en retour peut servir à valider une résa suivante if (!verif_cb_utilise($stuff->expl_cb)) { $affect = affecte_cb($stuff->expl_cb); } } if (!$affect) { switch ($transferts_retour_action_defaut) { case "0": //change la localisation d'origine $param = $trans->retour_exemplaire_change_localisation($stuff->expl_id); //le message a l'ecran $html_erreur_site .= "<div id='libInfoTransfert'>" . str_replace("!!lbl_site!!", $resSite, $msg["transferts_circ_retour_lbl_change_localisation"]) . "</div>"; if ($transferts_retour_action_autorise_autre == "1") { //on propose de générer le transfert $html_erreur_site .= " <input class='bouton' name='btActionTrans' type='button' value=\"" . $msg["transferts_circ_retour_bt_retour_mauvaise_localisation"] . "\" " . " onclick=\"changeAction();\"" . ">"; } break; case "1": //genere le transfert automatique de l'exemplaire $param = $trans->retour_exemplaire_genere_transfert_retour($stuff->expl_id); //le message a l'ecran $html_erreur_site .= "<div id='libInfoTransfert'>" . $msg["transferts_circ_retour_lbl_transfert"] . "</div>"; if ($transferts_retour_action_autorise_autre == "1") { //on propose de changer la localisation $html_erreur_site .= " <input class='bouton' name='btActionTrans' type='button' value=\"" . $msg["transferts_circ_retour_bt_changement_localisation"] . "\" " . " onclick=\"changeAction();\"" . ">"; } break; } //switch } if ($transferts_retour_action_autorise_autre == "1") { $html_erreur_site .= "<input type='hidden' name='paramTrans' value='" . $param . "'></form>"; } $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 .= "</div>"; 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("<hr /><div class='erreur'>{$msg[377]} :</div><div class='message_important'>" . $stuff->expl_note . "</div>"); } elseif ($pmb_play_pret_sound) { $alert_sound_list[] = "information"; } // zone du dernier emrunteur if ($stuff->expl_lastempr) { $dernier_empr = "<hr /><div class='row'>{$msg['expl_prev_empr']} "; $link = "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($stuff->lastempr_cb) . "'>"; $dernier_empr .= $link . $stuff->lastempr_prenom . ' ' . $stuff->lastempr_nom . ' (' . $stuff->lastempr_cb . ')</a>'; $dernier_empr .= "</div><hr />"; } 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 "<br /><div class='erreur'>" . $msg[369] . " : " . $retard . " " . $msg[370] . "</div>"; $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 "<br /><div class='erreur'>" . sprintf($msg["blocage_retard_pret"], formatdate($date_fin)) . "</div>"; $alertsound_list[] = "critique"; } else { print "<br /><div class='erreur'>" . sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr)) . "</div>"; $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("<br /><div class='erreur'>" . $msg["finance_retour_amende"] . " : " . comptes::format($amende_t["valeur"])); $alert_sound_list[] = "critique"; $compte_id = comptes::get_compte_id_from_empr($stuff->pret_idempr, 2); if ($compte_id) { $cpte = new comptes($compte_id); if ($cpte->id_compte) { $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $stuff->pret_idexpl), 0); print " " . $msg["finance_retour_amende_recorded"]; } } print "</div>"; } } // 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 "<div class='erreur'>{$msg[371]}</div>"; } } else { // impossible de supprimer en table pret print "<div class='erreur'>{$msg[372]}</div>"; } // 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 = "<strong>" . str_replace("!!site_dest!!", $lib_loc, $msg["transferts_circ_resa_validation_alerte"]) . "</strong><br />"; $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("<div class='message_important'>{$msg['352']}</div>\n\t\t\t\t\t\t\t<div class='row'>{$msg_trans}\n\t\t\t\t\t\t\t{$msg[373]}\n\t\t\t\t\t\t\t<strong><a href='./circ.php?categ=pret&form_cb=" . rawurlencode($empr->empr_cb) . "'>" . $empr->empr_prenom . " " . $empr->empr_nom . "</a></strong>\n\t\t\t\t\t\t\t ({$empr->empr_cb} )\n\t\t\t\t\t\t\t</div>"); $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 "<div class='erreur'>{$msg[605]}</div>"; $alert_sound_list[] = "critique"; } // show_report($stuff); // this stands for debugging }
function do_retour_doc() { global $dbh; global $msg; global $pmb_gestion_amende, $pmb_gestion_financiere, $pmb_blocage_retard, $pmb_blocage_max, $pmb_blocage_delai, $pmb_blocage_coef; // récupération localisation exemplaire $query = "select t.tdoc_libelle as type_doc"; $query .= ", l.location_libelle as location"; $query .= ", s.section_libelle as section"; $query .= " from docs_type t"; $query .= ", docs_location l"; $query .= ", docs_section s"; $query .= " where t.idtyp_doc=" . $this->expl_typdoc; $query .= " and l.idlocation=" . $this->expl_location; $query .= " and s.idsection=" . $this->expl_section; $query .= " limit 1"; $result = pmb_mysql_query($query, $dbh); $info_doc = pmb_mysql_fetch_object($result); $this->type_doc = $info_doc->type_doc; if ($this->nbparts > 1) { $this->type_doc .= " (" . $this->nbparts . ")"; } $this->location = $info_doc->location; $this->section = $info_doc->section; if ($this->expl_note) { $this->error_message = $msg[377]; } if ($this->pret_idempr) { // calcul du retard éventuel $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('{$this->pret_retour}'))) as retard "; $resultatdate = pmb_mysql_query($rqt_date); $resdate = pmb_mysql_fetch_object($resultatdate); $retard = $resdate->retard; if ($retard > 0) { //Calcul du vrai nombre de jours $date_debut = explode("-", $this->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; $this->error_message = $msg[369] . " : " . $retard . " " . $msg[370]; } else { $this->error_message = $msg["calendrier_active_aucun_retard"]; } } //Calcul du blocage if ($pmb_blocage_retard) { $date_debut = explode("-", $this->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 = pmb_mysql_result(pmb_mysql_query("select date_fin_blocage from empr where id_empr='" . $this->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 pmb_mysql_query("update empr set date_fin_blocage='" . $date_fin . "' where id_empr='" . $this->pret_idempr . "'"); $this->error_message = sprintf($msg["blocage_retard_pret"], formatdate($date_fin)); } else { $this->error_message = sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr)); } } } //Vérification des amendes if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amende = new amende($this->pret_idempr); $amende_t = $amende->get_amende($this->pret_idexpl); //Si il y a une amende, je la débite if ($amende_t["valeur"]) { $this->error_message = $msg["finance_retour_amende"] . " : " . comptes::format($amende_t["valeur"]); $compte_id = comptes::get_compte_id_from_empr($this->pret_idempr, 2); if ($compte_id) { $cpte = new comptes($compte_id); if ($cpte->id_compte) { $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $this->pret_idexpl), 0); $this->error_message .= " " . $msg["finance_retour_amende_recorded"]; } } } } // Suppression prêt et la mise en table de stat $query = "delete from pret where pret_idexpl = '" . $this->pret_idexpl . "' "; $result = pmb_mysql_query($query, $dbh); if ($result) { $this->retour_message = $msg["retour_ok"]; if (!$this->maj_stat_pret()) { // impossible de maj en table stat $this->error_message = $msg[371]; } } else { // impossible de supprimer en table pret $this->error_message = $msg[372]; } // traitement de l'éventuelle réservation if ($this->resa_idempr) { // le doc en retour peut servir à valider une résa suivante if (!verif_cb_utilise($this->cb_expl)) { $affect = affecte_cb($this->cb_expl); // affichage message de réservation if ($affect) { $this->error_message = $msg["rfid_retour_document_reserve_message"]; $this->url_reservation = "./circ.php?categ=pret&form_cb=" . rawurlencode($this->cb_reservataire); } // fin if affect } // fin if !verif_cb_utilise } // fin if resa } else { $this->error_message = $msg[605]; } }
function add_pret($id_empr, $id_expl, $cb_doc, $resarc_id = 0, $short_loan = 0) { // le lien MySQL global $dbh, $msg; global $pmb_quotas_avances, $pmb_utiliser_calendrier; global $pmb_gestion_financiere, $pmb_gestion_tarif_prets; global $include_path, $lang; global $deflt2docs_location; global $pmb_pret_date_retour_adhesion_depassee; global $pmb_short_loan_management; global $pmb_transferts_actif; global $pmb_resa_planning; $resarc_id += 0; /* on prépare la date de début*/ $pret_date = today(); $duree_pret = 0; // calcul de la duree du pret si la date de fin est definie par les previsions if ($resarc_id && $pmb_resa_planning == 1) { $q = 'select datediff(resarc_fin,"' . $pret_date . '") from resa_archive where resarc_id =' . $resarc_id . ' and resarc_resa_planning_id_resa!=0 limit 1'; $r = pmb_mysql_query($q, $dbh); if (pmb_mysql_num_rows($r)) { $duree_pret = pmb_mysql_result($r, 0, 0); } } if (!$duree_pret) { /* on cherche la durée du prêt */ if ($pmb_short_loan_management && $short_loan) { if ($pmb_quotas_avances) { //Initialisation de la classe $qt = new quota("SHORT_LOAN_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $duree_pret = $qt->get_quota_value($struct); if ($duree_pret == -1) { $duree_pret = 0; } } else { $query = "SELECT short_loan_duration as duree_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_properties = pmb_mysql_fetch_object($result); $duree_pret = $expl_properties->duree_pret; } } else { if ($pmb_quotas_avances) { //Initialisation de la classe $qt = new quota("LEND_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $duree_pret = $qt->get_quota_value($struct); if ($duree_pret == -1) { $duree_pret = 0; } } else { $query = "SELECT duree_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_properties = pmb_mysql_fetch_object($result); $duree_pret = $expl_properties->duree_pret; } } } // calculer la date de retour prévue, tenir compte de la date de fin d'adhésion if (!$duree_pret) { $duree_pret = '0'; } if ($pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY) as date_retour from empr where id_empr='" . $id_empr . "'"; } else { $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),empr_date_expiration) as date_retour from empr where id_empr='" . $id_empr . "'"; } $resultatdate = pmb_mysql_query($rqt_date) or die(pmb_mysql_error() . "<br /><br />{$rqt_date}<br /><br />"); $res = pmb_mysql_fetch_object($resultatdate); $date_retour = $res->date_retour; $pret_depasse_adhes = $res->pret_depasse_adhes; $empr_date_expiration = $res->empr_date_expiration; if ($pmb_utiliser_calendrier) { if ($pret_depasse_adhes == 0 || $pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "select date_ouverture from ouvertures where ouvert=1 and to_days(date_ouverture)>=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture "; $resultatdate = pmb_mysql_query($rqt_date); $res = @pmb_mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } else { $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture DESC"; $resultatdate = pmb_mysql_query($rqt_date); $res = @pmb_mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } // Si la date_retour, calculée ci-dessus d'après le calendrier, dépasse l'adhésion, alors que c'est interdit, // la date de retour doit etre le dernier jour ouvert if (!$pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "SELECT DATEDIFF('{$empr_date_expiration}','{$date_retour}')as diff"; $resultatdate = pmb_mysql_query($rqt_date); $res = @pmb_mysql_fetch_object($resultatdate); if ($res->diff < 0) { $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$empr_date_expiration}') and num_location={$deflt2docs_location} order by date_ouverture DESC"; $resultatdate = pmb_mysql_query($rqt_date); $res = @pmb_mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } } } // insérer le prêt $query = "INSERT INTO pret SET "; $query .= "pret_idempr = '" . $id_empr . "', "; $query .= "pret_idexpl = '" . $id_expl . "', "; $query .= "pret_date = sysdate(), "; $query .= "pret_retour = '{$date_retour}', "; $query .= "retour_initial = '{$date_retour}', "; $query .= "short_loan_flag = " . ($pmb_short_loan_management && $short_loan ? "'1'" : "'0'"); $result = @pmb_mysql_query($query, $dbh) or die(pmb_mysql_error() . "<br />can't INSERT into pret" . $query); // insérer la trace en stat, récupérer l'id et le mettre dans la table des prêts pour la maj ultérieure $stat_avant_pret = pret_construit_infos_stat($id_expl); $stat_id = stat_stuff($stat_avant_pret); $query = "update pret SET pret_arc_id='{$stat_id}' where "; $query .= "pret_idempr = '" . $id_empr . "' and "; $query .= "pret_idexpl = '" . $id_expl . "' "; $result = @pmb_mysql_query($query, $dbh) or die("can't update pret for stats " . $query); audit::insert_creation(AUDIT_PRET, $stat_id); //enregistrer les champs perso pret $p_perso = new pret_parametres_perso("pret"); $p_perso->rec_fields_perso($stat_id); if ($resarc_id) { $rqt_arch = "UPDATE resa_archive SET resarc_arcpretid = {$stat_id} WHERE resarc_id = '" . $resarc_id . "' "; @pmb_mysql_query($rqt_arch, $dbh); } $query = "update exemplaires SET "; $query .= "last_loan_date = sysdate() "; $query .= "where expl_id= '" . $id_expl . "' "; $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in exemplaires : " . $query); $query = "update exemplaires SET "; $query .= "expl_retloc=0 "; $query .= "where expl_id= '" . $id_expl . "' "; $result = @pmb_mysql_query($query, $dbh) or die("can't update expl_retloc in exemplaires : " . $query); $query = "update empr SET "; $query .= "last_loan_date = sysdate() "; $query .= "where id_empr= '" . $id_empr . "' "; $result = @pmb_mysql_query($query, $dbh) or die("can't update last_loan_date in empr : " . $query); $query = "delete from resa_ranger "; $query .= "where resa_cb='" . $cb_doc . "'"; $result = @pmb_mysql_query($query, $dbh) or die("can't delete cb_doc in resa_ranger : " . $query); //Débit du compte lecteur si nécessaire if ($pmb_gestion_financiere && $pmb_gestion_tarif_prets) { $tarif_pret = 0; switch ($pmb_gestion_tarif_prets) { case 1: //Gestion simple $query = "SELECT tarif_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @pmb_mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_tarif = pmb_mysql_fetch_object($result); $tarif_pret = $expl_tarif->tarif_pret; break; case 2: //Gestion avancée //Initialisation Quotas global $_parsed_quotas_; $_parsed_quotas_ = false; $qt_tarif = new quota("COST_LEND_QUOTA", "{$include_path}/quotas/own/{$lang}/finances.xml"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $tarif_pret = $qt_tarif->get_quota_value($struct); break; } $tarif_pret = $tarif_pret * 1; if ($tarif_pret) { $compte_id = comptes::get_compte_id_from_empr($id_empr, 3); if ($compte_id) { $cpte = new comptes($compte_id); $explaire = new exemplaire('', $id_expl); if ($explaire->id_notice == 0 && $explaire->id_bulletin) { //C'est un exemplaire de bulletin $bulletin = new bulletinage_display($explaire->id_bulletin); $titre = strip_tags($bulletin->display); } elseif ($explaire->id_notice) { $notice = new mono_display($explaire->id_notice); $titre = strip_tags($notice->header); } $libelle_expl = strlen($titre) > 15 ? $explaire->cb . " " . $titre : $explaire->cb . " " . $titre; $cpte->record_transaction("", abs($tarif_pret), -1, sprintf($msg["finance_pret_expl"], $libelle_expl), 0); } } } if ($pmb_transferts_actif) { // si transferts validé (en attente d'envoi), il faut restaurer le statut global $PMBuserid; $rqt = "SELECT id_transfert FROM transferts,transferts_demande\r\n\t\twhere\r\n\t\tnum_transfert=id_transfert and\r\n\t\tetat_demande=1 and num_expl ={$id_expl} and etat_transfert=0 and sens_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\r\n\t\t\tWHERE 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); } // cloture les demandes de transfert pour résa, refusée ou pas // afin de générer les transfert en automatique dans le circuit classique des résa $req = " update transferts,transferts_demande\n\t\tset etat_transfert=1 ,\n\t\tmotif=CONCAT(motif,'. Cloture, car parti en pret (gestion {$PMBuserid}, {$id_empr})')\n\t\twhere\n\t\tnum_transfert=id_transfert and\n\t\t(etat_demande=4 or etat_demande=0 or etat_demande=1)and\n\t\tetat_demande != 3 and etat_demande!=2 and etat_demande!=5 and\n\t\tnum_expl ={$id_expl} and etat_transfert=0 and sens_transfert=0\n\t\t"; pmb_mysql_query($req, $dbh); } // invalidation des résas avec ce code-barre, au cas où // $query = "update resa SET resa_cb='' where resa_cb='".$cb_doc."' "; // $result = @ pmb_mysql_query($query, $dbh) or die("can't update resa ".$query); }
die("no access"); } //Gestion des recouvrements require_once "{$class_path}/comptes.class.php"; // //Recherche des emprunteurs en recouvrement $requete = "select empr_id,empr_cb, concat(empr_nom,' ',empr_prenom) as empr_name,empr_adr1,empr_adr2,empr_cp,empr_ville,empr_pays,empr_mail,empr_tel1,empr_tel2, round(sum(id_expl!=0)/2) as nb_ouvrages, sum(montant) as somme ,location_libelle from recouvrements, empr JOIN docs_location ON empr_location=idlocation where id_empr=empr_id group by empr_id"; $resultat = mysql_query($requete); if ($pmb_lecteurs_localises) { $th_localisation = "<th>" . $msg["empr_location"] . "</th>"; } print "\n<script type='text/javascript' src='./javascript/sorttable.js'></script>\n<table class='sortable'>\n<tr><th>" . $msg["relance_recouvrement_cb"] . "</th><th>" . $msg["relance_recouvrement_name"] . "</th>{$th_localisation}<th>" . $msg["relance_recouvrement_nb_ouvrages"] . "</th><th>" . $msg["relance_recouvrement_somme_totale"] . "</th></tr>\n"; $pair = false; while ($r = mysql_fetch_object($resultat)) { if (!$pair) { $class = "odd"; } else { $class = "even"; } $pair = !$pair; print "<tr class='{$class}' onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$class}'\" onmousedown=\"document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_reader&id_empr=" . $r->empr_id . "';\" style='cursor: pointer'>"; print pmb_bidi("<td>" . $r->empr_cb . "</td>"); print pmb_bidi("<td>" . $r->empr_name . "</td>"); if ($pmb_lecteurs_localises) { print pmb_bidi("<td>" . $r->location_libelle . "</td>"); } print pmb_bidi("<td style='text-align:center'>" . $r->nb_ouvrages . "</td>"); print pmb_bidi("<td style='text-align:right'>" . comptes::format_simple($r->somme) . "</td>"); print "</tr>"; } print "</table>";
function confirm_pret($id_empr, $id_expl, $short_loan = 0) { // le lien MySQL global $dbh, $msg; global $pmb_quotas_avances, $pmb_utiliser_calendrier; global $pmb_gestion_financiere, $pmb_gestion_tarif_prets; global $include_path, $lang; global $deflt2docs_location; global $pmb_pret_date_retour_adhesion_depassee; global $pmb_short_loan_management; //supprimer le pret temporaire $query = "delete from pret where pret_idexpl = '" . $id_expl . "' "; $result = mysql_query($query, $dbh); /* on prépare la date de début*/ $pret_date = today(); /* on cherche la durée du prêt */ if ($pmb_short_loan_management && $short_loan) { if ($pmb_quotas_avances) { //Initialisation de la classe $qt = new quota("SHORT_LOAN_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $duree_pret = $qt->get_quota_value($struct); if ($duree_pret == -1) { $duree_pret = 0; } } else { $query = "SELECT short_loan_duration as duree_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_properties = mysql_fetch_object($result); $duree_pret = $expl_properties->duree_pret; } } else { if ($pmb_quotas_avances) { //Initialisation de la classe $qt = new quota("LEND_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $duree_pret = $qt->get_quota_value($struct); if ($duree_pret == -1) { $duree_pret = 0; } } else { $query = "SELECT duree_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_properties = mysql_fetch_object($result); $duree_pret = $expl_properties->duree_pret; } } // calculer la date de retour prévue, tenir compte de la date de fin d'adhésion if (!$duree_pret) { $duree_pret = "0"; } if ($pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY) as date_retour from empr where id_empr='" . $id_empr . "'"; } else { $rqt_date = "select empr_date_expiration,if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),0,1) as pret_depasse_adhes, if(empr_date_expiration>date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),date_add('" . $pret_date . "', INTERVAL '{$duree_pret}' DAY),empr_date_expiration) as date_retour from empr where id_empr='" . $id_empr . "'"; } $resultatdate = mysql_query($rqt_date) or die(mysql_error() . "<br /><br />{$rqt_date}<br /><br />"); $res = mysql_fetch_object($resultatdate); $date_retour = $res->date_retour; $pret_depasse_adhes = $res->pret_depasse_adhes; $empr_date_expiration = $res->empr_date_expiration; if ($pmb_utiliser_calendrier) { if ($pret_depasse_adhes == 0 || $pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "select date_ouverture from ouvertures where ouvert=1 and to_days(date_ouverture)>=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture "; $resultatdate = mysql_query($rqt_date); $res = @mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } else { $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$date_retour}') and num_location={$deflt2docs_location} order by date_ouverture DESC"; $resultatdate = mysql_query($rqt_date); $res = @mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } // Si la date_retour, calculée ci-dessus d'après le calendrier, dépasse l'adhésion, alors que c'est interdit, // la date de retour doit etre le dernier jour ouvert if (!$pmb_pret_date_retour_adhesion_depassee) { $rqt_date = "SELECT DATEDIFF('{$empr_date_expiration}','{$date_retour}')as diff"; $resultatdate = mysql_query($rqt_date); $res = @mysql_fetch_object($resultatdate); if ($res->diff < 0) { $rqt_date = "select date_ouverture from ouvertures where date_ouverture>=sysdate() and ouvert=1 and to_days(date_ouverture)<=to_days('{$empr_date_expiration}') and num_location={$deflt2docs_location} order by date_ouverture DESC"; $resultatdate = mysql_query($rqt_date); $res = @mysql_fetch_object($resultatdate); if ($res->date_ouverture) { $date_retour = $res->date_ouverture; } } } } // insérer le prêt $query = "INSERT INTO pret SET "; $query .= "pret_idempr = '" . $id_empr . "', "; $query .= "pret_idexpl = '" . $id_expl . "', "; $query .= "pret_date = sysdate(), "; $query .= "pret_retour = '{$date_retour}', "; $query .= "retour_initial = '{$date_retour}', "; $query .= "short_loan_flag = " . ($pmb_short_loan_management && $short_loan ? "'1'" : "'0'"); $result = @mysql_query($query, $dbh) or die("can't INSERT into pret" . $query); // insérer la trace en stat, récupérer l'id et le mettre dans la table des prêts pour la maj ultérieure $stat_avant_pret = pret_construit_infos_stat($id_expl); $stat_id = stat_stuff($stat_avant_pret); $query = "update pret SET pret_arc_id='{$stat_id}' where "; $query .= "pret_idempr = '" . $id_empr . "' and "; $query .= "pret_idexpl = '" . $id_expl . "' "; $result = @mysql_query($query, $dbh) or die("can't update pret for stats " . $query); $query = "update exemplaires SET "; $query .= "last_loan_date = sysdate() "; $query .= "where expl_id= '" . $id_expl . "' "; $result = @mysql_query($query, $dbh) or die("can't update last_loan_date in exemplaires : " . $query); $query = "update exemplaires SET "; $query .= "expl_retloc=0 "; $query .= "where expl_id= '" . $id_expl . "' "; $result = @mysql_query($query, $dbh) or die("can't update expl_retloc in exemplaires : " . $query); $query = "update empr SET "; $query .= "last_loan_date = sysdate() "; $query .= "where id_empr= '" . $id_empr . "' "; $result = @mysql_query($query, $dbh) or die("can't update last_loan_date in empr : " . $query); //Débit du compte lecteur si nécessaire if ($pmb_gestion_financiere && $pmb_gestion_tarif_prets) { $tarif_pret = 0; switch ($pmb_gestion_tarif_prets) { case 1: //Gestion simple $query = "SELECT tarif_pret"; $query .= " FROM exemplaires, docs_type"; $query .= " WHERE expl_id='" . $id_expl; $query .= "' and idtyp_doc=expl_typdoc LIMIT 1"; $result = @mysql_query($query, $dbh) or die("can't SELECT exemplaires " . $query); $expl_tarif = mysql_fetch_object($result); $tarif_pret = $expl_tarif->tarif_pret; break; case 2: //Gestion avancée //Initialisation Quotas global $_parsed_quotas_; $_parsed_quotas_ = false; $qt_tarif = new quota("COST_LEND_QUOTA", "{$include_path}/quotas/own/{$lang}/finances.xml"); $struct["READER"] = $id_empr; $struct["EXPL"] = $id_expl; $tarif_pret = $qt_tarif->get_quota_value($struct); break; } $tarif_pret = $tarif_pret * 1; if ($tarif_pret) { $compte_id = comptes::get_compte_id_from_empr($id_empr, 3); if ($compte_id) { $cpte = new comptes($compte_id); $cpte->record_transaction("", abs($tarif_pret), -1, sprintf($msg["finance_pret_expl"], $id_expl), 0); } } } $this->resa_pret_gestion($id_empr, $id_expl, $stat_id); $array[0]['statut'] = 1; $buf_xml = array2xml($array); return $buf_xml; }
function print_relance($id_empr, $mail = true) { global $mailretard_priorite_email, $mailretard_priorite_email_3; global $dbh, $charset, $msg, $pmb_gestion_financiere, $pmb_gestion_amende; global $mail_sended; $mail_sended = 0; $not_mail = 0; if ($pmb_gestion_financiere && $pmb_gestion_amende) { $req = "delete from cache_amendes where id_empr=" . $id_empr; pmb_mysql_query($req); $amende = new amende($id_empr); $level = $amende->get_max_level(); $niveau_min = $level["level_min"]; $id_expl = $level["level_min_id_expl"]; $total_amende = $amende->get_total_amendes(); } //Si mail de rappel affecté au groupe, on envoi au responsable $requete = "select id_groupe,resp_groupe from groupe,empr_groupe where id_groupe=groupe_id and empr_id={$id_empr} and resp_groupe and mail_rappel limit 1"; $res = pmb_mysql_query($requete); if (pmb_mysql_num_rows($res) > 0) { $requete = "select empr_mail from empr where id_empr='" . pmb_mysql_result($res, 0, 1) . "'"; $res = pmb_mysql_query($requete); if (@pmb_mysql_num_rows($res)) { list($empr_mail) = pmb_mysql_fetch_row($res); } } else { $requete = "select empr_mail from empr where id_empr={$id_empr}"; $resultat = pmb_mysql_query($requete); if (@pmb_mysql_num_rows($resultat)) { list($empr_mail) = pmb_mysql_fetch_row($resultat); } } if ($niveau_min) { //Si c'est un mail if (($mailretard_priorite_email == 1 || $mailretard_priorite_email == 2) && $empr_mail && ($niveau_min < 3 || $mailretard_priorite_email_3) && $mail) { if (send_mail($id_empr, $niveau_min)) { $requete = "update pret set printed=1 where pret_idexpl=" . $id_expl; pmb_mysql_query($requete, $dbh); $mail_sended = 1; } } else { $requete = "update pret set printed=2 where pret_idexpl=" . $id_expl; pmb_mysql_query($requete, $dbh); $not_mail = 1; //Débit du compte lecteur /*$frais="finance_relance_".$niveau_min; global $$frais; if ($$frais) { $id_compte=comptes::get_compte_id_from_empr($id_empr,2); if ($id_compte) { $cpte=new comptes($id_compte); $cpte->record_transaction("",$$frais,-1,sprintf($msg["relance_frais_relance_level"],$niveau_min)); } }*/ } } $req = "delete from cache_amendes where id_empr=" . $id_empr; pmb_mysql_query($req); //On loggue les infos de la lettre $niveau_courant = $niveau_min; if ($niveau_courant) { $niveau_suppose = $level["level_normal"]; $cpt_id = comptes::get_compte_id_from_empr($id_empr, 2); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $frais_relance = $cpt->summarize_transactions("", "", 0, $realisee = -1); if ($frais_relance < 0) { $frais_relance = -$frais_relance; } else { $frais_relance = 0; } $req = "insert into log_retard (niveau_reel,niveau_suppose,amende_totale,frais,idempr,log_printed,log_mail) values('" . $niveau_courant . "','" . $niveau_suppose . "','" . $total_amende . "','" . $frais_relance . "','" . $id_empr . "', '" . $not_mail . "', '" . $mail_sended . "')"; pmb_mysql_query($req, $dbh); $id_log_ret = pmb_mysql_insert_id(); $reqexpl = "select pret_idexpl as expl from pret where pret_retour<\tCURDATE() and pret_idempr={$id_empr}"; $resexple = pmb_mysql_query($reqexpl, $dbh); while ($liste = pmb_mysql_fetch_object($resexple)) { $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour "; $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_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, " . $dates_resa_sql . ", "; $requete .= " 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_id='" . $liste->expl . "' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id "; $res_det_expl = pmb_mysql_query($requete); $expl = pmb_mysql_fetch_object($res_det_expl); if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amd = $amende->get_amende($liste->expl); } $req_ins = "insert into log_expl_retard (titre,expl_id,expl_cb,date_pret,date_retour,amende,num_log_retard) values('" . addslashes($expl->tit) . "','" . $expl->expl_id . "','" . $expl->expl_cb . "','" . $expl->pret_date . "','" . $expl->pret_retour . "','" . $amd["valeur"] . "','" . $id_log_ret . "')"; pmb_mysql_query($req_ins, $dbh); } } return $not_mail; }
function fetch_data() { global $dbh; global $msg; global $charset; global $val_list_empr; global $pmb_gestion_financiere, $pmb_gestion_abonnement, $pmb_gestion_tarif_prets, $pmb_gestion_amende; global $deflt_docs_location; if (!$this->id_empr || !$dbh) { return FALSE; } $requete = "SELECT e.*, c.libelle AS code1, s.libelle AS code2, es.statut_libelle AS empr_statut_libelle, allow_loan, allow_book, allow_opac, allow_dsi, allow_dsi_priv, allow_sugg, allow_prol, d.location_libelle as localisation, date_format(empr_date_adhesion, '" . $msg["format_date"] . "') as aff_empr_date_adhesion, date_format(empr_date_expiration, '" . $msg["format_date"] . "') as aff_empr_date_expiration FROM empr e left join docs_location as d on e.empr_location=d.idlocation, empr_categ c, empr_codestat s, empr_statut es "; $requete .= " WHERE e.id_empr='" . $this->id_empr . "' "; $requete .= " AND c.id_categ_empr=e.empr_categ"; $requete .= " AND s.idcode=e.empr_codestat"; $requete .= " AND es.idstatut=e.empr_statut"; $requete .= " LIMIT 1"; $result = pmb_mysql_query($requete, $dbh) or die(pmb_mysql_error() . " " . $requete); if (!pmb_mysql_num_rows($result)) { return FALSE; } $empr = pmb_mysql_fetch_object($result); // affectation des propriétés $this->empr_cb = $empr->empr_cb; // code barre emprunteur $this->empr_nom = $empr->empr_nom; // nom emprunteur $this->empr_prenom = $empr->empr_prenom; // prénom mprunteur $this->empr_adr1 = $empr->empr_adr1; // adresse ligne 1 $this->empr_adr2 = $empr->empr_adr2; // adresse ligne 2 $this->empr_cp = $empr->empr_cp; // code postal $this->empr_ville = $empr->empr_ville; // ville $this->empr_pays = $empr->empr_pays; // ville $this->empr_mail = $empr->empr_mail; // adresse email $this->empr_tel1 = $empr->empr_tel1; // téléphone 1 $this->empr_tel2 = $empr->empr_tel2; // téléphone 2 $this->empr_prof = $empr->empr_prof; // profession $this->empr_year = $empr->empr_year; // année de naissance $this->empr_categ = $empr->empr_categ; // catégorie emprunteur $this->empr_codestat = $empr->empr_codestat; // code statistique $this->empr_creation = $empr->empr_creation; // date de création $this->empr_modif = $empr->empr_modif; // date de modification $this->empr_sexe = $empr->empr_sexe; // sexe de l'emprunteur $this->empr_login = $empr->empr_login; // login pour services OPAC $this->empr_password = $empr->empr_password; // mot de passe OPAC $this->empr_ldap = $empr->empr_ldap; $this->type_abt = $empr->type_abt; // type d'abonnement $this->empr_location = $empr->empr_location; // localisation $this->empr_location_l = $empr->localisation; // localisation $this->date_fin_blocage = $empr->date_fin_blocage; // Date de fin de blocage de l'emprunteur $this->empr_statut = $empr->empr_statut; $this->empr_statut_l = $empr->empr_statut_libelle; $this->total_loans = $empr->total_loans; $this->date_adhesion = $empr->empr_date_adhesion; // début adhésion $this->date_expiration = $empr->empr_date_expiration; // fin adhésion $this->aff_date_adhesion = $empr->aff_empr_date_adhesion; // début adhésion $this->aff_date_expiration = $empr->aff_empr_date_expiration; // fin adhésion $this->empr_msg = $empr->empr_msg; // message emprunteur $this->cat_l = $empr->code1; // libellé catégorie emprunteur $this->cstat_l = $empr->code2; // libellé code statistique. voir ce bug avec Eric $this->allow_loan = $empr->allow_loan; $this->allow_book = $empr->allow_book; $this->allow_opac = $empr->allow_opac; $this->allow_dsi = $empr->allow_dsi; $this->allow_dsi_priv = $empr->allow_dsi_priv; $this->allow_sugg = $empr->allow_sugg; $this->allow_prol = $empr->allow_prol; global $selector_prop_ajout_caddie_empr, $empr_show_caddie; if ($empr_show_caddie) { $this->img_ajout_empr_caddie = "<img src='./images/basket_empr.gif' align='middle' alt='basket' title=\"{$msg[400]}\" onClick=\"openPopUp('./cart.php?object_type=EMPR&item=" . $this->id . "', 'cart', 600, 700, -2, -2, '{$selector_prop_ajout_caddie_empr}')\">"; } else { $this->img_ajout_empr_caddie = ""; } $this->lien_nom_prenom = "<a href='./circ.php?categ=pret&form_cb=" . rawurlencode($this->cb) . "'>{$this->nom}, {$this->prenom}</a>"; $date_blocage = array(); $date_blocage = explode("-", $this->date_fin_blocage); if (mktime(0, 0, 0, $date_blocage[1], $date_blocage[2], $date_blocage[0]) > time()) { $this->blocage_active = true; } //Groupes $requete = "select id_groupe, libelle_groupe from groupe, empr_groupe where empr_id='" . $this->id . "' and id_groupe=groupe_id"; $result = pmb_mysql_query($requete); if (pmb_mysql_num_rows($result)) { while ($grp_temp = pmb_mysql_fetch_object($result)) { $this->groupes[] = "<a href='./circ.php?categ=groups&action=showgroup&groupID=" . $grp_temp->id_groupe . "'>" . htmlentities($grp_temp->libelle_groupe, ENT_QUOTES, $charset) . "</a>"; } } else { $this->groupes = array(); } //Paramètres perso //Liste des champs $p_perso = new parametres_perso("empr"); $perso_ = $p_perso->show_fields($this->id_empr); $perso = ""; $class = "colonne3"; $c = 0; if (count($perso_["FIELDS"])) { for ($i = 0; $i < count($perso_["FIELDS"]); $i++) { $p = $perso_["FIELDS"][$i]; $perso .= "<div class='{$class}'>"; $perso .= "<div class='row'>" . $p["TITRE"]; $perso .= $p["AFF"] . "</div>"; $perso .= "</div>"; if ($c == 0) { $c = 1; } else { if ($c == 1) { $class = "colonne_suite"; $c = 2; } else { if ($c == 2) { $class = "colonne3"; $c = 0; } } } } $reste = 2 - $c; if ($c != 0) { for ($i = 0; $i < $reste; $i++) { $perso .= "<div class='colonne3'> </div>"; $c++; } $perso .= "<div class='colonne_suite'> </div>"; } } $this->perso = $perso; //Comptes si gestion financiere if ($pmb_gestion_financiere) { $compte = ""; $n_c = 0; $neg = "<span class='erreur'>%s</span>"; $pos = "%s"; $compte .= "<div class='row'><hr /></div><div class='row'>"; if ($pmb_gestion_abonnement) { $cpt_id = comptes::get_compte_id_from_empr($this->id, 1); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); if ($cpt_id) { $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=1'>" . $msg["finance_solde_abt"] . "</a></strong> " . comptes::format($solde) . "</div>"; if ($novalid) { $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>"; } $compte .= "</div>"; } $n_c++; } if ($pmb_gestion_tarif_prets) { $cpt_id = comptes::get_compte_id_from_empr($this->id, 3); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); if ($cpt_id) { $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=3'>" . $msg["finance_solde_pret"] . "</a></strong> " . comptes::format($solde) . "</div>"; if ($novalid) { $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>"; } $compte .= "</div>"; } $n_c++; } if ($pmb_gestion_amende) { $cpt_id = comptes::get_compte_id_from_empr($this->id, 2); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); if ($cpt_id) { //Calcul des amendes $amende = new amende($this->id); $total_amende = $amende->get_total_amendes(); $compte .= "<div class='colonne3'><div><strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=2'>" . $msg["finance_solde_amende"] . "</a></strong> " . comptes::format($solde) . "</div>"; if ($novalid) { $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>"; } if ($total_amende) { $compte .= "<div> " . $msg["finance_pret_amende_en_cours"] . " : " . comptes::format($total_amende) . "</div>"; } $compte .= "</div>"; } $n_c++; } if ($n_c < 2) { for ($i = $n_c; $i < 3; $i++) { $compte .= "<div class='colonne3'> </div>"; } } $compte .= "</div><div class='row'></div>"; } $this->compte = $compte; }
function del_pret() { global $dbh; global $msg, $pmb_blocage_retard, $pmb_blocage_delai, $pmb_blocage_coef, $pmb_blocage_max, $pmb_gestion_financiere, $pmb_gestion_amende; global $selfservice_retour_retard_msg, $selfservice_retour_blocage_msg, $selfservice_retour_amende_msg; global $alertsound_list; if (!$this->expl->pret_idempr) { return ''; } // calcul du retard éventuel $rqt_date = "select ((TO_DAYS(CURDATE()) - TO_DAYS('" . $this->expl->pret_retour . "'))) as retard "; $resultatdate = pmb_mysql_query($rqt_date); $resdate = pmb_mysql_fetch_object($resultatdate); $retard = $resdate->retard; if ($retard > 0) { //Calcul du vrai nombre de jours $date_debut = explode("-", $this->expl->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; $message .= "<br /><div class='erreur'>" . $msg[369] . " : " . $retard . " " . $msg[370] . "</div>"; $alertsound_list[] = "critique"; $this->message_retard = $selfservice_retour_retard_msg . " " . $msg[369] . " : " . $retard . " " . $msg[370]; } } //Calcul du blocage if ($pmb_blocage_retard) { $date_debut = explode("-", $this->expl->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 = pmb_mysql_result(pmb_mysql_query("select date_fin_blocage from empr where id_empr='" . $this->expl->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 pmb_mysql_query("update empr set date_fin_blocage='" . $date_fin . "' where id_empr='" . $this->expl->pret_idempr . "'"); $message .= "<br /><div class='erreur'>" . sprintf($msg["blocage_retard_pret"], formatdate($date_fin)) . "</div>"; $alertsound_list[] = "critique"; $this->message_blocage = sprintf($selfservice_retour_blocage_msg, formatdate($date_fin)); } else { $message .= "<br /><div class='erreur'>" . sprintf($msg["blocage_already_retard_pret"], formatdate($date_fin_blocage_empr)) . "</div>"; $alertsound_list[] = "critique"; $this->message_blocage = sprintf($selfservice_retour_blocage_msg, formatdate($date_fin_blocage_empr)); } } } //Vérification des amendes if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amende = new amende($this->expl->pret_idempr); $amende_t = $amende->get_amende($this->expl_id); //Si il y a une amende, je la débite if ($amende_t["valeur"]) { $message .= pmb_bidi("<br /><div class='erreur'>" . $msg["finance_retour_amende"] . " : " . comptes::format($amende_t["valeur"])); $this->message_amende = $selfservice_retour_amende_msg . " : " . comptes::format($amende_t["valeur"]); $alertsound_list[] = "critique"; $compte_id = comptes::get_compte_id_from_empr($this->expl->pret_idempr, 2); if ($compte_id) { $cpte = new comptes($compte_id); if ($cpte->id_compte) { $cpte->record_transaction("", $amende_t["valeur"], -1, sprintf($msg["finance_retour_amende_expl"], $this->expl_id), 0); $message .= " " . $msg["finance_retour_amende_recorded"]; } } $message .= "</div>"; $req = "delete from cache_amendes where id_empr=" . $this->expl->pret_idempr; pmb_mysql_query($req); } } $query = "delete from pret where pret_idexpl=" . $this->expl_id; if (!pmb_mysql_query($query, $dbh)) { return ''; } $query = "update empr set last_loan_date=sysdate() where id_empr='" . $this->expl->pret_idempr . "' "; @pmb_mysql_query($query, $dbh); $query = "update exemplaires set expl_lastempr='" . $this->expl->pret_idempr . "', last_loan_date=sysdate() where expl_id='" . $this->expl->expl_id . "' "; if (!pmb_mysql_query($query, $dbh)) { return ''; } $this->maj_stat_pret(); $this->empr = new emprunteur($this->expl->pret_idempr, $erreur_affichage, FALSE, 2); $this->expl->pret_idempr = 0; $this->flag_rendu = 1; return $message; }
public function get_data_empr($id_empr) { global $dbh, $pmb_gestion_financiere, $pmb_gestion_abonnement, $pmb_gestion_tarif_prets, $pmb_gestion_amende; $empr = get_info_empr($id_empr); $i = count($this->data["empr_list"]); $this->data["empr_list"][$i]["name"] = $empr->nom; $this->data["empr_list"][$i]["fistname"] = $empr->prenom; $this->data["empr_list"][$i]["cb"] = $empr->cb; $this->data["empr_list"][$i]["aff_date_adhesion"] = $empr->aff_date_adhesion; $this->data["empr_list"][$i]["aff_date_expiration"] = $empr->aff_date_expiration; $this->data["empr_list"][$i]["categorie"] = $empr->cat_l; if ($pmb_gestion_financiere) { $this->data["empr_list"][$i]["compte_abonnement"]["solde"] = ""; $this->data["empr_list"][$i]["compte_abonnement"]["novalid"] = ""; // abonnement if ($pmb_gestion_abonnement) { $cpt_id = comptes::get_compte_id_from_empr($id_empr, 1); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); $this->data["empr_list"][$i]["compte_abonnement"]["solde"] = $solde; $this->data["empr_list"][$i]["compte_abonnement"]["novalid"] = $novalid; } // prets $this->data["empr_list"][$i]["compte_pret"]["solde"] = ""; $this->data["empr_list"][$i]["compte_pret"]["novalid"] = ""; if ($pmb_gestion_tarif_prets) { $cpt_id = comptes::get_compte_id_from_empr($id_empr, 3); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); $this->data["empr_list"][$i]["compte_pret"]["solde"] = $solde; $this->data["empr_list"][$i]["compte_pret"]["novalid"] = $novalid; } // amendes $this->data["empr_list"][$i]["compte_amende"]["solde"] = ""; $this->data["empr_list"][$i]["compte_amende"]["novalid"] = ""; if ($pmb_gestion_amende) { $cpt_id = comptes::get_compte_id_from_empr($id_empr, 2); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); $this->data["empr_list"][$i]["compte_amende"]["solde"] = $solde; $this->data["empr_list"][$i]["compte_amende"]["novalid"] = $novalid; } // Autre compte $this->data["empr_list"][$i]["compte_autre"]["solde"] = ""; $this->data["empr_list"][$i]["compte_autre"]["novalid"] = ""; $transactype = new transactype_list(); if ($transactype->get_count()) { $cpt_id = comptes::get_compte_id_from_empr($id_empr, 4); $cpte = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); $this->data["empr_list"][$i]["compte_autre"]["solde"] = $solde; $this->data["empr_list"][$i]["compte_autre"]["novalid"] = $novalid; } } return $this->data["empr_list"][$i]; }
function expl_retard($cb_doc, $niveau = 0, $id_empr = 0) { global $msg, $dbh, $charset; global $pmb_gestion_financiere, $pmb_gestion_amende; $valeur = 0; $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour "; $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_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, " . $dates_resa_sql . ", "; $requete .= " 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='" . $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() . " {$requete}"); $expl = mysql_fetch_object($res); // 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; } $libelle = $expl->tdoc_libelle; $responsabilites = get_notice_authors($expl->m_id); //print_r($responsabilites); $as = array_keys($responsabilites["responsabilites"], "0"); 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; } if ($aut1_libelle) { $auteurs_liste = implode("; ", $aut1_libelle); if ($auteurs_liste) { $libelle .= ' / ' . $auteurs_liste; } } $libelle = $expl->tit . " (" . $libelle . ")"; $this->expl_info .= " \t<expl>\n"; $this->expl_info .= "\t\t<label>" . htmlspecialchars($libelle, ENT_QUOTES, $charset) . "</label>\n"; $this->expl_info .= "\t\t<loan_date>" . htmlspecialchars($expl->aff_pret_date, ENT_QUOTES, $charset) . "</loan_date>\n"; $this->expl_info .= "\t\t<return_date>" . htmlspecialchars($expl->aff_pret_retour, ENT_QUOTES, $charset) . "</return_date>\n"; $this->expl_info .= "\t\t<location>" . htmlspecialchars($expl->location_libelle, ENT_QUOTES, $charset) . "</location>\n"; $this->expl_info .= "\t\t<section>" . htmlspecialchars($expl->section_libelle, ENT_QUOTES, $charset) . "</section>\n"; $this->expl_info .= "\t\t<expl_cb>" . htmlspecialchars($expl->expl_cb, ENT_QUOTES, $charset) . "</expl_cb>\n"; $this->expl_info .= "\t\t<expl_cote>" . htmlspecialchars($expl->expl_cote, ENT_QUOTES, $charset) . "</expl_cote>\n"; $this->expl_info .= "\t\t<tdoc_label>" . htmlspecialchars($expl->tdoc_libelle, ENT_QUOTES, $charset) . "</tdoc_label>\n"; if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amende = new amende($expl->pret_idempr); $amd = $amende->get_amende($expl->expl_id); if ($amd["valeur"]) { $this->expl_info .= "\t\t<expl_fee>" . htmlspecialchars(comptes::format_simple($amd["valeur"]), ENT_QUOTES, $charset) . "</expl_fee>\n"; $valeur = $amd["valeur"]; } } if ($niveau) { $this->expl_info .= "\t\t<expl_niveau>3</expl_niveau>\n"; } if ($id_empr) { $req_empr = "select empr_nom as nom, empr_prenom as prenom from empr where id_empr={$id_empr}"; $res = mysql_query($req_empr, $dbh); $empr = mysql_fetch_object($res); $this->expl_info .= "<empr_surname>" . htmlspecialchars($empr->nom, ENT_QUOTES, $charset) . "</empr_surname>"; $this->expl_info .= "<empr_name>" . htmlspecialchars($empr->prenom, ENT_QUOTES, $charset) . "</empr_name>"; } $this->expl_info .= " \t</expl>\n"; return $valeur; }
function print_amendes($valeur, $frais_relance) { global $pmb_pdf_font, $ourPDF, $largeur_page, $marge_page_droite, $marge_page_gauche, $msg, $debut_expl_page; //Si il y a des amendes $ourPDF->SetY($ourPDF->GetY() + 2); $ourPDF->setFont($pmb_pdf_font, '', 10); $ourPDF->SetWidths(array(70, 30)); if ($ourPDF->GetY() > 260) { $ourPDF->addPage(); $ourPDF->SetY($debut_expl_page); } if ($valeur) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_total_amendes"], comptes::format_simple($valeur))); } if ($frais_relance) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_frais_relance"], comptes::format_simple($frais_relance))); } if ($frais_relance && $valeur) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_total_du"], comptes::format_simple($valeur + $frais_relance))); } $ourPDF->SetY($ourPDF->GetY() + 4); }
<?php // +-------------------------------------------------+ // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: list_transactions.php,v 1.5 2011-09-06 08:54:29 jpermanne Exp $ //Liste des trabsactions d'un compte $base_path = ".."; //$base_noheader=1; $current_alert = "circ"; require_once "../includes/init.inc.php"; require_once "{$base_path}/classes/comptes.class.php"; $cpte = new comptes($id_compte); if ($cpte->error) { print $cpte->error_message; exit; } switch ($show_transactions) { case "2": $t = $cpte->get_transactions("", "", 0, 0); break; case "3": $date_debut_ = extraitdate($date_debut); $t = $cpte->get_transactions($date_debut_, "", 0, -1, 0, "asc"); break; case "1": default: $t = $cpte->get_transactions("", "", 0, -1, 10); break; } print "<form name='form_transactions' action='encaissement.php' method='post' onSubmit='return false'>\n<input type='hidden' name='act' value=''/>\n<input type='hidden' name='id_compte' value='" . $id_compte . "'/>\n<input type='hidden' name='show_transactions' value='" . $show_transactions . "'/>\n<input type='hidden' name='date_debut' value='" . htmlentities($date_debut, ENT_QUOTES, $charset) . "'/>\n";