Subversion Repositories Sites.tela-botanica.org

Rev

Rev 265 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 265 Rev 274
1
<?php
1
<?php
2
 
2
 
3
// +--------------------------------------------------------------------------------+
3
// +--------------------------------------------------------------------------------+
4
// | annuaire_moteur_fonction.php 		                      						|
4
// | annuaire_moteur_fonction.php 		                      						|
5
// +--------------------------------------------------------------------------------+
5
// +--------------------------------------------------------------------------------+
6
// | Copyright (c) 2000 - 2003 Tela Botanica 							        	|
6
// | Copyright (c) 2000 - 2003 Tela Botanica 							        	|
7
// +--------------------------------------------------------------------------------+
7
// +--------------------------------------------------------------------------------+
8
// | Les fonctions de annuaire_moteur.php                                           |
8
// | Les fonctions de annuaire_moteur.php                                           |
9
// +--------------------------------------------------------------------------------+
9
// +--------------------------------------------------------------------------------+
10
// | Auteur : Alexandre Granier <alexandre@tela-botanica.org> 		  		        |
10
// | Auteur : Alexandre Granier <alexandre@tela-botanica.org> 		  		        |
11
// +--------------------------------------------------------------------------------+
11
// +--------------------------------------------------------------------------------+
12
//
12
//
13
// $Id: annuaire_moteur_fonction.php,v 1.1 2005/03/24 08:47:31 alex Exp $
13
// $Id: annuaire_moteur_fonction.php,v 1.1 2005/03/24 08:47:31 alex Exp $
14
 
14
 
15
 
15
 
16
include_once 'api/pear/HTML/QuickForm/select.php';
16
include_once 'api/pear/HTML/QuickForm/select.php';
17
 
17
 
18
/** function mkengine ()
18
/** function mkengine ()
19
*
19
*
20
*
20
*
21
*
21
*
22
*	@return
22
*	@return
23
*/
23
*/
24
 
24
 
