<?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 | Regras de Pedido</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.261.27.1">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.261.27.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.261.27.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.261.27.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.261.27.1">
  <link rel="stylesheet" href="dist/css/sisplan.adjustDataTableButtons.css?versao=3.261.27.1">
  <link rel="stylesheet" href="dist/css/sisplan.newColorsButtons.css?versao=3.261.27.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.261.27.1" />
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.261.27.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.261.27.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.261.27.1">
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.261.27.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.261.27.1">
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.261.27.1">
  <style>
    .radioStyle {
      border: solid #e0e4e6;
      border-radius: 4px;
      border-width: 2px;
      padding: 7.25px;
      height: 136px;
    }

    
    #tabelaRegraPedidoALTERACAO th.sorting:nth-child(3) {
      width: 550px !important;
      max-width: 550px !important;
    }

    #tabelaRegraPedidoALTERACAO td:nth-child(3) .d-flex {
      justify-content: flex-end !important;
    }

    #tabelaRegraPedidoALTERACAO td:nth-child(3) .form-group,
    #tabelaRegraPedidoALTERACAO td:nth-child(3) input,
    #tabelaRegraPedidoALTERACAO td:nth-child(3) select {
      margin-left: auto !important;
    }

    .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 1.0em 1.0em !important;
      /* margin: 0 0 1.0em 0 !important; */
      -webkit-box-shadow: 0px 0px 0px 0px #000;
      box-shadow: 0px 0px 0px 0px #000;
      border-radius: 3px !important;
    }

    .acoes-container {
      margin-top: 15px;
      display: flex;
      gap: 6px;
    }

    .acoes-container .btn {
      padding: 4px 6px;
      min-width: 34px;
    }

    .placeholder {
      visibility: hidden;
    }
    
  </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">Regras de Pedido</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 card">
          <div class="row card-body d-flex" id="abaGeral">
            <nav class="col-lg-12">
              <div class="nav nav-tabs d-flex flex-nowrap" id="nav-tab" role="tablist" style="text-decoration: none; max-width: none!important; white-space: nowrap!important; overflow-x: auto!important; overflow-y: hidden">
                <a class="nav-link abaLink" id="tabPedidoCapa" data-toggle="tab" href="#divPedidoCapa" role="tab" aria-controls="divPedidoCapa" aria-selected="false">Pedido</a>
              </div>
            </nav>
            <div class="tab-content col-lg-12" id="nav-tabContent">
              <div class="tab-pane fade" id="divPedidoCapa" role="tabpanel" aria-labelledby="tabPedidoCapa">
                <nav class="col-lg-12">
                  <div class="nav nav-tabs" id="nav-tab" role="tablist" style="text-decoration: none">
                    <a class="nav-link abaLink" id="tabInclusaoPedido" data-toggle="tab" href="#divInclusaoPedido" role="tab" aria-controls="divInclusaoPedido" aria-selected="false">Inclusão</a>
                    <a class="nav-link abaLink" id="tabAlteracaoPedido" data-toggle="tab" href="#divAlteracaoPedido" role="tab" aria-controls="divAlteracaoPedido" aria-selected="false">Alteração</a>
                    <a class="nav-link abaLink" id="tabRegraManual" data-toggle="tab" href="#divRegraManual" role="tab" aria-controls="divRegraManual" aria-selected="false">Regras Manuais</a>
                  </div>
                </nav>
                <div class="tab-content col-lg-12" id="nav-tabContent">
                  <div class="tab-pane fade" id="divInclusaoPedido" role="subtabpanel" aria-labelledby="tabInclusaoPedido">
                    <div class="row" style="margin-top: 15px;">
                      <div class="col-sm-12">
                        <table id="tabelaRegraPedidoINCLUSAO" class="table table-sm table-select table-hover">
                          <thead>
                            <th>Regra</th>
                            <th>Descrição</th>
                            <th>Configuração</th>
                          </thead>
                          <tbody>
                          </tbody>
                        </table>
                      </div>
                    </div>
                  </div>
                  <div class="tab-pane fade" id="divAlteracaoPedido" role="subtabpanel" aria-labelledby="tabAlteracaoPedido">
                    <div class="row" style="margin-top: 15px;">
                      <div class="col-sm-12">
                        <table id="tabelaRegraPedidoALTERACAO" class="table table-sm table-select table-hover">
                          <thead>
                            <th>Regra</th>
                            <th>Descrição</th>
                            <th style="width: 500px;">Configuração</th>
                          </thead>
                          <tbody>
                          </tbody>
                        </table>
                      </div>
                    </div>
                  </div>
                  <div class="tab-pane fade" id="divRegraManual" role="subtabpanel" aria-labelledby="tabRegraManual">
                    <div class="row" style="margin-top: 15px;">
                      <div class="form-group col-md-2">
                        <label for="txtCodigoRegraManual">Código: *</label>
                        <input type="text" class="input-default focus form-control" id="txtCodigoRegraManual" name="txtCodigoRegraManual" placeholder="Gerado automaticamente" disabled>
                      </div>
                      <div class="form-group col-md-3">
                        <label for="txtDescricaoRegraManual">Regra: *</label>
                        <input type="text" class="input-default focus form-control" id="txtDescricaoRegraManual" name="txtDescricaoRegraManual" placeholder="Regra">
                      </div>
                      <div class="form-group col-md-3">
                        <label for="txtBloqRetRegraManual">Bloq. Ret.: </label>
                        <div class="input-group">
                          <input type="text" class="input-default focus form-control" id="txtBloqRetRegraManual" name="txtBloqRetRegraManual" placeholder="Bloq. Ret." title="Campo para relacionar um bloqueio de retorno. Exemplo: Foi adicionado um bloqueio X, e nele está relacionado um bloqueio Y. Ao ser liberado o bloqueio X, o Y será inserido automaticamente como bloqueio de retorno.">
                          <div class="input-group-append">
                            <button class="btn bg-danger" id="btnBloqRetRegraManual" data-button="absolute" type="button">
                              <i class="m-0 p-0 fas fa-search"></i>
                            </button>
                          <button class="btn bg-danger" id="btnLimpaBloqRetRegraManual" type="button">
                            <i class="m-0 p-0 fas fa-trash"></i>
                          </button>
                          </div>
                        </div>                        
                      </div>
                      <div class="col-md-3 col-12 form" id="tipo">
                        <fieldset class="form border-Field mb-0 pb-0">
                          <legend class="textoBorda mb-0 pb-0">Tipo *</legend>
                          <div class="form-row">                            
                            <div class="icheck-primary form-check ml-3">
                              <input type="checkbox" class="form-check-input" id="cbComercial">
                              <label class="form-check-label pr-2" for="cbComercial">Comercial</label>
                            </div>
                            <div class="icheck-primary form-check">
                              <input type="checkbox" class="form-check-input" id="cbFinanceiro">
                              <label class="form-check-label pr-2" for="cbFinanceiro">Financeiro</label>
                            </div>
                          </div>
                        </fieldset>
                      </div>      
                      <div class="form-group col-md-1" style="padding-left: 3px;" id="divIncluirRegraManual">
                        <button style="margin-top: 15px;" class="btn btnVerde btn-sisp" id="btnIncluirRegraManual">
                          <i class="fas fa-plus"></i> Incluir
                        </button>  
                      </div> 
                      <div class="form-group col-md-1 d-none" style="padding-left: 3px;" id="divAlterarRegraManual">
                        <div id="acoesRegraManual" class="acoes-container">
                          <button class="btn btn-sm btnVerde" id="btnConfirmarRegraManual" title="Confirmar">
                            <i class="fas fa-check"></i>
                          </button>
                          <button class="btn btn-danger btn-sm" id="btnCancelarRegraManual" title="Cancelar">
                            <i class="fas fa-times"></i>
                          </button>
                        </div>
                      </div> 
                      <div class="col-sm-12">
                        <table id="tabelaRegrasManuais" class="table table-sm table-select table-hover">
                          <thead>
                          </thead>
                          <tbody>
                          </tbody>
                        </table>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-12" style="display: flex!important; justify-content: flex-end!important;">
              <button style="margin-top: 15px;" class="btn btnVerde btn-sisp" id="btnGravar">
                <i class="fas fa-save"></i> Gravar
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php
  include_once('../../modais.php');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  </div>
  <script src="plugins/jquery/jquery.min.js?versao=3.261.27.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.261.27.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.261.27.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.261.27.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.261.27.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.261.27.1"></script>
  <script src="dist/js/sisplan.js?versao=3.261.27.1"></script>
  <script src="utils/funcoes.js?versao=3.261.27.1"></script>
  <script src="utils/cookies.js?versao=3.261.27.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.261.27.1"></script>
  <script src="dist/js/loadingoverlay.min.js?versao=3.261.27.1"></script>
  <script src="dist/js/driver.min.js?versao=3.261.27.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.261.27.1"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.261.27.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.261.27.1"></script>
  <script type="text/javascript" src="config.js?versao=3.261.27.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('PEDREGRAS');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

    });
  </script>
</body>

</html>