<?php
//define('ROOT_PATH', dirname(__FILE__));

Include("../includes/con_cliente.php");

//Include ROOT_PATH . '/includes/con_cliente.php';

 require_once('../connection.php');
    session_start();

    if(isset($_SESSION['User']))
    {
        $query="select * from tbusuario where nomeuser='".$_SESSION['User']."'";
        $result=mysqli_query($con,$query);
        $resultado = mysqli_fetch_assoc($result);
        $r_resultado = $resultado;
    }
    else
    {
        header("location:index.php");
    }


    $result_alunos = "SELECT * FROM tblcto WHERE lctvlrbaixado = 0 ORDER BY lctvencimento ASC ";
    $resultado_alunos = mysqli_query($con, $result_alunos);



    $c_fornecedor="SELECT DISTINCT lctfornecedor FROM tblcto ORDER BY lctfornecedor asc";
    $r_fornecedor= mysql_query($c_fornecedor);

    $c_grupo="SELECT DISTINCT lctgcusto FROM tblcto ORDER BY lctgcusto asc";
    $r_grupo= mysql_query($c_grupo);

    $c_centro="SELECT DISTINCT lctccusto FROM tblcto ORDER BY lctccusto asc";
    $r_centro= mysql_query($c_centro);

    $c_conta="SELECT DISTINCT lctcconta FROM tblcto ORDER BY lctcconta asc";
    $r_conta= mysql_query($c_conta);








?>


