<?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-info btn-sm" data-toggle="modal" data-target="#exampleModal">
<i class="fa fa-plus" aria-hidden="true"></i> Conta cliente
</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">Contas</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-8">
                <form action="" method="post">
                   <?php addAccount();?>
                      <div class="form-group">
                        <label for="product_category">Cliente</label>
                        <select required name="cliente"  class="form-control">
                            <option></option>
                            <?php busca_cliente();?>
                          
                            </select>
                    </div>
                    
					<div class="form-group">
                        <label for="product_name">Conta</label>
                        <input type="number" name="conta" autocomplete="off" class="form-control" required/>
                    </div>
                    
                    <div class="form-group">
                        <label for="product_name">Banco</label>
                        <input type="text" name="banco" autocomplete="off" class="form-control" required/>
                    </div>
                    
                    <div class="form-group">
                        <label for="product_name">Agencia</label>
                        <input type="text" name="agencia" autocomplete="off" class="form-control" required/>
                    </div>
                                       
                         <div class="form-group">
                        <button type="submit" name="submitConta" class="btn btn-info btn-sm"><span>Cadastrar</span></button>
                    </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>

<!-- BUTTON AND FUNCTION ADD STOCK Modal END -->




       </div></div>
<hr>
       <h5><i class="fa fa-users" aria-hidden="true"></i> Lista de clientes</h5>
        
      
        <table class="table">
             <thead>
                <tr>
                    <th>Item</th>
                    <th>Nome do cliente</th>
                    <th>Conta bancaria</th>
					<th>Agencia</th>
					<th>Banco</th>
				     <th>Editar</th>
                    <th>Deletar</th>
                </tr>
            </thead>
            <tbody>   
                 <?php
                 $item=1;
                 
                 $busca = mysqli_query($con,"SELECT * FROM banco_cliente");
                 while($row = mysqli_fetch_assoc($busca)){
                 ?>
                <tr>
                   <td><?php echo $item++;?></td>
                    <td><?php echo $row['cliente'];?></td>
                    <td><?php echo $row['conta'];?></td>
					<td><?php echo $row['agencia'];?></td>
					<td><?php echo $row['banco'];?></td>
				                    <!-- Button trigger modal -->
    <td><button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#exampleModal2<?php echo $row['id'];?>">
    <i class="fa fa-paint-brush" aria-hidden="true"></i>
</button></td>

<!-- Modal -->
<div class="modal fade" id="exampleModal2<?php echo $row['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">
        <h5 class="modal-title" id="exampleModalLabel">Cliente</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-8">
                <form action="" method="post">
                    <?php updateConta();?>
                  
					<div class="form-group">
                        <label for="product_category">Cliente</label>
                        <select required name="cliente"  class="form-control">
                            <option><?php echo $row['cliente'];?></option>
                            <?php busca_cliente();?>
                            </select>
                    </div>
                    
					<div class="form-group">
                        <label for="product_name">Conta</label>
                        <input type="number" name="conta" autocomplete="off" class="form-control" value="<?php echo $row['conta'];?>" required/>
                    </div>
                    
                    	<div class="form-group">
                        <label for="product_name">Banco</label>
                        <input type="text" name="banco" autocomplete="off" class="form-control" value="<?php echo $row['banco'];?>" required/>
                    </div>
                    
                    	<div class="form-group">
                        <label for="product_name">Agencia</label>
                        <input type="text" name="agencia" autocomplete="off" class="form-control" value="<?php echo $row['agencia'];?>" required/>
                    </div>
                    
                        <input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
                         <div class="form-group">
                        <button type="submit" name="updateClienteConta" class="btn btn-info btn-sm"><span>Actualizar</span></button>
                    </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>
                    
          

 <?php if($_SESSION['nivel'] == 1){ ?>
  <td><button type="button" class="btn btn-danger btn-sm"><a href="conta_cliente.php?delete=<?php echo $row['id'];?>"
                 style="text-decoration:none; color:white"><span><i class="fa fa-trash" aria-hidden="true"></i></span></a>
                </button></td>
              <?php }else{
                    echo "<td>N/A</td>";
              }?>
             
                
                    </tr>
           <?php }
           deleteConta();
           
           ?>      
             
            </tbody>
        </table>
        
        </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>
