<?php include_once('../../config.php') ?>

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Liberação Ordem de Compra</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.251.16.1">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.251.16.1">
  <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,600,700,400italic' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="dist/css/custom.css?versao=3.251.16.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.251.16.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.251.16.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.251.16.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.251.16.1">
  <link rel="stylesheet" href="dist/css/select.bootstrap.min.css?versao=3.251.16.1" />
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.251.16.1" />
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.251.16.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.251.16.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.251.16.1">
  <style>
    .radioStyle {
      border: solid #e0e4e6;
      border-radius: 4px;
      border-width: 2px;
      padding: 7.25px;
      height: 136px;
    }

    .campoSel {
      display: inline-block;
      position: absolute;
      width: 22px;
      height: 22px;
      border: 1px solid #D3CFC8;
      border-radius: 0;
    }

    .border-Field .textoBorda {
      font-size: 1.1em !important;
      text-align: left !important;
      width: auto;
      padding: 0 10px;
      border-bottom: none;
    }

    .border-Field {
      border: 1px solid var(--font-color) !important;
      padding: 0 1.0em 0 1.0em !important;
      margin: 0 0 0 0 !important;
      -webkit-box-shadow: 0px 0px 0px 0px #000;
      box-shadow: 0px 0px 0px 0px #000;
      border-radius: 3px !important;
    }

    #tabelaOc tbody td {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      padding: 0 !important;
      padding-left: 10px !important;
    }

    .card {
      padding: 1.5rem;
      border-top: 2px outset #ddd;
      box-shadow: none !important;
      margin-top: 20px;
      padding-top: 20px;
    }
  </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
  <div class="wrapper">

    <div class="content-wrapper">
      <section class="content">
        <div class="content-header">
          <div class="container-fluid">
            <div class="row mb-2">
              <div class="col-sm-6 flex">
              </div>
              <div class="col-sm-6">
                <!-- <ol class="breadcrumb float-sm-right">
                  
                  <li class="breadcrumb-item active">Liberação O.C</li>
                </ol> -->
              </div><!-- /.col -->
              <div class="container-fluid" id="grad1">
                <div class="row justify-content-center mt-0">
                  <div class="col-12">
                    <div class="card mb-0">
                      <div class="card-header" style="border: none!important;box-shadow:none!important;">
                        <h2 class="m-0">Liberação de Ordem de Compra
                          <button title="Tutorial" type="button" class="btn btn-info btn-sm ml-2" style="color: white;" id="tutorial">
                            <i class="fas fa-question-circle"></i>
                          </button>
                        </h2>
                      </div>
                      <div class="container-fluid">
                        <div class="row card-body" id="abaGeral">
                          <div id="tutorialFiltros" class="row card-body">
                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtDtEntregaDe">Período Entrega De/Até:</label>
                              <div class="input-group">
                                <input type="date" max="2500-12-31" class="input-default focus form-control mr-1" id="txtDtEntregaDe" name="txtDtEntregaDe">
                                <input type="date" max="2500-12-31" class="input-default focus form-control" id="txtDtEntregaAte" name="txtDtEntregaAte">
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtDtEmissaoDe">Período Emissão De/Até:</label>
                              <div class="input-group">
                                <input type="date" max="2500-12-31" class="input-default focus form-control mr-1" id="txtDtEmissaoDe" name="txtDtEmissaoDe">
                                <input type="date" max="2500-12-31" class="input-default focus form-control" id="txtDtEmissaoAte" name="txtDtEmissaoAte">
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtDtLiberadosDe">Liberados De/Até:</label>
                              <div class="input-group">
                                <input type="date" max="2500-12-31" class="input-default focus form-control mr-1" id="txtDtLiberadosDe" name="txtDtLiberadosDe">
                                <input type="date" max="2500-12-31" class="input-default focus form-control" id="txtDtLiberadosAte" name="txtDtLiberadosAte">
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtOc">Ordens de Compra: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtOc" name="txtOc" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnOc" name="btnOc" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaOc" name="btnLimpaOc" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtFornecedor">Fornecedor: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtFornecedor" name="txtFornecedor" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnFornecedor" name="btnFornecedor" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaFornecedor" name="btnLimpaFornecedor" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtStatus">Status: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtStatus" name="txtStatus" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnStatus" name="btnStatus" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaStatus" name="btnLimpaStatus" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtUserLib">Usuário Liberação: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtUserLib" name="txtUserLib" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnUserLib" name="btnUserLib" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaUserLib" name="btnLimpaUserLib" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtUserCadOC">Usuário Cad. OC: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtUserCadOC" name="txtUserCadOC" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnUserCadOC" name="btnUserCadOC" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaUserCadOC" name="btnLimpaUserCadOC" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-lg-4 form-group">
                              <label data-error="wrong" data-success="right" for="txtMaterial">Material: </label>
                              <div class="input-group">
                                <select class="js-example-programmatic js-states form-control" id="txtMaterial" name="txtMaterial" multiple="multiple"></select>
                                <div class="input-group-append">
                                  <button class="btn bg-danger" id="btnMaterial" name="btnMaterial" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                  <button class="btn bg-danger" id="btnLimpaMaterial" name="btnLimpaMaterial" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                </div>
                              </div>
                            </div>

                            <div class="col-sm-3 form-group d-flex">
                              <fieldset class="w-100 form border-Field mb-0 pb-0">
                                <legend class="textoBorda mb-0 pb-0">Filtro</legend>
                                <div class="">
                                  <div class="icheck-primary"><input type="radio" checked="checked" id="radioTodos" name="filtro"><label class="container p-0 m-0" for="radioTodos">Todos </label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioAnalise" name="filtro"> <label class="container p-0 m-0" for="radioAnalise">Em Análise </label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioLiberados" name="filtro"><label class="container p-0 m-0" for="radioLiberados">Liberados</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioRejeitados" name="filtro"><label class="container p-0 m-0" for="radioRejeitados">Rejeitados</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioBloqueados" name="filtro"><label class="container p-0 m-0" for="radioBloqueados">Bloqueados</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioBloqDir" name="filtro"><label class="container p-0 m-0" for="radioBloqDir">Bloq./Diretoria</label></div>
                                </div>
                              </fieldset>
                            </div>


                            <div class="col-sm-3 form-group d-flex">
                              <fieldset class="w-100 form border-Field mb-0 pb-0">
                                <legend class="textoBorda mb-0 pb-0">Hierarquia</legend>
                                <div class="">
                                  <div class="icheck-primary"><input type="radio" checked="checked" id="radioTodosHierarquia" name="hierarquia"><label for="radioTodosHierarquia" class="container p-0 m-0">Todos</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioAguardandoLib" name="hierarquia"><label for="radioAguardandoLib" class="container p-0 m-0">Aguardando Lib.</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioDispLib" name="hierarquia"><label for="radioDispLib" class="container p-0 m-0">Disp. Liberação</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioJaLiberado" name="hierarquia"><label for="radioJaLiberado" class="container p-0 m-0">Já Liberado</label></div>
                                </div>
                              </fieldset>
                            </div>

                            <div class="col-sm-3 form-group d-flex">
                              <fieldset class="w-100 form border-Field mb-0 pb-0">
                                <legend class="textoBorda mb-0 pb-0">Tipo</legend>
                                <div class="">
                                  <div class="icheck-primary"><input type="radio" checked="checked" id="radioTodosTipo" name="tipo"><label for="radioTodosTipo" class="container p-0 m-0">Todos</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioMaterial" name="tipo"><label for="radioMaterial" class="container p-0 m-0"> Material</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioProduto" name="tipo"><label for="radioProduto" class="container p-0 m-0"> Produto</label></div>
                                  <div class="icheck-primary"><input type="radio" id="radioServico" name="tipo"><label for="radioServico" class="container p-0 m-0">Serviço</label></div>
                                </div>
                              </fieldset>
                            </div>

                            <div class="col-sm-3 form-group d-flex">
                              <fieldset class="w-100 form border-Field mb-0 pb-0">
                                <legend class="textoBorda mb-0 pb-0">Situação</legend>
                                <div class="">
                                  <div class="icheck-primary"><input type="radio" checked="checked" id="radioTodosSituacao" name="situacao"> <label for="radioTodosSituacao" class="container p-0 m-0">Todos</label> </div>
                                  <div class="icheck-primary"><input type="radio" id="radioAberta" name="situacao"><label for="radioAberta" class="container p-0 m-0"> Aberta </label> </div>
                                  <div class="icheck-primary"><input type="radio" id="radioBaixada" name="situacao"> <label for="radioBaixada" class="container p-0 m-0"> Baixada </label> </div>
                                </div>
                              </fieldset>
                            </div>
                          </div>

                          <div class="col-sm-12 align-end d-flex justify-content-end mt-4">
                            <div class="button-group">
                              <button class="btn btn-primary btn-sisp" id="btnConsultar"><span class="fas fa-search"></span> Consultar</button>
                            </div>
                          </div>

                          <div class="card col-sm-12 table-responsive card-body">
                            <h5>Ordens de Compra</h5>
                            <table id="tabelaOc" class="table table-sm table-select table-hover" width="100%">
                              <thead>
                                <tr>
                                  <th class="th-sm">SEL
                                  </th>
                                  <th class="th-sm">Número
                                  </th>
                                  <th class="th-sm">Cód. For
                                  </th>
                                  <th class="th-sm">Fornecedor
                                  </th>
                                  <th class="th-sm">Valor
                                  </th>
                                </tr>
                              </thead>
                              <tbody>
                              </tbody>
                            </table>
                          </div>

                          <div class="col-sm-12 d-flex justify-content-end">
                            <button id="btnLiberar" class="btn btn-danger btn-sisp">Confirmar</button>
                          </div>

                        </div>
                      </div>
                    </div>

                    <div id="modal-itens" class="modal" tabindex="-1" role="dialog">
                      <div class="modal-dialog modal-xl" role="document">
                        <div class="modal-content" id="modalBody">
                          <div class="modal-header">
                            <h4 class="modal-title">Informações</h4>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                              <span aria-hidden="true">&times;</span>
                            </button>
                          </div>

                          <nav>
                            <div class="nav nav-tabs justify-content-center" id="nav-tab" role="tablist" style="text-decoration: none">
                              <a class="nav-link abaLink active" id="tabItens" data-toggle="tab" href="#divItens" role="tab" aria-controls="divItens" aria-selected="true">Itens</a>
                              <a class="nav-link abaLink" id="tabUltCompras" data-toggle="tab" href="#divUltCompras" role="tab" aria-controls="divUltCompras" aria-selected="false">Últimas Compras</a>
                            </div>
                          </nav>

                          <div class="tab-content" id="nav-tabContent">
                            <div class="tab-pane fade show active" id="divItens" role="tabpanel" aria-labelledby="tabFiscal">
                              <div class="col-12">
                                <div class="row card-body">
                                  <div class="col-4">
                                    <label data-error="wrong" data-success="right" for="txtNumeroOc">Ordem de Compra</label>
                                    <div class="input-group">
                                      <input type="text" class="input-default focus form-control" id="txtNumeroOc" name="txtNumeroOc" disabled>
                                    </div>
                                  </div>
                                  <div class="col-8">
                                    <label data-error="wrong" data-success="right" for="txtClienteOc">Fornecedor </label>
                                    <div class="input-group">
                                      <input type="text" class="input-default focus form-control" id="txtClienteOc" name="txtClienteOc" disabled>
                                    </div>
                                  </div>
                                  <div class="col-sm-12 table-responsive" style="margin-top: 20px;">
                                    <h5>Itens</h5>
                                    <table id="tabelaItens" class="table table-sm table-select table-hover" width="100%">
                                      <thead>
                                        <tr>
                                          <th class="th-sm">Código
                                          </th>
                                          <th class="th-sm">Descrição
                                          </th>
                                          <th class="th-sm">Cor
                                          </th>
                                          <th class="th-sm">Tam
                                          </th>
                                          <th class="th-sm">Qtde
                                          </th>
                                          <th class="th-sm">Preço
                                          </th>
                                        </tr>
                                      </thead>
                                      <tbody>
                                      </tbody>
                                    </table>
                                  </div>
                                </div>
                              </div>
                            </div>

                            <div class="tab-pane fade" id="divUltCompras" role="tabpanel" aria-labelledby="tabICMS">
                              <div class="tab-content" id="nav-tabContent">
                                <div class="tab-pane fade show active" role="tabpanel" aria-labelledby="tabFiscal">
                                  <div class="col-12">
                                    <div class="row card-body">
                                      <div class="col-sm-12 table-responsive" style="margin-top: 20px;">
                                        <h5>Últimas Compras</h5>
                                        <table id="tabelaUltCompras" class="table table-sm table-select table-hover" width="100%">
                                          <thead>
                                          </thead>
                                          <tbody>
                                          </tbody>
                                        </table>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  </div>
  <?php
  include_once('../../modais.php');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  <script src="plugins/jquery/jquery.min.js?versao=3.251.16.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.251.16.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.251.16.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.251.16.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.251.16.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.251.16.1"></script>
  <script src="dist/js/sisplan.js?versao=3.251.16.1"></script>
  <script src="utils/funcoes.js?versao=3.251.16.1"></script>
  <script src="utils/cookies.js?versao=3.251.16.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.251.16.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.251.16.1"></script>
  <script src="dist/js/driver.min.js?versao=3.251.16.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.251.16.1"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.251.16.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.251.16.1"></script>
  <script type="text/javascript" src="config.js?versao=3.251.16.1"></script>
  <script>
    $(document).ready(async function() {
      if (getCookie('usuario') == "") {
        window.location.href = `${BASE_URI}/login`;
        return;
      }

      let usuario = getCookie('usuario');
      let empresa = getCookie('empresa');

      ipInterno = IP_INTERNO;
      ipExterno = IP_EXTERNO;
      basicAuth = BASIC_AUTH;

      const temAcesso = await temAcessoTela('LIBERACAO_OC');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      sArquivo = `${BASE_URI}/pages/liberacao_oc/liberacao_oc.js?versao=3.251.16.1`;
      insereJavaScriptPagina(sArquivo);

    });
  </script>
</body>

</html>