<?php
$usuario = $_COOKIE["usuario"];
$nivel = $_COOKIE["nivel"];
if($nivel=="Master"){$usuario="";}



if($nivel=="Asistente"){
		echo "<script>window.location.href='../api/main.php'</script>";
}

if($nivel=="Supervisor"){
	echo "<script>window.location.href='../clientes/creditos_cobrador.php'</script>";
}

if($nivel=="Digitador"){
	echo "<script>window.location.href='../api/main.php'</script>";
}
 include("../header.php");

 include_once("../php/config.php");


 $sql = @mysql_query("select * from empresa") or die(mysql_error());
  $ventas = @mysql_query("select sum(total) as total from ventas where fecha='$hoy' and usuario='".$_COOKIE['usuario']."' and termino!='Credito' and estado='Cerrada'") or die(mysql_error());
  $devoluciones = @mysql_query("select sum(importe) as total from devoluciones where fecha='$hoy' and usuario='$usuario'") or die(mysql_error());
  $pedidos = @mysql_query("select sum(total) as total from ventas where fecha='$hoy' and estado='Pedido'") or die(mysql_error());
  $gastos = @mysql_query("select sum(monto) as total from egresos where fecha='$hoy'") or die(mysql_error());
  $pagos = @mysql_query("select sum(monto) as total from pagos_credito where fecha='$hoy'") or die(mysql_error());

  ///$inventario = @mysql_query("select * from inventario") or die(mysql_error());
 
 $empresa = @mysql_result($sql,0,"nombre");
 $telefono = @mysql_result($sql,0,"telefono");
 $direccion = @mysql_result($sql,0,"direccion");
 $rnc = @mysql_result($sql,0,"rnc");
 
   
  $params = mysql_query("select * from parametros") or die(mysql_error());
  $default_menu_pos = @mysql_result($params, 0, "default_menu_pos");

?>  

<style>
.card-box {
    position: relative;
    color: #fff;
    padding: 20px 10px 40px;
    margin: 20px 0px;
	height:125px;
}
.card-box:hover {
    text-decoration: none;
    color: #f1f1f1;
}
.card-box:hover .icons i {
    font-size: 100px;
    transition: 1s;
    -webkit-transition: 1s;
}
.card-box .inner {
    padding: 5px 10px 0 10px;
}
.card-box h3 {
    font-size: 27px;
    font-weight: bold;
    margin: 0 0 8px 0;
    white-space: nowrap;
    padding: 0;
    text-align: left;
}
.card-box p {
    font-size: 15px;
}
.card-box .icons {
    position: absolute;
    top: auto;
    bottom: 5px;
    right: 5px;
    z-index: 0;
    font-size: 72px;
    color: rgba(0, 0, 0, 0.15);
}
.card-box .card-box-footer {
    position: absolute;
    left: 0px;
    bottom: 0px;
    text-align: center;
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 1, 0.1);
    width: 100%;
    text-decoration: none;
}
.card-box:hover .card-box-footer {
    background: rgba(0, 0, 0, 0.3);
}
.bg-blue {
    background-color: #00c0ef !important;
}
.bg-green {
    background-color: #00a65a !important;
}
.bg-orange {
    background-color: #f39c12 !important;
}
.bg-red {
    background-color: #d9534f !important;
}
body{
	  background:#D2D2D2;
  }



  .container{
    background:white;
  }
  .c2{
    background:#D2D2D2;s
  }
  
  #table_ingresos th td a{
	  font-size:10px;
  }
</style>

<body>
<br><br>
<div class='container-fluid'>
  <div class="container">
<div class="row">

<div class="col-sm-2">
	<div class="card-box bg-blue">
                    <div class="inner">
                        <h3>  <span id="clientes" style="font-size: 25px;"><?php echo @decimal(mysql_result($ventas, 0, "total"))?></span> </h3>
                        <p>Ventas de hoy</p>
                    </div>
                    <div class="icons">
                        <i class="bi bi-cash-coin" aria-hidden="true"></i>
                    </div>
                    <a href="../pos/ventas.php" class="card-box-footer">Ver detalles<i class="fa fa-arrow-circle-right"></i></a>
                </div>
</div>

