<?php

 // ini_set('display_errors',1);

session_start();
 if($_SESSION['usuariogrupo_id']==1 || $_SESSION['usuariogrupo_id']==2){
		
}
else{ 
 	
	$punven_id = $_SESSION['puntoventa_id'];
}

date_default_timezone_set('America/Lima');
$hora = 17; //date('G');
require_once ("../formatos/formato.php");
require_once ("../formatos/fechas.php");
require_once ("../../config/Cado.php");
require_once ("../empresa/cEmpresa.php");
$oEmpresa = new cEmpresa();
require_once ("../venta/cVenta.php");
$oVenta = new cVenta();
require_once ("../compra/cCompra.php");
$oCompra = new cCompra();
require_once ("../notacredito/cNotacredito.php");
$oNotacredito = new cNotacredito();
require_once ("../guiaremision/cGuiaremision.php");
$oGuiaremision = new cGuiaremision();
require_once ("../cliente/cCliente.php");
$oCliente = new cCliente();
require_once ("../producto/cProducto.php");
$oProducto = new cProducto();
require_once ("../serviciopago/cServiciopago.php");
$oServiciopago = new cServiciopago();
require_once ("../configuracion/cConfiguracion.php");
$oConfiguracion = new cConfiguracion();

$y=date('Y');
$m=date('m');
$d=date('d');
	$dts=$oVenta->mostrarcantXMes('1','01','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_ene=$dt['canttot'];
	mysqli_free_result($dts);
	
	
	$dts=$oVenta->mostrarcantXMes('1','02','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_feb=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','03','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_mar=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','04','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_abr=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','05','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_may=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','06','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_jun=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','07','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_jul=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','08','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_ago=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','09','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_sep=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','10','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_oct=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','11','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_nov=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oVenta->mostrarcantXMes('1','12','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_dic=$dt['canttot'];
	mysqli_free_result($dts);
	$dts=$oCompra->mostrarcantXMes('1','01','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_ene_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	
	$dts=$oCompra->mostrarcantXMes('1','02','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_feb_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','03','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_mar_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','04','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_abr_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','05','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_may_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','06','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_jun_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','07','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_jul_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','08','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_ago_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','09','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_sep_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','10','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_oct_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','11','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_nov_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	$dts=$oCompra->mostrarcantXMes('1','12','1');
	$dt = mysqli_fetch_array($dts);
	$cant_mes_dic_com=$dt['canttot'];
	mysqli_free_result($dts);
	
	
	
$fecha = date('Y-m-d'); 
$dtscli = $oCliente->filtrar('','');
$cancli = mysqli_num_rows($dtscli);

$dtsprod = $oProducto->mostrar_filtro_panel();
$totprod = mysqli_num_rows($dtsprod);
///////
//$dia = 15;
//$d = 1;
//echo '----------'.$hora;

$dtsc=$oConfiguracion->mostrarUno('1');
$dtcon = mysqli_fetch_array($dtsc);
$diaven=$dtcon['tb_configuracion_diaven'];
mysqli_free_result($dtsc);

$fecha_hoy= $diaven.'-'.$m.'-'.$y;
list($day,$mon,$year) = explode('-',$fecha_hoy);
$fecha2dias=date('d-m-Y',mktime(0,0,0,$mon,$day+2,$year));
	
list($day,$mon,$year) = explode('-',$fecha_hoy);
$d2=date('d',mktime(0,0,0,$mon,$day+5,$year));


if($d>=$diaven && $d<=$d2){
$dtspagos = $oServiciopago->versi_pago(fecha_mysql($fecha_hoy),fecha_mysql($fecha2dias));
$rowspago = mysqli_num_rows($dtspagos);

if($rowspago>0){
	
$dias = 'info';	
}else
{
$fecha1=mktime(0,0,0,$m,$d,$y);
$fecha2=mktime(0,0,0,$m,$diaven,$y);
$diferencia=$fecha2-$fecha1;
$dias=$diferencia/(60*60*24);

if($d == $diaven){
	$dias='0';
}
}
}else{
	$dias = 'info';	
}


//echo '-----------------------------------------'.$dias;
$fecha_hoy = date('d-m-Y'); 
list($day,$mon,$year) = explode('-',$fecha_hoy);
$fecha_seis=date('d-m-Y',mktime(0,0,0,$mon,$day-6,$year)); 
$rs1 = $oVenta->ventas_asunat(fecha_mysql($fecha_seis),fecha_mysql($fecha_hoy));
$numrowvensunat = mysqli_num_rows($rs1);
$rs2 = $oNotacredito->notacredito_asunat(fecha_mysql($fecha_seis),fecha_mysql($fecha_hoy));
$numrownotcresunat = mysqli_num_rows($rs2);
$rs3 = $oGuiaremision->guia_asunat(fecha_mysql($fecha_seis),fecha_mysql($fecha_hoy));
$numrowguiasunat = mysqli_num_rows($rs3);
?>

  
  <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h5 class="m-2">Escritorio
			<small>Panel de Control</small>
			<?php echo ' | '.fechaActual(1); ?></h5>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item" >Inicio</li>
				<li class="breadcrumb-item active">Escritorio</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
  </div>
  
  
<div class="col-lg-12 col-sm-12 col-xs-12" style="height: 5px;"></div>
<?php if($numrowvensunat>0){?>
<div class="col-lg-6 col-sm-6 col-xs-12" >
<div class="alert alert-dismissable" style="background-color:#CC0000;color:#fff;">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>¡Cuidado!</strong> Tienes FACTURAS/BOLETAS de los ultimos 7 dias, en <a target="_blank" href="?app=venta"> ventas </a> por enviar a sunat.
</div>
</div>
<?php }?>
<?php if($numrownotcresunat>0){?>
<div class="col-lg-6 col-sm-6 col-xs-12" >
<div class="alert alert-dismissable" style="background-color:#3F729B;color:#fff;">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>¡Cuidado!</strong> Tienes DOCUMENTOS de los ultimos 7 dias, en <a target="_blank" href="?app=notacredito"> notas de credito </a> por enviar a sunat.
</div>
</div>
<?php }?>
<?php if($numrowguiasunat>0){?>
<div class="col-lg-6 col-sm-6 col-xs-12" >
<div class="alert alert-dismissable" style="background-color:#ef6c00;color:#fff;">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>¡Cuidado!</strong> Tienes DOCUMENTOS de los ultimos 7 dias, en <a target="_blank" href="?app=guiaremision"> guias de remision </a> por enviar a sunat.
</div>
</div>
<?php }?>
 
<section class="content">
   
	<div class="container-fluid">
		
	<div class="row">
	
	<div class="col-lg-12 col-sm-12 col-xs-12">
		<small id="msj_escritorio" class="ui-state-highlight ui-corner-all" style="width:auto; float:right; padding:2px; display:none"></small>	
	</div>
	
	<div class="col-lg-12 col-sm-12 col-xs-12 "  >
	<div class="row">
	<div class="col-lg-8 col-sm-8 col-xs-12" >
	<div class="row">
		
		
	<?php if($_SESSION['usuariogrupo_id']==6){
	?>		
   
   
		  
		  <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=venta">
			<div class="info-box">
              <span class="info-box-icon bg-success elevation-1"><i class="fas fa-cart-plus"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">VENTAS</span>
                <span class="info-box-number">     
                  <small>Menú/Ventas</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		    
		   <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=kardex">
			<div class="info-box">
              <span class="info-box-icon bg-warning elevation-1"><i class="fas fa-shopping-basket"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">KARDEX</span>
                <span class="info-box-number">     
                  <small>Menú/Almacen</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		  	 <div class="col-md-3 col-sm-6 col-12">
		   <a href="?app=kardex">
            <div class="info-box bg-gradient-success">
              <span class="info-box-icon"><i class="fas fa-user"></i></span>
              <div class="info-box-content">
                <span class="info-box-text">Menú/Cliente</span>
                <span class="info-box-number">CLIENTES</span>
              </div>            
            </div>
			</a>
          </div>
	
	
	<?php 	
	}else if ($_SESSION['usuariogrupo_id']=='4'){
	?>
	
	<?php 	
	}else{
	?>
				 
		 
		  
		  
		  <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=compra">
			<div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fas fa-shopping-cart"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">COMPRAS</span>
                <span class="info-box-number">     
                  <small>Menú/Compras</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		  <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=venta">
			<div class="info-box">
              <span class="info-box-icon bg-success elevation-1"><i class="fas fa-cart-plus"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">VENTAS</span>
                <span class="info-box-number">     
                  <small>Menú/Ventas</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		  
		   <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=notacredito">
			<div class="info-box">
              <span class="info-box-icon bg-danger elevation-1"><i class="fas fa-cart-plus"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">NT. CREDITO</span>
                <span class="info-box-number">     
                  <small>Menú/Operacion</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		
		 <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=notalmacen">
			<div class="info-box">
              <span class="info-box-icon bg-warning elevation-1"><i class="fas fa-cart-plus"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">NT. ALMACEN</span>
                <span class="info-box-number">     
                  <small>Menú/Almacen</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		  
			<div class="col-12 col-sm-6 col-md-4">
            <a href="?app=producto">
			<div class="info-box">
              <span class="info-box-icon bg-gray elevation-1"><i class="fas fa-dolly-flatbed"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">PRODUCTO</span>
                <span class="info-box-number">     
                  <small>Menú/Mant. Int.</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
		  
		  <div class="col-12 col-sm-6 col-md-4">
            <a href="?app=flujocaja">
			<div class="info-box">
              <span class="info-box-icon bg-info elevation-1"><i class="fab fa-cc-diners-club"></i></span>

              <div class="info-box-content">
				 <span class="info-box-text">CAJA</span>
                <span class="info-box-number">     
                  <small>Menú/Caja</small>
                </span>
				
              </div>  
            </div>
			</a>
          </div>
		  
	
	
	<?php }?>
		<div id="container_reporte_soles" class="col-lg-12 col-sm-12 col-xs-12" style="height:400px;" >
		</div>
	</div>
</div>
	<div class="col-lg-4 col-sm-4 col-xs-12 ">
	<div class="col-lg-12 col-sm-12 col-xs-12 bg-dark" >
	
	<div class="col-lg-12  col-sm-12 col-xs-12">				
		<label for="cmb_fil_puntoventa_id">Punto Venta:</label>
		<select name="cmb_fil_puntoventa_id" id="cmb_fil_puntoventa_id" class="form-control "></select>
	</div>
	
	<div class="col-lg-12 col-sm-12 col-xs-12" style="height:10px;"></div>
	
		<div class="col-lg-12 col-sm-12 col-xs-12 no-padding"  id="div_inforapida">
		
		</div>
		
		<div class="col-md-12 col-sm-12 col-xs-12">
          <div class="info-box">
            <span class="info-box-icon bg-yellow"><i class="fas fa-chalkboard-teacher"></i></span>
            <div class="info-box-content">
              <span class="info-box-text">Total Clientes</span>
              <span style="font-size:3rem;" class="info-box-number"><?php echo $cancli; ?></span>
            </div>
           
          </div>
         
        </div>
		
		<div class="col-md-12 col-sm-12 col-xs-12">
          <div class="info-box">
            <span class="info-box-icon bg-blue"><i class="fas fa-box-open"></i></span>
            <div class="info-box-content">
              <span class="info-box-text">Total Productos</span>
              <span style="font-size:3rem;" class="info-box-number"><?php echo $totprod; ?></span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>
		
		
</div>
</div>
	
	
	
	<?php 
	 if ($_SESSION['usuariogrupo_id']=='6'){}else{
	 ?>
	<div class="col-lg-12 col-sm-12 col-xs-12" style="height:5px;" > </div>
	
	<div class="col-lg-12 col-sm-12 col-xs-12"  > 
		<span class="btn btn-sm btn-primary float-right" style="cursor:pointer;" onclick="cuentapagar()" >Ver cronograma de pagos</span>
	</div>
	
	
	
	<div class="col-lg-12 col-sm-12 col-xs-12" style="height:5px;" > </div>
	
	<div id="div_cuentapagar_inicio" class="col-lg-12 col-sm-12 col-xs-12" > </div>
	 <?php }?>
	</div>
	</div>
</div>
			<div class="modal fade" id="div_cuentacobrar_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg" style="width:90%;"  role="document" >
			<div class="modal-content" style="background:transparent;" >
			<div class="modal-body div_cuentacobrar_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			<div class="modal fade" id="div_cuentapagar_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog" style="width:90%;"  role="document" >
			<div class="modal-content" style="background:transparent;" >
			<div class="modal-body div_cuentapagar_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
<!--MODAL PARA TOMAR PEDIDOS-->
			
			<div class="modal fade" id="div_efectuar_pedidos" role="dialog"  style="overflow-y:scroll;" >
			<div class="modal-dialog " style="width: 95% !important;" >
			<div class="modal-content">
			<div class="modal-body div_efecturar_conte" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>			
			
	<!--MODAL PARA PAGAR PEDIDOS-->
			
			<div class="modal fade" id="div_venta_form" role="dialog" style="padding:0px; overflow-y:scroll ">
			<div class="modal-dialog " style="width: 95% !important;"  >
			<div class="modal-content">
			<div class="modal-body div_venta_form_conten" style="padding:0px;"   >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
	<!--MODAL PARA CORREO ELECTRONICOS-->
			
			
			<div class="modal fade" id="div_venta_correo_form" role="dialog" data-keyboard="false" data-backdrop="static" style="padding:0px; overflow-y:scroll ">
			<div class="modal-dialog modal-lg"  >
			<div class="modal-content">
			<div class="modal-body div_venta_correo_conten" style="padding:0px;"   >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
		<!-- formulario de registro -->
			<div class="modal fade" id="div_venta_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog " style="width: 95% !important;" role="document" >
			<div class="modal-content">
			<div class="modal-body div_venta_form" style="padding:0%;" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
<!-- formulario de nuevo cliente -->
			<div class="modal fade" id="div_cliente_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_cliente_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>			
			
			
			<div class="modal fade" id="div_comprapagoarchivos_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_comprapagoarchivos_form" style="padding:0%;"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
	
		
			<div class="modal " id="div_egreso_form_dialog" role="dialog" style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_egreso_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			<div class="modal fade" id="div_egresoletra_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content ">
			<div class="modal-body div_egresoletra_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			<div class="modal fade" id="div_egresofac_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content ">
			<div class="modal-body div_egresofac_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			<div class="modal fade" id="div_letra_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-lg"  role="document" >
			<div class="modal-content">
			<div class="modal-body div_letra_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
			
			
			
			<!-- formulario de registros-->
			<div class="modal " id="div_mensaje_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px; overflow-y:scroll;">
			<div class="modal-dialog modal-md"  role="document" >
			<div class="modal-content" style="padding:0px;">
			<div class="modal-body div_mensaje"  >
			
		
			
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>		
		
	
	
		<!-- formulario de registro -->
			<div class="modal fade" id="div_compra_form_dialog" role="dialog" data-keyboard="false" data-backdrop="static" tabindex="-1"  style="padding:0px;overflow-y:scroll;">
			<div class="modal-dialog modal-xl" style="width: 95% !important;"   role="document" >
			<div class="modal-content">
			<div class="modal-body div_compra_form" style="padding:0%;" >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			<div class="modal fade" id="div_pago_form_dialog" role="dialog"  tabindex="-1"  style="padding:0px;overflow-y:scroll;">
			<div class="modal-dialog modal-lg" style=""   role="document" >
			<div class="modal-content">
			<div class="modal-body div_pago_form"  >
			</div>
			<br />
			<br />
			</div>
			</div>
			</div>
			
</div>
</section>
  
  
  <script type="text/javascript">
	
<?php if($_SESSION['usuariogrupo_id']==6){
 }else if ($_SESSION['usuariogrupo_id']=='4'){
	 
 }else
{?>
	//cuentacobrar();
	//cuentapagar();
 <?php }?>
	// resumenventas();
	// resumencompras();
	traertipocambio();
    $('#txt_tipcam').keydown(function(e){
      if(e.which==13){
        registrartipocambio($(this).val());
        
        return false;
      }
    });
	
	
	
	
	
	
	
	
	<?php if($dias=='info'){
		
	}else if($dias=='0'){
	    if($hora>=17){
	?>
	
		pago_form('falta','<?php echo $dias?>');
	<?php 
	}
	} else{
	    if($hora>=17){
	?>	
		pago_form('falta','<?php echo $dias?>');
	<?php 
	    }
	}
	?>
	
		function pago_form(act,dias){
				
			$('#div_pago_form_dialog').modal();
			$('body').css('overflow-y','hidden');
			$.ajax({
				type: "POST",
				url: "../serviciopago/serviciopago_form.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: act,
					dias:dias
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('.div_pago_form').html(div);
				},
				success: function(html){
					$('.div_pago_form').html(html);				
				}
			});
		}
	
	
	
	
		
	function compra_form(act,idf,pagar){
			$('#div_compra_form_dialog').modal();
		//$('body').css('overflow-y','hidden');
			$.ajax({
				type: "POST",
				url: "../compra/compra_form.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: act,
					com_id:	idf,
					com_pagar:pagar,
					vista:'cuent_pagar'
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('.div_compra_form').html(div);
				},
				success: function(html){
					$('.div_compra_form').html(html);				
				}
			});
		}
		
	function ver_archivos(compagsid,numdoc){
			$('#div_comprapagoarchivos_form_dialog').modal();
			$('body').css('overflow-y','hidden');
			
			$.ajax({
				type: "POST",
				url: "../cuentapagar/archivos_form.php",
				async:true,
				dataType: "html",                      
				data: ({
					compagsid:compagsid,
					numdoc:numdoc,
					vista:'compra_tabla'
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('.div_comprapagoarchivos_form').html(div);
				},
				success: function(html){
					$('.div_comprapagoarchivos_form').html(html);				
				}
			});
		}
	
function letra_form(act,id_let,vis){	
	
	$('#div_letra_form_dialog').modal('show'); 
	
	$.ajax({
		type: "POST",
		url: "../cuentapagar/letra_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			compag_id : id_let,
			vista:vis
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('.div_letra_form').html(div); 
		},
		success: function(html){
			$('.div_letra_form').html(html);				
		},
		complete: function(html){
		}
	});
}
	function pagos_form(idcompag){
			$('#div_pago_form_dialog').modal();
		//$('body').css('overflow-y','hidden');
			$.ajax({
				type: "POST",
				url: "../egreso/egreso_form_vista.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: 'ver_pagos',
					compag_id:	idcompag,
					vista:'cuenta_pagar'
				}),
				beforeSend: function() {
					var div = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> </div>  </center>";	
					$('.div_pago_form').html(div);
				},
				success: function(html){
					$('.div_pago_form').html(html);				
				}
			});
		}
		
