if ($cpte->validate_transaction($t[$i]->id_transaction)) { $somme += $t[$i]->montant * $t[$i]->sens; $val_transactions .= " #" . $t[$i]->id_transaction . "#"; } } if (count($t)) { $transacash_num = $cpte->cashdesk_memo_transactions($t); } if ($val_transactions != "") { $val_transactions = $msg["finance_enc_tr_lib_valider"] . " : " . $val_transactions . "\n"; } $solde_avant = $cpte->get_solde(); if ($solde_avant != 0) { $val_transactions .= $msg["finance_enc_tr_lib_etat_compte"] . " : " . $solde_avant; } $cpte->update_solde(); encaisse_form(true, $transacash_num); break; case "enc": if ($somme * 1 > 0) { //Generation de la transaction if ($id_transaction = $cpte->record_transaction("", $somme, 1, $val_transactions, 1)) { $cpte->validate_transaction($id_transaction); $cpte->update_solde(); if (!$transacash_num) { $req = "select MAX(transacash_num) from transactions where compte_id=" . $cpte->id_compte . ""; $resultat = pmb_mysql_query($req); if ($transacash_num = pmb_mysql_result($resultat, 0, 0)) { $req = "update transactions set transacash_num = {$transacash_num} where compte_id=" . $cpte->id_compte . " and transacash_num=0"; pmb_mysql_query($req); }
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; }
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 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 fetch_info_suite() { global $dbh; global $msg; global $charset; global $val_list_empr; global $pmb_gestion_financiere, $pmb_gestion_abonnement, $pmb_gestion_tarif_prets, $pmb_gestion_amende, $empr_header_format; global $deflt_docs_location; global $pmb_sur_location_activate; global $pmb_resa_planning; //Comptes si gestion financiere $compte = ""; $n_c = 0; $neg = "<span class='erreur'>%s</span>"; $pos = "%s"; if ($pmb_gestion_financiere) { $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='colonne4'><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='colonne4'><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, true); $total_amende = $amende->get_total_amendes(); $this->nb_amendes = $amende->nb_amendes; $compte .= "<div class='colonne4'><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++; } // Autre compte, que s'il y a des types de transaction $transactype = new transactype_list(); if ($transactype->get_count()) { $cpt_id = comptes::get_compte_id_from_empr($this->id, 4); $cpt = new comptes($cpt_id); $solde = $cpt->update_solde(); $novalid = $cpt->summarize_transactions("", "", 0, 0); $compte .= "\n\t\t\t\t<div class='colonne4'>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<strong><a href='./circ.php?categ=pret&sub=compte&id=" . $this->id . "&typ_compte=4'>" . $msg["transactype_empr_compte"] . "</a></strong> " . comptes::format($solde) . "</div>"; if ($novalid) { $compte .= "<div>" . $msg["finance_not_validated"] . " : " . comptes::format($novalid) . "</div>"; } $n_c++; } if ($n_c < 3) { for ($i = $n_c; $i < 4; $i++) { $compte .= "<div class='colonne4'> </div>"; } } $compte .= "</div><div class='row'></div>"; } $this->compte = $compte; if ($pmb_gestion_amende && $pmb_gestion_financiere) { $this->relance .= $this->do_tablo_relance(); } // ces propriétés sont absentes de la table emprunteurs pour le moment // $this->adate = $empr->empr_??? ; // date d'abonnement // $this->rdate = $empr->empr_??? ; // date de réabonnement if ($this->message) { $this->message = $empr->message . '<hr />' . $this->message; } else { $this->message = $empr->message; } $order = " order by p.pret_retour, p.pret_date, e.expl_cb"; $requete_nb_pret = "select count(1) as nb_pret from pret where pret_idempr=" . $this->id; $result_nb_pret = mysql_query($requete_nb_pret, $dbh); $r_nb_pret = mysql_fetch_object($result_nb_pret); $this->nb_pret = $r_nb_pret->nb_pret; // récupération du tableau des exemplaires empruntés // il nous faut : code barre exemplaire, titre/auteur, type doc, date de pret, date de retour $requete = "select e.expl_cb, e.expl_id, e.expl_notice, docs_location.location_libelle, docs_location.idlocation, docs_section.section_libelle, e.expl_bulletin,"; $requete .= " p.pret_date, p.pret_retour, p.short_loan_flag, t.tdoc_libelle,"; $requete .= " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour,"; $requete .= " if (pret_retour< CURDATE(),1 ,0 ) as retard , date_format(retour_initial, '" . $msg["format_date"] . "') as aff_retour_initial, cpt_prolongation"; $requete .= " from pret p, exemplaires e, docs_type t, docs_location, docs_section "; $requete .= " where p.pret_idempr=" . $this->id; $requete .= " and p.pret_idexpl=e.expl_id"; $requete .= " and e.expl_section=docs_section.idsection"; $requete .= " and e.expl_location=docs_location.idlocation"; $requete .= " and t.idtyp_doc=e.expl_typdoc"; $requete .= " " . $order; $result = mysql_query($requete, $dbh); $this->retard = 0; while ($pret = mysql_fetch_object($result)) { if ($pmb_sur_location_activate) { $sur_loc = sur_location::get_info_surloc_from_location($pret->idlocation); } if ($pret->expl_notice) { $notice = new mono_display($pret->expl_notice, 0); $this->prets[] = array('cb' => $pret->expl_cb, 'id' => $pret->expl_id, 'libelle' => $notice->header, 'typdoc' => $pret->tdoc_libelle, 'section' => $pret->section_libelle, 'location' => $pret->location_libelle, 'idlocation' => $pret->idlocation, 'date_pret' => $pret->aff_pret_date, 'date_retour' => $pret->aff_pret_retour, 'short_loan_flag' => $pret->short_loan_flag, 'sql_date_retour' => $pret->pret_retour, 'org_ret_date' => str_replace('-', '', $pret->pret_retour), 'pret_retard' => $pret->retard, 'retour_initial' => $pret->aff_retour_initial, 'cpt_prolongation' => $pret->cpt_prolongation, 'sur_location' => $sur_loc->libelle); } if ($pret->expl_bulletin) { $bulletin = new bulletinage_display($pret->expl_bulletin); $this->prets[] = array('cb' => $pret->expl_cb, 'id' => $pret->expl_id, 'libelle' => $bulletin->display, 'typdoc' => $pret->tdoc_libelle, 'section' => $pret->section_libelle, 'location' => $pret->location_libelle, 'idlocation' => $pret->idlocation, 'date_pret' => $pret->aff_pret_date, 'date_retour' => $pret->aff_pret_retour, 'short_loan_flag' => $pret->short_loan_flag, 'sql_date_retour' => $pret->pret_retour, 'org_ret_date' => str_replace('-', '', $pret->pret_retour), 'pret_retard' => $pret->retard, 'retour_initial' => $pret->aff_retour_initial, 'cpt_prolongation' => $pret->cpt_prolongation, 'sur_location' => $sur_loc->libelle); } $this->retard = $this->retard + $pret->retard; } $requete_resa = "select count(1) as nb_reservations "; $requete_resa .= " from resa "; $requete_resa .= " where resa_idempr=" . $this->id; $result_resa = mysql_query($requete_resa, $dbh); $resa = mysql_fetch_object($result_resa); $this->nb_reservations = $resa->nb_reservations; if ($pmb_resa_planning) { $requete_resa_planning = "select count(1) as nb_previsions "; $requete_resa_planning .= " from resa_planning "; $requete_resa_planning .= " where resa_idempr=" . $this->id; $result_resa_planning = mysql_query($requete_resa_planning, $dbh); $resa_planning = mysql_fetch_object($result_resa_planning); $this->nb_previsions = $resa_planning->nb_previsions; } return TRUE; }