





<div class="content-header" >

      <div class="container-fluid">

        <div class="row mb-2">

		 <div class="col-sm-6">

			<h1>

			Canje de letras proveedor

			<small>modulo</small>

			</h1>

		</div>	

		

		<div class="col-sm-6">

            <ol class="breadcrumb float-sm-right">

				<li class="breadcrumb-item" >Inicio</li>

				<li class="breadcrumb-item" >Operaciónes</li>

				<li class="breadcrumb-item active">Canje de letras proveedor</li>

            </ol>

          </div>

		</div>

	</div>

</div>





			<div class="modal fade" id="div_canje_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_canje_form" style="padding:0%;" >



			</div>

			<br />

			<br />

			</div>

			</div>

			</div>





			<div class="modal fade" id="div_canje_form_vista_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_canje_form_vista" style="padding:0%;" >



			</div>

			<br />

			<br />

			</div>

			</div>

			</div>









	<div class="modal fade" id="div_canjedocumentos_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_canjedocumentos_form" style="padding:0%;" >



			</div>

			<br />

			<br />

			</div>

			</div>

			</div>









	<div class="modal fade" id="div_canjeletra_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_canjeletra_form" style="padding:0%;" >



			</div>

			<br />

			<br />

			</div>

			</div>

			</div>





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



	<!-- filtro de registro -->

	<div id="div_canje_filtro" ></div>

	<!-- lista de datos -->

	<div id="div_caje_tabla" ></div>







<script type="text/javascript">















function letra_form(act,id_let,vis,canid){	

	

	$('#div_canjeletra_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,

			canid:canid

		}),

		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_canjeletra_form').html(div); 

		},

		success: function(html){

			$('.div_canjeletra_form').html(html);				

		},

		complete: function(html){



		}

	});

}







	

function canje_filtro()

{

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_filtro.php",

		async:true,

		dataType: "html",                      

		//data: ({

			//producto: $('#txt_fil_pro').val()

		//}),

		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_canje_filtro').html(div);

		},

		success: function(html){

			$('#div_canje_filtro').html(html);

		},

		complete: function(){

		//	cuentasxpagar_tabla();

		}

	});

}



function verForm(){

			if($("#cmb_fil_empresa_id").val()=="" || $("#hdd_fil_pro_id").val()=="" || $('#cmb_fil_mon_id').val() =="" ){

				$("#btn_nuevocanje").hide(100);

				$("#btn_nuevocanje").attr('onclick', '');

			}else{

				$("#btn_nuevocanje").show(100);

				$("#btn_nuevocanje").attr('onclick', 'canje_form()');

			}



		}



	function canje_form(mon){

			$('#div_canje_form_dialog').modal();

		//$('body').css('overflow-y','hidden');

			$.ajax({

				type: "POST",

				url: "../canjeproveedor/canjeproveedor_form.php",

				async:true,

				dataType: "html",                      

				data: ({

						provid : $('#hdd_fil_pro_id').val(),

						empid: $('#cmb_fil_empresa_id').val(), 

						monid: $('#cmb_fil_mon_id').val(),

						totmon: $('#hdd_totcanje').val()





						

				}),

				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_canje_form').html(div);

				},

				success: function(html){

					$('.div_canje_form').html(html);				

				}

			});

		}







function canje_form_vista(act,id){

			$('#div_canje_form_vista_dialog').modal();

		//$('body').css('overflow-y','hidden');

			$.ajax({

				type: "POST",

				url: "../canjeproveedor/canjeproveedor_form_vista.php",

				async:true,

				dataType: "html",                      

				data: ({

						act:act ,

						canid : 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_canje_form_vista').html(div);

				},

				success: function(html){

					$('.div_canje_form_vista').html(html);				

				}

			});

		}



		

function canje_tabla()

{

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_tabla.php",

		async:true,

		dataType: "html", 

		data: $("#for_fil_pro").serialize(),                    

		beforeSend: function() {

			

			$('#div_caje_tabla').addClass("ui-state-disabled");

		},

		success: function(html){

			$('#div_caje_tabla').html(html);

		},

		complete: function(){			

			$('#div_caje_tabla').removeClass("ui-state-disabled");

			canje_pago_agregar('restablecer');

		}

	});     

}

		

function canje_eliminar(act,cajpro_id)

