
<meta name="viewport" content="width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="mon.png">
<style>
body {
  position: relative;
  z-index: 1;
  @background:gray;
}
body::before {
  content: "";
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;  
  opacity: .10; 
  z-index: -1;
@ background: url("img/bg.jpg");
  background-repeat:no-repeat;
  background-size:cover;
}
</style>
<?php
 include_once("php/config.php");
 $sql = mysql_query("select * from login") or die(mysql_error());
  $sql2 = mysql_query("select * from empresa") or die(mysql_error());
  $logo= @mysql_result($sql2,0,"logo");
?>

<head>

<style type="text/css">
.logo0{
  width:400px;
  height:300px;
}


.barra_lateral{
    
  padding:12px;
  background:#F8F9F9 ;
  width:245px; 
  @border-top:solid 4px green;
  @border-bottom:solid 2px gray;
  
  @box-shadow:1px 2px 1px;
  @border-radius:5px 5px 5px;
  min-height:300px;
  margin-top:-20px;
  margin-left:-20px;
  height:1000px;
  float:left;
}

  .icon{
    width:20px;
    margin-bottom:0px;
  }
  
    .icon2{
    width:20px;
    margin-bottom:-5px;
    
  }
  
.isable{
  color: currentColor;
  cursor: not-allowed;
  opacity: 0.5;
  text-decoration: none;
}


.form-control{
  color:#6D6D6D;
  font-size: 13px;
}

.navbar a:hover{
  color:black;
}

.bold{
  font-weight: bolder;
}

th{
  text-align: center;

}
.ml-2{
  margin-left: 8px;
}

.mr-2{
  margin-right: : 8px;
}

.mt-2{
  margin-top: 8px;
}

.mb-2{
  margin-bottom: 8px;
}
td{
  font-family: Arial;
  font-size: 14px;
  color:gray;
}

</style>

<head>
  <meta charset="utf-8">

<head>
  <meta charset="utf-8">



  <meta name="theme-color" content="#563d7c">
  <title>Sandro-Software | NUBEPOS</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
 <link rel="stylesheet" href="vendor/fa/css/all.min.css">

</head>

<script src="src/jquery.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
        <!-- include the script -->

<link rel="stylesheet" href="vendor/themes/default.min.css" />

<script src="src/datatables.js"></script>
<script src="src/bootstrap_datatable.js"></script>

<script type="text/javascript" src="js/savy.js"></script>
  <script src="js/numeral.js"></script>
        <script src="js/moment.js"></script>
        <script src="js/fechas.js"></script>

<script src="vendor/alertify.min.js"></script>
  <script src="vendor/toastr/toastr.min.js"></script>
<link rel="stylesheet" href="vendor/alertify.min.css" />


</head>
<body id="bd">
  <br>

  <center>
    <div id="logo" style="background:white; width:400px; padding:10px; display:none;">
     <?php if($logo!=""){
          echo "<img class='logo0' src = 'LOGOS/$logo'>";
         }else{
          echo "<img class='logo0' src = 'LOGOS/default.png'>";
        }?>
        
    </div>
    <script>
      $("#logo").show();
      setTimeout(function(){
      $("#logo").hide();
      $(".container").show();
      $("#bd").addClass("bg-primary");
      },2000)
    </script>
  </center>
<div class="container" style="width: 350px; display:none;">


<div class="row">
 


<div class="col-md-12">
    
    <div class="card">
	<div class="panel-heading..">
	    
	</div>
        <div class="card-body">
            <center>
              <img src="img/cloud1.png" class="rounded" alt="Cinque Terre" style="width:100px;">
            <br>
            <small>Sandro-Software®</small><br>
              <span class="h1"><strong>NUBE</strong><span class="font-weight-light">POS</span></span>
        </center>
         
            
            
           
            <hr>
            
          <center>
           <span class="text-primary" class="text-success">Digite sus credenciales</span>
           </center>
           <br>
            <div class="row">
                <div class="col-md-3">
                <label><b>Usuario</b></label>
                </div>
                
                <div class="col-md-9">
                    <select  class="form-control  mb-2 font-weight-light" id="usuarios"  onChange="$('#clave').focus()">

                        <option value="" selected disabled>Sel. Usuario</option>
                        <?php while ($r2 = mysql_fetch_array($sql)) { ?>
                            <option value="<?php echo $r2['nombre'] ?>"> <?php echo $r2['nombre'] ?></option>
                <?php } ?>
                    </select>
                </div>
            </div>
            
            
            
          <div class="row">
          <label for="id" class="col-sm-3 col-form-label" ><b>Clave</b></label>
          <div class="col-sm-9">
            <input autocomplete="off" type="password"  class="form-control mb-2 font-weight-light" id="clave" name="clave" value="">
          </div>
        </div>
          
          
  <center>
           <button  class="btn btn-primary col-12" onclick="login()"><i class="fa fa-key"></i> Acceder al sistema</button>
       
          <hr>
          <strong><?php echo mysql_result($sql2,0,"nombre")?></strong><br>
          <?php echo mysql_result($sql2,0,"direccion")?><br>
          <?php echo mysql_result($sql2,0,"telefono")?>
          <hr>
           <small class="text-primary"><a href="init.php"><i class="fa fa-tools"></i> Config. servidor</a></small>
  </center>
		 
          
	        
		<input type="hidden" id="db" name="db">
            
     </div>       
        </div>
    </div>
</div>

</body>
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="js/sb-admin-datatables.min.js"></script>

	<script type="text/javascript" src="../js/savy.js"></script>
	<script src="js/numeral.js"></script>
        <script src="js/moment.js"></script>
        <script src="js/fechas.js"></script>

     
        <!-- include the script -->

  <script src="js/select2.js"></script>
  <script src="vendor/toastr/toastr.min.js"></script>
  
  
  
  
  <script>
  setup();

 function setup(){
	
	 if(localStorage.getItem("caja")==""){localStorage.setItem("caja", "01");}
	 if(localStorage.getItem("terminal")==""){localStorage.setItem("terminal", "01");}
	 if(localStorage.getItem("db")=="null" || localStorage.getItem("db")==""){localStorage.setItem("db", "base_prueba");}
	 if(localStorage.getItem("almacen2")==""){localStorage.setItem("almacen2", "ALMACEN-2");}
	 if(localStorage.getItem("estado_caja")==""){localStorage.setItem("estado_caja", "abierta");}
	 if(localStorage.getItem("servidor")==""){localStorage.setItem("servidor", "217.71.203.122");}
	 if(localStorage.getItem("almacen")==""){localStorage.setItem("almacen", "Almacen-1");}
 }
 
 
  window.addEventListener('popstate', function (event) {
  history.pushState(null, document.title, location.href);
});


  $("#db").val(localStorage.getItem("db"));

  function login(){
      var nombre=$("#usuarios").val();
      var clave=$("#clave").val();
      var db=$("#db").val();
      try{
        $.post( "php/login.php", { nombre: nombre, clave: clave, db: db})
        .done(function( data ) {
            data = JSON.parse(data);
            if(data.resp=="1"){
               // alert(data.nivel);
                localStorage.setItem("nivel",data.nivel);
                localStorage.setItem("usuario",data.nombre);
                var usuario = data.nombre;
                var nivel = data.nivel;
                var urlString = "nivel="+nivel+"&usuario="+usuario;
				if(nivel=="Cobrador"){
					window.location.href="api/clientes.php";
				}else{
					window.location.href="menu/menu.php?"+urlString;
				}
            }else{
                alert(data.resp)
            }
           
        });
      }catch(e){
          alert(e.message);
      }
  }
  </script>    