25
function mkengine()
25
function mkengine()
26
  {
26
  {
27
    global $label_bbota;
27
    global $label_bbota;
28
    global $nbr_total;
28
    global $nbr_total;
29
    global $bouton, $HTTP_POST_VARS ;
29
    global $bouton, $HTTP_POST_VARS ;
30
    
30
    
31
    
31
    
32
    $mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", "prenom", "cotisant", "pays", "sort", "T_REPONSE", "lettre","statut") ;
32
    $mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", "prenom", "cotisant", "pays", "sort", "T_REPONSE", "lettre","statut") ;
33
    
33
    
34
    // Deux cas , soit on a cliqué sur rechercher, soit on a cliqué sur un lien
34
    // Deux cas , soit on a cliqué sur rechercher, soit on a cliqué sur un lien
35
    foreach ($mes_vars as $key=>$value) {
35
    foreach ($mes_vars as $key=>$value) {
36
        if (!$bouton) {     // on a cliqué sur un lien
36
        if (!$bouton) {     // on a cliqué sur un lien
37
            if (empty($HTTP_POST_VARS[$value])) {
37
            if (empty($HTTP_POST_VARS[$value])) {
38
                
38
                
39
            }
39
            }
40
        } else {
40
        } else {
41
            // Si on clique sur le bouton rechercher
41
            // Si on clique sur le bouton rechercher
42
            if (empty ($HTTP_POST_VARS[$value])) {
42
            if (empty ($HTTP_POST_VARS[$value])) {
43
                $$value = "" ;
43
                $$value = "" ;
44
            } else {
44
            } else {
45
                $$value = $HTTP_POST_VARS[$value] ;
45
                $$value = $HTTP_POST_VARS[$value] ;
46
            }
46
            }
47
        }
47
        }
48
    }
48
    }
49
    
49
    
50
    // Comptage du nombre total de données dans la table (hors CACHER = 1)
50
    // Comptage du nombre total de données dans la table (hors CACHER = 1)
51
    $query = "select count(*) as CPT from ".ANN_ANNUAIRE;
51
    $query = "select count(*) as CPT from ".ANN_ANNUAIRE;
52
    $result = $GLOBALS['ann_db']->query($query) ;
52
    $result = $GLOBALS['ann_db']->query($query) ;
53
	if (DB::isError($result)) {
53
	if (DB::isError($result)) {
54
		return $result->getMessage().'<br />'.$result->getDebugInfo();
54
		return $result->getMessage().'<br />'.$result->getDebugInfo();
55
	}
55
	}
56
 
56
 
57
	if ($result->numRows() == 1) {
57
	if ($result->numRows() == 1) {
58
	    $tmp_nb = $result->fetchRow(DB_FETCHMODE_OBJECT);
58
	    $tmp_nb = $result->fetchRow(DB_FETCHMODE_OBJECT);
59
	    $nbr_total = $tmp_nb->CPT;
59
	    $nbr_total = $tmp_nb->CPT;
60
	    if ($nbr_total > 0) $chaine = "parmi $nbr_total données";
60
	    if ($nbr_total > 0) $chaine = "parmi $nbr_total données";
61
	    else die("<B>Erreur</B> lors du comptage des structures ($nbr_total trouvées) : $query");
61
	    else die("<B>Erreur</B> lors du comptage des structures ($nbr_total trouvées) : $query");
62
    } else die("<B>Erreur</B> lors du comptage des structures : $query");
62
    } else die("<B>Erreur</B> lors du comptage des structures : $query");
63
 
63
 
64
	$result->free();
64
	$result->free();
65
  // fin comptage
65
  // fin comptage
66
 
66
 
67
	$ret = '<h1>'.AM_L_TITRE.'</h1>'."\n";
67
	$ret = '<h1>'.AM_L_TITRE.'</h1>'."\n";
68
	$ret .= '<h2>'.AM_L_TITRE.' '.$chaine.'</h2>'."\n";
68
	$ret .= '<h2>'.AM_L_TITRE.' '.$chaine.'</h2>'."\n";
69
  // construction du moteur de str
69
  // construction du moteur de str
70
 	$formulaire = new HTML_QuickForm('formulaire_recherche', 'post', str_replace('&amp;', '&', $GLOBALS['ann_url']->getURL()));
70
 	$formulaire = new HTML_QuickForm('formulaire_recherche', 'post', str_replace('&amp;', '&', $GLOBALS['ann_url']->getURL()));
-
 
71
 	
-
 
72
 	$squelette =& $formulaire->defaultRenderer();
-
 
73
    $squelette->setFormTemplate("\n".'<div id="annuaire_zone_recherche"><table id="annuaire_recherche"><form{attributes}>'."\n".'{content}'."\n".'</form></table></div>'."\n");
-
 
74
    $squelette->setElementTemplate(  '<tr>'."\n".
-
 
75
                                    '<td class="champ">{label}</td>'."\n".
-
 
76
                                    '<td class="valeur">{element}'.
-
 
77
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">'.ADME_LG_FORM_SYMBOLE_CHP_OBLIGATOIRE.'</span><!-- END required -->'.
-
 
78
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'.
-
 
79
                                    '</td>'."\n".
-
 
80
                                    '</tr>'."\n");
71
 	
81
 	
72
 	$formulaire->addElement('text', 'recherche', AM_L_RECHERCHER);
82
 	$formulaire->addElement('text', 'recherche', AM_L_RECHERCHER);
73
 	
83
 	
74
 	$requete = 'select GC_ID, GC_NAME from gen_COUNTRY where GC_LOCALE="fr"';
84
 	$requete = 'select GC_ID, GC_NAME from gen_COUNTRY where GC_LOCALE="fr"';
75
    $pays = &$GLOBALS['ann_db']->getAssoc ($requete);
85
    $pays = &$GLOBALS['ann_db']->getAssoc ($requete);
76
    
86
    
77
    $pays = array_merge (array('tous' => 'Tous les pays'), $pays);
87
    $pays = array_merge (array('tous' => 'Tous les pays'), $pays);
78
    
88
    
79
    if (DB::isError($pays)) {
89
    if (DB::isError($pays)) {
80
		return $pays->getMessage().'<br />'.$pays->getDebugInfo();
90
		return $pays->getMessage().'<br />'.$pays->getDebugInfo();
81
	}
91
	}
82
 
92
 
83
	$select = new HTML_QuickForm_select ('pays', AM_L_PAYS, $pays, array ('class' => 'projet_asso')) ;
93
	$select = new HTML_QuickForm_select ('pays', AM_L_PAYS, $pays, array ('class' => 'projet_asso')) ;
84
	$formulaire->addElement($select) ;
94
	$formulaire->addElement($select) ;
85
	$formulaire->addElement('text', 'nom', AM_L_NOM);
95
	$formulaire->addElement('text', 'nom', AM_L_NOM);
86
	$formulaire->addElement('text', 'prenom', AM_L_PRENOM);
96
	$formulaire->addElement('text', 'prenom', AM_L_PRENOM);
87
	$formulaire->addElement('text', 'ville', AM_L_VILLE);
97
	$formulaire->addElement('text', 'ville', AM_L_VILLE);
88
	
98
	
89
	$departement = & $GLOBALS['ann_db']->getAssoc('select GFD_ID, CONCAT(GFD_ID,\' - \',GFD_NAME) as GFD_NAME from gen_FRENCH_DPT');
99
	$departement = & $GLOBALS['ann_db']->getAssoc('select GFD_ID, CONCAT(GFD_ID,\' - \',GFD_NAME) as GFD_NAME from gen_FRENCH_DPT');
90
	$departement = array_merge (array ('tous' => 'Tous'), $departement);
100
	$departement = array_merge (array ('tous' => 'Tous'), $departement);
91
	
101
	
92
	$select_dpt = new HTML_QuickForm_select ('departement', AM_L_DEPARTEMENT, $departement, array ('class' => 'projet_asso')) ;
102
	$select_dpt = new HTML_QuickForm_select ('departement', AM_L_DEPARTEMENT, $departement, array ('class' => 'projet_asso')) ;
93
	$formulaire->addElement($select_dpt);
103
	$formulaire->addElement($select_dpt);
94
	
104
	
95
	$formulaire->addElement('text', 'mail', AM_L_MAIL);
105
	$formulaire->addElement('text', 'mail', AM_L_MAIL);
96
	
106
	
97
	$cotisant = array (1 => 'Tous', 2 => 'Cotisants', 3 => 'Non cotisants');
107
	$cotisant = array (1 => 'Tous', 2 => 'Cotisants', 3 => 'Non cotisants');
98
	
108
	
99
	$select_cotisant = new HTML_QuickForm_select ('cotisant', AM_L_COTISANTS, $cotisant, array ('class' => 'projet_asso')) ;
109
	$select_cotisant = new HTML_QuickForm_select ('cotisant', AM_L_COTISANTS, $cotisant, array ('class' => 'projet_asso')) ;
100
	$formulaire->addElement($select_cotisant);
110
	$formulaire->addElement($select_cotisant);
101
	
111
	
102
	$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION';
112
	$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION';
103
    $resultat_annee_cotisation = &$GLOBALS['ann_db']->query ($requete);
113
    $resultat_annee_cotisation = &$GLOBALS['ann_db']->query ($requete);
104
    
114
    
105
    if (DB::isError($resultat_annee_cotisation)) {
115
    if (DB::isError($resultat_annee_cotisation)) {
106
		return $resultat_annee_cotisation->getMessage().'<br />'.$resultat_annee_cotisation->getDebugInfo();
116
		return $resultat_annee_cotisation->getMessage().'<br />'.$resultat_annee_cotisation->getDebugInfo();
107
	}
117
	}
108
	$tableau_annee_cotisation['Toutes'] = 'Toutes';
118
	$tableau_annee_cotisation['Toutes'] = 'Toutes';
109
	while ($ligne_annee_cotisation = $resultat_annee_cotisation->fetchRow(DB_FETCHMODE_OBJECT)) {
119
	while ($ligne_annee_cotisation = $resultat_annee_cotisation->fetchRow(DB_FETCHMODE_OBJECT)) {
110
    	$tableau_annee_cotisation[$ligne_annee_cotisation->annees] = $ligne_annee_cotisation->annees;	
120
    	$tableau_annee_cotisation[$ligne_annee_cotisation->annees] = $ligne_annee_cotisation->annees;	
111
    }
121
    }
112
	
122
	
113
	$select_annee = new HTML_QuickForm_select ('annee_cotisation', 'Année', $tableau_annee_cotisation, array ('class' => 'projet_asso')) ;
123
	$select_annee = new HTML_QuickForm_select ('annee_cotisation', 'Année', $tableau_annee_cotisation, array ('class' => 'projet_asso')) ;
114
	$formulaire->addElement($select_annee);
124
	$formulaire->addElement($select_annee);
115
	
125
	
116
	$grp = array(20 => 20, 50 => 50, 100 => 100) ;
126
	$grp = array(20 => 20, 50 => 50, 100 => 100) ;
117
	$select_grp = new HTML_QuickForm_select ('T_REPONSE', '', $grp, array ('class' => 'projet_asso')) ;
127
	$select_grp = new HTML_QuickForm_select ('T_REPONSE', 'Résultat par', $grp, array ('class' => 'projet_asso')) ;
118
	$formulaire->addElement($select_grp);
128
	$formulaire->addElement($select_grp);
119
	$formulaire->addElement('submit', 'bouton', AM_L_RECHERCHER);
129
	$formulaire->addElement('submit', 'bouton', AM_L_RECHERCHER);
120
	foreach ($mes_vars as $key=>$value) {
130
	foreach ($mes_vars as $key=>$value) {
121
		if (isset($_POST[$value])) {
131
		if (isset($_POST[$value])) {
122
			$default[$value] = $_POST[$value] ;
132
			$default[$value] = $_POST[$value] ;
123
		}
133
		}
124
	}
134
	}
125
	$formulaire->setDefaults($_POST);
135
	$formulaire->setDefaults($_POST);
126
 
136
 
127
    $ret .= '<br />'.$formulaire->toHTML();
137
    $ret .= '<br />'.$formulaire->toHTML();
128
    return $ret;
138
    return $ret;
129
}
139
}
130
 
