<?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 trigger modal -->
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#exampleModal">
  <i class="fas fa-fw fa-plus"></i> Funcionários
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Cadastrar</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="includes/code.php" method="post" enctype="multipart/form-data">
              <?php //$funcionario->AddEmploy();?>
			<div class="form-group">
			  <label for="nome_cliente">Nome complecto</label>
			  <input type="text" name="nome" class="form-control" autocomplete="off" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="bairro">Endereco</label>
			  <input type="text" name="endereco" class="form-control" autocomplete="off" required/>
			 </div>
			
			 
			 <div class="form-group">
			  <label for="nuit">Nuit</label>
			  <input type="number" name="nuit" class="form-control" autocomplete="off" required/>
			 </div>

             
			 <div class="form-group">
			  <label for="nuit">Numero INSS</label>
			  <input type="number" name="inss" class="form-control" autocomplete="off" required/>
			 </div>
			 
			  <div class="form-group">
			  <label for="nuit">Nacionalidade</label>
			  <input type="text" name="nacionalidade" class="form-control" autocomplete="off" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="bi">B.I/Passaporte/Carta de conducao</label>
			  <input type="text" name="bi" class="form-control" autocomplete="off" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="estado">Estado Civil</label>
			  <select required name="estado_civil" class="form-control">
			   <option></option>
			   <option>Casado(a)</option>
			   <option>Solteiro(a)</option>
			   <option>Viuvo(a)</option>
			   <option>Divorciado(a)</option>
			  </select>
			 </div>
			 
			 <div class="form-group">
			  <label for="provincia">Provincia</label>
			  <select required name="provincia" class="form-control">
			   <option></option>
			   <option>Maputo</option>
			   <option>Gaza</option>
			   <option>Inhambane</option>
			   <option>Manica</option>
			   <option>Sofala</option>
			   <option>Tete</option>
			   <option>Zambezia</option>
			   <option>Nampula</option>
			   <option>Niassa</option>
			   <option>Cabo Delegado</option>
			    </select>
			 </div>
			 <div class="form-group">
			  <label for="bi">Data de emissao</label>
			  <input type="date" name="data_emissao" class="form-control" autocomplete="off" required/>
			 </div>
			 		 
			 <div class="form-group">
			  <label for="local_emissao">Local de emissao</label>
			  <select required name="local_emissao" class="form-control">
			   <option></option>
			   <option>Matola</option>
			   <option>Maputo</option>
			   <option>Gaza</option>
			   <option>Inhambane</option>
			   <option>Manica</option>
			   <option>Sofala</option>
			   <option>Tete</option>
			   <option>Zambezia</option>
			   <option>Nampula</option>
			   <option>Niassa</option>
			   <option>Cabo Delegado</option>
			     </select>
			 </div>
             
			  <div class="form-group">
			  <label for="bi">Data de nascimento</label>
			  <input type="date" name="data_nasc" class="form-control" autocomplete="off" required/>
			 </div>
	
		   
		   <div class="form-group">
			  <label for="cell1">Contacto</label>
			  <input type="number" name="contacto" class="form-control" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell2">Contacto de um parente</label>
			  <input type="number" name="contacto_2" class="form-control" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell3">Nome do parente</label>
			  <input type="text" name="nome_parente" class="form-control" autocomplete="off">
			 </div>
						 
			  <div class="form-group">
			  <label for="cell1">Salario base</label>
			  <input type="number" name="salario" class="form-control" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell2">Curriculum vitae</label>
			  <input type="file" name="cv" class="form-control" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell3">Foto meio corpo</label>
			  <input type="file" name="foto" class="form-control" autocomplete="off">
			 </div>
			 
			  
			 
			 <div class="form-group">
			  <label for="cell3">Data de contratação</label>
			  <input type="date" name="data_contracto" class="form-control" autocomplete="off">
			 </div>
			 <div class="form-group">
			  <input type="submit" name="submitFunc" 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>

 <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>Lista de funcionarios</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>Contacto</th>
            <th>Contacto 2</th>
             <th>Editar</th>
            <th>Apagar</th>
              <th>Ficha</th>
              <th>Contracto</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'];
            ?>
           <tr>   
            <td><?php echo $item++;?></td>
            <td><?php echo $row['nome'];?></td>
            <td><?php echo $row['contacto'];?></td>
            <td><?php echo $row['contacto_2'];?></td>
                   <td>
                <!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#exampleModalLong<?php echo $id;?>">
  <span><i class="fa fa-paint-brush" aria-hidden="true"></i></span>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong<?php echo $id;?>" 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"><font color='red'><?php echo $row['nome'];?></font></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="" method="post" enctype="multipart/form-data">
		    <?php $funcionario->updateEmploy();?>
			<div class="form-group">
			  <label for="nome_cliente">Nome complecto</label>
			  <input type="text" name="nome" class="form-control" value="<?php echo $row['nome'];?>" autocomplete="off" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="bairro">Endereco</label>
			  <input type="text" name="endereco" class="form-control" value="<?php echo $row['endereco'];?>" autocomplete="off" required/>
			 </div>
			
			 
			 <div class="form-group">
			  <label for="nuit">Nuit</label>
			  <input type="number" name="nuit" class="form-control" value="<?php echo $row['nuit'];?>" autocomplete="off" required/>
			 </div>

             
			 <div class="form-group">
			  <label for="nuit">Numero INSS</label>
			  <input type="number" name="inss" class="form-control" value="<?php echo $row['inss'];?>" autocomplete="off" required/>
			 </div>
			 
			  <div class="form-group">
			  <label for="nuit">Nacionalidade</label>
			  <input type="text" name="nacionalidade" class="form-control" value="<?php echo $row['nacionalidade'];?>" autocomplete="off" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="bi">B.I/Passaporte/Carta de conducao</label>
			  <input type="text" name="bi" class="form-control" autocomplete="off" value="<?php echo $row['bi'];?>" required/>
			 </div>
			 
			 <div class="form-group">
			  <label for="estado">Estado Civil</label>
			  <select required name="estado_civil" class="form-control">
			   <option><?php echo $row['estado_civil'];?></option>
			   <option>Casado(a)</option>
			   <option>Solteiro(a)</option>
			   <option>Viuvo(a)</option>
			   <option>Divorciado(a)</option>
			  </select>
			 </div>
			 
			 <div class="form-group">
			  <label for="provincia">Provincia</label>
			  <select required name="provincia" class="form-control">
			   <option><?php echo $row['provincia'];?></option>
			   <option>Maputo</option>
			   <option>Gaza</option>
			   <option>Inhambane</option>
			   <option>Manica</option>
			   <option>Sofala</option>
			   <option>Tete</option>
			   <option>Zambezia</option>
			   <option>Nampula</option>
			   <option>Niassa</option>
			   <option>Cabo Delegado</option>
			    </select>
			 </div>
			 <div class="form-group">
			  <label for="bi">Data de emissao</label>
			  <input type="date" name="data_emissao" class="form-control"  autocomplete="off" required/>
			 </div>
			 		 
			 <div class="form-group">
			  <label for="local_emissao">Local de emissao</label>
			  <select required name="local_emissao" class="form-control">
			   <option><?php echo $row['local_emissao'];?></option>
			   <option>Matola</option>
			   <option>Maputo</option>
			   <option>Gaza</option>
			   <option>Inhambane</option>
			   <option>Manica</option>
			   <option>Sofala</option>
			   <option>Tete</option>
			   <option>Zambezia</option>
			   <option>Nampula</option>
			   <option>Niassa</option>
			   <option>Cabo Delegado</option>
			     </select>
			 </div>
             
			  <div class="form-group">
			  <label for="bi">Data de nascimento</label>
			  <input type="date" name="data_nasc" class="form-control" autocomplete="off" required/>
			 </div>
	
		   
		   <div class="form-group">
			  <label for="cell1">Contacto</label>
			  <input type="number" name="contacto"  class="form-control" value="<?php echo $row['contacto'];?>" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell2">Contacto de um parente</label>
			  <input type="number" name="contacto_2" class="form-control" value="<?php echo $row['contacto_2'];?>" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell3">Nome do parente</label>
			  <input type="text" name="nome_parente" class="form-control" value="<?php echo $row['nome_parente'];?>" autocomplete="off">
			 </div>
						 
			  <div class="form-group">
			  <label for="cell1">Salario base</label>
			  <input type="number" name="salario" class="form-control" value="<?php echo $row['salario'];?>" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell2">Curriculum vitae</label>
			  <input type="file" name="cv" class="form-control" autocomplete="off">
			 </div>
			 
			 <div class="form-group">
			  <label for="cell3">Foto meio corpo</label>
			  <input type="file" name="foto" class="form-control" autocomplete="off">
			 </div>
			 
			  <input type="hidden" name="id" value="<?php echo $id;?>">
			 
			 <div class="form-group">
			  <label for="cell3">Data de contratação</label>
			  <input type="date" name="data_contracto" class="form-control" autocomplete="off">
			 </div>
			 <div class="form-group">
			  <input type="submit" name="updateFunc" 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">Close</button>
      </div>
    </div>
  </div>
</div>
              
                        <!-- Button trigger modal -->
<td><button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#exampleModalLong1<?php echo $id;?>">
  <span><i class="fa fa-trash" aria-hidden="true"></i></span>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong1<?php echo $id;?>" 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">
          <?php $funcionario->deleteFunc();?>
        <p><h3>Deseja eliminar <font color="red"><?php echo $row['nome'];?>?</font></h3></p>
        <button type="button" class="btn btn-danger btn-sm"><a href="functionarios.php?delete=<?php echo $id;?>" style="text-decoration:none; color:white"><span>Confirmar</span></a></button>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Cancelar</button>
      </div>
    </div>
  </div>
</div>
          
       <td><button type="button" class="btn btn-info btn-sm">
		  <a href="ficha_trabalhador.php?id=<?php echo $id;?>" style="text-decoration:none; color:white;"><span>Ficha</span></a></button></td>      
         
          <td><button type="button" class="btn btn-info btn-sm">
		  <a href="contracto_func.php?id=<?php echo $id;?>" style="text-decoration:none; color:white;"><span>Contracto</span></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";?>

