<?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 | Ordem de Compra</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.261.22.1">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.261.22.1">

  <!-- Google Font: Source Sans Pro -->
  <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,600,700,400italic' rel='stylesheet' type='text/css'>
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">


  <link rel="stylesheet" href="dist/css/custom.css?versao=3.261.22.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.261.22.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.261.22.1" />
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.261.22.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.261.22.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.261.22.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.261.22.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.261.22.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.261.22.1">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.261.22.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.261.22.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.261.22.1">
  <link rel="stylesheet" href="plugins/datatables-colreorder/css/colReorder.bootstrap4.min.css?versao=3.261.22.1">
  <style>
    .table.dataTable tbody td,
    .table.dataTable thead {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    #tabelaOrdemCompra td div button {
      padding: .0rem .5rem;
      margin-top: .1rem;
      margin-bottom: .2rem;
    }

    #tabelaOrdemCompra td {
      padding: 0 !important;
      padding-left: 10px !important;
    }

    #modalPesquisaPedido div {
      z-index: 999 !important;
    }

    .quadrado {
      width: 23px;
      margin-right: 5px;
      height: 23px;
    }
  </style>
</head>

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

    <div class="content-wrapper">
      <div class="content-header">
        <div class="container-fluid">
          <div class="row mb-2">
            <div class="col-sm-6 flex">
              <h1 class="m-0 text-dark">Ordem de Compra</h1>
              <button type="button" class="btn btn-info btn-sm ml-2" title="Tutorial" style="color: white;" id="tutorial">
                <i class="fas fa-question-circle"></i></button>
            </div>
            <div class="col-sm-6">

            </div>
          </div>
        </div>
        <div class="container-fluid" id="divTabelaOrdemCompra">
          <div class="row card">
            <div class="col-sm-12 mt-3">
              <button class="btn btn-success btn-sisp" id="btnFiltros"><span class="fas fa-search"></span> Filtros</button>
              <button class="btn btn-danger btn-sisp" id="btnIncluir"><span class="fas fa-plus"></span> Incluir</button>
              <button id="btnImprimir" class="btn-sisp btn btn-success"><i class="fas fa-print"></i> Imprimir</button>
            </div>

            <div class="row">
              <div class="col-sm-6 d-flex justify-content-center align-items-center" style="height: 100%;">
                <div id="graficosOrdemCompra" class="mt-5" style="width: 100%;"></div>
              </div>
              <div class="col-sm-6 d-flex justify-content-center align-items-center" style="height: 100%;">
                <div id="graficosOrdemCompra1" class="mt-5" style="width: 100%;"></div>
              </div>
            </div>

            <div class="col-sm-12 table-responsive card-body pt-0">
              <h5>Lista de Ordem de Compra</h5>
              <table id="tabelaOrdemCompra" class="table table-sm-sisp table-select table-hover" width="100%">
                <thead>
                  <tr>
                    <th class="th-sm">Número</th>
                    <th class="th-sm">Código Fornecedor</th>
                    <th class="th-sm">Nome Fornecedor</th>
                    <th class="th-sm">Condição</th>
                    <th class="th-sm">Valor Total</th>
                    <th class="th-sm">Status</th>
                    <th class="th-sm">Descrição Status</th>
                    <th class="th-sm">Endereço</th>
                    <th class="th-sm">Bairro</th>
                    <th class="th-sm">Num End</th>
                    <th class="th-sm">Compl End</th>
                    <th class="th-sm">Coleção.</th>
                    <th class="th-sm">Descrição Coleção</th>
                    <th class="th-sm">Cnpj</th>
                    <th class="th-sm">Estado</th>
                    <th class="th-sm">Cep</th>
                    <th class="th-sm">Código Município</th>
                    <th class="th-sm">Cidade</th>
                    <th class="th-sm">Ddd Fone</th>
                    <th class="th-sm">Telefone</th>
                    <th class="th-sm">Inscrição</th>
                    <th class="th-sm">Data Emissão</th>
                    <th class="th-sm">Data Entrega</th>
                    <th class="th-sm">Solicitações</th>
                    <th class="th-sm">Envio</th>
                    <th class="th-sm">Nome Solicitante</th>
                    <th class="th-sm">Liberado</th>
                    <th class="th-sm">Motivo</th>
                    <th class="th-sm">Descrição</th>
                    <th class="th-sm">Obra</th>
                    <th class="th-sm">Descrição Obra</th>
                    <th class="th-sm">Nome Comprador</th>
                    <th class="th-sm">Num Contato</th>
                    <th class="th-sm">Deposito</th>
                    <th class="th-sm">Descrição Deposito</th>
                    <th class="th-sm">Código Transportadora</th>
                    <th class="th-sm">Nome Transportadora</th>
                    <th class="th-sm">Usuário</th>
                    <th class="th-sm">Histórico</th>
                    <th class="th-sm">Data Entrega Orig</th>
                    <th class="th-sm">Empresa</th>
                    <th class="th-sm">Data Deposito</th>
                    <th class="th-sm">Prazo</th>
                    <th class="th-sm">Frete</th>
                    <th class="th-sm">Descrição Frete</th>
                    <th class="th-sm">Referencia</th>
                    <th class="th-sm">Comprador</th>
                    <th class="th-sm">Prazo Med</th>
                    <th class="th-sm">Id Centro custo</th>
                    <th class="th-sm">Código Centro custo</th>
                    <th class="th-sm">Descrição Centro custo</th>
                    <th class="th-sm">Notas Fiscais</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
            </div>
          </div>
          <div class="d-flex gap-2 row">
            <div class="table-responsive card card-body col-12">
              <h5>Itens</h5>
              <table id="tabelaOrdemCompraVisualizacao" class="table table-sm table-select table-hover" width="100%">
                <thead></thead>
                <tbody></tbody>
              </table>
            </div>
          </div>
          <div class="card card-body">

            <div class="row">
              <div class="col-6">
                <label for="txtDataEmiDe">Observação de compra: </label>
                <textarea disabled rows="4" class="input-default focus form-control create" name="txtObsCompra" id="txtObsCompra"></textarea>
              </div>

              <div class="col-6">
                <label for="txtDataEmiDe">Observação de cotação: </label>
                <textarea disabled rows="4" class="input-default focus form-control create" name="txtObsCotacao" id="txtObsCotacao"></textarea>
              </div>
            </div>

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

      <div id="modal-filtros" 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">Filtros</h4>
              <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="row">
                <div class="form-group col-xl-3 col-lg-4 col-12">
                  <label for="txtDataEmiDe">Data Emissão De/até: </label>
                  <div class="input-group">
                    <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="txtDataEmiDe" name="DataDe">
                    <input type="date" max="2500-12-31" value="2500-12-01" class="input-default focus form-control validate" id="txtDataEmiAte" name="DataDe">
                  </div>
                </div>

                <div class="form-group col-xl-9 col-lg-8 col-12">
                  <label data-error="wrong" data-success="right" for="txtOrdemCompraConsulta">Ordem de Compra: </label>
                  <div class="input-group">
                    <input type="text" class="input-default col-lg-3 col-12 focus form-control" id="txtOrdemCompraConsulta" name="txtOrdemCompraConsulta" class="form-control" placeholder="Ordem de Compra">
                    <button class="btn bg-danger" id="btn-OrdemCompraConsulta" name="btn-OrdemCompraConsulta" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <input type="text" id="txtListaOrdemCompra" class="form-group col-lg-9 col-12 input-default focus form-control" placeholder="Lista de Ordem de Compra" disabled>
                    <button class="btn bg-danger" id="btn-limpa-OrdemCompra" name="btn-limpa-OrdemCompra" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-lg-6 col-12" id="Fornecedor">
                  <label data-error="wrong" data-success="right" for="txtFornecedor">Fornecedor: </label>
                  <div class="input-group">
                    <input type="text" autocomplete="off" class="input-default focus form-control" id="txtFornecedor" name="txtFornecedor" class="form-control" placeholder="Fornecedor">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btn-Fornecedor" name="btn-Fornecedor" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btn-limpa-Fornecedor" name="btn-limpa-Fornecedor" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-lg-6 col-12" id="Usuario">
                  <label data-error="wrong" data-success="right" for="txtUsuario">Usuário: </label>
                  <div class="input-group">
                    <input type="text" class="input-default focus form-control" id="txtUsuario" name="txtUsuario" class="form-control" placeholder="Usuário">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnUsuario" name="btnUsuario" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btnLimpaUsuario" name="btnLimpaUsuario" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-lg-6 col-12" id="Status">
                  <label data-error="wrong" data-success="right" for="txtStatus">Status: </label>
                  <div class="input-group">
                    <input type="text" class="input-default focus form-control" id="txtStatus" name="txtStatus" class="form-control" placeholder="Status">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btn-Status" name="btn-Status" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btn-limpa-Status" name="btn-limpa-Status" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-lg-6 col-12" id="Empresa">
                  <label data-error="wrong" data-success="right" for="txtEmpresa">Empresa: </label>
                  <div class="input-group">
                    <input type="text" class="input-default focus form-control" id="txtEmpresa" name="txtEmpresa" class="form-control" placeholder="Empresa">
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btn-Empresa" name="btn-Empresa" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                      <button class="btn bg-danger" id="btn-limpa-Empresa" name="btn-limpa-Empresa" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                    </div>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-lg-6 col-12">
                  <label data-error="wrong" class="labelGeral" data-success="right" for="txtSolicitacao">Solicitação:</label>
                  <div class="input-group">
                    <select class="js-example-programmatic js-states form-control" id="txtSolicitacao" name="txtSolicitacao" multiple="multiple">
                    </select>
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnSolicitacao" name="btnSolicitacao" data-button="absolute" type="button">
                        <i class="m-0 p-0 fas fa-search"></i>
                      </button>
                      <button class="btn bg-danger" id="btnLimpaSolicitacao" name="btnLimpaSolicitacao" 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="txtItemCompra">Item:</label>
                  <div class="input-group">
                    <select class="js-example-programmatic js-states form-control" id="txtItemCompra" name="txtItemCompra" multiple="multiple">
                    </select>
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnItemCompra" name="btnItemCompra" data-button="absolute" type="button">
                        <i class="m-0 p-0 fas fa-search"></i>
                      </button>
                      <button class="btn bg-danger" id="btnLimpaItemCompra" name="btnLimpaItemCompra" 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="txtCor">Cor:</label>
                  <div class="input-group">
                    <select class="js-example-programmatic js-states form-control" id="txtCor" name="txtCor" multiple="multiple">
                    </select>
                    <div class="input-group-append">
                      <button class="btn bg-danger" id="btnCor" name="btnCor" data-button="absolute" type="button">
                        <i class="m-0 p-0 fas fa-search"></i>
                      </button>
                      <button class="btn bg-danger" id="btnLimpaCor" name="btnLimpaCor" type="button">
                        <i class="m-0 p-0 fas fa-trash"></i>
                      </button>
                    </div>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-6">
                  <label for="">Tipo Item:</label>
                  <div class="relative">
                    <select name="" id="txtTipoItem" value="" class="form-group input-default">
                      <option value="">Todos</option>
                      <option value="P">Produto</option>
                      <option value="M">Material</option>
                      <option value="S">Serviço</option>
                    </select>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-6">
                  <label for="">E-mail:</label>
                  <div class="relative">
                    <select name="" id="txtEmail" value="" class="form-group input-default">
                      <option value="">Todos</option>
                      <option value="S">Enviado</option>
                      <option value="N">Não enviado</option>
                    </select>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-6">
                  <label for="">Filtro:</label>
                  <div class="relative">
                    <select name="" id="txtFiltro" value="" class="form-group input-default">
                      <option value="">Todos</option>
                      <option value="A">Em aberto</option>
                      <option value="F">Finalizadas</option>
                    </select>
                  </div>
                </div>

                <div class="form-group col-xl-4 col-6">
                  <label for="">Situação:</label>
                  <div class="relative">
                    <select name="" id="txtSituacao" value="" class="form-group input-default">
                      <option value="">Todas</option>
                      <option value="A">Em análise</option>
                      <option value="R">Rejeitadas</option>
                      <option value="D">Digitadas</option>
                      <option value="B">Bloqueadas</option>
                      <option value="N">Retornadas</option>
                      <option value="L">Liberadas</option>
                      <option value="E">Enviadas</option>
                    </select>
                  </div>
                </div>
                <div class="form-group col-xl-4 col-6">
                  <label for="">Somente em atraso:</label>
                  <div class="relative">
                    <select name="" id="txtSomenteEmAtraso" value="" class="form-group input-default">
                      <option value="N">Não</option>
                      <option value="S">Sim</option>
                    </select>
                  </div>
                </div>
              </div>

              <div class="modal-footer">
                <div class="form-row col-lg-12 col-sm-12">
                  <div class="col-lg-4 col-sm-12">
                    <label for="txtOrdem">Opção de Relatório:</label>
                    <div class="relative d-flex align-items-center">
                      <select id="txtOrdem" class="input-default focus custom-select">
                      </select>
                      <button class="btn btn-sm btn-success ml-2 btnEdicaoRelatorio" title="Edição de ordenações">
                        <i class="fas fa-check"></i>
                      </button>
                    </div>
                  </div>
                  <div class="col-lg-8 col-sm-12 d-flex justify-content-end align-items-end pr-2">
                    <button class="btn btn-primary btn-sisp" id="btnLimparFiltros" style="background-color: #B22222; border-color: #B22222"><span class="fas fa-trash"></span> Limpar Filtros</button>     
                    <button class="btn btn-primary btn-sisp" id="btnConsultar"><span class="fas fa-search"></span> Consultar</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php
    include_once('../../../modais.php');
    include_once('../../../modals/modal_anexos.html');
    ?>
    <aside class="control-sidebar control-sidebar-dark">
    </aside>
  </div>
  <script src="plugins/jquery/jquery.min.js?versao=3.261.22.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.261.22.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.261.22.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.261.22.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.261.22.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.261.22.1"></script>
  <script src="dist/js/sisplan.js?versao=3.261.22.1"></script>
  <script src="utils/funcoes.js?versao=3.261.22.1"></script>
  <script src="utils/cookies.js?versao=3.261.22.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.261.22.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.261.22.1"></script>
  <script src="dist/js/driver.min.js?versao=3.261.22.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.261.22.1"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.261.22.1"></script>
  <script type="text/javascript" src="modals/modal_anexos.js?versao=3.261.22.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.261.22.1"></script>
  <script type="text/javascript" src="config.js?versao=3.261.22.1"></script>
  <script src="graficos/graficos.js?versao=3.261.22.1"></script>
  <script src="plugins/high-charts/highcharts.js"></script>
  <script src="plugins/high-charts/highcharts-3d.js"></script>
  <script src="plugins/high-charts/cylinder.js"></script>
  <script src="plugins/high-charts/exporting.js"></script>
  <script src="plugins/datatables-colreorder/js/dataTables.colReorder.min.js?versao=3.261.22.1"></script>
  <script src="plugins/high-charts/export-data.js"></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('ORDEM_COMPRA');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      sArquivo = `${BASE_URI}/pages/ordem_compra/acesso_ordem_compra/acesso_ordem_compra.js?versao=3.261.22.1`;
      insereJavaScriptPagina(sArquivo);

    });
  </script>
</body>

</html>