<?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 facture table */
	$order_from = get_sql_from('banques');
	if(!$order_from) exit(error_message('Accès non autorisé!', false));

	/* get invoice */
	$order_id = intval($_REQUEST['id_banque']);
	if(!$order_id) exit(error_message('ID facture invalide!', false));
	
	/* retrieve order info */
	$order_fields = get_sql_fields('banques');
	$res = sql("select {$order_fields} from {$order_from} and id_banque={$order_id}", $eo);
	if(!($order = db_fetch_assoc($res))) exit(error_message('Aucune facture disponible', false));
	
	//var_dump($order);
	
	/* retrieve order items */
	$items = array();
	$order_total = 0;
	$item_fields = get_sql_fields('etat_banques');
	$item_from = get_sql_from('etat_banques');
	$res = sql("select {$item_fields} from {$item_from} and etat_banques.from_banque={$order_id}", $eo);
	while($row = db_fetch_assoc($res)){
		$row['LineTotal'] = str_replace('$', '', $row['montant']) * $row['qte'];
		$etat_banques[] = $row;
		$order_total += $row['LineTotal'];
	}
	
	//var_dump($etat_banques);
	
	?>
	
<html>
<head>
	<title>Etat des banques</title>
<style type="text/css" media="print">
input.imprimer
{
display:none;
}
</style>
 
</head>
 
<body>

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

</body>
 
</html>	
	

<h6>Honneur - Fraternité - Justice</h6>
<center>
<h2>Ministère de l'Habitat de l'Urbanisme et de l'Aménagement du territoire</h2>
<h4>Direction des Affaires Administratives et Financières</h4>
<h4>Service du Personnel</h4>
<center><u><h1>ETAT DES BANQUES / <?php echo $order['banque']; ?></h1></u></center>
</center>


	<div class="row">
		<div class="col-sm-6">
			<!-- customer info 
			<h5>CLIENT : <?php echo $order['client']; ?></h5>
			<h5>ENTREPRISE : <?php echo $order['entreprise']; ?></h5>
			<h5>ADRESSE : <?php echo $order['adresse']; ?></h5>
			<h5>CONTACT : <?php echo $order['contact']; ?></h5>
			-->
		</div>
		<div class="col-sm-6 text-right">
			<!-- invoice info 
			<h1></h1>
			<h5>Nouakchott, le <?php echo $order['date']; ?></h5>
			-->
			
		</div>
	</div>
	
	<hr>
	
	<!-- order etat_banques -->
	<table class="table table-striped table-bordered">
		<thead>
			<th class="text-center">N° ORDRE</th>
			<th class="text-center">MATRICULE</th>
			<th>NOM ET PRENOM</th>
			<th>FONCTION</th>
			<th class="text-center">BANQUE</th>
			<th class="text-center">N°COMPTE</th>
			<th class="text-center">MONTANT</th>
		</thead>
		
		<tbody>
			<?php foreach($etat_banques as $i => $item){ ?>
				<tr>
					<td class="text-center"><?php echo ($i + 1); ?></td>
					<td><?php echo $item['matricule']; ?></td>
					<td><?php echo $item['nom_prenom']; ?></td>
					<td><?php echo $item['fonction']; ?></td>
					<td><?php echo $item['n_compte']; ?></td>
					<td><?php echo $item['banque']; ?></td>
					<td class="text-center"><?php echo number_format($item['montant'], 0, ',', ' '); ?></td>
					<!--<td class="text-center"><?php echo $item['qte']; ?></td>/-->
					<!--<td class="text-right"><?php echo number_format($item['montant'], 0, ',', ' '); ?></td>/-->
				</tr>
			<?php } ?>
		</tbody>
		
		<tfoot>


			<tr>
				<th colspan="6" class="text-right">TOTAL</th>
				<th class="text-right"> <?php echo number_format($order_total + $order['Freight'], 0, ',', ' '); ?></th>
			</tr>
		</tfoot>
	</table>
	
	<span id="in-words"><b>Arrêté le présent reçu à la somme de:</b></span>

<?php
include_once('nel.php');
echo enlettres("$order_total");
?>
<span id="in-words"><b> MRU</b></span>

	<br><br><br>
	Le Directeur des Affaires Administratives et Financières<span id="in-words" style="float: right;"><b><h5><?php echo $order['directeur']; ?></h5></b></span>
	<!--
	<center>
	<p>
		Numéro Téléphone : +222 37 66 39 34 | +213 780 01 12 81 | Email gérant : boubouttboullah@icloud.com<br>
		Email bureau : sbbs.impexp@gmail.com | RC : 102204/GU/23213/477 | NIF : 00621223
	</p>
	</center>
	-->
	<!-- <span id="in-words" style="color: red;"><b>NB. AUCUNE SOMME PAYEE N'EST EN AUCUN CAS REMBOURSABLE</b></span> /-->
	
	<?php

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

?>
