<?php include "includes/header.php";?>

<?php include "includes/navbar.php";?>

  <div id="wrapper">

    <!-- Sidebar -->
   <?php include "includes/sidebar.php";?>

    <div id="content-wrapper">

      <div class="container-fluid">

        <!-- Breadcrumbs-->
        <ol class="breadcrumb">
          <li class="breadcrumb-item">
            <a href="#">Ola</a>
          </li>
          <li class="breadcrumb-item active"><?php echo $_SESSION['nome'];?></li>
        </ol>

        <!-- Icon Cards-->
        <div class="row">
       
	    <div class="container">
	        
	        
	     <?php 
	     if(isset($_GET['func']) && !empty($_GET['func'])){
	         
	         $worker = $_GET['func'];
	     }
	     
	     ?>   
	        
	        <td><button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#exampleModalLong1">
  <span>Submeter fereas</span>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle"></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">        
        <p><h5>Confirmar ferias de <font color="red"><?php echo $worker;?></font></h5></p>

        <div class="container">
          <div class="col-sm-8">

            <form action="includes/code.php" method="post">
              <div class="form-group">
                <label for="data_inicio">Data inicio</label>
                <input type="date" name="data_inicio" class="form-control" required/>
              </div>

              <div class="form-group">
                <label for="data_fim">Data Fim</label>
                <input type="date" name="data_fim" class="form-control" required/>
              </div>
              
              <input type="hidden" name="nome" value="<?php echo $worker;?>"/>

              <div class="form-group">
              <button type="submit" class="btn btn-info btn-sm" name="submitFerias"><span>Confirmar</span></button>

              </div>
            </form>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Cancelar</button>
      </div>
    </div>
  </div>
</div>

<table class="table">
    <thead>
        <tr>
            <th>Item</th>
            <th>Nome</th>
            <th>Data inicio</th>
            <th>Data fim</th>
            <th>Numero de dias</th>
            <th>Dias em falta</th>
            <th>Ano</th>
            <th></th>
        </tr>
        <tbody>
            <?php 
            $item=1;
            $seleciona = $database->query("SELECT * FROM ferias WHERE nome='$worker'");
            while($row = $database->fetch_assoc($seleciona)){
            ?>
            <tr>
                <td><?php echo $item++;?></td>
                 <td><?php echo $row['nome'];?></td>
                  <td><?php echo $row['data_inicio'];?></td>
                   <td><?php echo $row['data_fim'];?></td>
                    <td><?php echo $row['numero_dias'];?></td>
                    <td><?php echo 30 - $row['numero_dias'];?></td>
                     <td><?php echo $row['ano'];?></td>
            </tr>
            <?php }?>
        </tbody>
    </thead>
</table>
	        
	    </div>
	   
        
        
        </div>

     
        

      </div>
      <!-- /.container-fluid -->

      <!-- Sticky Footer -->
      <?php include "includes/footer.php";?>

    </div>
    <!-- /.content-wrapper -->

  </div>
  <!-- /#wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
 <?php include "includes/logout_modal.php";?>

  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Page level plugin JavaScript-->
  <script src="vendor/chart.js/Chart.min.js"></script>
  <script src="vendor/datatables/jquery.dataTables.js"></script>
  <script src="vendor/datatables/dataTables.bootstrap4.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="js/sb-admin.min.js"></script>

  <!-- Demo scripts for this page-->
  <script src="js/demo/datatables-demo.js"></script>
  <script src="js/demo/chart-area-demo.js"></script>

</body>

</html>
