Subversion Repositories Sites.tela-botanica.org

Rev

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

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