140
 
131
function mkquery()
141
function mkquery()
132
{
142
{
133
    // définition des variables globales
143
    // définition des variables globales
134
	global $lettre ;
144
	global $lettre ;
135
	global $bouton ;
145
	global $bouton ;
136
    
146
    
137
	// Requete sur l'annuaire pour extraire le nom, prénom, ville, nom du département (jointure),
147
	// Requete sur l'annuaire pour extraire le nom, prénom, ville, nom du département (jointure),
138
	// l'état de la cotisation (jointure) 
148
	// l'état de la cotisation (jointure) 
139
	
149
	
140
	// le tableau suivant contient tous les champs de la table annuaire_tela sur lesquels on peut effectuer une recherche
150
	// le tableau suivant contient tous les champs de la table annuaire_tela sur lesquels on peut effectuer une recherche
141
	$fields_annu = array("nom" => ANN_CHAMPS_NOM, "prenom" => ANN_CHAMPS_PRENOM , "mail" => ANN_CHAMPS_MAIL , "ville" => ANN_CHAMPS_VILLE,
151
	$fields_annu = array("nom" => ANN_CHAMPS_NOM, "prenom" => ANN_CHAMPS_PRENOM , "mail" => ANN_CHAMPS_MAIL , "ville" => ANN_CHAMPS_VILLE,
142
			"dept" => "U_FRENCH_DPT", "pays" => ANN_CHAMPS_PAYS  ) ;
152
			"dept" => "U_FRENCH_DPT", "pays" => ANN_CHAMPS_PAYS  ) ;
143
 
153
 
144
    $mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", 
154
    $mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", 
145
						"prenom", "cotisant", "pays", "sort", "T_REPONSE", 
155
						"prenom", "cotisant", "pays", "sort", "T_REPONSE", 
146
						"lettre","statut", "annee_cotisation") ;
156
						"lettre","statut", "annee_cotisation") ;
147
 
157
 
148
    foreach ($mes_vars as $key=>$value) {
158
    foreach ($mes_vars as $key=>$value) {
149
        if (!$bouton) {
159
        if (!$bouton) {
150
            
160
            
151
        } else {
161
        } else {
152
            $lettre = "" ;
162
            $lettre = "" ;
153
            if (empty ($_REQUEST[$value])) {
163
            if (empty ($_REQUEST[$value])) {
154
                $$value = "" ;
164
                $$value = "" ;
155
            } else {
165
            } else {
156
                $$value = $_REQUEST[$value] ;
166
                $$value = $_REQUEST[$value] ;
157
            }
167
            }
158
        }
168
        }
159
    }
169
    }
160
    $queries = 'select '.ANN_CHAMPS_ID.','.ANN_CHAMPS_NOM.', '.ANN_CHAMPS_PRENOM.', '.
170
    $queries = 'select '.ANN_CHAMPS_ID.','.ANN_CHAMPS_NOM.', '.ANN_CHAMPS_PRENOM.', '.
161
    				ANN_CHAMPS_PAYS.','.ANN_CHAMPS_MAIL.', '.ANN_CHAMPS_VILLE ;
171
    				ANN_CHAMPS_PAYS.','.ANN_CHAMPS_MAIL.', '.ANN_CHAMPS_VILLE ;
162
    $queries .= ", ".ANN_TABLE_PAYS.".GC_NAME ";
172
    $queries .= ", ".ANN_TABLE_PAYS.".GC_NAME ";
163
	$queries .= "from ";