function egresoletra_form(act,id_cp){	
	
	$('#div_egresoletra_form_dialog').modal('show'); 
	
	$.ajax({
		type: "POST",
		url: "../cuentapagar/egreso_cuentapagarletra.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			compag_id : id_cp,
			vista: 'cuentasxpagar_panel'
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('.div_egresoletra_form').html(div); 
		},
		success: function(html){
			$('.div_egresoletra_form').html(html);				
		},
		complete: function(html){
		}
	});
}
		function pagosletra_form(idcompag){
			$('#div_pago_form_dialog').modal();
		
			$.ajax({
				type: "POST",
				url: "../egreso/egreso_form_vista_letra.php",
				async:true,
				dataType: "html",                      
				data: ({
					action: 'ver_pagos',
					compag_id:	idcompag,
					vista:'cuentasxpagar_panel'
				}),
				beforeSend: function() {
					var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('.div_pago_form').html(div);
				},
				success: function(html){
					$('.div_pago_form').html(html);				
				}
			});
		}
	
		
	
function egreso_form(act,id_cp){	
	
	$('#div_egresofac_form_dialog').modal('show'); 
	
	$.ajax({
		type: "POST",
		url: "../cuentapagar/egreso_cuentapagar.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			compag_id : id_cp,
			vista: 'cuentasxpagar_panel'
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					
			$('.div_egresofac_form').html(div); 
		},
		success: function(html){
			$('.div_egresofac_form').html(html);				
		},
		complete: function(html){			
			cuentacobrar();
		}
	});
}
	
	$('#btn_excel_conso_general').click(function() {
		$("#for_conso_general").attr('action', "../cstreporte/reporte_consolidado_general.php");
		$("#for_conso_general").submit();
	});
	
	
