<?php
	
	ob_start();
	require 'connexionBD.php';

	$db = new Connect($_GET['mySchool']);
	$dc = $db->connect_db($_GET['mySchool']);

	$req = 'SELECT ecole.denomination as denomination, idPredication FROM predication, ecole WHERE predication.idEcole=ecole.idEcole AND predication.idPredication="'.$_GET['idPredication'].'" AND predication.validite="OUI" AND ecole.validite="OUI"';
	$q=$dc->prepare($req);
	$q->execute();
	
	while($a=$q->fetch()){
		$eglise=str_replace(" ", "_", trim(strtolower($a['denomination'])));
		$idPredication=$a['idPredication'];
	}
			
?>

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

<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:solid 1px;
    border-collapse: collapse;
}
th
{
    width:  100%;
    text-align:;
    border:solid 1px;
    padding:2px;
    font-size:12px;
}
td
{
    width:  100%;
    text-align:;
    border:solid 1px;
    padding:2px;
    font-size:12px;
}
-->
</style>

<body>
	

    <?php	
    	
        $dirname="../../mesFichiers/".$eglise."/resumepred/".$idPredication;
    
        $dir = opendir($dirname);
        $message = "Fichier non disponible.";
        $rep = "ok";
        $i=1;
        
        while($file = readdir($dir)) {
            $message = "";
            if($rep == "ok") {
                
            }
            
            if($file != '.' && $file != '..' && !is_dir($dirname.$file)){
                echo '<a href="'.$dirname.'/'.$file.'" style ="font-size:25px; text-decoration: none;"> * '.str_replace(".jpg","",$file).'</a>'.'<br /><br />';
                $i++;
            }
            $rep="nok";
        }
        
        echo '<span style ="font-size:30px;">'.$message.'</span>';
        closedir($dir);
    	
    ?>
	


</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;
    }
	
?>