173
	$queries .= "from ";
164
	$queries .= ANN_TABLE_PAYS.','.ANN_ANNUAIRE ;
174
	$queries .= ANN_TABLE_PAYS.','.ANN_ANNUAIRE ;
165
	// On effectue une jointure gauche si l on veut tous les inscrits
175
	// On effectue une jointure gauche si l on veut tous les inscrits
166
	// y compris ce qui ne cotisent pas sinon pas de jointure gauche
176
	// y compris ce qui ne cotisent pas sinon pas de jointure gauche
167
	/*
177
	/*
168
	if (isset($cotisant) && $cotisant != 1) {
178
	if (isset($cotisant) && $cotisant != 1) {
169
		
179
		
170
	} else {
180
	} else {
171
		$queries .= ' left ' ;
181
		$queries .= ' left ' ;
172
	}
182
	}
173
	$queries .= ' join annuaire_COTISATION on '.
183
	$queries .= ' join annuaire_COTISATION on '.
174
    				ANN_ANNUAIRE.'.U_ID=annuaire_COTISATION.IC_ANNU_ID ';
184
    				ANN_ANNUAIRE.'.U_ID=annuaire_COTISATION.IC_ANNU_ID ';
175
    				
185
    				
176
    if (isset($annee_cotisation) && $annee_cotisation != 0) {
186
    if (isset($annee_cotisation) && $annee_cotisation != 0) {
177
        	$queries .= ' and year(IC_DATE)='.$annee_cotisation ; 
187
        	$queries .= ' and year(IC_DATE)='.$annee_cotisation ; 
178
    } else {
188
    } else {
179
    		$queries .= 'and year(IC_DATE)='.date('Y') ;
189
    		$queries .= 'and year(IC_DATE)='.date('Y') ;
180
    }
190
    }
181
 */
191
 */
182
	// Construction en fonction des champs saisies
192
	// Construction en fonction des champs saisies
183
 
193
 
184
	// juste le champs "rechercher", on regarde partout
194
	// juste le champs "rechercher", on regarde partout
185
	$queries .= " where " ;
195
	$queries .= " where " ;
186
 
196
 
187
	if ($lettre == "") {
197
	if ($lettre == "") {
188
        if ($_REQUEST['recherche'] != '') {
198
        if ($_REQUEST['recherche'] != '') {
189
            $queries .= '('.ANN_CHAMPS_NOM.' like "%'.$_REQUEST['recherche'].'%"' ; // le premier
199
            $queries .= '('.ANN_CHAMPS_NOM.' like "%'.$_REQUEST['recherche'].'%"' ; // le premier
190
                foreach($fields_annu as $key=>$value) {
200
                foreach($fields_annu as $key=>$value) {
191
					if ($key == "nom") continue ;
201
					if ($key == "nom") continue ;
192
							$queries .= ($key == "pays" ? 
202
							$queries .= ($key == "pays" ? 
193
                                    $pays == "tous" ? ")" :
203
                                    $pays == "tous" ? ")" :
194
                                    ") and $value = '$pays'" : " or $value like '%$recherche%'") ;	// les autres
204
                                    ") and $value = '$pays'" : " or $value like '%$recherche%'") ;	// les autres
195
                }
205
                }
196
				$queries .= ' and ' ;	
206
				$queries .= ' and ' ;	
197
			} else {
207
			} else {
198
 
208
 
199
			// si un ou plusieurs autres champs ont été indiqué, on les rajoute ici
209
			// si un ou plusieurs autres champs ont été indiqué, on les rajoute ici
200
 
210
 
201
			$or_flag = false ;
211
			$or_flag = false ;
202
			foreach($fields_annu as $key=>$valeur) {
212
			foreach($fields_annu as $key=>$valeur) {
203
                if ($key != "") {
213
                if ($key != "") {
204
                    if ($key == "pays" && ($$key != 'tous' && $$key != '')) {
214
                    if ($key == "pays" && ($$key != 'tous' && $$key != '')) {
205
                        if ($$key != "tous") $queries .= ") and $valeur like \"%".$$key."%\"" ;
215
                        if ($$key != "tous") $queries .= ") and $valeur like \"%".$$key."%\"" ;
206
                    } else {
216
                    } else {
207
                        if ($key == "dept") {
217
                        if ($key == "dept") {
208
                            if ($$key != "tous" && isset($HTTP_POST_VARS[$key])) {  
218
                            if ($$key != "tous" && isset($HTTP_POST_VARS[$key])) {  
209
                                $queries .= " and U_FRENCH_DPT=".$$key ;
219
                                $queries .= " and U_FRENCH_DPT=".$$key ;
210
                                if ($fields_annu["pays"] != "fr") $queries .= ' and '.ANN_CHAMPS_PAYS.'="fr"' ;
220
                                if ($fields_annu["pays"] != "fr") $queries .= ' and '.ANN_CHAMPS_PAYS.'="fr"' ;
211
                            }
221
                            }
212
                            
222
                            
213
                        } else {
223
                        } else {
214
                            if ($$key != '' && $key != 'pays') {
224
                            if ($$key != '' && $key != 'pays') {
215
                            	if (!$or_flag) $queries .= '(' ;
225
                            	if (!$or_flag) $queries .= '(' ;
216
                            	$queries .= $valeur.' like "%'.$$key.'%"' ;	
226
                            	$queries .= $valeur.' like "%'.$$key.'%"' ;	
217
                            	if ($key != "ville") $queries .= " and " ;
227
                            	if ($key != "ville") $queries .= " and " ;
218
                            }
228
                            }
219
                            
229
                            
220
                        }
230
                        }
221
                    }
231
                    }
222
                    $or_flag = true ;
232
                    $or_flag = true ;
223
                }
233
                }
224
			}
234
			}
225
			// ici le cas ou rien n'a été saisie du tout, on affiche tout
235
			// ici le cas ou rien n'a été saisie du tout, on affiche tout
226
			if (!$or_flag) {
236
			if (!$or_flag) {
227
					$queries .= ANN_CHAMPS_NOM.' like "%")' ;
237
					$queries .= ANN_CHAMPS_NOM.' like "%")' ;
228
			}
238
			}
229
	}
239
	}
230
} else {
240
} else {
231
	if ($lettre == "tous") $lettre = "" ;
241
	if ($lettre == "tous") $lettre = "" ;
232
	$queries .= ANN_CHAMPS_NOM.' like "'.$lettre.'%"' ;
242
	$queries .= ANN_CHAMPS_NOM.' like "'.$lettre.'%"' ;
233
}
243
}
234
    $queries .= "" ;
