1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Associaspip, extension de SPIP pour gestion d'associations * |
---|
4 | * * |
---|
5 | * Copyright (c) 2007 Bernard Blazin & François de Montlivault (V1) * |
---|
6 | * Copyright (c) 2010-2011 Emmanuel Saint-James & Jeannot Lapin (V2) * |
---|
7 | * * |
---|
8 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
---|
9 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
---|
10 | \***************************************************************************/ |
---|
11 | |
---|
12 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
13 | |
---|
14 | include_spip('inc/texte'); // pour nettoyer_raccourci_typo |
---|
15 | |
---|
16 | function voir_adherent_paiements($data, $lien, $type) |
---|
17 | { |
---|
18 | foreach($data as $k => $row) { |
---|
19 | $j = $lien ? $row['justification'] |
---|
20 | : nettoyer_raccourcis_typo($row['justification']); |
---|
21 | $id = $row['id']; |
---|
22 | $id_compte = ($row['id_compte'])?$row['id_compte']:$id; // l'id_compte est soit explicitement present dans la ligne(pour les dons), sinon c'est qu'il est le meme qu'id (pour les cotisations) |
---|
23 | $data[$k] = "<tr id='$type$id' style='background-color: #EEEEEE;'>" |
---|
24 | . "<td class='arial11 border1' style='text-align:right;'>$id</td>\n" |
---|
25 | . '<td class="arial11 border1">'.$row['journal']."</td>\n" |
---|
26 | . '<td class="arial11 border1">'.association_datefr($row['date'])."</td>\n" |
---|
27 | . '<td class="arial11 border1">'.propre($j)."</td>\n" |
---|
28 | . '<td class="arial11 border1" style="text-align:right;">'.$row['montant'].' €</td>' |
---|
29 | . '<td style="text-align:right;">' |
---|
30 | . association_bouton(_T('asso:adherent_label_voir_operation'), 'voir-12.png', 'comptes','id_compte='.$id_compte) |
---|
31 | . "</td>" |
---|
32 | . '</tr>'; |
---|
33 | } |
---|
34 | return $data; |
---|
35 | } |
---|
36 | |
---|
37 | function voir_adherent_cotisations($id_auteur, $full=false) |
---|
38 | { |
---|
39 | $row = sql_allfetsel('id_compte AS id, recette AS montant, date, justification, journal', "spip_asso_comptes", "id_journal=$id_auteur AND imputation=" . sql_quote($GLOBALS['association_metas']['pc_cotisations']), '', "date DESC, id_compte DESC" ); |
---|
40 | |
---|
41 | if (!$row) return ''; |
---|
42 | |
---|
43 | return "<table border='0' cellpadding='2' cellspacing='0' width='100%' class='arial2' style='border: 1px solid #aaaaaa;'>\n" |
---|
44 | . "<tr style='background-color: #DBE1C5;'>\n" |
---|
45 | . '<th style="text-align:right;">'._T('asso:adherent_entete_id').'</th>' |
---|
46 | . '<th>'._T('asso:adherent_entete_journal').'</th>' |
---|
47 | . '<th>'._T('asso:adherent_entete_date').'</th>' |
---|
48 | . '<th>'._T('asso:adherent_entete_justification').'</th>' |
---|
49 | . '<th style="text-align:right;">'._T('asso:montant').'</th>' |
---|
50 | . '<th style="text-align:right;">'._T('asso:action').'</th>' |
---|
51 | . '</tr>' |
---|
52 | . join("\n", voir_adherent_paiements($row, $full, 'cotisation')) |
---|
53 | . '</table>'; |
---|
54 | } |
---|
55 | |
---|
56 | function voir_adherent_dons($id_auteur, $full=false) |
---|
57 | { |
---|
58 | $row = sql_allfetsel('D.id_don AS id, D.argent AS montant, D.date_don AS date, justification, journal, id_compte', |
---|
59 | "spip_asso_dons AS D LEFT JOIN spip_asso_comptes AS C ON C.id_journal=D.id_don", |
---|
60 | 'C.imputation=' . sql_quote($GLOBALS['association_metas']['pc_dons']) . ' AND '. 'id_adherent='.$id_auteur, |
---|
61 | '', |
---|
62 | "D.date_don DESC" ); |
---|
63 | |
---|
64 | if (!$row) return ''; |
---|
65 | |
---|
66 | return "<table border='0' cellpadding='2' cellspacing='0' width='100%' class='arial2' style='border: 1px solid #aaaaaa;'>\n" |
---|
67 | . "<tr style='background-color: #DBE1C5;'>\n" |
---|
68 | . '<th style="text-align:right;">'._T('asso:adherent_entete_id').'</th>' |
---|
69 | . '<th>'._T('asso:adherent_entete_journal').'</th>' |
---|
70 | . '<th>'._T('asso:adherent_entete_date').'</th>' |
---|
71 | . '<th>'._T('asso:adherent_entete_justification').'</th>' |
---|
72 | . '<th style="text-align:right;">'._T('asso:montant').'</th>' |
---|
73 | . '<th style="text-align:right;">'._T('asso:action').'</th>' |
---|
74 | . '</tr>' |
---|
75 | . join("\n", voir_adherent_paiements($row, $full, 'don')) |
---|
76 | . '</table>'; |
---|
77 | } |
---|
78 | |
---|
79 | function voir_adherent_ventes($critere) |
---|
80 | { |
---|
81 | $row = sql_allfetsel('id_vente AS id ,article, quantite, date_vente, date_envoi', "spip_asso_ventes", $critere, '', "date_vente DESC" ); |
---|
82 | if (!$row) return ''; |
---|
83 | |
---|
84 | foreach($row as $k => $v) { |
---|
85 | $row[$k] = '<tr style="background-color: #EEEEEE;">' |
---|
86 | . '<td class="arial11 border1" style="text-align:right;">'.$v['id']."</td>\n" |
---|
87 | . '<td class="arial11 border1" style="text-align:right;">'.association_datefr($v['date_vente'])."</td>\n" |
---|
88 | . '<td class="arial11 border1">'.$v['article']."</td>\n" |
---|
89 | . '<td class="arial11 border1" style="text-align:right;">'.$v['quantite']."</td>\n" |
---|
90 | . '<td class="arial11 border1" style="text-align:right;">'.association_datefr($v['date_envoi'])."</td>\n" |
---|
91 | . '<td class="arial11 border1" style="text-align:center;">' |
---|
92 | . association_bouton(_T('asso:adherent_bouton_maj_vente'), 'edit-12.gif', 'edit_vente','id='.$v['id']) |
---|
93 | . "</td>\n" |
---|
94 | . '</tr>'; |
---|
95 | } |
---|
96 | |
---|
97 | return "<table border='0' cellpadding='2' cellspacing='0' width='100%' class='arial2' style='border: 1px solid #aaaaaa;'>\n" |
---|
98 | . "<tr style='background-color: #DBE1C5;'>\n" |
---|
99 | . '<th style="text-align:right;">'._T('asso:vente_entete_id')."</th>\n" |
---|
100 | . '<th>'._T('asso:vente_entete_date')."</th>\n" |
---|
101 | . '<th>'._T('asso:vente_entete_article')."</th>\n" |
---|
102 | . '<th style="text-align:right;">'._T('asso:vente_entete_quantites')."</th>\n" |
---|
103 | . '<th>'._T('asso:vente_entete_date_envoi')."</th>\n" |
---|
104 | . "<td><strong> </strong></td>\n" |
---|
105 | . '</tr>' |
---|
106 | . join("", $row) |
---|
107 | . '</table>'; |
---|
108 | } |
---|
109 | |
---|
110 | function voir_adherent_recus($id_auteur) |
---|
111 | { |
---|
112 | $row = array_map('array_shift', sql_allfetsel("date_format( date, '%Y' ) AS annee", "spip_asso_comptes", "id_journal=$id_auteur", 'annee', "annee ASC" )); |
---|
113 | foreach($row as $k => $annee) { |
---|
114 | $h = generer_url_ecrire('pdf_fiscal', "id=$id_auteur&annee=$annee"); |
---|
115 | $row[$k] = "<a href='$h'>$annee</a>"; |
---|
116 | } |
---|
117 | return join("\n", $row); |
---|
118 | } |
---|
119 | |
---|
120 | ?> |
---|