<?php

date_default_timezone_set('America/Lima');
session_start();
if($_SESSION["sistema"]!= "1"){ header("location: ../login/index.php"); exit();}

require_once ("../../config/Cado.php");
require_once ("../canchapos/cCanchapos.php");
$oCanchapos = new cCanchapos();
require_once("../formatos/formato.php");
	$dts=$oCanchapos->mostrarUno($_POST['sepcan_id']);
	$dt = mysqli_fetch_array($dts);
			$fec = $dt['tb_separacioncancha_fecforini'];
			$hini = $dt['tb_separacioncancha_horforini'];
			$cli_tel = $dt['tb_cliente_tel'];
			$cli_nom = $dt['tb_cliente_nom'];
			$est = $dt['tb_separacioncancha_est'];
			$det = $dt['tb_separacioncancha_des'];
			$tiemin = $dt['tb_separacioncancha_tiemin'];
			$horainitime = $dt['tb_separacioncancha_horainitime'];
			$horafintime = $dt['tb_separacioncancha_horafintime'];
			$ade = $dt['tb_separacioncancha_ade'];
			$can_nom = $dt['tb_cancha_nom'];
	mysqli_free_result($dts);
	$mone_id = 1;
	
	$can = strlen($cli_doc);
	$forpag_id = '1';
	$cli_id = '1';
	$fecd = date('d-m-Y');
	$pro_nom = 'ALQUILER DE CAMPO '.$can_nom.' : '.$tiemin.' minutos';
?>



 <style type="text/css">
.ui-autocomplete
{
    z-index: 99999; 
}

input[type=checkbox] {
 cursor:pointer;
}

#chk_imprimir{
  visibility: hidden;
}

.div_checkbox {
    width: 60px;
    height: 20px;
    background: #00ACC1;
    margin: 0 40px;
    border-radius: 6px;
	padding:12px;
    position: relative;
  font-family: 'Aldrich', sans-serif; 
}
.div_checkbox:before {
    content: 'Sí';
    position: absolute;
    top: 5px;
    left: 12px;
    color: #fff;
    font-size: 13px;
  line-height: 15px;
  text-shadow: 0 0 2px #fff;
}

.div_checkbox:after {
    content: 'No';
	color: #FF1744;
    position: absolute;
    top: 5px;
	right: 5px;
	font-size: 13px;
	line-height: 15px;
  text-shadow: 0 0 1px #FF1744;
}

.div_checkbox label { 
    background: #FF1744;
    display: block;
	width: 25px;
	height: 15px;
	padding:10px;
	border-radius: 4px;
    transition: all .7s ease;
    cursor: pointer;
    position: absolute;
    top: 2px;
    z-index: 1;
    left: 5px;
}
.div_checkbox input[type=checkbox]:checked + label {
    left: 30px;
    background: #fff;
}



</style>
 		

<script type="text/javascript">











/* 
function ver_fecven(){	
	$.ajax({
		type: "POST",
		url: "../venta/ver_fecven.php",
		async:false,
		dataType: "json",                      
		data: ({
			ven_fec: 		'<?php echo $fecd; ?>',
			venpag_numdia: 	$('#txt_venpag_numdia').val()
		}),
		beforeSend: function() {
					
		},
		success: function(data){
			$('#txt_venpag_fecven').val(data.fecha);
		}
	});
}
 */


function pago_venta_agregar(act,idf,tabla='1')
{
	$.ajax({
		type: "POST",
		url: "../venta/pago_venta_agregar.php",
		async:false,
		dataType: "json",                      
		data: ({
			action:	 act,
			item_id:	idf,
			venpag_mon: $('#txt_venpag_mon').val(),
			venpag_for: $('#cmb_forpag_id').val(),
			venpag_mod: $('#cmb_modpag_id').val(),
			venpag_numope: $('#txt_venpag_numope').val(),
			venpag_numdia: $('#txt_venpag_numdia').val(),
			venpag_fecven: $('#txt_venpag_fecven').val(),
			venpag_cajid: $('#cmb_caj_id').val(),
			ven_tot: $('#txt_ven_tot').val(),
			venpag_tot: $('#hdd_venpag_tot').val()						
		}),
		beforeSend: function() {
			
		},
		success: function(data){
			if(data.est==false)
			{

				toastr["success"](data.msj);	

				if(data.dat.tipo=="venpag_mon")
				{
					$('#txt_venpag_mon').val(data.dat.mon);
					$('#txt_venpag_mon').focus();
				}
				if(data.dat.tipo=="venpag_mod")
				{
					$('#cmb_modpag_id').focus();
				}
				if(data.dat.tipo=="venpag_numope")
				{
					$('#txt_venpag_numope').focus();
				}
				if(data.dat.tipo=="venpag_numdia")
				{
					$('#txt_venpag_numdia').focus();
				}
			}
			if(data.est==true)
			{
				if(data.dat.tipo=="agregado")
				{
					$('#txt_venpag_mon').focus();
				}
			}
		},
		complete: function(){			
			pago_venta_tabla();
		}
	});

}