244
    $queries .= "" ;
235
    // jointure entre annuaire et table des pays annuaire_tela et gen_COUNTRY
245
    // jointure entre annuaire et table des pays annuaire_tela et gen_COUNTRY
236
	$queries .= "  ".ANN_ANNUAIRE.".".ANN_CHAMPS_PAYS."=".ANN_TABLE_PAYS.".GC_ID" ;
246
	$queries .= "  ".ANN_ANNUAIRE.".".ANN_CHAMPS_PAYS."=".ANN_TABLE_PAYS.".GC_ID" ;
237
	
247
	
238
    if (isset($nom) && $nom != "") $queries .= " and ".ANN_CHAMPS_NOM." like \"%$nom%\"" ;
248
    if (isset($nom) && $nom != "") $queries .= " and ".ANN_CHAMPS_NOM." like \"%$nom%\"" ;
239
    if (isset($prenom) && $prenom != "") $queries .= " and ".ANN_CHAMPS_PRENOM." like \"%$prenom%\"" ;
249
    if (isset($prenom) && $prenom != "") $queries .= " and ".ANN_CHAMPS_PRENOM." like \"%$prenom%\"" ;
240
    if (isset($ville) && $ville != "") $queries .= " and ".ANN_CHAMPS_VILLE." like \"%$ville%\"" ;
250
    if (isset($ville) && $ville != "") $queries .= " and ".ANN_CHAMPS_VILLE." like \"%$ville%\"" ;
241
    if (isset($mail) && $mail != "") $queries .= " and ".ANN_CHAMPS_MAIL." like \"%$mail%\"" ;
251
    if (isset($mail) && $mail != "") $queries .= " and ".ANN_CHAMPS_MAIL." like \"%$mail%\"" ;
242
  if (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '') $queries .= ' order by '.$_REQUEST['sort'] ;
252
  if (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '') $queries .= ' order by '.$_REQUEST['sort'] ;
243
  return $queries;
253
  return $queries;
244
}
254
}
245
  
255
  
