| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | require_once("../class/config.php"); |
|---|
| 6 | require_once("stat_functions.php"); |
|---|
| 7 | |
|---|
| 8 | /* Affichage des variables : */ |
|---|
| 9 | /* |
|---|
| 10 | reset($_POST); |
|---|
| 11 | while (list($k,$v)=each($_POST)) { |
|---|
| 12 | echo "$k = $v<br />"; |
|---|
| 13 | if (is_array($v)) { |
|---|
| 14 | reset($v); |
|---|
| 15 | echo $k."[] = "; |
|---|
| 16 | while (list($k2,$v2)=each($v)) { |
|---|
| 17 | echo $v2.", "; |
|---|
| 18 | } |
|---|
| 19 | } |
|---|
| 20 | } |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | $tbl=""; |
|---|
| 25 | $where=""; |
|---|
| 26 | $fields=""; |
|---|
| 27 | $order=""; |
|---|
| 28 | $inner=array(); |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | if ($pa=="d") { // enfants |
|---|
| 32 | $tbl=" enfants u "; |
|---|
| 33 | $txt1="d'enfants"; |
|---|
| 34 | } |
|---|
| 35 | if ($pa=="e") { // etablissements |
|---|
| 36 | $tbl=" ets u "; |
|---|
| 37 | $txt1="d'etablissements"; |
|---|
| 38 | } |
|---|
| 39 | if ($pa=="f") { // universites |
|---|
| 40 | $tbl=" univ u "; |
|---|
| 41 | $txt1="d'universités"; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | if ($pa=="a") { // salarie |
|---|
| 46 | $where=" AND u.typ=1 "; |
|---|
| 47 | $txt1="de salariés"; |
|---|
| 48 | } |
|---|
| 49 | if ($pa=="b") { // etudiants |
|---|
| 50 | $where=" AND u.typ=0"; |
|---|
| 51 | $txt1="d'étudiants"; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | /* ************************************************************************* */ |
|---|
| 59 | /* SALARIES ETUDIANTS OU LES 2 */ |
|---|
| 60 | /* ************************************************************************* */ |
|---|
| 61 | |
|---|
| 62 | if ($pa=="a" || $pa=="b" || $pa=="c") { |
|---|
| 63 | $tbl=" users u "; |
|---|
| 64 | if ($pa=="c") $txt1="de salariés et étudiants"; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | // critere Geographique : pour tous |
|---|
| 68 | if ($q=="a") { // territoire |
|---|
| 69 | $where.=" AND u.tid='$qa' "; |
|---|
| 70 | list($ttt)=@mysql_fetch_array(mq("SELECT territoire FROM territoires WHERE id='$qa';")); |
|---|
| 71 | $txt2[]="sur le territoire ".$ttt; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | if ($q=="b") { // région |
|---|
| 75 | list($ttt)=@mysql_fetch_array(mq("SELECT region FROM regions WHERE id='$qb';")); |
|---|
| 76 | $txt2[]="dans la région ".$ttt; |
|---|
| 77 | $where.=" AND t.region='$qb' "; |
|---|
| 78 | if (!$inner[territoires]) { |
|---|
| 79 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 80 | $inner[territoires]=1; |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | if ($pa=="a" || $pa=="b" || $pa=="c") { |
|---|
| 85 | $order="nom"; |
|---|
| 86 | |
|---|
| 87 | if ($o=="b" && is_array($ob)) { // restriction par projets |
|---|
| 88 | if (!$inner[proj_users]) { |
|---|
| 89 | $tbl.=" INNER JOIN proj_users p ON p.eid=u.login "; |
|---|
| 90 | $inner[proj_users]=1; |
|---|
| 91 | } |
|---|
| 92 | $ttt2=""; |
|---|
| 93 | for($i=0;$i<count($ob);$i++) { |
|---|
| 94 | if ($i!=0) $ttt2.=", "; |
|---|
| 95 | $ttt2.=substr($ob[$i],1); |
|---|
| 96 | } |
|---|
| 97 | $where.=" AND p.pid IN ($ttt2) "; |
|---|
| 98 | $ttt=""; |
|---|
| 99 | $tt=mq("SELECT concat(nom,' (',ville,')') FROM projets WHERE id IN ($ttt2);"); |
|---|
| 100 | while ($tt2=mysql_fetch_array($tt)) { |
|---|
| 101 | $ttt.=$tt2[0].", "; |
|---|
| 102 | } |
|---|
| 103 | $txt2[]="Lié à l'un des projets suivants : ".$ttt; |
|---|
| 104 | } |
|---|
| 105 | if ($o=="c" && $oc) { // restriction par type de projet |
|---|
| 106 | if (!$inner[proj_users]) { |
|---|
| 107 | $tbl.=" INNER JOIN proj_users p ON p.eid=u.login "; |
|---|
| 108 | $inner[proj_users]=1; |
|---|
| 109 | } |
|---|
| 110 | if (!$inner[projets]) { |
|---|
| 111 | $tbl.=" INNER JOIN projets prj ON prj.id=p.pid "; |
|---|
| 112 | $inner[projets]=1; |
|---|
| 113 | } |
|---|
| 114 | $where.=" AND prj.type = '".substr($oc,1)."' "; |
|---|
| 115 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_actions WHERE id='".substr($oc,1)."';")); |
|---|
| 116 | $txt2[]="Lié à un projet du type : $ttt"; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | if ($nl) { |
|---|
| 120 | $nla=intval($nla); if (!$nla) $nla="0"; |
|---|
| 121 | $nlb=intval($nlb); if (!$nlb) $nlb="0"; |
|---|
| 122 | $where.=" AND birth < DATE_SUB(NOW(),INTERVAL $nla YEAR) AND birth > DATE_SUB(NOW(),INTERVAL $nlb YEAR) "; |
|---|
| 123 | $txt2[]="Dont l'âge est compris entre $nla et $nlb ans"; |
|---|
| 124 | } |
|---|
| 125 | if ($nc) { |
|---|
| 126 | $where.=" AND u.nom LIKE '%$nc%' "; |
|---|
| 127 | $txt2[]="Dont le nom contient '$nc'"; |
|---|
| 128 | } |
|---|
| 129 | if ($ncb) { |
|---|
| 130 | $where.=" AND u.adresse2 LIKE '%$ncb%' "; |
|---|
| 131 | $txt2[]="Dont l'adresse 2 contient '$ncb'"; |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | } // salariés, étudiants ou les 2. |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | if ($pa=="b") { // etudiants critères spécifiques : |
|---|
| 138 | |
|---|
| 139 | if ($s=="b" && $sb) { // restriction par université |
|---|
| 140 | $where.=" AND u.univ = '".substr($sb,1)."' "; |
|---|
| 141 | list($ttt)=@mysql_fetch_array(mq("SELECT concat(nom,' (',ville,')') FROM univ WHERE id='".substr($sb,1)."';")); |
|---|
| 142 | $txt2[]="Etudiant à l'université : $ttt"; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | if ($na==1) { $where.=" AND u.adherent=1 "; $txt2[]="Etudiant Adhérent"; } |
|---|
| 146 | if ($na==2) { $where.=" AND u.adherent=0 "; $txt2[]="Etudiant NON Adhérent"; } |
|---|
| 147 | if ($nb==1) { $where.=" AND u.referent=1 "; $txt2[]="Etudiant Référent"; } |
|---|
| 148 | if ($nb==2) { $where.=" AND u.referent=0 "; $txt2[]="Etudiant NON Référent"; } |
|---|
| 149 | |
|---|
| 150 | if ($nr) { $where.=" AND u.filiere='$nr' "; |
|---|
| 151 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_filiere WHERE id='$nr';")); |
|---|
| 152 | $txt2[]="Etudiant dans la filière : $ttt"; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | if ($nd) { // niveau d'étude |
|---|
| 156 | $ttt=""; |
|---|
| 157 | $where.=" AND u.niveau IN ("; |
|---|
| 158 | for($i=0;$i<count($ne);$i++) { |
|---|
| 159 | if ($i!=0) $where.=", "; |
|---|
| 160 | $where.=$ne[$i]; |
|---|
| 161 | $ttt.=" Bac+".$ne[$i].", "; |
|---|
| 162 | } |
|---|
| 163 | $where.=") "; |
|---|
| 164 | $txt2[]="De niveau d'étude $ttt"; |
|---|
| 165 | } |
|---|
| 166 | if ($nf) { // statut de l'étudiant |
|---|
| 167 | $where.=" AND u.etusta='$nf' "; |
|---|
| 168 | $txt2[]="De statut : ".$a_sta_etu[$nf]; |
|---|
| 169 | } |
|---|
| 170 | if ($ng==1) { $where.=" AND u.voiture=1 "; $txt2[]="Ayant une voiture"; } |
|---|
| 171 | if ($ng==2) { $where.=" AND u.voiture=0 "; $txt2[]="N'ayant pas de voiture"; } |
|---|
| 172 | if ($nh) { $where.=" AND u.sexe='$nh' "; |
|---|
| 173 | if (!$nh) $txt2[]="Uniquement les filles"; else $txt2[]="Uniquement les garçons"; |
|---|
| 174 | } |
|---|
| 175 | if ($ni) { $where.=" AND u.modea='$ni' "; |
|---|
| 176 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM mode_arrivee WHERE id='$ni';")); |
|---|
| 177 | $txt2[]="Dont le mode d'arrivée est : $ttt"; |
|---|
| 178 | } |
|---|
| 179 | if ($nj) { $nj=$nj-1; $where.=" AND u.readmail='$nj' "; |
|---|
| 180 | if ($nj) $txt2[]="Qui lit son mail régulièrement"; else $txt2[]="Qui ne lit pas son mail régulièrement"; |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | /* ************************************************************************* */ |
|---|
| 187 | /* ENFANTS */ |
|---|
| 188 | /* ************************************************************************* */ |
|---|
| 189 | |
|---|
| 190 | if ($pa=="d") { // enfants |
|---|
| 191 | if ($nc) { |
|---|
| 192 | $where.=" AND u.nom LIKE '%$nc%' "; |
|---|
| 193 | $txt2[]="Dont le nom contient '$nc'"; |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | if ($o=="b" && is_array($ob)) { // restriction par projets |
|---|
| 197 | if (!$inner[interv_enfants]) { |
|---|
| 198 | $tbl.=" INNER JOIN interv_enfants ie ON ie.enid=u.id "; |
|---|
| 199 | $inner[interv_enfants]=1; |
|---|
| 200 | } |
|---|
| 201 | if (!$inner[interv]) { |
|---|
| 202 | $tbl.=" INNER JOIN interv ON interv.id=ie.iid "; |
|---|
| 203 | $inner[interv]=1; |
|---|
| 204 | } |
|---|
| 205 | $ttt2=""; |
|---|
| 206 | for($i=0;$i<count($ob);$i++) { |
|---|
| 207 | if ($i!=0) $ttt2.=", "; |
|---|
| 208 | $ttt2.=substr($ob[$i],1); |
|---|
| 209 | } |
|---|
| 210 | $where.=" AND interv.pid IN ($ttt2) "; |
|---|
| 211 | $ttt=""; |
|---|
| 212 | $tt=mq("SELECT concat(nom,' (',ville,')') FROM projets WHERE id IN ($ttt2);"); |
|---|
| 213 | while ($tt2=mysql_fetch_array($tt)) { |
|---|
| 214 | $ttt.=$tt2[0].", "; |
|---|
| 215 | } |
|---|
| 216 | $txt2[]="Lié à l'un des projets suivants : ".$ttt; |
|---|
| 217 | |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | if ($o=="c" && $oc) { // restriction par type de projets |
|---|
| 221 | if (!$inner[interv_enfants]) { |
|---|
| 222 | $tbl.=" INNER JOIN interv_enfants ie ON ie.enid=u.id "; |
|---|
| 223 | $inner[interv_enfants]=1; |
|---|
| 224 | } |
|---|
| 225 | if (!$inner[interv]) { |
|---|
| 226 | $tbl.=" INNER JOIN interv ON interv.id=ie.iid "; |
|---|
| 227 | $inner[interv]=1; |
|---|
| 228 | } |
|---|
| 229 | if (!$inner[projets]) { |
|---|
| 230 | $tbl.=" INNER JOIN projets prj ON prj.id=interv.pid "; |
|---|
| 231 | $inner[projets]=1; |
|---|
| 232 | } |
|---|
| 233 | $where.=" AND prj.type = '".substr($oc,1)."' "; |
|---|
| 234 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_actions WHERE id='".substr($oc,1)."';")); |
|---|
| 235 | $txt2[]="Lié à un projet du type : $ttt"; |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | // sexe : |
|---|
| 241 | if ($tb) { $where.=" AND u.sexe='$tb' "; |
|---|
| 242 | if (!$tb) $txt2[]="Uniquement les filles"; else $txt2[]="Uniquement les garçons"; |
|---|
| 243 | |
|---|
| 244 | } |
|---|
| 245 | // classe : |
|---|
| 246 | if ($ta) { $where.=" AND u.classe='$ta' "; |
|---|
| 247 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_classe WHERE id='$ta';")); |
|---|
| 248 | $txt2[]="Enfants de la classe de : $ttt"; |
|---|
| 249 | } |
|---|
| 250 | // etablissement |
|---|
| 251 | if ($tc=='b') { $where.=" AND u.eid='".substr($tcb,1)."' "; |
|---|
| 252 | list($ttt)=@mysql_fetch_array(mq("SELECT concat(nom,' (',ville,')') FROM ets WHERE id='".substr($tcb,1)."';")); |
|---|
| 253 | $txt2[]="Enfants de l'établissement : $ttt"; |
|---|
| 254 | } |
|---|
| 255 | // type d'établissement |
|---|
| 256 | if ($tc=='c') { |
|---|
| 257 | $where.=" AND un.etype='$tcc' "; |
|---|
| 258 | if (!$inner[ets]) { |
|---|
| 259 | $tbl.=" LEFT JOIN ets un ON un.id=u.eid "; |
|---|
| 260 | $inner[ets]=1; |
|---|
| 261 | } |
|---|
| 262 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_ets WHERE id='$tcc';")); |
|---|
| 263 | $txt2[]="Enfants dans les établissements du type : $ttt"; |
|---|
| 264 | |
|---|
| 265 | } |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | /* ************************************************************************* */ |
|---|
| 269 | /* ETABLISSEMENTS */ |
|---|
| 270 | /* ************************************************************************* */ |
|---|
| 271 | if ($pa=="e") { |
|---|
| 272 | if ($te=="a") { $where.=" AND u.etype='$tea' "; |
|---|
| 273 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_ets WHERE id='$tea';")); |
|---|
| 274 | $txt2[]="Etablissements du type : $ttt"; |
|---|
| 275 | } |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | /* ************************************************************************* */ |
|---|
| 279 | /* UNIVERSITES */ |
|---|
| 280 | /* ************************************************************************* */ |
|---|
| 281 | if ($pa=="f") { |
|---|
| 282 | if ($tf=="a") { $where.=" AND u.etype='$tfa' "; } |
|---|
| 283 | list($ttt)=@mysql_fetch_array(mq("SELECT data FROM type_univ WHERE id='$tfa';")); |
|---|
| 284 | $txt2[]="Universités du type : $ttt"; |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | /* ************************************************************************* */ |
|---|
| 289 | /* ************************************************************************* */ |
|---|
| 290 | /* NOW THE FIELDS */ |
|---|
| 291 | /* ************************************************************************* */ |
|---|
| 292 | /* ************************************************************************* */ |
|---|
| 293 | |
|---|
| 294 | /* ************************************************************************* */ |
|---|
| 295 | /* GROUPS */ |
|---|
| 296 | /* ************************************************************************* */ |
|---|
| 297 | |
|---|
| 298 | if ($r=="e") { |
|---|
| 299 | /* Special case : handle a group by managment. */ |
|---|
| 300 | switch ($rre) { |
|---|
| 301 | case 'a': // par territoire |
|---|
| 302 | $txt3="Calcul regroupé par territoire"; |
|---|
| 303 | // Ajoute la table territoire si elle n'a pas été incluse. |
|---|
| 304 | if (!$inner[territoires]) { |
|---|
| 305 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 306 | $inner[territoires]=1; |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | $fields=" t.territoire , count(*) AS compteur "; |
|---|
| 310 | $group=" GROUP BY t.id "; |
|---|
| 311 | break; |
|---|
| 312 | case 'b': // par région |
|---|
| 313 | $txt3="Calcul regroupé par région"; |
|---|
| 314 | // Ajoute la table territoire si elle n'a pas été incluse. |
|---|
| 315 | if (!$inner[territoires]) { |
|---|
| 316 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 317 | $inner[territoires]=1; |
|---|
| 318 | } |
|---|
| 319 | // Ajoute la table region si elle n'a pas été incluse. |
|---|
| 320 | if (!$inner[region]) { |
|---|
| 321 | $tbl.=" INNER JOIN regions r ON r.id=t.region "; |
|---|
| 322 | $inner[region]=1; |
|---|
| 323 | } |
|---|
| 324 | $fields=" r.region, count(*) AS compteur "; |
|---|
| 325 | $group=" GROUP BY r.id "; |
|---|
| 326 | break; |
|---|
| 327 | case 'c': // par projet (pour les étudiants) |
|---|
| 328 | $txt3="Calcul regroupé par projet"; |
|---|
| 329 | if (!$inner[proj_users]) { |
|---|
| 330 | $tbl.=" INNER JOIN proj_users p ON p.eid=u.login "; |
|---|
| 331 | $inner[proj_users]=1; |
|---|
| 332 | } |
|---|
| 333 | if (!$inner[projets]) { |
|---|
| 334 | $tbl.=" LEFT JOIN projets prj ON prj.id=p.pid "; |
|---|
| 335 | $inner[projets]=1; |
|---|
| 336 | } |
|---|
| 337 | $fields=" CONCAT(prj.nom,' (',prj.id,')') AS projet, count(*) AS compteur "; |
|---|
| 338 | $group=" GROUP BY prj.id "; |
|---|
| 339 | break; |
|---|
| 340 | case 'd': // par type de projet (pour les étudiants) |
|---|
| 341 | $txt3="Calcul regroupé par type de projet"; |
|---|
| 342 | if (!$inner[proj_users]) { |
|---|
| 343 | $tbl.=" INNER JOIN proj_users p ON p.eid=u.login "; |
|---|
| 344 | $inner[proj_users]=1; |
|---|
| 345 | } |
|---|
| 346 | if (!$inner[projets]) { |
|---|
| 347 | $tbl.=" LEFT JOIN projets prj ON prj.id=p.pid "; |
|---|
| 348 | $inner[projets]=1; |
|---|
| 349 | } |
|---|
| 350 | if (!$inner[type_actions]) { |
|---|
| 351 | $tbl.=" INNER JOIN type_actions ta ON ta.id=prj.type "; |
|---|
| 352 | $inner[type_actions]=1; |
|---|
| 353 | } |
|---|
| 354 | $fields=" ta.data AS TypeDeProjet, count(*) AS compteur "; |
|---|
| 355 | $group=" GROUP BY ta.id "; |
|---|
| 356 | break; |
|---|
| 357 | case 'e': // par université |
|---|
| 358 | $txt3="Calcul regroupé par université"; |
|---|
| 359 | if (!$inner[univ]) { |
|---|
| 360 | $tbl.=" LEFT JOIN univ un ON un.id=u.univ "; |
|---|
| 361 | $inner[univ]=1; |
|---|
| 362 | } |
|---|
| 363 | $fields=" concat(un.nom,' (',un.ville,')') AS universite, count(*) as compteur "; |
|---|
| 364 | $group=" GROUP BY un.id "; |
|---|
| 365 | break; |
|---|
| 366 | case 'f': // par type d'université |
|---|
| 367 | $txt3="Calcul regroupé par type d'université"; |
|---|
| 368 | if (!$inner[univ]) { |
|---|
| 369 | $tbl.=" LEFT JOIN univ un ON un.id=u.univ "; |
|---|
| 370 | $inner[univ]=1; |
|---|
| 371 | } |
|---|
| 372 | if (!$inner[type_univ]) { |
|---|
| 373 | $tbl.=" LEFT JOIN type_univ tu ON un.etype=tu.id "; |
|---|
| 374 | $inner[type_univ]=1; |
|---|
| 375 | } |
|---|
| 376 | $fields=" tu.data AS TypeUniversite, count(*) as compteur "; |
|---|
| 377 | $group=" GROUP BY tu.id "; |
|---|
| 378 | break; |
|---|
| 379 | case 'g': // par filiere de l'étudiant |
|---|
| 380 | $txt3="Calcul regroupé par filière d'étude"; |
|---|
| 381 | if (!$inner[type_filiere]) { |
|---|
| 382 | $tbl.=" LEFT JOIN type_filiere tf ON u.filiere=tf.id "; |
|---|
| 383 | $inner[type_filiere]=1; |
|---|
| 384 | } |
|---|
| 385 | $fields=" tf.data as Filiere, count(*) as compteur "; |
|---|
| 386 | $group=" GROUP BY tf.id "; |
|---|
| 387 | break; |
|---|
| 388 | case 'h': // par adhérent |
|---|
| 389 | $txt3="Calcul regroupé par statut adhérent"; |
|---|
| 390 | $fields=" CASE u.adherent WHEN 1 THEN 'Adhérent' ELSE 'Non Adhérent' END AS Adherent, count(*) AS compteur "; |
|---|
| 391 | $group=" GROUP BY u.adherent "; |
|---|
| 392 | break; |
|---|
| 393 | case 'i': // par référent |
|---|
| 394 | $txt3="Calcul regroupé par statut référent"; |
|---|
| 395 | $fields=" CASE u.referent WHEN 1 THEN 'Référent' ELSE 'Non Référent' END AS Referent, count(*) AS compteur "; |
|---|
| 396 | $group=" GROUP BY u.referent "; |
|---|
| 397 | break; |
|---|
| 398 | case 'j': // par niveau d'étude |
|---|
| 399 | $txt3="Calcul regroupé par niveau d'étude"; |
|---|
| 400 | $fields=" CONCAT('Bac +',niveau) AS Niveau, count(*) AS compteur "; |
|---|
| 401 | $group=" GROUP BY u.niveau "; |
|---|
| 402 | break; |
|---|
| 403 | case 'k': // par statut |
|---|
| 404 | $txt3="Calcul regroupé par statut étudiant"; |
|---|
| 405 | $fields=" CASE u.etusta WHEN 1 THEN 'Demandeur' WHEN 2 THEN 'Contacté' |
|---|
| 406 | WHEN 3 THEN 'Volontaire' WHEN 4 THEN 'Volontaire Actif' WHEN 5 THEN 'Ancien' |
|---|
| 407 | ELSE 'autre !' END AS statut, count(*) as compteur "; |
|---|
| 408 | $group=" GROUP BY u.etusta "; |
|---|
| 409 | break; |
|---|
| 410 | case 'o': // par sexe de l'enfant |
|---|
| 411 | case 'l': // par sexe |
|---|
| 412 | $txt3="Calcul regroupé par sexe"; |
|---|
| 413 | $fields=" CASE u.sexe WHEN 1 THEN 'Garçon' ELSE 'Fille' END AS sexe , count(*) as compteur "; |
|---|
| 414 | $group=" GROUP BY u.sexe "; |
|---|
| 415 | break; |
|---|
| 416 | case 'm': // par mode d'arrivée |
|---|
| 417 | $txt3="Calcul regroupé par mode d'arrivée à l'AFEV"; |
|---|
| 418 | if (!$inner[mode_arrivee]) { |
|---|
| 419 | $tbl.=" LEFT JOIN mode_arrivee ma ON ma.id=u.modea "; |
|---|
| 420 | $inner[mode_arrivee]=1; |
|---|
| 421 | } |
|---|
| 422 | $fields=" ma.data AS ModeArrivee, count(*) as compteur "; |
|---|
| 423 | $group=" GROUP BY ma.id "; |
|---|
| 424 | break; |
|---|
| 425 | case 'n': // par classe de l'enfant |
|---|
| 426 | $txt3="Calcul regroupé par classe"; |
|---|
| 427 | if (!$inner[type_classe]) { |
|---|
| 428 | $tbl.=" LEFT JOIN type_classe cl ON cl.id=u.classe "; |
|---|
| 429 | $inner[type_classe]=1; |
|---|
| 430 | } |
|---|
| 431 | $fields=" cl.data AS Classe, count(*) as compteur "; |
|---|
| 432 | $group=" GROUP BY cl.id "; |
|---|
| 433 | break; |
|---|
| 434 | case 'p': // par etablissement de l'enfant |
|---|
| 435 | $txt3="Calcul regroupé par établissement de provenance"; |
|---|
| 436 | if (!$inner[ets]) { |
|---|
| 437 | $tbl.=" LEFT JOIN ets ON ets.id=u.eid "; |
|---|
| 438 | $inner[ets]=1; |
|---|
| 439 | } |
|---|
| 440 | $fields=" concat(ets.nom,' (',ets.ville,')') AS Etablissement, count(*) as compteur "; |
|---|
| 441 | $group=" GROUP BY ets.id "; |
|---|
| 442 | break; |
|---|
| 443 | case 'q': // par type d'établissement |
|---|
| 444 | $txt3="Calcul regroupé par type d'établissement de provenance"; |
|---|
| 445 | if (!$inner[ets]) { |
|---|
| 446 | $tbl.=" LEFT JOIN ets ON ets.id=u.eid "; |
|---|
| 447 | $inner[ets]=1; |
|---|
| 448 | } |
|---|
| 449 | if (!$inner[type_ets]) { |
|---|
| 450 | $tbl.=" LEFT JOIN type_ets te ON te.id=ets.etype "; |
|---|
| 451 | $inner[type_ets]=1; |
|---|
| 452 | } |
|---|
| 453 | $fields=" te.data AS TypeEtablissement, count(*) as compteur "; |
|---|
| 454 | $group=" GROUP BY te.id "; |
|---|
| 455 | break; |
|---|
| 456 | case 'r': // par type d'établissement (pour les ets eux-même) |
|---|
| 457 | $txt3="Calcul regroupé par type d'établissement"; |
|---|
| 458 | if (!$inner[type_ets]) { |
|---|
| 459 | $tbl.=" LEFT JOIN type_ets te ON te.id=u.etype "; |
|---|
| 460 | $inner[type_ets]=1; |
|---|
| 461 | } |
|---|
| 462 | $fields=" te.data AS TypeEtablissement, count(*) as compteur "; |
|---|
| 463 | $group=" GROUP BY te.id "; |
|---|
| 464 | break; |
|---|
| 465 | case 's': // par type d'université (pour les universités elles-memes) |
|---|
| 466 | $txt3="Calcul regroupé par type d'université"; |
|---|
| 467 | if (!$inner[type_univ]) { |
|---|
| 468 | $tbl.=" LEFT JOIN type_univ tu ON tu.id=u.etype "; |
|---|
| 469 | $inner[type_univ]=1; |
|---|
| 470 | } |
|---|
| 471 | $fields=" tu.data AS TypeUniversite, count(*) as compteur "; |
|---|
| 472 | $group=" GROUP BY tu.id "; |
|---|
| 473 | break; |
|---|
| 474 | case 't': // enfants par projet |
|---|
| 475 | $txt3="Calcul regroupé par projet de rattachement"; |
|---|
| 476 | if (!$inner[interv_enfants]) { |
|---|
| 477 | $tbl.=" LEFT JOIN interv_enfants ie ON ie.enid=u.id "; |
|---|
| 478 | $inner[interv_enfants]=1; |
|---|
| 479 | } |
|---|
| 480 | if (!$inner[interv]) { |
|---|
| 481 | $tbl.=" LEFT JOIN interv ON interv.id=ie.iid "; |
|---|
| 482 | $inner[interv]=1; |
|---|
| 483 | } |
|---|
| 484 | if (!$inner[projets]) { |
|---|
| 485 | $tbl.=" LEFT JOIN projets prj ON prj.id=interv.pid "; |
|---|
| 486 | $inner[projets]=1; |
|---|
| 487 | } |
|---|
| 488 | $fields=" CONCAT(prj.nom,' (',prj.ville,')') AS Projet, count(*) as compteur "; |
|---|
| 489 | $group=" GROUP BY prj.id "; |
|---|
| 490 | break; |
|---|
| 491 | case 'u': // enfants par type de projet |
|---|
| 492 | $txt3="Calcul regroupé par type de projet"; |
|---|
| 493 | if (!$inner[interv_enfants]) { |
|---|
| 494 | $tbl.=" LEFT JOIN interv_enfants ie ON ie.enid=u.id "; |
|---|
| 495 | $inner[interv_enfants]=1; |
|---|
| 496 | } |
|---|
| 497 | if (!$inner[interv]) { |
|---|
| 498 | $tbl.=" LEFT JOIN interv ON interv.id=ie.iid "; |
|---|
| 499 | $inner[interv]=1; |
|---|
| 500 | } |
|---|
| 501 | if (!$inner[projets]) { |
|---|
| 502 | $tbl.=" LEFT JOIN projets prj ON prj.id=interv.pid "; |
|---|
| 503 | $inner[projets]=1; |
|---|
| 504 | } |
|---|
| 505 | if (!$inner[type_actions]) { |
|---|
| 506 | $tbl.=" INNER JOIN type_actions ta ON ta.id=prj.type "; |
|---|
| 507 | $inner[type_actions]=1; |
|---|
| 508 | } |
|---|
| 509 | $fields=" ta.data AS TypeDeProjet, count(*) AS compteur "; |
|---|
| 510 | $group=" GROUP BY ta.id "; |
|---|
| 511 | break; |
|---|
| 512 | } |
|---|
| 513 | $order=""; |
|---|
| 514 | } else { |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | |
|---|
| 518 | /* Normal case : select fields appropriate depending on the requested data and field list and type of output */ |
|---|
| 519 | |
|---|
| 520 | /* ************************************************************************* */ |
|---|
| 521 | /* Salaries Etudiants */ |
|---|
| 522 | /* ************************************************************************* */ |
|---|
| 523 | if ($pa=="a" || $pa=="b" || $pa=="c") { |
|---|
| 524 | if ($r=="c") { // Etiquettes (champs adresse) |
|---|
| 525 | $fields=" concat(u.nom,' ',u.prenom) AS nom, u.adresse, u.zip, u.ville "; |
|---|
| 526 | } |
|---|
| 527 | if ($r=="d") { // Email (champ login + autres champs substituables) |
|---|
| 528 | $fields=" u.login "; |
|---|
| 529 | } |
|---|
| 530 | if ($r=="b" || $r=="a" && is_array($ra)) { |
|---|
| 531 | $txt3="Liste Web"; |
|---|
| 532 | $fields=" "; |
|---|
| 533 | $first=true; |
|---|
| 534 | $normal=array("nom","prenom","adresse","zip","ville","tel","portable", |
|---|
| 535 | "tid","login","adherent","referent","niveau","struct","droit", |
|---|
| 536 | "adresse2","zip2","ville2","voiture","readmail"); |
|---|
| 537 | for($i=0;$i<count($normal);$i++) { |
|---|
| 538 | if (in_array($normal[$i],$ra)) { |
|---|
| 539 | $fields.=abf("u.".$normal[$i]); |
|---|
| 540 | } |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | // maintenant les autres champs possibles : |
|---|
| 544 | if (in_array("email",$ra)) { |
|---|
| 545 | $fields.=abf("CONCAT(login,'@afev.org') AS email"); |
|---|
| 546 | } |
|---|
| 547 | if (in_array("birth",$ra)) { |
|---|
| 548 | $fields.=abf("CONCAT(SUBSTRING(birth,9,2),'/',SUBSTRING(birth,6,2),'/',SUBSTRING(birth,1,4)) AS naissance"); |
|---|
| 549 | } |
|---|
| 550 | if (in_array("tid",$ra)) { |
|---|
| 551 | $fields.=abf("t.territoire"); |
|---|
| 552 | if (!$inner[territoires]) { |
|---|
| 553 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 554 | $inner[territoires]=1; |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | if (in_array("rid",$ra)) { |
|---|
| 559 | $fields.=abf("r.region"); |
|---|
| 560 | |
|---|
| 561 | if (!$inner[territoires]) { |
|---|
| 562 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 563 | $inner[territoires]=1; |
|---|
| 564 | } |
|---|
| 565 | if (!$inner[region]) { |
|---|
| 566 | $tbl.=" INNER JOIN regions r ON r.id=t.region "; |
|---|
| 567 | $inner[region]=1; |
|---|
| 568 | } |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | if (in_array("datearr",$ra)) { |
|---|
| 572 | $fields.=abf("CONCAT(SUBSTRING(datearr,9,2),'/',SUBSTRING(datearr,6,2),'/',SUBSTRING(datearr,1,4)) AS arrivee"); |
|---|
| 573 | } |
|---|
| 574 | |
|---|
| 575 | if (in_array("modearr",$ra)) { |
|---|
| 576 | $fields.=abf("ma.data AS modearrivee"); |
|---|
| 577 | if (!$inner[mode_arrivee]) { |
|---|
| 578 | $tbl.=" LEFT JOIN mode_arrivee ma ON ma.id=u.modea "; |
|---|
| 579 | $inner[mode_arrivee]=1; |
|---|
| 580 | } |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | if (in_array("filiere",$ra)) { |
|---|
| 584 | $fields.=abf("fi.data AS filiere"); |
|---|
| 585 | if (!$inner[filiere]) { |
|---|
| 586 | $tbl.=" LEFT JOIN type_filiere fi ON fi.id=u.filiere "; |
|---|
| 587 | $inner[filiere]=1; |
|---|
| 588 | } |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | if (in_array("univ",$ra)) { |
|---|
| 592 | $fields.=abf("un.nom AS universite"); |
|---|
| 593 | if (!$inner[univ]) { |
|---|
| 594 | $tbl.=" LEFT JOIN univ un ON un.id=u.univ "; |
|---|
| 595 | $inner[univ]=1; |
|---|
| 596 | } |
|---|
| 597 | } |
|---|
| 598 | |
|---|
| 599 | if (in_array("univville",$ra)) { |
|---|
| 600 | $fields.=abf("un.ville AS universite_ville"); |
|---|
| 601 | if (!$inner[univ]) { |
|---|
| 602 | $tbl.=" LEFT JOIN univ un ON un.id=u.univ "; |
|---|
| 603 | $inner[univ]=1; |
|---|
| 604 | } |
|---|
| 605 | } |
|---|
| 606 | |
|---|
| 607 | if (in_array("univtype",$ra)) { |
|---|
| 608 | $fields.=abf("tu.data AS universite_type"); |
|---|
| 609 | if (!$inner[univ]) { |
|---|
| 610 | $tbl.=" LEFT JOIN univ un ON un.id=u.univ "; |
|---|
| 611 | $inner[univ]=1; |
|---|
| 612 | } |
|---|
| 613 | if (!$inner[type_univ]) { |
|---|
| 614 | $tbl.=" LEFT JOIN type_univ tu ON un.etype=tu.id "; |
|---|
| 615 | $inner[type_univ]=1; |
|---|
| 616 | } |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | if (in_array("sexe",$ra)) { |
|---|
| 620 | $fields.=abf("IF(sexe=1,'Homme','Femme') AS sexe"); |
|---|
| 621 | } |
|---|
| 622 | if (in_array("etusta",$ra)) { |
|---|
| 623 | $fields.=abf("CASE u.etusta WHEN 1 THEN 'Demandeur' WHEN 2 THEN 'Contacté' |
|---|
| 624 | WHEN 3 THEN 'Volontaire' WHEN 4 THEN 'Volontaire Actif' WHEN 5 THEN 'Ancien' |
|---|
| 625 | ELSE 'autre !' END AS statut"); |
|---|
| 626 | } |
|---|
| 627 | if (in_array("solidaire",$ra)) { |
|---|
| 628 | $fields.=abf("CASE u.solidaire WHEN 0 THEN 'Non' WHEN 1 THEN 'Oui, ponctuellement' |
|---|
| 629 | WHEN 2 THEN 'Oui, longtemps' ELSE 'autre !' END AS solidaire"); |
|---|
| 630 | } |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | } |
|---|
| 634 | } // \etu/sal |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | /* ************************************************************************* */ |
|---|
| 638 | /* ENFANTS */ |
|---|
| 639 | /* ************************************************************************* */ |
|---|
| 640 | if ($pa=="d") { |
|---|
| 641 | if ($r=="c") { // Etiquettes (champs adresse) |
|---|
| 642 | $fields=" concat(u.nom,' ',u.prenom) AS nom, u.adresse, u.zip, u.ville "; |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | if ($r=="b" || $r=="a" && is_array($ra)) { |
|---|
| 646 | $txt3="Liste Web"; |
|---|
| 647 | $fields=" "; |
|---|
| 648 | $first=true; |
|---|
| 649 | $normal=array("nom","prenom","adresse","zip","ville","tel"); |
|---|
| 650 | for($i=0;$i<count($normal);$i++) { |
|---|
| 651 | if (in_array($normal[$i],$ra)) { |
|---|
| 652 | $fields.=abf("u.".$normal[$i]); |
|---|
| 653 | } |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | if (in_array("birth",$ra)) { |
|---|
| 657 | $fields.=abf("CONCAT(SUBSTRING(birth,9,2),'/',SUBSTRING(birth,6,2),'/',SUBSTRING(birth,1,4)) AS naissance"); |
|---|
| 658 | } |
|---|
| 659 | if (in_array("tid",$ra)) { |
|---|
| 660 | $fields.=abf("t.territoire"); |
|---|
| 661 | if (!$inner[territoires]) { |
|---|
| 662 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 663 | $inner[territoires]=1; |
|---|
| 664 | } |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | if (in_array("rid",$ra)) { |
|---|
| 668 | $fields.=abf("r.region"); |
|---|
| 669 | |
|---|
| 670 | if (!$inner[territoires]) { |
|---|
| 671 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 672 | $inner[territoires]=1; |
|---|
| 673 | } |
|---|
| 674 | if (!$inner[region]) { |
|---|
| 675 | $tbl.=" INNER JOIN regions r ON r.id=t.region "; |
|---|
| 676 | $inner[region]=1; |
|---|
| 677 | } |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | if (in_array("eid",$ra)) { |
|---|
| 681 | $fields.=abf("un.nom AS etablissement"); |
|---|
| 682 | if (!$inner[ets]) { |
|---|
| 683 | $tbl.=" LEFT JOIN ets un ON un.id=u.eid "; |
|---|
| 684 | $inner[ets]=1; |
|---|
| 685 | } |
|---|
| 686 | } |
|---|
| 687 | |
|---|
| 688 | if (in_array("projet",$ra)) { |
|---|
| 689 | $fields.=abf("prj.nom AS projet"); |
|---|
| 690 | if (!$inner[interv_enfants]) { |
|---|
| 691 | $tbl.=" LEFT JOIN interv_enfants ine ON ine.enid=u.id "; |
|---|
| 692 | $inner[interv_enfants]=1; |
|---|
| 693 | } |
|---|
| 694 | if (!$inner[interv]) { |
|---|
| 695 | $tbl.=" LEFT JOIN interv ON interv.id=ine.iid "; |
|---|
| 696 | $inner[interv]=1; |
|---|
| 697 | } |
|---|
| 698 | if (!$inner[projets]) { |
|---|
| 699 | $tbl.=" LEFT JOIN projets prj ON prj.id=interv.pid "; |
|---|
| 700 | $inner[projets]=1; |
|---|
| 701 | } |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | if (in_array("eidtype",$ra)) { |
|---|
| 705 | $fields.=abf("tye.data AS typeetablissement"); |
|---|
| 706 | if (!$inner[ets]) { |
|---|
| 707 | $tbl.=" LEFT JOIN ets un ON un.id=u.eid "; |
|---|
| 708 | $inner[ets]=1; |
|---|
| 709 | } |
|---|
| 710 | if (!$inner[type_ets]) { |
|---|
| 711 | $tbl.=" LEFT JOIN type_ets tye ON tye.id=un.etype "; |
|---|
| 712 | $inner[type_ets]=1; |
|---|
| 713 | } |
|---|
| 714 | } |
|---|
| 715 | |
|---|
| 716 | if (in_array("sexe",$ra)) { |
|---|
| 717 | $fields.=abf("IF(sexe=1,'Homme','Femme') AS sexe"); |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | } // listes web / excel |
|---|
| 721 | } // \enfants |
|---|
| 722 | |
|---|
| 723 | /* ************************************************************************* */ |
|---|
| 724 | /* ETABLISSEMENT */ |
|---|
| 725 | /* ************************************************************************* */ |
|---|
| 726 | if ($pa=="e") { |
|---|
| 727 | if ($r=="c") { // Etiquettes (champs adresse) |
|---|
| 728 | $fields=" u.nom, u.adresse, u.zip, u.ville "; |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | if ($r=="b" || $r=="a" && is_array($ra)) { |
|---|
| 732 | $txt3="Liste Web"; |
|---|
| 733 | $fields=" "; |
|---|
| 734 | $first=true; |
|---|
| 735 | $normal=array("nom","adresse","zip","ville","tel","email"); |
|---|
| 736 | for($i=0;$i<count($normal);$i++) { |
|---|
| 737 | if (in_array($normal[$i],$ra)) { |
|---|
| 738 | $fields.=abf("u.".$normal[$i]); |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | if (in_array("tid",$ra)) { |
|---|
| 743 | $fields.=abf("t.territoire"); |
|---|
| 744 | if (!$inner[territoires]) { |
|---|
| 745 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 746 | $inner[territoires]=1; |
|---|
| 747 | } |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | if (in_array("rid",$ra)) { |
|---|
| 751 | $fields.=abf("r.region"); |
|---|
| 752 | |
|---|
| 753 | if (!$inner[territoires]) { |
|---|
| 754 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 755 | $inner[territoires]=1; |
|---|
| 756 | } |
|---|
| 757 | if (!$inner[region]) { |
|---|
| 758 | $tbl.=" INNER JOIN regions r ON r.id=t.region "; |
|---|
| 759 | $inner[region]=1; |
|---|
| 760 | } |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | if (in_array("etype",$ra)) { |
|---|
| 764 | $fields.=abf("te.data AS TypeEtablissement"); |
|---|
| 765 | if (!$inner[type_ets]) { |
|---|
| 766 | $tbl.=" LEFT JOIN type_ets te ON te.id=u.etype "; |
|---|
| 767 | $inner[type_ets]=1; |
|---|
| 768 | } |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | } |
|---|
| 772 | } // \etablissement |
|---|
| 773 | |
|---|
| 774 | /* ************************************************************************* */ |
|---|
| 775 | /* UNIVERSITE */ |
|---|
| 776 | /* ************************************************************************* */ |
|---|
| 777 | if ($pa=="f") { |
|---|
| 778 | if ($r=="c") { // Etiquettes (champs adresse) |
|---|
| 779 | $fields=" u.nom, u.adresse, u.zip, u.ville "; |
|---|
| 780 | } |
|---|
| 781 | |
|---|
| 782 | if ($r=="b" || $r=="a" && is_array($ra)) { |
|---|
| 783 | $txt3="Liste Web"; |
|---|
| 784 | $fields=" "; |
|---|
| 785 | $first=true; |
|---|
| 786 | $normal=array("nom","adresse","zip","ville","tel","email"); |
|---|
| 787 | for($i=0;$i<count($normal);$i++) { |
|---|
| 788 | if (in_array($normal[$i],$ra)) { |
|---|
| 789 | $fields.=abf("u.".$normal[$i]); |
|---|
| 790 | } |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | if (in_array("tid",$ra)) { |
|---|
| 794 | $fields.=abf("t.territoire"); |
|---|
| 795 | if (!$inner[territoires]) { |
|---|
| 796 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 797 | $inner[territoires]=1; |
|---|
| 798 | } |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | if (in_array("rid",$ra)) { |
|---|
| 802 | $fields.=abf("r.region"); |
|---|
| 803 | |
|---|
| 804 | if (!$inner[territoires]) { |
|---|
| 805 | $tbl.=" INNER JOIN territoires t ON t.id=u.tid "; |
|---|
| 806 | $inner[territoires]=1; |
|---|
| 807 | } |
|---|
| 808 | if (!$inner[region]) { |
|---|
| 809 | $tbl.=" INNER JOIN regions r ON r.id=t.region "; |
|---|
| 810 | $inner[region]=1; |
|---|
| 811 | } |
|---|
| 812 | } |
|---|
| 813 | |
|---|
| 814 | if (in_array("etype",$ra)) { |
|---|
| 815 | $fields.=abf("tu.data AS TypeUniversite"); |
|---|
| 816 | if (!$inner[type_univ]) { |
|---|
| 817 | $tbl.=" LEFT JOIN type_univ tu ON tu.id=u.etype "; |
|---|
| 818 | $inner[type_univ]=1; |
|---|
| 819 | } |
|---|
| 820 | } |
|---|
| 821 | |
|---|
| 822 | } |
|---|
| 823 | } // \universite |
|---|
| 824 | |
|---|
| 825 | |
|---|
| 826 | |
|---|
| 827 | } // if ($r!="e") |
|---|
| 828 | |
|---|
| 829 | |
|---|
| 830 | /* ************************************************************************* */ |
|---|
| 831 | /* ORDRE */ |
|---|
| 832 | /* ************************************************************************* */ |
|---|
| 833 | $ord=""; |
|---|
| 834 | if ($order) { $ord=" ORDER BY $order "; |
|---|
| 835 | $txt4="Trié par $order"; |
|---|
| 836 | } |
|---|
| 837 | |
|---|
| 838 | $sql="SELECT $fields FROM $tbl WHERE 1 $where $group $ord"; |
|---|
| 839 | |
|---|
| 840 | |
|---|
| 841 | /* On peut afficher le sql, mais ca bouzille les entetes :) */ |
|---|
| 842 | |
|---|
| 843 | /* |
|---|
| 844 | echo " |
|---|
| 845 | <p> |
|---|
| 846 | SQL : $sql |
|---|
| 847 | </p> |
|---|
| 848 | "; |
|---|
| 849 | */ |
|---|
| 850 | |
|---|
| 851 | /* ************************************************************************* */ |
|---|
| 852 | /* AFFICHAGE RESULTAT */ |
|---|
| 853 | /* ************************************************************************* */ |
|---|
| 854 | |
|---|
| 855 | if ($r=="a" || $r=="e") { // Affichage web : |
|---|
| 856 | |
|---|
| 857 | // Affichage de la requête en francais : |
|---|
| 858 | echo "<p><b>Rappel des critères du tableau : </b><br /> |
|---|
| 859 | Voici une liste $txt1<br /> |
|---|
| 860 | "; |
|---|
| 861 | if (is_array($txt2)) { |
|---|
| 862 | foreach ($txt2 as $ttt) echo "$ttt<br />"; |
|---|
| 863 | } |
|---|
| 864 | if ($txt4) echo "$txt4<br />"; |
|---|
| 865 | if ($txt3) echo "$txt3"; |
|---|
| 866 | echo "</p>"; |
|---|
| 867 | |
|---|
| 868 | $styleinline=1; |
|---|
| 869 | include("head.php"); |
|---|
| 870 | |
|---|
| 871 | $res=mq($sql); |
|---|
| 872 | echo "<p>Résultats : ".mysql_num_rows($res)." Lignes</p>"; |
|---|
| 873 | if (mysql_errno()) { |
|---|
| 874 | echo "<h6>Oups, cette requête semble incorrecte. Signalez-nous l'erreur...<br />".mysql_error()."</h6>"; |
|---|
| 875 | exit; |
|---|
| 876 | } |
|---|
| 877 | |
|---|
| 878 | $first=true; |
|---|
| 879 | while ($c=mysql_fetch_array($res,MYSQL_ASSOC)) { |
|---|
| 880 | if ($first) { |
|---|
| 881 | echo "<table class=\"mgt\"> |
|---|
| 882 | <tr>"; |
|---|
| 883 | $rt=array_keys($c); |
|---|
| 884 | for($i=0;$i<count($rt);$i++) { |
|---|
| 885 | echo "<th>$rt[$i]</th>"; |
|---|
| 886 | } |
|---|
| 887 | echo " |
|---|
| 888 | </tr> |
|---|
| 889 | "; |
|---|
| 890 | } |
|---|
| 891 | $first=false; |
|---|
| 892 | echo "<tr> |
|---|
| 893 | "; |
|---|
| 894 | for($i=0;$i<count($rt);$i++) { |
|---|
| 895 | echo "<td>".$c[$rt[$i]]."</td>"; |
|---|
| 896 | } |
|---|
| 897 | echo " |
|---|
| 898 | </tr> |
|---|
| 899 | "; |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | echo "</table> |
|---|
| 903 | "; |
|---|
| 904 | |
|---|
| 905 | include("foot.php"); |
|---|
| 906 | exit; |
|---|
| 907 | |
|---|
| 908 | |
|---|
| 909 | } |
|---|
| 910 | |
|---|
| 911 | |
|---|
| 912 | if ($r=="b") { // CSV Excel |
|---|
| 913 | |
|---|
| 914 | $res=mq($sql); |
|---|
| 915 | |
|---|
| 916 | if (mysql_errno()) { |
|---|
| 917 | echo "<h6>Oups, cette requête semble incorrecte. Signalez-nous l'erreur...<br />".mysql_error()."</h6>"; |
|---|
| 918 | exit; |
|---|
| 919 | } |
|---|
| 920 | |
|---|
| 921 | header("Content-type: text/csv"); |
|---|
| 922 | header("Content-Disposition: attachment"); |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | $gu="\""; |
|---|
| 927 | $sep=";"; |
|---|
| 928 | |
|---|
| 929 | function addslashes2($str) { |
|---|
| 930 | global $gu; |
|---|
| 931 | return str_replace("\n","\r\n",str_replace("$gu","$gu$gu",$str)); |
|---|
| 932 | } |
|---|
| 933 | |
|---|
| 934 | $first=true; |
|---|
| 935 | while ($c=mysql_fetch_array($res,MYSQL_ASSOC)) { |
|---|
| 936 | if ($first) { |
|---|
| 937 | $rt=array_keys($c); |
|---|
| 938 | for($i=0;$i<count($rt);$i++) { |
|---|
| 939 | if ($i) echo $sep; |
|---|
| 940 | echo $rt[$i]; |
|---|
| 941 | } |
|---|
| 942 | echo "\r\n"; |
|---|
| 943 | } |
|---|
| 944 | $first=false; |
|---|
| 945 | for($i=0;$i<count($rt);$i++) { |
|---|
| 946 | if ($i) echo $sep; |
|---|
| 947 | echo $gu.addslashes2($c[$rt[$i]]).$gu; |
|---|
| 948 | } |
|---|
| 949 | echo "\r\n"; |
|---|
| 950 | } |
|---|
| 951 | exit; |
|---|
| 952 | } |
|---|
| 953 | |
|---|
| 954 | |
|---|
| 955 | if ($r=="c") { |
|---|
| 956 | // Etiquettes pdf |
|---|
| 957 | include("pdf.php"); |
|---|
| 958 | } |
|---|
| 959 | |
|---|
| 960 | |
|---|
| 961 | if ($r=="d") { // Mailing :) |
|---|
| 962 | |
|---|
| 963 | $title="Envoi d'un email à une liste d'utilisateurs"; |
|---|
| 964 | include("head.php"); |
|---|
| 965 | |
|---|
| 966 | $res=mq($sql); |
|---|
| 967 | |
|---|
| 968 | if (mysql_errno()) { |
|---|
| 969 | echo "<h6>Oups, cette requête semble incorrecte. Signalez-nous l'erreur...<br />".mysql_error()."</h6>"; |
|---|
| 970 | exit; |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | if (mysql_num_rows($res)>200) { |
|---|
| 974 | ?> |
|---|
| 975 | <h1>Envoi a plus de 200 destinataires.</h1> |
|---|
| 976 | <p>Attention : le mail que vous allez envoyer va être destiné à plus de 200 destinataire. Je ne vous afficherais donc pas leur noms. Assurez-vous d'avoir bien choisi vos critères de sélection avant d'envoyer ce mail</p> |
|---|
| 977 | <form method="post" action="stat_mail.php"> |
|---|
| 978 | <table class="mgt"> |
|---|
| 979 | <tr><th colspan="2" style="text-align: center">Envoi d'email à une liste</th></tr> |
|---|
| 980 | <tr><th>Destinataires</th><td>Plus de 200, non affichés |
|---|
| 981 | <input type="hidden" name="sql" value="<?php echo urlencode($sql); ?>" /> |
|---|
| 982 | </td></tr> |
|---|
| 983 | |
|---|
| 984 | <?php } else { ?> |
|---|
| 985 | |
|---|
| 986 | <form method="post" action="stat_mail.php"> |
|---|
| 987 | <table class="mgt"> |
|---|
| 988 | <tr><th colspan="2" style="text-align: center">Envoi d'email à une liste</th></tr> |
|---|
| 989 | <tr><th>Destinataires</th> |
|---|
| 990 | <td> |
|---|
| 991 | <?php |
|---|
| 992 | while ($c=mysql_fetch_array($res,MYSQL_ASSOC)) { |
|---|
| 993 | echo "<input type=\"hidden\" name=\"rcpt[]\" value=\"$c[login]\" />$c[login] "; |
|---|
| 994 | } |
|---|
| 995 | ?> |
|---|
| 996 | </td></tr> |
|---|
| 997 | <?php } ?> |
|---|
| 998 | <tr><th>Expéditeur</th><td> |
|---|
| 999 | <?php if ($right==4) { ?> |
|---|
| 1000 | <?php echo $uid; ?>@afev.org<input type="hidden" name="from" value="<?php echo $uid; ?>@afev.org" /> |
|---|
| 1001 | <?php } else { ?> |
|---|
| 1002 | <select name="from"><option value="<?php echo $uid; ?>@afev.org"><?php echo $uid; ?>@afev.org</option> |
|---|
| 1003 | <?php |
|---|
| 1004 | // en fonction de qui on a, on affiche les from autorisés : |
|---|
| 1005 | $sql="SELECT email FROM territoires "; |
|---|
| 1006 | if ($right!=1 && $right!=5 && $right!=6) $sql.="WHERE id='$ctid'"; |
|---|
| 1007 | $g=mq($sql.";"); |
|---|
| 1008 | while (list($mailtid)=mysql_fetch_array($g)) { |
|---|
| 1009 | if ($mailtid) { |
|---|
| 1010 | echo "<option value=\"$mailtid\">$mailtid</option>"; |
|---|
| 1011 | } |
|---|
| 1012 | } |
|---|
| 1013 | if ($right==1) { |
|---|
| 1014 | echo "<option value=\"webmaster@afev.org\">webmaster@afev.org</option>"; |
|---|
| 1015 | } |
|---|
| 1016 | } |
|---|
| 1017 | ?> |
|---|
| 1018 | </select> |
|---|
| 1019 | </td></tr> |
|---|
| 1020 | <tr><th>Sujet</th><td><input type="text" id="subject" name="subject" value="<?php echo fl($subject); ?>" size="40" maxlength="200" /></td></tr> |
|---|
| 1021 | <tr><th>Texte du mail</th><td><textarea rows="16" cols="64" id="corps" name="corps"><?php echo fl($corps); ?></textarea></td></tr> |
|---|
| 1022 | <tr><td colspan="2"><input type="submit" value="Envoyer ce message par email à cette liste" /> |
|---|
| 1023 | </table> |
|---|
| 1024 | </form> |
|---|
| 1025 | |
|---|
| 1026 | <?php |
|---|
| 1027 | |
|---|
| 1028 | include("foot.php"); |
|---|
| 1029 | exit; |
|---|
| 1030 | } // mailing |
|---|
| 1031 | |
|---|
| 1032 | ?> |
|---|