Projet

Général

Profil

Evolution #2570 » bulletin_simple.inc.php

Martial LENZEN, 07/12/2010 19:07

 
1
<?php
2
/*
3
* $Id: bulletin_simple.inc.php 5028 2010-08-05 20:22:27Z crob $
4
*
5
* Copyright 2001, 2005 Thomas Belliard, Laurent Delineau, Edouard Hue, Eric Lebrun
6
*/
7
$delais_apres_cloture=getSettingValue('delais_apres_cloture');
8
//echo "\$delais_apres_cloture=$delais_apres_cloture<br />";
9

    
10
function acces_appreciations($periode1, $periode2, $id_classe) {
11
	global $delais_apres_cloture;
12

    
13
	if(($_SESSION['statut']=='eleve')||($_SESSION['statut']=='responsable')) {
14
		for($i=$periode1;$i<=$periode2;$i++) {
15
			$sql="SELECT * FROM matieres_appreciations_acces WHERE id_classe='$id_classe' AND
16
												statut='".$_SESSION['statut']."' AND
17
												periode='$i';";
18
			//echo "$sql<br />";
19
			$res=mysql_query($sql);
20
			if($res) {
21
				if(mysql_num_rows($res)>0) {
22
					$lig=mysql_fetch_object($res);
23
					//echo "\$lig->acces=$lig->acces<br />";
24
					if($lig->acces=="y") {
25
						$tab_acces_app[$i]="y";
26
					}
27
					elseif($lig->acces=="date") {
28
						//echo "<p>P?riode $i: Date limite: $lig->date<br />";
29
						$tab_date=explode("-",$lig->date);
30
						$timestamp_limite=mktime(0,0,0,$tab_date[1],$tab_date[2],$tab_date[0]);
31
						//echo "$timestamp_limite<br />";
32
						$timestamp_courant=time();
33
						//echo "$timestamp_courant<br />";
34

    
35
						if($timestamp_courant>$timestamp_limite){
36
							$tab_acces_app[$i]="y";
37
						}
38
						else {
39
							$tab_acces_app[$i]="n";
40
						}
41
					}
42
					elseif($lig->acces=="d") {
43
						$sql="SELECT verouiller,UNIX_TIMESTAMP(date_verrouillage) AS date_verrouillage FROM periodes WHERE id_classe='$id_classe' AND num_periode='$i';";
44
						//echo "$sql<br />";
45
						$res_dv=mysql_query($sql);
46

    
47
						if(mysql_num_rows($res_dv)>0) {
48
							$lig_dv=mysql_fetch_object($res_dv);
49

    
50
							if($lig_dv->verouiller!='O') {
51
								$tab_acces_app[$i]="n";
52
							}
53
							else {
54
								$timestamp_limite=$lig_dv->date_verrouillage+$delais_apres_cloture*24*3600;
55
								$timestamp_courant=time();
56
								//echo "\$timestamp_limite=$timestamp_limite<br />";
57
								//echo "\$timestamp_courant=$timestamp_courant<br />";
58

    
59
								if($timestamp_courant>$timestamp_limite){
60
									$tab_acces_app[$i]="y";
61
								}
62
								else {
63
									$tab_acces_app[$i]="n";
64
								}
65
								//echo "\$tab_acces_app[$i]=$tab_acces_app[$i]<br />";
66
							}
67
						}
68
						else {
69
							$tab_acces_app[$i]="n";
70
						}
71
					}
72
					else {
73
						$tab_acces_app[$i]="n";
74
					}
75
				}
76
				else {
77
					$tab_acces_app[$i]="n";
78
				}
79
			}
80
			else {
81
				$tab_acces_app[$i]="n";
82
			}
83
		}
84
	}
85
	else {
86
		// Pas de limitations d'acc?s pour les autres statuts.
87
		for($i=$periode1;$i<=$periode2;$i++) {
88
			$tab_acces_app[$i]="y";
89
		}
90
	}
91
	return $tab_acces_app;
92
} // function
93

    
94
//function bulletin($current_eleve_login,$compteur,$total,$periode1,$periode2,$nom_periode,$gepiYear,$id_classe,$affiche_rang,$test_coef,$affiche_categories) {
95
//function bulletin($current_eleve_login,$compteur,$total,$periode1,$periode2,$nom_periode,$gepiYear,$id_classe,$affiche_rang,$test_coef,$affiche_categories,$couleur_lignes=NULL) {
96
//function bulletin_bis($tab_moy,$current_eleve_login,$compteur,$total,$periode1,$periode2,$nom_periode,$gepiYear,$id_classe,$affiche_rang,$test_coef,$affiche_categories,$couleur_lignes=NULL) {
97
function bulletin($tab_moy,$current_eleve_login,$compteur,$total,$periode1,$periode2,$nom_periode,$gepiYear,$id_classe,$affiche_rang,$test_coef,$affiche_categories,$couleur_lignes=NULL) {
98
//global $nb_notes,$nombre_eleves,$type_etablissement,$type_etablissement2;
99
global $nb_notes,$type_etablissement,$type_etablissement2;
100

    
101
global $display_moy_gen;
102
global $affiche_coef;
103
global $bull_intitule_app;
104

    
105
global $affiche_deux_moy_gen;
106

    
107
$alt=1;
108

    
109
// donn?es requise :
110
//- le login de l'?l?ve    : $current_eleve_login
111
//- $compteur : compteur
112
//- $total : nombre total d'?l?ves
113
//- $periode1 : num?ro de la premi?re p?riode ? afficher
114
//- $periode2 : num?ro de la derni?re p?riode ? afficher
115
//- $nom_periode : tableau des noms de p?riode
116
//- $gepiYear : ann?e
117
//- $id_classe : identifiant de la classe.
118

    
119
//==========================================================
120
// AJOUT: boireaus 20080218
121
//        Dispositif de restriction des acc?s aux appr?ciations pour les comptes responsables/eleves
122
//echo "\$_SESSION['statut']=".$_SESSION['statut']."<br />";
123
//echo "\$periode1=$periode1<br />";
124
//echo "\$periode2=$periode2<br />";
125

    
126
unset($tab_acces_app);
127
$tab_acces_app=array();
128
$tab_acces_app = acces_appreciations($periode1, $periode2, $id_classe);
129
//==========================================================
130

    
131
$nb_periodes = $periode2 - $periode1 + 1;
132
$on_continue = "yes";
133
if ($nb_periodes == 1) {
134
	// S'il n'est demand? qu'une seule p?riode:
135
	// Test pour savoir si l'?l?ve appartient ? la classe pour la p?riode consid?r?e
136
	$test_eleve_app = sql_query1("select count(login) from j_eleves_classes where login='".$current_eleve_login."' and id_classe='".$id_classe."' and periode='".$periode1."'");
137
	if ($test_eleve_app == 0) {$on_continue = "no";}
138
}
139

    
140
if ($on_continue == 'yes') {
141

    
142
	// Mis hors de la fonction
143
	//$affiche_coef=sql_query1("SELECT display_coef FROM classes WHERE id='".$id_classe."'");
144

    
145
	//echo "\$affiche_categories=$affiche_categories<br />";
146
	$data_eleve = mysql_query("SELECT * FROM eleves WHERE login='$current_eleve_login'");
147
	$current_eleve_nom = mysql_result($data_eleve, 0, "nom");
148
	$current_eleve_prenom = mysql_result($data_eleve, 0, "prenom");
149
	$current_eleve_sexe = mysql_result($data_eleve, 0, "sexe");
150
	$current_eleve_naissance = mysql_result($data_eleve, 0, "naissance");
151
	$current_eleve_naissance = affiche_date_naissance($current_eleve_naissance);
152
	$current_eleve_elenoet = mysql_result($data_eleve, 0, "elenoet");
153
	$data_profsuivi = mysql_query("SELECT u.login FROM utilisateurs u, j_eleves_professeurs j WHERE (j.login='$current_eleve_login' AND j.professeur = u.login AND j.id_classe='$id_classe') ");
154
	$current_eleve_profsuivi_login = @mysql_result($data_profsuivi, 0, "login");
155
	
156
	//$data_etab = mysql_query("SELECT e.* FROM etablissements e, j_eleves_etablissements j WHERE (j.id_eleve ='$current_eleve_login' AND e.id = j.id_etablissement) ");
157
	$data_etab = mysql_query("SELECT e.* FROM etablissements e, j_eleves_etablissements j WHERE (j.id_eleve ='$current_eleve_elenoet' AND e.id = j.id_etablissement) ");
158
	$current_eleve_etab_id = @mysql_result($data_etab, 0, "id");
159
	$current_eleve_etab_nom = @mysql_result($data_etab, 0, "nom");
160
	$current_eleve_etab_niveau = @mysql_result($data_etab, 0, "niveau");
161
	$current_eleve_etab_type = @mysql_result($data_etab, 0, "type");
162
	$current_eleve_etab_cp = @mysql_result($data_etab, 0, "cp");
163
	$current_eleve_etab_ville = @mysql_result($data_etab, 0, "ville");
164
	
165
	if ($current_eleve_etab_niveau!='') {
166
		foreach ($type_etablissement as $type_etab => $nom_etablissement) {
167
			if ($current_eleve_etab_niveau == $type_etab) {$current_eleve_etab_niveau_nom = $nom_etablissement;}
168
	
169
		}
170
		if ($current_eleve_etab_cp == 0) {$current_eleve_etab_cp = '';}
171
		if ($current_eleve_etab_type == 'aucun')
172
			$current_eleve_etab_type = '';
173
		else
174
			$current_eleve_etab_type = $type_etablissement2[$current_eleve_etab_type][$current_eleve_etab_niveau];
175
	}
176
	$classe_eleve = mysql_query("SELECT * FROM classes WHERE id='$id_classe'");
177
	$current_eleve_classe = mysql_result($classe_eleve, 0, "classe");
178
	$id_classe = mysql_result($classe_eleve, 0, "id");
179
	
180
	$regime_doublant_eleve = mysql_query("SELECT * FROM j_eleves_regime WHERE login = '$current_eleve_login'");
181
	$current_eleve_regime = mysql_result($regime_doublant_eleve, 0, "regime");
182
	$current_eleve_doublant = mysql_result($regime_doublant_eleve, 0, "doublant");
183
	
184
	//-------------------------------
185
	// On affiche l'en-t?te : Les donn?es de l'?l?ve
186
	//-------------------------------
187
	echo "<span class='bull_simpl'><span class='bold'>$current_eleve_nom $current_eleve_prenom</span>";
188
	if ($current_eleve_sexe == "M") {
189
		echo ", n? le $current_eleve_naissance";
190
		} else {
191
		echo ", n?e le $current_eleve_naissance";
192
	}
193
	if ($current_eleve_regime == "d/p") {echo ",&nbsp;demi-pensionnaire";}
194
	if ($current_eleve_regime == "ext.") {echo ",&nbsp;externe";}
195
	if ($current_eleve_regime == "int.") {echo ",&nbsp;interne";}
196
	if ($current_eleve_regime == "i-e")
197
		if ($current_eleve_sexe == "M") echo ",&nbsp;interne&nbsp;extern?"; else echo ",&nbsp;interne&nbsp;extern?e";
198
	if ($current_eleve_doublant == 'R')
199
		if ($current_eleve_sexe == "M") echo ", <b>redoublant</b>"; else echo ", <b>redoublante</b>";
200
	echo "&nbsp;&nbsp;-&nbsp;&nbsp;Classe de $current_eleve_classe, ann?e scolaire $gepiYear<br />\n";
201
	
202
	if ($current_eleve_etab_nom != '') {
203
		echo "Etablissement d'origine : ";
204
		if ($current_eleve_etab_id != '990') {
205
			echo "$current_eleve_etab_niveau_nom $current_eleve_etab_type $current_eleve_etab_nom ($current_eleve_etab_cp $current_eleve_etab_ville)<br />\n";
206
		} else {
207
			echo "hors de France<br />\n";
208
		}
209
	}
210
	if ($periode1 < $periode2) {
211
		echo "R?sultats de : ";
212
		$nb = $periode1;
213
		while ($nb < $periode2+1) {
214
		echo $nom_periode[$nb];
215
		if ($nb < $periode2) echo " - ";
216
		$nb++;
217
		}
218
		echo ".</span>";
219
	} else {
220
		$temp = strtolower($nom_periode[$periode1]);
221
		echo "R?sultats du $temp.</span>";
222
	
223
	}
224
	//
225
	//-------------------------------
226
	// Fin de l'en-t?te
227
	
228
	// On initialise le tableau :
229
	
230
	$larg_tab = 680;
231
	$larg_col1 = 120;
232
	$larg_col2 = 38;
233
	$larg_col3 = 38;
234
	$larg_col4 = 20;
235
	$larg_col5 = $larg_tab - $larg_col1 - $larg_col2 - $larg_col3 - $larg_col4;
236
	//=========================
237
	// MODIF: boireaus 20080315
238
	//echo "<table width=$larg_tab border=1 cellspacing=1 cellpadding=1>\n";
239
	echo "<table width=$larg_tab class='boireaus' cellspacing='1' cellpadding='1' summary='Mati?res/Notes/Appr?ciations'>\n";
240
	//=========================
241
	echo "<tr><td width=\"$larg_col1\" class='bull_simpl'>$compteur";
242
	if ($total != '') {echo "/$total";}
243
	echo "</td>\n";
244
	
245
	//====================
246
	// Modif: boireaus 20070626
247
	if($affiche_coef=='y'){
248
		if ($test_coef != 0) echo "<td width=\"$larg_col2\" align=\"center\"><p class='bull_simpl'>Coef.</p></td>\n";
249
	}
250
	//====================
251
	
252
	echo "<td width=\"$larg_col2\" align=\"center\" class='bull_simpl'>Classe</td>\n";
253
	echo "<td width=\"$larg_col3\" align=\"center\" class='bull_simpl'>&Eacute;l?ve</td>\n";
254
	if ($affiche_rang=='y')
255
		echo "<td width=$larg_col4 align=\"center\" class='bull_simpl'><i>Rang</i></td>\n";
256
	echo "<td width=\"$larg_col5\" class='bull_simpl'>$bull_intitule_app</td></tr>\n";
257
	//echo "</table>";
258
	// On attaque maintenant l'affichage des appr?ciations des Activit?s Interdisciplinaires devant appara?tre en t?te des bulletins :
259
	$call_data = mysql_query("SELECT * FROM aid_config WHERE order_display1 = 'b' ORDER BY order_display2");
260
	$nb_aid = mysql_num_rows($call_data);
261
	$z=0;
262
	while ($z < $nb_aid) {
263
		$display_begin = mysql_result($call_data, $z, "display_begin");
264
		$display_end = mysql_result($call_data, $z, "display_end");
265
		if (($periode1 >= $display_begin) and ($periode2 <= $display_end)) {
266
			$indice_aid = @mysql_result($call_data, $z, "indice_aid");
267
			$aid_query = mysql_query("SELECT id_aid FROM j_aid_eleves WHERE (login='$current_eleve_login' and indice_aid='$indice_aid')");
268
			$aid_id = @mysql_result($aid_query, 0, "id_aid");
269
			if ($aid_id != '') {
270
				affiche_aid_simple($affiche_rang, $test_coef,$indice_aid,$aid_id,$current_eleve_login,$periode1,$periode2,$id_classe, 'bull_simpl', $affiche_coef);
271
			}
272
		}
273
		$z++;
274
	}
275
	//------------------------------
276
	// Boucle 'groupes'
277
	//------------------------------
278

    
279
/*
280
	if ($affiche_categories) {
281
		// On utilise les valeurs sp?cifi?es pour la classe en question
282
		$appel_liste_groupes = mysql_query("SELECT DISTINCT jgc.id_groupe ".
283
		"FROM j_eleves_groupes jeg, j_groupes_classes jgc, j_groupes_matieres jgm, j_matieres_categories_classes jmcc, matieres m " .
284
		"WHERE ( " .
285
		"jeg.login = '" . $current_eleve_login ."' AND " .
286
		"jgc.id_groupe = jeg.id_groupe AND " .
287
		"jgc.categorie_id = jmcc.categorie_id AND " .
288
		"jgc.id_classe = '".$id_classe."' AND " .
289
		"jgm.id_groupe = jgc.id_groupe AND " .
290
		"m.matiere = jgm.id_matiere" .
291
		") " .
292
		"ORDER BY jmcc.priority,jgc.priorite,m.nom_complet");
293
	} else {
294
		$appel_liste_groupes = mysql_query("SELECT DISTINCT jgc.id_groupe, jgc.coef " .
295
		"FROM j_groupes_classes jgc, j_groupes_matieres jgm, j_eleves_groupes jeg " .
296
		"WHERE ( " .
297
		"jeg.login = '" . $current_eleve_login . "' AND " .
298
		"jgc.id_groupe = jeg.id_groupe AND " .
299
		"jgc.id_classe = '".$id_classe."' AND " .
300
		"jgm.id_groupe = jgc.id_groupe" .
301
		") " .
302
		"ORDER BY jgc.priorite,jgm.id_matiere");
303
	}
304
	
305
	// La ligne suivante a ?t? remplac?e par les requ?tes int?grant le classement par cat?gories de mati?res
306
	// $appel_liste_groupes = mysql_query("SELECT DISTINCT jeg.id_groupe id_groupe FROM j_eleves_groupes jeg, j_groupes_classes jgc WHERE (jeg.login = '" . $current_eleve_login . "' AND jeg.id_groupe = jgc.id_groupe AND jgc.id_classe = '" . $id_classe . "') ORDER BY jgc.priorite");
307
	$nombre_groupes = mysql_num_rows($appel_liste_groupes);
308

    
309
	$get_cat = mysql_query("SELECT id FROM matieres_categories");
310
	$categories = array();
311
	while ($row = mysql_fetch_array($get_cat, MYSQL_ASSOC)) {
312
		$categories[] = $row["id"];
313
	}
314
	
315
	$cat_names = array();
316
	foreach ($categories as $cat_id) {
317
		$cat_names[$cat_id] = html_entity_decode_all_version(mysql_result(mysql_query("SELECT nom_complet FROM matieres_categories WHERE id = '" . $cat_id . "'"), 0));
318
	}
319
	
320
	$total_cat_eleve = array();
321
	$total_cat_classe = array();
322
	
323
	//===========================
324
	// MODIF: boireaus 20070627
325
	//$total_cat_coef = array();
326
	$total_cat_coef_eleve = array();
327
	$total_cat_coef_classe = array();
328
	//===========================
329
	
330
	//===========================
331
	// AJOUT: boireaus 20070627
332
	$total_coef_eleve=array();
333
	$total_coef_classe=array();
334
	//===========================
335
	
336
	$nb=$periode1;
337
	while ($nb < $periode2+1) {
338
		$total_points_classe[$nb] = 0;
339
		$total_points_eleve[$nb] = 0;
340
	
341
		//===========================
342
		// MODIF: boireaus 20070627
343
		//$total_coef[$nb] = 0;
344
		$total_coef_eleve[$nb] = 0;
345
		$total_coef_classe[$nb] = 0;
346
		//===========================
347
	
348
		$total_cat_eleve[$nb] = array();
349
		$total_cat_classe[$nb] = array();
350
		$total_cat_coef[$nb] = array();
351
		foreach($categories as $cat_id) {
352
			$total_cat_eleve[$nb][$cat_id] = 0;
353
			$total_cat_classe[$nb][$cat_id] = 0;
354
	
355
			//===========================
356
			// MODIF: boireaus 20070627
357
			//$total_cat_coef[$nb][$cat_id] = 0;
358
			$total_cat_coef_eleve[$nb][$cat_id] = 0;
359
			$total_cat_coef_classe[$nb][$cat_id] = 0;
360
			//===========================
361
		}
362
		$nb++;
363
	}
364

    
365
*/
366

    
367
	// R?cup?ration des noms de catgories
368
	$get_cat = mysql_query("SELECT id FROM matieres_categories");
369
	$categories = array();
370
	while ($row = mysql_fetch_array($get_cat, MYSQL_ASSOC)) {
371
		$categories[] = $row["id"];
372
	}
373
	
374
	$cat_names = array();
375
	foreach ($categories as $cat_id) {
376
		$cat_names[$cat_id] = html_entity_decode_all_version(mysql_result(mysql_query("SELECT nom_complet FROM matieres_categories WHERE id = '" . $cat_id . "'"), 0));
377
	}
378

    
379
	// Nombre de groupes sur la classe
380
	$nombre_groupes=count($tab_moy['current_group']);
381

    
382
	// R?cup?ration des indices de l'?l?ve $current_eleve_login dans $tab_moy
383
	unset($tab_login_indice);
384
	$nb=$periode1;
385
	while ($nb < $periode2+1) {
386
		//$tab_login_indice[$nb]=$tab_moy['periodes'][$nb]['tab_login_indice'][$current_eleve_login];
387
		// Un ?l?ve qui arrive ou part en cours d'ann?e ne sera pas dans la classe ni dans les groupes sur certaines p?riodes
388
		//if(isset($tab_moy['periodes'][$nb]['tab_login_indice'][$current_eleve_login])) {
389
		if(isset($tab_moy['periodes'][$nb]['tab_login_indice'][strtoupper($current_eleve_login)])) {
390
			//$tab_login_indice[$nb]=$tab_moy['periodes'][$nb]['tab_login_indice'][$current_eleve_login];
391
			$tab_login_indice[$nb]=$tab_moy['periodes'][$nb]['tab_login_indice'][strtoupper($current_eleve_login)];
392
			//echo "\$tab_login_indice[$nb]=$tab_login_indice[$nb]<br />";
393
		}
394
		/*
395
		else {
396
			echo "\$tab_moy['periodes'][$nb]['tab_login_indice'][$current_eleve_login] n'est pas affect?.<br />";
397
		}
398
		*/
399
		$nb++;
400
	}
401

    
402
	//$j = 0;
403

    
404
	$prev_cat_id = null;
405

    
406
	//while ($j < $nombre_groupes) {
407
	for($j=0;$j<$nombre_groupes;$j++) {
408

    
409
			//echo "<table width=$larg_tab border=1 cellspacing=0 cellpadding=1 style='margin-bottom: 0px; border-bottom: 1px solid black; border-top: none;'>";
410
	
411
		$inser_ligne='no';
412

    
413
		//$group_id = mysql_result($appel_liste_groupes, $j, "id_groupe");
414
		//$current_group = get_group($group_id);
415

    
416
		// On r?cup?re le groupe depuis $tab_moy
417
		$current_group=$tab_moy['current_group'][$j];
418
		//echo "<p>Groupe n?$j: ".$current_group['name']."<br />\n";
419

    
420
		// Coefficient pour le groupe
421
		$current_coef=$current_group["classes"]["classes"][$id_classe]["coef"];
422
	
423
		// Pour les enseignements ? bonus,...
424
		$mode_moy=$current_group["classes"]["classes"][$id_classe]["mode_moy"];
425
	
426
		$current_matiere_professeur_login = $current_group["profs"]["list"];
427
	
428
		$current_matiere_nom_complet = $current_group["matiere"]["nom_complet"];
429

    
430

    
431
		$nb=$periode1;
432
		while ($nb < $periode2+1) {
433
			/*
434
			$current_classe_matiere_moyenne_query = mysql_query("SELECT round(avg(note),1) moyenne FROM matieres_notes WHERE (statut ='' AND id_groupe='" . $current_group["id"] . "' AND periode='$nb')");
435
			$current_classe_matiere_moyenne[$nb] = mysql_result($current_classe_matiere_moyenne_query, 0, "moyenne");
436
			*/
437
			$current_classe_matiere_moyenne[$nb]=$tab_moy['periodes'][$nb]['current_classe_matiere_moyenne'][$j];
438

    
439
			// On teste si des notes de une ou plusieurs boites du carnet de notes doivent ?tre affich?e
440
			$test_cn = mysql_query("select c.nom_court, c.id from cn_cahier_notes cn, cn_conteneurs c
441
			where (cn.periode = '$nb' and cn.id_groupe='".$current_group["id"]."' and cn.id_cahier_notes = c.id_racine and c.id_racine!=c.id and c.display_bulletin = 1) ");
442
			$nb_ligne_cn[$nb] = mysql_num_rows($test_cn);
443
			$n = 0;
444
			while ($n < $nb_ligne_cn[$nb]) {
445
				$cn_id[$nb][$n] = mysql_result($test_cn, $n, 'c.id');
446
				$cn_nom[$nb][$n] = mysql_result($test_cn, $n, 'c.nom_court');
447
				$n++;
448
			}
449
			$nb++;
450
	
451
		}
452
	
453
	
454
	
455
		// Maintenant on regarde si l'?l?ve suit bien cette mati?re ou pas
456
		//-----------------------------
457
		$nb=$periode1;
458
		while ($nb < $periode2+1) {
459
			// Test suppl?mentaire pour savoir si l'?l?ve appartient ? la classe pour la p?riode consid?r?e
460
			$test_eleve_app = sql_query1("select count(login) from j_eleves_classes where login='".$current_eleve_login."' and id_classe='".$id_classe."' and periode='".$nb."'");
461
			if (((in_array(strtolower($current_eleve_login), $current_group["eleves"][$nb]["list"])) or
462
			(in_array(strtoupper($current_eleve_login), $current_group["eleves"][$nb]["list"]))) and $test_eleve_app !=0)
463
			{
464
				$inser_ligne='yes';
465
				/*
466
				$current_eleve_note_query = mysql_query("SELECT * FROM matieres_notes mn, j_eleves_classes jec WHERE (mn.login='$current_eleve_login' AND mn.periode='$nb' AND mn.id_groupe='".$current_group["id"]."' and jec.periode='$nb' and jec.login='$current_eleve_login' and jec.id_classe='$id_classe')");
467
				*/
468
				$current_eleve_note[$nb]=$tab_moy['periodes'][$nb]['current_eleve_note'][$j][$tab_login_indice[$nb]];
469
				$current_eleve_statut[$nb]=$tab_moy['periodes'][$nb]['current_eleve_statut'][$j][$tab_login_indice[$nb]];
470

    
471
				$current_eleve_appreciation_query = mysql_query("SELECT * FROM matieres_appreciations ma, j_eleves_classes jec WHERE (ma.login='$current_eleve_login' AND ma.id_groupe='" . $current_group["id"] . "' AND ma.periode='$nb' and jec.periode='$nb' and jec.login='$current_eleve_login' and jec.id_classe='$id_classe')");
472
				$current_eleve_appreciation[$nb] = @mysql_result($current_eleve_appreciation_query, 0, "appreciation");
473

    
474
				/*
475
				// Coefficient personnalis? pour l'?l?ve?
476
				$sql="SELECT value FROM eleves_groupes_settings WHERE (" .
477
						"login = '".$current_eleve_login."' AND " .
478
						"id_groupe = '".$group_id."' AND " .
479
						"name = 'coef')";
480
				$test_coef_personnalise = mysql_query($sql);
481
				if (mysql_num_rows($test_coef_personnalise) > 0) {
482
					$coef_eleve = mysql_result($test_coef_personnalise, 0);
483
				} else {
484
					// Coefficient du groupe:
485
					$coef_eleve = $current_coef;
486
				}
487
				//=========================
488
				// MODIF: boireaus 20071217 On arrondira seulement ? l'affichage
489
				//$coef_eleve=number_format($coef_eleve,1, ',', ' ');
490
				//=========================
491
				*/
492
				$coef_eleve=$tab_moy['periodes'][$nb]['current_coef_eleve'][$tab_login_indice[$nb]][$j];
493

    
494
				//echo "\$coef_eleve=\$tab_moy['periodes'][$nb]['current_coef_eleve'][".$tab_login_indice[$nb]."][$j]=".$coef_eleve."<br />\n";
495

    
496
			} else {
497
				$current_eleve_note[$nb] = '';
498
				$current_eleve_statut[$nb] = 'Non suivie';
499
				$current_eleve_appreciation[$nb] = '';
500
			}
501
	
502

    
503
			//++++++++++++++++++++++++
504
			// Modif d'apr?s F.Boisson
505
			// notes dans appreciation
506
			$sql="SELECT cnd.note, cd.note_sur FROM cn_notes_devoirs cnd, cn_devoirs cd, cn_cahier_notes ccn WHERE cnd.login='".$current_eleve_login."' AND cnd.id_devoir=cd.id AND cd.id_racine=ccn.id_cahier_notes AND ccn.id_groupe='".$current_group["id"]."' AND ccn.periode='$nb' AND cnd.statut='';";
507
			$result_nbct=mysql_query($sql);
508
			$string_notes='';
509
			if ($result_nbct ) {
510
				while ($snnote =  mysql_fetch_assoc($result_nbct)) {
511
					if ($string_notes != '') $string_notes .= ", ";
512
					$string_notes .= $snnote['note'];
513
					if(getSettingValue("note_autre_que_sur_referentiel")=="V" || $snnote['note_sur']!=getSettingValue("referentiel_note")) {
514
						$string_notes .= "/".$snnote['note_sur'];
515
					}
516
				}
517
			}
518
			$current_eleve_appreciation[$nb] = str_replace('@@Notes', $string_notes,$current_eleve_appreciation[$nb]);
519
			//++++++++++++++++++++++++
520
		
521
	
522
			$nb++;
523
		}
524

    
525

    
526

    
527

    
528
		if ($inser_ligne == 'yes') {
529
			if ($affiche_categories) {
530
			// On regarde si on change de cat?gorie de mati?re
531
				if ($current_group["classes"]["classes"][$id_classe]["categorie_id"] != $prev_cat_id) {
532
					$prev_cat_id = $current_group["classes"]["classes"][$id_classe]["categorie_id"];
533
					// On est dans une nouvelle cat?gorie
534
					// On r?cup?re les infos n?cessaires, et on affiche une ligne
535
	
536
					// On d?termine le nombre de colonnes pour le colspan
537
					$nb_total_cols = 4;
538
					//====================
539
					// Modif: boireaus 20070626
540
					if($affiche_coef=='y'){
541
						if ($test_coef != 0) {$nb_total_cols++;}
542
					}
543
					//====================
544
					if ($affiche_rang == 'y') {$nb_total_cols++;}
545
	
546
					// On regarde s'il faut afficher la moyenne de l'?l?ve pour cette cat?gorie
547
					$affiche_cat_moyenne_query = mysql_query("SELECT affiche_moyenne FROM j_matieres_categories_classes WHERE (classe_id = '" . $id_classe . "' and categorie_id = '" . $prev_cat_id . "')");
548
					if (mysql_num_rows($affiche_cat_moyenne_query) == "0") {
549
						$affiche_cat_moyenne = false;
550
					} else {
551
						$affiche_cat_moyenne = mysql_result($affiche_cat_moyenne_query, 0);
552
					}
553
	
554
					// On a toutes les infos. On affiche !
555
					echo "<tr>\n";
556
					echo "<td colspan='" . $nb_total_cols . "'>\n";
557
					echo "<p style='padding: 0; margin:0; font-size: 10px; text-align:left;'>".$cat_names[$prev_cat_id]."</p></td>\n";
558
					echo "</tr>\n";
559
				}
560
			}
561
			if($couleur_lignes=='y') {
562
				$alt=$alt*(-1);
563
				echo "<tr class='lig$alt'>\n";
564
				$alt2=$alt;
565
			}
566
			else {
567
				echo "<tr>\n";
568
			}
569
			echo "<td ";
570
			if ($nb_periodes > 1) echo " rowspan= ".$nb_periodes;
571
			//echo" width=\"$larg_col1\" class='bull_simpl'><b>$current_matiere_nom_complet</b>";
572
			echo " width=\"$larg_col1\" class='bull_simpl'><b>".htmlentities($current_matiere_nom_complet)."</b>";
573
			$k = 0;
574
			//echo "(".$current_group['id'].")";
575
			while ($k < count($current_matiere_professeur_login)) {
576
				echo "<br /><i>".affiche_utilisateur($current_matiere_professeur_login[$k],$id_classe)."</i>";
577
				$k++;
578
			}
579
			echo "</td>\n";
580
	
581
			//====================
582
			// Modif: boireaus 20070626
583
			if($affiche_coef=='y'){
584
				if ($test_coef != 0) {
585
					//if ($current_coef > 0) $print_coef= $current_coef ; else $print_coef='-';
586
					//if ($coef_eleve > 0) $print_coef= $coef_eleve; else $print_coef='-';
587
					if ($coef_eleve > 0) {$print_coef= number_format($coef_eleve,1, ',', ' ');} else {$print_coef='-';}
588
					echo "<td width=\"$larg_col2\"";
589
					if ($nb_periodes > 1) echo " rowspan= ".$nb_periodes;
590
					echo " align=\"center\"><p class='bull_simpl'>".$print_coef."</p></td>\n";
591
				}
592
			}
593
			//====================
594
	
595
			$nb=$periode1;
596
			$print_tr = 'no';
597
			while ($nb < $periode2+1) {
598
				if ($print_tr == 'yes') {
599
					//echo "<tr style='border-width: 5px;'>\n";
600
					if($couleur_lignes=='y') {
601
						$alt2=$alt2*(-1);
602
						echo "<tr class='lig$alt2' style='border-width: 5px;'>\n";
603
					}
604
					else {
605
						echo "<tr>\n";
606
					}
607
				}
608
				//=========================
609
				// MODIF: boireaus 20080315
610
				//echo "<td width=\"$larg_col2\" align=\"center\" class='bull_simpl'>\n";
611
				//if($nb>$periode1) {$style_bordure_cell="border: 1px dashed black;";} else {$style_bordure_cell="";}
612
				//$style_bordure_cell="border: 1px dashed black;";
613
				if($nb==$periode1) {
614
					if($nb==$periode2) {
615
						$style_bordure_cell="border: 1px solid black";
616
					}
617
					else {
618
						$style_bordure_cell="border: 1px solid black; border-bottom: 1px dashed black";
619
					}
620
				}
621
				elseif($nb==$periode2) {
622
					$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black;";
623
				}
624
				else {
625
					$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black; border-bottom: 1px dashed black;";
626
				}
627
				echo "<td width=\"$larg_col2\" align=\"center\" class='bull_simpl' style='$style_bordure_cell'>\n";
628
				//=========================
629
				//echo "\$nb=$nb<br />";
630
				$note=number_format($current_classe_matiere_moyenne[$nb],1, ',', ' ');
631
				if ($note != "0,0")  {echo $note;} else {echo "-";}
632
				echo "</td>\n";
633
				echo "<td width=\"$larg_col3\" align=\"center\" class='bull_simpl' style='$style_bordure_cell'>\n<b>";
634
				$flag_moy[$nb] = 'no';
635
				if ($current_eleve_note[$nb] != '') {
636
					if ($current_eleve_statut[$nb] != '') {
637
						echo $current_eleve_statut[$nb];
638
					} else {
639
						//$note=number_format($current_eleve_note[$nb],1, ',', ' ');
640
						$note=nf($current_eleve_note[$nb]);
641
						echo "$note";
642
						$flag_moy[$nb] = 'yes';
643
					}
644
				} else {
645
					echo '-';
646
				}
647
				echo "</b></td>\n";
648

    
649
				//Affichage des cellules rang le cas ?ch?ant
650
				if ($affiche_rang == 'y')  {
651
					/*
652
					$rang = sql_query1("select rang from matieres_notes where (
653
					periode = '".$nb."' and
654
					id_groupe = '".$current_group["id"]."' and
655
					login = '".$current_eleve_login."' )
656
					");
657
					if (($rang == 0) or ($rang == -1)){
658
						$rang = "-";
659
					}
660
					else{
661
						//$rang.="/".$nb_notes[$current_group["id"]][$nb];
662
						//if(isset($nb_notes[$current_group["id"]][$nb])){
663
							$rang.="/".$nb_notes[$current_group["id"]][$nb];
664
						//}
665
						//$rang.="<br />\$nb_notes[".$current_group["id"]."][$nb]";
666
					}
667
					*/
668

    
669
					$rang="-";
670
					if(isset($tab_login_indice[$nb])) {
671
						if(isset($tab_moy['periodes'][$nb]['current_eleve_rang'][$j][$tab_login_indice[$nb]])) {
672
							// Si l'?l?ve n'est dans le groupe que sur une p?riode (cas des IDD), son rang n'existera pas sur certaines p?riodes
673
							//echo "\$tab_moy['periodes'][$nb]['current_eleve_rang'][$j][".$tab_login_indice[$nb]."]=";
674
							$rang=$tab_moy['periodes'][$nb]['current_eleve_rang'][$j][$tab_login_indice[$nb]];
675
							//echo "$rang<br />";
676
						}
677
					}
678
					$eff_grp_avec_note=$tab_moy['periodes'][$nb]['current_group_effectif_avec_note'][$j];
679
					if(($rang!=0)&&($rang!=-1)&&($rang!='')&&($rang!='-')){
680
						$rang.="/$eff_grp_avec_note";
681
					}
682

    
683
					echo "<td width=\"$larg_col4\" align=\"center\" class='bull_simpl' style='$style_bordure_cell'><i>".$rang."</i></td>\n";
684
				}
685

    
686
				// Affichage des cases appr?ciations
687
				echo "<td width=\"$larg_col5\" class='bull_simpl' style='$style_bordure_cell; text-align:left;'>\n";
688
				// Affichage des moyennes secondaires
689
				if ($nb_ligne_cn[$nb] != 0) {
690
					$tiret = 'no';
691
					for ($cn=0; $cn<$nb_ligne_cn[$nb]; $cn++) {
692
						$appel_cn = mysql_query("select note, statut from cn_notes_conteneurs where (login='$current_eleve_login' and id_conteneur='".$cn_id[$nb][$cn]."')");
693
						$cn_statut = @mysql_result($appel_cn,0,'statut');
694
						if ($cn_statut == 'y') {
695
							$cn_note = @mysql_result($appel_cn,0,'note');
696
							if ($tiret == 'yes')   echo " - ";
697
							echo $cn_nom[$nb][$cn]."&nbsp;:&nbsp;".$cn_note;
698
							$tiret = 'yes';
699
						}
700
					}
701
					echo "<br />\n";
702
				}
703
				//==========================================================
704
				// MODIF: boireaus 20080218
705
				//        Dispositif de restriction des acc?s aux appr?ciations pour les comptes responsables/eleves
706
				//if ($current_eleve_appreciation[$nb]) {
707
				if (($current_eleve_appreciation[$nb])&&($tab_acces_app[$nb]=="y")) {
708
				//==========================================================
709
					//======================================
710
					// MODIF: boireaus
711
					//echo $current_eleve_appreciation[$nb];
712
					if ($current_eleve_appreciation[$nb]=="-1") {
713
						echo "<span class='noprint'>-</span>\n";
714
					}
715
					else{
716
						if((strstr($current_eleve_appreciation[$nb],">"))||(strstr($current_eleve_appreciation[$nb],"<"))){
717
							echo "$current_eleve_appreciation[$nb]";
718
						}
719
						else{
720
							echo nl2br($current_eleve_appreciation[$nb]);
721
						}
722
					}
723
					//======================================
724
				} else {
725
					echo " -";
726
				}
727
				echo "</td></tr>\n";
728
				$print_tr = 'yes';
729
				$nb++;
730
			}
731

    
732
			/*
733
			// On calcule les moyennes g?n?rales de l'?l?ve et de la classe :
734
			if ($test_coef != 0) {
735
				$nb=$periode1;
736
				while ($nb < $periode2+1) {
737
					if ($flag_moy[$nb] == 'yes') {
738
		
739
						//===========================
740
						// MODIF: boireaus 20070627
741
						//$total_coef[$nb] += $current_coef;
742
						//$total_points_classe[$nb] += $current_coef*$current_classe_matiere_moyenne[$nb];
743
						//$total_points_eleve[$nb] += $current_coef*$current_eleve_note[$nb];
744
		
745
						if($mode_moy=='-') {
746
							$total_coef_eleve[$nb] += $coef_eleve;
747
							$total_points_eleve[$nb] += $coef_eleve*$current_eleve_note[$nb];
748
		
749
							$total_coef_classe[$nb] += $current_coef;
750
							$total_points_classe[$nb] += $current_coef*$current_classe_matiere_moyenne[$nb];
751
						}
752
						elseif($mode_moy=='sup10') {
753
							if($current_eleve_note[$nb]>10) {
754
								$total_points_eleve[$nb] += $coef_eleve*($current_eleve_note[$nb]-10);
755
							}
756
		
757
							if($current_classe_matiere_moyenne[$nb]>0) {
758
								$total_points_classe[$nb] += $current_coef*($current_classe_matiere_moyenne[$nb]-10);
759
							}
760
						}
761
						else {
762
							echo "<p>ANOMALIE&nbsp;: \$mode_moy='$mode_moy' mode inconnu pour ".$current_group['name']."</p>\n";
763
						}
764
		
765
						//===========================
766
		
767
						//if($affiche_categories=='1'){
768
						if(($affiche_categories=='1')||($affiche_categories==true)){
769
							$total_cat_classe[$nb][$prev_cat_id] += $current_coef*$current_classe_matiere_moyenne[$nb];
770
		
771
							//===========================
772
							// MODIF: boireaus 20070627
773
							//$total_cat_eleve[$nb][$prev_cat_id] += $current_coef*$current_eleve_note[$nb];
774
							$total_cat_eleve[$nb][$prev_cat_id] += $coef_eleve*$current_eleve_note[$nb];
775
							//$total_cat_coef[$nb][$prev_cat_id] += $current_coef;
776
							$total_cat_coef_eleve[$nb][$prev_cat_id] += $coef_eleve;
777
							$total_cat_coef_classe[$nb][$prev_cat_id] += $current_coef;
778
							//===========================
779
						}
780
					}
781
					$nb++;
782
				}
783
			}
784
			*/
785
		}
786
		//$j++;
787
	//  echo "</table>";
788
	}
789

    
790
	//echo "<table width=$larg_tab border=1 cellspacing=1 cellpadding=1>";
791
	// On attaque maintenant l'affichage des appr?ciations des Activit?s Interdisciplinaires devant appara?tre en fin de bulletin :
792
	$call_data = mysql_query("SELECT * FROM aid_config WHERE order_display1 = 'e' ORDER BY order_display2");
793
	$nb_aid = mysql_num_rows($call_data);
794
	$z=0;
795
	while ($z < $nb_aid) {
796
		$display_begin = mysql_result($call_data, $z, "display_begin");
797
		$display_end = mysql_result($call_data, $z, "display_end");
798
		if (($periode1 >= $display_begin) and ($periode2 <= $display_end)) {
799
			$indice_aid = @mysql_result($call_data, $z, "indice_aid");
800
			$aid_query = mysql_query("SELECT id_aid FROM j_aid_eleves WHERE (login='$current_eleve_login' and indice_aid='$indice_aid')");
801
			$aid_id = @mysql_result($aid_query, 0, "id_aid");
802
			if ($aid_id != '') {
803
				affiche_aid_simple($affiche_rang, $test_coef,$indice_aid,$aid_id,$current_eleve_login,$periode1,$periode2,$id_classe, 'bull_simpl', $affiche_coef);
804
			}
805
		}
806
		$z++;
807
	}
808
	//echo "</table>";
809
	
810
	//echo "<table width=$larg_tab border=1 cellspacing=1 cellpadding=1>";
811

    
812
	//====================================================================
813
	//====================================================================
814
	//====================================================================
815

    
816
	// Affichage des moyennes g?n?rales
817
	if($display_moy_gen=="y") {
818
		if ($test_coef != 0) {
819
			echo "<tr>\n<td";
820
			if ($nb_periodes > 1) echo " rowspan=".$nb_periodes;
821
			echo ">\n<p class='bull_simpl'><b>Moyenne g?n?rale</b></p>\n</td>\n";
822
			//====================
823
			// Modif: boireaus 20070626
824
			if($affiche_coef=='y'){
825
				echo "<td";
826
				if ($nb_periodes > 1) echo " rowspan=".$nb_periodes;
827
				echo " align=\"center\" style='$style_bordure_cell'>-</td>\n";
828
			}
829
			//====================
830
	
831
			$nb=$periode1;
832
			$print_tr = 'no';
833
			while ($nb < $periode2+1) {
834
				//=============================
835
				//if($nb==$periode1){echo "<tr>\n";}
836
				if($print_tr=='yes'){echo "<tr style='border-width: 5px;'>\n";}
837
				//=============================
838
	
839
				//=========================
840
				// AJOUT: boireaus 20080315
841
				if($nb==$periode1) {
842
					if($nb==$periode2) {
843
						$style_bordure_cell="border: 1px solid black";
844
					}
845
					else {
846
						$style_bordure_cell="border: 1px solid black; border-bottom: 1px dashed black";
847
					}
848
				}
849
				elseif($nb==$periode2) {
850
					$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black;";
851
				}
852
				else {
853
					$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black; border-bottom: 1px dashed black;";
854
				}
855
				//=========================
856
	
857
				echo "<td class='bull_simpl' align=\"center\" style='$style_bordure_cell'>\n";
858
				/*
859
				//echo "\$total_points_classe[$nb]=$total_points_classe[$nb]<br />\n";
860
				//echo "\$tab_moy_gen[$nb]=$tab_moy_gen[$nb]<br />\n";
861
				//if ($total_points_classe[$nb] != 0) {
862
				if(($total_points_classe[$nb]!=0)||(isset($tab_moy_gen[$nb]))) {
863
					//$moy_classe=number_format($total_points_classe[$nb]/$total_coef[$nb],1, ',', ' ');
864
	
865
					//=========================
866
					// MODIF: boireaus 20080316
867
					//$moy_classe=number_format($total_points_classe[$nb]/$total_coef_classe[$nb],1, ',', ' ');
868
					//$moy_classe=number_format($tab_moy_gen[$nb],1, ',', ' ');
869
					$moy_classe=$tab_moy_gen[$nb];
870
					//=========================
871
				} else {
872
					$moy_classe = '-';
873
				}
874
				//echo "$moy_classe";
875
				echo nf($moy_classe);
876
				*/
877

    
878
				echo nf($tab_moy['periodes'][$nb]['moy_generale_classe'],2);
879
				if ($affiche_deux_moy_gen==1) {
880
					echo "<br />\n";
881
					$moy_classe1=$tab_moy['periodes'][$nb]['moy_generale_classe1'];
882
					echo "<i>".nf($moy_classe1,2)."</i>\n";
883
				}
884
				echo "</td>\n";
885

    
886
				echo "<td class='bull_simpl' align=\"center\" style='$style_bordure_cell'>\n";
887
				/*
888
				if ($total_points_eleve[$nb] != '0') {
889
					//$moy_eleve=number_format($total_points_eleve[$nb]/$total_coef[$nb],1, ',', ' ');
890
					$moy_eleve=number_format($total_points_eleve[$nb]/$total_coef_eleve[$nb],1, ',', ' ');
891
				} else {
892
					$moy_eleve = '-';
893
				}
894
				*/
895
				if(isset($tab_login_indice[$nb])) {
896
					$moy_eleve=$tab_moy['periodes'][$nb]['moy_gen_eleve'][$tab_login_indice[$nb]];
897
					echo "<b>".nf($moy_eleve,2)."</b>\n";
898

    
899
					if ($affiche_deux_moy_gen==1) {
900
						echo "<br />\n";
901
						$moy_eleve1=$tab_moy['periodes'][$nb]['moy_gen_eleve1'][$tab_login_indice[$nb]];
902
						echo "<i><b>".nf($moy_eleve1,2)."</b></i>\n";
903
					}
904
				}
905
				else {
906
					echo "-\n";
907
				}
908
				echo "</td>\n";
909

    
910
				if ($affiche_rang == 'y')  {
911
					$rang = sql_query1("select rang from j_eleves_classes where (
912
					periode = '".$nb."' and
913
					id_classe = '".$id_classe."' and
914
					login = '".$current_eleve_login."' )
915
					");
916

    
917
					$nombre_eleves=count($tab_moy['periodes'][$nb]['current_eleve_login']);
918
					if (($rang == 0) or ($rang == -1)) {$rang = "-";} else  {$rang .="/".$nombre_eleves;}
919
						echo "<td class='bull_simpl' align=\"center\" style='$style_bordure_cell'>".$rang."</td>\n";
920
				}
921

    
922
				if ($affiche_categories) {
923
					echo "<td class='bull_simpl' style='$style_bordure_cell; text-align:left;'>\n";
924
					foreach($categories as $cat_id) {
925

    
926
						// MODIF: boireaus 20070627 ajout du test et utilisation de $total_cat_coef_eleve, $total_cat_coef_classe
927
						// Tester si cette cat?gorie doit avoir sa moyenne affich?e
928
						$affiche_cat_moyenne_query = mysql_query("SELECT affiche_moyenne FROM j_matieres_categories_classes WHERE (classe_id = '".$id_classe."' and categorie_id = '".$cat_id."')");
929
						if (mysql_num_rows($affiche_cat_moyenne_query) == "0") {
930
							$affiche_cat_moyenne = false;
931
						} else {
932
							$affiche_cat_moyenne = mysql_result($affiche_cat_moyenne_query, 0);
933
						}
934
	
935
						if($affiche_cat_moyenne){
936
							/*
937
							//if ($total_cat_coef[$nb][$cat_id] != "0") {
938
							if ($total_cat_coef_eleve[$nb][$cat_id] != "0") {
939
								//$moy_eleve=number_format($total_cat_eleve[$nb][$cat_id]/$total_cat_coef[$nb][$cat_id],1, ',', ' ');
940
								//$moy_classe=number_format($total_cat_classe[$nb][$cat_id]/$total_cat_coef[$nb][$cat_id],1, ',', ' ');
941
								$moy_eleve=number_format($total_cat_eleve[$nb][$cat_id]/$total_cat_coef_eleve[$nb][$cat_id],1, ',', ' ');
942
	
943
								if ($total_cat_coef_classe[$nb][$cat_id] != "0") {
944
									$moy_classe=number_format($total_cat_classe[$nb][$cat_id]/$total_cat_coef_classe[$nb][$cat_id],1, ',', ' ');
945
								}
946
								else{
947
									$moy_classe="-";
948
								}
949
	
950
								echo $cat_names[$cat_id] . " - <b>".$moy_eleve."</b> (classe : " . $moy_classe . ")<br/>\n";
951
							}
952
							*/
953

    
954
							// Si l'?l?ve est bien dans la classe sur la p?riode $nb
955
							if(isset($tab_login_indice[$nb])) {
956
								$moy_eleve=$tab_moy['periodes'][$nb]['moy_cat_eleve'][$tab_login_indice[$nb]][$cat_id];
957
								$moy_classe=$tab_moy['periodes'][$nb]['moy_cat_classe'][$tab_login_indice[$nb]][$cat_id];
958
	
959
								echo $cat_names[$cat_id] . " - <b>".nf($moy_eleve,2)."</b> (classe : " . nf($moy_classe,2) . ")<br/>\n";
960
							}
961
						}
962
					}
963
					echo "</td>\n</tr>\n";
964
				} else {
965
					echo "<td class='bull_simpl' style='text-align:left; $style_bordure_cell'>-</td>\n</tr>\n";
966
				}
967
				$nb++;
968
				$print_tr = 'yes';
969
			}
970
		}
971
	}
972
	echo "</table>\n";
973
	
974
	// Les absences
975
	
976
	echo "<span class='bull_simpl'><b>Absences et retards:</b></span>\n";
977
	//echo "<table width=$larg_tab border=1 cellspacing=1 cellpadding=1>\n";
978
	echo "<table width='$larg_tab' class='boireaus' cellspacing='1' cellpadding='1' summary='Absences et retards'>\n";
979
	$nb=$periode1;
980
	while ($nb < $periode2+1) {
981
		//On v?rifie si le module est activ?
982
		if (getSettingValue("active_module_absence")!='2') {
983
		    $current_eleve_absences_query = mysql_query("SELECT * FROM absences WHERE (login='$current_eleve_login' AND periode='$nb')");
984
		    $eleve_abs[$nb] = @mysql_result($current_eleve_absences_query, 0, "nb_absences");
985
		    $eleve_abs_nj[$nb] = @mysql_result($current_eleve_absences_query, 0, "non_justifie");
986
		    $eleve_retards[$nb] = @mysql_result($current_eleve_absences_query, 0, "nb_retards");
987
		    $current_eleve_appreciation_absences = @mysql_result($current_eleve_absences_query, 0, "appreciation");
988
		    $eleve_app_abs[$nb] = @mysql_result($current_eleve_absences_query, 0, "appreciation");
989
		} else {
990
		    // Initialisations files
991
		    require_once("../lib/initialisationsPropel.inc.php");
992
		    $eleve = EleveQuery::create()->findOneByLogin($current_eleve_login);
993
		    if ($eleve != null) {
994
			$current_eleve_absences_query = mysql_query("SELECT * FROM absences WHERE (login='$current_eleve_login' AND periode='$nb')");
995
			$eleve_abs[$nb] = $eleve->getDemiJourneesAbsenceParPeriode($nb)->count();
996
			$eleve_abs_nj[$nb] = $eleve->getDemiJourneesNonJustifieesAbsenceParPeriode($nb)->count();
997
			$eleve_retards[$nb] = $eleve->getRetardsParPeriode($nb)->count();
998
			$current_eleve_appreciation_absences = @mysql_result($current_eleve_absences_query, 0, "appreciation");
999
			$eleve_app_abs[$nb] = @mysql_result($current_eleve_absences_query, 0, "appreciation");
1000
		    }
1001
		}
1002
		if (($eleve_abs[$nb] != '') and ($eleve_abs_nj[$nb] != '')) {
1003
			$eleve_abs_j[$nb] = $eleve_abs[$nb]-$eleve_abs_nj[$nb];
1004
		} else {
1005
			$eleve_abs_j[$nb] = "?";
1006
		}
1007
		if ($eleve_abs_nj[$nb] === '') { $eleve_abs_nj[$nb] = "?"; }
1008
		if ($eleve_retards[$nb] === '') { $eleve_retards[$nb] = "?";}
1009
	
1010
		//====================================
1011
		// AJOUT: boireaus 20080317
1012
		if($nb==$periode1) {
1013
			if($nb==$periode2) {
1014
				$style_bordure_cell="border: 1px solid black";
1015
			}
1016
			else {
1017
				$style_bordure_cell="border: 1px solid black; border-bottom: 1px dashed black";
1018
			}
1019
		}
1020
		elseif($nb==$periode2) {
1021
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black;";
1022
		}
1023
		else {
1024
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black; border-bottom: 1px dashed black;";
1025
		}
1026
		//====================================
1027
	
1028
		echo "<tr>\n<td valign=top class='bull_simpl' style='$style_bordure_cell'>$nom_periode[$nb]</td>\n";
1029
	// Test pour savoir si l'?l?ve appartient ? la classe pour la p?riode consid?r?e
1030
	$test_eleve_app = sql_query1("select count(login) from j_eleves_classes where login='".$current_eleve_login."' and id_classe='".$id_classe."' and periode='".$nb."'");
1031
	if ($test_eleve_app != 0) {
1032
		echo "<td valign=top class='bull_simpl' style='$style_bordure_cell'>\n";
1033
		if ($eleve_abs_j[$nb] == "1") {
1034
			echo "Absences justifi?es : une demi-journ?e";
1035
		} else if ($eleve_abs_j[$nb] != "0") {
1036
			echo "Absences justifi?es : $eleve_abs_j[$nb] demi-journ?es";
1037
		} else {
1038
			echo "Aucune absence justifi?e";
1039
		}
1040
		echo "</td>\n";
1041
		echo "<td valign=top class='bull_simpl' style='$style_bordure_cell'>\n";
1042
		if ($eleve_abs_nj[$nb] == '1') {
1043
			echo "Absences non justifi?es : une demi-journ?e";
1044
		} else if ($eleve_abs_nj[$nb] != '0') {
1045
			echo "Absences non justifi?es : $eleve_abs_nj[$nb] demi-journ?es";
1046
		} else {
1047
			echo "Aucune absence non justifi?e";
1048
		}
1049
		echo "</td>\n";
1050
		echo "<td valign=top class='bull_simpl' style='$style_bordure_cell'>Nb. de retards : $eleve_retards[$nb]</td>\n</tr>\n";
1051
	} else {
1052
	echo "<td valign=top class='bull_simpl' style='$style_bordure_cell'>-</td><td valign=top class='bull_simpl' style='$style_bordure_cell'>-</td><td valign=top class='bull_simpl' style='$style_bordure_cell'>-</td>\n</tr>\n";
1053
	}
1054
		//Ajout Eric
1055
		if ($current_eleve_appreciation_absences != "") {
1056
		if ($test_eleve_app != 0) {
1057
			echo "<tr>\n";
1058
			echo "<td valign=top class='bull_simpl' style='$style_bordure_cell'>&nbsp;</td>\n";
1059
			echo "<td valign=top class='bull_simpl' colspan=\"3\" style='text-align:left; $style_bordure_cell'>";
1060
			echo " Observation(s) : $current_eleve_appreciation_absences</td>\n</tr>\n";
1061
		} else {
1062
			echo "<tr><td valign=top class='bull_simpl' style='$style_bordure_cell'>&nbsp;</td><td valign=top class='bull_simpl' colspan=\"3\" style='$style_bordure_cell'>-</td>\n</tr>\n";
1063
		}
1064
		}
1065
	
1066
		$nb++;
1067
	}
1068
	echo "</table>\n";
1069
	
1070
	
1071
	// Maintenant, on met l'avis du conseil de classe :
1072
	
1073
	echo "<span class='bull_simpl'><b>Avis du conseil de classe </b> ";
1074
	if ($current_eleve_profsuivi_login) {
1075
		echo "<b>(".ucfirst(getSettingValue("gepi_prof_suivi"))." : <i>".affiche_utilisateur($current_eleve_profsuivi_login,$id_classe)."</i>)</b>";
1076
	}
1077
	echo " :</span>\n";
1078
	$larg_col1b = $larg_tab - $larg_col1 ;
1079
	echo "<table width=\"$larg_tab\" class='boireaus' cellspacing='1' cellpadding='1' summary='Avis du conseil de classe'>\n";
1080
	$nb=$periode1;
1081
	while ($nb < $periode2+1) {
1082
	
1083
		//=========================
1084
		// AJOUT: boireaus 20080317
1085
		if($nb==$periode1) {
1086
			if($nb==$periode2) {
1087
				$style_bordure_cell="border: 1px solid black";
1088
			}
1089
			else {
1090
				$style_bordure_cell="border: 1px solid black; border-bottom: 1px dashed black";
1091
			}
1092
		}
1093
		elseif($nb==$periode2) {
1094
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black;";
1095
		}
1096
		else {
1097
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black; border-bottom: 1px dashed black;";
1098
		}
1099
		//=========================
1100
	
1101
		$current_eleve_avis_query = mysql_query("SELECT * FROM avis_conseil_classe WHERE (login='$current_eleve_login' AND periode='$nb')");
1102
		$current_eleve_avis[$nb] = @mysql_result($current_eleve_avis_query, 0, "avis");
1103

    
1104
// **** AJOUT POUR LA MENTION ****
1105
	$current_eleve_mention[$nb] = @mysql_result($current_eleve_avis_query, 0, "mention");
1106
// **** FIN D'AJOUT POUR LA MENTION ****
1107

    
1108
	// Test pour savoir si l'?l?ve appartient ? la classe pour la p?riode consid?r?e
1109
	$test_eleve_app = sql_query1("select count(login) from j_eleves_classes where login='".$current_eleve_login."' and id_classe='".$id_classe."' and periode='".$nb."'");
1110
	if (($current_eleve_avis[$nb]== '') or ($tab_acces_app[$nb]!="y") or ($test_eleve_app == 0)) {$current_eleve_avis[$nb] = ' -';}
1111
	
1112
	echo "<tr>\n<td valign=\"top\" width =\"$larg_col1\" class='bull_simpl' style='text-align:left; $style_bordure_cell'>$nom_periode[$nb]</td>\n";
1113
	
1114
	//echo "<td valign=\"top\"  width = \"$larg_col1b\" class='bull_simpl' style='text-align:left; $style_bordure_cell'>$current_eleve_avis[$nb]</td>\n";
1115

    
1116
// AJOUT POUR LES MENTIONS (ATTENTION : la ligne ci-dessus a du coup ?t? mise en commentaire !)
1117
        echo "<td valign=\"top\"  width = \"$larg_col1b\" class='bull_simpl' style='text-align:left; $style_bordure_cell'>$current_eleve_avis[$nb]<br/><br/>\n";
1118
        echo "<b>Mention : </b>";
1119
        if ($current_eleve_mention[$nb]=="F")
1120
           echo "F?licitations.";
1121
        elseif ($current_eleve_mention[$nb]=="M")
1122
           echo "Mention honorable.";
1123
        elseif ($current_eleve_mention[$nb]=="E")
1124
           echo "Encouragements.";
1125
        else
1126
           echo "-";
1127
        echo "</td>\n";
1128
// FIN DE L'AJOUT POUR LES MENTIONS
1129

    
1130
	echo "</tr>\n";
1131
		$nb++;
1132
	}
1133
	echo "</table>\n";
1134

    
1135
	} // fin de la condition if ($on_continue == 'yes')
1136
} // Fin de la fonction
1137

    
1138
function affiche_aid_simple($affiche_rang, $test_coef, $indice_aid, $aid_id, $current_eleve_login, $periode1, $periode2, $id_classe, $style_bulletin, $affiche_coef) {
1139

    
1140
unset($tab_acces_app);
1141
$tab_acces_app=array();
1142
$tab_acces_app = acces_appreciations($periode1, $periode2, $id_classe);
1143

    
1144
	$nb_periodes = $periode2 - $periode1 + 1;
1145
	$call_data = mysql_query("SELECT * FROM aid_config WHERE indice_aid = '$indice_aid'");
1146
	$AID_NOM = @mysql_result($call_data, 0, "nom");
1147
	$note_max = @mysql_result($call_data, 0, "note_max");
1148
	$type_note = @mysql_result($call_data, 0, "type_note");
1149
	$display_begin = @mysql_result($call_data, 0, "display_begin");
1150
	$display_end = @mysql_result($call_data, 0, "display_end");
1151
	$bull_simplifie = @mysql_result($call_data, 0, "bull_simplifie");
1152
	// On v?rifie que cette AID soit autoris?e ? l'affichage dans le bulletin simplifi?
1153
	if ($bull_simplifie == "n") {
1154
		return "";
1155
	}
1156

    
1157
	$aid_nom_query = mysql_query("SELECT nom FROM aid WHERE (id='$aid_id' and indice_aid='$indice_aid')");
1158
	$aid_nom = @mysql_result($aid_nom_query, 0, "nom");
1159
	//------
1160
	// On regarde maintenant quels sont les profs responsables de cette AID
1161
	$aid_prof_resp_query = mysql_query("SELECT id_utilisateur FROM j_aid_utilisateurs WHERE (id_aid='$aid_id' and indice_aid='$indice_aid')");
1162
	$nb_lig = mysql_num_rows($aid_prof_resp_query);
1163
	$n = '0';
1164
	while ($n < $nb_lig) {
1165
		$aid_prof_resp_login[$n] = mysql_result($aid_prof_resp_query, $n, "id_utilisateur");
1166
		$n++;
1167
	}
1168
	//------
1169
	// On appelle l'appr?ciation de l'?l?ve, et sa note le cas ?ch?ant
1170
	//------
1171
	$nb=$periode1;
1172
	while($nb < $periode2+1) {
1173
		//=========================
1174
		// AJOUT: boireaus 20080317
1175
		if($nb==$periode1) {
1176
			if($nb==$periode2) {
1177
				$style_bordure_cell="border: 1px solid black";
1178
			}
1179
			else {
1180
				$style_bordure_cell="border: 1px solid black; border-bottom: 1px dashed black";
1181
			}
1182
		}
1183
		elseif($nb==$periode2) {
1184
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black;";
1185
		}
1186
		else {
1187
			$style_bordure_cell="border: 1px solid black; border-top: 1px dashed black; border-bottom: 1px dashed black;";
1188
		}
1189
		//=========================
1190

    
1191
		$current_eleve_aid_appreciation_query = mysql_query("SELECT * FROM aid_appreciations WHERE (login='$current_eleve_login' AND periode='$nb' and id_aid='$aid_id' and indice_aid='$indice_aid')");
1192
		$eleve_aid_app[$nb] = @mysql_result($current_eleve_aid_appreciation_query, 0, "appreciation");
1193
		if ($eleve_aid_app[$nb] == '') {$eleve_aid_app[$nb] = ' -';}
1194
		$periode_query = mysql_query("SELECT * FROM periodes WHERE id_classe = '$id_classe'");
1195
		$periode_max = mysql_num_rows($periode_query);
1196
		$last_periode_aid = min($periode_max,$display_end);
1197
		if (($type_note == 'every') or (($type_note == 'last') and ($nb == $last_periode_aid))) {
1198
			$current_eleve_aid_note[$nb] = @mysql_result($current_eleve_aid_appreciation_query, 0, "note");
1199
			$current_eleve_aid_statut[$nb] = @mysql_result($current_eleve_aid_appreciation_query, 0, "statut");
1200
			if ($note_max != 20) {
1201
				$eleve_aid_app[$nb] = "(note sur ".$note_max.") ".$eleve_aid_app[$nb];
1202
			}
1203
			if ($current_eleve_aid_note[$nb] != '') $current_eleve_aid_note[$nb]=number_format($current_eleve_aid_note[$nb],1, ',', ' ');
1204
			$aid_note_min_query = mysql_query("SELECT MIN(note) note_min FROM aid_appreciations a, j_eleves_classes j WHERE (a.login = j.login and j.id_classe = '$id_classe' and a.statut='' and a.periode = '$nb' and j.periode='$nb' and a.indice_aid='$indice_aid')");
1205

    
1206
			$aid_note_min[$nb] = @mysql_result($aid_note_min_query, 0, "note_min");
1207
			if ($aid_note_min[$nb] == '') {$aid_note_min[$nb] = '-';}
1208
			$aid_note_max_query = mysql_query("SELECT MAX(note) note_max FROM aid_appreciations a, j_eleves_classes j WHERE (a.login = j.login and j.id_classe = '$id_classe' and a.statut='' and a.periode = '$nb' and j.periode='$nb' and a.indice_aid='$indice_aid')");
1209

    
1210
			$aid_note_max[$nb] = @mysql_result($aid_note_max_query, 0, "note_max");
1211
			if ($aid_note_max[$nb] == '') {$aid_note_max[$nb] = '-';}
1212

    
1213
			$aid_note_moyenne_query = mysql_query("SELECT round(avg(note),1) moyenne FROM aid_appreciations a, j_eleves_classes j WHERE (a.login = j.login and j.id_classe = '$id_classe' and a.statut='' and a.periode = '$nb' and j.periode='$nb' and a.indice_aid='$indice_aid')");
1214

    
1215
			$aid_note_moyenne[$nb] = @mysql_result($aid_note_moyenne_query, 0, "moyenne");
1216
			if ($aid_note_moyenne[$nb] == '') {
1217
				$aid_note_moyenne[$nb] = '-';
1218
			} else {
1219
				$aid_note_moyenne[$nb]=number_format($aid_note_moyenne[$nb],1, ',', ' ');
1220
			}
1221
		} else {
1222
			$current_eleve_aid_statut[$nb] = '-';
1223
			$current_eleve_aid_note[$nb] = '-';
1224
			$aid_note_min[$nb] = '-';
1225
			$aid_note_max[$nb] = '-';
1226
			$aid_note_moyenne[$nb] = '-';
1227
		}
1228
		$nb++;
1229
	}
1230
	//------
1231
	// On affiche l'appr?ciation aid :
1232
	//------
1233

    
1234
	echo "<tr><td ";
1235
	if ($nb_periodes > 1) echo " rowspan= ".$nb_periodes;
1236
	echo " class='$style_bulletin' style='$style_bordure_cell'><b>$AID_NOM : $aid_nom</b><br /><i>";
1237
	$n = '0';
1238
	while ($n < $nb_lig) {
1239
		echo affiche_utilisateur($aid_prof_resp_login[$n],$id_classe)."<br />";
1240
		$n++;
1241
	}
1242
	echo "</i></td>";
1243
	if($affiche_coef=='y'){
1244
		if ($test_coef != 0) {
1245
			echo "<td ";
1246
			if ($nb_periodes > 1) echo " rowspan= ".$nb_periodes;
1247
			echo " align=\"center\" style='$style_bordure_cell'><p class='".$style_bulletin."'>-</p></td>";
1248
		}
1249
	}
1250

    
1251
	$nb=$periode1;
1252
	$print_tr = 'no';
1253
	while ($nb < $periode2+1) {
1254
		if ($print_tr == 'yes') echo "<tr>";
1255
		echo "<td align=\"center\" class='$style_bulletin' style='$style_bordure_cell'>$aid_note_moyenne[$nb]</td>";
1256
		echo "<td align=\"center\" class='$style_bulletin' style='$style_bordure_cell'><b>";
1257
		// L'?l?ve fait-il partie de la classe pour la p?riode consid?r?e ?
1258
		$test_eleve_app = sql_query1("select count(login) from j_eleves_classes where login='".$current_eleve_login."' and id_classe='".$id_classe."' and periode='".$nb."'");
1259
    if ($test_eleve_app !=0) {
1260
     if ($current_eleve_aid_statut[$nb] == '') {
1261
			if ($current_eleve_aid_note[$nb] != '') {
1262
				echo $current_eleve_aid_note[$nb];
1263
			} else {
1264
				echo "-";
1265
			}
1266
		 } else if ($current_eleve_aid_statut[$nb] != 'other'){
1267
			echo "$current_eleve_aid_statut[$nb]";
1268
		 } else {
1269
			echo "-";
1270
		 }
1271
		} else  echo "-";
1272
		echo "</b></td>";
1273
		if ($affiche_rang == 'y') echo "<td align=\"center\" class='".$style_bulletin."' style='$style_bordure_cell'>-</td>";
1274
		if ($test_eleve_app !=0) {
1275
        if (($eleve_aid_app[$nb]== '') or ($tab_acces_app[$nb]!="y")) {$eleve_aid_app[$nb] = ' -';}
1276
		    echo "<td class='$style_bulletin' style='text-align:left; $style_bordure_cell'>$eleve_aid_app[$nb]</td></tr>";
1277
		} else echo "<td class='$style_bulletin' style='$style_bordure_cell'>-</td></tr>";
1278
		$print_tr = 'yes';
1279
		$nb++;
1280
	}
1281

    
1282

    
1283
	//------
1284

    
1285
}
1286

    
1287
?>
(7-7/7)