function pago_venta_tabla(act)
{
	$.ajax({
		type: "POST",
		url: "../venta/pago_venta_tabla.php",
		async:false,
		dataType: "html",                      
		data: ({
			action:	 act,
			ven_tot: $('#txt_ven_tot').val()					
		}),
		beforeSend: function() {
			$('#div_venta_pago_car_tabla').addClass("ui-state-disabled");
		},
		success: function(html){
			$('#div_venta_pago_car_tabla').html(html);
		},
		complete: function(){			
			$('#div_venta_pago_car_tabla').removeClass("ui-state-disabled");

			monto_venpag();
		}
	});

}

function monto_venpag()
{
	var total= $('#txt_ven_tot').val();
	$('#txt_venpag_mon').val(total);

	//alert(total);

	if($('#chk_venpag_aut').is(':checked'))
	{		
		var dif = $('#hdd_venpag_dif').val();
		$('#txt_venpag_mon').val(dif);
	}
	
}


function venpag_aut()
{
	if($('#chk_venpag_aut').is(':checked'))
	{  
		$("#div_pago_agregar").show(100);
		pago_venta_tabla('actualizar');

		$("#hdd_ven_pag_numite").attr('disabled', false);
		$("#hdd_venpag_tot").attr('disabled', false);
		$("#hdd_venpag_val").val('1');
		$("#txt_venpag_mon").attr('readonly',false);
		
		$("#cmb_forpag_id").val('2');
		
		//$("#cmb_forpag_id").attr('disabled', true);
		forpag_id();
	}
	else 
	{
		$("#div_pago_agregar").hide(100);

		pago_venta_agregar('restablecer');
		$('#div_venta_pago_car_tabla').html('');

		$("#hdd_ven_pag_numite").attr('disabled', 'disabled');
		$("#hdd_venpag_tot").attr('disabled', 'disabled');
		$("#hdd_venpag_val").val('');
		$("#txt_venpag_mon").attr('readonly',true);
		
		$("#cmb_forpag_id").val('1');
		$("#cmb_forpag_id").attr('disabled', false);
		forpag_id();
		
	}
	/* $("#txt_venpag_mon").focus(); */
}

function forpag_id()
{
	var tipo = $("#cmb_forpag_id").val();

	$('#txt_venpag_numope').val('');
	$('#txt_venpag_numdia').val('');
	$('#txt_venpag_fecven').val('');

	$("#div_modo").hide(100);
	$("#div_tarjeta").hide(100);
	$("#div_cuentadeposito").hide(100);			
	$("#div_operacion").hide(100);
	$("#div_dia").hide(100);
	$("#div_fecven").hide(100);
	
	//contado
	if(tipo == 1)
	{		
		$("#div_modo").show(100);
		$("#div_caj").show(100);
	}
	//credito
	if(tipo == 2){			
		$("#div_dia").show(100);
		$("#div_fecven").show(100);	
		$("#div_operacion").hide(100);
		$("#div_caj").hide(100);
	}	

}

	
function validar_campos(modid){
	
	
	var mon_id = $("#txt_mone_id").val();
	var punven_id = $("#txt_punven_id").val();
	

	if(modid==""){

		
		$("#div_operacion").hide(100);
	
	}else if(modid==1){
	

		$(".lbl_venpag_numope").text('Nº Operacion:');
		$("#div_operacion").hide(100);
		cmb_caja_id('1',punven_id,mon_id);
		
	}else if(modid==2){
		
		$(".lbl_venpag_numope").text('Nº Operacion:');
		$("#div_operacion").show(100);
		cmb_caja_id2(1,mon_id,'2');
		
	}else if(modid==3){
		
		$(".lbl_venpag_numope").text('Nº Operacion:');
			$("#div_operacion").show(100);

	}else if(modid==4){
		
		$(".lbl_venpag_numope").text('Nº Operacion:');
			$("#div_operacion").show(100);
			cmb_caja_id2(1,mon_id,'2');

	}else if(modid==5){
		
		$(".lbl_venpag_numope").text('Nº Cheque:');
			$("#div_operacion").show(100);
			cmb_caja_id('',punven_id,mon_id);

	}
	else if(modid==6){
		$(".lbl_venpag_numope").text('Nº Operacion:');
			$("#div_operacion").show(100);
			cmb_caja_id2(1,mon_id,'2');
	}else if(modid==7){
		$(".lbl_venpag_numope").text('Nº Operacion:');
			$("#div_operacion").show(100);
			cmb_caja_id3(punven_id,mon_id,'3','YAPE');
	}
	else if(modid==8){
		$(".lbl_venpag_numope").text('Nº Operacion:');
			$("#div_operacion").show(100);
			cmb_caja_id3(punven_id,mon_id,'3','PLIN');
	}
}


