<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">

<title>Bulletin</title>
<style type="text/css">
<!--

@media print  { .noprint  { display: none; }
.page-break  { display:block; page-break-after:always; }
@page  
{ 
   size: 210mm 297mm; 
  /* Chrome sets own margins, we change these printer settings */
  margin: 5mm 5mm 5mm 5mm;
        }

}
body,td,th {
font-family: "Times New Roman", Times, serif;
size:14px;
}
	

-->
</style>
</head>
<body bgcolor="#FFFFFF">

<form method="post" action="_affichenotespareleve2cs.php" >

<?php
function mention($totlagen,$moycoef){
	        if($moycoef==0) { return " ";
			 }
			 else
			 {
	         if(round($totlagen*20/$moycoef,1)>=18) return "EXC."; 
			 elseif(round($totlagen*20/$moycoef,1)>=16) return "T.B.";
			 elseif(round($totlagen*20/$moycoef,1)>=14) return "B.";
			 elseif(round($totlagen*20/$moycoef,1)>=12) return "A.B.";
			 elseif(round($totlagen*20/$moycoef,1)>=10) return "P.";
			 elseif (round($totlagen*20/$moycoef,1)>0) return "F.";
			 elseif(round($totlagen*20/$moycoef,1)==0) return " ";
			 } 
}
echo "<div class='noprint'>";
echo'<button type="button" class="noprint" onclick="window.print()" /><img src="imprimante.png" height="32" width="40" />';
echo "<a href=\"javascript:history.go(-2)\"><button type='button' >Retourner</button></a>";

include 'header.php';
echo "</div>";
$studentID=$_GET['studentID'];
include '_serveur.php';?>
<?php
	
$sql = 'SELECT * from classes inner JOIN students on classes.id=students.classID
inner join classesSemesters on classes.id=classesSemesters.classID
                               inner JOIN semesters on semesters.id=classesSemesters.semesterID where students.id="'.$studentID.'" order by semesters.id' ;

   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
                                   }
$req=  mysqli_query($link, $sql);
$i=0;
  while($data = mysqli_fetch_array($req)){
	  $classeid1=$data[0];
	  $classe=$data[1];
   $cont[$i]=$data[13];
   $i=$i+1;
  }
$sql = 'SELECT * from gradesSubjects inner join subSubjects on gradesSubjects.subSubjectID=subSubjects.id
							   inner join subjects on subSubjects.subjectID=subjects.id
							   where gradesSubjects.classID="'.$classeid1.'" order by subjects.ordering,gradesSubjects.ordering  ' ;
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);

$i=0;
  while($data = mysqli_fetch_array($req)){
	  $coefficient1[$i]=$data[2];
	  $sousmatid1[$i]=$data[4];
	  $matsous[$i]=$data[5];
	  $sousmat1[$i]=$data[6];
	  $matid1[$i]=$data[7];
	  $mat1[$i]=$data[8];
	  
	 // echo  $matid1[$i]." ".$mat1[$i]." ".$sousmatid1[$i]." ".$sousmat1[$i]." ".$coefficient1[$i]."<br>";
  $i=$i+1;
   }
   $matid2 = array_unique($matid1, SORT_REGULAR);

   $mat2=array_unique($mat1, SORT_REGULAR);
   
