<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Regra de Cortina
  </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.259.1.1">

  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../dist/css/custom.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../dist/css/sisplan.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../dist/css/PesquisaVariosSelect2.css?versao=3.259.1.1">
  <link rel="stylesheet" type="text/css" href="../plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.259.1.1">
  <!-- Toastr -->
  <link rel="stylesheet" href="../plugins/toastr/toastr.min.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.259.1.1">
  <link rel="shortcut icon" href="../favicon.ico">
  <link rel="stylesheet" type="text/css" href="../dist/css/driver.min.css?versao=3.259.1.1" />
  <link rel="stylesheet" href="../dist/css/jquery-ui.css?versao=3.259.1.1">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <link rel="stylesheet" href="../plugins/select2/css/select2.min.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.259.1.1">
  <link rel="stylesheet" href="../plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.259.1.1">
  <link rel="stylesheet" type="text/css" href="../dist/css/sisplan.newColorsButtons.css?versao=3.259.1.1" />


</head>
<style>
  #msform {
    text-align: start;
    position: relative;
  }

  .card {
    box-shadow: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
  }

  .card-header {
    box-shadow: 0px 1px rgb(0 0 0 / 20%) !important;
  }


  .fa-angle-right,
  .fa-angle-down {
    color: #343a40;
  }

  .card-body {
    margin-left: 0px !important;
    padding-left: 1.25rem !important;
    padding-top: 0px;
    padding-bottom: 0px;
    padding-right: 1.25rem !important;
  }

  .header-content-page .title-page,
  .title-content-page .title,
  .title-page {
    font-size: 20px;
    line-height: normal;
    font-weight: 500;
    color: #343a40;
    margin: 0;
    font-family: Roboto, Arial, sans-serif;
  }

  #DadosGerais>.card,
  #obs>.card {
    background: #f7f7f7;
  }

  .radiosStyle {
    padding-top: 0.5rem;
    border: solid #e0e4e6;
    border-radius: 4px;
    border-width: 2px;
    margin-left: 0%;
  }

  .radiosStyle2 {
    padding-top: 0.5rem;
    border: solid #e0e4e6;
    border-radius: 4px;
    border-width: 2px;
  }

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

  .border-Field {
    border: 1.0px 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;
    padding-bottom: 0px !important;
    border-radius: 3px !important;
  }

  #btnIncluir,
  #btnIncluirItem {
    border: 1px solid transparent;
    background: var(--primary);
  }

  #btnLimpaCampos,
  #btnLimpaCampos i {
    background: #e92639;
    cursor: pointer;
  }

  #btnRemover {
    border: 1px solid transparent;
    background: #bd2130;
  }

  #btnIncluir:hover,
  #btnCarregar:hover,
  #btnIncluirItem:hover {
    background: #439af7;
    cursor: pointer;
  }

  .form-row>.col,
  .form-row>[class*=col-] {
    padding-right: 8px !important;
    /* padding-left: 10px !important; */
  }

  .divBtnOpcoes {
    background-color: rgb(189 33 48) !important;
    border: 1px solid transparent !important;
  }

  span.fa-trash-alt {
    color: #ffffff !important;
  }

  .content- wrapper {
    margin-left: 0px !important;
  }

  .main-header,
  .main-sidebar,
  footer {
    display: none;
  }

  #tabelaCalculoItens {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