function cmb_caja_id3(punven_id,moneid,tip,ban_nom)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_cajaxpuntoventa_id3.php",
			async:true,
			dataType: "html",                      
			data: ({
				punven_id: punven_id,
				mon_id: moneid,
				tip: tip,
				bannom : ban_nom,
				vista : 'venta'
			}),
			beforeSend: function(){
				$('#cmb_caj_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_caj_id').html(html);
			}
		});
	}

function cmb_caja_id(tip,punven_id,moneid)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_cajaxpuntoventa_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				tip : tip,
				punven_id: punven_id,
				mon_id: moneid
			}),
			beforeSend: function(){
				$('#cmb_caj_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_caj_id').html(html);
			}
		});
	}
	
function cmb_caja_id2(punven_id,moneid,tip)
	{	
		$.ajax({
			type: "POST",
			url: "../caja/cmb_cajaxpuntoventa_id2.php",
			async:true,
			dataType: "html",                      
			data: ({
				punven_id: punven_id,
				mon_id: moneid,
				tip: tip // 1 : bancos // 2 : detracciones
			}),
			beforeSend: function(){
				$('#cmb_caj_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_caj_id').html(html);
			}
		});
	}



	cmb_docgen_id();
	//cmb_cue_id_canpos();
	//cmb_subcue_id_canpos('4');

	$('#cmb_cue_id_canpos').change(function(){
		cmb_subcue_id_canpos($('#cmb_cue_id_canpos').val());
	});
	

 function ver_fecven(){	
	$.ajax({
		type: "POST",
		url: "../cotizacion/ver_fecven.php",
		async:false,
		dataType: "json",                      
		data: ({
			ven_fec: 		'<?php echo $fecd; ?>',
			venpag_numdia: 	$('#txt_venpag_numdia').val()
		}),
		beforeSend: function() {
					
		},
		success: function(data){
			$('#txt_venpag_fecven').val(data.fecha);
		}
	});
}

function cmb_docgen_id(docid,can)
{	
		$.ajax({
			type: "POST",
			url: "../documento/cmb_doc_id.php",
			async:true,
			dataType: "html",                      
			data: ({
				mod_id: 3,
				doc_id: docid,
				doc: $('#txt_ven_cli_docv').val(),
				doccan : can ,<?php //echo $can?>
				vista:'ven',
				tot : $('#txt_ven_tot').val(),
				def:1
				
			}),
			beforeSend: function() {
				$('#cmb_doc_canpos_id').html('<option value="">Cargando...</option>');
			},
			success: function(html){			
				$('#cmb_doc_canpos_id').html(html);
			},
			complete: function(){
					numdoc_id();
		}
	});
	}
	
function numdoc_id()
{
	var tipo = $("#cmb_doc_canpos_id").val();
	
	if(tipo == 33 || tipo == 34 )
	{		
		$("#div_numdoc").show(100);
		
	}else{
		$("#div_numdoc").hide(100);
	}
	
} 



function cliente_cargar_datos_canpos(idf){	
	$.ajax({
		type: "POST",
		url: "../cliente/cliente_reg.php",
		async:true,
		dataType: "json",                      
		data: ({
			action: "obtener_datos",
			cli_id:	idf
		}),
		beforeSend: function() {
		
		},
		success: function(data){
			$('#hdd_ven_cli_idv').val(idf);	
			$('#txt_ven_cli_nomv').val(data.nombre);	
			$('#txt_ven_cli_docv').val(data.documento);						
			$('#txt_ven_cli_dir').val(data.direccion);
			$("#hdd_ven_cli_tip").val(data.tipo);
			cargar_direcciones(idf);
			
		can = 	$('#txt_ven_cli_docv').val().length;
		
		if(can == '8'){
				cmb_docgen_id('4',can);
		}else{
				cmb_docgen_id('5',can);
		}		
			//cargar_vehiculos(idf);
			
		}
	});		
}
	
	
function cliente_form(act,idf){
	$('#div_cliente_form_dialog').modal();
	$.ajax({
		type: "POST",
		url: "../cliente/cliente_form.php",
		async:true,
		dataType: "html",                      
		data: ({
			action: act,
			cli_id:	idf,
			vista:	'venta'
		}),
		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_cliente_form').html(div); 
		},
		success: function(html){ 	
			$('.div_cliente_form').html(html); 				
		},
		complete: function(){
				
				
		}
	});
}