$sql = 'SELECT * from  classes  left join students on  students.classID=classes.id
                                left  join grades on students.id=grades.studentID and students.classID=grades.classID 
                                left join gradesSubjects on grades.subSubjectID=gradesSubjects.subSubjectID and grades.classID=gradesSubjects.classID
							     left join subSubjects on grades.subSubjectID=subSubjects.id
							    left join subjects on subSubjects.subjectID=subjects.id
							    left join classesSemesters on classesSemesters.classId=classes.id and grades.semesterID=classesSemesters.semesterID
							    left join semesters on semesters.id=classesSemesters.semesterID 
								left join users on users.id=students.userID
                                where students.id="'.$studentID.'" order by students.firstName,students.lastName,users.firstName,subjects.id,subSubjects.id,semesters.id , subjects.ordering' ;
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);
$i=0;
$coeftotal1=0; $sumtotal1=0;
$Moyencla1=0;
  while($data = mysqli_fetch_array($req)){
		$studentid[$i]=$data[3]; 
		 $prenom[$i]=$data[5];
	  	 $famille[$i]=$data[6];
		 $pere[$i]=$data[33];
		$grade[$i]=$data[14];
	  $discipcoef[$i]=$data[17];	
	  $discipid[$i]=$data[19];
	  $discip[$i]=$data[21];
	  $matid[$i]=$data[22];
	  $mat[$i]=$data[23];
	  $orderm[$i]=$data[24];
	  $ctrlid[$i]=$data[29];
	  $ctrl[$i]=$data[30];
	  $cl[$i]=$data[1];
	  $clid[$i]=$data[0];
	  $ma[$i]=0;
	if($ctrlid[$i]==1) { if($grade[$i]!=-1) {$coeftotal1=$coeftotal1+$discipcoef[$i]; $sumtotal1=$sumtotal1+$grade[$i];} }
//echo $studentid[$i]." ".$prenom[$i]." ".$famille[$i]." ".$cl[$i]." ".$ctrl[$i]." ".$mat[$i]." ".$discip[$i]." ".$grade[$i]." ". $discipcoef[$i]."<br>";
//echo $studentid[$i]." ". $matid[$i]. " " .$discipid[$i]. " ". $discipcoef[$i]."<br>";
  $i=$i+1;
}
$num=0;
$trig=1;
if($coeftotal1==0) $coeftotal1=1;	
$Moyencla1=$sumtotal1*20/$coeftotal1;	
echo '<div class="page-break">';