// $("#container_ventasdiarias_empresas_soles").highcharts({
    // chart: {
        // plotBackgroundColor: null,
        // plotBorderWidth: null,
        // plotShadow: false,
        // type: 'pie'
    // },
    // title: {
        // text: 'Ventas hoy por empresas en SOLES'
    // },
    // tooltip: {
        // pointFormat: '{series.name}: <b>{point.y} S/ </b>'
    // },
    // plotOptions: {  
        // pie: {
            // allowPointSelect: true,
            // cursor: 'pointer',
            // dataLabels: {
                // enabled: false
            // },
            // showInLegend: true
        // }
    // },
    // series: [{
        // name: 'Ventas ',
        // colorByPoint: true,
        // data: [
	// <?php 
	// $dts1=$oEmpresa->mostrarTodos();
	// while($dt1 = mysqli_fetch_array($dts1))
	// {
	
	
	// $dts=$oVenta->mostrar_ventas_hoy_empresa($dt1["tb_empresa_id"],'1');
	// $dt = mysqli_fetch_array($dts);
	// $can = $dt['tot'];
	// mysqli_free_result($dts);
	
	// if($can==""){
		// $can=0;
	// }else{
		// $can = $can;
	// }
	// ?>
		// {
            // name: '<?php echo $dt1['tb_empresa_razsoc']; ?>',
            // y: <?php echo $can; ?>
        // },
	// <?php 
	// } 
	// ?>	
		// ]
    // }]
