<?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 Produção Simples</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.243.6.1">
  <link rel="stylesheet" href="../dist/css/adminlte.min.css?versao=3.243.6.1">
  <link rel="stylesheet" href="../dist/css/custom.css?versao=3.243.6.1">
  <link rel="stylesheet" href="../dist/css/sisplan.css?versao=3.243.6.1">
  <link rel="stylesheet" type="text/css" href="../plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.243.6.1">
  <link rel="stylesheet" href="../plugins/toastr/toastr.min.css?versao=3.243.6.1">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.243.6.1">
  <link rel="shortcut icon" href="../favicon.ico">
  <link rel="stylesheet" type="text/css" href="../dist/css/driver.min.css?versao=3.243.6.1" />
  <link rel="stylesheet" href="../dist/css/jquery-ui.css?versao=3.243.6.1">
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <link rel="stylesheet" href="../dist/css/cadastro.css?versao=3.243.6.1">
  <style>
    #progressbar li {
      list-style-type: none;
      font-size: 12px;
      width: 50%;
      float: left;
      position: relative;
    }

    #progressbar {
      margin-left: 0% !important;
    }

    #ItensOF {
      margin-top: 15px;
    }

    #QuantidadeBaixada {
      margin-top: 15px;
    }
  </style>
</head>

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

    <div id="myModal" class="modal" tabindex="-1" role="dialog">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 id="myModalLabel" class="modal-title"></h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <div class="modal-body">
            <p id="myModalText"></p>
          </div>
          <div class="modal-footer">
            <button id="btnYes" type="button" class="btn btn-primary">Sim</button>
            <button id="btnNo" type="button" class="btn btn-secondary" data-dismiss="modal">Não</button>
          </div>
        </div>
      </div>
    </div>
    <div id="myModal" class="modal" tabindex="-1" role="dialog">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 id="myModalLabel" class="modal-title"></h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <div class="modal-body">
            <p id="myModalText"></p>
          </div>
          <div class="modal-footer">
            <button id="btnYes" type="button" class="btn btn-primary">Sim</button>
            <button id="btnNo" type="button" class="btn btn-secondary" data-dismiss="modal">Não</button>
          </div>
        </div>
      </div>
    </div>
    <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"></h1>
            </div>
            <div class="col-sm-6">
              <!-- <ol class="breadcrumb float-sm-right">
                
                <li class="breadcrumb-item active"><a href="../ordemproducao">Acesso Ordem de Produção Simples</a></li>
                <li class="breadcrumb-item active">Cadastro Ordem de Produção Simples</li>
              </ol> -->
            </div>
          </div>
        </div>
        <div class="row justify-content-center mt-0">
          <div class="col-10 text-left p-0 mt-3 mb-2">
            <div class="card px-0 pt-4 pb-0 mt-3 mb-3">
              <h2>
                <strong class="ml-4">Ordem de Produção Simples</strong>
                <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>
              </h2>
              <div class="row">
                <div class="col-md-12 mx-0">
                  <form id="msform">
                    <ul id="progressbar">
                      <li class="active" id="account"><strong>Dados da OF</strong></li>
                      <li id="payment"><strong>Itens da OF</strong></li>
                    </ul>
                    <p>Preencha os dados e clique em avançar para realizar o cadastro da Ordem de Produção</p>
                    <fieldset>
                      <div class="form-card" id="formcard1">
                        <h2 class="fs-title">Dados Gerais</h2>
                        <div class="row">
                          <div class="col-5">
                            <label data-error="wrong" data-success="right" for="txtPeriodo">Período *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtPeriodo" name="txtPeriodo" class="form-control" placeholder="Período">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Periodo" name="btn-Periodo" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Periodo" name="btn-limpa-Periodo" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-5">
                            <div class="group-default form-group">
                              <label for="txtSituacao">Tipo OF </label>
                              <div class="relative">
                                <select id="txtSituacao" class="input-default focus form-control validate">
                                  <option value="Normal" selected>Normal</option>
                                  <option value="Reprocesso">Reprocesso</option>
                                </select>
                              </div>
                            </div>
                          </div>
                          <div class="col-2 form-group">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtPrioridade">Prioridade</label>
                            <div class="input-group">
                              <input type="number" autocomplete="off" class="input-default focus form-control" id="txtPrioridade" name="txtPrioridade" class="form-control" placeholder="Prioridade">
                            </div>
                          </div>
                          <div class="col-4" id="ColunaOrdem">
                            <label data-error="wrong" data-success="right" for="txtNumeroOrdem">Ordem Número *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control validate" aria-describedby="ordemError" id="txtNumeroOrdem" name="txtNumeroOrdem" class="form-control" placeholder="Numero Ordem de Produção">
                              <div class="input-group-append">
                                <!-- <button class="btn bg-danger" id="btn-Ordem" name="btn-Ordem" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button> -->
                                <button class="btn bg-danger" id="btn-limpa-Ordem" name="btn-limpa-Ordem" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-3" id="lblPedido">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtPedido">Pedido</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtPedido" name="txtPedido" class="form-control" placeholder="Pedido">
                            </div>
                          </div>
                          <div class="col-3" id="lblReprocesso">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtReprocesso">Reprocesso</label>
                            <div class="input-group">
                              <input type="number" autocomplete="off" class="input-default focus form-control" id="txtReprocesso" name="txtReprocesso" class="form-control" disabled placeholder="Número Reprocesso">
                            </div>
                          </div>
                          <div class="col-2">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtPerda">Perda </label>
                            <div class="input-group">
                              <input type="number" autocomplete="off" class="input-default focus form-control" id="txtPerda" name="txtPerda" class="form-control" placeholder="Perda">
                            </div>
                          </div>
                          <div class="col-6">
                            <label data-error="wrong" data-success="right" for="txtCliente">Cliente *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtCliente" name="txtCliente" class="form-control" placeholder="Código do Cliente">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Cliente" name="btn-Cliente" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Cliente" name="btn-limpa-Cliente" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-6">
                            <label data-error="wrong" data-success="right" for="txtFaccao">Facção *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtFaccao" name="txtFaccao" class="form-control" placeholder="Facção">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Faccao" name="btn-Faccao" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Faccao" name="btn-limpa-Faccao" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-5">
                            <label data-error="wrong" data-success="right" for="txtSetor">Setor *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtSetor" name="txtSetor" class="form-control" placeholder="Código do Setor">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Setor" name="btn-Setor" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Setor" name="btn-limpa-Setor" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-5">
                            <label data-error="wrong" data-success="right" for="txtParte">Parte *</label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtParte" name="txtParte" class="form-control" placeholder="Código da Parte">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Parte" name="btn-Parte" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Parte" name="btn-limpa-Parte" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                          <div class="col-2">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtPreco">Preço </label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtPreco" name="txtPreco" class="form-control" placeholder="Preço">
                            </div>
                          </div>
                          <div class="col-4">
                            <div class="group-default form-group">
                              <label for="txtDataSaida">Data Saída </label>
                              <div class="relative">
                                <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="txtDataSaida" name="txtDataSaida">
                              </div>
                            </div>
                          </div>
                          <div class="col-4">
                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtPeso">Peso </label>
                            <div class="input-group">
                              <input type="text" max="2500-12-31" autocomplete="off" class="input-default focus form-control" id="txtPeso" name="txtPeso" class="form-control" placeholder="Peso">
                            </div>
                          </div>
                          <div class="col-4">
                            <div class="group-default form-group">
                              <label for="txtDataRetornoFim">Data Retorno </label>
                              <div class="relative">
                                <input type="date" max="2500-12-31" value="2500-12-31" class="input-default focus form-control validate" id="txtDataRetornoFim" name="txtDataRetornoFim">
                              </div>
                            </div>
                          </div>
                          <div class="col-12">
                            <label for="txtObs" class="form-label">Observação </label>
                            <textarea style="resize: none" class="input-default form-control" id="txtObs" cols="50" rows="5"></textarea>
                          </div>
                        </div>
                      </div>
                      <input type="button" name="avancar1" class="btn-sisp next action-button" id="avancar1" value="Avançar" />
                      <button type="button" id="btnVoltar" style="font-size:15px;" class="btn-sisp action-button-previous" data-dismiss="modal">Voltar</button>
                    </fieldset>
                    <fieldset>
                      <div class="form-card" id="formcard2">
                        <div class="row">
                          <div class="col-12">
                            <label data-error="wrong" data-success="right" for="txtProduto">Produto </label>
                            <div class="input-group">
                              <input type="text" autocomplete="off" class="input-default focus form-control" id="txtProduto" name="txtProduto" class="form-control" placeholder="Código do Produto">
                              <div class="input-group-append">
                                <button class="btn bg-danger" id="btn-Produto" name="btn-Produto" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                <button class="btn bg-danger" id="btn-limpa-Produto" name="btn-limpa-Produto" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                              </div>
                            </div>
                          </div>
                        </div>
                        <h2 class="fs-title" id="ItensOF">Itens da OF</h2>
                        <div>
                          <div class="col-sm-12 table-responsive card-body">
                            <table id="tabelaGradeProduto" class="table table-sm table-select table-hover" width="100%">
                              <thead>
                                <tr id="colunas">
                                </tr>
                              </thead>
                              <tbody>
                              </tbody>
                            </table>
                          </div>
                        </div>
                        <h2 class="fs-title" id="QuantidadeBaixada">Itens Baixados</h2>
                        <div>
                          <div class="col-sm-12 table-responsive card-body">
                            <table id="tabelaQuantidadeBaixada" class="table table-sm table-select table-hover" width="100%">
                              <thead>
                                <tr id="colunasaaaaaa">
                                </tr>
                              </thead>
                              <tbody>
                              </tbody>
                            </table>
                          </div>
                        </div>
                      </div>
                      <input type="button" name="btnGravar" class="action-button" value="Gravar" id="btnGravar" />
                      <input type="button" name="btnFinalizar" class="action-button" value="Finalizar" id="btnFinalizar" />
                      <input type="button" name="btnReabrir" class="action-button d-none" value="Reabrir" id="btnReabrir" />
                      <input type="button" name="btnCancBaixas" class="action-button" value="Canc. Baixas" id="btnCancBaixas" />
                      <input type="button" name="btnBaixar" class="action-button" value="Baixar" id="btnBaixar" />
                      <input type="button" name="voltar2" class="previous action-button-previous" value="Voltar" id="voltar2" />
                    </fieldset>
                  </form>
                </div>
              </div>
            </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">Baixar quantidades da OF</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="col-3">
                <div class="group-default form-group">
                  <label for="">Data da Baixa:</label>
                  <div class="relative">
                    <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="txtDataBaixa" name="txtDataBaixa">
                  </div>
                </div>
              </div>
              <div class="col-9">
                <label data-error="wrong" data-success="right" for="txtFuncionarioBaixa">Funcionário </label>
                <div class="input-group">
                  <input type="text" autocomplete="off" class="input-default focus form-control" id="txtFuncionarioBaixa" name="txtFuncionarioBaixa" class="form-control" placeholder="Funcionário">
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btn-Funcionario" name="btn-Funcionario" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btn-limpa-Funcionario" name="btn-limpa-Funcionario" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 table-responsive card-body">
                <table id="tabelaBaixaProdutos" class="table table-sm table-select table-hover" width="100%">
                  <thead>
                    <tr id="colunas">
                      <th>Cor</th>
                      <th>Descrição</th>
                      <th>Tam</th>
                      <th>Qtde</th>
                      <th>Qtde Baixa</th>
                      <th>Qtde 2</th>
                      <th>Qtde I</th>
                      <th>Baixado</th>
                      <th>Peso</th>
                      <th>Talhado</th>
                      <th>Peso Estoque</th>
                    </tr>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <div class="modal-footer d-flex justify-content-between">
            <button class="btn btn-secondary btn-sisp" id="btnZeraQtdeBaixa"><span class="fas fa-trash"></span> Zera Qtde Baixa</button>
            <div>
              <button class="btn btn-primary btn-sisp" id="btnDesistirBaixa" style="background-color: #B22222; border-color: #B22222"><span class="fas fa-trash"></span> Cancelar</button>
              <button class="btn btn-primary btn-sisp" id="btnBaixarQuantidadesOF" style="background-color: #228B22; border-color: #228B22"><span class="fas fa-check-circle"></span> Baixar</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div id="modal-filtrosCancelar" 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">Cancelar quantidades da OF</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="col-3">
                <div class="group-default form-group">
                  <label for="">Data da Baixa:</label>
                  <div class="relative">
                    <input type="date" max="2500-12-31" value="1200-01-01" class="input-default focus form-control validate" id="txtDataBaixa" name="txtDataBaixa">
                  </div>
                </div>
              </div>
              <div class="col-9">
                <label data-error="wrong" data-success="right" for="txtFuncionarioBaixa">Funcionário </label>
                <div class="input-group">
                  <input type="text" autocomplete="off" class="input-default focus form-control" id="txtFuncionarioBaixa" name="txtFuncionarioBaixa" class="form-control" placeholder="Funcionário">
                  <div class="input-group-append">
                    <button class="btn bg-danger" id="btn-Funcionario" name="btn-Funcionario" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                    <button class="btn bg-danger" id="btn-limpa-Funcionario" name="btn-limpa-Funcionario" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                  </div>
                </div>
              </div>
              <div class="col-sm-12 table-responsive card-body">
                <table id="tabelaBaixaCancelar" class="table table-sm table-select table-hover" width="100%">
                  <thead>
                    <tr id="colunas">
                      <th>Cor</th>
                      <th>Descrição</th>
                      <th>Tam</th>
                      <th>Qtde</th>
                      <th>Qtde Baixa</th>
                      <th>Qtde 2</th>
                      <th>Qtde I</th>
                      <th>Baixado</th>
                      <th>Peso</th>
                      <th>Talhado</th>
                      <th>Peso Estoque</th>
                    </tr>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <div class="row">
              <button class="btn btn-primary btn-sisp" id="btnCancelarBaixa" style="background-color: #B22222; border-color: #B22222"><span class="fas fa-trash"></span> Cancelar</button>     
              <button class="btn btn-primary btn-sisp" id="btnBaixar" style="background-color: #228B22; border-color: #228B22"><span class="fas fa-check-circle"></span> Baixar</button>
            </div>
          </div>
        </div>
      </div>
    </div>



  </div>

  <?php
  include_once('../../../footer.php');
  ?>
  <aside class="control-sidebar control-sidebar-dark">
  </aside>
  </div>
  <script src="../plugins/jquery/jquery.min.js?versao=3.243.6.1"></script>
  <script src="../plugins/jquery-ui/jquery-ui.min.js?versao=3.243.6.1"></script>
  <script type="text/javascript" src="../dist/js/jquery.dataTables.js?versao=3.243.6.1"></script>
  <script type="text/javascript" src="../dist/js/dataTables.bootstrap4.min.js?versao=3.243.6.1"></script>
  <script src="../plugins/sweetalert2/sweetalert2.min.js?versao=3.243.6.1"></script>
  <script src="../plugins/toastr/toastr.min.js?versao=3.243.6.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <script src="../plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/adminlte.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/requisicoes.js?versao=3.243.6.1"></script>
  <script src="../dist/js/sisplan.js?versao=3.243.6.1"></script>
  <script src="../dist/js/cliente/entidade.js?versao=3.243.6.1"></script>
  <script src="../dist/js/loadingoverlay.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/valida_cpf_cnpj.js?versao=3.243.6.1"></script>
  <script src="../plugins/jquery-validation/jquery.validate.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/dataTables.keyTable.js?versao=3.243.6.1"></script>
  <script src="../utils/funcoes.js?versao=3.243.6.1"></script>
  <script src="../utils/cookies.js?versao=3.243.6.1"></script>
  <script src="../dist/js/jquery.maskMoney.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/jquery.mask.min.js?versao=3.243.6.1"></script>
  <script src="../dist/js/driver.min.js?versao=3.243.6.1"></script>
  <script type="text/javascript" src="../config.js?versao=3.243.6.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('ORDEMPRODUCAO');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

      const permissaoUsuarioLogado = await permissaoAcessos("ORDEMPRODUCAO");

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

      sArquivo = `${BASE_URI}/pages/ordemproducao/cadastro_ordemproducao/ordemproducao.js?versao=3.243.6.1`;
      insereJavaScriptPagina(sArquivo);
    });
  </script>
</body>

</html>