<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Recálculo de Pedido
  </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.2412.10.1">

  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.2412.10.1">
  <link rel="stylesheet" href="dist/css/custom.css?versao=3.2412.10.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.2412.10.1">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.2412.10.1">
  <!-- Toastr -->
  <link rel="stylesheet" href="plugins/toastr/toastr.min.css?versao=3.2412.10.1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.2412.10.1">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.2412.10.1" />
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.2412.10.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.2412.10.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.2412.10.1">
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.2412.10.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;
  }


  .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%;
  }

  .bordaProduto {
    padding: 10px;
    border: solid #e0e4e6;
    border-radius: 4px;
    border-width: 2px;
  }

  .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    float: left;
  }

  .modalFooterFixo {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #171f21;
    z-index: 999999;
  }

  .table.dataTable tbody td {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 200px;
  }

  .content-header {
    margin-bottom: 1% !important;
  }

  .sidebar-collapse .sidebar-margin {
    margin-left: 5%;
  }

  .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;
  }

  @media (min-width: 1200px) and (max-width: 5000px) {
    #fildsetOption {
      bottom: -17px
    }

    #consultarEstilizado {
      bottom: -19px;
    }
  }
</style>

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

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


    <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">Recálculo de Pedido </h4>
                    <button title="Tutorial" class="btn btn-info btn-sm ml-2" id="tutorial">
                      <i class="fas fa-question-circle"></i>
                    </button>
                  </div>
                </div>
                <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 pb-3" style="padding-top: 10px;">
                        <div class="tab-pane fade show active" role="tabpanel" aria-labelledby="dados-tab">
                          <label for="divGeral">Dados Pedido</label>
                          <div class="form-row bordaProduto" id="divGeral">
                            <div class="col-md-12 col-12">
                              <div class="form-row">

                                <div class="col-12">
                                  <div class="row">
                                    <div class="col-md-auto col-12 form" style="margin-top: 7px;">
                                      <div class="group-default">
                                        <fieldset class="form border-Field mb-0 pb-0">
                                          <legend class="textoBorda mb-0 pb-0">Tipo</legend>
                                          <div class="form-row justify-content-lg-start justify-content-center">
                                            <div class="radio-group form-radio">
                                              <label>
                                                <input type="radio" checked="checked" id="tipoMaterial" value="P" name="tipoConsulta">
                                                <span></span>Produto</label>
                                            </div>
                                            <div class="radio-group form-radio">
                                              <label class="ml-3">
                                                <input type="radio" id="tipoProduto" value="M" name="tipoConsulta">
                                                <span></span>Material</label>
                                            </div>
                                          </div>
                                        </fieldset>
                                      </div>
                                    </div>
                                  </div>
                                </div>

                                <div class="col-xl-4 col-12 form-group">
                                  <label data-error="wrong" class="labelGeral" data-success="right" for="txtPedido">Pedido:</label>
                                  <div class="input-group">
                                    <input type="text" class="input-default focus form-control" id="txtPedido" name="txtPedido" class="form-control" placeholder="Pedido">
                                    <div class="input-group-append">
                                      <button class="btn bg-danger" id="btnPedido" name="btnPedido" data-button="absolute" type="button">
                                        <i class="m-0 p-0 fas fa-search"></i>
                                      </button>
                                      <button class="btn bg-danger" id="btnLimpaPedido" type="button">
                                        <i class="m-0 p-0 fas fa-trash"></i>
                                      </button>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-xl-4 col-12 form-group">
                                  <label data-error="wrong" class="labelGeral" data-success="right" for="txtCliente">Cliente:</label>
                                  <div class="input-group">
                                    <input type="text" class="input-default focus form-control" id="txtCliente" name="txtCliente" class="form-control" placeholder="Cliente">
                                    <div class="input-group-append">
                                      <button class="btn bg-danger" id="btnCliente" name="btnCliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                      <button class="btn bg-danger" id="btnLimpaCliente" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-xl-4 col-12 form-group">
                                  <label style="margin-bottom: .1rem;" data-error="wrong" data-success="right" for="txtRepresentante">Representante: </label>
                                  <div class="relative" style="margin-top: 5px;">
                                    <div class="input-group">
                                      <input type="text" class="input-default focus form-control" id="txtRepresentante" name="txtRepresentante" class="form-control" placeholder="Representante">
                                      <div class="input-group-append">
                                        <button class="btn bg-danger" id="btnRepresentante" name="btnRepresentante" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                        <button class="btn bg-danger" id="btnLimpaRepresentante" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-xl-5 col-12 form-group" id="labelProduto">
                                  <label style="margin-bottom: .1rem;" data-error="wrong" data-success="right" for="txtProduto">Produto: </label>
                                  <div class="relative" style="margin-top: 6px;">
                                    <div class="input-group">
                                      <input type="text" class="input-default focus form-control" id="txtProduto" name="txtProduto" class="form-control" placeholder="Produto">
                                      <div class="input-group-append">
                                        <button class="btn bg-danger" id="btnProduto" name="btnProduto" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                        <button class="btn bg-danger" id="btnLimpaProduto" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-xl-5 col-12 d-none form-group" id="labelMaterial">
                                  <label style="margin-bottom: .1rem;" data-error="wrong" data-success="right" for="txtMaterial">Material: </label>
                                  <div class="relative" style="margin-top: 6px;">
                                    <div class="input-group">
                                      <input type="text" class="input-default focus form-control" id="txtMaterial" name="txtMaterial" class="form-control" placeholder="Material">
                                      <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" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-xl-5 col-lg-10 col-md-12 form-group">
                                  <label data-error="wrong" class="labelGeral" data-success="right" for="txtTabelaPreco">Tabela de Preço:</label>
                                  <div class="input-group">
                                    <input type="text" class="input-default focus form-control" id="txtTabelaPreco" name="txtTabelaPreco" class="form-FFcontrol" placeholder="Tabela de Preço">
                                    <div class="input-group-append">
                                      <button class="btn bg-danger" id="btnTabelaPreco" name="btnTabelaPreco" data-button="absolute" type="button">
                                        <i class="m-0 p-0 fas fa-search"></i>
                                      </button>
                                      <button class="btn bg-danger" id="btnLimpaTabelaPreco" type="button">
                                        <i class="m-0 p-0 fas fa-trash"></i>
                                      </button>
                                    </div>
                                  </div>
                                </div>
                                <div class="col-lg-1 col-6 form-group">
                                  <label for="selectPrazo">Prazo:</label>
                                  <div class="relative">
                                    <select id="selectPrazo" class="input-default focus form-control validate" disabled name="selectPrazo">
                                      <option value="00">00</option>
                                    </select>
                                  </div>
                                </div>
                                <div class="col-6 col-lg-1 form-group">
                                  <label data-error="wrong" class="labelGeral" data-success="right" for="txtPedido">Indice:</label>
                                  <div class="input-group">
                                    <input type="number" class="input-default focus form-control" id="txtIndice" name="txtIndice" class="form-control" value="1" placeholder="Indice">
                                  </div>
                                </div>

                                <div class="col-xl-5 col-lg-12 text-center text-sm-left">
                                  <div>
                                    <fieldset class="form border-Field mb-0 pb-0" id="fildsetOption">
                                      <legend class="textoBorda mb-0 pb-0">Opções</legend>
                                      <div class="ml-auto pr-0 ml-0">
                                        <label class="">
                                          <input type="checkbox" id="cbManterDescontoItem" name="operacao">
                                          <span class="checkmark"></span>
                                          Manter Desconto do Item</label>
                                        <label class="ml-2">
                                          <input type="checkbox" id="cbSemExpedicao" name="operacao">
                                          <span class="checkmark"></span>
                                          Sem Expedição</label>
                                        <label class="ml-2">
                                          <input type="checkbox" id="cbAtualizarTabPrecoPedido" name="operacao">
                                          <span class="checkmark"></span>
                                          Atualizar Tab. Preco Pedido</label>
                                      </div>
                                    </fieldset>
                                  </div>
                                </div>

                                <div class="col-xl-2 col-lg-12 d-flex d-xl-block justify-content-center form-group" id="consultarEstilizado">
                                  <button type="button" id="btnConsultar" class="btn btn-sisp bg-gradient-primary mt-2"><span class="fas fa-search"></span>  Consultar</button>
                                </div>

                                <div class="col-xl-5 col-lg-12 col-12 d-block d-xl-flex align-items-end justify-content-end">
                                  <div class="col-xl-3 col-12">
                                    <label data-error="wrong" data-success="right" for="txtValorOriginal">Valor Original</label>
                                    <input type="text" id="txtValorOriginal" class="form-control" data-bs-toggle="tooltip" value="0,00" readonly>
                                  </div>
                                  <div class="col-xl-3 col-12">
                                    <label data-error="wrong" data-success="right" for="txtValorRecalculo">Valor Recálculo</label>
                                    <input type="text" id="txtValorRecalculo" class="form-control" data-bs-toggle="tooltip" value="0,00" readonly>
                                  </div>
                                  <div class="mt-3 ml-2 d-flex justify-content-center justify-content-xl-end">
                                    <button type="button" id="btnRecalPedido" class="btn btn-sisp bg-gradient-success"><span class="fas fa-calculator"></span> Recalc. Índice</button>
                                    <button type="button" id="btnPrecoTab" class="btn btn-sisp bg-gradient-success ml-2" data-toggle="tooltip" title="Refaz o calculo, com os valores cadastrados na tabela de preço."><span class="fas fa-list-alt"></span> Preço Tab</button>
                                  </div>
                                </div>

                                <div class="col-md-12 col-12 table-responsive bordaProduto mt-2" style="width:100%;">
                                  <table id="tabelaPedido" class="table table-sm table-hover table-select table-condensed" style="width:100%;">
                                    <thead>
                                      <tr>
                                        <th>NUMERO</th>
                                        <th>ORDEM</th>
                                        <th>CODIGO</th>
                                        <th>CODIGO2</th>
                                        <th>DESCRICAO</th>
                                        <th>COR</th>
                                        <th>DESC_COR</th>
                                        <th>TAM</th>
                                        <th>QTDE</th>
                                        <th>QTDE_F</th>
                                        <th>DESC_ITEM</th>
                                        <th>PRECO_ORIG</th>
                                        <th>PRECO</th>
                                      </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                  </table>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="modal-footer p-0 flex align-center">
                        <!-- <div class="p-0 ml-1 sidebar-margin row">
                          <div class="col-3">
                            <label data-error="wrong" data-success="right" for="txtValorOriginal">Valor Original</label>
                            <input type="text" id="txtValorOriginal" class="form-control" data-bs-toggle="tooltip" value="0.00" readonly>
                          </div>
                          <div class="col-3">
                            <label data-error="wrong" data-success="right" for="txtValorRecalculo">Valor Recálculo</label>
                            <input type="text" id="txtValorRecalculo" class="form-control" data-bs-toggle="tooltip" value="0.00" readonly>
                          </div>
                        </div> -->
                        <div style=" margin-left: auto; margin-right: 8px;">
                          <button type="button" id="btnGravar" style="font-size:15px;" class="btn btn-danger btn-sisp action-button">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>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <aside class="control-sidebar control-sidebar-dark">
    </aside>
    <?php
    include_once('../../modais.php');
    ?>
  </main>

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

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

      const permissaoUsuarioLogado = await permissaoAcessos("RECAL_PEDIDO");

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

      await insereJavaScriptPagina(sArquivo);

      habilitaCamposObrigatoriosTela(nomeTela);

      $(function() {
        $('[data-toggle="tooltip"]').tooltip()
      })
    });
  </script>
</body>

</html>