<?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 ("../../config/Datos.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();
require_once ("../usuario/cUsuarioprograma.php");
$oUsuarioprograma = new cUsuarioprograma();

$y=date('Y');
$m=date('m');
$d=date('d');


////MODULO VENTAS POS ///
$dts=$oUsuarioprograma->mostrar_uno($_SESSION['usuario_id'],'61');
$numrows = mysqli_num_rows($dts);
if($numrows>0){
	$banventa = true;
}else{
	$banventa = false;
}






	$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;


// echo '-----------------------------------------'.$app_igv_val;




$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);
?>


<style type="text/css">

.carda{
   
   margin: 40px auto;
   display: flex;
   flex-direction: column;
   } 
.globo{
   border-radius: 25px;
      padding: 12px;
      background: #3B71CA;
      color: white;
   padding: 10px;
   position: relative;
   width: 400px;
   margin: 0 auto;
   font-family: Courierf;
   z-index: 1;
   }
   
.globo::after {
   content: '';
   position: absolute;
   bottom: 0; 
   left: 10px;
   background: transparent;
   width: 0px; height: 0px;
   border-bottom: 20px solid #3B71CA;
   border-right: 20px solid transparent;
   border-left: 20px solid transparent;
   transform: rotate(90deg);
   z-index: -1;
   }
.imagen {
   left:100px;
   width: 100px;
} 

</style>

<?php if($banventa==true){ ?>

<a id="" href="#" class=" back-to-top" style="z-index:9999;" role="button" aria-label="Scroll to top">
			<input id="chkposgra" type="checkbox" checked data-toggle="toggle" style=""
			data-on="<i class='fa fa-align-left'></i> POS" 
			data-off="GRAFICAS" data-onstyle="success" data-offstyle="danger" data-size="normal" >
</a>
		
<div class="container-fluid">
	<div class="row">
	
		<div class="col-lg-12 col-sm-12 col-xs-12" id="contenedor_base_venta" ></div>
		<div class="col-lg-10 col-sm-12 col-xs-12" id="contenedor_base_venta1" >
		    
		    
			<div class="row" >
										
										<?php 
										require_once ("../comunicado/cComunicado.php");
										$oComunicado = new cComunicado();
										
										$fec = date('d-m-Y');
										$fecactual = strtotime($fec);
										$dts1=$oComunicado->mostrar_comunicado($fecactual);	
										$num_rows= mysqli_num_rows($dts1);
										
										while($dt1 = mysqli_fetch_array($dts1)){
											  $com_tip =$dt1['tb_comunicado_tip'];
											  if($com_tip == 1){
												  $tip = "NORMAL";
											  }else{
												  $tip = "CHANCHITO";
												}
										?>
										<div class="col-lg-6 col-md-6 col-12" >
										
										
										<?php if($com_tip == 2){
										?>
										
										
										<div class="carda" style="padding:5px;">
										
										<div class="globo" >
											<span style="" > <?php echo nl2br($dt1['tb_comunicado_nom']); ?></span>
										</div>
										<div>
											<img class="imagen" width="60" src ="../../images/chanchito.png" />
										</div>
										
										</div>
									
										<?php 
										}?>
										
										<?php if($com_tip == 1){
										?>
										
										<div class="carda" style="padding:5px;" >
										
										<div class="globo" >
											<span style="" > <?php echo nl2br($dt1['tb_comunicado_nom']); ?></span>
										</div>
										<div >
											<img class="imagen" width="45" src ="../../images/anuncio.png" />
										</div>
										
										</div>
										
										<?php 
										}?>
											
										
										</div>
										<?php
										}

										?>		
				</div>
	
		
		</div>
		<div class="col-lg-12 col-sm-12 col-xs-12" id="contenedor_base_grafica" ></div>
		
	</div>
	</div>
	
	
<?php } ?>
  
   <?php if($banventa==false){ ?>
  <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: 2px;"></div>
<div class="row">
<?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 }?>
 
 </div>
 

<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=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=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-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-white" >
	
	<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>

