<?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">

          <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#exampleModalLong1">
  <span><i class="fa fa-table" aria-hidden="true"></i> Folha de salario</span>
</button>

<!-- 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">
       <div class="container">
        <div class="col-sm-10">
         
        <form action="salariosFinal.php" method="post">
          <div class="form-group">
            <label for="mes_salario">Mes</label>
            <select required name="mes_salario" class="form-control">
            <option></option>
                <option>Janeiro</option>
                <option>Fevereiro</option>
                <option>Marco</option>
                <option>Abril</option>
                <option>Maio</option>
                <option>Junho</option>
                <option>Julho</option>
                <option>Agosto</option>
                <option>Setembro</option>
                <option>Outubro</option>
                <option>Novembro</option>
                <option>Dezembro</option>
            </select>
          </div>
          <div class="form-group">
            <button type="submit" name="btn_folha" class="btn btn-info btn-sm"><span>Submeter</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>   
   
 <br> <br>
 <div class="container-fluid">

<!-- Breadcrumbs-->

<!-- DataTables Example -->
<div class="card mb-3">
  <div class="card-header">
    <i class="fas fa-table"></i>
    <b>Processamento de salarios</b></div>
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
        <thead>
          <tr>
            <th>Item</th>
            <th>Nome</th>
            <th>Salario Base</th>
            <th>Processar</th>
            <th>Historico</th>
          </tr>
        </thead>
       
        <tbody>
            
          <?php 
          $item =1;
          $functionarios = $database->query("SELECT * FROM funcionarios WHERE status='Activo'");
          while($row = $database->fetch_assoc($functionarios)){
           
            $id = $row['id'];
           $salarioBase = $row['salario'];

           $inss = $salarioBase * 0.03;
           $irps = $salarioBase * 0.04;
          

            $today = date('Y-m-d');
            ?>
           <tr>   
            <td><?php echo $item++;?></td>
            <td><?php echo $row['nome'];?></td>
            <td><?php echo number_format($salarioBase,2,",",".");?></td>
             
    <td><button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#exampleModal<?php echo $id;?>">
  <i class="fas fa-fw fa-plus"></i> Pagar
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModal<?php echo $id;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h3 class="modal-title" id="exampleModalLabel"><font color='brown'><?php echo $row['nome'];?></font></h3>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
          <div class="container">
              <div class="col-sm-10">
                  
             
          <form action="paySalarios.php" method="post" enctype="multipart/form-data">
			 <div class="form-group">
			  <label for="bi">Mes</label>
             <select required name="mes_salario" class="form-control">
                <option></option>
                <option>Janeiro</option>
                <option>Fevereiro</option>
                <option>Marco</option>
                <option>Abril</option>
                <option>Maio</option>
                <option>Junho</option>
                <option>Julho</option>
                <option>Agosto</option>
                <option>Setembro</option>
                <option>Outubro</option>
                <option>Novembro</option>
                <option>Dezembro</option>
             </select>
            </div>

             <div class="form-group">
			  <label for="bi">Salario base</label>
			  <input type="number" name="salarioBase" value="<?php echo $salarioBase;?>" class="form-control" autocomplete="off" required/>
			 </div>

             <div class="form-group">
			  <label for="bi">Faltas</label>
			  <input type="number" name="faltas" class="form-control" autocomplete="off" required/>
			 </div>
              
             <div class="form-group">
			  <label for="bi">Outros Descontos internos</label>
			  <input type="number" name="descontosInternos" class="form-control" autocomplete="off" required/>
			 </div>

             <div class="form-group">
			  <label for="bi">Inss 3%</label>
			  <input type="number" name="inss" class="form-control" value="<?php echo $inss;?>" autocomplete="off" required/>
			 </div>
             <div class="form-group">
			  <label for="bi">Irps 4%</label>
			  <input type="number" name="irps" class="form-control" value="<?php echo $irps;?>" autocomplete="off" required/>
			 </div>

             <div class="form-group">
			  <label for="bi">Bonus mensal</label>
			  <input type="number" name="bonus" class="form-control" autocomplete="off" required/>
			 </div>

             <input type="hidden" name="nome" value="<?php echo $row['nome'];?>"/>
			
			 <div class="form-group">
			  <input type="submit" name="submitSalario" class="btn btn-primary btn-block" value="Enviar"/>
			 </div>
	
		   </form>
         </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
      </div>
    </div>
  </div>
</div>
   
          
<td><button type="button" class="btn btn-success btn-sm"><a href="historico.php?id=<?php echo $id;?>" style="text-decoration:none; color:white;"><i class="fas fa-fw fa-print"></i></a></button></td>

         
        
 
          




        </tr>
        
        <?php }
          
          ?>  

         
      
   
               </tbody>
      </table>
    </div>
  </div>
  <div class="card-footer small text-muted">Jonas Dinis Chambela</div>
</div>



</div>

        </div>
      </div>
      <!-- /.container-fluid -->
		  </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";?>
 <?php include "includes/sweatscripFooter.php";?>