246
function mkresu() {
256
function mkresu() {
247
   
257
   
248
    $requete = mkquery() ;
258
    $requete = mkquery() ;
249
	
259
	
250
	// Requete sans le limit pour le nombre de resultat
260
	// Requete sans le limit pour le nombre de resultat
251
	$resultat_nbr = $GLOBALS['ann_db']->query($requete) ;
261
	$resultat_nbr = $GLOBALS['ann_db']->query($requete) ;
252
    if (DB::isError($resultat_nbr)) {
262
    if (DB::isError($resultat_nbr)) {
253
		return $resultat_nbr->getMessage().'<br />'.$resultat_nbr->getDebugInfo().'<br />'.$requete ;
263
		return $resultat_nbr->getMessage().'<br />'.$resultat_nbr->getDebugInfo().'<br />'.$requete ;
254
	}  
264
	}  
255
	$nbr_final = $resultat_nbr->numRows() ;
265
	$nbr_final = $resultat_nbr->numRows() ;
256
	$resultat_nbr->free();
266
	$resultat_nbr->free();
257
	$_SESSION['requete_mail_tous'] = $requete ;
267
	$_SESSION['requete_mail_tous'] = $requete ;
258
	
268
	
259
	if (!isset($_REQUEST['T_REPONSE'])) $_REQUEST['T_REPONSE'] = 20 ;
269
	if (!isset($_REQUEST['T_REPONSE'])) $_REQUEST['T_REPONSE'] = 20 ;
260
	$debut = $_REQUEST['pageID'] * $_REQUEST['T_REPONSE'];
270
	$debut = $_REQUEST['pageID'] * $_REQUEST['T_REPONSE'];
261
	$requete .= ' limit '.$debut.','.$_REQUEST['T_REPONSE'];
271
	$requete .= ' limit '.$debut.','.$_REQUEST['T_REPONSE'];
262
    // Requetes avec les résultats affichés
272
    // Requetes avec les résultats affichés
263
 
273
 
264
    $resultat = $GLOBALS['ann_db']->query($requete) ;
274
    $resultat = $GLOBALS['ann_db']->query($requete) ;
265
    if (DB::isError($resultat)) {
275
    if (DB::isError($resultat)) {
266
		return $resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'.$requete ;
276
		return $resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'.$requete ;
267
	}   
277
	}   
268
    
278
    
269
    
279
    
270
    $variables_a_supprimer = array ('username', 'password', 'connexion');
280
    $variables_a_supprimer = array ('username', 'password', 'connexion');
271
	foreach ($variables_a_supprimer as $var) if (isset($_POST[$var])) unset ($_POST[$var]) ;
281
	foreach ($variables_a_supprimer as $var) if (isset($_POST[$var])) unset ($_POST[$var]) ;
272
	
282
	
273
	
283
	
274
	$variables = array_merge ($_POST, $_GET);
284
	$variables = array_merge ($_POST, $_GET);
275
	
285
	
276
	foreach ($variables as $key => $var) if ($variables[$key] != '') $GLOBALS['ann_url']->addQueryString($key, $variables[$key]);
286
	foreach ($variables as $key => $var) if ($variables[$key] != '') $GLOBALS['ann_url']->addQueryString($key, $variables[$key]);
277
    
287
    
278
    $ret = "<div><table><tr>" ;
288
    $ret = "<table id=\"recherche_alphabetique\"><tr>" ;
279
    
289
    
280
    for ($i = 65 ; $i <91 ; $i++) {
290
    for ($i = 65 ; $i <91 ; $i++) {
281
        $ret .= "\t<td><a href=\"".$GLOBALS['ann_url']->getURL()."&lettre=";	
291
        $ret .= "\t<td><a href=\"".$GLOBALS['ann_url']->getURL()."&lettre=";	
282
        $ret .= chr($i)."\">";
292
        $ret .= chr($i)."\">";
283
        $ret .= chr($i) ;
293
        $ret .= chr($i) ;
284
        $ret .= "</a></td>\n";
294
        $ret .= "</a></td>\n";
285
	}
295
	}
286
	$GLOBALS['ann_url']->addQueryString('lettre', 'tous');
296
	$GLOBALS['ann_url']->addQueryString('lettre', 'tous');
287
    $ret .= '<td>&nbsp;&nbsp;<a href="'.$GLOBALS['ann_url']->getURL().'">'.AM_L_TOUS."</a></td>\n" ;
297
    $ret .= '<td>&nbsp;&nbsp;<a href="'.$GLOBALS['ann_url']->getURL().'">'.AM_L_TOUS."</a></td>\n" ;
288
    $ret .= "<tr></table></div>\n" ;
298
    $ret .= "<tr></table>\n" ;
289
	
-
 
290
 
-
 
291
    
299
   
292
    include_once 'api/pear/Pager/Pager.php';
300
    include_once 'api/pear/Pager/Pager.php';
293
    
301
    
294
	$params = array(
302
	$params = array(
295
	    'mode'       => 'Jumping',
303
	    'mode'       => 'Jumping',
296
	    'perPage'    => $_REQUEST['T_REPONSE'],
304
	    'perPage'    => $_REQUEST['T_REPONSE'],
297
	    'delta'      => 12,
305
	    'delta'      => 12,
298
	    'httpMethod' => 'GET',
306
	    'httpMethod' => 'GET',
299
	    'extraVars' => array_merge($_POST, $_GET),
307
	    'extraVars' => array_merge($_POST, $_GET),
300
	    'altNext' => 'Suivant',
308
	    'altNext' => 'Suivant',
301
	    'altPrev' => 'Précédent',
309
	    'altPrev' => 'Précédent',
302
	    'nextImg' => 'Suivant',
310
	    'nextImg' => 'Suivant',
303
	    'prevImg' => 'Précedent',
311
	    'prevImg' => 'Précedent',
304
	    'totalItems'   => $nbr_final
312
	    'totalItems'   => $nbr_final
305
		);
313
		);
306
	$pager = & Pager::factory($params);
314
	$pager = & Pager::factory($params);
307
	$data  = $pager->getPageData();
315
	$data  = $pager->getPageData();
308
	$links = $pager->getLinks();
316
	$links = $pager->getLinks();
309
	$range = $pager->getOffsetByPageId();
317
	$range = $pager->getOffsetByPageId();
310
	$ret .= '<h2>'.$range[0].' - '.$range[1].' parmi '.$nbr_final.'</h2>';
318
	$ret .= '<h2>'.$range[0].' - '.$range[1].' parmi '.$nbr_final.'</h2>';
311
	$ret .= '<br /><br />';
-
 
312
	$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
319
	$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
313
	include_once 'api/pear/HTML/Table.php';
320
	include_once 'api/pear/HTML/Table.php';
314
	$table = new HTML_Table(array("class" => "table_cadre"));
321
	$table = new HTML_Table(array("class" => "table_cadre"));
315
	$table->addRow(array("<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_NOM."\">Identit&eacute;</a>", 
322
	$table->addRow(array("<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_NOM."\">Identit&eacute;</a>", 
316
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_MAIL."\">Adresse mail</a>", 
323
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_MAIL."\">Adresse mail</a>", 
317
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_VILLE."\">".AM_L_VILLE, "Pays ou Dpt (fr)", 
324
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=".ANN_CHAMPS_VILLE."\">".AM_L_VILLE, "Pays ou Dpt (fr)", 
318
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=U_COT\">Cotisant en ".date(Y)),'', 'TH') ;
325
					"<a href=\"".$GLOBALS['ann_url']->getURL()."&amp;sort=U_COT\">Cotisant en ".date(Y)),'', 'TH') ;
319
	while ($valeur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
326
	while ($valeur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
320
		$ligne_tableau = array();
327
		$ligne_tableau = array();
321
		$montant = 0;
328
		$montant = 0;
322
		// Le nom de l inscrit avec un lien dessus pour voir les details
329
		// Le nom de l inscrit avec un lien dessus pour voir les details
323
		$GLOBALS['ann_url']->addQueryString('u_id', $valeur[ANN_CHAMPS_ID]);
330
		$GLOBALS['ann_url']->addQueryString('u_id', $valeur[ANN_CHAMPS_ID]);
324
		array_push ($ligne_tableau, '<a href="'.$GLOBALS['ann_url']->getURL().'">'.$valeur[ANN_CHAMPS_NOM].' '.$valeur[ANN_CHAMPS_PRENOM].'</a>');
331
		array_push ($ligne_tableau, '<a href="'.$GLOBALS['ann_url']->getURL().'">'.$valeur[ANN_CHAMPS_NOM].' '.$valeur[ANN_CHAMPS_PRENOM].'</a>');
325
		
332
		
326
		// l email
333
		// l email
327
		array_push ($ligne_tableau, '<a href="mailto:'.$valeur[ANN_CHAMPS_MAIL].'">'.$valeur[ANN_CHAMPS_MAIL].'</a>');
334
		array_push ($ligne_tableau, '<a href="mailto:'.$valeur[ANN_CHAMPS_MAIL].'">'.$valeur[ANN_CHAMPS_MAIL].'</a>');
328
		// La ville
335
		// La ville
329
		array_push ($ligne_tableau, $valeur[ANN_CHAMPS_VILLE]);
336
		array_push ($ligne_tableau, $valeur[ANN_CHAMPS_VILLE]);
330
		
337
		
331
		// Le pays ou le departement si francais
338
		// Le pays ou le departement si francais
332
		if ($valeur['U_COUNTRY'] != 'fr') {
339
		if ($valeur['U_COUNTRY'] != 'fr') {
333
			array_push ($ligne_tableau,  $valeur['GC_NAME']) ;
340
			array_push ($ligne_tableau,  $valeur['GC_NAME']) ;
334
		} else {
341
		} else {
335
	        $req_dpt = 'select GFD_NAME from '.ANN_TABLE_DEPARTEMENT.','.ANN_ANNUAIRE.
342
	        $req_dpt = 'select GFD_NAME from '.ANN_TABLE_DEPARTEMENT.','.ANN_ANNUAIRE.
336
						' where '.ANN_ANNUAIRE.'.'.ANN_CHAMPS_ID.'='.$valeur[ANN_CHAMPS_ID] ;
343
						' where '.ANN_ANNUAIRE.'.'.ANN_CHAMPS_ID.'='.$valeur[ANN_CHAMPS_ID] ;
337
	        $req_dpt .= " and ".ANN_ANNUAIRE.".U_FRENCH_DPT=".ANN_TABLE_DEPARTEMENT.".GFD_ID" ;
344
	        $req_dpt .= " and ".ANN_ANNUAIRE.".U_FRENCH_DPT=".ANN_TABLE_DEPARTEMENT.".GFD_ID" ;
338
	        $resultat_dpt = $GLOBALS['ann_db']->query($req_dpt) ;
345
	        $resultat_dpt = $GLOBALS['ann_db']->query($req_dpt) ;
339
	        if (DB::isError($resultat_dpt)) {
346
	        if (DB::isError($resultat_dpt)) {
340
	        	return $resultat_dpt->getMessage().'<br />'.$resultat_dpt->getDebugInfo().'<br />'.$req_dpt ;
347
	        	return $resultat_dpt->getMessage().'<br />'.$resultat_dpt->getDebugInfo().'<br />'.$req_dpt ;
341
	        }
348
	        }
342
	        $ligne_dpt = $resultat_dpt->fetchRow(DB_FETCHMODE_OBJECT) ;
349
	        $ligne_dpt = $resultat_dpt->fetchRow(DB_FETCHMODE_OBJECT) ;
343
			array_push ($ligne_tableau, $ligne_dpt->GFD_NAME) ;
350
			array_push ($ligne_tableau, $ligne_dpt->GFD_NAME) ;
344
		}
351
		}
345
		// Si cotisant
352
		// Si cotisant
346
		if ($valeur->IC_MONTANT != NULL) $montant = $valeur->IC_MONTANT.' &euro;';
353
		if ($valeur->IC_MONTANT != NULL) $montant = $valeur->IC_MONTANT.' &euro;';
347
		array_push ($ligne_tableau, $montant);
354
		array_push ($ligne_tableau, $montant);
348
		$table->addRow($ligne_tableau);
355
		$table->addRow($ligne_tableau);
349
	}
356
	}
350
	$table->altRowAttributes(1, array("class" => "ligne_paire"), array("class" => "ligne_impaire")) ;
357
	$table->altRowAttributes(1, array("class" => "ligne_paire"), array("class" => "ligne_impaire"), true);
351
	$ret .= $table->toHTML();
358
	$ret .= $table->toHTML();
352
	$GLOBALS['ann_url']->removeQueryString('u_id');
359
	$GLOBALS['ann_url']->removeQueryString('u_id');
353
	
360
	
354
	$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
361
	$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
355
	$GLOBALS['ann_url']->addQueryString(ANN_VARIABLE_ACTION, ANN_ACTION_MAIL_TOUS);
362
	$GLOBALS['ann_url']->addQueryString(ANN_VARIABLE_ACTION, ANN_ACTION_MAIL_TOUS);
356
	$ret .= "<div><a href=\"".$GLOBALS['ann_url']->getURL()."\">".AM_L_MAIL_SELECTION."</a></div>\n" ;
363
	$ret .= "<div id=\"envoyer_selection\"><a href=\"".$GLOBALS['ann_url']->getURL()."\">".AM_L_MAIL_SELECTION."</a></div>\n" ;
357
	$ret .= $requete;
364
	$ret .= '<pre id="debogage">'.$requete.'</pre>';
358
  return $ret;
365
  return $ret;
359
}
366
}
360
 
