1 | <?php |
---|
2 | /** |
---|
3 | * Plugin Association |
---|
4 | * |
---|
5 | * Copyright (c) 2007 |
---|
6 | * Bernard Blazin & François de Montlivault |
---|
7 | * http://www.plugandspip.com |
---|
8 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. |
---|
9 | * Pour plus de details voir le fichier COPYING.txt. |
---|
10 | * |
---|
11 | **/ |
---|
12 | |
---|
13 | // Boucles SPIP-listes |
---|
14 | global $tables_principales; |
---|
15 | |
---|
16 | //Ensuite, donner le format des tables ajoutées. Par exemple : |
---|
17 | $tables_principales['spip_asso_adherents']= array( |
---|
18 | 'field' => array( |
---|
19 | "id_adherent" => "BIGINT(21) NOT NULL AUTO_INCREMENT", |
---|
20 | "nom" => "TEXT NOT NULL ", |
---|
21 | "prenom" => "TEXT NOT NULL ", |
---|
22 | "sexe" => "TINYTEXT NOT NULL", |
---|
23 | "fonction" => "TEXT", |
---|
24 | "email" => "TINYTEXT NOT NULL", |
---|
25 | "validite" => "DATE NOT NULL DEFAULT '0000-00-00' ", |
---|
26 | "numero" => "TEXT NOT NULL", |
---|
27 | "rue" => "TEXT NOT NULL ", |
---|
28 | "cp" => "TEXT NOT NULL ", |
---|
29 | "ville" => "TEXT NOT NULL ", |
---|
30 | "telephone" => "TINYTEXT", |
---|
31 | "portable" => "TINYTEXT", |
---|
32 | "montant" => "TEXT NOT NULL", |
---|
33 | "date" => "DATE NOT NULL DEFAULT '0000-00-00'", |
---|
34 | "divers" => "TEXT", |
---|
35 | "remarques" => "TEXT", |
---|
36 | "statut" => "TINYTEXT", |
---|
37 | "vignette" => "TINYTEXT", |
---|
38 | "relance" => "tinyint(4) NOT NULL default '0' ", |
---|
39 | "id_auteur" => "int(11) default NULL", |
---|
40 | "id_asso" => "text NOT NULL", |
---|
41 | "categorie" => "text NOT NULL", |
---|
42 | "naissance" => "date NOT NULL default '0000-00-00'", |
---|
43 | "profession" => "text NOT NULL", |
---|
44 | "societe" => "text NOT NULL", |
---|
45 | "identifiant" => "text NOT NULL", |
---|
46 | "passe" => "text NOT NULL", |
---|
47 | "creation" => "date NOT NULL default '0000-00-00'", |
---|
48 | "maj" => "timestamp(14) NOT NULL", |
---|
49 | "utilisateur1" => "text NOT NULL", |
---|
50 | "utilisateur2" => "text NOT NULL", |
---|
51 | "utilisateur3" => "text NOT NULL", |
---|
52 | "utilisateur4" => "text NOT NULL", |
---|
53 | "secteur" => "text NOT NULL", |
---|
54 | "publication" => "text NOT NULL", |
---|
55 | ), |
---|
56 | 'key' => array("PRIMARY KEY" => "id_adherent") |
---|
57 | ); |
---|
58 | |
---|
59 | $tables_principales['spip_asso_dons']= array( |
---|
60 | 'field' => array( |
---|
61 | "id_don" => "bigint(21) NOT NULL auto_increment", |
---|
62 | "date_don" => "date NOT NULL default '0000-00-00'", |
---|
63 | "bienfaiteur" => "text NOT NULL", |
---|
64 | "id_adherent" => "int(11) NOT NULL default '0'", |
---|
65 | "argent" => "tinytext", |
---|
66 | "colis" => "text", |
---|
67 | "valeur" => "text NOT NULL", |
---|
68 | "contrepartie" => "tinytext", |
---|
69 | "commentaire" => " text", |
---|
70 | "maj" => "timestamp(14) NOT NULL", |
---|
71 | ), |
---|
72 | 'key' => array("PRIMARY KEY" => "id_don") |
---|
73 | ); |
---|
74 | |
---|
75 | $tables_principales['spip_asso_ventes']= array( |
---|
76 | 'field' => array( |
---|
77 | "id_vente" => "BIGINT(21) AUTO_INCREMENT", |
---|
78 | "article" => "TINYTEXT NOT NULL", |
---|
79 | "code" => "TEXT NOT NULL", |
---|
80 | "acheteur" => "TINYTEXT NOT NULL", |
---|
81 | "quantite" => "TINYTEXT NOT NULL", |
---|
82 | "date_vente" => "DATE NOT NULL DEFAULT '0000-00-00'", |
---|
83 | "date_envoi" => "DATE DEFAULT '0000-00-00'", |
---|
84 | "don" => "TINYTEXT", |
---|
85 | "prix_vente" => "TINYTEXT", |
---|
86 | "frais_envoi" => "float NOT NULL default '0'", |
---|
87 | "commentaire" => "TEXT", |
---|
88 | "maj" => "timestamp(14) NOT NULL", |
---|
89 | ), |
---|
90 | |
---|
91 | 'key' => array("PRIMARY KEY" => "id_vente") |
---|
92 | ); |
---|
93 | |
---|
94 | $tables_principales['spip_asso_comptes']= array( |
---|
95 | 'field' => array( |
---|
96 | "id_compte" => "bigint(21) NOT NULL auto_increment", |
---|
97 | "date" => "date default NULL", |
---|
98 | "recette" => "float NOT NULL default '0'", |
---|
99 | "depense" => "float NOT NULL default '0'", |
---|
100 | "justification" => "text", |
---|
101 | "imputation" => "text", |
---|
102 | "journal" => "tinytext", |
---|
103 | "id_journal" => "int(11) NOT NULL default '0'", |
---|
104 | "valide" => "text NOT NULL", |
---|
105 | ), |
---|
106 | |
---|
107 | 'key' => array("PRIMARY KEY" => "id_compte") |
---|
108 | ); |
---|
109 | |
---|
110 | $tables_principales['spip_asso_categories']= array( |
---|
111 | 'field' => array( |
---|
112 | "id_categorie" => "int(10) unsigned NOT NULL auto_increment", |
---|
113 | "valeur" => "varchar(30) NOT NULL default", |
---|
114 | "libelle" => "text NOT NULL", |
---|
115 | "duree" => "text NOT NULL", |
---|
116 | "cotisation" => "float NOT NULL default '0'", |
---|
117 | "commentaires" => " text NOT NULL", |
---|
118 | ), |
---|
119 | |
---|
120 | 'key' => array("PRIMARY KEY" => "id_categorie") |
---|
121 | ); |
---|
122 | |
---|
123 | $tables_principales['spip_asso_banques']= array( |
---|
124 | 'field' => array( |
---|
125 | "id_banque" => "int(11) NOT NULL auto_increment", |
---|
126 | "valeur" => "text NOT NULL", |
---|
127 | "intitule" => "text NOT NULL", |
---|
128 | "reference" => "text NOT NULL", |
---|
129 | "solde" => "float NOT NULL default '0'", |
---|
130 | "date" => "date NOT NULL", |
---|
131 | "commentaire" => "text NOT NULL", |
---|
132 | ), |
---|
133 | |
---|
134 | 'key' => array("PRIMARY KEY" => "id_banque") |
---|
135 | ); |
---|
136 | |
---|
137 | $tables_principales['spip_asso_activites']= array( |
---|
138 | 'field' => array( |
---|
139 | "id_activite" => "bigint(20) NOT NULL auto_increment", |
---|
140 | "id_evenement" => "bigint(20) NOT NULL", |
---|
141 | "nom" => "text NOT NULL", |
---|
142 | "id_adherent" => "bigint(20) NOT NULL", |
---|
143 | "membres" => "text NOT NULL", |
---|
144 | "non_membres" => "text NOT NULL", |
---|
145 | "inscrits" => "int(11) NOT NULL default '0'", |
---|
146 | "date" => "date NOT NULL default '0000-00-00'", |
---|
147 | "telephone" => "text NOT NULL", |
---|
148 | "adresse" => "text NOT NULL", |
---|
149 | "email" => "text NOT NULL", |
---|
150 | "commentaire" => "text NOT NULL", |
---|
151 | "montant" => "float NOT NULL default '0'", |
---|
152 | "date_paiement" => "date NOT NULL default '0000-00-00'", |
---|
153 | "statut" => "text NOT NULL", |
---|
154 | ), |
---|
155 | |
---|
156 | 'key' => array("PRIMARY KEY" => "id_activite") |
---|
157 | ); |
---|
158 | |
---|
159 | // |
---|
160 | // <BOUCLE(ADHERENTS)> |
---|
161 | // |
---|
162 | function boucle_ASSO_ADHERENTS($id_boucle, &$boucles) { |
---|
163 | $boucle = &$boucles[$id_boucle]; |
---|
164 | $id_table = $boucle->id_table; |
---|
165 | $boucle->from[$id_table] = "spip_asso_adherents"; |
---|
166 | return calculer_boucle($id_boucle, $boucles); |
---|
167 | } |
---|
168 | // |
---|
169 | // <BOUCLE(BIENFAITEURS)> |
---|
170 | // |
---|
171 | function boucle_ASSO_DONS($id_boucle, &$boucles) { |
---|
172 | $boucle = &$boucles[$id_boucle]; |
---|
173 | $id_table = $boucle->id_table; |
---|
174 | $boucle->from[$id_table] = "spip_asso_dons"; |
---|
175 | return calculer_boucle($id_boucle, $boucles); |
---|
176 | } |
---|
177 | // |
---|
178 | // <BOUCLE(VENTES)> |
---|
179 | // |
---|
180 | function boucle_ASSO_VENTES($id_boucle, &$boucles) { |
---|
181 | $boucle = &$boucles[$id_boucle]; |
---|
182 | $id_table = $boucle->id_table; |
---|
183 | $boucle->from[$id_table] = "spip_asso_ventes"; |
---|
184 | return calculer_boucle($id_boucle, $boucles); |
---|
185 | } |
---|
186 | // |
---|
187 | // <BOUCLE(BANQUE)> |
---|
188 | // |
---|
189 | function boucle_ASSO_COMPTES($id_boucle, &$boucles) { |
---|
190 | $boucle = &$boucles[$id_boucle]; |
---|
191 | $id_table = $boucle->id_table; |
---|
192 | $boucle->from[$id_table] = "spip_asso_comptes"; |
---|
193 | return calculer_boucle($id_boucle, $boucles); |
---|
194 | } |
---|
195 | // |
---|
196 | // <BOUCLE(BANQUES)> |
---|
197 | // |
---|
198 | function boucle_ASSO_banqueS($id_boucle, &$boucles) { |
---|
199 | $boucle = &$boucles[$id_boucle]; |
---|
200 | $id_table = $boucle->id_table; |
---|
201 | $boucle->from[$id_table] = "spip_asso_banques"; |
---|
202 | return calculer_boucle($id_boucle, $boucles); |
---|
203 | } |
---|
204 | |
---|
205 | // |
---|
206 | // <BOUCLE(CATEGORIES)> |
---|
207 | // |
---|
208 | function boucle_ASSO_CATEGORIES($id_boucle, &$boucles) { |
---|
209 | $boucle = &$boucles[$id_boucle]; |
---|
210 | $id_table = $boucle->id_table; |
---|
211 | $boucle->from[$id_table] = "spip_asso_categories"; |
---|
212 | return calculer_boucle($id_boucle, $boucles); |
---|
213 | } |
---|
214 | |
---|
215 | // |
---|
216 | // <BOUCLE(ACTIVITES)> |
---|
217 | // |
---|
218 | function boucle_ASSO_ACTIVITES($id_boucle, &$boucles) { |
---|
219 | $boucle = &$boucles[$id_boucle]; |
---|
220 | $id_table = $boucle->id_table; |
---|
221 | $boucle->from[$id_table] = "spip_asso_activites"; |
---|
222 | return calculer_boucle($id_boucle, $boucles); |
---|
223 | } |
---|
224 | |
---|
225 | function association_auteur_infos($id='', $nom='') { |
---|
226 | if ($id) $query = "SELECT * FROM spip_asso_adherents WHERE id_auteur=$id"; |
---|
227 | if ($nom) $query = "SELECT * FROM spip_asso_adherents WHERE nom='$nom'"; |
---|
228 | $result = spip_query($query); |
---|
229 | |
---|
230 | if ($row = spip_fetch_array($result)) { |
---|
231 | $row=serialize($row); |
---|
232 | } |
---|
233 | return $row; |
---|
234 | } |
---|
235 | // Page blanche //include_spip('base/association'); |
---|
236 | //include_spip('inc/plugin'); |
---|
237 | function association_header_prive($flux){ |
---|
238 | $flux .= '<link rel="stylesheet" type="text/css" href="'.direction_css(find_in_path('association.css')).'" />'; |
---|
239 | return $flux; |
---|
240 | } |
---|
241 | function association_rediriger_javascript($url) { |
---|
242 | echo '<script language="javascript" type="text/javascript">window.location.replace("'.$url.'");</script>'; |
---|
243 | exit(); |
---|
244 | } |
---|
245 | |
---|
246 | //Conversion de date |
---|
247 | function association_datefr($date) { |
---|
248 | $split = explode('-',$date); |
---|
249 | $annee = $split[0]; |
---|
250 | $mois = $split[1]; |
---|
251 | $jour = $split[2]; |
---|
252 | return $jour.'/'.$mois.'/'.$annee; |
---|
253 | } |
---|
254 | |
---|
255 | //Affichage du message indiquant la date |
---|
256 | function association_date_du_jour($heure=false) { |
---|
257 | return '<p>'.($heure ? _T('asso:date_du_jour_heure') : _T('asso:date_du_jour')).'</p>'; |
---|
258 | } |
---|
259 | |
---|
260 | //Creation d'un login |
---|
261 | function association_cree_login($nom) { |
---|
262 | $login = strtolower($login); |
---|
263 | $login = ereg_replace("[^a-zA-Z0-9]", "", $login); |
---|
264 | |
---|
265 | for ($i = 0; ; $i++) { |
---|
266 | if ($i) $login = $login.$i; |
---|
267 | else $login = $login; |
---|
268 | $query = spip_query("SELECT id_auteur FROM spip_auteurs WHERE login='$login'"); |
---|
269 | if (!spip_num_rows($query)) break; |
---|
270 | } |
---|
271 | return $login; |
---|
272 | } |
---|
273 | ?> |
---|