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')) |
---|
14 | return; |
---|
15 | |
---|
16 | include_spip('inc/navigation_modules'); |
---|
17 | |
---|
18 | function exec_adherents() |
---|
19 | { |
---|
20 | if (!autoriser('associer', 'adherents')) { |
---|
21 | include_spip('inc/minipres'); |
---|
22 | echo minipres(); |
---|
23 | } else { |
---|
24 | /* recuperation des variables */ |
---|
25 | $critere = request_statut_interne(); // peut appeler set_request |
---|
26 | $statut_interne = _request('statut_interne'); |
---|
27 | $lettre = _request('lettre'); |
---|
28 | onglets_association('titre_onglet_membres'); |
---|
29 | // TOTAUX : effectifs par statuts |
---|
30 | $membres = $GLOBALS['association_liste_des_statuts']; |
---|
31 | array_shift($membres); // on sort les anciens membres |
---|
32 | $liste_libelles = $liste_effectifs = array(); |
---|
33 | foreach ($membres as $statut) { |
---|
34 | $classe_css = $GLOBALS['association_styles_des_statuts'][$statut]; |
---|
35 | $liste_libelles[$classe_css] = _T('asso:adherent_liste_nombre_'.$statut); |
---|
36 | $liste_effectifs[$classe_css] = sql_countsel('spip_asso_membres', "statut_interne='$statut'"); |
---|
37 | } |
---|
38 | echo totauxinfos_effectifs('adherents', $liste_libelles, $liste_effectifs); |
---|
39 | // TOTAUX : montants des cotisations durant l'annee en cours |
---|
40 | $data = sql_fetsel('SUM(recette) AS somme_recettes, SUM(depense) AS somme_depenses', 'spip_asso_comptes', "DATE_FORMAT('date', '%Y')=DATE_FORMAT(NOW(), '%Y') AND imputation=".sql_quote($GLOBALS['association_metas']['pc_cotisations']) ); |
---|
41 | echo totauxinfos_montants(_T('asso:cotisations'), $data['somme_recettes'], $data['somme_depenses']); |
---|
42 | // datation et raccourcis |
---|
43 | $res['gerer_les_groupes'] = array('annonce.gif', 'groupes'); |
---|
44 | $res['menu2_titre_relances_cotisations'] = array('relance-24.png', 'edit_relances'); |
---|
45 | $res['synchronise_asso_membre_lien'] = array('reload-32.png', 'synchroniser_asso_membres'); |
---|
46 | icones_association(array(), $res); |
---|
47 | if ( test_plugin_actif('FPDF') && test_plugin_actif('COORDONNEES') ) { // etiquettes |
---|
48 | echo debut_cadre_enfonce('',true); |
---|
49 | echo recuperer_fond('prive/inc_cadre_etiquette'); |
---|
50 | fin_cadre_enfonce(); |
---|
51 | } |
---|
52 | //Filtre ID et groupe : si le filtre id est actif, on ignore le filtre groupe |
---|
53 | $id = intval(_request('id')); |
---|
54 | if (!$id) { |
---|
55 | $id = _T('asso:adherent_libelle_id_auteur'); |
---|
56 | //Filtre groupe |
---|
57 | $id_groupe = intval(_request('id_groupe')); |
---|
58 | } else { |
---|
59 | $critere = "a.id_auteur=$id"; |
---|
60 | $id_groupe = 0; |
---|
61 | } |
---|
62 | /* on appelle ici la fonction qui calcule le code du formulaire/tableau de membres pour pouvoir recuperer la liste des membres affiches a transmettre a adherents_table pour la generation du pdf */ |
---|
63 | list($liste_id_auteurs, $code_liste_membres) = adherents_liste(intval(_request('debut')), $lettre, $critere, $statut_interne, $id_groupe); |
---|
64 | if (test_plugin_actif('FPDF')) { |
---|
65 | echo debut_cadre_enfonce('',true); |
---|
66 | echo '<h3>'. _T('plugins_vue_liste') .'</h3>'; |
---|
67 | echo adherents_table($liste_id_auteurs); |
---|
68 | fin_cadre_enfonce(); |
---|
69 | } |
---|
70 | debut_cadre_association('annonce.gif', 'adherent_titre_liste_actifs'); |
---|
71 | echo "<table width='100%' class='asso_tablo_filtres'>\n"; |
---|
72 | echo '<tr>'; |
---|
73 | // PAGINATION ALPHABETIQUE |
---|
74 | echo '<td width="30%" class="pagination0">'; |
---|
75 | if (!$lettre) { |
---|
76 | $lettre = '%'; |
---|
77 | } |
---|
78 | $query = sql_select('UPPER( LEFT( nom_famille, 1 ) ) AS init', 'spip_asso_membres', '', 'init', 'nom_famille, id_auteur'); |
---|
79 | while ($data = sql_fetch($query)) { |
---|
80 | $i = $data['init']; |
---|
81 | if($i==$lettre) { |
---|
82 | echo ' <strong>'.$i.'</strong>'; |
---|
83 | } else { |
---|
84 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne&lettre=$i"); |
---|
85 | echo " <a href='$h'>$i</a>\n"; |
---|
86 | } |
---|
87 | } |
---|
88 | if ($lettre=='%') { |
---|
89 | echo ' <strong>'._T('asso:entete_tous').'</strong>'; |
---|
90 | } else { |
---|
91 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne"); |
---|
92 | echo "<a href='$h'>"._T('asso:entete_tous').'</a>'; |
---|
93 | } |
---|
94 | // FILTRES |
---|
95 | //Filtre groupes |
---|
96 | if ( sql_countsel('spip_asso_groupes', '') ) { // ne proposer que s'il y a des groupes definis |
---|
97 | # if ($GLOBALS['association_metas']['aff_groupes']) { // ne proposer que si on affiche les groupes ?? (on peut vouloir filtrer par groupe sans pour autant les afficher donc desactive) |
---|
98 | echo '</td><td width="25%" class="formulaire">'; |
---|
99 | echo '<form method="post" action="'.generer_url_ecrire('adherents').'"><div>'; |
---|
100 | echo '<input type="hidden" name="exec" value="adherents" />'; |
---|
101 | echo '<select name="id_groupe" onchange="form.submit()">'; |
---|
102 | $qGroupes = sql_select('nom, id_groupe', 'spip_asso_groupes', '', 'nom'); |
---|
103 | echo '<option value="">'._T('asso:tous_les_groupes').'</option>'; |
---|
104 | while ($groupe = sql_fetch($qGroupes)) { |
---|
105 | echo '<option value="'.$groupe['id_groupe'].'"'; |
---|
106 | if ($id_groupe==$groupe['id_groupe']) |
---|
107 | echo ' selected="selected"'; |
---|
108 | echo '>'.$groupe['nom'].'</option>'; |
---|
109 | } |
---|
110 | echo '</select><noscript><input type="submit" value="'._T('lister').'" /></noscript></div></form>'; |
---|
111 | # } |
---|
112 | } |
---|
113 | //Filtre ID |
---|
114 | echo '</td><td width="16%" class="formulaire">'; |
---|
115 | echo '<form method="post" action="'.generer_url_ecrire('adherents').'"><div>'; |
---|
116 | echo '<input type="text" name="id" onfocus=\'this.value=""\' size="5" value="'. $id .'" onchange="form.submit()" />'; |
---|
117 | echo '<noscript><input type="submit" value="'._T('lister').'" /></noscript></div></form>'; |
---|
118 | //Filtre statut |
---|
119 | echo '</td><td width="23%" class="formulaire">'; |
---|
120 | echo '<form method="post" action="'.generer_url_ecrire('adherents').'"><div>'; |
---|
121 | echo '<input type="hidden" name="lettre" value="'.$lettre.'" />'; |
---|
122 | echo '<select name="statut_interne" onchange="form.submit()">'; |
---|
123 | echo '<option value="defaut">'._T('asso:entete_tous').'</option>'; |
---|
124 | foreach ($GLOBALS['association_liste_des_statuts'] as $statut) { |
---|
125 | echo '<option value="'.$statut.'"'; |
---|
126 | if ($statut_interne==$statut) { |
---|
127 | echo ' selected="selected"'; |
---|
128 | } |
---|
129 | echo '> '._T('asso:adherent_entete_statut_'.$statut).'</option>'; |
---|
130 | } |
---|
131 | echo '</select><noscript><input type="submit" value="'._T('lister').'" /></noscript></div></form>'; |
---|
132 | echo '</td>'; |
---|
133 | echo '</tr>'; |
---|
134 | echo '</table>'; |
---|
135 | //Affichage de la liste |
---|
136 | echo $code_liste_membres; |
---|
137 | fin_page_association(); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | /* adherent liste renvoie un tableau des id des auteurs affiches et le code html */ |
---|
142 | function adherents_liste($debut, $lettre, $critere, $statut_interne, $id_groupe, $max_par_page=30) |
---|
143 | { |
---|
144 | if ($lettre) |
---|
145 | $critere .= " AND UPPER( SUBSTRING( nom_famille, 1, 1 ) ) LIKE '$lettre' "; |
---|
146 | $jointure_groupe = ''; |
---|
147 | if ($id_groupe) { |
---|
148 | $critere .= " AND c.id_groupe=$id_groupe "; |
---|
149 | $jointure_groupe = ' LEFT JOIN spip_asso_groupes_liaisons c ON b.id_auteur=c.id_auteur '; |
---|
150 | } |
---|
151 | $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
---|
152 | include_spip('inc/filtres_images_mini'); |
---|
153 | $query = sql_select('a.id_auteur AS id_auteur, b.email AS email, a.sexe, a.nom_famille, a.prenom, a.id_asso, b.statut AS statut, a.validite, a.statut_interne, a.categorie, b.bio AS bio','spip_asso_membres' . " a LEFT JOIN spip_auteurs b ON a.id_auteur=b.id_auteur $jointure_groupe", $critere, '', 'nom_famille ', "$debut,$max_par_page" ); |
---|
154 | $auteurs = ''; |
---|
155 | $liste_id_auteurs = array(); |
---|
156 | while ($data = sql_fetch($query)) { |
---|
157 | $id_auteur = $data['id_auteur']; |
---|
158 | $liste_id_auteurs[] = $id_auteur; |
---|
159 | $class = $GLOBALS['association_styles_des_statuts'][$data['statut_interne']]; |
---|
160 | $logo = $chercher_logo($id_auteur, 'id_auteur'); |
---|
161 | if ($logo) { |
---|
162 | $logo = image_reduire($logo[0], 60); |
---|
163 | }else{ |
---|
164 | $logo = '<img src="'._DIR_PLUGIN_ASSOCIATION_ICONES.'membre-60.gif" width="10"/>' ; |
---|
165 | } |
---|
166 | if (empty($data['email'])) { |
---|
167 | $mail = $data['nom_famille']; |
---|
168 | } else { |
---|
169 | $mail = '<a href="mailto:'.$data['email'].'">'.$data['nom_famille'].'</a>'; |
---|
170 | } |
---|
171 | $statut = $data['statut']; |
---|
172 | if (!$statut OR $statut=='nouveau') |
---|
173 | $statut = $data['bio']; |
---|
174 | switch($statut) { |
---|
175 | case '0minirezo': |
---|
176 | $icone = 'admin-12.gif'; |
---|
177 | break; |
---|
178 | case '1comite': |
---|
179 | $icone = 'redac-12.gif'; |
---|
180 | break; |
---|
181 | case '5poubelle': |
---|
182 | $icone = 'poubelle.gif'; |
---|
183 | break; |
---|
184 | case '6forum': |
---|
185 | default : |
---|
186 | $icone = 'visit-12.gif'; |
---|
187 | break; |
---|
188 | } |
---|
189 | $icone = !$icone ? strlen($statut) : http_img_pack($icone,'','', _T('asso:adherent_label_modifier_visiteur')); |
---|
190 | $auteurs .= "<tr class='$class'>\n"; |
---|
191 | if ($GLOBALS['association_metas']['aff_id_auteur']=='on') { |
---|
192 | $auteurs .= '<td class="integer">' |
---|
193 | . $id_auteur.'</td>'; |
---|
194 | } |
---|
195 | if ($GLOBALS['association_metas']['aff_photo']=='on') { |
---|
196 | $auteurs .= '<td class="logo centre">'.$logo.'</td>'; |
---|
197 | } |
---|
198 | if ($GLOBALS['association_metas']['aff_civilite']=='on' && $GLOBALS['association_metas']['civilite']=='on') |
---|
199 | $auteurs .= '<td class="honorific-prefix">'.$data['sexe'].'</td>'; |
---|
200 | $auteurs .= '<td class="family-name">' |
---|
201 | .$mail.'</td>'; |
---|
202 | if ($GLOBALS['association_metas']['aff_prenom']=='on' && $GLOBALS['association_metas']['prenom']=='on') $auteurs .= '<td class="given-name">'.$data['prenom'].'</td>'; |
---|
203 | if ($GLOBALS['association_metas']['aff_groupes']=='on') { |
---|
204 | $auteurs .= '<td class="organisation-unit">'; |
---|
205 | $query_groupes = sql_select('g.nom as nom_groupe, g.id_groupe as id_groupe', 'spip_asso_groupes g LEFT JOIN spip_asso_groupes_liaisons l ON g.id_groupe=l.id_groupe', 'l.id_auteur='.$id_auteur); |
---|
206 | if ($row_groupes = sql_fetch($query_groupes)) { |
---|
207 | $auteurs .= '<a href="'. generer_url_ecrire('voir_groupe', 'id='.$row_groupes['id_groupe']) .'">'.$row_groupes['nom_groupe'].'</a>'; |
---|
208 | while ($row_groupes = sql_fetch($query_groupes)) { |
---|
209 | $auteurs .= ', <a href="'.generer_url_ecrire('voir_groupe', 'id='.$row_groupes['id_groupe']).'">'.$row_groupes['nom_groupe'].'</a>'; |
---|
210 | } |
---|
211 | } |
---|
212 | $auteurs .= '</td>'; |
---|
213 | } |
---|
214 | if ($GLOBALS['association_metas']['aff_id_asso']=='on' && $GLOBALS['association_metas']['id_asso']=='on') { |
---|
215 | $auteurs .= '<td class="text">'.$data['id_asso'].'</td>'; |
---|
216 | } |
---|
217 | if ($GLOBALS['association_metas']['aff_categorie']=='on') { |
---|
218 | $auteurs .= '<td class="text">'. affiche_categorie($data['categorie']) .'</td>'; |
---|
219 | } |
---|
220 | if ($GLOBALS['association_metas']['aff_validite']=='on') { |
---|
221 | $auteurs .= '<td class="date">'; |
---|
222 | if ($data['validite']==''){ |
---|
223 | $auteurs .= ' '; |
---|
224 | } else { |
---|
225 | $auteurs .= '<abbr class="dtend" title="'.$data['validite'].'">'. association_datefr($data['validite']) .'</td>'; |
---|
226 | } |
---|
227 | $auteurs .= '</td>'; |
---|
228 | } |
---|
229 | $auteurs .= '<td class="action">' |
---|
230 | . '<a href="'. generer_url_ecrire('auteur_infos','id_auteur='.$id_auteur) .'">'.$icone.'</a></td>' |
---|
231 | . '<td class="action">'. association_bouton('adherent_label_ajouter_cotisation', 'cotis-12.gif', 'ajout_cotisation','id='.$id_auteur) .'</td>' |
---|
232 | . '<td class="action">'. association_bouton('adherent_label_modifier_membre', 'edit-12.gif', 'edit_adherent','id='.$id_auteur) .'</td>' |
---|
233 | . '<td class="action">'. association_bouton('adherent_label_voir_membre', 'voir-12.png', 'voir_adherent','id='.$id_auteur) .'</td>' |
---|
234 | . '<td class="action"><input name="id_auteurs[]" type="checkbox" value="'.$id_auteur.'" /></td>' |
---|
235 | . "</tr>\n"; |
---|
236 | } |
---|
237 | |
---|
238 | $res = "<table width='100%' class='asso_tablo' id='asso_tablo_adherents'>\n" |
---|
239 | . "<thead>\n<tr>"; |
---|
240 | if ($GLOBALS['association_metas']['aff_id_auteur']=='on') { |
---|
241 | $res .= '<th>'._T('asso:entete_id').'</th>'; |
---|
242 | } |
---|
243 | if ($GLOBALS['association_metas']['aff_photo']=='on') { |
---|
244 | $res .= '<th>'._T('asso:adherent_libelle_photo').'</th>'; |
---|
245 | } |
---|
246 | if ($GLOBALS['association_metas']['aff_civilite']=='on' && $GLOBALS['association_metas']['civilite']=='on') $res .= '<th>'._T('asso:adherent_libelle_sexe').'</th>'; |
---|
247 | $res .= '<th>'._T('asso:adherent_libelle_nom_famille').'</th>'; |
---|
248 | if ($GLOBALS['association_metas']['aff_prenom']=='on' && $GLOBALS['association_metas']['prenom']=='on') $res .= '<th>'._T('asso:adherent_libelle_prenom').'</th>'; |
---|
249 | if ($GLOBALS['association_metas']['aff_groupes']=='on') { |
---|
250 | $res .= '<th>'._T('asso:adherent_libelle_groupes').'</th>'; |
---|
251 | } |
---|
252 | if ($GLOBALS['association_metas']['aff_id_asso']=='on' && $GLOBALS['association_metas']['id_asso']=='on') { |
---|
253 | $res .= '<th>'._T('asso:adherent_libelle_id_asso').'</th>'; |
---|
254 | } |
---|
255 | if ($GLOBALS['association_metas']['aff_categorie']=='on') { |
---|
256 | $res .= '<th>'._T('asso:adherent_libelle_categorie').'</th>'; |
---|
257 | } |
---|
258 | if ($GLOBALS['association_metas']['aff_validite']=='on') { |
---|
259 | $res .= '<th>'._T('asso:adherent_libelle_validite').'</th>'; |
---|
260 | } |
---|
261 | $res .= '<th colspan="4" class="actions" width="30">'._T('asso:entete_actions').'</th>' |
---|
262 | . '<th><input title="'._T('asso:selectionner_tout').'" type="checkbox" id="selectionnerTous" onclick="var currentVal = this.checked; var checkboxList = document.getElementsByName(\'id_auteurs[]\'); for (var i in checkboxList){checkboxList[i].checked=currentVal;}" /></th>' |
---|
263 | . "</tr>\n</thead><tbody>" |
---|
264 | . $auteurs |
---|
265 | . "</tbody>\n</table>\n"; |
---|
266 | //SOUS-PAGINATION |
---|
267 | $res .= "<table class='asso_tablo_filtres'><tr>\n<td width='52%'><p class='pagination'>"; |
---|
268 | $nombre_selection = sql_countsel('spip_asso_membres', $critere); |
---|
269 | $pages = intval($nombre_selection/$max_par_page)+1; |
---|
270 | if ($pages!=1) { |
---|
271 | for ($i=0; $i<$pages; $i++) { |
---|
272 | $position = $i*$max_par_page; |
---|
273 | if ($position==$debut) { |
---|
274 | $res .= '<strong>'.$position.'</strong>'; |
---|
275 | } else { |
---|
276 | $h = generer_url_ecrire('adherents', 'lettre='.$lettre.'&debut='.$position.'&statut_interne='.$statut_interne); |
---|
277 | $res .= "<a href='$h'>$position</a>\n"; |
---|
278 | } |
---|
279 | } |
---|
280 | } |
---|
281 | $res .= "</p></td><td width='48%' class='formulaire'><form>\n" |
---|
282 | . (!$auteurs ? '' : ('<select name="action_adherents"><option value="" selected="">'._T('asso:choisir_action').'</option><option value="desactive">' |
---|
283 | .($statut_interne=='sorti' ? _T('asso:reactiver_adherent') : _T('asso:desactiver_adherent')) |
---|
284 | .'</option><option value="delete">'._T('asso:supprimer_adherent').'</option>' |
---|
285 | .(sql_countsel('spip_asso_groupes', '') ? '<option value="grouper">'._T('asso:rejoindre_groupe').'</option><option value="degrouper">'._T('asso:quitter_un_groupe').'</option>' : '') |
---|
286 | .'</select><input type="submit" value="'._T('asso:bouton_confirmer').'" />')) |
---|
287 | . '<input type="hidden" name="statut_courant" value="'.$statut_interne.'" />' |
---|
288 | . '</form></td></tr></table>'; |
---|
289 | return array($liste_id_auteurs, generer_form_ecrire('action_adherents', $res)); |
---|
290 | } |
---|
291 | |
---|
292 | function affiche_categorie($c) |
---|
293 | { |
---|
294 | return is_numeric($c) |
---|
295 | ? sql_getfetsel('valeur', 'spip_asso_categories', "id_categorie=$c") |
---|
296 | : $c; |
---|
297 | } |
---|
298 | |
---|
299 | function adherents_table($liste_id_auteurs) |
---|
300 | { |
---|
301 | $champs = description_table('spip_asso_membres'); |
---|
302 | $res = ''; |
---|
303 | foreach ($champs['field'] as $k => $v) { |
---|
304 | if (!(($GLOBALS['association_metas']['civilite']!='on' && $k=='sexe') OR ($GLOBALS['association_metas']['prenom']!='on' && $k=='prenom') OR ($GLOBALS['association_metas']['id_asso']!='on' && $k=='id_asso'))) { |
---|
305 | $libelle = 'adherent_libelle_'.$k; |
---|
306 | $trad = _T('asso:'.$libelle); |
---|
307 | if ($libelle!=str_replace(' ', '_', $trad)) { |
---|
308 | $res .= "<input type='checkbox' name='champs[$k]' />$trad<br />"; |
---|
309 | } |
---|
310 | } |
---|
311 | } |
---|
312 | /* on ajoute aussi le mail */ |
---|
313 | $res .= '<input type="checkbox" name="champs[email]" />'._T('asso:email').'<br />'; |
---|
314 | /* si le plugin coordonnees est actif, on ajoute l'adresse et le telephone */ |
---|
315 | if (test_plugin_actif('COORDONNEES')) { |
---|
316 | $res .= '<input type="checkbox" name="champs[adresse]" />'._T('asso:adresse').'<br />'; |
---|
317 | $res .= '<input type="checkbox" name="champs[telephone]" />'._T('asso:telephone').'<br />'; |
---|
318 | } |
---|
319 | /* on fait suivre la liste des auteurs a afficher */ |
---|
320 | $res .= '<input type="hidden" name="liste_id_auteurs" value="'.serialize($liste_id_auteurs).'" />'; |
---|
321 | return generer_form_ecrire('pdf_adherents', $res, '', _T('asso:bouton_impression')); |
---|
322 | } |
---|
323 | |
---|
324 | ?> |
---|