<?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-warning btn-sm" data-toggle="modal" data-target="#exampleModal">
  <i class="fas fa-fw fa-plus"></i> Processo
</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">
			<div class="form-group">
			  <label for="nome_cliente">Nome complecto</label>
              <select required name="nome" class="form-control">
                <option></option>
                <?php $funcionario->takeFunc();?>
              </select>
            </div>
			 
			 <div class="form-group">
			  <label for="motivo">Motivo do processo</label>
              <textarea name="motivo" class="form-control" row="14px" col="24px"></textarea>
            </div>
			
			
		
			 <div class="form-group">
			  <label for="bi">Data do processo</label>
			  <input type="date" name="data_processo" class="form-control" autocomplete="off" required/>
			 </div>

             <div class="form-group">
			  <label for="bi">Prazo de resposta</label>
			  <input type="date" name="data_prazo" class="form-control" autocomplete="off" required/>
			 </div>
			
			 <div class="form-group">
			  <input type="submit" name="submitDisciplinar" 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 processos disciplinares</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>Data do processo</th>
            <th>Data de limite</th>
             <th>P.disciplinar</th>
              <th>Estado</th>
              <th>Apagar</th>
          </tr>
        </thead>
       
        <tbody>
            
          <?php 
          $item =1;
          $functionarios = $database->query("SELECT * FROM processos_disciplinares");
          while($row = $database->fetch_assoc($functionarios)){
            
            $id = $row['id'];

            $estado = $row['status'];
            ?>
           <tr>   
            <td><?php echo $item++;?></td>
            <td><?php echo $row['nome'];?></td>
            <td><?php echo $row['data_processo'];?></td>
            <td><?php echo $row['data_prazo'];?></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><i class="fa fa-print" aria-hidden="true"></i></span></a></button></td> 
        
        
       <?php 
       if($estado == "pendente"){
        ?>
<td><button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#exampleModalLongstatus<?php echo $id;?>">
  <span>Pendente</span>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModalLongstatus<?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 $discipline->Answers();?>
			 <div class="form-group">
			  <label for="motivo">Resposta do processo</label>
              <textarea name="resposta" class="form-control" row="14px" col="24px"></textarea>
            </div>	
            <input type="hidden" name="id" value="<?php echo $id;?>"/>		
			 <div class="form-group">
			  <input type="submit" name="submitAnswer" class="btn btn-primary btn-block" value="Enviar"/>
			 </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>

       <?php }else{
        ?>
<td><button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#exampleModalLong12<?php echo $id;?>">
  <span>Respondindo</span>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong12<?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">
        <p><?php echo $row['resposta'];?></p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Cancelar</button>
      </div>
    </div>
  </div>
</div>


       <?php }
       
       ?> 
          




                                  <!-- 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 $discipline->deleteProcesso();?>
        <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="disciplinares.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>
        </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";?>