// });
	
	
// $("#container_ventasdiarias_empresas_dolares").highcharts({
    // chart: {
        // plotBackgroundColor: null,
        // plotBorderWidth: null,
        // plotShadow: false,
        // type: 'pie'
    // },
    // title: {
        // text: 'Ventas hoy por empresas en DOLARES'
    // },
    // tooltip: {
        // pointFormat: '{series.name}: <b>{point.y} US$ </b>'
    // },
    // plotOptions: {  
        // pie: {
            // allowPointSelect: true,
            // cursor: 'pointer',
            // dataLabels: {
                // enabled: false
            // },
            // showInLegend: true
        // }
    // },
    // series: [{
        // name: 'Ventas ',
        // colorByPoint: true,
        // data: [
	// <?php 
	// $dts1=$oEmpresa->mostrarTodos();
	// while($dt1 = mysqli_fetch_array($dts1))
	// {
	
	
	// $dts=$oVenta->mostrar_ventas_hoy_empresa($dt1["tb_empresa_id"],'2');
	// $dt = mysqli_fetch_array($dts);
	// $can = $dt['tot'];
	// mysqli_free_result($dts);
	
	// if($can==""){
		// $can=0;
	// }else{
		// $can = $can;
	// }
	// ?>
		// {
            // name: '<?php echo $dt1['tb_empresa_razsoc']; ?>',
            // y: <?php echo $can; ?>
        // },
	// <?php 
	// } 
	// ?>	
		// ]
    // }]
