<?php
	ob_start();
	require 'connexionBD.php';
	
	
	//include 'ChiffreEnLettre.php'; 

	
/*	function int2str($a)
{
$convert = explode('.',$a);
if (isset($convert[1]) && $convert[1]!=''){
return int2str($convert[0]).'Dinars'.' et '.int2str($convert[1]).'Centimes' ;
}
if ($a<0) return 'moins '.int2str(-$a);
if ($a<17){
switch ($a){
case 0: return 'zero';
case 1: return 'un';
case 2: return 'deux';
case 3: return 'trois';
case 4: return 'quatre';
case 5: return 'cinq';
case 6: return 'six';
case 7: return 'sept';
case 8: return 'huit';
case 9: return 'neuf';
case 10: return 'dix';
case 11: return 'onze';
case 12: return 'douze';
case 13: return 'treize';
case 14: return 'quatorze';
case 15: return 'quinze';
case 16: return 'seize';
}
} else if ($a<20){
return 'dix-'.int2str($a-10);
} else if ($a<100){
if ($a%10==0){
switch ($a){
case 20: return 'vingt';
case 30: return 'trente';
case 40: return 'quarante';
case 50: return 'cinquante';
case 60: return 'soixante';
case 70: return 'soixante-dix';
case 80: return 'quatre-vingt';
case 90: return 'quatre-vingt-dix';
}
} elseif (substr($a, -1)==1){
if( ((int)($a/10)*10)<70 ){
return int2str((int)($a/10)*10).'-et-un';
} elseif ($a==71) {
return 'soixante-et-onze';
} elseif ($a==81) {
return 'quatre-vingt-un';
} elseif ($a==91) {
return 'quatre-vingt-onze';
}
} elseif ($a<70){
return int2str($a-$a%10).'-'.int2str($a%10);
} elseif ($a<80){
return int2str(60).'-'.int2str($a%20);
} else{
return int2str(80).'-'.int2str($a%20);
}
} else if ($a==100){
return 'cent';
} else if ($a<200){
return int2str(100).' '.int2str($a%100);
} else if ($a<1000){
return int2str((int)($a/100)).' '.int2str(100).' '.int2str($a%100);
} else if ($a==1000){
return 'mille';
} else if ($a<2000){
return int2str(1000).' '.int2str($a%1000).' ';
} else if ($a<1000000){
return int2str((int)($a/1000)).' '.int2str(1000).' '.int2str($a%1000);
}
else if ($a==1000000){
return 'millions';
}
else if ($a<2000000){
return int2str(1000000).' '.int2str($a%1000000).' ';
}
else if ($a<1000000000){
return int2str((int)($a/1000000)).' '.int2str(1000000).' '.int2str($a%1000000);
}
}*/






	
	
	$db = new Connect($_GET['mySchool']);
	$dc = $db->connect_db($_GET['mySchool']);
	
	$query='SELECT rapport.anneeScolaire as anneeScolaire, nom, postnom, idRapport, cours.libelle as cours, observation, classe.libelle as Classe, section.libelle as Section, `option`.libelle as OptionLib, lettre.libelle as Lettre FROM professeur, rapport, cours, classe, section, `option`, lettre WHERE rapport.idProf=professeur.idProf AND rapport.idProf = "'.$_GET['idProf'].'" AND rapport.idClasse=classe.idClasse AND rapport.idCours=cours.idCours AND classe.idSection = section.idSection AND classe.idOption = `option`.idOption AND classe.idLettre = lettre.idLettre AND classe.validite = "OUI" AND section.validite = "OUI" AND lettre.validite = "OUI" AND `option`.validite = "OUI" AND cours.validite="OUI" AND professeur.validite="OUI" GROUP BY cours, observation, Classe, Section, OptionLib, Lettre ORDER BY Classe';
				  // echo $query;
	$q=$dc->prepare($query);
	$q->execute();
	
	$i=1;
	$cours = array();
	$observation = array();
	$classe = array();
		   	
   	while($a=$q->fetch()){
   	    
   	    if($a['Classe']=="5eme" || $a['Classe']=="6eme") { if(strtoupper(trim($a['Lettre']))=="AUCUNE"){$a['Section']=""; $a['Lettre']="";} else {$a['Section']="";}}
				
		else {
		
			if(strtoupper(trim($a['Section'])) == "AUCUNE") $a['Section']="";
			if(strtoupper(trim($a['OptionLib'])) == "AUCUNE") $a['OptionLib']="";
			if(strtoupper(trim($a['Lettre'])) == "AUCUNE") $a['Lettre']="";
		
		}
   	    
   	    $prof = strtoupper($a['nom']." ".$a['postnom']);
   	    $cours[$i] = ucfirst(strtolower($a['cours']));
   	    $observation[$i] = $a['observation'];
	    $annee = $a['anneeScolaire'];
	    $classe[$i] = strtolower($a['Classe'])." ".strtoupper($a['Section']." ".$a['OptionLib']." ".$a['Lettre']);
	    
	    $i++;
	    
	}
	
			
?>

<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=euc-kr">

<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="http://templateq.com" />
</head>
<style type="text/css">
<!--
table
{
    width:  100%;
    border:none;
    border-collapse: collapse;
}
th
{
    text-align: center;
    border: solid 1px #000000;
    background: #f8f8f8;
    padding:10px;
}
td
{
    text-align: center;
    border: solid 1px #000000;
    padding:10px;
}
-->
</style>

<body>
	
	<div>
		
	</div>
	
	
	<div style="position:absolute; left:10px; top:10px; border:1px solid; padding:10px; width:200px; font-size:18px; text-align:center">
		LYCEE DR SHAUMBA <br/> <br/>
		<u> KINSHASA GOMBE </u>
	</div>
	
	<div style="position:relative; left:400px; top:10px; padding:10px; width:350px; font-size:18px; text-align:center">
		<?php echo"ANNEE SCOLAIRE : ".$annee; ?> <br/>
	</div>
	
	
	<div style="position:relative; left:60px; width:600px; top:80px; border:1px solid; padding:10px; font-size:18px; text-align:center">
		EXECUTION DES PREVISIONS DES MATIERES 
	</div>
	
	
	<div style="position:relative; left:30px; width:750px; top:35px; padding:10px; font-size:14px; text-align:center">
		
		<table>
		    
		    <tr>
		        <th> N° </th>
	            <th> Nom et Postnom </th>
                <th> Branche(s) </th>
                <th> Classe(s) </th>
                <th> Observation </th>
		    </tr>
		    
		    <?php for($j=1; $j<=count($observation); $j++){ ?>
		    
		    <tr>
		        <td> <?php echo $j; ?>  </td>
	            <td style="text-align:left"> <?php echo $prof; ?> </td>
                <td style="text-align:left"> <?php echo $cours[$j]; ?> </td>
                <td style="text-align:left"> <?php echo $classe[$j]; ?> </td>
                <td style="text-align:left"> <?php echo $observation[$j]; ?> </td>
		    </tr>
		    
		    <?php } ?>
		    
		</table>
		
	</div>
	
	
</body>
</html>


<?php 
    
	$content = ob_get_clean();
    require_once 'html2pdf.class.php';
    try
    {
        $html2pdf = new HTML2PDF("P", "A4", "fr");
        $html2pdf->setDefaultFont("Arial");
        $html2pdf->writeHTML($content);
        $html2pdf->Output("votre_pdf.pdf");
    }
    catch(HTML2PDF_exception $e) {
        echo $e;
        exit;
    }
	
?>