<html>
 <head>

    	<meta charset="utf-8" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
        
      <title>Sistema SCA - Grupo BRO</title>

      <link rel="stylesheet" href="../node_modules/bootstrap/compiler/bootstrap.css">
      <link rel="stylesheet" href="../node_modules/bootstrap/compiler/styler.css">

      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
      <link rel="stylesheet" href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" />
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

      <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

      <script src="jquery.maskMoney.js" type="text/javascript"></script>






 </head>

 <body>

     <nav class="navbar fixed-top navbar-expand-lg navbar-dark" style="background-color: #3333ff;">
      <a class="navbar-brand" href="menu.php">
            <img src="../img/logomarca.png" width="50" height="40" class="d-inline-block align-center" alt="">Inclusão de Lançamentos  -  <?php echo $resultado["nomeuser"];?>
            
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
        <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
        </ul>
        <form class="form-inline my-2 my-lg-0">
          <button class="btn btn-primary btn-sm my-2 my-sm-0">
            <a href="gdocumentos.php" style="color:inherit"> Voltar </a></button>
        </form>
      </div>
    </nav>

    <div class="container theme-showcase" role="main" style="margin-top: 8rem;">
      <div class="page-header">
        <h1>Ultimos Lançamentos</h1>
      </div>
      <div class="pull-right">
        <button type="button" class="btn btn-xs btn-success btn-sm" data-toggle="modal" data-target="#myModalcad">Novo</button>
      </div>
    </div>

      

      <!-- Inicio Modal CADASTRO -->
      <div class="modal fade" id="myModalcad" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close btn-sm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title w-100 text-center" id="myModalLabel">Novo Lançamento</h4>
            </div>
            <div class="modal-body">
              <form method="POST" action="http://189.1.26.66/sca/follow/processa_cadastro.php" enctype="multipart/form-data">
                <div class="form-group">
                  <label for="message-text" class="control-label">Empresa:</label>
                  <!--<input name="situacao" type="text" class="form-control"> -->
                  <select class="form-control" style="margin-top: -10px;" id="empresa" required name="empresa">
                        <option value="Brasil">BRASIL ORTOPEDIA</option>
                        <option value="Ajumed">AJUMED</option>
                        <option value="Orthomac">ORTHOMAC</option>
                        <option value="Best Care">BEST CARE</option>
                  </select>
                </div>

                <div class="form-group">
                  <label for="message-text" style="margin-top: -10px;" class="control-label">Fornecedor:</label>
                  <!--<input name="situacao" type="text" class="form-control"> -->
                  <select class="custom-select " style="margin-top: -10px;" id="fornecedor"  required name="fornecedor">
                    <option value="">Selecione o Fornecedor...</option>
                      <?php
                          while($l_fornecedor=mysql_fetch_array($r_fornecedor)){
                            echo "<option value='" .$l_fornecedor['0']."'>".$l_fornecedor['0']."</option>";
                          }
                      ?>
                  </select>
                </div>
                <div class="form-group">
                  <label for="message-text" style="margin-top: -10px;" class="control-label">Grupo de Custo:</label>
                  <select class="custom-select " style="margin-top: -10px;" id="grupo" required name="grupo">
                    <option value="">Selecione o Grupo de Custo...</option>
                      <?php
                          while($l_grupo=mysql_fetch_array($r_grupo)){
                            echo "<option value='" .$l_grupo['0']."'>".$l_grupo['0']."</option>";
                          }
                      ?>
                  </select>
                </div>
                <div class="form-group">
                  <label for="message-text" style="margin-top: -10px;" class="control-label">Centro de Custo:</label>
                  <select class="custom-select " id="centro" style="margin-top: -10px;" required name="centro">
                    <option value="">Selecione o Grupo de Custo...</option>
                      <?php
                          while($l_centro=mysql_fetch_array($r_centro)){
                            echo "<option value='" .$l_centro['0']."'>".$l_centro['0']."</option>";
                          }
                      ?>
                  </select>
                </div>
                <div class="form-group">
                  <label for="message-text" style="margin-top: -10px;" class="control-label">Conta de Custo:</label>
                  <select class="custom-select " id="conta" style="margin-top: -10px;" required name="conta">
                    <option value="">Selecione a Conta de Custo...</option>
                      <?php
                          while($l_conta=mysql_fetch_array($r_conta)){
                            echo "<option value='" .$l_conta['0']."'>".$l_conta['0']."</option>";
                          }
                      ?>
                  </select>
                </div>
                <div class="form-group">
                  <label for="recipient-name" style="margin-top: -10px;" class="control-label">Vencimento:</label>
                  <input class="form-control " style="margin-top: -10px;" required type="date" name="vencimento" >
                </div>
                <div class="form-group">
                  <label for="recipient-name" style="margin-top: -10px;" class="control-label">Valor R$:</label>
                  <input class="form-control " style="margin-top: -10px;" placeholder="R$ 0,00" required type="number" name="dataini" >
                </div>
                
                <div class="modal-footer">
                  <button type="submit" class="btn btn-warning btn-sm">Cadastrar e Sair</button>
                  <button type="submit" class="btn btn-success btn-sm">Cadastrar e Novo</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
      <!-- Fim Modal CADASTRO -->
      
      <div class="row mx-5">
        <div class="table-responsive-xl">
          <!--<table class="table table-sm"> -->
          <table style="font-size: 9px; overflow: auto;" class="table table-striped table-responsive-md btn-table table-hover table-bordered">
            <thead>
              <tr class="info">
                <th>Id</th>
                <th>Empresa</th>
                <th>Fornecedor</th>
                <th>Grupo</th>
                <th>C.Custo</th>
                <th>Conta</th>
                <th>Valor R$</th>
                <th>Vencimento</th>

              </tr>
            </thead>
            <tbody>
              <?php while($rows_alunos = mysqli_fetch_assoc($resultado_alunos)){ ?>
                <tr onclick="location.href = 'detalheprocesso.php?id=<?php echo $rows_alunos['id']; ?>'" style="cursor: hand;">
                  <td><?php echo $rows_alunos['idmov']; ?></td>
                  <td><?php echo $rows_alunos['lctempresas']; ?></td>
                  <td><?php echo $rows_alunos['lctfornecedor']; ?></td>
                  <td><?php echo $rows_alunos['lctgcusto']; ?></td>
                  <td><?php echo $rows_alunos['lctccusto']; ?></td>
                  <td><?php echo $rows_alunos['lctcconta']; ?></td>
                  <td><?php echo $rows_alunos['lctvlrdcto']; ?></td>
                  <td><?php echo $rows_alunos['lctvencimento']; ?></td>
                  <td>
                    <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal<P><?php echo $rows_alunos['aplicacao']; ?></P>">Visualizar</button>
                    
                    <button type="button" class="btn btn-warning btn-sm" data-toggle="modal" data-target="#exampleModal" data-whatever="<?php echo $rows_alunos['aplicacao']; ?>" data-whateverstatus="<?php echo $rows_alunos['Status']; ?>" data-whatevermatricula="<?php echo $rows_alunos['id']; ?>">
                      Editar
                  </td>
                </tr>
                <!-- Modal VISUALIZA -->
                <div class="modal fade" id="myModal<P><?php echo $rows_alunos['tipo']; ?></P>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                  <div class="modal-dialog" role="document">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title w-100 text-center" id="myModalLabel"><?php echo $rows_alunos['tipo']; ?></h4>
                      </div>
                      <div class="modal-body">
                        <P>Id: <?php echo $rows_alunos['id']; ?></P>
                        <P>Controle de Validade: <?php echo $rows_alunos['validade']; ?></P>
                        <P>Situação: <?php echo $rows_alunos['Status']; ?></P>
                        <P>Alteração: <?php echo $rows_alunos['controle']; ?></P>
                        <P>Usuário: <?php echo $rows_alunos['usuario']; ?></P>
                      </div>
                    </div>
                  </div>
                </div>
                <!-- FIM Modal VISUALIZA -->
              <?php } ?>
            </tbody>
           </table>
        </div>
      </div>    
    <!--</div> -->

    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title w-100 text-center" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
            <form method="POST" action="http://192.168.0.12/sca/alteratipo.php" enctype="multipart/form-data">
              <div class="form-group">
                <label for="recipient-name" class="control-label">Documento:</label>
                <input name="professor" type="text" class="form-control" id="recipient-name">
              </div>
              <div class="form-group">
                <label for="message-text" class="control-label">Situação:</label>
                <!--<input name="situacao" type="text" class="form-control" id="recipient-situacao"> -->
                <select class="form-control" id="recipient-situacao" required name="situacao">
                        <option value="Ativo">Ativo</option>
                        <option value="Inativo">Inativo</option>
                  </select>

              </div>
              <div class="form-group">
                <label for="message-text" class="control-label">Controla Validade:</label>
                <!--<input name="situacao" type="text" class="form-control" id="recipient-situacao"> -->
                <select class="form-control" id="recipient-validade" required name="validade">
                        <option value="Sim">Sim</option>
                        <option value="Não">Não</option>
                  </select>

              </div>
              <input name= "matricula" type="hidden" id="recipient-matricula">
              <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Cancelar</button>
                <button type="submit" class="btn btn-danger">Alterar</button>
              </div>
            </form>
          </div>
          
        </div>
      </div>
    </div>




    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>

    <script type="text/javascript">

    $('#exampleModal').on('show.bs.modal', function (event) {
      var button = $(event.relatedTarget) // Button that triggered the modal
      var recipient = button.data('whatever')
      var recipientstatus = button.data('whateverstatus')
      var recipientvalidade = button.data('whatevervalidade')
      var recipientmatricula = button.data('whatevermatricula')

      var modal = $(this)
      modal.find('.modal-title').text('Id: ' + recipientmatricula)
      modal.find('#recipient-name').val(recipient)
      modal.find('#recipient-situacao').val(recipientstatus)
      modal.find('#recipient-validade').val(recipientvalidade)
      modal.find('#recipient-matricula').val(recipientmatricula)
    })

  </script>


  </body>
</html>