{

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_reg.php",

		async:true,

		dataType: "json", 

		data: ({

			action : act,

			cajpro_id : cajpro_id

		}),               

		beforeSend: function() {

			

		},

		success: function(data){

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

		},

		complete: function(){			

			canje_tabla();

		}

	});     

}









function canje_documentos_tabla(act,provid,empid,docnum,monid)

{

	

	

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canje_documento_tabla.php",

		async:false,

		dataType: "html",                  

		data: ({

			action:	 act,

			provid: provid,

			empid: empid,

			docnum:docnum,

			monid:monid



		}),

		beforeSend: function() {

			$('#div_canje_doc').addClass("ui-state-disabled");

		},

		success: function(html){

			$('#div_canje_doc').html(html);

		},

		complete: function(){			

			$('#div_canje_doc').removeClass("ui-state-disabled");



			monto_canpag();

		}

	});

}















function canje_pago_tabla(act)

{

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canje_pago_tabla_insertar.php",

		async:false,

		dataType: "html",                  

		data: ({

			action:	 act,

			can_tot: $('#hdd_can_tot').val()

		}),

		beforeSend: function() {

			$('#div_canje_car_tabla').addClass("ui-state-disabled");

		},

		success: function(html){

			$('#div_canje_car_tabla').html(html);

		},

		complete: function(){			

			$('#div_canje_car_tabla').removeClass("ui-state-disabled");



			monto_canpag();

		}

	});

}





function monto_canpag()

{



		var dif = $('#hdd_canpag_dif').val();

		$('#txt_letra_imp').val(dif);

}







function canje_pago_agregar(act,idf)

{	



	//alert($('#txt_canje_fec').val());



	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canje_pago_agregar.php",

		async:false,

		dataType: "json",                      

		data: ({

			item_id : idf,

			action:	 act,	

			canpag_mon: $('#txt_letra_imp').val(),

			canpag_numlet: $('#txt_canje_numlet').val(),

			canpag_numunilet: $('#txt_canje_letuni').val(),

			canpag_ref: $('#txt_canje_ref').val(),

			canpag_lugar: $('#txt_canje_lug').val(),

			canpag_numdia: $('#txt_canje_numdia').val(),

			canpag_fecven: $('#txt_canje_fecven').val(),

			canpag_fecemi: $('#txt_canje_fec').val(),

			can_tot: $('#hdd_can_tot').val(),

			canpag_tot: $('#hdd_canpag_tot').val()			

		}),

		beforeSend: function() {

			

		},

		success: function(data){

			if(data.est==false)

			{

			

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



				if(data.dat.tipo=="canpag_mon")

				{

					$('#txt_letra_imp').val(data.dat.mon);

					$('#txt_letra_imp').focus();

				}

				

				if(data.dat.tipo=="canpag_numdia")

				{

					$('#txt_canje_numdia').focus();

				}



				if(data.dat.tipo=="canpag_ref")

				{

					$('#txt_canje_ref').focus();

				}



				

			}



			if(data.est==true)

			{

				if(data.dat.tipo=="agregado")

				{

					$('#txt_letra_imp').focus();

				}

			}

		},

		complete: function(){

			canje_pago_tabla();

			$('#txt_canje_numdia').val('');

			$('#txt_canje_fecven').val('<?php echo date("d-m-Y")?>');

		}

	});

}

	



function canje_letras_tabla_vista(act,canid)

{

	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canje_letra_tabla_vista.php",

		async:false,

		dataType: "html",                  

		data: ({

			action:	 act,

			canid:canid



		}),

		beforeSend: function() {

			$('#div_canje_car_tabla_vista').addClass("ui-state-disabled");

		},

		success: function(html){

			$('#div_canje_car_tabla_vista').html(html);

		},

		complete: function(){			

			$('#div_canje_car_tabla_vista').removeClass("ui-state-disabled");



		}

	});

}



	$(function() {



		$('#btn_actualizar').click(function() {

			$("#content").load("../cajeproveedor/cajeproveedor_vista.php");

		});





	$("#div_canjeletra_form_dialog").on('hidden.bs.modal', function () {

		   	$('body').css('overflow-y','hidden');

		});

		

	$("#div_canjeletra_form_dialog").on('hidden.bs.modal', function () {

		   	$('body').css('overflow-y','scroll');

		});



		canje_filtro();



		setTitle("CANJE DE LETRAS PROVEEDOR - "+nombreEmpresa); 



	});



</script>  