function cargar_direcciones(idcli){
	
			$.ajax({
 					type: "POST",
 					url: "../cliente/cmb_clidir_id.php",
 					async:true,
 					dataType: "html",                      
 					data: ({						
 						cli_id: idcli,
 						vista:	''
 					}),
 					beforeSend: function() {
 						$('#cmb_ven_cli_dirv').html('<option value="">Cargando...</option>');
 					},
 					success: function(html){			
 						$('#cmb_ven_cli_dirv').html(html);
 					},
 					complete: function(){
 						
 						}
 					});
}


$(function() {

	

$('#hdd_imp_val').val('0');
$('#chk_imprimir').change(function()
{
	if($('#chk_imprimir').is(':checked'))
	{		
		$('#hdd_imp_val').val('1');
	}else{
		$('#hdd_imp_val').val('0');
	}
});


pago_venta_agregar('restablecer');
cliente_cargar_datos_canpos(<?php echo $cli_id?>);
validar_campos($("#cmb_modpag_id").val());

$( "#txt_ven_cli_docv" ).autocomplete({
		minLength: 1,
		source: "../cliente/cliente_complete_doc.php",
		select: function(event, ui){			
			$("#hdd_ven_cli_idv").val(ui.item.id);
			$("#txt_ven_cli_nomv").val(ui.item.nombre);
			$("#txt_ven_cli_dir").val(ui.item.direccion);
			$("#hdd_ven_cli_tip").val(ui.item.tipo);
				$("#txt_bus_pro_codbar").focus();
				cargar_direcciones(ui.item.id);
				
		can = $('#txt_ven_cli_docv').val().length;
		
		if(can == '8'){
				cmb_docgen_id('4',can);
		}else{
				cmb_docgen_id('5',can);
		}	
				
			}
		});

$( "#txt_ven_cli_nomv" ).autocomplete({
		minLength: 1,
		source: "../cliente/cliente_complete_nom.php",
		select: function(event, ui){			
			$("#hdd_ven_cli_idv").val(ui.item.id);							
			$("#txt_ven_cli_docv").val(ui.item.documento);
			$("#txt_ven_cli_dir").val(ui.item.direccion);
			$("#hdd_ven_cli_tip").val(ui.item.tipo);
				$("#txt_bus_pro_codbar").focus();
				cargar_direcciones(ui.item.id);
				
		can = $('#txt_ven_cli_docv').val().length;
		
		if(can == '8'){
				cmb_docgen_id('4',can);
		}else{
				cmb_docgen_id('5',can);
		}	
		
			}
		});
	
$("#txt_venpag_mon").attr('readonly',true);
	 
		 
$("#chk_venpag_aut").change(function(){
			venpag_aut();
}); 
		
		
$("#cmb_forpag_id").change(function(){		
			forpag_id();
		});
		
$("#cmb_modpag_id").change(function(){		
			validar_campos($("#cmb_modpag_id").val());
		});

$("#txt_venpag_mon").keydown(function(e){
			if (e.which == 13){
				if($("#txt_venpag_mon").val()>0)
				{
					$("#cmb_forpag_id").focus();
				}
				else
				{
					$("#txt_bus_pro_codbar").focus();
				}				
				return false;
			}
		});

$("#cmb_forpag_id").keydown(function(e){
			if (e.which == 13){
				if($("#cmb_forpag_id").val()==1)$("#cmb_modpag_id").focus();
				if($("#cmb_forpag_id").val()==2)$("#txt_venpag_numdia").focus();
				return false;
			}
		});



$("#txt_ven_tot").change(function(e){
				
				monto_venpag();
			
		});
		
		
		$("#txt_ven_detitem").keydown(function(e){
			if (e.which == 13){
				
				
				return false;
			}
		});
		
		
$("#txt_ven_tot").keydown(function(e){
			if (e.which == 13){
				
				monto_venpag();
				return false;
			}
		});

		/* $("#cmb_modpag_id").keydown(function(e){
			if (e.which == 13){
				if($("#cmb_modpag_id").val()==1)$("#btn_venpag_agregar").focus();
				if($("#cmb_modpag_id").val()==2)$("#cmb_tar_id").focus();
				if($("#cmb_modpag_id").val()==3)$("#cmb_cuedep_id").focus();
				return false;
			}
		}); */

	
		$("#txt_venpag_numope").keydown(function(e){
			if (e.which == 13){$("#btn_venpag_agregar").focus();return false;}
		});
		
		$('#txt_venpag_numdia').change( function() {
			if($('#txt_venpag_numdia').val()!="")
			{
				ver_fecven();
			}
			else
			{
				$('#txt_venpag_fecven').val('');
			}
		});

		$("#txt_venpag_numdia").keydown(function(e){
			if (e.which == 13){$("#btn_venpag_agregar").focus();return false;}
		});
		

	

		
$('#cmb_doc_canpos_id').change(function(){
	
		
		numdoc_id();
	
});


$('#txt_atenc_guia,#txt_lle_guia').change(function(){
		$(this).val($(this).val().toUpperCase());
	});
	
var clicando = false;

$("#btn_ven_guardar").click(function() {
    
    
	
	var tipo = $("#cmb_doc_canpos_id").val();
	
	if(tipo == 33 || tipo == 34 )
	{		
		if($("#txt_canpos_numdoc").val()=="")
		{
			toastr["warning"]('Debes ingresar un numero de documento.'); 
			$("#txt_canpos_numdoc").focus();
		}else{
			$("#for_canposven").submit();
		}
		
	}else if($("#cmb_modpag_id").val()==""){
		toastr["warning"]('Debe seleccionar un modo de pago');  
	}else if($("#hdd_venpag_val").val() =="" && $("#cmb_caj_id").val()==""){
		toastr["warning"]('Debe seleccionar una caja');  
	}else if($("#txt_ven_tot").val()<=0){
		toastr["warning"]('Ingrese un monto total a cobrar');  
	}else{
		
		if(clicando){	
			clicando= false;	 	
			toastr["error"]('PRESIONE DE NUEVO A GUARDAR.');
		}else{
			clicando= true;
			$("#for_canposven").submit();
		
		}
		
		
		
		
	}

	
});
	
$('#for_canposven').bootstrapValidator({ 
	      message: 'Valor no valido',
	      feedbackIcons: {
	      	valid: 'glyphicon glyphicon-ok',
	      	invalid: 'glyphicon glyphicon-remove',
	      	validating: 'glyphicon glyphicon-refresh'
	      },
	      fields: {	      	
	      	
	      	cmb_doc_canpos_id: {
	      		group: '.col-lg-12',
	      		validators: {
	      			notEmpty: {
	      				message: 'Requerido *'
	      			}
	      		}
	      	},
			txt_lle_guia: {
	      		group: '.col-lg-12',
	      		validators: {
	      			notEmpty: {
	      				message: 'Requerido *'
	      			}
	      		}
	      	}
	      }
	  }).on('success.form.bv', function(e) { 
				//$('#div_mensaje_dialog').modal();
	  	$.ajax({
	  		type: "POST",
	  		url: "../canchapos/canchapos_reg.php",
	  		async:true,
	  		dataType: "json",
	  		data: $("#for_canposven").serialize(),
	  		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_mensaje').html(div);
	  			 
	  		},
	  		success: function(data){
	  			$('#div_canchapos_info_dialog').modal('hide');;
			
			if(data.est==0){
				///$('.div_venta_form_dialog').modal('hide');
				toastr["danger"](data.msj);
				
				
			}else if(data.est==0){
				toastr["info"](data.msj);
				//$('.div_venta_form_dialog').modal('hide');
					
			}	


			venta_ticket_datos(data.ven_id,data.ven_act);		

			
			
				//$('.div_venta_form_dialog in').removeClass('modal-backdrop');		
				canchapos_form_calendar('<?php echo $_POST['cancha_id']?>');
				
				
			/* 	$('.modal').modal('hide');
				$('.in').removeClass('modal-backdrop');		
				toastr["success"](data.msj);  			
				 */
	  		/* egreso_impresion(data.egr_id); */
	  			//cotizacion_tabla();
				
				
	  		},
	  		complete: function(){
	  			
	  		}
	  	});	
		

	  });
	 

	});
	
	

	function cmb_cue_id_canpos()
	{	
		$.ajax({
			type: "POST",
			url: "../cuentas/cmb_cue_id_canpos.php",
			async:true,
			dataType: "html",                      
			data: ({
				cuetip_id:"1",
				orden: "ord",
				cue_id: "4"
			}),
			beforeSend: function() {
				$('#cmb_cue_id_canpos').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_cue_id_canpos').html(html);
			}
		});
	}

	function cmb_subcue_id_canpos(cuenta_id)
	{	
		$.ajax({
			type: "POST",
			url: "../cuentas/cmb_subcue_id_canpos.php",
			async:true,
			dataType: "html",                      
			data: ({
				cue_id: cuenta_id,
				subcue_id: "<?php echo $subcue_id?>"
			}),
			beforeSend: function() {
				$('#cmb_subcue_id_canpos').html('<option value="">Cargando...</option>');
			},
			success: function(html){
				$('#cmb_subcue_id_canpos').html(html);
			}
		});
	}
	
	

	
