1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * Associaspip, extension de SPIP pour gestion d'associations * |
---|
4 | * * |
---|
5 | * Copyright (c) 2007 Bernard Blazin & Francois 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('pdf/extends'); |
---|
15 | |
---|
16 | function exec_pdf_adherents() |
---|
17 | { |
---|
18 | if (!autoriser('associer', 'adherents')) { |
---|
19 | include_spip('inc/minipres'); |
---|
20 | echo minipres(); |
---|
21 | } else { |
---|
22 | |
---|
23 | $pdf=new PDF(); |
---|
24 | |
---|
25 | $pdf->titre = _T('asso:adherent_titre_liste_actifs'); |
---|
26 | $pdf->Open(); |
---|
27 | $pdf->AddPage(); |
---|
28 | |
---|
29 | //On définit les colonnes (champs,largeur,intitulé,alignement) |
---|
30 | $champs = $GLOBALS['association_tables_principales']['spip_asso_membres']['field']; |
---|
31 | $sent = _request('champs'); |
---|
32 | foreach ($champs as $k => $v) { |
---|
33 | if ($sent[$k]=='on') { |
---|
34 | $type = strpos($v, 'text'); |
---|
35 | $p = ($type===false) ? 'R' : (($type==0) ? 'L' : 'C'); |
---|
36 | $n = ($type===false) ? 20 : (($type==0) ? 45 : 25); |
---|
37 | $pdf->AddCol($k,$n,_T('asso:adherent_libelle_' . $k), $p); |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | // ainsi que les colonnes pour les champs hors table spip_asso_membres |
---|
42 | include_spip('inc/association_coordonnees'); |
---|
43 | $liste_id_auteurs = unserialize(_request('liste_id_auteurs')); |
---|
44 | if ($sent['email']=='on') { |
---|
45 | $pdf->AddCol('email',45 ,_T('asso:adherent_libelle_email'), 'C'); |
---|
46 | $emails = association_recuperer_emails($liste_id_auteurs); |
---|
47 | } |
---|
48 | |
---|
49 | if ($sent['adresse']=='on') { |
---|
50 | $pdf->AddCol('adresse',45 ,_T('asso:adherent_libelle_adresse'), 'L'); |
---|
51 | $adresses = association_recuperer_adresses($liste_id_auteurs,"\n"," "); |
---|
52 | } |
---|
53 | if ($sent['telephone']=='on') { |
---|
54 | $pdf->AddCol('telephone',30 ,_T('asso:adherent_libelle_telephone'), 'C'); |
---|
55 | $telephones = association_recuperer_telephones($liste_id_auteurs); |
---|
56 | } |
---|
57 | |
---|
58 | $prop=array( |
---|
59 | 'HeaderColor'=>array(255,150,100), |
---|
60 | 'color1'=>array(224,235,255), |
---|
61 | 'color2'=>array(255,255,255), |
---|
62 | 'padding'=>2 |
---|
63 | ); |
---|
64 | $order = 'id_auteur'; |
---|
65 | if ($sent['nom_famille']=='on') |
---|
66 | $order = 'nom_famille' . ",$order"; |
---|
67 | |
---|
68 | $adresses_tels = array(); |
---|
69 | foreach($liste_id_auteurs as $id_auteur) { |
---|
70 | $adresses_tels[$id_auteur] = array(); |
---|
71 | if ($sent['email']=='on') $adresses_tels[$id_auteur]['email'] = implode("\n", $emails[$id_auteur]); |
---|
72 | if ($sent['adresse']=='on') $adresses_tels[$id_auteur]['adresse'] = implode("\n\n", $adresses[$id_auteur]); |
---|
73 | if ($sent['telephone']=='on') { |
---|
74 | $first_tel = true; |
---|
75 | $telephones_string = ''; |
---|
76 | foreach ($telephones[$id_auteur] as $telephone) { |
---|
77 | if (!$first_tel) {$telephones_string .= "\n";} else $first_tel = false; |
---|
78 | $telephones_string .= print_tel($telephone," "); |
---|
79 | } |
---|
80 | $adresses_tels[$id_auteur]['telephone'] = $telephones_string; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | $pdf->Query_extended(sql_select('*','spip_asso_membres', sql_in('id_auteur', $liste_id_auteurs), '', $order), $prop, $adresses_tels, 'id_auteur'); |
---|
85 | $pdf->Output(); |
---|
86 | } |
---|
87 | } |
---|
88 | ?> |
---|