function show_lines_list() { global $id_empr, $msg, $charset; //Liste des recouvrements print "\n\t<div class='row'>\t\n\t<script type='text/javascript' src='./javascript/sorttable.js'></script>\n\t<table class='sortable'>\n\n\t\t<tr>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_date"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_type"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_titre"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_cb"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_cote"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_pret_date"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date1"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date2"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_relance_date3"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_prix_calcul"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th>" . htmlentities($msg["relance_recouvrement_montant"], ENT_QUOTES, $charset) . "</th>\n\t\t\t<th></th>\n\t\t\t<th></th>\t\t\n\t\t</tr>"; $requete = "select recouvr_id,id_expl,date_rec,libelle,montant, expl_notice,expl_bulletin, recouvr_type, date_pret,date_relance1,date_relance2,date_relance3, expl_cote ,\texpl_cb\n\tfrom recouvrements left join exemplaires on expl_id=id_expl where empr_id={$id_empr} order by date_rec,recouvr_id"; $resultat = pmb_mysql_query($requete); $pair = false; while ($r = pmb_mysql_fetch_object($resultat)) { if (!$pair) { $pair_impair = "odd"; } else { $pair_impair = "even"; } $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" "; $pair = !$pair; if ($r->id_expl) { if ($r->expl_notice) { $notice = new mono_display($r->expl_notice); } elseif ($r->expl_bulletin) { $req = "select bulletin_notice from bulletins where bulletin_id={$r->expl_bulletin}"; $res = pmb_mysql_query($req); $id_bull_notice = pmb_mysql_result($res, 0, 0); $notice = new serial_display($id_bull_notice); } $libelle = strip_tags(html_entity_decode($notice->header, ENT_QUOTES, $charset)); } else { $libelle = $r->libelle; } if (!$r->recouvr_type) { print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t<td>" . format_date($r->date_rec) . "</td>\n\t\t\t\t<td>" . htmlentities($msg["relance_recouvrement_amende"], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($libelle, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td><a href='./circ.php?categ=visu_ex&form_cb_expl=" . $r->expl_cb . "'>" . $r->expl_cb . "</a></td>\n\t\t\t\t<td>" . htmlentities($r->expl_cote, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . format_date($r->date_pret) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance1) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance2) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance3) . "</td>\n\t\t\t\t<td></td>\n\t\t\t\t<td style='text-align:right'><span dynamics='circ,recouvr_prix' dynamics_params='text' id='prix_" . $r->recouvr_id . "'>" . comptes::format_simple($r->montant) . "</span></td>\n\t\t\t\t<td style='text-align:center'><input type='checkbox' name='recouvr_ligne[]' value='" . $r->recouvr_id . "'></td>\n\t\t\t\t<td>"); if (!$r->id_expl) { print "<input type='button' value='...' class='bouton' onClick=\"this.form.act_line.value='update_line'; this.form.recouvr_id.value='" . $r->recouvr_id . "'; this.form.submit();\"/>"; } else { print " "; } print "</td>"; print "</tr>"; } elseif ($r->id_expl) { $requete = "select expl_prix, prix from exemplaires, notices where (notice_id=expl_notice or notice_id=expl_bulletin) and expl_id =" . $r->id_expl; //http://localhost/~ngantier/pmb/circ.php?categ=visu_ex&form_cb_expl=p $res_prix = pmb_mysql_query($requete); $comment_prix = ''; if ($r_prix = pmb_mysql_fetch_object($res_prix)) { if (!($comment_prix = $r_prix->expl_prix)) { $comment_prix = $r_prix->prix; } } print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript}>\n\t\t\t\t<td>" . format_date($r->date_rec) . "</td>\n\t\t\t\t<td>" . htmlentities($msg["relance_recouvrement_prix"], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($libelle, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td><a href='./circ.php?categ=visu_ex&form_cb_expl=" . $r->expl_cb . "'>" . $r->expl_cb . "</a></td>\n\t\t\t\t<td>" . htmlentities($r->expl_cote, ENT_QUOTES, $charset) . "</td>\t\t\t\n\t\t\t\t<td>" . format_date($r->date_pret) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance1) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance2) . "</td>\n\t\t\t\t<td>" . format_date($r->date_relance3) . "</td>\n\t\t\t\t<td>" . htmlentities($comment_prix, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td style='text-align:right'><span dynamics='circ,recouvr_prix' dynamics_params='text' id='prix_" . $r->recouvr_id . "'>" . comptes::format_simple($r->montant) . "</span></td>\n\t\t\t\t<td style='text-align:center'><input type='checkbox' name='recouvr_ligne[]' value='" . $r->recouvr_id . "'></td>\n\t\t\t\t<td>"); print "</td>"; print "</tr>"; } } print "</table></div>"; print "\n\t\t<div class='row'></div>\n\t</div>\n\t<!--boutons -->\n\t<div class='row'>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_del_all_lines"] . "' class='bouton' onClick=\"if (confirm('" . $msg["relance_recouvrement_confirm_del"] . "')) { this.form.act_line.value='del_line'; this.form.submit(); }\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_add_line"] . "' class='bouton' onClick=\"this.form.act_line.value='update_line'; this.form.recouvr_id.value=''; this.form.submit();\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_export_tableur"] . "' class='bouton' onClick=\"document.location='./circ/relance/recouvr_reader_excel.php?id_empr={$id_empr}';\"/>\n\t\t<input type='button' value='" . $msg["relance_recouvrement_solder"] . "' class='bouton' onClick=\"if (confirm('" . $msg["relance_recouvrement_confirm_solder"] . "')) { this.form.act_line.value='solde'; this.form.submit(); }\"/>\n\t\t<input type='button' value='" . $msg["76"] . "' class='bouton' onClick=\"document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_liste'\"/>\n\t</div>"; }
die("no access"); } //Gestion des recouvrements require_once "{$class_path}/comptes.class.php"; // //Recherche des emprunteurs en recouvrement $requete = "select empr_id,empr_cb, concat(empr_nom,' ',empr_prenom) as empr_name,empr_adr1,empr_adr2,empr_cp,empr_ville,empr_pays,empr_mail,empr_tel1,empr_tel2, round(sum(id_expl!=0)/2) as nb_ouvrages, sum(montant) as somme ,location_libelle from recouvrements, empr JOIN docs_location ON empr_location=idlocation where id_empr=empr_id group by empr_id"; $resultat = mysql_query($requete); if ($pmb_lecteurs_localises) { $th_localisation = "<th>" . $msg["empr_location"] . "</th>"; } print "\n<script type='text/javascript' src='./javascript/sorttable.js'></script>\n<table class='sortable'>\n<tr><th>" . $msg["relance_recouvrement_cb"] . "</th><th>" . $msg["relance_recouvrement_name"] . "</th>{$th_localisation}<th>" . $msg["relance_recouvrement_nb_ouvrages"] . "</th><th>" . $msg["relance_recouvrement_somme_totale"] . "</th></tr>\n"; $pair = false; while ($r = mysql_fetch_object($resultat)) { if (!$pair) { $class = "odd"; } else { $class = "even"; } $pair = !$pair; print "<tr class='{$class}' onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$class}'\" onmousedown=\"document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_reader&id_empr=" . $r->empr_id . "';\" style='cursor: pointer'>"; print pmb_bidi("<td>" . $r->empr_cb . "</td>"); print pmb_bidi("<td>" . $r->empr_name . "</td>"); if ($pmb_lecteurs_localises) { print pmb_bidi("<td>" . $r->location_libelle . "</td>"); } print pmb_bidi("<td style='text-align:center'>" . $r->nb_ouvrages . "</td>"); print pmb_bidi("<td style='text-align:right'>" . comptes::format_simple($r->somme) . "</td>"); print "</tr>"; } print "</table>";
function expl_retard($cb_doc, $niveau = 0, $id_empr = 0) { global $msg, $dbh, $charset; global $pmb_gestion_financiere, $pmb_gestion_amende; $valeur = 0; $dates_resa_sql = " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour "; $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, pret_idempr, expl_id, expl_cb,expl_cote, pret_date, pret_retour, tdoc_libelle, section_libelle, location_libelle, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date!='', concat(' (',mention_date,')') ,''))) as tit, " . $dates_resa_sql . ", "; $requete .= " notices_m.tparent_id, notices_m.tnvol "; $requete .= " FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), docs_type, docs_section, docs_location, pret "; $requete .= " WHERE expl_cb='" . $cb_doc . "' and expl_typdoc = idtyp_doc and expl_section = idsection and expl_location = idlocation and pret_idexpl = expl_id "; $res = mysql_query($requete, $dbh) or die(mysql_error() . " {$requete}"); $expl = mysql_fetch_object($res); // récupération du titre de série if ($expl->tparent_id && $expl->m_id) { $parent = new serie($expl->tparent_id); $tit_serie = $parent->name; if ($expl->tnvol) { $tit_serie .= ', ' . $expl->tnvol; } } if ($tit_serie) { $expl->tit = $tit_serie . '. ' . $expl->tit; } $libelle = $expl->tdoc_libelle; $responsabilites = get_notice_authors($expl->m_id); //print_r($responsabilites); $as = array_keys($responsabilites["responsabilites"], "0"); for ($i = 0; $i < count($as); $i++) { $indice = $as[$i]; $auteur_1 = $responsabilites["auteurs"][$indice]; $auteur = new auteur($auteur_1["id"]); $aut1_libelle[] = $auteur->isbd_entry; } if ($aut1_libelle) { $auteurs_liste = implode("; ", $aut1_libelle); if ($auteurs_liste) { $libelle .= ' / ' . $auteurs_liste; } } $libelle = $expl->tit . " (" . $libelle . ")"; $this->expl_info .= " \t<expl>\n"; $this->expl_info .= "\t\t<label>" . htmlspecialchars($libelle, ENT_QUOTES, $charset) . "</label>\n"; $this->expl_info .= "\t\t<loan_date>" . htmlspecialchars($expl->aff_pret_date, ENT_QUOTES, $charset) . "</loan_date>\n"; $this->expl_info .= "\t\t<return_date>" . htmlspecialchars($expl->aff_pret_retour, ENT_QUOTES, $charset) . "</return_date>\n"; $this->expl_info .= "\t\t<location>" . htmlspecialchars($expl->location_libelle, ENT_QUOTES, $charset) . "</location>\n"; $this->expl_info .= "\t\t<section>" . htmlspecialchars($expl->section_libelle, ENT_QUOTES, $charset) . "</section>\n"; $this->expl_info .= "\t\t<expl_cb>" . htmlspecialchars($expl->expl_cb, ENT_QUOTES, $charset) . "</expl_cb>\n"; $this->expl_info .= "\t\t<expl_cote>" . htmlspecialchars($expl->expl_cote, ENT_QUOTES, $charset) . "</expl_cote>\n"; $this->expl_info .= "\t\t<tdoc_label>" . htmlspecialchars($expl->tdoc_libelle, ENT_QUOTES, $charset) . "</tdoc_label>\n"; if ($pmb_gestion_financiere && $pmb_gestion_amende) { $amende = new amende($expl->pret_idempr); $amd = $amende->get_amende($expl->expl_id); if ($amd["valeur"]) { $this->expl_info .= "\t\t<expl_fee>" . htmlspecialchars(comptes::format_simple($amd["valeur"]), ENT_QUOTES, $charset) . "</expl_fee>\n"; $valeur = $amd["valeur"]; } } if ($niveau) { $this->expl_info .= "\t\t<expl_niveau>3</expl_niveau>\n"; } if ($id_empr) { $req_empr = "select empr_nom as nom, empr_prenom as prenom from empr where id_empr={$id_empr}"; $res = mysql_query($req_empr, $dbh); $empr = mysql_fetch_object($res); $this->expl_info .= "<empr_surname>" . htmlspecialchars($empr->nom, ENT_QUOTES, $charset) . "</empr_surname>"; $this->expl_info .= "<empr_name>" . htmlspecialchars($empr->prenom, ENT_QUOTES, $charset) . "</empr_name>"; } $this->expl_info .= " \t</expl>\n"; return $valeur; }
function send_mail($id_empr, $relance) { global $pmb_gestion_devise, $msg, $charset; global $biblio_name, $biblio_email, $biblio_phone, $PMBuseremailbcc; // l'objet du mail $var = "mailretard_" . $relance . "objet"; global ${$var}; eval("\$objet=\"" . ${$var} . "\";"); // la formule de politesse du bas (le signataire) $var = "mailretard_" . $relance . "fdp"; global ${$var}; eval("\$fdp=\"" . ${$var} . "\";"); // le texte après la liste des ouvrages en retard $var = "mailretard_" . $relance . "after_list"; global ${$var}; eval("\$after_list=\"" . ${$var} . "\";"); // le texte avant la liste des ouvrges en retard $var = "mailretard_" . $relance . "before_list"; global ${$var}; eval("\$before_list=\"" . ${$var} . "\";"); // le "Madame, Monsieur," ou tout autre truc du genre "Cher adhérent," $var = "mailretard_" . $relance . "madame_monsieur"; global ${$var}; eval("\$madame_monsieur=\"" . ${$var} . "\";"); if ($madame_monsieur) { $texte_mail .= $madame_monsieur . "\r\n\r\n"; } if ($before_list) { $texte_mail .= $before_list . "\r\n\r\n"; } //Récupération des exemplaires $rqt = "select pret_idempr, expl_id, expl_cb from pret, exemplaires where pret_idempr='" . $id_empr . "' and pret_retour < curdate() and pret_idexpl=expl_id order by pret_date "; $req = pmb_mysql_query($rqt) or die('Erreur SQL !<br />' . $rqt . '<br />' . pmb_mysql_error()); $i = 0; $total_amendes = 0; //Calcul des frais de relance $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 < 0) { $frais_relance = -$frais_relance; } else { $frais_relance = 0; } } while ($data = pmb_mysql_fetch_array($req)) { //Calcul des amendes $valeur = 0; $amende = new amende($data["pret_idempr"]); $amd = $amende->get_amende($data["expl_id"]); if ($amd["valeur"]) { $valeur = $amd["valeur"]; $total_amendes += $valeur; } /* Récupération des infos exemplaires et prêt */ $requete = "SELECT notices_m.notice_id as m_id, notices_s.notice_id as s_id, expl_cb, pret_date, pret_retour, tdoc_libelle, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, "; $requete .= " date_format(pret_date, '" . $msg["format_date"] . "') as aff_pret_date, "; $requete .= " date_format(pret_retour, '" . $msg["format_date"] . "') as aff_pret_retour, "; $requete .= " IF(pret_retour>sysdate(),0,1) as retard, notices_m.tparent_id, notices_m.tnvol "; $requete .= "FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), docs_type , pret "; $requete .= "WHERE expl_cb='" . addslashes($data['expl_cb']) . "' and expl_typdoc = idtyp_doc and pret_idexpl = expl_id "; $res = pmb_mysql_query($requete); $expl = pmb_mysql_fetch_object($res); $responsabilites = array(); $header_aut = ""; $responsabilites = get_notice_authors($expl->m_id + $expl->s_id); $as = array_search("0", $responsabilites["responsabilites"]); if ($as !== FALSE && $as !== NULL) { $auteur_0 = $responsabilites["auteurs"][$as]; $auteur = new auteur($auteur_0["id"]); $header_aut .= $auteur->isbd_entry; } else { $aut1_libelle = array(); $as = array_keys($responsabilites["responsabilites"], "1"); for ($i = 0; $i < count($as); $i++) { $indice = $as[$i]; $auteur_1 = $responsabilites["auteurs"][$indice]; $auteur = new auteur($auteur_1["id"]); $aut1_libelle[] = $auteur->isbd_entry; } $header_aut .= implode(", ", $aut1_libelle); } $header_aut ? $auteur = " / " . $header_aut : ($auteur = ""); // récupération du titre de série $tit_serie = ""; if ($expl->tparent_id && $expl->m_id) { $parent = new serie($expl->tparent_id); $tit_serie = $parent->name; if ($expl->tnvol) { $tit_serie .= ', ' . $expl->tnvol; } } if ($tit_serie) { $expl->tit = $tit_serie . '. ' . $expl->tit; } $texte_mail .= $expl->tit . $auteur . "\r\n"; $texte_mail .= " -" . sprintf($msg["relance_mail_retard_dates"], $expl->aff_pret_date, $expl->aff_pret_retour); if ($valeur) { $texte_mail .= " " . sprintf($msg["relance_mail_retard_amende"], comptes::format_simple($valeur)); } $texte_mail .= "\r\n"; $i++; } if ($total_amendes) { $texte_mail .= "\r\n" . sprintf($msg["relance_mail_retard_total_amendes"], comptes::format_simple($total_amendes)); } if ($frais_relance) { $texte_mail .= "\r\n" . $msg["relance_lettre_retard_frais_relance"] . comptes::format_simple($frais_relance); } if ($frais_relance && $total_amendes) { $texte_mail .= "\r\n" . $msg["relance_lettre_retard_total_du"] . comptes::format_simple($total_amendes + $frais_relance); } $texte_mail .= "\r\n\r\n"; if ($after_list) { $texte_mail .= $after_list . "\r\n\r\n"; } if ($fdp) { $texte_mail .= $fdp . "\r\n\r\n"; } $texte_mail .= mail_bloc_adresse(); //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={$id_empr} and resp_groupe and mail_rappel limit 1"; $res = pmb_mysql_query($requete); /* Récupération du nom, prénom et mail du lecteur destinataire */ if (pmb_mysql_num_rows($res) > 0) { $requete = "select id_empr, empr_mail, empr_nom, empr_prenom from empr where id_empr='" . pmb_mysql_result($res, 0, 1) . "'"; $result = pmb_mysql_query($requete); $coords_dest = pmb_mysql_fetch_object($result); } else { $requete = "select id_empr, empr_mail, empr_nom, empr_prenom from empr where id_empr={$id_empr}"; $res = pmb_mysql_query($requete); $coords_dest = pmb_mysql_fetch_object($res); } /* Récupération du nom, prénom et mail du lecteur concerné */ $requete = "select id_empr, empr_mail, empr_nom, empr_prenom, empr_cb from empr where id_empr={$id_empr}"; $res = pmb_mysql_query($requete); $coords = pmb_mysql_fetch_object($res); //remplacement nom et prenom $texte_mail = str_replace("!!empr_name!!", $coords->empr_nom, $texte_mail); $texte_mail = str_replace("!!empr_first_name!!", $coords->empr_prenom, $texte_mail); // function mailpmb($to_nom="", $to_mail, $obj="", $corps="", $from_name="", $from_mail, $headers, $copie_CC="", $copie_BCC="", $faire_nl2br=0, $pieces_jointes=array()) { $res_envoi = mailpmb($coords_dest->empr_prenom . " " . $coords_dest->empr_nom, $coords_dest->empr_mail, $objet . " : " . $coords->empr_prenom . " " . mb_strtoupper($coords->empr_nom, $charset) . " (" . $coords->empr_cb . ")", $texte_mail, $biblio_name, $biblio_email, "Content-Type: text/plain; charset=\"{$charset}\"\n", "", $PMBuseremailbcc, 1); return $res_envoi; }
function print_amendes($valeur, $frais_relance) { global $pmb_pdf_font, $ourPDF, $largeur_page, $marge_page_droite, $marge_page_gauche, $msg, $debut_expl_page; //Si il y a des amendes $ourPDF->SetY($ourPDF->GetY() + 2); $ourPDF->setFont($pmb_pdf_font, '', 10); $ourPDF->SetWidths(array(70, 30)); if ($ourPDF->GetY() > 260) { $ourPDF->addPage(); $ourPDF->SetY($debut_expl_page); } if ($valeur) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_total_amendes"], comptes::format_simple($valeur))); } if ($frais_relance) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_frais_relance"], comptes::format_simple($frais_relance))); } if ($frais_relance && $valeur) { $ourPDF->SetX($marge_page_gauche + 40); $ourPDF->Row(array($msg["relance_lettre_retard_total_du"], comptes::format_simple($valeur + $frais_relance))); } $ourPDF->SetY($ourPDF->GetY() + 4); }