//echo $classeid1." taille d'une classe:".sizeof($studentid);
if (sizeof($studentid)<=1) 
{ echo " Classe n'existe pas"; exit(0);}


	if($trig==1){
		
//include 'titre.php';
	echo '<div class="page-break"><table width="100%" border="0">
  <tr>
    <td colspan="4" ><h4 align="left">SOEURS BASILIENNES CHOUERITES<br />
      COLLEGE SAINT JOSEPH - MINIARA</h4></td>
  </tr>
  <tr >
    <td colspan="5" align="center">RELEVE DES NOTES  <br />
                                    2025-2026   </td>
  </tr>
  <tr class="carnet">
  <td width="20%" height="30">Nom et Prénom:</td><td width="70%" bgcolor="#FFFFFF">'. strtoupper($prenom[$num]).'<span style="padding-left:30px;"></span>'.strtoupper($pere[$num]).'<span style="padding-left:30px;"></span>'.strtoupper($famille[$num]).'</td>
  <td width="10%">Classe:'.strtoupper($cl[$num]).'</td></tr>
</table>';
echo '<table width="98%" border="1" align="center" cellspacing="0">

  <tr class="carnet">
  
    <td width=30%  height="25" >Matières</span></td>
    <td width="10%">Coef.</td>';
	$trig=0;
		$j=0;
	while($j<sizeof($cont))
	{
    echo '<td width="7%">'.$cont[$j].'<br /></td>';
	$j=$j+1;
	}
	 echo '<td width="7%"><b>M.G.</b><br /></td>';	
 echo "</tr>";
	}
		$m=$num;
		$sou=0;
		$s=0;
		$totlagen1=0;$moycoef1=0;
		$totlagen2=0;$moycoef2=0;
		$totlagen3=0;$moycoef3=0;
 		$totlagen4=0;$moycoef4=0;
		$totlagen5=0;$moycoef5=0;
 		$totlagen6=0;$moycoef6=0;
		$coeftot=0;$countdisc1=0;
	 while($s<=sizeof($studentid)){
		 $coefsou=0;
		$discpsum1=0;
		 $discpsum2=0;
		 $discpsum3=0;
		 $discpsum4=0;$discpsum5=0; $discpsum6=0;
		 $matcoef1=0;
		$matcoef2=0;
		 $matcoef3=0;
		 $matcoef4=0;$matcoef5=0;
		 $matcoef6=0;

		 $coefmat2s[$mat2[$s]]=0;
		if($mat2[$s]!=""){
		echo "<tr><td width=30%  height='25' align='center'>
		<label class='w3-text-blue'  ><b>".$mat2[$s]."</b></label><br></td><td></td><td></td>
		<td></td><td></td><td></td><td></td><td></td><td></td>";
		    $countdisc=0;
			
	      while($matsous[$sou]==$matid2[$s]){
		
            echo "<tr><td>". $sousmat1[$sou]."<br>";
			echo "<td align='center'><b>". $coefficient1[$sou]."</b></td>";
			$sumg=0;
			$col1=0;
			$coefmat2s[$mat2[$s]]=$coefmat2s[$mat2[$s]]+ $coefficient1[$sou];
			$coeftot=$coeftot+$coefficient1[$sou];
			$countgra=0;
			$colu=0;

			
			while(($discipid[$m]==$sousmatid1[$sou])&&($studentid[$m]==$studentid[$num])){  
                     if($ctrlid[$m]==1) {//$matcoef1=$matcoef1+$coefficient1[$sou];
				                           if($grade[$m]<>-1){ $matcoef1=$matcoef1+$discipcoef[$m];
				                            $discpsum1=$discpsum1+$grade[$m];
									  	    $sumg=$sumg+$grade[$m];}
											
						 if(($grade[$m]==-1)) echo "<td align='center'>Abs.</td>";
						 else {$colu=1; echo "<td align='center'>".$grade[$m]."</td>"; }
						 if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
						 }
				   elseif($ctrlid[$m]==2) {//$matcoef2=$matcoef2+$coefficient1[$sou];
				   				              if($grade[$m]<>-1){  $matcoef2=$matcoef2+$discipcoef[$m];
				                                $discpsum2=$discpsum2+$grade[$m];$sumg=$sumg+$grade[$m]; 
											  }
									  
						        if($colu<1) {echo "<td align='center'></td>";$col1++;}
								if($grade[$m]==-1) echo "<td align='center'>Abs.</td>";
						        else {$colu=2; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;}
								
				   elseif($ctrlid[$m]==3) {// $matcoef3=$matcoef3+$coefficient1[$sou];
				   				                if($grade[$m]<>-1){ $matcoef3=$matcoef3+$discipcoef[$m];
				                                 $discpsum3=$discpsum3+$grade[$m];$sumg=$sumg+$grade[$m];
												}
				                           if($colu<2) {echo "<td align='center'></td>";$col1++;}
								if($grade[$m]==-1) echo "<td align='center'>Abs.</td>";
						        else {$colu=3; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
							}
				   elseif($ctrlid[$m]==4) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                                if($grade[$m]<>-1){ $matcoef4=$matcoef4+$discipcoef[$m];
												$discpsum4=$discpsum4+$grade[$m];$sumg=$sumg+$grade[$m];
												}
												
				                         if($colu<3) {echo "<td align='center'></td>";$col1++;}
								if($grade[$m]==-1) echo "<td align='center'>Abs.</td>";
						        else {$colu=4; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }
			 elseif($ctrlid[$m]==6) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                               if($grade[$m]<>-1){$matcoef5=$matcoef5+$discipcoef[$m];
												$discpsum5=$discpsum5+$grade[$m];$sumg=$sumg+$grade[$m];
											   }
						               if($colu<4) {echo "<td align='center'></td>";$col1++;}
								if($grade[$m]==-1) echo "<td align='center'>Abs.</td>";
						        else {$colu=5; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }
			 elseif($ctrlid[$m]==7) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                                if($grade[$m]<>-1){ $matcoef6=$matcoef6+$discipcoef[$m];
												$discpsum6=$discpsum6+$grade[$m];$sumg=$sumg+$grade[$m];}
						    if($colu<5) {echo "<td align='center'></td>";$col1++;}
								if($grade[$m]==-1) echo "<td align='center'>Abs.</td>";
						        else {$colu=6; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }
	 elseif($ctrlid[$m]==8) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                                if($grade[$m]<>-1){ $matcoef4=$matcoef4+$discipcoef[$m];
												$discpsum4=$discpsum4+$grade[$m];$sumg=$sumg+$grade[$m];
												}
												
				                         while($colu<3) {echo "<td align='center'></td>";$col1++;$colu++;}
								if($grade[$m]==-1) echo "<td align='center'></td>";
						        else {$colu=4; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }
	 elseif($ctrlid[$m]==9) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                                if($grade[$m]<>-1){ $matcoef5=$matcoef5+$discipcoef[$m];
												$discpsum5=$discpsum5+$grade[$m];$sumg=$sumg+$grade[$m];
												}
												
				                         while($colu<4) {echo "<td align='center'></td>";$col1++;$colu++;}
								if($grade[$m]==-1) echo "<td align='center'></td>";
						        else {$colu=5; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }
		 elseif($ctrlid[$m]==10) {//$matcoef4=$matcoef4+$coefficient1[$sou];
				                                if($grade[$m]<>-1){ $matcoef6=$matcoef6+$discipcoef[$m];
												$discpsum6=$discpsum6+$grade[$m];$sumg=$sumg+$grade[$m];
												}
												
				                         while($colu<5) {echo "<td align='center'></td>";$col1++;$colu++;}
								if($grade[$m]==-1) echo "<td align='center'></td>";
						        else {$colu=6; echo "<td align='center'>".$grade[$m]."</td>";}
							if(($grade[$m]<>0)&&($grade[$m]<>-1)) $countgra=$countgra+1;
				   }		   

				   elseif($grade[$m]==0) echo "<td> </td>";

				   
				  $m=$m+1;
				   $col1=$col1+1;
			     }
				  
                  $sou=$sou+1; 
				  $ajoutcol=6;
				  $ajoutcol=$ajoutcol-$col1;
				while( $ajoutcol!=0){
					  echo "<td></td>";
					  $ajoutcol=$ajoutcol-1;  
				  }
				  if($countgra==0) $countgra=1;
				  $moyg=$sumg/$countgra;
				  $moyg=round($moyg,1);
			     if($moyg==0)  echo "<td align='center'></td></tr>";else echo "<td align='center'>".$moyg."</td></tr>";
		    
				 }
 if($discpsum1<>0) {$countdisc=$countdisc+1;}
  if($discpsum2<>0) {$countdisc=$countdisc+1;}
 if($discpsum3<>0) {$countdisc=$countdisc+1;}
 if($discpsum4<>0) {$countdisc=$countdisc+1;}
 if($discpsum5<>0) {$countdisc=$countdisc+1;}
 if($discpsum6<>0) {$countdisc=$countdisc+1;}


				/* echo "<tr><td><b> Total ".$mat2[$s]." </b></td>";
				 echo "<td align='center'><b>".$coefmat2s[$mat2[$s]]."</b></td>";
				 if($discpsum1<>0) {$countdisc=$countdisc+1; echo "<td align='center'><b>".$discpsum1. "</b></td>";} else{echo "<td><b></b></td>";}
				 if($discpsum2<>0) {$countdisc=$countdisc+1;  echo "<td align='center'><b>".$discpsum2."</b></td>";} else{echo "<td><b></b></td>";}
				  if($discpsum3<>0) {$countdisc=$countdisc+1;echo "<td align='center'><b>".$discpsum3."</b></td>";} else{echo "<td><b></b></td>";}
 				 if($discpsum4<>0) {$countdisc=$countdisc+1;echo "<td align='center'><b>".$discpsum4."</b></td>";} else{echo "<td><b></b></td>";}
				  if($discpsum5<>0) {$countdisc=$countdisc+1;echo "<td align='center'><b>".$discpsum5."</b></td>";} else{echo "<td><b></b></td>";}
 				 if($discpsum6<>0) {$countdisc=$countdisc+1;echo "<td align='center'><b>".$discpsum6."</b></td>";} else{echo "<td><b></b></td>";} */

				 if($countdisc==0) $countdisc=1;
				 $disctotal=($discpsum1+$discpsum2+$discpsum3+$discpsum4+$discpsum5+$discpsum6)/$countdisc;
				 $disctotal=round($disctotal,1);
				// if($disctotal==0) echo "<td align='center'><b></b></td></tr>"; else echo "<td align='center'><b>".$disctotal."</b></td></tr>";
				 $matcoef11=$matcoef1;$matcoef22=$matcoef2;$matcoef33=$matcoef3;$matcoef44=$matcoef4;
				 $matcoef55=$matcoef5;$matcoef66=$matcoef6;
				 if($matcoef1==0) $matcoef11=1;  if($matcoef2==0) $matcoef22=1;
				 if($matcoef3==0) $matcoef33=1; if($matcoef4==0) $matcoef44=1;
				 if($matcoef5==0) $matcoef55=1; if($matcoef6==0) $matcoef66=1;

			     echo "<tr><td><b> Moyenne ".$mat2[$s]." </b></td>";
				 echo "<td align='center'><b>20</b></td>";
				 if($discpsum1==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center'><b>".round($discpsum1*20/$matcoef11,1)."</b></td>";
				 if($discpsum2==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center' > <b>".round($discpsum2*20/$matcoef22,1)."</b></td>";
				 if($discpsum3==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center'><b>".round($discpsum3*20/$matcoef33,1)."</b></td>";
 				 if($discpsum4==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center'><b>".round($discpsum4*20/$matcoef44,1)."</b></td>";
				 if($discpsum5==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center'><b>".round($discpsum5*20/$matcoef55,1)."</b></td>";
 				 if($discpsum6==0) echo "<td align='center'><b></b></td>"; else echo "<td align='center'><b>".round($discpsum6*20/$matcoef66,1)."</b></td>";

				 $moymatf=($discpsum1*20/$matcoef11+$discpsum2*20/$matcoef22+$discpsum3*20/$matcoef33+$discpsum4*20/$matcoef44+$discpsum5*20/$matcoef55+$discpsum6*20/$matcoef66)/$countdisc;
				 
				 $moymatf=round($moymatf,1);
				 if( $moymatf==0) echo "<td align='center'><b></b></td></tr>"; else echo "<td align='center'><b>".$moymatf."</b></td></tr>";

		        }
                $totlagen1=$totlagen1+$discpsum1;
				$moycoef1=$moycoef1+$matcoef1;
				$totlagen2=$totlagen2+$discpsum2;
				$moycoef2=$moycoef2+$matcoef2;
                $totlagen3=$totlagen3+$discpsum3;
				$moycoef3=$moycoef3+$matcoef3;
				$totlagen4=$totlagen4+$discpsum4;
                $moycoef4=$moycoef4+$matcoef4;
			    $totlagen5=$totlagen5+$discpsum5;
                $moycoef5=$moycoef5+$matcoef5;
			   $totlagen6=$totlagen6+$discpsum6;
                $moycoef6=$moycoef6+$matcoef6;

				 $s=$s+1; 				
              }
			  echo "<tr><td colspan='7' height='10px'></td></tr>";
			  echo "<tr><td><b> Total Général</b></td>";
			  
				 echo "<td align='center'><b>". $coeftot."</b></td>";
				 if($totlagen1==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen1."</b></td>";$countdisc1++;}
				 if($totlagen2==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen2."</b></td>";$countdisc1++;}
				 if($totlagen3==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen3."</b></td>";$countdisc1++;}
 				 if($totlagen4==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen4."</b></td>";$countdisc1++;}
                  if($totlagen5==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen5."</b></td>";$countdisc1++;}
 				 if($totlagen6==0)  echo "<td><b></b></td>"; else {echo "<td align='center'><b>".$totlagen6."</b></td>";$countdisc1++;}
				 if($countdisc1==0) $countdisc1=1;
				 $totalgf=($totlagen1+$totlagen2+$totlagen3+$totlagen4+$totlagen5+$totlagen6)/$countdisc1;
				 $totalgf=round($totalgf,1);
				 
				 echo "<td align='center'><b>".$totalgf."</b></td></tr>"; 
				   echo "<tr><td><b> Moyenne Générale</b></td>";
				 echo "<td align='center'><b>20</b></td>";
				if($totlagen1==0)  echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen1*20/$moycoef1,1)."</b></td>";
				 if($totlagen2==0) echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen2*20/$moycoef2,1)."</b></td>";
				if($totlagen3==0)  echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen3*20/$moycoef3,1)."</b></td>";
 				 if($totlagen4==0) echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen4*20/$moycoef4,1)."</b></td>";
				 if($totlagen5==0)  echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen5*20/$moycoef5,1)."</b></td>";
 				 if($totlagen6==0) echo "<td><b></b></td>"; else echo "<td align='center'><b>".round($totlagen6*20/$moycoef6,1)."</b></td>";
				 if($moycoef1==0) $moycoef1=1 ;
				 if($moycoef2==0) $moycoef2=1;
				if($moycoef3==0) $moycoef3=1 ;
 				 if($moycoef4==0) $moycoef4=1;
				 if($moycoef5==0) $moycoef5=1;
 				 if($moycoef6==0) $moycoef6=1;
			$moyengf=(($totlagen1*20/$moycoef1)+($totlagen2*20/$moycoef2)+($totlagen3*20/$moycoef3)+($totlagen4*20/$moycoef4)
				 +($totlagen5*20/$moycoef5)+($totlagen6*20/$moycoef6))/$countdisc1;
				 $moyengf=round($moyengf,1);
	 echo "<td align='center'><b>".$moyengf."</td></tr>";  

				    echo "<tr><td><b> Mention</b></td>";
				 echo "<td></td>";
				echo "<td align='center'><b>".mention($totlagen1,$moycoef1)."</b></td>";
				 echo "<td align='center'><b>".mention($totlagen2,$moycoef2)."</b></td>";
				 echo "<td align='center' ><b>".mention($totlagen3,$moycoef3)."</b></td>";
				 echo "<td align='center'><b>".mention($totlagen4,$moycoef4)."</b></td>";
				 echo "<td align='center' ><b>".mention($totlagen5,$moycoef5)."</b></td>";
				 echo "<td align='center'><b>".mention($totlagen6,$moycoef6)."</b></td>";

                 echo "<td></td></tr>"; 
				$sql = 'SELECT * from absenceclasse where studentID="'. $studentid[$num].'"' ;
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
                             }
           $req=  mysqli_query($link, $sql);
		   
   while($data = mysqli_fetch_array($req)){
	  $studID=$data[1];
	  $seme=$data[5];
	  $abs[$studID][$seme]=$data[4];
        }
		
				    echo "<tr><td><b> Absence</b></td>";
				 echo "<td></td>";
				if($studID==$studentid[$num]){
					echo "<td align='center'><b>".$abs[$studID][1]."</b></td>";
				 echo "<td align='center'><b>".$abs[$studID][2]."</b></td>";
				 echo "<td align='center' ><b>".$abs[$studID][3]."</b></td>";
				 echo "<td align='center'><b>".$abs[$studID][4]."</b></td>";
				 echo "<td align='center' ><b>".$abs[$studID][5]."</b></td>";
				 echo "<td align='center'><b>".$abs[$studID][6]."</b></td>";
		}
		else
		{
			 echo "<td align='center'><b></b></td>";
				 echo "<td align='center'><b></b></td>";
				 echo "<td align='center' ><b></b></td>";
				 echo "<td align='center'><b></b></td>";
				 echo "<td align='center' ><b></b></td>";
				 echo "<td align='center'><b></b></td>";
		}

                 echo "<td></td></tr>";  	 	 			
       echo "</table>";
	   
	 echo '<div class="w3-panel w3-white w3-border w3-round-xlarge w3-border-black" >
        <p>Observations:</p>
          </div>';
	echo '<div class="w3-cell-row">

  <div class="w3-container w3-round-xxlarge w3-border w3-cell w3-border-black">
    <p>Direction</p>';
	if($classeid1>=13) echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  <div class="w3-container w3-round-xxlarge  w3-cell">
    <p></p>
  </div>
  <div class="w3-container w3-round-xxlarge w3-border w3-celln w3-border-black">
    <p>Parent</p>
  </div>

</div>';
echo '</div>';
		$num=$m; 
		//$num=$num+1;
	$trig=1;
	
?>
</body>
</html>
