Subversion Repositories Sites.tela-botanica.org

Rev

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

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