</script>
<style type="text/css">
.ui-autocomplete
{
    z-index: 99999; 
}
	</style>

<div class="col-12 col-lg-12 col-md-12 col-sm-12" style="background-color:#fff;">

			<form  role="form" id="for_canposven" method="POST">
				<?php  //echo $can;?>
				<input type="hidden" id="hdd_can_id" name="hdd_can_id" value="<?php echo $_POST['cancha_id']?>">
				<input type="hidden" id="txt_mone_canpos_id" name="txt_mone_canpos_id" value="1">
				<input type="hidden" id="hdd_sepcan_id" name="hdd_sepcan_id" value="<?php echo $_POST['sepcan_id']?>">
				<input type="hidden" id="action" name="action" value="<?php echo $_POST['action'] ?>">
				<input name="hdd_imp_val" id="hdd_imp_val" type="hidden" value="">
				<input name="txt_mone_id" id="txt_mone_id" type="hidden" value="1">
<input name="hdd_venpag_val" id="hdd_venpag_val" type="hidden" value="">

					<div class="col-lg-12 col-sm-12 col-12">
						<table>
							<tr>
								<td> <h3 class="box-title">Documento a emitir</h3> </td>
								<td>
									<div style="padding:5px;" class="">
										<div class="div_checkbox float-left">
											<input type="checkbox" name="chk_imprimir" id="chk_imprimir" value="0" />
											<label for="chk_imprimir"></label>
										</div>
											<strong class="" style="font-size:15px;">Imprimir</strong>
										</div>

								</td>

							</tr>

						</table>
						
						

					</div>
	
					<div class="col-lg-12 col-sm-12 col-12 ">
							

 						<input type="hidden" id="hdd_ven_cli_idv" name="hdd_ven_cli_idv" value="<?php echo $cli_id ?>" />
 											
											<div class="row">

											<div class="col-lg-5 col-sm-4 col-6">															
												<label for="txt_com_pro_doc">RUC/DNI:</label>
 												<div class="input-group">
 													<span id="" style=""  class="input-group-btn">
									<span id="" style="cursor:pointer" class="btn btn-info btn-sm btn-flat" onClick="cliente_form('insertar')"><i class="fa fa-plus"></i></span> 
						</span>		
 														
 														<input name="txt_ven_cli_docv" type="text" id="txt_ven_cli_docv" value="<?php echo $cli_doc?>"   maxlength="11" class="form-control form-control-sm"> 
 													</div>
 												</div>

 												<div class="col-lg-7 col-sm-4 col-6">
 													<div id="div_clientecuenta_detalle"></div>
 													<label for="txt_ven_cli_nomv">Cliente:</label>
 													<input type="text" id="txt_ven_cli_nomv" name="txt_ven_cli_nomv"  value="<?php echo $cli_nom?>" class="form-control form-control-sm" />
 												</div> 
 											
 											
 												<div class="col-lg-12 col-sm-12 col-12">
 													<div id="div_clientecuenta_detalle"></div>
 													<label for="cmb_ven_cli_dirv">Dirección:</label>
 													
													<select name="cmb_ven_cli_dirv" id="cmb_ven_cli_dirv" class="form-control form-control-sm" >
													<option value="">-</option>
													</select>										   
												</div>
												</div>
											
		
		
	
					<div class="row">
					
					<div class="col-lg-6 col-sm-6 col-6">
						<label for="cmb_doc_canpos_id">Documento:</label>
						<select name="cmb_doc_canpos_id" id="cmb_doc_canpos_id" class="form-control form-control-sm"> </select>
					</div>
					
					<div id="div_numdoc" style="" class="col-lg-6 col-sm-6 col-6"> 
 							<label for="txt_canpos_numdoc">Num. Doc.:</label></br>
 							<input name="txt_canpos_numdoc" id="txt_canpos_numdoc" type="text" class=" form-control form-control-sm " >
 					</div>
				
				
				<div class="col-lg-12 col-sm-12 col-12">
 						<label for="txt_ven_detitem">Detalle:</label>
 						<input type="text" id="txt_ven_detitem" name="txt_ven_detitem" autocomplete="off" value="<?php echo $pro_nom?>" class="form-control form-control-sm" />
 			</div> 
 											
				
				
				
				
				<div class="row">
					<div id="" style="" class="col-lg-4 col-sm-4 col-4"> 
 							<label for="txt_canpos_totmin">Minutos:</label>
 							<input name="txt_canpos_totmin" id="txt_canpos_totmin" type="text" value="<?php echo $tiemin; ?>" class=" form-control form-control-xl "  >
 					</div>
					
					<div id="" style="" class="col-lg-4 col-sm-4 col-4"> 
 							<label for="txt_canpos_totmin">Adelanto:</label>
 							<input name="txt_canpos_ade" id="txt_canpos_ade" type="text" value="<?php echo formato_money($ade); ?>" class=" form-control form-control-xl "  >
 					</div>
					
					<div id="" style="" class="col-lg-4 col-sm-4 col-4"> 
 							<label for="txt_ven_tot">TOTAL:</label>
 							<input name="txt_ven_tot" id="txt_ven_tot" autocomplete="off" type="text" value="<?php echo formato_money($tot); ?>" class=" form-control form-control-xl "  >
 								</div>
 					</div>
				
				
				
 						<div class="col-lg-12 col-md-12 col-sm-12 col-12 " style="padding:3px;"> 
 							
 							<div id="tabcliente" class="nav-tabs-custom">
 								<nav class="nav nav-tabs">
 									<a href="#tab_2" style="color:#000;" class="nav-item nav-link active"  id="formpagotitle" data-toggle="tab" aria-expanded="true">Forma de Pago</a>
 								</nav>
 								<div class="tab-content">
 									
 										
 										<div class="active tab-pane " id="tab_2">
 											
 													<div class="row"> 
													
													<div class="col-lg-3 col-sm-4 col-12 form-group">
 														
														<label for="cmb_forpag_id">Forma:</label>
														
														<div class="input-group">
														
																<div class="icheck-primary div_chkcompag" >
																<input type="checkbox" id="chk_venpag_aut" >
																<label for="chk_venpag_aut">
																</label>
																</div>
														
 															<select name="cmb_forpag_id" id="cmb_forpag_id"  class="form-control form-control-sm">
 																<option value="1" selected="selected">CONTADO</option>
 																<option value="2">CREDITO</option>
 																
 															</select> 
														</div>
 													</div>
													
													<div id="div_modo" class="col-lg-3 col-sm-4 col-12">
															<label for="cmb_modpag_id">Modo:</label> 
															<select name="cmb_modpag_id" id="cmb_modpag_id" class="form-control form-control-sm">
 															<option value="1">EFECTIVO</option>
															<option value="7">YAPE</option>
															<option value="8">PLIN</option>
															<option value="2">DEPOSITO</option>
															<option value="4">TRANSFERENCIA</option>
															<option value="5">CHEQUE</option>
															<option value="6">TARJETA</option>
															</select> 
														</div>

													<div id="div_operacion" style="display:none" class="col-lg-3 col-sm-4 col-12"> 
 														<label class="lbl_venpag_numope">N° Operación:</label> 
 														<input type="text" name="txt_venpag_numope" autocomplete="off" id="txt_venpag_numope" class="form-control form-control-sm" >
 													</div>
				
													<div id="div_dia" style="display:none" class="col-lg-3 col-sm-3 col-12"> 
 														<label for="txt_venpag_numdia">N° Días:</label></br>
 														<input name="txt_venpag_numdia" id="txt_venpag_numdia" type="text" class=" form-control form-control-sm dias"  maxlength="3" >
 													</div>

 													<div id="div_fecven" style="display:none" class="col-lg-3 col-sm-3 col-12"> 
 														<label for="txt_venpag_fecven">F. Vencimiento:</label></br>
 														<input type="text" name="txt_venpag_fecven" id="txt_venpag_fecven"  maxlength="10" class=" form-control form-control-sm" readonly>
 													</div>
													
													<div class="col-lg-3 col-sm-3 col-xs-6" id="div_caj" >
														<label for="cmb_caj_id">Caja:</label>
														<select name="cmb_caj_id" id="cmb_caj_id" class="form-control form-control-sm"></select>
													</div>
													
													<div class="col-lg-3 col-sm-4 col-12">
 														<label for="txt_venpag_mon">Monto:</label> 
 														
														<div class="input-group"> 
 															<input name="txt_venpag_mon" type="text" class="form-control form-control-sm" id="txt_venpag_mon" style="text-align:right;" maxlength="10">
 														
															<span id="div_pago_agregar" style="display:none"  class="input-group-btn">
 																<a id="btn_venpag_agregar" class="btn btn-primary btn-flat btn-sm"  href="javascript:void(0)" onClick="pago_venta_agregar('agregar')">Agregar</a> 
 															</span>
 													   </div>
													
													</div>

 													

 												</div>
												
												<div class="col-lg-12 col-md-12 col-12 div_pagos_tabla">
 													<div id="div_venta_pago_car_tabla"></div>
 												</div>
 										
 										</div> 
 									</div>
 									
 								</div> 
 						</div>
 							

				
				
				
				
				
				
 					<div class="col-lg-4 col-sm-12 col-6" style="display:none" >
 							<label for="cmb_forpag_id_canpos">Forma:</label>													
							<select name="cmb_forpag_id_canpos" id="cmb_forpag_id_canpos"  class="form-control form-control-sm">
 							<option value="1" <?php if($forpag_id==1) echo 'selected'; ?> >CONTADO</option>
 							<option value="2" <?php if($forpag_id==2) echo 'selected'; ?> >CREDITO</option>
 							</select> 														
 					</div>

 					<div id="div_modo_canpos" class="col-lg-4 col-sm-12 col-6" style="display:none" >
 							<label for="cmb_modpag_id_canpos">Modo:</label> 
 							<select name="cmb_modpag_id_canpos" id="cmb_modpag_id_canpos" class="form-control form-control-sm">
							<option value="1" selected >EFECTIVO</option>
							<option value="2">DEPOSITO</option>
							<option value="4">TRANSFERENCIA</option>
							<option value="5">CHEQUE</option>
							<option value="6">TARJETA</option>
							</select> 
					</div>								

					<div id="div_dia_canpos" style="display:none" class="col-lg-2 col-sm-6 col-6"> 
 							<label for="txt_canpos_numdia">N° Días:</label></br>
 							<input name="txt_canpos_numdia" id="txt_canpos_numdia" type="text" value="<?php echo $dia; ?>" class=" form-control form-control-sm dias"  maxlength="3" >
 					</div>

 					<div id="div_fecven_canpos" style="display:none" class="col-lg-3 col-sm-6 col-6"> 
 							<label for="txt_canpos_fecven">F. Venc:</label></br>
 							<input type="text" name="txt_canpos_fecven" id="txt_canpos_fecven"  maxlength="10" class=" form-control form-control-sm" readonly>
 					</div>
					
					<div  class="col-lg-3 col-sm-6 col-6" id="div_nroopecom_canpos" style="display:none"  > 
 							<label id="lbl_egr_nroopecom">NRO. OPERACION:</label></br>
 							<input type="text" name="txt_nroope_canpos" id="txt_nroope_canpos"  class=" form-control form-control-sm ">
 					</div>
					
					<div id="div_cue" class="col-lg-4 col-sm-3 col-6 d-none">
							<label for="cmb_cue_id_canpos">Cuenta:</label>
							<select name="cmb_cue_id_canpos" id="cmb_cue_id_canpos" class="form-control form-control-sm "> </select> 
					</div>

					<div id="div_subcue" class="col-lg-4 col-sm-3 col-6 d-none">
						<label for="cmb_subcue_id_canpos">Sub Cuenta:</label>
						<select name="cmb_subcue_id_canpos" id="cmb_subcue_id_canpos_canpos" class="form-control form-control-sm "></select>
					</div>
					
					<div id="div_caj_canpos" class="col-lg-4 col-sm-12 col-6 " style="display:none" >
						<label for="cmb_caj_id_canpos">Caja:</label>
						<select name="cmb_caj_id_canpos" id="cmb_caj_id_canpos"  class="form-control form-control-sm" >
						</select>
					</div>
					
					<div class="col-12 col-lg-12 col-md-12 col-sm-12" style="height:10px;"></div>
					
					
					

						
 					</div>
					
					
					
					<div class="col-12 col-lg-12 col-md-12 col-sm-12" style="height:10px;"></div>

				</div>

			</form>
		
		<div class="modal-footer pull-right">	 
			<button type="button" class="btn btn-default " id="" data-dismiss="modal">Cancelar</button>
			<button type="button" class="btn btn-primary " id="btn_ven_guardar">Guardar</button>
		</div> 
		
		
		
		</div> 