function add_pret($id_empr, $id_expl, $cb_doc) { // le lien MySQL global $dbh; global $msg; global $pmb_quotas_avances; /* on prépare la date de début*/ $pret_date = time(); /* on cherche la durée du prêt */ 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 $pret_retour = $pret_date + 3600 * 24 * $duree_pret; // 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("Y-m-d", $pret_retour) . "', "; $query .= "retour_initial = '" . date("Y-m-d", $pret_retour) . "' "; $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); $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 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); }
if ($opac_pret_prolongation == 1 && $allow_prol) { $prolongation = TRUE; $expl_id = $data['expl_id']; $query = "select cpt_prolongation, pret_date,pret_retour, expl_location from pret, exemplaires where expl_id=pret_idexpl and pret_idexpl='" . $data['expl_id'] . "'"; $result = pmb_mysql_query($query, $dbh); $data_expl = pmb_mysql_fetch_array($result); $nb_prolongation = $cpt_prolongation = $data_expl['cpt_prolongation']; $cpt_prolongation++; $duree_prolongation = $opac_pret_duree_prolongation; $today = sql_value("SELECT CURRENT_DATE()"); if ($pmb_pret_restriction_prolongation > 0) { $pret_nombre_prolongation = $pmb_pret_nombre_prolongation; if ($pmb_pret_restriction_prolongation == 2) { // Limitation du pret par les quotas //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $pret_nombre_prolongation = $qt->get_quota_value($struct); } } $worksheet->write($line, $x + 5, $nb_prolongation . "/" . $pret_nombre_prolongation); } } } } else { // fin du if nb_elements switch ($lvl) { case 'all': if (!$dest) {
function check_quota_resa($id_empr, $id_notice, $id_bulletin) { global $dbh; global $msg; global $pmb_quotas_avances; global $_quotas_elements_; global $pmb_resa_quota_pret_depasse; //Initialisation résultat $error = array(); $error["ERROR"] = false; //Si les quotas avancés sont autorisés if ($pmb_quotas_avances) { $struct = array(); //Quota de notice ou bulletin ? if ($id_notice) { $quota_type = "BOOK_NMBR_QUOTA"; $struct["NOTI"] = $id_notice; $elt_name = "NOTICETYPE"; } else { $quota_type = "BOOK_NMBR_SERIAL_QUOTA"; $struct["BULL"] = $id_bulletin; $elt_name = "BULLETINTYPE"; } //Initialisation du quota $qt = new quota($quota_type); $struct["READER"] = $id_empr; //Si résa bloquée en cas de dépassement de quota de prêt if (!$pmb_resa_quota_pret_depasse) { //Le quota de prêt est-il atteint pour cette notice ou bulletin //Récupération de l'élément indirect à tester $elt = $qt->get_element_by_name($elt_name); //Récupération de l'exemplaire le plus défavorable associé à la réservation $object_id = $qt->get_object_for_indirect_element($_quotas_elements_[$elt], $struct); //Initialisation du quota de prêt $qt_pret = new quota("LEND_NMBR_QUOTA"); $struct_pret["READER"] = $id_empr; $struct_pret["EXPL"] = $object_id; $r = $qt_pret->check_quota($struct_pret); } else { $r = false; } //Si quota de prêt non violé alors on regarde les quotas de réservation if (!$r) { //Vérification $r = $qt->check_quota($struct); //Si quota violé if ($r) { $error["ERROR"] = true; //Erreur $error["MESSAGE"] = $qt->error_message; //Peut-on forcer ou pas la résa $error["FORCE"] = $qt->force; return $error; } } else { $error["ERROR"] = true; //Erreur $error["MESSAGE"] = $qt_pret->error_message . "<br />" . $msg["resa_quota_pret_error"]; //Peut-on forcer ou pas la résa $r_force = $qt->check_quota($struct); if ($r_force) { $error["FORCE"] = $qt->force; } else { $error["FORCE"] = 0; } return $error; } return $error; } else { return $error; } }
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); }
$list_statut .= ">" . htmlentities($r->statut_libelle, ENT_QUOTES, $charset) . "</option>\n"; } $list_statut .= "</select>\n"; $finance_amende_relance_form = str_replace("!!statut_perdu!!", $list_statut, $finance_amende_relance_form); print $finance_amende_relance_form; break; default: //Gestion simple show_amende_parameters(); break; } } else { $menu_sous_rub = $msg["finance_amendes"]; //Gestion par quotas if ($quota) { $qt = new quota($quota, "{$include_path}/quotas/own/{$lang}/finances.xml"); } else { quota::parse_quotas("{$include_path}/quotas/own/{$lang}/finances.xml"); } $admin_menu_quotas = "<span><a href='./admin.php?categ=finance&sub=amendes_relance&action=edit_loststatus'>" . $msg["finance_statut_perdu_expl_empr"] . "</a></span> "; for ($i = 0; $i < count($_quotas_types_); $i++) { if ($_quotas_types_[$i]["FILTER_ID"] == "amende_relance") { $admin_menu_quotas .= "<span><a href='./admin.php?categ=finance&sub=amendes_relance"a=" . $_quotas_types_[$i]["ID"] . "'>" . $_quotas_types_[$i]["SHORT_COMMENT"] . "</a></span>\n"; if ($quota == $_quotas_types_[$i]["ID"]) { $menu_sous_rub .= " > " . $_quotas_types_[$i]["SHORT_COMMENT"]; if ($elements) { $menu_sous_rub .= " > " . $qt->get_title_by_elements_id($elements); } } } }
function do_sel_list() { global $tpl_opac_view_list_sel_tableau, $tpl_opac_view_list_sel_tableau_ligne; global $pmb_opac_view_class; global $base_path, $include_path, $lang, $msg; global $charset; // on reprend... global $pmb_opac_view_activate; $j = 0; $list = $disabled = ""; //on a une classe spécifique pour la gestion des vues... //on ne peut pas proposer le forcage, mais on peut peut etre afficher les valeurs if ($pmb_opac_view_class) { $tpl = "\n\t\t<div class='row'>" . htmlentities($msg['opac_view_class_exists'], ENT_QUOTES, $charset) . "</div>"; } else { if ($pmb_opac_view_activate == 2) { //définition en administration, on va chercher les valeurs... $qt = new quota("OPAC_VIEW", $include_path . "/quotas/own/" . $lang . "/opac_views.xml"); //Tableau de passage des paramètres if ($this->id_empr) { $struct["READER"] = $this->id_empr ? $this->id_empr : 0; $values = $qt->get_quota_value_with_id($struct); } else { $values = $qt->apply_conflict(array("")); } if ($values['VALUE']) { $allowed = unserialize($values['VALUE']); } //on a peut etre déjà forcer if (count($this->view_list_empr) == 0) { $disabled = "disabled='disabled'"; } } //OPAC Classique $line = str_replace('!!class!!', "even", $tpl_opac_view_list_sel_tableau_ligne); $line = str_replace('!!name!!', $msg['opac_view_classic_opac'], $line); $line = str_replace('!!comment!!', $msg['opac_view_classic_opac_comment'], $line); $line = str_replace('!!opac_view_id!!', 0, $line); $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='even'\" "; $line = str_replace('!!tr_surbrillance!!', $tr_surbrillance, $line); if ($disabled == "") { if (in_array(0, $this->view_list_empr) || !count($this->view_list_empr)) { $checked = "checked='checked'"; } else { $checked = ""; } $line = str_replace("!!checked!!", $checked, $line); if ($this->view_list_empr_default == 0) { $checked_default = "checked='checked'"; } else { $checked_default = ""; } $line = str_replace("!!radio_checked!!", $checked_default, $line); $line = str_replace("!!disabled!!", $disabled, $line); } else { if (in_array(0, $allowed['allowed'])) { $checked = "checked='checked'"; } else { $checked = ""; } $line = str_replace("!!checked!!", $checked, $line); if ($allowed['default'] == 0) { $checked_default = "checked='checked'"; } else { $checked_default = ""; } $line = str_replace("!!radio_checked!!", $checked_default, $line); } $line = str_replace("!!disabled!!", $disabled, $line); $liste .= $line; //Pour les vues for ($i = 0; $i < count($this->opac_views_list); $i++) { if ($this->opac_views_list[$i]->visible == 0) { continue; } if ($this->opac_views_list[$i]->visible > 0) { $j++; } $line = str_replace('!!class!!', $j % 2 ? "odd" : "even", $tpl_opac_view_list_sel_tableau_ligne); $line = str_replace('!!name!!', $this->opac_views_list[$i]->name, $line); $line = str_replace('!!comment!!', $this->opac_views_list[$i]->comment, $line); $line = str_replace('!!opac_view_id!!', $this->opac_views_list[$i]->id, $line); $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='" . ($j % 2 ? "odd" : "even") . "'\" "; $line = str_replace('!!tr_surbrillance!!', $tr_surbrillance, $line); //gestion simple ou forçage pour l'utilisateur... if ($disabled == "") { if (in_array($this->opac_views_list[$i]->id, $this->view_list_empr)) { $checked = "checked='checked'"; } else { $checked = ""; } $line = str_replace("!!checked!!", $checked, $line); if ($this->view_list_empr_default == $this->opac_views_list[$i]->id) { $checked_default = "checked='checked'"; } else { $checked_default = ""; } $line = str_replace("!!radio_checked!!", $checked_default, $line); } else { if (in_array($this->opac_views_list[$i]->id, $allowed['allowed'])) { $checked = "checked='checked'"; } else { $checked = ""; } $line = str_replace("!!checked!!", $checked, $line); if ($allowed['default'] == $this->opac_views_list[$i]->id) { $checked_default = "checked='checked'"; } else { $checked_default = ""; } $line = str_replace("!!radio_checked!!", $checked_default, $line); } $line = str_replace("!!disabled!!", $disabled, $line); $liste .= $line; } $tpl = str_replace('!!lignes_tableau!!', $liste, $tpl_opac_view_list_sel_tableau); if ($pmb_opac_view_activate == 2 && !$pmb_opac_view_class) { $forcage = "\n\t\t\t<label for='force'>" . $msg['opac_view_allow_force'] . "</label> \n\t\t\t " . $msg['40'] . "<input type='radio' name='force_opac_view_choice' onclick='allow_forcage();' value='1' " . ($disabled != "" ? "" : "checked") . "/>\n\t\t\t " . $msg['39'] . "<input type='radio' name='force_opac_view_choice' onclick='disable_forcage();' value='0' " . ($disabled == "" ? "" : "checked") . "/>\n\t\t\t<script type='text/javascript'>\n\t\t\t\tfunction allow_forcage(){\n\t\t\t\t\tvar checkboxes = document.forms.empr_form['form_empr_opac_view[]'];\n\t\t\t\t\tvar radios = document.forms.empr_form['form_empr_opac_view_default'];\n\t\t\t\t\tfor (var i=0 ; i<checkboxes.length ; i++){\n\t\t\t\t\t\tcheckboxes[i].disabled= false;\n\t\t\t\t\t}\n\t\t\t\t\tfor (var i=0 ; i<radios.length ; i++){\n\t\t\t\t\t\tradios[i].disabled= false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfunction disable_forcage(){\n\t\t\t\t\tvar selected_views = new Array();"; foreach ($allowed['allowed'] as $view) { $forcage .= "\n\t\t\t\t\tselected_views.push(" . $view . ")"; } $forcage .= "\n\t\t\t\t\tvar checkboxes = document.forms.empr_form['form_empr_opac_view[]'];\n\t\t\t\t\tvar radios = document.forms.empr_form['form_empr_opac_view_default'];\n\t\t\t\t\tfor (var i=0 ; i<checkboxes.length ; i++){\n\t\t\t\t\t\tvar selected = false;\n\t\t\t\t\t\tfor(key in selected_views){\n\t\t\t\t\t\t\tif(checkboxes[i].value == selected_views[key]){\n\t\t\t\t\t\t\t\tselected = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcheckboxes[i].disabled= true;\n\t\t\t\t\t\tif(selected){\n\t\t\t\t\t\t\tcheckboxes[i].checked = true;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tcheckboxes[i].checked = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (var i=0 ; i<radios.length ; i++){\n\t\t\t\t\t\tradios[i].disabled= true;\n\t\t\t\t\t\tif(radios[i].value == " . $allowed['default'] . "){\n\t\t\t\t\t\t\tradios[i].checked = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t</script>"; } else { $forcage = ""; } $tpl = str_replace("!!forcage!!", $forcage, $tpl); } return $tpl; }
function _renew_response_($values) { global $opac_pret_prolongation, $opac_pret_duree_prolongation, $pmb_pret_restriction_prolongation, $pmb_pret_nombre_prolongation, $dbh, $msg; global $selfservice_pret_prolonge_non_msg; global $protocol_prolonge; $empr_cb = $values["PATRON_IDENTIFIER"][0]; $expl_cb = $values["ITEM_IDENTIFIER"][0]; $localisation = $values["INSTITUTION_ID"][0]; $magnetic = "N"; $desensitize = "N"; $titre = $expl_cb; $due_date = ""; $ok = 1; $prolonge = "Y"; if ($opac_pret_prolongation) { $prolongation = TRUE; $requete = "select expl_id,id_empr, expl_bulletin,expl_notice,type_antivol,empr_cb from exemplaires join pret on (expl_id=pret_idexpl) join empr on (pret_idempr=id_empr) where expl_cb='" . addslashes($expl_cb) . "'"; $resultat = pmb_mysql_query($requete); if (!$resultat) { $error_message = "Le document n'existe pas ou n'est pas en prêt!"; } else { $expl = pmb_mysql_fetch_object($resultat); $expl_id = $expl->expl_id; $id_empr = $expl->id_empr; //on recupere les informations du pret $query = "select cpt_prolongation, retour_initial, pret_date, pret_retour from pret where pret_idexpl=" . $expl_id . " limit 1"; $result = pmb_mysql_query($query, $dbh); $data = pmb_mysql_fetch_array($result); $cpt_prolongation = $data['cpt_prolongation']; $retour_initial = $data['retour_initial']; $cpt_prolongation++; $duree_prolongation = $opac_pret_duree_prolongation; $today = sql_value("SELECT CURRENT_DATE()"); if ($pmb_pret_restriction_prolongation == 0) { // Aucune limitation des prolongations $prolongation = true; $duree_prolongation = $opac_pret_duree_prolongation; } else { if ($pmb_pret_restriction_prolongation > 0) { $pret_nombre_prolongation = $pmb_pret_nombre_prolongation; if ($pmb_pret_restriction_prolongation == 1 && $cpt_prolongation > $pret_nombre_prolongation) { // Limitation simple de la prolongation $prolongation = FALSE; } else { if ($pmb_pret_restriction_prolongation == 2) { // Limitation du pret par les quotas //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $pret_nombre_prolongation = $qt->get_quota_value($struct); if ($cpt_prolongation > $pret_nombre_prolongation) { $prolongation = FALSE; } //Initialisation des quotas la durée de prolongations $qt = new quota("PROLONG_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $duree_prolongation = $qt->get_quota_value($struct); } } // fin if gestion par quotas } } $date_prolongation = sql_value("SELECT DATE_ADD('{$retour_initial}', INTERVAL {$duree_prolongation} DAY)"); $diff = sql_value("SELECT DATEDIFF('{$retour_initial}','{$today}')"); if ($diff < -$duree_prolongation || $diff > $duree_prolongation) { $prolongation = FALSE; } // Recherche de la nouvelle date de retour $req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='" . $data['expl_location'] . "' order by date_ouverture asc"; $res_date_calendrier = pmb_mysql_query($req_date_calendrier); while ($date_calendrier = pmb_mysql_fetch_object($res_date_calendrier)) { $ecart = sql_value("SELECT DATEDIFF('{$date_calendrier->date_ouverture}','{$date_prolongation}')"); if ($ecart >= 0) { $date_prolongation = $date_calendrier->date_ouverture; break; } } if ($prolongation == TRUE) { // Memorisation de la nouvelle date de prolongation $query = "update pret set cpt_prolongation='" . $cpt_prolongation . "', pret_retour='" . $date_prolongation . "' where pret_idexpl=" . $expl_id; $result = pmb_mysql_query($query, $dbh); $due_date = $date_prolongation; $due_date = sql_value("select date_format('{$date_prolongation}', '" . $msg["format_date"] . "')"); //$due_date=@pmb_mysql_result($resultat,0,0); } else { $error_message = "{$selfservice_pret_prolonge_non_msg}"; } } } else { $error_message = "Prolongation non activée"; } if ($error_message) { //Attention, pour les deux lignes suivantes, cela dépend d'un paramètre NEDAP ou IDENT if ($protocol_prolonge) { $ok = 0; $prolonge = "N"; } $ret["SCREEN_MESSAGE"][0] = $error_message; } $ret["OK"] = $ok; $ret["RENEWAL_OK"] = $prolonge; $ret["MAGNETIC_MEDIA"] = $magnetic; $ret["DESENSITIZE"] = $desensitize; $ret["TRANSACTION_DATE"] = date("Ymd His", time()); $ret["INSTITUTION_ID"][0] = $localisation; $ret["PATRON_IDENTIFIER"][0] = $empr_cb; $ret["ITEM_IDENTIFIER"][0] = $expl_cb; $ret["TITLE_IDENTIFIER"][0] = $titre; $ret["DUE_DATE"][0] = $due_date; return $ret; }
function do_action($id_empr) { global $pmb_gestion_amende, $lang, $include_path; global $finance_recouvrement_lecteur_statut; $action = "action_" . $id_empr; global ${$action}, $msg, $charset, $finance_statut_perdu; $act = ${$action}; //Récupération du solde du compte $frais_relance = 0; $id_compte = comptes::get_compte_id_from_empr($id_empr, 2); if ($id_compte) { $cpte = new comptes($id_compte); $frais_relance = $cpte->summarize_transactions("", "", 0, $realisee = -1); if ($frais_relance && $frais_relance < 0) { $frais_relance = -$frais_relance; } else { $frais_relance = 0; } } //Si action différent de zéro, alors changement $quatre = false; if ($act != 0) { //Récupération de la liste des prêts $amende = new amende($id_empr); // on efface le cache pour qu'il soit remis à jour au prochain accès $req = "delete from cache_amendes where id_empr={$id_empr} "; pmb_mysql_query($req); $montant_total = 0; for ($j = 0; $j < count($amende->t_id_expl); $j++) { $params = $amende->t_id_expl[$j]; //Si c'est juste un changement de niveau if ($act < 4) { //Si il y a attente de changement d'état if ($params["amende"]["niveau_relance"] < $params["amende"]["niveau"]) { //Si le niveau attendu est supérieur ou égal au niveau demandé if ($params["amende"]["niveau"] >= $act) { //On passe au niveau demandé $niveau = $act; } else { //Sinon on passe au niveau prévu $niveau = $params["amende"]["niveau"]; } //Enregistrement du changement de niveau $requete = "update pret set niveau_relance={$niveau}, date_relance=now(), printed=0 where pret_idempr={$id_empr} and pret_idexpl=" . $params["id_expl"]; pmb_mysql_query($requete); } //Si le niveau supposé est inférieur au dernier niveau validé (ex : prolongations,...), on peut revenir.. if ($params["amende"]["niveau"] < $params["amende"]["niveau_relance"]) { if ($params["amende"]["niveau_relance"] >= $act) { //On passe au niveau demandé $niveau = $act; } else { //Sinon on passe au niveau prévu $niveau = $params["amende"]["niveau"]; } //Enregistrement du changement de niveau $requete = "update pret set niveau_relance={$niveau}, date_relance=now(), printed=0 where pret_idempr={$id_empr} and pret_idexpl=" . $params["id_expl"]; pmb_mysql_query($requete); } } else { //Sinon, c'est plus grave, on passe en recouvrement !! $quatre = true; //Si niveau prévu = 4 if ($params["amende"]["niveau"] == 4) { //Passage des ouvrages en statut perdu $requete = "update exemplaires set expl_statut={$finance_statut_perdu} where expl_id=" . $params["id_expl"]; pmb_mysql_query($requete); //Débit du compte lecteur + tarif des relances $debit = $amende->get_amende($params["id_expl"]); $debit = $debit["valeur"]; $id_compte = comptes::get_compte_id_from_empr($id_empr, 2); if ($id_compte) { //&&($debit) $compte = new comptes($id_compte); //Enregistrement transaction $id_transaction = $compte->record_transaction("", $debit, -1, sprintf($msg["relance_recouvr_transaction"], $params["id_expl"]), 0); //Validation $compte->validate_transaction($id_transaction); $montant_total += $debit; $requete = "select pret_date from pret where pret_idexpl=" . $params["id_expl"]; $resultat = pmb_mysql_query($requete); $r = pmb_mysql_fetch_object($resultat); $req_pret_date = ", date_pret='" . $r->pret_date . "' "; $requete = "select log.date_log as date_log, log.niveau_reel as niv\n\t\t\t\t\t\tfrom log_expl_retard as expl,log_retard as log \n\t\t\t\t\t\twhere expl.num_log_retard=log.id_log and log.idempr={$id_empr} and expl.expl_id=" . $params["id_expl"] . " order by log.date_log limit 3"; $res = pmb_mysql_query($requete); $req_date_relance = ""; $i = 1; while ($log = pmb_mysql_fetch_object($res)) { $req_date_relance .= ", date_relance" . $i++ . "='" . $log->date_log . "' "; } $requete = "insert into recouvrements set empr_id={$id_empr}, id_expl=" . $params["id_expl"] . ", date_rec= now(), libelle='',recouvr_type=0, montant='{$debit}' {$req_pret_date} {$req_date_relance}"; pmb_mysql_query($requete); // Essayer de retrouver le prix de l'exemplaire $requete = "select expl_prix, prix from exemplaires, notices where (notice_id=expl_notice or notice_id=expl_bulletin) and expl_id =" . $params["id_expl"]; $resultat = pmb_mysql_query($requete); $prix = 0; if ($r = pmb_mysql_fetch_object($resultat)) { if (!($prix = 1 * $r->expl_prix)) { $prix = 1 * $r->prix; } } $requete = "insert into recouvrements set empr_id={$id_empr}, id_expl=" . $params["id_expl"] . ", date_rec=now(), libelle='', recouvr_type=1, montant='{$prix}' {$req_pret_date} {$req_date_relance}"; pmb_mysql_query($requete); // on modifie le status du lecteur si demandé if ($finance_recouvrement_lecteur_statut) { $requete = "update empr set empr_statut={$finance_recouvrement_lecteur_statut} where id_empr={$id_empr}"; pmb_mysql_query($requete); } } //Supression du pret $requete = "delete from pret where pret_idexpl=" . $params["id_expl"]; pmb_mysql_query($requete); $requete = "update exemplaires set expl_note=concat(expl_note,' ','" . $msg["relance_non_rendu_expl"] . "'),expl_lastempr='" . $id_empr . "' where expl_id=" . $params["id_expl"]; pmb_mysql_query($requete); $requete = "update empr set empr_msg=trim(concat(empr_msg,' ','" . addslashes($msg["relance_recouvrement"]) . "')) where id_empr=" . $id_empr; pmb_mysql_query($requete); } } //Ajout solde du compte amendes if ($quatre) { if ($frais_relance) { $requete = "insert into recouvrements (empr_id,id_expl,date_rec,libelle,montant) values({$id_empr},0,now(),'" . $msg["relance_frais_relance"] . "'," . $frais_relance . ")"; pmb_mysql_query($requete); $montant_total += $frais_relance; } //Passage en perte pour la bibliothèque //Débit sur le compte 0 //if ($montant_total) { // $requete="insert into transactions (compte_id,user_id,user_name,machine,date_enrgt,date_prevue,date_effective,montant,sens,realisee,commentaire,encaissement) values(0,$PMBuserid,'".$PMBusername."','".$_SERVER["REMOTE_ADDR"]."', now(), now(), now(), ".($montant_total*1).", -1, 1,'Recouvrement lecteur : ".$params["id_expl"]."',0)"; // pmb_mysql_query($requete); //} } } //Traitement des frais $niveau_min = $act; $the_frais = 0; if ($pmb_gestion_amende == 1) { $frais = "finance_relance_" . $niveau_min; global ${$frais}; $the_frais = ${$frais}; } else { $quota_name = ""; switch ($niveau_min) { case 1: $quota_name = "AMENDERELANCE_FRAISPREMIERERELANCE"; break; case 2: $quota_name = "AMENDERELANCE_FRAISDEUXIEMERELANCE"; break; case 3: $quota_name = "AMENDERELANCE_FRAISTROISIEMERELANCE"; break; default: break; } $qt = new quota($quota_name, "{$include_path}/quotas/own/{$lang}/finances.xml"); $struct["READER"] = $id_empr; $the_frais = $qt->get_quota_value($struct); if ($the_frais == -1) { $the_frais = 0; } } if ($the_frais) { if ($id_compte) { $compte = new comptes($id_compte); //Enregistrement transaction $cpte->record_transaction("", $the_frais, -1, sprintf($msg["relance_frais_relance_level"], $niveau_min)); } } } }
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 self_renew($expl_cb, $PMBUserId = -1) { global $opac_pret_prolongation, $opac_pret_duree_prolongation, $pmb_pret_restriction_prolongation, $pmb_pret_nombre_prolongation, $dbh, $msg; global $selfservice_pret_prolonge_non_msg; $titre = $expl_cb; $error_message = ""; $due_date = date("Ymd His", time()); $ok = 1; $ret["status"] = ""; if ($opac_pret_prolongation) { $prolongation = TRUE; $requete = "select expl_id,id_empr, expl_bulletin,expl_notice,type_antivol,empr_cb from exemplaires join pret on (expl_id=pret_idexpl) join empr on (pret_idempr=id_empr) where expl_cb='" . addslashes($expl_cb) . "'"; $resultat = mysql_query($requete); if (!$resultat) { $error_message = "Le document n'existe pas ou n'est pas en prêt!"; } else { $expl = mysql_fetch_object($resultat); $expl_id = $expl->expl_id; $id_empr = $expl->id_empr; //on recupere les informations du pret $query = "select cpt_prolongation, retour_initial, pret_date, pret_retour from pret where pret_idexpl=" . $expl_id . " limit 1"; $result = mysql_query($query, $dbh); $data = mysql_fetch_array($result); $cpt_prolongation = $data['cpt_prolongation']; $retour_initial = $data['retour_initial']; $cpt_prolongation++; $duree_prolongation = $opac_pret_duree_prolongation; $today = sql_value("SELECT CURRENT_DATE()"); if ($pmb_pret_restriction_prolongation == 0) { // Aucune limitation des prolongations $prolongation = true; $duree_prolongation = $opac_pret_duree_prolongation; } else { if ($pmb_pret_restriction_prolongation > 0) { $pret_nombre_prolongation = $pmb_pret_nombre_prolongation; if ($pmb_pret_restriction_prolongation == 1 && $cpt_prolongation > $pret_nombre_prolongation) { // Limitation simple de la prolongation $prolongation = FALSE; } else { if ($pmb_pret_restriction_prolongation == 2) { // Limitation du pret par les quotas //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $pret_nombre_prolongation = $qt->get_quota_value($struct); if ($cpt_prolongation > $pret_nombre_prolongation) { $prolongation = FALSE; } //Initialisation des quotas la durée de prolongations $qt = new quota("PROLONG_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $duree_prolongation = $qt->get_quota_value($struct); } } // fin if gestion par quotas } } $date_prolongation = sql_value("SELECT DATE_ADD('{$retour_initial}', INTERVAL {$duree_prolongation} DAY)"); $diff = sql_value("SELECT DATEDIFF('{$retour_initial}','{$today}')"); if ($diff < -$duree_prolongation || $diff > $duree_prolongation) { $prolongation = FALSE; } // Recherche de la nouvelle date de retour $req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='" . $data['expl_location'] . "' order by date_ouverture asc"; $res_date_calendrier = mysql_query($req_date_calendrier); while ($date_calendrier = mysql_fetch_object($res_date_calendrier)) { $ecart = sql_value("SELECT DATEDIFF('{$date_calendrier->date_ouverture}','{$date_prolongation}')"); if ($ecart >= 0) { $date_prolongation = $date_calendrier->date_ouverture; break; } } if ($prolongation == TRUE) { // Memorisation de la nouvelle date de prolongation $query = "update pret set cpt_prolongation='" . $cpt_prolongation . "', pret_retour='" . $date_prolongation . "' where pret_idexpl=" . $expl_id; $result = mysql_query($query, $dbh); $due_date = $date_prolongation; $due_date = sql_value("select date_format('{$date_prolongation}', '" . $msg["format_date"] . "')"); //$due_date=@mysql_result($resultat,0,0); } else { $ok = 0; $error_message = "{$selfservice_pret_prolonge_non_msg}"; } } } else { $error_message = "Prolongation non activée"; } if ($charset != "utf-8") { $error_message = utf8_encode($error_message); } $ret["status"] = $ok; $ret["message"] = $error_message; $ret["transaction_date"] = date("Ymd His", time()); if ($charset != "utf-8") { $ret["title"] = utf8_encode($titre); } else { $ret["title"] = $titre; } $ret["due_date"] = $due_date; return $ret; }
function quota($type_id = "", $descriptor = "") { global $_parsed_quotas_; global $lang; global $include_path; global $_quotas_table_; if ($descriptor == "") { $this->descriptor = $include_path . "/quotas/{$lang}.xml"; } else { $this->descriptor = $descriptor; } if (!$_parsed_quotas_[$this->descriptor]) { quota::parse_quotas($this->descriptor); } $this->table = $_quotas_table_; if ($type_id != "") { $this->type_id = $type_id; $this->quota_type = $this->get_quota_type_by_id($type_id); if (count($this->quota_type) == 0) { $this->quota_type = $this->get_quota_type_by_name($type_id); } } }
function do_fiche() { global $empr_tmpl, $empr_pret_allowed; global $msg, $charset; global $groupID; global $biblio_email; global $pmb_lecteurs_localises; global $pmb_gestion_abonnement, $pmb_gestion_financiere, $pmb_gestion_tarif_prets, $pmb_gestion_amende; global $finance_blocage_abt, $finance_blocage_amende, $finance_blocage_pret, $pmb_blocage_retard, $pmb_blocage_retard_force; global $force_finance; global $pmb_resa_planning; global $dbh; global $pmb_blocage_retard, $pmb_blocage_coef, $pmb_blocage_max, $pmb_blocage_delai; global $empr_fiche_depliee; global $pmb_opac_view_activate; global $pmb_sur_location_activate; global $alert_sound_list; // l'utilisateur veut-il les sons d'alerte global $pmb_short_loan_management; $this->fiche = $empr_tmpl; $this->fiche = str_replace('!!cb!!', $this->cb, $this->fiche); $this->fiche = str_replace('!!nom!!', pmb_strtoupper($this->nom), $this->fiche); $this->fiche = str_replace('!!prenom!!', $this->prenom, $this->fiche); $this->fiche = str_replace('!!image_caddie_empr!!', $this->img_ajout_empr_caddie, $this->fiche); $this->fiche = str_replace('!!info_nb_pret!!', $this->nb_pret, $this->fiche); $this->fiche = str_replace('!!info_nb_resa!!', $this->nb_reservations, $this->fiche); if ($pmb_resa_planning) { $this->fiche = str_replace('!!info_resa_planning!!', $msg[empr_nb_resa_planning] . ":" . $this->nb_previsions, $this->fiche); } else { $this->fiche = str_replace('!!info_resa_planning!!', "", $this->fiche); } $this->fiche = str_replace('!!info_authldap!!', $this->ldap, $this->fiche); $this->fiche = str_replace('!!id!!', $this->id, $this->fiche); $this->fiche = str_replace('!!adr1!!', $this->adr1, $this->fiche); $this->fiche = str_replace('!!adr2!!', $this->adr2, $this->fiche); $this->fiche = str_replace('!!tel1!!', $this->tel1, $this->fiche); $this->fiche = str_replace('!!sms!!', $this->sms, $this->fiche); $this->fiche = str_replace('!!tel2!!', $this->tel2, $this->fiche); $this->fiche = str_replace('!!cp!!', $this->cp, $this->fiche); $this->fiche = str_replace('!!ville!!', $this->ville, $this->fiche); $this->fiche = str_replace('!!pays!!', $this->pays, $this->fiche); $emails = array(); $email_final = array(); $emails = explode(';', $this->mail); for ($i = 0; $i < count($emails); $i++) { $email_final[] = "<a href='mailto:" . $emails[$i] . "'>" . $emails[$i] . "</a>"; } $this->fiche = str_replace('!!mail_all!!', implode(" ", $email_final), $this->fiche); $this->fiche = str_replace('!!prof!!', $this->prof, $this->fiche); $this->fiche = str_replace('!!date!!', $this->birth, $this->fiche); $this->fiche = str_replace('!!categ!!', $this->cat_l, $this->fiche); $this->fiche = str_replace('!!codestat!!', $this->cstat_l, $this->fiche); $this->fiche = str_replace('!!adhesion!!', $this->aff_date_adhesion, $this->fiche); $this->fiche = str_replace('!!expiration!!', $this->aff_date_expiration, $this->fiche); $this->fiche = str_replace('!!last_loan_date!!', $this->aff_last_loan_date, $this->fiche); $this->fiche = str_replace('!!perso!!', $this->perso, $this->fiche); $this->fiche = str_replace('!!header_format!!', $this->header_format, $this->fiche); $this->fiche = str_replace('!!empr_login!!', $this->login, $this->fiche); if ($this->pwd) { $this->fiche = str_replace('!!empr_pwd!!', "<i><strong>" . $msg["empr_pwd_opac_affected"] . "</strong></i>", $this->fiche); } else { $this->fiche = str_replace('!!empr_pwd!!', "", $this->fiche); } $this->fiche = str_replace('!!comptes!!', $this->compte, $this->fiche); $this->fiche = str_replace('!!empr_statut_libelle!!', $this->empr_statut_libelle, $this->fiche); $this->fiche = str_replace('!!empr_picture!!', $this->picture_empr($this->cb), $this->fiche); if ($empr_fiche_depliee == "1") { $this->fiche = str_replace('!!depliee!!', " startOpen=\"Yes\"", $this->fiche); } else { $this->fiche = str_replace('!!depliee!!', "", $this->fiche); } if ($pmb_lecteurs_localises) { $this->fiche = str_replace("<!-- !!localisation!! -->", "<div class='row'><strong>{$msg['empr_location']} : </strong>" . $this->empr_location_l . "</div>", $this->fiche); $resume_localisation = $this->empr_location_l; } if ($pmb_opac_view_activate) { } //Groupes if (count($this->groupes)) { $this->fiche = str_replace('!!groupes!!', "<strong>" . $msg[groupes_empr] . " : </strong>" . implode(" / ", $this->groupes) . "\n", $this->fiche); $resume_groupe = implode(" / ", $this->groupes); } else { $this->fiche = str_replace('!!groupes!!', " ", $this->fiche); } // Ajout d'infos complémentaires lorsque la fiche lecteur est repliée par défaut $empr_resume = ''; if ($empr_fiche_depliee == "0") { //localisation if ($resume_localisation) { $empr_resume = $resume_localisation . " - "; } //categ if ($this->cat_l) { $empr_resume .= $this->cat_l . " - "; } //groupe if ($resume_groupe) { $empr_resume .= $resume_groupe . " - "; } } $this->fiche = str_replace('!!empr_resume!!', $empr_resume, $this->fiche); //Pret autorisé ou non ? $pret_ok = 0; if ($pmb_gestion_financiere && $force_finance == 0) { $message_pret = ""; if ($pmb_gestion_abonnement) { //Vérification du compte $cpte_abt_id = comptes::get_compte_id_from_empr($this->id, 1); if ($cpte_abt_id) { $cpte_abt = new comptes($cpte_abt_id); $solde_neg = $cpte_abt->get_solde(); if ($finance_blocage_abt && $solde_neg * 1 < 0) { if ($pret_ok < 2) { $pret_ok = $finance_blocage_abt; } $message_pret .= sprintf($msg["finance_pret_solde_abt"], comptes::format($solde_neg)) . "<br />"; $this->blocage_abt = $finance_blocage_abt; } if ($solde_neg * 1 < 0) { $this->compte_abt = abs($solde_neg); } } } if ($pmb_gestion_tarif_prets) { //Vérification du compte $cpte_pret_id = comptes::get_compte_id_from_empr($this->id, 3); if ($cpte_pret_id) { $cpte_pret = new comptes($cpte_pret_id); $solde_neg = $cpte_pret->get_solde(); if ($finance_blocage_pret && $solde_neg * 1 < 0) { if ($pret_ok < 2) { $pret_ok = $finance_blocage_pret; } $message_pret .= sprintf($msg["finance_pret_solde_pret"], comptes::format($solde_neg)) . "<br />"; $this->blocage_tarifs = $finance_blocage_pret; } if ($solde_neg * 1 < 0) { $this->compte_tarifs = abs($solde_neg); } } } if ($pmb_gestion_amende) { //Vérification du compte $cpte_amende_id = comptes::get_compte_id_from_empr($this->id, 2); if ($cpte_amende_id) { $cpte_amende = new comptes($cpte_amende_id); $solde_neg = $cpte_amende->get_solde(); $amende = new amende($this->id, true); $amende_neg = $amende->get_total_amendes(); if ($finance_blocage_amende && ($solde_neg * 1 < 0 || $amende_neg * 1)) { $this->blocage_amendes = $finance_blocage_amende; if ($pret_ok < 2) { $pret_ok = $finance_blocage_amende; } if ($solde_neg * 1 < 0) { $message_pret .= sprintf($msg["finance_pret_solde_amende"], comptes::format($solde_neg)) . "<br />"; } if ($amende_neg * 1) { $message_pret .= sprintf($msg["finance_pret_amende_en_cours_blocage"], comptes::format($amende_neg)) . "<br />"; } } if ($solde_neg * 1 < 0) { $this->compte_amendes = abs($solde_neg); } if ($amende_neg * 1) { $this->amendes_en_cours = abs($amende_neg); } } } } if ($pmb_blocage_retard && $force_finance == 0) { if ($this->date_blocage && $this->blocage_active) { $this->blocage_retard = $pmb_blocage_retard_force; //pas de forçage possible if ($pmb_blocage_retard_force == 2) { $message_pret .= sprintf($msg["blocage_retard_pret"], formatdate($this->date_blocage)) . "<br />"; } else { $message_pret .= sprintf($msg["blocage_retard_pret"], formatdate($this->date_blocage)) . " <input type='button' value='" . $msg["blocage_params"] . "' class='bouton' onClick=\"openPopUp('./circ/blocage.php?id_empr=" . $this->id . "','blocage_params',400,200,-2,-2,'toolbar=no, dependent=yes,resizable=yes');\"/><br />"; } if ($pret_ok < 2) { $pret_ok = $pmb_blocage_retard_force; } } } // Ajout de l'impossibilité d'effectuer un prêt si un document n'est pas rendu // alors qu'il a dépassé le délai de blocage (NG72) . if ($pmb_blocage_retard && $force_finance == 0) { // Recherche la date de retour du document la plus petite, soit le plus gros retard potentiel $requete = "select MIN(pret_retour)as pret_retour"; $requete .= " from pret p"; $requete .= " where p.pret_idempr=" . $this->id; $result = mysql_query($requete, $dbh); while ($bloca = mysql_fetch_object($result)) { if ($bloca->pret_retour) { $pret_retour = $bloca->pret_retour; $date_debut = explode("-", $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) { // Interdire alors de nouveau pret if ($pret_ok < 2) { $pret_ok = $pmb_blocage_retard_force; } $this->blocage_retard = $pmb_blocage_retard_force; } } } } if (!$pret_ok && $this->allow_loan) { $this->fiche = str_replace("!!empr_case_pret!!", $empr_pret_allowed, $this->fiche); $this->fiche = str_replace('!!id!!', $this->id, $this->fiche); } else { if ($pret_ok == 1 && $this->allow_loan) { $message_pret .= "<input type='button' class='bouton' value=\"" . $msg["finance_pret_force_pret"] . "\" onClick=\"this.form.force_finance.value=1; this.form.submit();\">"; } elseif ($this->allow_loan) { $message_pret .= "<div class='erreur'>" . $msg["finance_pret_bloque"] . "</div>"; } else { $message_pret .= "<div class='erreur'>" . $msg["empr_no_allow_loan"] . "</div>"; } $this->fiche = str_replace("!!empr_case_pret!!", $message_pret, $this->fiche); } $abonnement = ""; if ($pmb_gestion_financiere && $pmb_gestion_abonnement == 2) { if ($this->type_abt) { $requete = "select type_abt_libelle from type_abts where id_type_abt='" . $this->type_abt . "'"; $resultat_type_abt = mysql_query($requete); if (@mysql_num_rows($resultat_type_abt)) { $abonnement = mysql_result($resultat_type_abt, 0, 0); } } } if ($abonnement) { $this->fiche = str_replace("!!abonnement!!", "<div class='row'><strong>" . $msg["finance_type_abt"] . " : </strong>" . htmlentities($abonnement, ENT_QUOTES, $charset) . "</div>\n", $this->fiche); } else { $this->fiche = str_replace("!!abonnement!!", "", $this->fiche); } // message if ($this->empr_msg) { $message_fiche_empr = "\n\t\t\t\t\t<hr />\n\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t<div class='colonne10'><img src='./images/info.png' /></div>\n\t\t\t\t\t\t<div class='colonne-suite'><span class='erreur'>{$this->empr_msg}</span></div>\n\t\t\t\t\t\t</div><br />"; $alert_sound_list[] = "information"; $this->fiche = str_replace('!!empr_msg!!', $message_fiche_empr, $this->fiche); } else { $this->fiche = str_replace('!!empr_msg!!', "", $this->fiche); } // on distingue les messages de prêts du message sur l'emprunteur $this->fiche = str_replace('!!pret_msg!!', $this->message, $this->fiche); if ($this->adhesion_renouv_proche()) { $message_date_depassee = $msg[empr_date_renouv_proche]; } elseif ($this->adhesion_depassee()) { $message_date_depassee = $msg[empr_date_depassee]; } else { $message_date_depassee = ""; } if ($message_date_depassee) { $alert_sound_list[] = "critique"; } $this->fiche = str_replace('!!empr_date_depassee!!', $message_date_depassee, $this->fiche); if ($this->age_categ_change()) { $message_categ_age_change = $msg[empr_categ_age_change]; } else { $message_categ_age_change = ""; } if ($message_categ_age_change) { $alert_sound_list[] = "information"; } $this->fiche = str_replace('!!empr_categ_age_change!!', $message_categ_age_change, $this->fiche); $group_zone = "<a href='./circ.php'>{$msg['64']}</a>"; if ($groupID) { $group_zone .= " <a href='./circ.php?categ=groups&action=showgroup&groupID={$groupID}'>{$msg['grp_autre_lecteur']}</a>"; } $this->fiche = str_replace('!!group_zone!!', $group_zone, $this->fiche); $fsexe[0] = $msg[128]; $fsexe[1] = $msg[126]; $fsexe[2] = $msg[127]; $this->fiche = str_replace('!!sexe!!', $fsexe[$this->sexe], $this->fiche); // valeur pour les champ hidden du prêt. L'id empr est pris en charge plus haut (voir Eric) $this->fiche = str_replace('!!cb!!', $this->cb, $this->fiche); // traitement liste exemplaires en prêt $this->fiche = str_replace('!!nb_prets_encours!!', $this->nb_pret, $this->fiche); //On affiche le bouton de mail si le destinataire a une adresse mail if ($this->mail) { $mail_click = "onclick=\"if (confirm('" . $msg["mail_pret_confirm"] . "')) { openPopUp('./pdf.php?pdfdoc=mail_liste_pret&id_empr=" . $this->id . "', 'print_PDF', 600, 500, -2, -2, '{$PDF_win_prop}');} return(false) \""; $bouton_mail_liste_pret = "<input type='button' name='maillistedocs' class='bouton' value='{$msg['email']}' {$mail_click} />"; } else { $bouton_mail_liste_pret = ""; } $this->fiche = str_replace("!!mail_liste_pret!!", $bouton_mail_liste_pret, $this->fiche); //Si mail de rappel affecté au responsable du groupe $requete = "select id_groupe,resp_groupe from groupe,empr_groupe where id_groupe=groupe_id and empr_id=" . $this->id . " and resp_groupe and mail_rappel limit 1"; $res = mysql_query($requete); if (mysql_num_rows($res) > 0) { $requete = "select id_empr, empr_mail from empr where id_empr='" . mysql_result($res, 0, 1) . "'"; $result = mysql_query($requete); $has_mail = mysql_result($result, 0, 1) ? 1 : 0; } else { $has_mail = $this->mail ? 1 : 0; } //Si retard sur un document, proposer la lettre de retard ou l'email de retard if ($this->retard >= 1) { $imprime_click = "onclick=\"openPopUp('./pdf.php?pdfdoc=lettre_retard&id_empr=" . $this->id . "', 'lettre', 600, 500, -2, -2, 'toolbar=no, dependent=yes, resizable=yes'); return(false) \""; $bouton_lettre_retard = $msg['retard'] . " <input type=\"button\" class=\"bouton\" value=\"" . $msg["lettre_retard"] . "\" " . $imprime_click . ">"; if ($has_mail && $biblio_email) { $mail_click = "onclick=\"if (confirm('" . $msg["mail_retard_confirm"] . "')) { openPopUp('./mail.php?type_mail=mail_retard&id_empr=" . $this->id . "', 'mail', 600, 500, -2,- 2, 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes');} return(false) \""; $bouton_mail_retard = "<input type=\"button\" class=\"bouton\" value=\"" . $msg["mail_retard"] . "\" " . $mail_click . ">"; } else { $bouton_mail_retard = ""; } } else { $bouton_lettre_retard = ""; $bouton_mail_retard = ""; } $this->fiche = str_replace("!!lettre_retard!!", $bouton_lettre_retard, $this->fiche); $this->fiche = str_replace("!!mail_retard!!", $bouton_mail_retard, $this->fiche); $voir_tout_pret = ""; //separation prets classiques et prets courts $prets_list = array('0' => '', '1' => ''); if (!count($this->prets)) { // dans ce cas, le lecteur n'a rien en prêt $prets_list[0] = "<tr><td colspan='9'>{$msg['650']}</td></tr>"; $prets_list[1] = ''; } else { // constitution du code HTML $vdr = 0; $id_bloc = $id_inpret = ''; $odd_even = 0; // Gestion de limitation de la visualisation de la liste de pret. global $pmb_pret_aff_limitation; global $pmb_pret_aff_nombre; global $see_all_pret; global $current_module; while (list($cle, $valeur) = each($this->prets)) { $id_inpret .= $valeur['id'] . '|'; if ($valeur['pret_retard'] == 1) { $tit_color = "color='RED'"; } else { $tit_color = ""; } //Affichage des prolongations global $pmb_pret_restriction_prolongation, $pmb_pret_nombre_prolongation, $pmb_utiliser_calendrier; $pret_nombre_prolongation = 0; $forcage_prolongation = TRUE; $duree_prolongation = 0; // Limitation simple du pret if ($pmb_pret_restriction_prolongation == 1) { $pret_nombre_prolongation = $pmb_pret_nombre_prolongation; } elseif ($pmb_pret_restriction_prolongation == 2) { // Limitation du pret par les quotas //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $this->id; $struct["EXPL"] = $valeur['id']; $pret_nombre_prolongation = $qt->get_quota_value($struct); $forcage_prolongation = $qt->get_force_value($struct); //Initialisation des quotas de durée de prolongation $qt = new quota("PROLONG_TIME_QUOTA"); $struct["READER"] = $this->id; $struct["EXPL"] = $valeur['id']; $duree_prolongation = $qt->get_quota_value($struct); } //$forcage_prolongation=FALSE; /* on prépare la date de début*/ $pret_date = $valeur['sql_date_retour']; $rqt_date = "select date_add('" . $pret_date . "', INTERVAL '{$duree_prolongation}' DAY) as date_prolongation "; $resultatdate = mysql_query($rqt_date); $res = mysql_fetch_object($resultatdate); $date_prolongation = str_replace('-', "", $res->date_prolongation); if ($pmb_utiliser_calendrier) { $req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='" . $valeur["idlocation"] . "' and DATEDIFF(date_ouverture,'{$date_prolongation}')>=0 order by date_ouverture asc limit 1"; $res_date_calendrier = mysql_query($req_date_calendrier); if (mysql_num_rows($res_date_calendrier) > 0) { $date_prolongation = str_replace('-', "", mysql_result($res_date_calendrier, 0, 0)); } } if ($odd_even == 0) { $pair_impair = "odd"; $odd_even = 1; } else { if ($odd_even == 1) { $pair_impair = "even"; $odd_even = 0; } } $expl_sur_loc = ""; if ($pmb_sur_location_activate) { $expl_sur_loc = "<td><center>" . $valeur["sur_location"] . "</center></td>"; } $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\""; $prets_list[$valeur['short_loan_flag']] .= "\n\t\t\t\t\t<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t\t<form class='form-{$current_module}' name=prolong" . $valeur['id'] . " action='circ.php'>\n\t\t\t\t\t\t<td class='empr-expl'><a href='./circ.php?categ=visu_ex&form_cb_expl=" . rawurlencode($valeur['cb']) . "'>\n\t\t\t\t\t\t\t{$valeur['cb']}</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td size='70%'>\n\t\t\t\t\t\t\t<font {$tit_color}>" . strip_tags($valeur['libelle']) . "</font>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['typdoc']}</center>\n\t\t\t\t\t\t</td>{$expl_sur_loc}\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['location']}<br />{$valeur['section']}</center>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['date_pret']}</center>\n\t\t\t\t\t\t</td>\t\t\t\t\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<center>{$valeur['retour_initial']}</center>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>"; if ($pmb_pret_restriction_prolongation == 0) { $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['cpt_prolongation']}</center>"; } else { $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['cpt_prolongation']}/{$pret_nombre_prolongation}</center>"; } $prets_list[$valeur['short_loan_flag']] .= "</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type='hidden' name='categ' value='pret'>\n\t\t\t\t\t\t\t<input type='hidden' name='sub' value='pret_prolongation'>\n\t\t\t\t\t\t\t<input type='hidden' name='form_cb' value='{$this->cb}'>\n\t\t\t\t\t\t\t<input type='hidden' name='cb_doc' value='{$valeur['cb']}'>\n\t\t\t\t\t\t\t<input type='hidden' name='id_doc' value='{$valeur['id']}'>\n\t\t\t\t\t\t\t<input type='hidden' name='date_retour' value=\"\">"; $vdr = max($vdr, $date_prolongation); // $vdr=max($vdr,$valeur['org_ret_date']); if ($forcage_prolongation == FALSE && $valeur['cpt_prolongation'] >= $pret_nombre_prolongation) { $prets_list[$valeur['short_loan_flag']] .= "<center>{$valeur['date_retour']}</center>" . "</td>" . "</form><td> </td></tr>"; } else { $date_clic = " onClick=\"openPopUp('./select.php?what=calendrier"; $date_clic .= "&caller=prolong" . $valeur['id']; $date_clic .= "&date_caller={$date_prolongation}"; $date_clic .= "¶m1=date_retour¶m2=date_retour_lib&auto_submit=YES',"; $date_clic .= " 'date_retour', 250, 300, -2, -2,"; $date_clic .= " 'toolbar=no, dependent=yes, resizable=yes')\""; $prets_list[$valeur['short_loan_flag']] .= "\n\t\t\t\t\t\t<center><input type='button' name='date_retour_lib' class='bouton' value='{$valeur['date_retour']}' " . $date_clic . " sorttable_customkey='{$valeur['date_retour']}' /></center>\n\t\t\t\t\t\t</td><td><center>"; $prets_list[$valeur['short_loan_flag']] .= "<input type='checkbox' id='prol_" . $valeur['id'] . "' name='cbox_prol' onClick='check_cb(this.form)'/>"; $prets_list[$valeur['short_loan_flag']] .= "</center></td>\n\t\t\t\t\t\t</form></tr>"; } // Gestion de limitation de la visualisation de la liste de pret. if ($pmb_pret_aff_limitation == 1 && $pmb_pret_aff_nombre && !$see_all_pret && $cle + 1 >= $pmb_pret_aff_nombre) { break; } } // Gestion de limitation de la visualisation de la liste de pret. if ($pmb_pret_aff_limitation == 1 && $pmb_pret_aff_nombre && !$see_all_pret && $this->nb_pret > $pmb_pret_aff_nombre) { // le bouton 'Voir tous les prets' n'a pas été posté et on arrive à la limite imposée //Affichage du bouton 'Voir tous les prets' $tout_voir_click = "onclick=\"document.location='circ.php?categ=pret&see_all_pret=1&form_cb=" . $this->cb . "'\""; $voir_tout_pret = "<input type='button' name='see_all_pret' class='bouton' value='" . $msg['pret_liste_voir_tout'] . "' {$tout_voir_click}/>"; } } /* 1ere option */ //$prets_list = $prets_list[0].(($pmb_short_loan_management==1 && count($prets_list[1]))?("<tr ><th colspan='9'>".$msg['short_loans']."</th></tr>".$prets_list[1]):''); /* 2eme option*/ $id_inpret = substr($id_inpret, 0, -1); $date_format_SQL = substr($vdr, 0, 4) . '-' . substr($vdr, 4, 2) . '-' . substr($vdr, 6, 2); $svdr = formatdate($date_format_SQL); $date_prol = " onClick=\"openPopUp('./select.php?what=calendrier"; $date_prol .= "&caller=prolong_bloc"; $date_prol .= "&date_caller={$vdr}"; $date_prol .= "¶m1=date_retbloc¶m2=date_retbloc_lib&auto_submit=YES',"; $date_prol .= " 'date_retbloc',"; $date_prol .= " 250,260,-2,-2,'toolbar=no, dependent=yes, resizable=yes')\""; $butt_prol = "\n\t\t\t<input type='button' name='date_retbloc_lib' class='bouton' value='{$svdr}' " . $date_prol . " />\n\t\t\t<input type='hidden' name='categ' value='pret'>\n\t\t\t<input type='hidden' name='sub' value='pret_prolongation_bloc'>\n\t\t\t<input type='hidden' name='form_cb' value='{$this->cb}'>\n\t\t\t<input type='hidden' name='date_retbloc' value=\"\">\n\t\t\t<input type='hidden' name='id_bloc' value=\"\">"; $this->fiche = str_replace('!!id_inpret!!', $id_inpret, $this->fiche); if ($vdr) { $this->fiche = str_replace('!!prol_date!!', $butt_prol, $this->fiche); $this->fiche = str_replace('!!bouton_cocher_prolong!!', "<input type='button' name='bloc_all' value='+' class='bouton' title='{$msg['resa_tout_cocher']}' onClick='check_allcb(this.form)'/>", $this->fiche); } else { $this->fiche = str_replace('!!prol_date!!', "", $this->fiche); $this->fiche = str_replace('!!bouton_cocher_prolong!!', " ", $this->fiche); } $this->fiche = str_replace('!!voir_tout_pret!!', $voir_tout_pret, $this->fiche); /* 1ere option */ //$this->fiche = str_replace('!!pret_list!!', $prets_list, $this->fiche); /* 2eme option */ $this->fiche = str_replace('!!pret_list!!', $prets_list[0], $this->fiche); if ($pmb_short_loan_management == 1) { if (count($prets_list[1])) { $this->fiche = str_replace('!!short_loan_list!!', $prets_list[1], $this->fiche); } else { $this->fiche = str_replace('!!short_loan_list!!', '', $this->fiche); } } //tableau des relances $this->fiche = str_replace('!!relance!!', $this->relance, $this->fiche); if ($pmb_gestion_amende && $pmb_gestion_financiere) { $bt_histo_relance = " <input type='button' class='bouton' id='see_late' name='see_late' value=\"" . $msg['empr_see_late'] . "\" onclick=\"document.location='./circ.php?categ=pret&sub=show_late&id={$this->id}' \" />"; } else { $bt_histo_relance = ""; } $this->fiche = str_replace('!!bt_histo_relance!!', $bt_histo_relance, $this->fiche); // mise à jour de la liste des réservations $this->fiche = str_replace('!!resa_list!!', $this->fetch_resa(), $this->fiche); if ($pmb_resa_planning) { // mise à jour de la liste des réservations plannifiées $this->fiche = str_replace('!!resa_planning_list!!', $this->fetch_resa_planning(), $this->fiche); } else { $this->fiche = str_replace('!!resa_planning_list!!', '', $this->fiche); } if ($this->allow_sugg && SESSrights & ACQUISITION_AUTH) { $req = "select count(id_suggestion) as nb from suggestions, suggestions_origine where num_suggestion=id_suggestion and origine='" . $this->id . "' and type_origine='1' "; $res = mysql_query($req, $dbh); $btn_sug = ""; $sug = mysql_fetch_object($res); if ($sug->nb) { $btn_sug = "<input type='button' class='bouton' id='see_sug' name='see_sug' value='" . $msg['acquisition_lecteur_see_sugg'] . "' onclick=\"document.location='./acquisition.php?categ=sug&action=list&user_id={$this->id}&user_statut=1' \" />"; } $this->fiche = str_replace('!!voir_sugg!!', $btn_sug, $this->fiche); } else { $this->fiche = str_replace('!!voir_sugg!!', "", $this->fiche); } // mise à jour de la liste des abonnement de circulation de pério $this->fiche = str_replace('!!serialcirc_empr!!', $this->fetch_serial_circ(), $this->fiche); }
function list_views() { global $dbh; global $pmb_opac_view_activate; global $include_path; global $lang; $this->opac_views_list = array(); $this->view_list_empr_default = 0; //on reprend... if ($this->id_empr) { $req = "SELECT * FROM opac_views, opac_views_empr where opac_view_visible!=0 and emprview_view_num=opac_view_id and emprview_empr_num=" . $this->id_empr; $myQuery = mysql_query($req, $dbh); if (mysql_num_rows($myQuery)) { while ($r = mysql_fetch_object($myQuery)) { if ($r->emprview_default) { $this->view_list_empr_default = $r->opac_view_id; } $this->opac_views_list[] = $r->opac_view_id; } } //on regarde l'OPAC classique $query = "select emprview_view_num,emprview_default from opac_views_empr where emprview_view_num = 0 and emprview_empr_num = " . $this->id_empr; $result = mysql_query($query); if (mysql_num_rows($result)) { $r = mysql_fetch_object($result); $this->opac_views_list[] = 0; if ($r->emprview_default) { $this->view_list_empr_default = 0; } } } if (count($this->opac_views_list) == 0) { if ($pmb_opac_view_activate == 2) { $qt = new quota("OPAC_VIEW", $include_path . "/quotas/own/" . $lang . "/opac_views.xml"); $struct = array('READER' => $this->id_empr ? $this->id_empr : 0); if ($this->id_empr) { $struct["READER"] = $this->id_empr ? $this->id_empr : 0; $val = $qt->get_quota_value($struct); } else { $tmp = $qt->apply_conflict(array("")); $val = $tmp['VALUE']; } $values = unserialize($val); $this->opac_views_list = $values['allowed']; $this->view_list_empr_default = $values['default']; } else { if (!$this->id_empr) { $this->opac_views_list[] = 0; $req = "SELECT * FROM opac_views where opac_view_visible=1"; $myQuery = mysql_query($req, $dbh); if (mysql_num_rows($myQuery)) { while ($r = mysql_fetch_object($myQuery)) { if ($r->emprview_default) { $this->view_list_empr_default = $r->opac_view_id; } /*else if(!$this->id_empr && !$this->view_list_empr_default){ //si pas d'emprunteur, on met la première vue trouvée par défaut $this->view_list_empr_default = $r->opac_view_id; }*/ $this->opac_views_list[] = $r->opac_view_id; } } } } } }
// Limitation simple de la prolongation $prolongation = FALSE; } else { if ($pmb_pret_restriction_prolongation == 2) { // Limitation du pret par les quotas //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $pret_nombre_prolongation = $qt->get_quota_value($struct); if ($cpt_prolongation > $pret_nombre_prolongation) { $prolongation = FALSE; } //Initialisation des quotas la durée de prolongations $qt = new quota("PROLONG_TIME_QUOTA"); $struct["READER"] = $id_empr; $struct["EXPL"] = $expl_id; $duree_prolongation = $qt->get_quota_value($struct); } } // fin if gestion par quotas } } // fin else if pmb_pret_restriction_prolongation>0 $date_prolongation = sql_value("SELECT DATE_ADD('{$date_retour}', INTERVAL {$duree_prolongation} DAY)"); $diff = sql_value("SELECT DATEDIFF('{$date_retour}','{$today}')"); if ($diff < -$duree_prolongation || $diff > $duree_prolongation) { $prolongation = FALSE; } $req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='" . $data_expl['expl_location'] . "' and DATEDIFF(date_ouverture,'{$date_prolongation}')>=0 order by date_ouverture asc limit 1";
function get_parameters($id_expl) { global $pmb_gestion_financiere, $pmb_gestion_amende, $lang, $include_path; global $finance_amende_jour, $finance_delai_avant_amende, $finance_delai_recouvrement, $finance_amende_maximum, $finance_delai_1_2, $finance_delai_2_3; global $tbclasses; global $_quotas_elements_; global $_quotas_types_; global $_quotas_table_; $param = array(); if ($pmb_gestion_amende == 1) { //Gestion simple des amendes $param["delai_avant_amende"] = $finance_delai_avant_amende; $param["amende_jour"] = $finance_amende_jour; $param["delai_recouvrement"] = $finance_delai_recouvrement; $param["amende_maximum"] = $finance_amende_maximum; $param["delai_1_2"] = $finance_delai_1_2; $param["delai_2_3"] = $finance_delai_2_3; } else { //Gestion des quotas global $_parsed_quotas_; if (!$tbclasses["QUOTAS_ELEMENTS"]) { $_parsed_quotas_ = false; } else { $_quotas_elements_ = $tbclasses["QUOTAS_ELEMENTS"]; $_quotas_types_ = $tbclasses["QUOTAS_TYPES"]; $_quotas_table_ = $tbclasses["QUOTAS_TABLE"]; $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); } $struct["READER"] = $this->id_empr; $struct["EXPL"] = $id_expl; $qt_delai_avant_amende = new quota("AMENDE_DELAI", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["delai_avant_amende"] = $qt_delai_avant_amende->get_quota_value($struct); if (!$tbclasses["QUOTAS_ELEMENTS"]) { $tbclasses["QUOTAS_ELEMENTS"] = $_quotas_elements_; $tbclasses["QUOTAS_TYPES"] = $_quotas_types_; $tbclasses["QUOTAS_TABLE"] = $_quotas_table_; } $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); $qt_amende_jour = new quota("AMENDE_BY_DAY", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["amende_jour"] = $qt_amende_jour->get_quota_value($struct); if ($param["amende_jour"] == -1) { $param["amende_jour"] = 0; } $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); $qt_delai_recouvrement = new quota("AMENDE_DELAI_RECOUVREMENT", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["delai_recouvrement"] = $qt_delai_recouvrement->get_quota_value($struct); $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); $qt_amende_maximum = new quota("AMENDE_MAXIMUM", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["amende_maximum"] = $qt_amende_maximum->get_quota_value($struct); $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); $qt_amende_maximum = new quota("AMENDE_1_2", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["delai_1_2"] = $qt_amende_maximum->get_quota_value($struct); $_parsed_quotas_ = array("{$include_path}/quotas/own/{$lang}/finances.xml" => true); $qt_amende_maximum = new quota("AMENDE_2_3", "{$include_path}/quotas/own/{$lang}/finances.xml"); $param["delai_2_3"] = $qt_amende_maximum->get_quota_value($struct); $_parsed_quotas_ = false; } return $param; }
function prolonger($id_prolong) { global $id_empr, $date_retour, $date_retour_lib, $form_cb, $cb_doc, $confirm; global $dbh, $alert_sound_list, $msg; global $pmb_pret_restriction_prolongation, $pmb_pret_nombre_prolongation, $force_prolongation, $bloc_prolongation; global $deflt2docs_location, $pmb_location_reservation; $prolongation = TRUE; //Récupération des ids de notices et de bulletin par rapport à l'id de l'exemplaire placé en paramètre $query = "select expl_cb, expl_notice, expl_bulletin from exemplaires where expl_id='{$id_prolong}' limit 1"; $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $retour = pmb_mysql_fetch_object($result); $cb_doc = $retour->expl_cb; //Récupération du nombre de prolongations effectuées pour l'exemplaire $query_prolong = "select cpt_prolongation, retour_initial, pret_date from pret where pret_idexpl=" . $id_prolong . " limit 1"; $result_prolong = pmb_mysql_query($query_prolong, $dbh); $data = pmb_mysql_fetch_array($result_prolong); $cpt_prolongation = $data['cpt_prolongation']; $retour_initial = $data['retour_initial']; $pret_date = $data['pret_date']; $pret_day = explode(" ", $pret_date); if ($pret_day[0] != today()) { $cpt_prolongation++; } if ($force_prolongation != 1) { //Rechercher s'il subsiste une réservation à traiter sur le bulletin ou la notice $query_resa = "select count(1) from resa where resa_idnotice=" . $retour->expl_notice . " and resa_idbulletin=" . $retour->expl_bulletin . " and (resa_cb='' or resa_cb='{$cb_doc}')"; if ($pmb_location_reservation) { $query_resa = "select count(1) from resa,empr,resa_loc \n\t\t\t\t\twhere resa_idnotice=" . $retour->expl_notice . " and resa_idbulletin=" . $retour->expl_bulletin . " and (resa_cb='' or resa_cb='{$cb_doc}')\n\t\t\t\t\tand resa_idempr=id_empr\n\t\t\t\t\tand empr_location=resa_emprloc and resa_loc='" . $deflt2docs_location . "' \n\t\t\t\t\t"; } $result_resa = pmb_mysql_query($query_resa, $dbh); $has_resa = pmb_mysql_result($result_resa, 0, 0); if (!$has_resa) { if ($pmb_pret_restriction_prolongation > 0) { //limitation simple du prêt if ($pmb_pret_restriction_prolongation == 1) { $pret_nombre_prolongation = $pmb_pret_nombre_prolongation; $forcage_prolongation = 1; } else { //Initialisation des quotas pour nombre de prolongations $qt = new quota("PROLONG_NMBR_QUOTA"); //Tableau de passage des paramètres $struct["READER"] = $id_empr; $struct["EXPL"] = $id_prolong; $pret_nombre_prolongation = $qt->get_quota_value($struct); $forcage_prolongation = $qt->get_force_value($struct); } if ($cpt_prolongation > $pret_nombre_prolongation) { $prolongation = FALSE; } } } else { $prolongation = FALSE; $forcage_prolongation = 1; } } //est-ce qu'on a le droit de prolonger if ($prolongation == TRUE) { $query = "update pret set cpt_prolongation='" . $cpt_prolongation . "' where pret_idexpl=" . $id_prolong . " limit 1"; pmb_mysql_query($query, $dbh); // mettre ici la routine de prolongation $pretProlong = new pret($id_empr, $id_prolong, $form_cb, "", ""); $resultProlongation = $pretProlong->prolongation($date_retour); $erreur_affichage = ""; } else { if ($retour->expl_notice != 0) { $q = new notice($retour->expl_notice); $nom = $q->tit1; } elseif ($retour->expl_bulletin != 0) { $query = "select bulletin_notice, bulletin_numero,date_date from bulletins where bulletin_id =" . $retour->expl_bulletin; $res = pmb_mysql_query($query, $dbh); $bull = pmb_mysql_fetch_object($res); $q = new serial($bull->bulletin_notice); $nom = $q->tit1 . ". " . $bull->bulletin_numero . " (" . formatdate($bull->date_date) . ")"; } if ($has_resa) { if ($bloc_prolongation == 0) { $erreur_affichage = "<table border='0' cellpadding='1' height='40' border='1'><tr><td width='33'><span><img src='./images/quest.png' /></span></td>\n\t\t\t\t\t\t\t\t<td width='100%'>"; $erreur_affichage .= $msg["document_prolong"] . " '{$nom}' : <span class='erreur'>{$msg[393]}</span>"; $erreur_affichage .= "<input type='button' class='bouton' value='{$msg[76]}' onClick=\"document.location='./circ.php?categ=pret&form_cb=" . rawurlencode($form_cb) . "'\">"; $erreur_affichage .= " <input type='button' class='bouton' value='{$msg[pret_plolongation_forcage]}' onClick=\"document.location='circ.php?categ=pret&sub=pret_prolongation&form_cb=" . rawurlencode($form_cb) . "&cb_doc={$cb_doc}&id_doc=" . $id_prolong . "&date_retour={$date_retour}&force_prolongation={$forcage_prolongation}'\">"; $erreur_affichage .= "</td></tr></table>"; } else { $erreur_affichage .= $msg["document_prolong"] . " '{$nom}' : <span class='erreur'>{$msg[393]}</span><br />"; } } else { if ($bloc_prolongation == 0) { $erreur_affichage = "<hr />\n\t\t\t\t\t\t<div class='row'>\n\t\t\t\t\t\t\t<div class='colonne10'><img src='./images/error.png' /></div>\n\t\t\t\t\t\t\t<div class='colonne-suite'>" . $msg["document_prolong"] . " '{$nom}' : <span class='erreur'>" . $msg[pret_plolongation_refuse] . "</span></div>"; $alert_sound_list[] = "critique"; $erreur_affichage .= "<input type='button' class='bouton' value='{$msg[76]}' onClick=\"document.location='./circ.php?categ=pret&id_empr={$id_empr}'\" />"; $erreur_affichage .= " <input type='button' class='bouton' value='{$msg[pret_plolongation_forcage]}' onClick=\"document.location='./circ.php?categ=pret&sub=pret_prolongation&form_cb=" . rawurlencode($form_cb) . "&cb_doc={$cb_doc}&id_doc=" . $id_prolong . "&date_retour={$date_retour}&force_prolongation={$forcage_prolongation}'\" />"; $erreur_affichage .= "</div><br />"; } else { $erreur_affichage .= $msg["document_prolong"] . " '{$nom}' : <span class='erreur'>" . $msg[pret_plolongation_refuse] . "</span><br />"; } } } } return $erreur_affichage; }