<?php } ?>
			<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 registro -->
			<div class="modal fade" id="div_productomarca_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:98%"    role="document" >

			<div class="modal-content">

			<div class="modal-body div_productomarca_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"  data-keyboard="false" data-backdrop="static" 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 class="modal fade" id="div_inventarioveralmacenes_form_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">
			<div class="modal-body div_inventarioveralmacenes_form" style="padding:0px;" >
			</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;
      }
    });
	
	

	
	$('#chkposgra').bootstrapToggle();
	
	
	 $('#chkposgra').change(function() {
      if($(this).prop('checked')==true){
		  
		   $('#contenedor_base_venta').show('fade');
		   $('#contenedor_base_grafica').hide('fade');
		   
		
		  
		  
	  }else if($(this).prop('checked')==false){
		  
		   $('#contenedor_base_venta').hide('fade');
		   $('#contenedor_base_grafica').show('fade');
		   cargar_basegrafica();
		  
	  }
    });
		
	function cargar_basegrafica(){
		
			/* $('#div_mensaje_dialog').modal('show');
			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_mensaje').html(div); */
				
			$.ajax({
				type: "POST",
				url: "../grafica/grafica_inicio.php",
				async:true,
				dataType: "html",                      
				data: ({
					action : "insertar"
				}),
				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>";	
					//$('#contenedor_base_venta').html(div);
				},
				success: function(html){
					$('#contenedor_base_grafica').html(html);				
				}
			});
		}
	

	
	 <?php if($banventa==true){ ?>
	
	$("body").addClass('sidebar-collapse');
	
	 <?php } ?>
	 
	venta_form();
	
	
	
	
		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 venta_form(){
		
			/* $('#div_mensaje_dialog').modal('show');
			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_mensaje').html(div); */
				
			$.ajax({
				type: "POST",
				url: "../venta/venta_form_inicio.php",
				async:true,
				dataType: "html",                      
				data: ({
					action : "insertar"
				}),
				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>";	
					//$('#contenedor_base_venta').html(div);
				},
				success: function(html){
					$('#contenedor_base_venta').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();
		}
	});
}
	
 
 Highcharts.theme = {
    colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572',
             '#FF9655', '#FFF263', '#6AF9C4'],
    chart: {
        backgroundColor: {
            linearGradient: [0, 0, 500, 500],
            stops: [
			[0, '#f4f6f9'],
			[1, '#f4f6f9']
				]
        },
    },
    title: {
        style: {
            color: '#000000',
            font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
        }
    },
    subtitle: {
        style: {
            color: '#000000',
            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);				
		}
	});
}



	///  FACTURACION
	
	
	
	

 function venta_ticket_datos(id_ven,imprimir){	
		
		/* alert(id_ven); */
		
		$.ajax({
			type: "POST",
			url: "../venta/venta_ticket_datos.php",
			async:true,
			dataType: "json",                      
			data: ({ 
			venid: id_ven
			}),
			beforeSend: function() {
				
			},
			success: function(data){
				 //console.log(data); 
				
				if(data!=""){					
					if(data.ven_docabr=="F" /* && data.cli_nom !='CLIENTE' */ ){
					generarFactura_xml(data,data.url_genfac,data.emp_ruc,data.ven_numdoc,id_ven,data.cli_id,imprimir);
					}else if(data.ven_docabr=="B" /* && data.cli_nom !='CLIENTE' */ ){
					generarBoleta_xml(data,data.url_genbol,data.emp_ruc,data.ven_numdoc,id_ven,data.cli_id,imprimir);
					}else if(data.ven_docabr=="T"){
						
						if(imprimir=="1"){
							venta_ticket_impresion(data,data.imp_doc);
						}
					}		
				}else{
					
				}
			}
		});
	
}


 function venta_ticket_datos_tabla(id_ven){	
		
		/* alert(id_ven); */
		
		$.ajax({
			type: "POST",
			url: "../venta/venta_ticket_datos.php",
			async:true,
			dataType: "json",                      
			data: ({ 
			venid: id_ven
			}),
			beforeSend: function() {
				
			},
			success: function(data){
				// console.log(data); 
				
				if(data!=""){					
					if(data.ven_docabr=="T"){
					venta_ticket_impresion(data,data.imp_doc);
					}		
				}else{
					
				}
			}
		});
	
}



function venta_ticket_impresion(data,url){	

	$.ajax({
		type: "POST",
		url: url,
		async:true,
		dataType: "html",                      
		data: data,
		beforeSend: function()
		{
			//console.log(data);	
		},
		success: function(html){
				
			
		}
	});
}

function generarFactura_xml(data,url,emp_ruc,ven_numdoc,id_ven,id_cli,imprimir){
		/* alert(url); */
		$.ajax({
		type: "POST",
		url: url,
		async:true,
		dataType: "json",                      
		data: data,
		beforeSend: function()
		{
			
		},
		success: function(data){
				/* alert(html); */
				//tip_com = '01';
		/* crear_xml(html,emp_ruc,ven_numdoc,tip_com,id_ven,id_cli); */
		firmar(data.url,data.arc,emp_ruc,ven_numdoc,data.tipcom,id_ven,id_cli,imprimir);
		}
	});

}

function generarBoleta_xml(data,url,emp_ruc,ven_numdoc,id_ven,id_cli,imprimir){
		/* alert(url); */
		$.ajax({
		type: "POST",
		url: url,
		async:true,
		dataType: "json",                      
		data: data,
		beforeSend: function()
		{
			
		},
		success: function(data){
			
 firmar(data.url,data.arc,emp_ruc,ven_numdoc,data.tipcom,id_ven,id_cli,imprimir);			
			/* alert(html); */
		//tip_com = '03';
		//crear_xml(html,emp_ruc,ven_numdoc,tip_com,id_ven,id_cli);
		}
	});

}

