<?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 paiments table */
	$pointages_from = get_sql_from('pointages');
	if(!$pointages_from) exit(error_message('Access denied!', false));

	/* get invoice */
	$pointages_id = intval($_REQUEST['id_pointages']);
	if(!$pointages_id) exit(error_message('Invalid invoice ID!', false));
	
	/* retrieve pointages info */
	$pointages_fields = get_sql_fields('pointages');
	$res = sql("select {$pointages_fields} from {$pointages_from} and id_pointages={$pointages_id}", $eo);
	if(!($pointages = db_fetch_assoc($res))) exit(error_message('Invoice not found!', false));
	
	//var_dump($pointages);
	
	/* retrieve pointages items */
	$items = array();
	$pointages_total = 0;
	$item_fields = get_sql_fields('fiche_pointages');
	$item_from = get_sql_from('fiche_pointages');
	$res = sql("select {$item_fields} from {$item_from} and fiche_pointages.from_pointage={$pointages_id}", $eo);
	while($row = db_fetch_assoc($res)){
		$row['emargement'] = str_replace('$', '', $row['emargement']);
		$items[] = $row;
		//$pointages_total = ['emargement'];
	}
	
	//var_dump($items);
	
	?>
	
	<html>

<head>
    <title></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>
	
	
	<div>
		<center>
			<h6>Honneur-Fraternité-Justice</h6>
		</center>
		<h3>Ministère de l'Habitat de l'Urbanisme et de l'Aménagement du territoire</h3>
		<hr>
	</div>	
	<center>
	<h1>FICHE DE POINTAGE</h1>
	</center>



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

        <div class="col-sm-6 text-right">

        </div>
        <h2>Structure :
            <?php echo $pointages['structure']; ?>
        </h2>        
		<h2>Mois :
            <?php echo $pointages['mois']; ?>
        </h2>
    </div>

</div>

<hr>

<!-- pointages items -->
<table class="table table-striped table-bpointagesed">
    <thead>
        <th class="text-center">DATE</th>
        <th>NOM ET PRENOM</th>
        <th class="text-center">FONCTION</th>
        <th class="text-center">NNI</th>
        <th class="text-center">HEURE/ARRIVE</th>
        <th class="text-center">HEURE/DEPART</th>
        <th class="text-center">EMARGEMENT</th>
    </thead>

    <tbody>
        <?php foreach($items as $i => $item){ ?>
        <tr>
            <td class="text-center">
                <?php echo $item['date_fiche_pointage']; ?>
            </td>
            <td>
                <?php echo $item['nom_prenom_fp']; ?>
            </td>
            <td class="text-center">
                <?php echo $item['fonction_fp']; ?>
            </td>
            <td class="text-center">
                <?php echo $item['nni_fp']; ?>
            </td>
			<td class="text-center">
                <?php echo $item['heure_arrive']; ?>
            </td>			
			<td class="text-center">
                <?php echo $item['heure_depart']; ?>
            </td>			
			<td class="text-center">
                <?php echo $item['emargement']; ?>
            </td>
        </tr>

        <?php } ?>
    </tbody>

</table>


<?php

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

?>