// });
	
	
	
	// $("#container_ventas_empresas_soles").highcharts({
	
    // chart: {
        // type: 'column'
    // },
    // title: {
        // text: 'Ventas mensuales por empresas en SOLES'
    // },
    // subtitle: {
        // text: 'Multiempresa administrador'
    // },
    // xAxis: {
        // categories: [
            // 'Ene.',
            // 'Febr.',
            // 'Mar.',
            // 'Abr.',
            // 'May.',
            // 'Jun.',
            // 'Jul.',
            // 'Agos.',
            // 'Sept.',
            // 'Oct.',
            // 'Nov.',
            // 'Dic.'
        // ],
        // crosshair: true
    // },
    // yAxis: {
        // min: 0,
        // title: {
            // text: 'Total de ventas mensuales en soles'
        // }
    // },
    // tooltip: {
        // headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
        // pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            // '<td style="padding:0"><b>{point.y} S/ .</b></td></tr>',
        // footerFormat: '</table>',
        // shared: true,
        // useHTML: true
    // },
    // plotOptions: {
        // column: {
            // pointPadding: 0.2,
            // borderWidth: 0,
			 // dataLabels: {
                // enabled: true,
                // format: '{point.y} S/'
            // }
        // }
    // },
    // series: [
	// <?php 
	// $dts1=$oEmpresa->mostrarTodos();
	// while($dt1 = mysqli_fetch_array($dts1))
	// {
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'01','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_ene=$dt['canttot'];
	// mysqli_free_result($dts);
	
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'02','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_feb=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'03','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_mar=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'04','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_abr=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'05','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_may=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'06','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_jun=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'07','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_jul=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'08','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_ago=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'09','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_sep=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'10','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_oct=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'11','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_nov=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'12','1');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_dic=$dt['canttot'];
	// mysqli_free_result($dts);
	
		
	// ?>
	
	
	// {
        // name: '<?php echo $dt1['tb_empresa_razsoc']; ?>',
        // data: [<?php echo $cant_mes_ene ?>,<?php echo $cant_mes_feb ?>,<?php echo $cant_mes_mar ?>,<?php echo $cant_mes_abr ?>,
		// <?php echo $cant_mes_may ?>,<?php echo $cant_mes_jun ?>,<?php echo $cant_mes_jul ?>,<?php echo $cant_mes_ago ?>,
		// <?php echo $cant_mes_sep ?>,<?php echo $cant_mes_oct ?>,<?php echo $cant_mes_nov ?>,<?php echo $cant_mes_dic ?>]
    // }, 
	// <?php 
	// } 
	// ?>
	
	// ]