// function crear_xml(xml,emp_ruc,ven_numdoc,tip_com,id_ven,id_cli){
		// /* alert(url); */
		// $.ajax({
		// type: "POST",
		// url: '../../docgeneracion/crearxml.php',
		// async:true,
		// dataType: "json",                      
		// data: ({
			// xml : xml,
			// emp_ruc : emp_ruc,
			// ven_numdoc : ven_numdoc,
			// tip_com : tip_com,
		// }),
		// beforeSend: function()
		// {
			
		// },
		// success: function(data){
		
			// firmar(data.url,data.arc,emp_ruc,ven_numdoc,data.tipcom,id_ven,id_cli);
				
		// }
	// });

// }

function firmar(url,arc,emp_ruc,ven_numdoc,tipcom,id_ven,id_cli,imprimir){
		/* alert(url); */
		$.ajax({
		type: "POST",
		url: url,
		async:true,
		dataType: "json",                      
		data: ({
			arc : arc,
			emp_ruc : emp_ruc,
			ven_numdoc:ven_numdoc,
			tipcom:tipcom,
			venid:id_ven
		}),
		beforeSend: function()
		{
			
		},
		success: function(data){			
			//generar_pdf(id_ven);
			//generarPDF417(data);
			traer_datos_doc(id_ven,data.fil_name_xml,imprimir);
			enviarSunat(data.xml_nom,data.fil_name_zip,data.fil_name_xml,data.filenom,id_ven,id_cli,tipcom,emp_ruc);
			
				
			
		}
	});

}


function enviarSunat(nomxml,fil_name_zip,fil_name_xml,filenom,id_ven,id_cli,tipcom,emp_ruc){
		$.ajax({
		type: "POST",
		url: '../../docgeneracion/enviosunat.php',
		async:true,
		dataType: "json",                      
		data: ({
			nomxml:nomxml,
			name_zip:fil_name_zip,
			nomfile:filenom,
			id_ven:id_ven,
			xmlarchivo:fil_name_xml,
			tipcom:tipcom,
			emp_ruc:emp_ruc
		}),
		beforeSend: function()
		{
			toastr["error"]('Esperando respuesta de sunat');
		},
		success: function(data){
			
			toastr["success"](data.msj);
			
			if(data.est==1){
				//enviarCorreo(id_ven,id_cli);
				
				//abrirEnPestana('="../../../../files/venta/venta_impcpe_doc.php?venid='+id_ven);
				venta_tabla();
			}else{
				toastr["info"]('El documento no se ha emitido.');
			}
			
		}
	});

}


 function generar_pdf(id_ven){	
		
//alert(id_ven); 
		
		$.ajax({
			type: "GET",
			url: "../venta/venta_generar_doc.php",
			async:true,
			dataType: "json",                      
			data: ({ 
			venid: id_ven
			}),
			beforeSend: function() {
				
			},
			success: function(data){
				toastr["info"]('Pdf generado');
				}
		});
	
}

function enviarCorreo(venid,cliid){
	
	$('#div_venta_correo_form').modal();
	//$('body').css('overflow-y','hidden');
				
	$.ajax({
			type: "POST",
			url: "../venta/venta_correo_form.php",
			async:true,
			dataType: "html",
			data: ({
				venta_id:venid,
				cli_id:cliid	
			}),
			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_correo_conten').html(div);
	       


		   },
			success: function(html){
				$('.div_venta_correo_conten').html(html);				
			}
		});
	
}

function traer_datos_doc(venid,urlxml,imprimir){
	
	
	
	$.ajax({
			type: "POST",
			url: "../venta/venta_doc_datos.php",
			async:true,
			dataType: "json",                      
			data:({ 
			venid: venid,
			urlxml :urlxml
			}),
			beforeSend: function() {
				
			},
			success: function(data){
				/* console.log(data); */
			
			//generarPDF417(data);
			
			if(imprimir=="1"){
				venta_doc_impresion(data,data.imp_doc);
			}
			/* if(data.cli_ema==""){
				
			}else{
				act ="enviar";
				enviarCorreo(data);
			}	 */	
			
			}
		});
	
}

function generarPDF417(data){
	
	console.log(data);
	
	$.ajax({
			type: "POST",
			url: "../venta/generarPdf417.php",
			async:true,
			dataType: "json",                      
			data:data,
			beforeSend: function() {
				
			},
			success: function(data){			

			}
		});	 
		
}

function venta_doc_impresion(data,url){
	$.ajax({
			type: "POST",
			url: url,
			async:true,
			dataType: "json",                      
			data: data ,
			beforeSend: function() {
				//console.log(data);
			},
			success: function(data){
				
				
			}
		});
}






////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	$(".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>
  
     