<?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.263.17.1">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.263.17.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.263.17.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/select.bootstrap.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.263.17.1" />
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/datatables-colreorder/css/colReorder.bootstrap4.min.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="dist/css/sisplan.newColorsButtons.css?versao=3.263.17.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;
    }

    .table.dataTable tbody td,
    .table.dataTable thead {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .table.dataTable tr td,
    .table.dataTable tr td,
    .table.dataTable th {
      padding: 4px 12px;
    }

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

    #legendas {
      flex-direction: row;
      flex-wrap: wrap;
    }

    .quadrado {
      width: 20px;
      margin-right: 5px;
      height: 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 px-0">
                      <div class="card-header" style="border: none!important;box-shadow:none!important;">
                        <h2 class="m-0 pl-2">Baixa 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">
                          <form id="form" class="col-12">
                            <div id="tutorialFiltros" class="row card-body p-0">
                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtNumeros">Números:</label>
                                <div class="input-group">
                                  <select class="js-example-programmatic js-states form-control" id="txtNumeros" name="txtNumeros" multiple="multiple">
                                  </select>
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnNumeros" name="btnNumeros" data-button="absolute" type="button">
                                      <i class="m-0 p-0 fas fa-search"></i>
                                    </button>
                                    <button class="btn bg-danger" id="btnLimpaNumeros" name="btnLimpaNumeros" type="button">
                                      <i class="m-0 p-0 fas fa-trash"></i>
                                    </button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtCodigos">Códigos:</label>
                                <div class="input-group">
                                  <select class="js-example-programmatic js-states form-control" id="txtCodigos" name="txtCodigos" multiple="multiple">
                                  </select>
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnCodigos" name="btnCodigos" data-button="absolute" type="button">
                                      <i class="m-0 p-0 fas fa-search"></i>
                                    </button>
                                    <button class="btn bg-danger" id="btnLimpaCodigos" name="btnLimpaCodigos" type="button">
                                      <i class="m-0 p-0 fas fa-trash"></i>
                                    </button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtCores">Cores:</label>
                                <div class="input-group">
                                  <select class="js-example-programmatic js-states form-control" id="txtCores" name="txtCores" multiple="multiple">
                                  </select>
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnCores" name="btnCores" data-button="absolute" type="button">
                                      <i class="m-0 p-0 fas fa-search"></i>
                                    </button>
                                    <button class="btn bg-danger" id="btnLimpaCores" name="btnLimpaCores" type="button">
                                      <i class="m-0 p-0 fas fa-trash"></i>
                                    </button>
                                  </div>
                                </div>
                              </div>
                              <div class="col-auto form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="selectSituacao">Situação:</label>
                                <div class="input-group">
                                  <select class="input-default focus form-control" data-dropdown-css-class="select2-danger" id="selectSituacao" aria-describedby="tipoError" class="custom-select focus">
                                    <option value="0">Todas</option>
                                    <option value="1">Abertas</option>
                                    <option value="2">Baixadas</option>
                                    <option value="3">Tem baixa</option>
                                  </select>
                                </div>
                              </div>
                              <div class="col-xl-1 col-6 form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtPercentual">Percentual:</label>
                                <input autocomplete="off" type="text" class="input-default focus form-control campoValor text-right" id="txtPercentual" placeholder="0,00" name="percentual" maxlength="6" />
                              </div>
                              <div class="col-auto form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtEntrega">Data de entrega:</label>
                                <input autocomplete="off" type="date" class="input-default focus form-control" id="txtEntrega" name="entrega" />
                              </div>
                              <div class="col-auto form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtQuantidade">Quantidade:</label>
                                <input type="number" name="txtQuantidade" min="1" id="txtQuantidade" class="input-default focus form-control" data-bs-toggle="tooltip" title="Quantidade" value="1">
                              </div>
                              <div class="col-xl-3 col-6 form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtBarra">Barra:</label>
                                <input autocomplete="off" type="text" class="input-default focus form-control" id="txtBarra" placeholder="Barra" name="barra" />
                              </div>
                              <div class="col-auto form-group flex align-items-end ml-auto">
                                <button type="button" class="btn btn-primary btn-sisp" id="btnConsultar"><i class="fas fa-search"></i> Consultar</button>
                              </div>
                              <div class="form-row col-12 pr-1">
                                <div class="flex flex-column col-12 pr-0">
                                  <div class="table-responsive">
                                    <table id="tabelaItens" class="table table-select table-hover" width="100%">
                                      <thead>
                                      </thead>
                                      <tbody>
                                      </tbody>
                                    </table>
                                  </div>
                                </div>
                                <div class="row col-12 d-none" id="divQtdeBipada">
                                  <div class="col-auto">
                                    <div class="col-auto form-group">
                                      <label data-error="wrong" class="labelGeral" data-success="right" for="txtEntrega">Qtde Bipada:</label>
                                      <input type="number" name="txtQuantidadeBipada" id="txtQuantidadeBipada" class="form-control" data-bs-toggle="tooltip" title="Total de peças bipadas" readonly>
                                    </div>
                                  </div>
                                  <div class="col-auto">
                                    <div class="col-auto form-group">
                                      <label data-error="wrong" class="labelGeral" data-success="right" for="txtEntrega">Qtde Saldo:</label>
                                      <input type="number" name="txtQuantidadeSaldo" id="txtQuantidadeSaldo" class="form-control" data-bs-toggle="tooltip" title="Saldo para baixa" readonly>
                                    </div>
                                  </div>
                                  <div class="col-auto">
                                    <div class="col-auto form-group">
                                      <label data-error="wrong" class="labelGeral" data-success="right" for="txtEntrega">Qtde. Total:</label>
                                      <input type="number" name="txtQuantidadeTotalOrdem" id="txtQuantidadeTotalOrdem" class="form-control" data-bs-toggle="tooltip" title="Quantidade total da ordem de compra" readonly>
                                    </div>
                                  </div>
                                </div>
                              </div>

                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtDeposito">Depósito:</label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" id="txtDeposito" name="txtDeposito" placeholder="Depósito">
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnDeposito" name="btnDeposito" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                    <button class="btn bg-danger" id="btnLimpaDeposito" name="btnLimpaDeposito" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtFuncionario">Funcionário:</label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" id="txtFuncionario" name="txtFuncionario" placeholder="Funcionário">
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnFuncionario" name="btnFuncionario" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                    <button class="btn bg-danger" id="btnLimpaFuncionario" name="btnLimpaFuncionario" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-xl-4 col-12">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtTipoMovimento">Tipo Movimento:</label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" id="txtTipoMovimento" name="txtTipoMovimento" placeholder="Tipo Movimento">
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnTipoMovimento" name="btnTipoMovimento" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                    <button class="btn bg-danger" id="btnLimpaTipoMovimento" name="btnLimpaTipoMovimento" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group col-lg-4 col-12 d-none" id="localContainer">
                                <label data-error="wrong" data-success="right" for="txtLocal">Local: </label>
                                <div class="input-group">
                                  <input type="text" class="input-default focus form-control" id="txtLocal" name="txtLocal" placeholder="Local">
                                  <div class="input-group-append">
                                    <button class="btn bg-danger" id="btnLocal" name="btnLocal" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                    <button class="btn bg-danger" id="btnLimpaLocal" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                  </div>
                                </div>
                              </div>
                              <div class="col-xl-2 col-6 form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtLote">Lote:</label>
                                <input autocomplete="off" type="text" class="input-default focus form-control" id="txtLote" placeholder="Lote" name="lote" />
                              </div>
                              <div class="col-xl-3 col-6 form-group">
                                <label data-error="wrong" class="labelGeral" data-success="right" for="txtObservacao">Observação:</label>
                                <input autocomplete="off" type="text" class="input-default focus form-control" id="txtObservacao" placeholder="Observação" name="observacao" />
                              </div>
                              <div class="form-row col-12 pr-1 align-items-end my-1">
                                <div class="button-group ml-auto">
                                  <button type="button" class="btn btnVerde btn-sisp" id="btnBaixar"><i class="fas fa-check"></i> Baixar</button>
                                  <button type="button" class="btn btn-danger btn-sisp" id="btnEstornar"><i class="fas fa-check"></i> Estornar</button>
                                </div>
                              </div>
                            </div>
                          </form>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  </div>

  <div
    class="modal fade"
    data-backdrop="static"
    id="modalManutencao"
    tabindex="-1"
    role="dialog"
    aria-labelledby="modalManutencao"
    aria-hidden="true">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title">Alterar</h4>
          <button
            type="button"
            class="close"
            data-dismiss="modal"
            aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body pb-0">
          <form id="formManutencao">
            <div class="form-row">
              <div class="col-6 form-group">
                <label data-error="wrong" class="labelGeral" data-success="right" for="txtQuantidadeBaixarModal">Baixar:</label>
                <input autocomplete="off" type="text" class="input-default focus form-control campoValor text-right" id="txtQuantidadeBaixarModal" placeholder="0,00" />
              </div>
              <div class="col-6 form-group">
                <label data-error="wrong" class="labelGeral" data-success="right" for="txtQuantidadeEstornarModal">Estornar:</label>
                <input autocomplete="off" type="text" class="input-default focus form-control campoValor text-right" id="txtQuantidadeEstornarModal" placeholder="0,00" />
              </div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button
            type="button"
            class="btn btnVerde btn-sisp"
            id="btnConfirmarModal">
            <i class="fas fa-check"></i>
            Confirmar
          </button>
          <button
            class="btn btn-danger btn-sisp"
            class="close"
            data-dismiss="modal"
            aria-label="Close"
            id="btnCancelarModal">
            Cancelar
          </button>
        </div>
      </div>
    </div>
  </div>
  <?php
  include_once('../../modais.php');
  include_once('./modal_manutencao.php');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  <script src="plugins/jquery/jquery.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.263.17.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-validation/jquery.validate.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/sisplan.js?versao=3.263.17.1"></script>
  <script src="utils/funcoes.js?versao=3.263.17.1"></script>
  <script src="utils/cookies.js?versao=3.263.17.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.263.17.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/driver.min.js?versao=3.263.17.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.263.17.1"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="config.js?versao=3.263.17.1"></script>
  <script src="https://cdn.datatables.net/select/1.6.0/js/dataTables.select.min.js"></script>
  <script src="plugins/datatables-colreorder/js/dataTables.colReorder.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/jquery.maskMoney.min.js?versao=3.263.17.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('BAIXA_ORDEM_COMPRA');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

    });
  </script>
</body>

</html>