// });
	
	
	
	
	// $("#container_ventas_empresas_dolares").highcharts({
	
    // chart: {
        // type: 'column'
    // },
    // title: {
        // text: 'Ventas mensuales por empresas en DOLARES'
    // },
    // subtitle: {
        // text: 'Multiempresa administrador'
    // },
    // xAxis: {
        // categories: [
            // 'Ene.',
            // 'Febr.',
            // 'Mar.',
            // 'Abr.',
            // 'May.',
            // 'Jun.',
            // 'Jul.',
            // 'Agos.',
            // 'Sept.',
            // 'Oct.',
            // 'Nov.',
            // 'Dic.'
        // ],
        // crosshair: true
    // },
    // yAxis: {
        // min: 0,
        // title: {
            // text: 'Total de ventas mensuales en dolares'
        // }
    // },
    // tooltip: {
        // headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
        // pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            // '<td style="padding:0"><b>{point.y} US$ .</b></td></tr>',
        // footerFormat: '</table>',
        // shared: true,
        // useHTML: true
    // },
    // plotOptions: {
        // column: {
            // pointPadding: 0.2,
            // borderWidth: 0,
			 // dataLabels: {
                // enabled: true,
                // format: '{point.y} US$'
            // }
        // }
    // },
    // series: [
	// <?php 
	// $dts1=$oEmpresa->mostrarTodos();
	// while($dt1 = mysqli_fetch_array($dts1))
	// {
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'01','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_ene=$dt['canttot'];
	// mysqli_free_result($dts);
	
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'02','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_feb=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'03','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_mar=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'04','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_abr=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'05','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_may=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'06','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_jun=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'07','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_jul=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'08','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_ago=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'09','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_sep=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'10','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_oct=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'11','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_nov=$dt['canttot'];
	// mysqli_free_result($dts);
	
	// $dts=$oVenta->mostrarcantXMes($dt1["tb_empresa_id"],'12','2');
	// $dt = mysqli_fetch_array($dts);
	// $cant_mes_dic=$dt['canttot'];
	// mysqli_free_result($dts);
	
		
	// ?>
	
	
	// {
        // name: '<?php echo $dt1['tb_empresa_razsoc']; ?>',
        // data: [<?php echo $cant_mes_ene ?>,<?php echo $cant_mes_feb ?>,<?php echo $cant_mes_mar ?>,<?php echo $cant_mes_abr ?>,
		// <?php echo $cant_mes_may ?>,<?php echo $cant_mes_jun ?>,<?php echo $cant_mes_jul ?>,<?php echo $cant_mes_ago ?>,
		// <?php echo $cant_mes_sep ?>,<?php echo $cant_mes_oct ?>,<?php echo $cant_mes_nov ?>,<?php echo $cant_mes_dic ?>]
    // }, 
	// <?php 
	// } 
	// ?>
	
	// ]