<div class="col-sm-2">
	<div class="card-box bg-orange">
                    <div class="inner">
                        <h3>  <span id="clientes" style="font-size: 25px;"><?php echo @decimal(mysql_result($pedidos, 0, "total"))?></span> </h3>
                        <p>Pedidos</p>
                    </div>
                    <div class="icons">
                        <i class="bi bi-cart" aria-hidden="true"></i>
                    </div>
                    <a href="../pos/pedidos.php" class="card-box-footer">Ver detalles<i class="fa fa-arrow-circle-right"></i></a>
                </div>
</div>

  

<div class="col-sm-2">
	<div class="card-box bg-green">
                    <div class="inner">
                    <h3>  <span id="clientes" style="font-size: 25px;"><?php echo @decimal(mysql_result($pagos, 0, "monto"))?></span> </h3>

                        <p>Pagos de credito</p>
                    </div>
                    <div class="icons">
                        <i class="bi bi-coin" aria-hidden="true"></i>
                    </div>
                    <a href="../ingresos/ingresos.php" class="card-box-footer">Ver detalles<i class="fa fa-arrow-circle-right"></i></a>
                </div>
</div>

<div class="col-sm-2">
	<div class="card-box bg-red">
                    <div class="inner">
                    <h3>  <span id="clientes" style="font-size: 25px;"><?php echo @decimal(mysql_result($gastos, 0, "monto"))?></span> </h3>

                        <p>Gastos</p>
                    </div>
                    <div class="icons">
                        <i class="bi bi-cash-stack" aria-hidden="true"></i>
                    </div>
                    <a href="../pos/ventas.php" class="card-box-footer">Ver detalles<i class="fa fa-arrow-circle-right"></i></a>
                </div>
</div>
</div>

<?php if($default_menu_pos=="complete"){?>
<div class="col-md-4">
 <div class="panel panel-default" style="height:250px;">
   <div class="panel-body">
   <center>
     <span class="text-verde h4">VERIFICADOR DE PRECIOS</span>
	 <hr>
	 <img src="../img/barcode.jpg" width="100" >
	 
	 <br><br>
	 <form action="" method="POST">
	 <input selected type="text" id="txt_codigo" name="txt_codigo" class="form-control" placeholder="Codigo de barras..">
	
	
	 </form>
	<div id="detalle_precio">
	  <?php 
	  include_once 'check_precio.php';
	  echo "<span class='text-primary h5'>".($descripcion)."</span><br>";
	  echo "<span class='text-primary h4'><b>RD$".decimal($precio_)."</b></span>";
	 ?>
	</div>
  </center>
   
   </div>
 </div>

</div>

<?php }?>

<div class="col-md-8">
 <div class="panel panel-default" style="height:250px;">
   <div class="panel-body">
   <center>
     <span class="text-verde h4">LISTA DE VENTAS PARA COBRAR
	 </span>
	 <hr>
	
	
	 
	<div id="detalle_ventas">
	  <?php 
	  include_once 'ventas_pendiente.php';
	  
	 ?>
	</div>
  </center>
   
   </div>
 </div>

</div>

</div>
<br>
<div class="container" style="background:white">
  <br>
<div class="row">
  <div class="col-md-5">
    <?php
    include_once 'lista_ventas.php';
    ?>
  </div>

  <div class="col-md-3">
    <?php
    include_once 'lista_ingresos.php';
    ?>
  </div>


  <div class="col-md-3">

    <?php
    include_once 'lista_egresos.php';
    ?>
  </div>
</div>

</div>
    </div>
</body>

<script type="text/javascript">
    
 
    $("#lb_usuario_activo").html(myUser);
     $("#lb_fecha").html(fecha_actual_normal());
     localStorage.setItem("empresa","<?php echo $empresa?>");
     localStorage.setItem("direccion","<?php echo $direccion?>");
     localStorage.setItem("telefono","<?php echo $telefono?>");
     localStorage.setItem("rnc","<?php echo $rnc?>");
	 //get_compra()
     function get_compra() {
	 var hoy = moment().format('YYYY-MM-DD')
 
    var sql = "select * from compra_factoria where fecha_entrega<='" + hoy + "'"
    _enviar("../php/traer_datos.php", {
        "sql": sql
      })
      .done(function(data) {
        var rs = JSON.parse(data);
	    
        for (var i in rs.data) {

		   noti("info",rs.data[i].productor,"Produccion pendientes de pago",);

        }

      })
  }
	
</script>


