<?php include_once('../../config.php') ?>
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Sisplan Web | Importação de Produto</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/adminlte.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css?versao=3.263.17.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.263.17.1">
  <link rel="stylesheet" href="dist/css/sisplan.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/PesquisaVariosSelect2.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="dist/css/dataTables.bootstrap4.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.263.17.1">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="dist/css/select.bootstrap.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="dist/css/jquery-ui.css?versao=3.263.17.1">
  <link rel="stylesheet" type="text/css" href="dist/css/driver.min.css?versao=3.263.17.1" />
  <link rel="stylesheet" href="plugins/select2/css/select2.min.css?versao=3.263.17.1">
  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.263.17.1">

  <style>
    .importFile {
      border-radius: 8px;
      border: 1px dashed rgb(172, 70, 70);
      background: var(--modal-content-color);
      height: 120px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .importFile i {
      width: 36px;
      height: 36px;
      font-size: 34px;
    }

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

    .dragover {
      border-radius: 8px;
      border: 1px dashed rgb(70, 121, 172);
      transition: 0.2s ease;
      background: var(--modal-content-color);
    }
    
    .table.dataTable tbody td,
    .table.dataTable thead {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .table.dataTable tr td,
    .table.dataTable tr td,
    .table.dataTable th {
      padding: 4px 12px;
    }

  </style>
  <link rel="stylesheet" href="./plugins/toastr/toastr.min.css">

</head>

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

    <div class="content-wrapper">
      <section class="content">
        <div class="row justify-content-center mt-0">
          <div class="col-10 text-center p-0 mt-3 mb-2">
            <div class="card px-0 pt-4 pb-0 mt-3 mb-3">
              <div class="card-header text-center flex" style="border-bottom: 2px solid var(--primary-color);">
                <h2>Importação de Produto
                  <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>
              <div class="row p-4">
                <div class="col-12 col-sm-12" id="importDrag">
                  <label for="fileImportCSV" class="pointer drag labelImport" style="width: 100%">
                    <input type="file" class="d-none" id="fileImportCSV" accept=".csv">
                    <div class="importFile">
                      <div class="d-flex align-items-center justify-content-center" style="flex-direction: column;">
                        <i class="fas fa-cloud-upload-alt"></i>
                        <span class="mt-2">Importar arquivos CSV</span>
                        <p>Clique para selecionar o arquivo que deseja importar</p>
                      </div>
                    </div>
                  </label>

                  <button id="btnImportar" type="button" class="btn btn-danger btn-block mt-1">
                    Importar
                  </button>
                </div>
              </div>

              <div id="progressBarImport" class="m-4 d-none">
                <div class="progress" style="height: 10px;">
                  <div class="progress-bar text-center" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="60" style="width: 60%">
                  </div>
                </div>
              </div>

              <div class="card card-body mb-0">
                <div class="flex flex-column col-12">
                  <div class="table-responsive">
                    <table id="tabelaProdutos" class="table table-select table-hover" width="100%">
                      <thead>
                      </thead>
                      <tbody>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>

    <aside class="control-sidebar control-sidebar-dark">
    </aside>

    <?php
    include_once('../../modais.php');
    ?>
  </div>

  <script src="plugins/jquery/jquery.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/jquery.dataTables.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/dataTables.bootstrap4.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/loadingoverlay.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-ui/jquery-ui.min.js?versao=3.263.17.1"></script>
  <script>
    $.widget.bridge('uibutton', $.ui.button)
  </script>
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/adminlte.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/sisplan.js?versao=3.263.17.1"></script>
  <script src="plugins/sweetalert2/sweetalert2.min.js?versao=3.263.17.1"></script>
  <script src="plugins/toastr/toastr.min.js?versao=3.263.17.1"></script>
  <script src="dist/js/requisicoes.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="dist/js/sum().js?versao=3.263.17.1"></script>
  <script src="utils/cookies.js?versao=3.263.17.1"></script>
  <script src="dist/js/jquery.maskMoney.min.js?versao=3.263.17.1"></script>
  <script src="pages/loja/js/rotinas.js?versao=3.263.17.1"></script>
  <script src="dist/js/dataTables.keyTable.js?versao=3.263.17.1"></script>
  <script src="dist/js/driver.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-validation/jquery.validate.min.js?versao=3.263.17.1"></script>
  <script src="plugins/jquery-validation/additional-methods.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="config.js?versao=3.263.17.1"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js"></script>
  <script src="plugins/select2/js/select2.full.min.js?versao=3.263.17.1"></script>
  <script type="text/javascript" src="utils/funcoes.js?versao=3.263.17.1"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.2/papaparse.min.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('IMPORTACAO_PRODUTO');
      if (!temAcesso.resultado) {
        toastrAcesso(temAcesso, BASE_URI);
        return;
      }

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

</html>