// });
 
 
 
 Highcharts.theme = {
    colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572',
             '#FF9655', '#FFF263', '#6AF9C4'],
    chart: {
        backgroundColor: {
            linearGradient: [0, 0, 500, 500],
            stops: [
			[0, '#343a40'],
			[1, '#343a40']
				]
        },
    },
    title: {
        style: {
            color: '#EEEEEE',
            font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
        }
    },
    subtitle: {
        style: {
            color: '#E0E0E0',
            font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
        }
    },
    legend: {
        itemStyle: {
            font: '9pt Trebuchet MS, Verdana, sans-serif',
            color: 'black'
        },
        itemHoverStyle:{
            color: 'danger'
        }
    }
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
 
 
 
	  $("#container_reporte_soles").highcharts({
		  
    chart: {
        type: 'area'
    },
    title: {
        text: 'Ventas/Compras'
    },
    subtitle: {
        text: '* Jane\'s banana consumption is unknown',
        align: 'right',
        verticalAlign: 'bottom'
    },
    legend: {
        layout: 'vertical',
        align: 'left',
        verticalAlign: 'top',
        x: 100,
        y: 70,
        floating: true,
        borderWidth: 1,
        backgroundColor: '#FFFFFF'
    },
    xAxis: {
        categories: 
		[		
			'Ene.',
            'Febr.',
            'Mar.',
            'Abr.',
            'May.',
            'Jun.',
            'Jul.',
            'Agos.',
            'Sept.',
            'Oct.',
            'Nov.',
            'Dic.'		
		]
    },
    yAxis: {
        title: {
            text: 'Compras-Ventas S/'
        }
    },
    plotOptions: {
        area: {
            fillOpacity: 0.5		
        }
    },
    credits: {
        enabled: false
    },
    series: [{
        name: 'Ventas',
        data: [
		<?php echo moneda_mysql(formato_money($cant_mes_ene)); ?>, 
		<?php echo moneda_mysql(formato_money($cant_mes_feb)); ?>, 
		<?php echo moneda_mysql(formato_money($cant_mes_mar)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_abr)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_may)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_jun)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_jul)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_ago)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_sep)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_oct)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_nov)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_dic)); ?>
		]
    }, {
        name: 'Compras',
        data: [
		<?php echo moneda_mysql(formato_money($cant_mes_ene_com)); ?>, 
		<?php echo moneda_mysql(formato_money($cant_mes_feb_com)); ?>, 
		<?php echo moneda_mysql(formato_money($cant_mes_mar_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_abr_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_may_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_jun_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_jul_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_ago_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_sep_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_oct_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_nov_com)); ?>,
		<?php echo moneda_mysql(formato_money($cant_mes_dic_com)); ?>
		]
    }]
});
  
  
  
  
	
	function venta_form_directa(act,idf){
		$('#div_venta_form_dialog').modal();
		$('body').css('overflow-y','hidden');
		$.ajax({
			type: "POST",
			url: "../venta/venta_form.php",
			async:true,
			dataType: "html",   
			position:'top',                   
			data: ({
				action: act,
				ven_id:	idf
			}),
			beforeSend: function() {
				var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					
				$('.div_venta_form').html(div);
			},
			success: function(html){
				$('.div_venta_form').html(html);				
			},
			complete: function(){
			}
		});
	}
	
	function traertipocambio(){
		$.ajax({
			type: "POST",
			url: "../tipocambio/tipocambio_sunat.php",
			async:true,
			dataType: "html",                      
			data: ({
			}),
			beforeSend: function() {
				
			},
			success: function(html){				
			
			tipcam = html.trim();
			if(tipcam==""){
				
			}
			else{
				$(".div_tipcam").hide();
				registrartipocambio(tipcam)
			}
			
			},
			complete: function(){
				
			}
		});	 
  }
  
  cmb_fil_puntoventa_id(<?php echo $punven_id; ?>);
