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 | |
---|
13 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
14 | |
---|
15 | include_spip('inc/navigation_modules'); |
---|
16 | include_spip ('inc/voir_adherent'); // pour voir_adherent_infos |
---|
17 | |
---|
18 | function exec_adherents() { |
---|
19 | |
---|
20 | include_spip('inc/autoriser'); |
---|
21 | if (!autoriser('associer', 'adherents')) { |
---|
22 | include_spip('inc/minipres'); |
---|
23 | echo minipres(); |
---|
24 | } else { |
---|
25 | $url_association = generer_url_ecrire('association'); |
---|
26 | $url_adherents = generer_url_ecrire('adherents'); |
---|
27 | $url_edit_relances=generer_url_ecrire('edit_relances'); |
---|
28 | |
---|
29 | //debut_page(_T('asso:titre_gestion_pour_association'), "", ""); |
---|
30 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
---|
31 | echo $commencer_page(_T('asso:association')) ; |
---|
32 | association_onglets(_T('asso:titre_onglet_membres')); |
---|
33 | |
---|
34 | echo debut_gauche("",true); |
---|
35 | |
---|
36 | $critere = request_statut_interne(); // peut appeler set_request |
---|
37 | $statut_interne = _request('statut_interne'); |
---|
38 | |
---|
39 | echo debut_boite_info(true); |
---|
40 | |
---|
41 | echo association_icone(_T('asso:menu2_titre_relances_cotisations'), $url_edit_relances, 'ico_panier.png'); |
---|
42 | echo '<p>'._T('asso:adherent_liste_legende').'</p>'; |
---|
43 | |
---|
44 | // TOTAUX |
---|
45 | |
---|
46 | echo '<div><strong>'._T('asso:adherent_liste_nombre').'</strong></div>'; |
---|
47 | $nombre= $nombre_total=0; |
---|
48 | $membres = $GLOBALS['association_liste_des_statuts']; |
---|
49 | array_shift($membres); // ancien membre |
---|
50 | foreach ($membres as $statut) { |
---|
51 | $nombre=sql_countsel('spip_asso_membres', "statut_interne='$statut'"); |
---|
52 | echo '<div style="float:right;text_align:right">'.$nombre.'</div>'; |
---|
53 | echo '<div>'._T('asso:adherent_liste_nombre_'.$statut).'</div>'; |
---|
54 | $nombre_total += $nombre; |
---|
55 | } |
---|
56 | echo '<div style="float:right;text_align:right">'.$nombre_total.'</div>'; |
---|
57 | echo '<div>'._T('asso:adherent_liste_nombre_total').'</div>'; |
---|
58 | |
---|
59 | echo association_date_du_jour(); |
---|
60 | |
---|
61 | echo fin_boite_info(true); |
---|
62 | |
---|
63 | echo debut_cadre_enfonce('',true), |
---|
64 | '<h3 style="text-align:center;">', |
---|
65 | _T('plugins_vue_liste'), '</h3>', |
---|
66 | adherents_table(), |
---|
67 | fin_cadre_enfonce(true); |
---|
68 | |
---|
69 | |
---|
70 | echo debut_droite("",true); |
---|
71 | |
---|
72 | echo debut_cadre_relief( "", true, "", $titre = _T('asso:adherent_titre_liste_actifs')); |
---|
73 | |
---|
74 | echo "<table border='0' cellpadding='2' cellspacing='0' width='100%' class='arial2'>\n"; |
---|
75 | echo "<tr>"; |
---|
76 | |
---|
77 | // PAGINATION ALPHABETIQUE |
---|
78 | echo '<td>'; |
---|
79 | |
---|
80 | $lettre= _request('lettre'); |
---|
81 | if (!$lettre) { $lettre = "%"; } |
---|
82 | |
---|
83 | $query = sql_select("upper( substring( nom_famille, 1, 1 ) ) AS init", 'spip_asso_membres', '', 'init', 'nom_famille, id_auteur'); |
---|
84 | |
---|
85 | while ($data = sql_fetch($query)) { |
---|
86 | $i = $data['init']; |
---|
87 | if($i==$lettre) { |
---|
88 | echo ' <strong>'.$i.'</strong>'; |
---|
89 | } |
---|
90 | else { |
---|
91 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne&lettre=$i"); |
---|
92 | echo " <a href='$h'>$i</a>\n"; |
---|
93 | } |
---|
94 | } |
---|
95 | if ($lettre == "%") { echo ' <strong>'._T('asso:adherent_entete_tous').'</strong>'; } |
---|
96 | else { |
---|
97 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne"); |
---|
98 | echo "\n<a href='$h'>"._T('asso:adherent_entete_tous').'</a>'; } |
---|
99 | |
---|
100 | // FILTRES |
---|
101 | echo '</td><td style="text-align:right;">'; |
---|
102 | |
---|
103 | //Filtre ID |
---|
104 | $id = intval(_request('id')); |
---|
105 | if (!$id) { |
---|
106 | $id = _T('asso:adherent_libelle_id_auteur'); |
---|
107 | } else { |
---|
108 | $critere = "a.id_auteur=$id"; |
---|
109 | } |
---|
110 | |
---|
111 | echo "\n<form method='post' action='".$url_adherents."'><div>"; |
---|
112 | echo '<input type="text" name="id" class="fondl" style="padding:0.5px" onfocus=\'this.value=""\' size="10" value="'. $id .'" onchange="form.submit()" />'; |
---|
113 | echo '</div></form>'; |
---|
114 | echo '</td>'; |
---|
115 | echo '<td style="text-align:right;">'; |
---|
116 | |
---|
117 | //Filtre statut |
---|
118 | echo "\n<form method='post' action='".$url_adherents."'><div>\n"; |
---|
119 | echo '<input type="hidden" name="lettre" value="'.$lettre.'" />'; |
---|
120 | echo "\n<select name='statut_interne' class='fondl' onchange='form.submit()'>\n"; |
---|
121 | echo "<option value='defaut'>"._T('asso:adherent_entete_statut_defaut')."</option>"; |
---|
122 | foreach ($GLOBALS['association_liste_des_statuts'] as $statut) { |
---|
123 | echo "\n<option value='".$statut."'"; |
---|
124 | if ($statut_interne==$statut) {echo ' selected="selected"';} |
---|
125 | echo '> '._T('asso:adherent_entete_statut_'.$statut).'</option>'; |
---|
126 | } |
---|
127 | echo '</select>'; |
---|
128 | echo '</div></form>'; |
---|
129 | echo '</td>'; |
---|
130 | echo '</tr>'; |
---|
131 | echo '</table>'; |
---|
132 | |
---|
133 | //Affichage de la liste |
---|
134 | echo adherents_liste(intval(_request('debut')), $lettre, $critere, $statut_interne); |
---|
135 | echo fin_cadre_relief(true); |
---|
136 | echo fin_page_association(); |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | function adherents_liste($debut, $lettre, $critere, $statut_interne) |
---|
141 | { |
---|
142 | |
---|
143 | $max_par_page=30; |
---|
144 | |
---|
145 | if ($lettre) |
---|
146 | $critere .= " AND upper( substring( nom_famille, 1, 1 ) ) like '$lettre' "; |
---|
147 | $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
---|
148 | $query = voir_adherent_infos("*", '', $critere, '', "nom_famille ", "$debut,$max_par_page" ); |
---|
149 | $auteurs = ''; |
---|
150 | while ($data = sql_fetch($query)) { |
---|
151 | $id_auteur=$data['id_auteur']; |
---|
152 | $class = $GLOBALS['association_styles_des_statuts'][$data['statut_interne']] . " border1"; |
---|
153 | |
---|
154 | $logo = $chercher_logo($id_auteur, 'id_auteur'); |
---|
155 | if ($logo) { |
---|
156 | $logo = '"'. $logo[0] . '" width="60"'; |
---|
157 | }else{ |
---|
158 | $logo = '"'._DIR_PLUGIN_ASSOCIATION_ICONES.'ajout.gif" width="10"' ; |
---|
159 | } |
---|
160 | if (empty($data["email"])) { |
---|
161 | $mail = $data["nom_famille"]; |
---|
162 | } else { |
---|
163 | $mail = '<a href="mailto:'.$data["email"].'">'.$data["nom_famille"].'</a>'; |
---|
164 | } |
---|
165 | if ($data['validite']==""){$valide = ' ';}else{$valide = association_datefr($data['validite']);} |
---|
166 | |
---|
167 | $statut = $data['statut']; |
---|
168 | if (!$statut OR $statut == 'nouveau') $statut = $data['bio']; |
---|
169 | |
---|
170 | switch($statut) { |
---|
171 | case "0minirezo": |
---|
172 | $icone= "admin-12.gif"; break; |
---|
173 | case "1comite": |
---|
174 | $icone="redac-12.gif"; break; |
---|
175 | case "5poubelle": |
---|
176 | $icone="poubelle-12.gif"; break; |
---|
177 | case "6forum": |
---|
178 | $icone="visit-12.gif"; break; |
---|
179 | default : |
---|
180 | $icone='';#"adher-12.gif"; break; |
---|
181 | } |
---|
182 | $icone = !$icone ? strlen($statut) : http_img_pack($icone,'','', _T('asso:adherent_label_modifier_visiteur')); |
---|
183 | |
---|
184 | $auteurs .= "\n<tr>" |
---|
185 | . '<td style="text-align:right;" class="'.$class. '">' |
---|
186 | . $id_auteur |
---|
187 | . '</td>' |
---|
188 | . '<td class="'.$class. '">' |
---|
189 | . "<img src=$logo" . ' alt=" " title="' |
---|
190 | . $data["nom_famille"].' '.$data["prenom"].'" />' |
---|
191 | . "</td>\n"; |
---|
192 | if ($GLOBALS['association_metas']['civilite']=="on") $auteurs .= '<td class="'.$class. '">'.$data['sexe']."</td>\n"; |
---|
193 | $auteurs .= '<td class="'.$class. '">' |
---|
194 | . $mail . "</td>\n"; |
---|
195 | if ($GLOBALS['association_metas']['prenom']=="on") $auteurs .= '<td class="'.$class. '">'.$data["prenom"]."</td>\n"; |
---|
196 | if ($GLOBALS['association_metas']['id_asso']=="on") $auteurs .= '<td class="'.$class. '">'.$data["id_asso"]."</td>\n"; |
---|
197 | $auteurs .= '<td class="'.$class. '">' |
---|
198 | . affiche_categorie($data["categorie"]) |
---|
199 | . "</td>\n" |
---|
200 | . '<td class="'.$class. '">' . $valide . "</td>\n" |
---|
201 | . '<td class="'.$class. '">' |
---|
202 | . '<a href="' |
---|
203 | . generer_url_ecrire('auteur_infos','id_auteur='.$id_auteur) |
---|
204 | .'">' |
---|
205 | . $icone |
---|
206 | ."</a></td>\n" |
---|
207 | . '<td class="'.$class. '">' |
---|
208 | . association_bouton(_T('asso:adherent_label_ajouter_cotisation'), 'cotis-12.gif', 'ajout_cotisation','id='.$id_auteur) |
---|
209 | ."</td>\n" |
---|
210 | . '<td class="'.$class. '">' |
---|
211 | . association_bouton(_T('asso:adherent_label_modifier_membre'), 'edit-12.gif', 'edit_adherent','id='.$id_auteur) |
---|
212 | ."</td>\n" |
---|
213 | . '<td class="'.$class. '">' |
---|
214 | . association_bouton(_T('asso:adherent_label_voir_membre'), 'voir-12.png', 'voir_adherent','id='.$id_auteur) |
---|
215 | . "</td>\n" |
---|
216 | . '<td class="'.$class. '"><input name="delete[]" type="checkbox" value="'.$id_auteur.'" /></td>' |
---|
217 | . "</tr>\n"; |
---|
218 | } |
---|
219 | |
---|
220 | $res = "<table border='0' cellpadding='2' cellspacing='0' width='100%' class='arial2' style='border: 1px solid #aaaaaa;'>\n" |
---|
221 | . "<tr style='background-color: #DBE1C5;'>\n" |
---|
222 | . "<td><strong>"._T('asso:adherent_libelle_id_auteur')."</strong></td>\n" |
---|
223 | . "<th>"._T('asso:adherent_libelle_photo')."</th>\n"; |
---|
224 | if ($GLOBALS['association_metas']['civilite']=="on") $res .= "<th>"._T('asso:adherent_libelle_sexe')."</th>\n"; |
---|
225 | $res .= "<th>"._T('asso:adherent_libelle_nom_famille')."</th>\n"; |
---|
226 | if ($GLOBALS['association_metas']['prenom']=="on") $res .= "<th>"._T('asso:adherent_libelle_prenom')."</th>\n"; |
---|
227 | if ($GLOBALS['association_metas']['id_asso']=="on") $res .= "<th>"._T('asso:adherent_libelle_id_asso')."</th>\n"; |
---|
228 | $res .= "<th>"._T('asso:adherent_libelle_categorie')."</th>\n" |
---|
229 | . "<th>"._T('asso:adherent_libelle_validite')."</th>\n" |
---|
230 | . '<th colspan="4" style="text-align:center;">'._T('asso:adherent_entete_action')."</th>\n" |
---|
231 | . "<th>"._T('asso:adherent_entete_supprimer_abrev')."</th>\n" |
---|
232 | . '</tr>' |
---|
233 | . $auteurs |
---|
234 | . '</table>'; |
---|
235 | |
---|
236 | //SOUS-PAGINATION |
---|
237 | |
---|
238 | $nombre_selection=sql_countsel('spip_asso_membres', $critere); |
---|
239 | |
---|
240 | $pages=intval($nombre_selection/$max_par_page) + 1; |
---|
241 | |
---|
242 | if ($pages != 1) { |
---|
243 | for ($i=0;$i<$pages;$i++) { |
---|
244 | $position= $i * $max_par_page; |
---|
245 | if ($position == $debut) { |
---|
246 | $res .= '<strong>'.$position."</strong>\n"; |
---|
247 | } |
---|
248 | else { |
---|
249 | $h = generer_url_ecrire('adherents', 'lettre='.$lettre.'&debut='.$position.'&statut_interne='.$statut_interne); |
---|
250 | $res .= "<a href='$h'>$position</a>\n"; |
---|
251 | } |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | $res .= "\n<div style='float:right;'>\n" |
---|
256 | . (!$auteurs ? '' : ('<input type="submit" value="'._T('asso:bouton_supprimer').'" class="fondo" />')) |
---|
257 | . '</div>'; |
---|
258 | |
---|
259 | return generer_form_ecrire('action_adherents', $res); |
---|
260 | |
---|
261 | } |
---|
262 | |
---|
263 | function affiche_categorie($c) |
---|
264 | { |
---|
265 | return is_numeric($c) |
---|
266 | ? sql_getfetsel("valeur", "spip_asso_categories", "id_categorie=$c") |
---|
267 | : $c; |
---|
268 | } |
---|
269 | |
---|
270 | function adherents_table() |
---|
271 | { |
---|
272 | $champs = $GLOBALS['association_tables_principales']['spip_asso_membres']['field']; |
---|
273 | $res = ''; |
---|
274 | foreach ($champs as $k => $v) { |
---|
275 | $libelle = 'adherent_libelle_' . $k; |
---|
276 | $trad = _T('asso:' . $libelle); |
---|
277 | if ($libelle != str_replace(' ', '_', $trad)) { |
---|
278 | $res .= "<input type='checkbox' name='champs[$k]' />$trad<br />"; |
---|
279 | } |
---|
280 | } |
---|
281 | return generer_form_ecrire('pdf_adherents', $res, '', _T('asso:bouton_impression')); |
---|
282 | } |
---|
283 | |
---|
284 | ?> |
---|