<?php
	$currDir = dirname(__FILE__);
	include("$currDir/nel.php");
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");

	include_once("$currDir/header.php");

	/* grant access to all users who have access to the reunions table */
	$order_from = get_sql_from('reunions');
	if(!$order_from) exit(error_message('Access denied!', false));

	/* get invoice */
	$order_id = intval($_REQUEST['idreunion']);
	if(!$order_id) exit(error_message('Invalid invoice ID!', false));
	
	/* retrieve order info */
	$order_fields = get_sql_fields('reunions');
	$res = sql("select {$order_fields} from {$order_from} and idreunion={$order_id}", $eo);
	if(!($order = db_fetch_assoc($res))) exit(error_message('Invoice not found!', false));
	
	//var_dump($order);
	
	/* retrieve order items */
	$items = array();
	$order_total = 0;
	$item_fields = get_sql_fields('item_reunions');
	$item_from = get_sql_from('item_reunions');
	$res = sql("select {$item_fields} from {$item_from} and item_reunions.link_out={$order_id}", $eo);
	while($row = db_fetch_assoc($res)){
		$row['LineTotal'] = str_replace('$', '', $row['']);
		$items[] = $row;
		$order_total += $row[''];
	}
	
	//var_dump($items);
	
	?>
		<!-- bouton impression -->
	<html>

		<head>
			<title></title>
			<style type="text/css" media="print">
				input.imprimer {
					display: none;
				}
			</style>
			
			<style>
				#imgentete
				{
					width: 160px;
					height: 160px;
					float: left;
				}
				
								#imgentete2
				{
					width: 80px;
					height: 80px;
					float: right;
				}
				
				#bas {
					position: fixed;
					bottom: 0;
					width: 100%;
				}
				
				#gras{
					font-weight: 700;
				}
				
				.para{
					line-height: 20px;
				}
				
				.momo{
					background-color: gray;
					color: black;
				}
				
				#gros{
					font-size: 35px;
				}
			</style>

		</head>

<body>

    <form method="POST" action="">

        <input type="button" value="Imprimer" class="imprimer" name="bnom" onClick="javascript:window.print()">
    </form>

</body>

	<!-- entete info -->
		<div>
			<?php
				$logo_src = getUploadDir("") .$order["logo"];
				echo "<img id='imgentete' src=\"{$logo_src}\" />";
			?>
		</div>		
		
		<div>
				<img id="imgentete2" src="images/iata.png" alt="IATA">
		</div>
			<h1 class="text-center" id="gros"><?php echo $order['rs']; ?></h1>	
			<p class="text-center"><?php echo $order['description']; ?></p>

			
	<!-- entete info -->
<hr>

<div class="row">
    <div class="col-sm-6">
        <!-- customer info -->

        <div class="col-sm-6 text-right">
            <!-- invoice info -->
            <h5>DATE :
                <?php echo $order['date']; 
            ?>
            </h5>
            <center>
                <h3>
                    ORDRE DU JOUR
                </h3>
				<h3>
					<?php echo $order['ordre_jour']; ?>
				</h3>
            </center>
        </div>
		<div id="infoc">
					DATE : <?php echo $order['date']; ?><br>
					TEMPS : <?php echo $order['temps']; ?><br>
					DUREE : <?php echo $order['duree']; ?><br>
					LIEU : <?php echo $order['lieu']; ?><br>
		</div>
            <center>
                <h3>
                    OBJECTIF DE LA REUNION
                </h3>
				<p>
					<?php echo $order['objectif']; ?>
				</p>
            </center>		
    </div>

</div>

<br>

<!-- order items -->
<table class="table table-striped table-bordered">
    <thead class="momo">
        <th>ACTIVITES OU SUJET</th>
        <th>TEMPS ALLOUES</th>
        <th>RESPONSABLE</th>
        <th>OBJECTIF</th>
    </thead>

    <tbody>
        <?php foreach($items as $i => $item){ ?>
        <tr>
            <td>
                <?php echo $item['activite']; ?>
            </td>              
			<td class="text-center">
                <?php echo $item['temps']; ?>
            </td>            
			<td class="text-center">
                <?php echo $item['responsable']; ?>
            </td>			
			<td class="text-center">
                <?php echo $item['objectif']; ?>
            </td>
        </tr>
        <?php } ?>
    </tbody>
</table>

<?php

	include_once("$currDir/footer.php");

?>