</style>

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

  <script type="text/javascript" src="../config.js"></script>
  <div class="wrapper">

    <?php
    include_once('../../../menu.php');
    ?>

    <div class="content-wrapper">
      <div class="content-header">
        <div class="container-fluid">
          <div class="row mb-2">
            <div class="col-sm-6">
              <h3 class="col-mb=2"></h3>
            </div>
            <div class="col-sm-6">
            </div>
          </div>
          <div class="row">
            <div class="col-12">
              <div class="card" style="height:auto;">
                <div class="card-header bg-dark">
                  <div class="row flex">
                    <h4 class="text-white">Cadastro de Regra de Cortina </h4>
                    <button title="Tutorial" class="btn btn-info btn-sm ml-2" id="tutorial">
                      <i class="fas fa-question-circle"></i>
                    </button>
                  </div>
                </div>
                <fieldset>
                  <div class="card-body" style="padding-left: 0rem!important; padding-right: 0rem!important;">
                    <form id="msform" name="msform">
                      <div class="collapse show" id="DadosGerais">
                        <div class="card card-body" style="padding-top: 10px;">
                          <div class="tab-pane fade show active" role="tabpanel" aria-labelledby="dados-tab">
                            <fieldset class="form border-Field p-0">
                              <!-- <label >Dados Regra</label> -->
                              <legend class="textoBorda pb-0 mb-0" for="divGeral">Dados Regra</legend>
                              <div class="row" id="divGeral">
                                <div class="col-lg-12 col-12">
                                  <div class="row" style="margin-left: 0px;">
                                    <div class="col-12 col-sm-2 col-lg-3 col-xl-2 mb-2 mb-lg-0" style="margin-left: 5px;" id="codigoInfoTour">
                                      <label for="txtCodigo" class="col-12" style="margin-left: -18px;">Código:</label>
                                      <div style="margin-left: -11px;">
                                        <input type="text" autocomplete="off" readonly placeholder="Preenchimento automático" class="input-default focus form-control validate" pattern="[0-9]+$" id="txtCodigo" name="txtCodigo">
                                      </div>
                                    </div>
                                    <div class="form-group col-sm col-10" id="descricaoInfoTour">
                                      <label for="txtDescricao" style="margin-left: -4px;">Descrição: *</label>
                                      <div class="relative" style="margin-left: -5px;">
                                        <input type="text" autocomplete="off" placeholder="Descrição" class="input-default focus form-control validate" id="txtDescricao" name="txtDescricao">
                                      </div>
                                    </div>
                                    <div class="icheck-primary form-group col-2">
                                      <input type="checkbox" class="form-check-input" id="cbArredondamento" style="margin-top: 31px; margin-left: 1px;">
                                      <label class="form-check-label" for="cbArredondamento" style="margin-top: 34px;">Arredondamento</label>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </fieldset>

                            <fieldset class="form border-Field p-0" id="fieldTabelaCalculo">
                              <legend class="textoBorda pb-0 mb-0">Tabela de Cáculo</legend>
                              <div class="row justify-content-center">
                                <div class="row mb-2" style="width: 100%;">
                                  <div class="form-group col-6">
                                    <label for="txtDescricaoCalculo" style="margin-left: -4px;">Descrição: *</label>
                                    <div class="relative" style="margin-left: -5px;">
                                      <input type="text" autocomplete="off" placeholder="Descrição" class="input-default focus form-control validate" pattern="[0-9]+$" id="txtDescricaoCalculo" name="txtDescricaoCalculo">
                                    </div>
                                  </div>
                                  <div class="form-group col-4">
                                    <label for="selectParametro">Parâmetro:</label>
                                    <div class="relative">
                                      <select id="selectParametro" class="input-default focus form-control validate" name="selectParamatro">
                                        <option value="(ALTURA_ITEM)" selected>(ALTURA_ITEM)</option>
                                      </select>
                                    </div>
                                  </div>
                                  <div class="col-2" style="margin-top: 28px;margin-bottom: 16px;">
                                    <button class="btn btn-block h-100" id="btnIncluir" name="btnIncluir" data-button="absolute" type="button">
                                      <label class="m-0 p-0">Incluir</label>
                                    </button>
                                  </div>
                                  <div class="col-lg-12 col-12 table-responsive  mt-4 mt-lg-1">
                                    <table id="tabelaCalculo" class="table table-sm table-hover">
                                      <thead>
                                      </thead>
                                      <tbody>
                                      </tbody>
                                    </table>
                                  </div>
                                </div>
                              </div>
                            </fieldset>
                          </div>
                        </div>
                        <button id="btnGravar" type="submit" style="font-size:15px;" class="btn btn-danger btn-sisp action-button mr-3" value="Gravar">Gravar</button>
                        <button type="button" id="btnVoltar" style="font-size:15px;" class="btn btn-success btn-sisp action-button-previous" data-dismiss="modal">Voltar</button>
                      </div>
                    </form>
                  </div>
                </fieldset>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div id="modalCalculo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <h4 class="modal-title">Cálculo</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">
            <div class="form-row">
              <div class="form-group col-6">
                <label for="txtParamInicial" style="margin-left: -4px;">Altura Inicial: *</label>
                <div class="relative" style="margin-left: -5px;">
                  <input type="text" autocomplete="off" placeholder="Altura Inicial" class="input-default focus form-control validate camposMascara" required="required" pattern="[0-9]+$" id="txtParamInicial" name="txtParamInicial">
                </div>
              </div>
              <div class="form-group col-6">
                <label for="txtParamFinal" style="margin-left: -4px;">Altura Final: *</label>
                <div class="relative" style="margin-left: -5px;">
                  <input type="text" autocomplete="off" placeholder="Altura Final" class="input-default focus form-control validate camposMascara" required="required" pattern="[0-9]+$" id="txtParamFinal" name="txtParamFinal">
                </div>
              </div>
              <div class="col-10">
                <label for="txtServico">Serviço: *</label>
                <div class="input-group">
                  <input type="text" class="input-default focus form-control" aria-describedby="ufError" id="txtServico" name="txtServico" class="form-control" placeholder="Serviço">
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btnServico" name="btnServico" data-button="absolute" type="button">
                      <i class="m-0 p-0 fas fa-search"></i>
                    </button>
                    <button class="btn bg-danger" id="btnLimpaServico" type="button">
                      <i class="m-0 p-0 fas fa-trash"></i>
                    </button>
                  </div>
                </div>
              </div>
              <div class="col-2" style="margin-top: 28px;margin-bottom: 16px;">
                <button class="btn btn-block h-100" id="btnIncluirItem" name="btnIncluirItem" data-button="absolute" type="button">
                  <label class="m-0 p-0">Incluir</label>
                </button>
              </div>
              <div class="col-sm-12 table-responsive">
                <table id="tabelaCalculoItens" class="table display nowrap">
                  <thead>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button class="btn btn-danger btn-sisp" class="close" data-dismiss="modal" aria-label="Close">Fechar</button>
            <button class="btn bg-gradient-success btn-sisp" class="close" id="btnConfirmarCalculo" data-dismiss="modal" aria-label="Close"> Confirmar</button>
          </div>
        </div>
      </div>
    </div>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
      <!-- Control sidebar content goes here -->
    </aside><!-- /.control-sidebar -->
    <?php
    include_once('../../../modais.php');
    ?>
  </div>

  <script src="../plugins/jquery/jquery.min.js?versao=3.259.1.1"></script>
  <script src="../dist/js/jquery.maskMoney.min.js?versao=3.259.1.1"></script>
  <script src="../plugins/jquery-ui/jquery-ui.min.js?versao=3.259.1.1"></script>
  <script type="text/javascript" src="../dist/js/jquery.dataTables.js?versao=3.259.1.1"></script>
  <script type="text/javascript" src="../dist/js/dataTables.bootstrap4.min.js?versao=3.259.1.1"></script>
  <script src="../plugins/sweetalert2/sweetalert2.min.js?versao=3.259.1.1"></script>
  <script src="../plugins/toastr/toastr.min.js?versao=3.259.1.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="../plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.259.1.1"></script>
  <script src="../dist/js/adminlte.min.js?versao=3.259.1.1"></script>
  <script src="../dist/js/requisicoes.js?versao=3.259.1.1"></script>
  <script src="../dist/js/loadingoverlay.min.js?versao=3.259.1.1"></script>
  <script src="../dist/js/valida_cpf_cnpj.js?versao=3.259.1.1"></script>
  <script src="../plugins/jquery-validation/jquery.validate.min.js?versao=3.259.1.1"></script>
  <script src="../dist/js/dataTables.keyTable.js?versao=3.259.1.1"></script>
  <script src="../dist/js/sisplan.js?versao=3.259.1.1"></script>
  <script src="../utils/funcoes.js?versao=3.259.1.1"></script>
  <script src="../utils/cookies.js?versao=3.259.1.1"></script>
  <script src="../dist/js/driver.min.js?versao=3.259.1.1"></script>
  <script src="../plugins/select2/js/select2.full.min.js?versao=3.259.1.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;
      sArquivo = `${BASE_URI}/pages/regra_cortina/cadastro_regra_cortina/regra_cortina.js?versao=3.259.1.1`;
      const nomeTela = ('<?php echo basename(__FILE__) ?>').replace('.php', '');

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

      const permissaoUsuarioLogado = await permissaoAcessos("REGRA_CORTINA");

      if (permissaoUsuarioLogado.INCLUI == 'N') {
        await criaMensagemErro("Sem permissão para incluir!", () => {
          window.location.href = `${BASE_URI}/regra_cortina`
        });
        return;
      }

      await insereJavaScriptPagina(sArquivo);

      habilitaCamposObrigatoriosTela(nomeTela);
    });
  </script>
</body>

</html>