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('voir_membres', 'association', 0)) { /* on s'assure qu'il n'y ai pas d'id associe a la demande d'autorisation sur voir_membres car on les consulte tous */ |
---|
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('cotisations', $data['somme_recettes'], $data['somme_depenses']); |
---|
42 | // datation et raccourcis |
---|
43 | if (autoriser('voir_groupes', 'association', 100)) { // l'id groupe passe en parametre est a 100 car ce sont les groupes definis par l'utilisateur et non ceux des autorisation qu'on liste dans cette page. |
---|
44 | $res['gerer_les_groupes'] = array('annonce.gif', 'groupes'); |
---|
45 | } |
---|
46 | $res['menu2_titre_relances_cotisations'] = array('relance-24.png', 'edit_relances'); |
---|
47 | $res['synchronise_asso_membre_lien'] = array('reload-32.png', 'synchroniser_asso_membres'); |
---|
48 | icones_association(array(), $res); |
---|
49 | if ( test_plugin_actif('FPDF') && test_plugin_actif('COORDONNEES') ) { // etiquettes |
---|
50 | echo debut_cadre_enfonce('',true); |
---|
51 | echo recuperer_fond('prive/inc_cadre_etiquette'); |
---|
52 | echo fin_cadre_enfonce(true); |
---|
53 | } |
---|
54 | //Filtre ID et groupe : si le filtre id est actif, on ignore le filtre groupe |
---|
55 | $id = intval(_request('id')); |
---|
56 | if (!$id) { |
---|
57 | $id = _T('asso:adherent_libelle_id_auteur'); |
---|
58 | //Filtre groupe |
---|
59 | $id_groupe = intval(_request('id_groupe')); |
---|
60 | } else { |
---|
61 | $critere = "a.id_auteur=$id"; |
---|
62 | $id_groupe = 0; |
---|
63 | } |
---|
64 | if (test_plugin_actif('FPDF')) { |
---|
65 | echo debut_cadre_enfonce('',true); |
---|
66 | echo '<h3>'. _T('plugins_vue_liste') .'</h3>'; |
---|
67 | echo '<div class="formulaire_spip formulaire_asso_listemembres">'; |
---|
68 | $champs = description_table('spip_asso_membres'); |
---|
69 | $res = '<ul><li class="edit_champs">'; |
---|
70 | foreach ($champs['field'] as $k => $v) { |
---|
71 | if (!((!$GLOBALS['association_metas']['civilite'] && $k=='sexe') OR (!$GLOBALS['association_metas']['prenom'] && $k=='prenom') OR (!$GLOBALS['association_metas']['id_asso'] && $k=='id_asso'))) { |
---|
72 | $libelle = 'adherent_libelle_'.$k; |
---|
73 | $trad = _T('asso:'.$libelle); |
---|
74 | if ($libelle!=str_replace(' ', '_', $trad)) { |
---|
75 | $res .= "<div class='choix'><input type='checkbox' name='champs[$k]' id='listemembres_$k' /><label for='listemembres_$k'>$trad</label></div>"; |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | // on ajoute aussi le mail |
---|
80 | $res .= '<div class="choix"><input type="checkbox" name="champs[email]" id="listemembres_email" /><label for="listemembres_email">'._T('asso:adherent_libelle_email').'</label></div>'; |
---|
81 | if (test_plugin_actif('COORDONNEES')) { // si le plugin coordonnees est actif, on ajoute l'adresse et le telephone |
---|
82 | $res .= '<div class="choix"><input type="checkbox" name="champs[adresse]" id="listemembres_adresse" /><label for="listemembres_adresse">'._T('coordonnees:adresses').'</label></div>'; |
---|
83 | $res .= '<div class="choix"><input type="checkbox" name="champs[telephone]" id="listemembres_telephone" /><label for="listemembres_telephone"><label for="listemembres_telephone">'._T('coordonnees:numeros').'</label></div>'; |
---|
84 | } |
---|
85 | // on appelle ici la fonction qui calcule le code du formulaire/tableau de membres pour pouvoir recuperer la liste des membres affiches a transmettre pour la generation du pdf |
---|
86 | list($where_adherents, $jointure_adherents, $code_liste_membres) = adherents_liste(intval(_request('debut')), $lettre, $critere, $statut_interne, $id_groupe); |
---|
87 | /* on fait suivre la liste des auteurs a afficher */ |
---|
88 | $res .= '<input type="hidden" name="where_adherents" value="'.$where_adherents.'" />'; |
---|
89 | $res .= '<input type="hidden" name="jointure_adherents" value="'.$jointure_adherents.'" />'; |
---|
90 | $res .= '<input type="hidden" name="statut_interne" value="'.$statut_interne.'" />'; |
---|
91 | $res .= '</li></ul>'; |
---|
92 | $res .= '<p class="boutons"><input type="submit" value="'. _T('asso:bouton_imprimer') .'" /></p>'; |
---|
93 | echo generer_form_ecrire('pdf_adherents', $res, '', ''); |
---|
94 | echo '</div>'; |
---|
95 | echo fin_cadre_enfonce(true); |
---|
96 | } |
---|
97 | debut_cadre_association('annonce.gif', 'adherent_titre_liste_actifs'); |
---|
98 | // FILTRES |
---|
99 | echo "<table width='100%' class='asso_tablo_filtres'>\n<tr>"; |
---|
100 | // Pagination alphabetique |
---|
101 | echo '<td width="30%" class="pagination0">'; |
---|
102 | if (!$lettre) { |
---|
103 | $lettre = '%'; |
---|
104 | } |
---|
105 | $query = sql_select('UPPER( LEFT( nom_famille, 1 ) ) AS init', 'spip_asso_membres', '', 'init', 'nom_famille, id_auteur'); |
---|
106 | while ($data = sql_fetch($query)) { |
---|
107 | $i = $data['init']; |
---|
108 | if($i==$lettre) { |
---|
109 | echo ' <strong>'.$i.'</strong>'; |
---|
110 | } else { |
---|
111 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne&lettre=$i"); |
---|
112 | echo " <a href='$h'>$i</a>\n"; |
---|
113 | } |
---|
114 | } |
---|
115 | if ($lettre=='%') { |
---|
116 | echo ' <strong>'._T('asso:entete_tous').'</strong>'; |
---|
117 | } else { |
---|
118 | $h = generer_url_ecrire('adherents', "statut_interne=$statut_interne"); |
---|
119 | echo "<a href='$h'>"._T('asso:entete_tous').'</a>'; |
---|
120 | } |
---|
121 | # 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) |
---|
122 | echo '</td><td width="25%">'. association_selectionner_groupe($id_groupe, 'adherents') ; // filtre groupes |
---|
123 | # } |
---|
124 | //Filtre ID |
---|
125 | echo '</td><td width="16%" class="formulaire">'; |
---|
126 | echo '<form method="post" action="'.generer_url_ecrire('adherents').'"><div>'; |
---|
127 | echo association_selectionner_statut($id, ''); |
---|
128 | echo '<noscript><input type="submit" value="'._T('asso:bouton_lister').'" /></noscript></div></form>'; |
---|
129 | //Filtre statut |
---|
130 | echo '</td><td width="23%">'; |
---|
131 | echo '<form method="post" action="'.generer_url_ecrire('adherents').'"><div>'; |
---|
132 | echo '<input type="hidden" name="lettre" value="'.$lettre.'" />'; |
---|
133 | echo association_selectionner_statut($statut_interne, ''); |
---|
134 | echo '<noscript><input type="submit" value="'._T('asso:bouton_lister').'" /></noscript></div></form></td>'; |
---|
135 | echo '</tr></table>'; |
---|
136 | //Affichage de la liste |
---|
137 | echo $code_liste_membres; |
---|
138 | fin_page_association(); |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | /* adherent liste renvoie le code html et tout ce qu'il faut pour effectuer la requete avec les meme filtres (where et la possible jonction sur la table des groupes) */ |
---|
143 | function adherents_liste($debut, $lettre, $critere, $statut_interne, $id_groupe, $max_par_page=30) |
---|
144 | { |
---|
145 | if ($lettre) |
---|
146 | $critere .= " AND UPPER( SUBSTRING( nom_famille, 1, 1 ) ) LIKE '$lettre' "; |
---|
147 | $jointure_groupe = ''; |
---|
148 | if ($id_groupe) { |
---|
149 | $critere .= " AND c.id_groupe=$id_groupe "; |
---|
150 | $jointure_groupe = ' LEFT JOIN spip_asso_groupes_liaisons c ON a.id_auteur=c.id_auteur '; |
---|
151 | } |
---|
152 | $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
---|
153 | include_spip('inc/filtres_images_mini'); |
---|
154 | $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" ); |
---|
155 | $auteurs = ''; |
---|
156 | while ($data = sql_fetch($query)) { |
---|
157 | $id_auteur = $data['id_auteur']; |
---|
158 | $class = $GLOBALS['association_styles_des_statuts'][$data['statut_interne']]; |
---|
159 | $logo = $chercher_logo($id_auteur, 'id_auteur'); |
---|
160 | if ($logo) { |
---|
161 | $logo = image_reduire($logo[0], 60); |
---|
162 | }else{ |
---|
163 | $logo = '<img src="'._DIR_PLUGIN_ASSOCIATION_ICONES.'membre-60.gif" width="10"/>' ; |
---|
164 | } |
---|
165 | if (empty($data['email'])) { |
---|
166 | $mail = $data['nom_famille']; |
---|
167 | } else { |
---|
168 | $mail = '<a href="mailto:'.$data['email'].'">'.$data['nom_famille'].'</a>'; |
---|
169 | } |
---|
170 | $statut = $data['statut']; |
---|
171 | if (!$statut OR $statut=='nouveau') |
---|
172 | $statut = $data['bio']; |
---|
173 | switch($statut) { |
---|
174 | case '0minirezo': |
---|
175 | $icone = 'admin-12.gif'; |
---|
176 | break; |
---|
177 | case '1comite': |
---|
178 | $icone = 'redac-12.gif'; |
---|
179 | break; |
---|
180 | case '5poubelle': |
---|
181 | $icone = 'poubelle.gif'; |
---|
182 | break; |
---|
183 | case '6forum': |
---|
184 | default : |
---|
185 | $icone = 'visit-12.gif'; |
---|
186 | break; |
---|
187 | } |
---|
188 | $icone = !$icone ? strlen($statut) : http_img_pack($icone,'','', _T('asso:adherent_label_modifier_visiteur')); |
---|
189 | $auteurs .= "<tr class='$class'>\n"; |
---|
190 | if ($GLOBALS['association_metas']['aff_id_auteur']=='on') { |
---|
191 | $auteurs .= '<td class="integer">' |
---|
192 | . $id_auteur.'</td>'; |
---|
193 | } |
---|
194 | if ($GLOBALS['association_metas']['aff_photo']=='on') { |
---|
195 | $auteurs .= '<td class="logo centre">'.$logo.'</td>'; |
---|
196 | } |
---|
197 | if ($GLOBALS['association_metas']['aff_civilite']=='on' && $GLOBALS['association_metas']['civilite']=='on') |
---|
198 | $auteurs .= '<td class="honorific-prefix">'.$data['sexe'].'</td>'; |
---|
199 | $auteurs .= '<td class="family-name">' |
---|
200 | .$mail.'</td>'; |
---|
201 | if ($GLOBALS['association_metas']['aff_prenom']=='on' && $GLOBALS['association_metas']['prenom']=='on') $auteurs .= '<td class="given-name">'.$data['prenom'].'</td>'; |
---|
202 | if ($GLOBALS['association_metas']['aff_groupes']=='on') { |
---|
203 | $auteurs .= '<td class="organisation-unit">'; |
---|
204 | $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); |
---|
205 | if ($row_groupes = sql_fetch($query_groupes)) { |
---|
206 | $auteurs .= '<a href="'. generer_url_ecrire('voir_groupe', 'id='.$row_groupes['id_groupe']) .'">'.$row_groupes['nom_groupe'].'</a>'; |
---|
207 | while ($row_groupes = sql_fetch($query_groupes)) { |
---|
208 | $auteurs .= ', <a href="'.generer_url_ecrire('voir_groupe', 'id='.$row_groupes['id_groupe']).'">'.$row_groupes['nom_groupe'].'</a>'; |
---|
209 | } |
---|
210 | } |
---|
211 | $auteurs .= '</td>'; |
---|
212 | } |
---|
213 | if ($GLOBALS['association_metas']['aff_id_asso']=='on' && $GLOBALS['association_metas']['id_asso']=='on') { |
---|
214 | $auteurs .= '<td class="text">'.$data['id_asso'].'</td>'; |
---|
215 | } |
---|
216 | if ($GLOBALS['association_metas']['aff_categorie']=='on') { |
---|
217 | $auteurs .= '<td class="text">'. affiche_categorie($data['categorie']) .'</td>'; |
---|
218 | } |
---|
219 | if ($GLOBALS['association_metas']['aff_validite']=='on') { |
---|
220 | $auteurs .= '<td class="date">'; |
---|
221 | if ($data['validite']==''){ |
---|
222 | $auteurs .= ' '; |
---|
223 | } else { |
---|
224 | $auteurs .= '<abbr class="dtend" title="'.$data['validite'].'">'. association_datefr($data['validite']) .'</td>'; |
---|
225 | } |
---|
226 | $auteurs .= '</td>'; |
---|
227 | } |
---|
228 | $auteurs .= '<td class="action">' |
---|
229 | . '<a href="'. generer_url_ecrire('auteur_infos','id_auteur='.$id_auteur) .'">'.$icone.'</a></td>' |
---|
230 | . '<td class="action">'. association_bouton('adherent_label_ajouter_cotisation', 'cotis-12.gif', 'ajout_cotisation','id='.$id_auteur) .'</td>' |
---|
231 | . '<td class="action">'. association_bouton('adherent_label_modifier_membre', 'edit-12.gif', 'edit_adherent','id='.$id_auteur) .'</td>' |
---|
232 | . '<td class="action">'. association_bouton('adherent_label_voir_membre', 'voir-12.png', 'voir_adherent','id='.$id_auteur) .'</td>' |
---|
233 | . '<td class="action"><input name="id_auteurs[]" type="checkbox" value="'.$id_auteur.'" /></td>' |
---|
234 | . "</tr>\n"; |
---|
235 | } |
---|
236 | |
---|
237 | $res = "<table width='100%' class='asso_tablo' id='asso_tablo_adherents'>\n" |
---|
238 | . "<thead>\n<tr>"; |
---|
239 | if ($GLOBALS['association_metas']['aff_id_auteur']=='on') { |
---|
240 | $res .= '<th>'._T('asso:entete_id').'</th>'; |
---|
241 | } |
---|
242 | if ($GLOBALS['association_metas']['aff_photo']=='on') { |
---|
243 | $res .= '<th>'._T('asso:adherent_libelle_photo').'</th>'; |
---|
244 | } |
---|
245 | if ($GLOBALS['association_metas']['aff_civilite']=='on' && $GLOBALS['association_metas']['civilite']=='on') $res .= '<th>'._T('asso:adherent_libelle_sexe').'</th>'; |
---|
246 | $res .= '<th>'._T('asso:adherent_libelle_nom_famille').'</th>'; |
---|
247 | if ($GLOBALS['association_metas']['aff_prenom']=='on' && $GLOBALS['association_metas']['prenom']=='on') $res .= '<th>'._T('asso:adherent_libelle_prenom').'</th>'; |
---|
248 | if ($GLOBALS['association_metas']['aff_groupes']=='on') { |
---|
249 | $res .= '<th>'._T('asso:adherent_libelle_groupes').'</th>'; |
---|
250 | } |
---|
251 | if ($GLOBALS['association_metas']['aff_id_asso']=='on' && $GLOBALS['association_metas']['id_asso']=='on') { |
---|
252 | $res .= '<th>'._T('asso:adherent_libelle_id_asso').'</th>'; |
---|
253 | } |
---|
254 | if ($GLOBALS['association_metas']['aff_categorie']=='on') { |
---|
255 | $res .= '<th>'._T('asso:adherent_libelle_categorie').'</th>'; |
---|
256 | } |
---|
257 | if ($GLOBALS['association_metas']['aff_validite']=='on') { |
---|
258 | $res .= '<th>'._T('asso:adherent_libelle_validite').'</th>'; |
---|
259 | } |
---|
260 | $res .= '<th colspan="4" class="actions" width="30">'._T('asso:entete_actions').'</th>' |
---|
261 | . '<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>' |
---|
262 | . "</tr>\n</thead><tbody>" |
---|
263 | . $auteurs |
---|
264 | . "</tbody>\n</table>\n"; |
---|
265 | //SOUS-PAGINATION |
---|
266 | $res .= "<table class='asso_tablo_filtres'><tr>\n<td width='52%'><p class='pagination'>"; |
---|
267 | $nombre_selection = sql_countsel('spip_asso_membres', $critere); |
---|
268 | $pages = intval($nombre_selection/$max_par_page)+1; |
---|
269 | if ($pages!=1) { |
---|
270 | for ($i=0; $i<$pages; $i++) { |
---|
271 | $position = $i*$max_par_page; |
---|
272 | if ($position==$debut) { |
---|
273 | $res .= '<strong>'.$position.'</strong>'; |
---|
274 | } else { |
---|
275 | $h = generer_url_ecrire('adherents', 'lettre='.$lettre.'&debut='.$position.'&statut_interne='.$statut_interne); |
---|
276 | $res .= "<a href='$h'>$position</a>\n"; |
---|
277 | } |
---|
278 | } |
---|
279 | } |
---|
280 | if (autoriser('editer_membres', 'association', 100)) { |
---|
281 | $res .= "</p></td><td width='48%' class='formulaire'><form>\n"; |
---|
282 | if ($auteurs) { |
---|
283 | $res .= '<select name="action_adherents"><option value="" selected="">'._T('asso:choisir_action').'</option><option value="desactive">' |
---|
284 | .($statut_interne=='sorti' ? _T('asso:reactiver_adherent') : _T('asso:desactiver_adherent')) |
---|
285 | .'</option><option value="delete">'._T('asso:supprimer_adherent').'</option>'; |
---|
286 | if (autoriser('editer_groupes', 'association', 100)) { |
---|
287 | $res .=sql_countsel('spip_asso_groupes', '') ? '<option value="grouper">'._T('asso:rejoindre_groupe').'</option><option value="degrouper">'._T('asso:quitter_un_groupe').'</option>' : ''; |
---|
288 | } |
---|
289 | $res .='</select><input type="submit" value="'._T('asso:bouton_confirmer').'" />'; |
---|
290 | } |
---|
291 | $res .= '<input type="hidden" name="statut_courant" value="'.$statut_interne.'" />' |
---|
292 | . '</form></td>'; |
---|
293 | } |
---|
294 | $res .= '</tr></table>'; |
---|
295 | |
---|
296 | return array($critere, $jointure_groupe, generer_form_ecrire('action_adherents', $res)); |
---|
297 | } |
---|
298 | |
---|
299 | function affiche_categorie($c) |
---|
300 | { |
---|
301 | return is_numeric($c) |
---|
302 | ? sql_getfetsel('valeur', 'spip_asso_categories', "id_categorie=$c") |
---|
303 | : $c; |
---|
304 | } |
---|
305 | |
---|
306 | ?> |
---|