function cmb_fil_puntoventa_id(punven){
		$.ajax({
 					type: "POST",
 					url: "../puntoventa/cmb_punven_id.php",
 					async:true,
 					dataType: "html",                      
 					data: ({						
 						emp_id:'',
						punven_id :punven,
 						vista:	''
 					}),
 					beforeSend: function() {
 						$('#cmb_fil_puntoventa_id').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_fil_puntoventa_id').html(html);
 					},
 					complete: function(){
 						$('#txt_punven_id').val($('#cmb_fil_puntoventa_id').val());
 						verinforapida($('#cmb_fil_puntoventa_id').val());
						}
 					});
}
   
   function verinforapida(punven_id){
		$.ajax({
			type: "POST",
			url: "../base/info_rapida.php",
			async:true,
			dataType: "html",                      
			data: ({
				punven_id : punven_id
			}),
			beforeSend: function() {
				var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
				$('#div_inforapida').html(div);
			},
			success: function(html){				
				$("#div_inforapida").html(html);
			},
			complete: function(){
				
			}
		});	 
  }
   
  function registrartipocambio(tipcam){
		$.ajax({
			type: "POST",
			url: "../tipocambio/tipocambio_reg.php",
			async:true,
			dataType: "json",                      
			data: ({
				vista:'panel',
				action_tipocambio : 'insertar',
				txt_tipcam_val : tipcam
			}),
			beforeSend: function() {
				
			},
			success: function(data){				
					$("#msj_escritorio").html(data.tipcam_msj);	
					$("#msj_escritorio").show();	
			},
			complete: function(){
				 setTimeout(function(){ 
						 $('#msj_escritorio').hide(100);
					 }, 8000);
           setTimeout(function(){ 
            location.reload();
           }, 4000);
			}
		});	 
  }
  	
 /* 
  function cuentacobrar(){
	$.ajax({
		type: "POST",
		url: "../cuentacobrar/cuentacobrar_inicio.php",
		async:true,
		dataType: "html",                      
		data: ({
			
			//action: act,
			//mar_id:	idf
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
					$('#div_cuentacobrar_inicio').html(div);
        },
		success: function(html){
			$('#div_cuentacobrar_inicio').html(html);				
		}
	});
} */



function cuentapagar(){
	$.ajax({
		type: "POST",
		url: "../cuentapagar/cuentapagar_inicio.php",
		async:true,
		dataType: "html",                      
		data: ({
			vista:'base'
			//action: act,
			//mar_id:	idf
		}),
		beforeSend: function() {
			var div = "<center> <br> <span class='spinner-border spinner-border-lg mr-2'></span> <span style='font-size:1.5rem;'>PROCESANDO PETICIÓN</span></center>";	
			$('#div_cuentapagar_inicio').html(div);
        },
		success: function(html){
			$('#div_cuentapagar_inicio').html(html);				
		}
	});
}
	
	
	
	
	$(".btn_color_user").click(function(){
		
		var namheader = $(this).attr('data-name');
		var namslider = $(this).attr('data-name2');
		
		$.ajax({
		type: "POST",
		url: "../usuario/usuario_reg.php",
		async:true,
		dataType: "html",                      
		data: ({
			namheader : namheader,
			namslider : namslider
		}),
		beforeSend: function() {
			
        },
		success: function(html){
					
		}
	});
	});	
	
	
	
	$("#cmb_fil_puntoventa_id").change(function(){
		verinforapida($('#cmb_fil_puntoventa_id').val());
	});
		
		
		
	$("#div_efectuar_pedidos").on('hidden.bs.modal', function () {
		$("#content").load("../base/base_vista.php");	
		$('body').css('overflow-y','scroll');
    });
	
	$("#div_comprapagoarchivos_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
    });
	
	$("#div_pago_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
    });
	
	$("#div_ingreso_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','hidden');
    });
	$("#div_cuentacobrar_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
    });
	$("#div_egreso_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','hidden');
    });
	$("#div_cuentapagar_form_dialog").on('hidden.bs.modal', function () {
		   	$('body').css('overflow-y','scroll');
    });
  
  </script>
  
     