367
 
361
function resume_cotisation() {
368
function resume_cotisation() {
362
	
369
	
363
	$res = '<h1>Etat des cotisations</h1>'."\n";
370
	$res = '<h1>Etat des cotisations</h1>'."\n";
364
	
371
	
365
	$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION';
372
	$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION';
366
    $tableau_annee_cotisation = &$GLOBALS['ann_db']->getCol ($requete);
373
    $tableau_annee_cotisation = &$GLOBALS['ann_db']->getCol ($requete);
367
    if (DB::isError($tableau_annee_cotisation)) {
374
    if (DB::isError($tableau_annee_cotisation)) {
368
		return $tableau_annee_cotisation->getMessage().'<br />'.$tableau_annee_cotisation->getDebugInfo();
375
		return $tableau_annee_cotisation->getMessage().'<br />'.$tableau_annee_cotisation->getDebugInfo();
369
	}
376
	}
370
	$requete = 'select MC_ID,MC_LABEL from MODE_COTISATION order by MC_ID' ;
377
	$requete = 'select MC_ID,MC_LABEL from MODE_COTISATION order by MC_ID' ;
371
	$tableau_mode_cotisation = & $GLOBALS['ann_db']->getAssoc($requete);
378
	$tableau_mode_cotisation = & $GLOBALS['ann_db']->getAssoc($requete);
372
	if (DB::isError($tableau_annee_cotisation)) {
379
	if (DB::isError($tableau_annee_cotisation)) {
373
		return $tableau_mode_cotisation->getMessage().'<br />'.$tableau_mode_cotisation->getDebugInfo();
380
		return $tableau_mode_cotisation->getMessage().'<br />'.$tableau_mode_cotisation->getDebugInfo();
374
	}
381
	}
375
	// Initialisation de la table
382
	// Initialisation de la table
376
	include_once 'api/pear/HTML/Table.php';
383
	include_once 'api/pear/HTML/Table.php';
377
	$table = new HTML_Table(array('class' => 'table_cadre'));
384
	$table = new HTML_Table(array('class' => 'table_cadre'));
378
	$table->addRow(array_merge (array('Année'), $tableau_mode_cotisation, 
385
	$table->addRow(array_merge (array('Année'), $tableau_mode_cotisation, 
379
				array('Total', 'Nb cotisant', 'Nb inscrit', 'Ratio')), '', 'TH');
386
				array('Total', 'Nb cotisant', 'Nb inscrit', 'Ratio')), '', 'TH');
380
	
387
	
381
	foreach ($tableau_annee_cotisation as $annee) {
388
	foreach ($tableau_annee_cotisation as $annee) {
382
		
389
		
383
		// recherche du nombre d adherent de l annee
390
		// recherche du nombre d adherent de l annee
384
		$requete_nb_cotisant = 'select count(*) as nbr from annuaire_tela where U_DATE < "'.$annee.'-12-31" union'.
391
		$requete_nb_cotisant = 'select count(*) as nbr from annuaire_tela where U_DATE < "'.$annee.'-12-31" union'.
385
								' select count(*) as nbr from annuaire_COTISATION where year(IC_DATE)='.$annee;
392
								' select count(*) as nbr from annuaire_COTISATION where year(IC_DATE)='.$annee;
386
		// La requete union renvoie une colonne appele nbr avec 2 lignes le nbre inscrit a tela et le nbre de cotisant 
393
		// La requete union renvoie une colonne appele nbr avec 2 lignes le nbre inscrit a tela et le nbre de cotisant 
387
		// pour une année donnee
394
		// pour une année donnee
388
		
395
		
389
		$resultat = $GLOBALS['ann_db']->query($requete_nb_cotisant);
396
		$resultat = $GLOBALS['ann_db']->query($requete_nb_cotisant);
390
		if (DB::isError($resultat)) {
397
		if (DB::isError($resultat)) {
391
				return $resultat->getMessage().'<br />'.$rseultat->getDebugInfo();
398
				return $resultat->getMessage().'<br />'.$rseultat->getDebugInfo();
392
		}
399
		}
393
		$nb_inscrit_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
400
		$nb_inscrit_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
394
		$nb_cotisant_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
401
		$nb_cotisant_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
395
		$ratio = $nb_cotisant_annee->nbr / $nb_inscrit_annee->nbr * 100;
402
		$ratio = $nb_cotisant_annee->nbr / $nb_inscrit_annee->nbr * 100;
396
		$ligne_table = array();
403
		$ligne_table = array();
397
		
404
		
398
		// On insere une premiere colone pour les annees
405
		// On insere une premiere colone pour les annees
399
		array_push ($ligne_table, $annee);
406
		array_push ($ligne_table, $annee);
400
		$somme_annee = 0;
407
		$somme_annee = 0;
401
		foreach ($tableau_mode_cotisation as $mode_id => $mode_label) {
408
		foreach ($tableau_mode_cotisation as $mode_id => $mode_label) {
402
			$requete = 'select sum(IC_MONTANT) as montant from annuaire_COTISATION where IC_MC_ID='.$mode_id.
409
			$requete = 'select sum(IC_MONTANT) as montant from annuaire_COTISATION where IC_MC_ID='.$mode_id.
403
						' and year(IC_DATE)='.$annee;
410
						' and year(IC_DATE)='.$annee;
404
			$montant = $GLOBALS['ann_db']->getOne($requete);
411
			$montant = $GLOBALS['ann_db']->getOne($requete);
405
			if (DB::isError($montant)) {
412
			if (DB::isError($montant)) {
406
				return $montant->getMessage().'<br />'.$montant->getDebugInfo();
413
				return $montant->getMessage().'<br />'.$montant->getDebugInfo();
407
			}
414
			}
408
			array_push ($ligne_table, $montant);
415
			array_push ($ligne_table, $montant);
409
			$somme_annee += $montant;
416
			$somme_annee += $montant;
410
		}
417
		}
411
		
418
		
412
		array_push ($ligne_table, $somme_annee, $nb_cotisant_annee->nbr, $nb_inscrit_annee->nbr,substr((string)$ratio, 0, 5).' %');
419
		array_push ($ligne_table, $somme_annee, $nb_cotisant_annee->nbr, $nb_inscrit_annee->nbr,substr((string)$ratio, 0, 5).' %');
413
		
420
		
414
		$table->addRow($ligne_table);
421
		$table->addRow($ligne_table);
415
		
422
		
416
	}
423
	}
417
	$res .= $table->toHTML();
424
	$res .= $table->toHTML();
418
	$res .= print_r(parse_url($GLOBALS['ann_url']->getURL(), PHP_URL_PATH), true);
425
	$res .= print_r(parse_url($GLOBALS['ann_url']->getURL(), PHP_URL_PATH), true);
419
	return $res;
426
	return $res;
420
}
427
}
421
/* +--Fin du code ----------------------------------------------------------------------------------------+
428
/* +--Fin du code ----------------------------------------------------------------------------------------+
422
*
429
*
423
* $Log:$
430
* $Log:$
424
* * +-- Fin du code ----------------------------------------------------------------------------------------+
431
* * +-- Fin du code ----------------------------------------------------------------------------------------+
425
*/
432
*/
426
 
433
 
427
?>
434
?>