����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 74.208.127.88  /  Your IP : 216.73.216.116
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/muebles/application/customer2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/muebles/application/customer2/j_pos.js
let aval = 0;


//abrir modal de registro de datos adiciones de cliente empleo
	$("#btn-job").click(function(){
		//modal datos de trabajo
		$("#modal-customer_job").modal("show");		
		set_focus("#txtclientA");
	});
	
	//OCULTAR cualquier div 
function myFunction() {
    var x = document.getElementById("tabla_ocultar");
    if (x.style.display === "none") {
        x.style.display = "block";
		console.log("Ver Tabla de avales");
    } else {
        x.style.display = "none";
		console.log("Ocultar tabla de avales");
    }
}

		
$(document).ready( function (){
	
	
	  
	
	//enter en datos adicionales individuales cobranza
	$("#txtmin_pay").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtpayment_period");
		}
      });
	  $("#txtpayment_period").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtpaydate");
		}
      });
	  $("#txtpaydate").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtpayday");
		}
      });
	  $("#txtpayday").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#saveCobranza2");
		}
      });
	  
	  
	 
	  
	
	$("#txtname").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtparentesco");
		}
      });
	
	 $("#txtparentesco").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtdir");
		}
      });
	  
	   $("#txtdir").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txttel");
		}
      });
	  
	   $("#txttel").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtcolonia");
		}
      });
	  
	   $("#txtcolonia").keydown(function(e) {
        if(e.which == 13) {
		 
				set_focus("#txtciudad");
		}
      });
	  
	   $("#txtciudad").keydown(function(e) {
        if(e.which == 13) {
			var crud = $("#crud").val();
	
				if(crud != "E"){
					set_focus("#btnsaveAval");
				}else{
					
					var xcrud = $("#inputcrud").val();
					if(xcrud=='E'){
						set_focus("#btnEditAval2");
					}else{
						set_focus("#btnEditAval");
					}
					
				}	
		}
      });
	
	
	//buscar cliente en vista  employed
	$( "#txtclient" ).autocomplete({
			search  : function(){$(this).addClass('working');},
			open    : function(){$(this).removeClass('working');},
			source: function(request, response) {
				$.getJSON("autocomplete_client.php", { term: $('#txtclient').val() }, 
					response); },
				minLength:1,
				select:function(event, ui){
						$("#client_id").val(ui.item.id_client);
						$("#ClienteId").val(ui.item.id_client);
						$("#credito").val(ui.item.credito);
						
						//habilitar boton de agregar registro
						$("#btn-job").prop('disabled', false);
				}
			}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( "<dl><dt>"+item.id + "</dt>"+item.contract+ "</dl>"  )
			.appendTo( ul );
	};
	
	//buscar cliente en vista  collection
	$( "#txtclientC" ).autocomplete({
			search  : function(){$(this).addClass('working');},
			open    : function(){$(this).removeClass('working');},
			source: function(request, response) {
				$.getJSON("autocomplete_client.php", { term: $('#txtclientC').val() }, 
					response); },
				minLength:1,
				select:function(event, ui){
						$("#client_id").val(ui.item.id_client);
						$("#ClienteId").val(ui.item.id_client);
						$("#credito").val(ui.item.credito);
						$("#txtclientC").val(ui.item.contrato);
						//habilitar boton de agregar registro
						$("#btnCol").prop('disabled', false);
				}
			}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( "<dl><dt>"+item.id + "</dt>" + "<dt>" + item.nombre + "</dt><dt>" + item.contract+ "</dt></dl>"  )
			.appendTo( ul );
	};
	
	
	//buscar cliente en vista  collection
	$( "#txtclientCobranzaOnly" ).autocomplete({
			search  : function(){$(this).addClass('working');},
			open    : function(){$(this).removeClass('working');},
			source: function(request, response) {
				$.getJSON("autocomplete_client.php", { term: $('#txtclientCobranzaOnly').val() }, 
					response); },
				minLength:1,
				select:function(event, ui){
						$("#DatoIdClientCOnly").val(ui.item.id_client);
						$("#txtIdclientCobranza").val(ui.item.id_client);
						$("#txtContratoclientCobranza").val(ui.item.contrato);
						//habilitar boton de agregar registro
						$("#btnCol").prop('disabled', false);
				}
			}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( "<dl><dt>"+item.id + "</dt>" + "<dt>" + item.nombre + "</dt><dt>" + item.contract+ "</dt></dl>"  )
			.appendTo( ul );
	};
	
	//buscar cliente en vista  employed
	$( "#txtnameB" ).autocomplete({
			search  : function(){$(this).addClass('working');},
			open    : function(){$(this).removeClass('working');},
			source: function(request, response) {
				$.getJSON("autocomplete_client.php", { term: $('#txtnameB').val() }, 
					response); },
				minLength:1,
				select:function(event, ui){
						$("#client_id").val(ui.item.id_client);
						$("#ClienteId").val(ui.item.id_client);
						$("#credito").val(ui.item.credito);
						//contrato
						$("#txtcontractCancel").val(ui.item.contrato);
				}
			}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( "<dl><dt>"+item.id_client + "</dt>" + "<dt>" + item.nombre + "</dt><dt>" + item.contract+ "</dt></dl>"  )
			.appendTo( ul );
	};
	
	//ENTER EN MODAL DAR DE cancelar contrato
	 //txtnameB  
	 $("#txtnameB").keydown(function(e) {
        if(e.which == 13) {
		  
				set_focus("#txtdateBaja");
		}
      });
	  
	  //txtdateBaja
	  
	   $("#txtdateBaja").keydown(function(e) {
        if(e.which == 13) {
		  
				set_focus("#txtreason");
		}
      });
	  
	  //txtreason
	  
	  $("#txtreason").keydown(function(e) {
        if(e.which == 13) {
		  
				set_focus("#btncheckCancel");
		}
      });
	
	
	
});	

//verificamos si el contrat existe
$(document).on("blur","#txtcontract",function (){
	
	console.log("Verificar contrato si ya existe");
	 var trx = $("#txtcontract").val();
	
	 if(trx == '' || trx == null){
		 $.notify({
						message: "Favor de ingresar contrato!!"		
					},{
						type: 'warning',
						delay: 5000,
					});	
					
		return;
		set_focus("#txtcontract");
		console.log("Validamos que no este vacio el campo contrato");
	 }else{
		 ConsultarContratoExiste(trx);
		 console.log("verificamos que exista el contrato");
	 }
	
});

//Consultar Contrato si Existe(trx)
function ConsultarContratoExiste(idbrg){
	var value = {
		id_item: idbrg,
		method : "get_contract"
	};
	$.ajax(
	{
		url : "customer.php",
		type: "POST",
		data : value,
		success: function(data, textStatus, jqXHR)
		{
			var data = jQuery.parseJSON(data);
			if(data.error ==true){
				
				var crud=$("#crud").val();
	
				if(crud != 'E'){
					$.notify({
						message: "Contrato ya existe!!"		
					},{
						type: 'danger',
						delay: 5000,
					});	
					$("#txtcontract").val("");
					set_focus("#txtcontract");
					return
				}	
				
			}

		},
		error: function(jqXHR, textStatus, errorThrown)
		{
			$.notify({
				message: "Error general  de clientes  consulta de contrato"
						
			},{
				type: 'danger',
				delay: 5000,
			});	
		}
	});
}

	//abrir modal de aval
$(document).on("click","#new-aval",function(){
	
	var crud = $("#crud").val();
	
	if(crud != "E"){
	
		set_focus("#txtname");
			
		var aval_id = $("#avalActual_id").val();
			
			if(aval_id == '' || aval_id == null)
		{
			$.notify({
				message: "Revise datos de Cliente, datos Faltantes, re-intente"
			},{
				type: 'warning',
				delay: 3000,
			});
			return;
		}else{
			var x =  parseInt(document.getElementById("avalActual_id").value);
			console.log(aval_id);
			$("#modalmasteritem").modal("show");
			if(x <= 1){ 
				$("#titleAval").html("Datos de aval 1");
				console.log("abrir para primer aval");
				set_focus("#new-aval");	
				x= x+1;
			}
			if(x =2){
								
			$("#titleAval").html("Datos de aval 1");				
								
			}	
		}
		
	}else{
		console.log("editar datos de aval 1");
		document.getElementById('btnEditAval').style.visibility = "visible"; // show
		document.getElementById('btnsaveAval').style.visibility = "hidden"; // show
		
		$("#modalmasteritem").modal("show");
		$("#titleAval").html("Editar Datos de aval 1");
		set_focus("#txtname");
		
			
	}		
		
});


//guardar editar aval 1 y abrir aval 2
$(document).on( "click","#btnEditAval", function() {
	
	swal({
		title: "Editar",
		text: "Desea Editar Datos de aval 1 de cliente ?",
		type: "warning",
		showCancelButton: true,
		confirmButtonClass: "btn-primary",
		confirmButtonText: "Actualizar",
		closeOnConfirm: true }, 
		function(){
					set_focus("#txtname");
					console.log("Editar datos aval 1!!!");						
					//editar aval 1 de cliente
					//actualizamos aval 1 
					//edit_aval(name,relationship,colonia,direction,customer_id,country,phone,contract)
					edit_aval($("#txtname").val(),$("#txtparentesco").val(),$("#txtcolonia").val(),$("#txtdir").val(),$("#customer_id").val(),$("#txtciudad").val(),$("#txttel").val(),$("#txtcontract").val())
					
					document.getElementById('btnsaveAval').style.visibility = "hidden"; // show
					
					
						//agregar aval 2 para editar
					var contract = $("#txtcontract").val();
					agregar_aval2(contract);	
					
		});
		
});

//guardar editar aval 1 y abrir aval 2
$(document).on( "click","#btnEditAval2", function() {
	
	swal({
		title: "Editar",
		text: "Desea Editar Datos de aval 2 de cliente ?",
		type: "warning",
		showCancelButton: true,
		confirmButtonClass: "btn-primary",
		confirmButtonText: "Actualizar",
		closeOnConfirm: true }, 
		function(){
					
					set_focus("#txtname");
					console.log("Editar datos aval 2!!!");						
					//editar aval 1 de cliente
					edit_aval($("#txtname").val(),$("#txtparentesco").val(),$("#txtcolonia").val(),$("#txtdir").val(),$("#customer_id").val(),$("#txtciudad").val(),$("#txttel").val(),$("#txtcontract").val())
					
					//cierra modal de aval
					$("#modalmasteritem").modal("hide");
					
					//ACTUALIZAR DATOS DE EMPLEO
					edit_cobranza1($("#txtcontract").val(),$("#txtclientA").val(),$("#txtworkplace").val(),$("#txtsalary").val(),$("#txtlaborOld").val(),$("#txtlaborOld_periodicity").val(),$("#txtpayment_periodicity").val());
		
		
					//abrimos cobranza 
					$("#modalCobranza2").modal("show");
					set_focus("#txtmin_pay");
				
		});
		
});

//Salir de las ventanas
$(document).on( "click","#Salir", function() {
	
	swal({
		title: "Cliente",
		text: "Desea Salir de Editar datos de cliente ?",
		type: "warning",
		showCancelButton: true,
		confirmButtonClass: "btn-primary",
		confirmButtonText: "Salir",
		closeOnConfirm: true }, 
		function(){
				
					location.reload();
					
					//cierra modal de aval
					$("#modalmasteritem").modal("hide");
					
					//cerramos cobranza 
					$("#modalCobranza2").modal("hide");		
					
					//cerramos cliente 
					$("#modalClientes").modal("hide");		
					
		});
		
});


//funcion que actualizar aval 1
function edit_aval(name,relationship,colonia,direction,customer_id,country,phone,contract){
			var indice_aval = $("#avalActual_id").val();
			let ajax = {method: "editAval",
			indice_aval,
			name,
			relationship,
			colonia,
			direction,
			customer_id,
			country,
			phone,
			contract
			}
			$.ajax({
				url: "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);
					if($resp['result'] == true){
						
						$.notify({
							message: " Registro de aval Actualizado correctamente!!" 
							},{
							type: 'info',
							delay: 3000,
						});
						
						
					}else{
						$.notify({
							message: " Error de registro de aval 1" 
							},{
							type: 'warning',
							delay: 3000,
						});
						
					}
					
				},
				error: function (request, textStatus, errorThrown) {
						$.notify({
							message: "Error : " + request.responseJSON.message
							},{
							type: 'success',
							delay: 3000,
						});
					
					
				}
			});
}

	
//agregamos aval 2
function agregar_aval2(contract){
			let ajax = {method: "agregar_aval2",
			contract,
			}
			$.ajax({
				url: "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);
					if($resp['result'] == true){
						
						console.log("mostra editar aval 2");
						
					
						$("#txtname").val("");
						$("#txtparentesco").val("");
						$("#txttel").val("");
						$("#txtcolonia").val("");
						$("#txtdir").val("");
						$("#inputcrud").val("");
						$("#avalActual_id").val("");
						
						//agregamos el segundo aval
						$("#txtname").val($resp['data'].name);
						$("#txtparentesco").val($resp['data'].relationship);
						$("#txttel").val($resp['data'].phone);
						$("#txtcolonia").val($resp['data'].colonia);
						$("#txtdir").val($resp['data'].country);
						$("#inputcrud").val("E");
						$("#avalActual_id").val($resp['data'].id);
						
						document.getElementById('btnEditAval').style.visibility = "hidden"; // show
						document.getElementById('btnEditAval2').style.visibility = "visible"; // show
			
						$("#titleAval").html("Datos de aval 2");
						set_focus("#txtname");
						
						$.notify({
							message: " Editar aval 2" 
							},{
							type: 'success',
							delay: 3000,
						});
						
						
					}else{
						$.notify({
							message: " Error de registro de aval 2" 
							},{
							type: 'warning',
							delay: 3000,
						});
						
					}
					
				},
				error: function (request, textStatus, errorThrown) {
						$.notify({
							message: "Error : " + request.responseJSON.message
							},{
							type: 'success',
							delay: 3000,
						});
					
					
				}
			});
}
	
	//guardar registro de empleo 
$(document).on( "click","#btnsaveAval", function() {
	//titulo de avales
	// $("#saveCobranza").click();
	
	$("#titleAval").html("Datos de aval 2");
	

	//$("#btnsaveAval").prop('disabled', true);
	var id_client = $("#txtclientA").val();
	var name= $("#txtname").val();
	var parentesco = $("#txtparentesco").val();
	var tel = $("#txttel").val();
	var colonia= $("#txtcolonia").val();
	var dir=$("#txtdir").val();
	var ciudad=$("#txtciudad").val();
			
	
	
	if($("#txtname").val() == ''){
					swal("Ingrese nombre");
					return;
				}
	if($("#txtciudad").val() == ''){
					swal("Ingrese Poblacion");
					return;
				}
	if($("#txttel").val() == ''){
					swal("ingrese numero de telefono");
					return;
				}
	if($("avalActual_id").val() == ''){
					$.notify({
							message: "Error General de registro de aval, falta id de aval" 
							},{
							type: 'danger',
							delay: 3000,
						});
					
					
					return;
				}
	
						$.notify({
							message: " registrando avales espere..." 
							},{
							type: 'success',
							delay: 3000,
						});
						var aval_id = $("#avalActual_id").val();
						add_aval($("#txtname").val(),$("#txtparentesco").val(),$("#txtcolonia").val(),$("#txtdir").val(),$("#customer_id").val(),$("#txtciudad").val(),$("#txttel").val(),$("#txtcontract").val());
						console.log("registrar aval con exito, # aval= " + aval_id);
						
	
});


//funcion que agrega aval
function add_aval(name,relationship,colonia,direction,customer_id,country,phone,contract){
			let ajax = {method: "saveAval",
			name,
			relationship,
			colonia,
			direction,
			customer_id,
			country,
			phone,
			contract
			}
			$.ajax({
				url: "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);
					if($resp['result'] == true){
						
						var avalActual_id = $("avalActual_id").val();
						//gardamos los valores del aval registrado en note
						var avales = $("#avalActual_id").val() + "/" + $("#txtname").val() + "/" + $("#txtparentesco").val() + "/" + $("#txttel").val() + "/" + $("#txtcolonia").val() + "/" + $("#txtdir").val() + "#";
						
						//var mitextarea= document.getElementById("txtnote");
						//var texto=document.createTextNode(avales);
						//mitextarea.appendChild(texto);
						//$("#txtnote").val(avales);
						
						
						
						$("#txtname").val("");
						$("#txtparentesco").val("");
						$("#txttel").val("");
						$("#txtcolonia").val("");
						$("#txtdir").val("");
						$("#inputcrud").val("");
						var x =  parseInt(document.getElementById("avalActual_id").value);
						y=x+1;
						$("#avalActual_id").val(y);
						console.log(y);
						aval=aval+1;
						$("#txtname").focus();
						if(aval==2){
							console.log("cerrar datos de empleo y guardar");
							$("#saveCobranza").click();
							$( "#modalmasteritem" ).modal("hide");
						}
						
						$.notify({
							message: " Registro de Avales Guardados" 
							},{
							type: 'success',
							delay: 3000,
						});
						
						
					}else{
						$.notify({
							message: " Error de registro de aval" 
							},{
							type: 'warning',
							delay: 3000,
						});
						
					}
					
				},
				error: function (request, textStatus, errorThrown) {
						$.notify({
							message: "Error : " + request.responseJSON.message
							},{
							type: 'success',
							delay: 3000,
						});
					
					
				}
			});
		}



//btn  cancelar cliente
$("#btnCancelar").click(function(){
		console.log("abrir modal para cancelar contrato");				
						
		$("#crud").val("B");
				
		$("#myModalLabel").html("Cancelar Cliente");
				
		$("#CancelarCmodal").modal("show");		
		set_focus("#txtnameB");
	
});		

//editar adicionales de cbranza EditCobranza
$("#EditCobranza").click(function(){
	
	var crud = $("#crud").val();
	
	if(crud=='E'){
		
		//(cont,txtclientA,txtworkplace,txtsalary,txtlaborOld,txtlaborOld_periodicity,txtpayment_periodicity)
		edit_cobranza1($("#txtcontract").val(),$("#txtclientA").val(),$("#txtworkplace").val(),$("#txtsalary").val(),$("#txtlaborOld").val(),$("#txtlaborOld_periodicity").val(),$("#txtpayment_periodicity").val());
		
		//modal-customer
							$("#modalCobranza2").modal("show");
							$("#myModalLabel").html("Editar Datos de Cobranza");
							//$("#txtclientA").prop('disabled', false);
							console.log("Empezar editar datos de cobranza");
							set_focus("#txtmin_pay");						
					
		
	}else{
		console.log("no aplica solo en editar cliente");
	}	
				
});		


//edit_cobranza1
function edit_cobranza1(cont,txtclientA,txtworkplace,txtsalary,txtlaborOld,txtlaborOld_periodicity,txtpayment_periodicity){
			let ajax = {
				method: "edit_cobranza1",
				cont:cont,
				txtclientA :  txtclientA,
				txtsalary: txtsalary,
				txtworkplace : txtworkplace,
				txtlaborOld: txtlaborOld,
				txtlaborOld_periodicity:txtlaborOld_periodicity,
				txtpayment_periodicity:txtpayment_periodicity
			}
			$.ajax({
				url:  "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);

					if($resp['status'] == true){
						
						$.notify({
								message: "Registro de Empleo de Cliente Actualizado correctamente"
							},{
								type: 'success',
								delay: 4000,
							});	
						
						
						
					}else{
						
						$.notify({
								message: "Error :" + $resp['message']
							},{
								type: 'success',
								delay: 4000,
							});	
						
							
						document.getElementById("txtworkplace").focus();
						swal($resp['message']);
					}
				},
				error: function (request, textStatus, errorThrown) {
					swal("Error ", request.responseJSON.message, "error");

				}
			});
}
				


//cancelar cliente
$(document).on("click",'#btncheckCancel',function(){
		
	if($("#txtcontractCancel").val() == ''){
					swal("Buscar primero cliente a cancelar!");
					return;
		}
	
	var contract = $("#txtcontractCancel").val();
		//datos de cancelacion
	var crud = $("#crud").val();
		var fechab = $("#txtdateBaja").val(); 
		var txtreason = $("#txtreason").val();
		
		var value = {
			contract:contract,
			crud:crud,
			fechab:fechab,
			txtreason: txtreason,
			method : "check_cancelC"
		};
		$.ajax(
		{
			url : "customer.php",
			type: "POST",
			data : value,
			success: function(data, textStatus, jqXHR)
			{
				var data = jQuery.parseJSON(data);
				if(data.result == true)
				{
				
					$.notify({
						message: "Cliente cancelado correctamente!"
					},{
						type: 'success',
						delay: 3000,
					});
					$("#CancelarCmodal").modal("hide");
					
				
				}else{
				
					$.notify({
						message: "Error en el registro de cancelacion de cliente" + data.error
					},{
						type: 'danger',
						delay: 5000,
					});
					set_focus("#txtnameB");
					return;
				}
			},
			error: function(jqXHR, textStatus, errorThrown)
			{
				$.notify({
						message: "Error general para cancelar registro, #: " + textStatus.responseText 
					},{
						type: 'danger',
						delay: 5000,
					});
				
			}
		});
	});






//datos de referencias laborales
$(document).on( "click","#saveCobranza", function() {
	
		var crud=$("#crud").val();
		var contrato=$("#txtcontract").val();
	
	
if(crud == 'E'){
		if(contrato == '' || contrato== null ){
			$.notify({
				message: "No se Puede Editar el contrato"
			},{
				type: 'warning',
				delay: 8000,
			});		
			$("#txtnombre").focus();
			
		}else{
				$("#txtcontract").disabled=true;
				swal({
						title: "Editar",
						text: "Desea Editar Datos Adicionales de cliente ?",
						type: "warning",
						showCancelButton: true,
						confirmButtonClass: "btn-primary",
						confirmButtonText: "Actualizar",
						closeOnConfirm: true }, 
					function(){
					console.log("Editar datos adicionales!!!");						
						//adicionales de empleo de cliente
					edit_cobranza1($("#txtcontract").val(),$("#txtclientA").val(),$("#txtworkplace").val(),$("#txtsalary").val(),$("#txtlaborOld").val(),$("#txtlaborOld_periodicity").val(),$("#txtpayment_periodicity").val());
				//ocultar modal
					$("#modal-customer_job").modal("hide");	
					
					//focus en buscar cliente
					set_focus("#txtBuscarCliente");
					
					
				});
		}		
		
	}else{

			
			set_focus("#txtmin_pay");
			var id_client = $("#txtclientA").val();
			var workplace = $("#txtworkplace").val();	
			var laborOld = $("#txtlaborOld").val();
			var salary = $("#txtsalary").val();
			var avales = $("#txtnote").val();
			var laborOld_periodicity=$("txtlaborOld_periodicity").val();
			var payment_periodicity = $("#txtpayment_periodicity").val();
			

			//encontramos el primer # 54/ANA/ANA/ANA#32/ANA/ANA/ANA#
			//var validarAvales = avales.indexOf('#');
			//var validarAvales2 = avales.lastIndexOf('#');
			/*
			if(validarAvales == -1 ){
				$.notify({
						message: "Favor de ingresar aval #1. no esta capturado: " 
					},{
						type: 'warning',
						delay: 8000,
					});
				return;
			}else{
				
				if(validarAvales == validarAvales2  ){
					$.notify({
					message: "Favor de ingresar aval #2. no esta capturado: " 
				},{
					type: 'warning',
					delay: 8000,
				});
				return;		
				}
				
			}
			*/
			
			if(workplace == '' || workplace== null ){
				$.notify({
					message: "por favor ingrese EMPLEO"
				},{
					type: 'warning',
					delay: 8000,
				});		
				$("#txtworkplace").focus();
				return;
			}
			
			if(salary == '' || salary== null ){
				$.notify({
					message: "por favor ingrese Sueldo"
				},{
					type: 'warning',
					delay: 8000,
				});		
				$("#txtworkplace").focus();
				return;
			}
			
			if(id_client == '' || id_client == null ){
				$.notify({
					message: "primero busque al cliente, para agregar el # contrato"
				},{
					type: 'warning',
					delay: 8000,
				});		
				$("#CleanDatos").click();
				$("#txtclient").focus();
				return;
			}
			
			
			var value = {
					id_client : id_client,
					workplace : workplace,
					laborOld : laborOld,
					salary : salary,
					avales : avales,
					laborOld_periodicity:laborOld_periodicity,
					payment_periodicity:payment_periodicity,
						method : "saveadicionales"
					};
					$(this).prop('disabled', true);
					proccess_waiting("#infoproses");
					$.ajax(
					{
						url : "customer.php",
						type: "POST",
						data : value,
						success: function(data, textStatus, jqXHR)
						{
							
							//ocultar modal
							$("#modal-customer_job").modal("hide");	
							
							var resp = JSON.parse(data);
							if(resp['result']==true){
								
								$.notify({
								message: "Se Registraron datos de Empleo! "
								},{
									type: 'success',
									delay: 5000,
								});	
								//modal-customer_job
							$("#modalCobranza2").modal("show");
								set_focus("#txtmin_pay");
								
							}else{
								$.notify({
								message: "Error Registro Empleo!" + resp.error
								},{
									type: 'danger',
									delay: 5000,
								});
								
							}	
								
							
						},
						error: function(jqXHR, textStatus, errorThrown)
						{
							$.notify({
								message: "Error: "  + data.error
							},{
								type: 'danger',
								delay: 8000,
							});	
							$("#saveCobranza").prop('disabled', false);
						}
					});	
	}
});	


/*
editar datos adicinales de cliente
*/
function edit_cobranza(cont,workplace,laborOld,laborOld_periodicity,salary,payment_periodicity){
			let ajax = {
				method: "edit_cobranza",
				cont:cont,
				workplace :  workplace,
				laborOld : laborOld,
				laborOld_periodicity:laborOld_periodicity,
				salary:salary,
				payment_periodicity:payment_periodicity
			}
			$.ajax({
				url:  "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);

					if($resp['status'] == true){
						
						set_focus("#txtworkplace");	
						swal("Se Actualizo Registro de datos adicionales! ");
						
					}else{
							
						document.getElementById("txtworkplace").focus();
						swal($resp['message']);
					}
				},
				error: function (request, textStatus, errorThrown) {
					swal("Error ", request.responseJSON.message, "error");

				}
			});
		}



//ABRIR modal cobranza 2
$("#btnCol").click(function(){
		//modal datos de trabajo
		$("#modalCustomerCollection").modal("show");	
			console.log("Entrar a modal de cobranza individual");
		set_focus("#txtmin_pay");
	});
	
//datos para guardar de cobranza desde modal inidividual
$(document).on( "click","#saveCobranza2", function() {
	
	
	var id_client = $("#txtIdclientCobranza").val();
	var payday = $("#txtpayday").val();
	var payment_period = $("#txtpayment_period").val();
	var min_pay = $("#txtmin_pay").val();
	var paydate = $("#txtpaydate").val();
	var contract = $("#txtContratoclientCobranza").val();
	
	if(id_client == '' || id_client== null ){
		$.notify({
			message: "por favor ingrese contrato"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}
	
	if(payday == '' || payday== null ){
		$.notify({
			message: "por favor ingrese dias de pago"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}
	
	if(min_pay == '' || min_pay == null ){
		$.notify({
			message: "por favor ingrese  pago minimo"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}

	
	var value = {
			id_client : id_client,
			payday : payday,
			payment_period : payment_period,
			min_pay : min_pay,
			paydate: paydate,
			contract: contract,
				method : "saveadicionales2"
			};
			
			
			$.ajax(
			{
				url : "customer.php",
				type: "POST",
				data : value,
				success: function(data, textStatus, jqXHR)
				{
					 
					 //ocultar modal cobranza 2
					$("#modalClientes").modal("hide");	
					//ocultar modal cobranza 2
					$("#modalCobranza2").modal("hide");	
					
					$.notify({
						message: "Se Registraron datos de Cobranza! " 
					},{
						type: 'warning',
						delay:1000,
					});	
					$.notify({
						message: "Espere se Abrira Captura de articulos....! "
					},{
						type: 'warning',
						delay: 3000,
					});	
					
					var data = jQuery.parseJSON(data);
					
					var cliente = data.id_client;
				
					setTimeout( function() { 
					
					window.location.href = "../salesCredit/v_pos.php?id_client=" + cliente;

					}, 5000 );
				
				},
				error: function(jqXHR, textStatus, errorThrown)
				{
					$.notify({
						message: "Error: "  + data.error
					},{
						type: 'danger',
						delay: 8000,
					});	
					$("#saveCobranza2").prop('disabled', false);
				}
			});
	
	
	
});


//datos para guardar de cobranza desde modal inidividual
$(document).on( "click","#saveCobranzaDesdeCliente", function() {
	
	
	var id_client = $("#txtIdclientCobranza").val();
	var payday = $("#txtpayday").val();
	var payment_period = $("#txtpayment_period").val();
	var min_pay = $("#txtmin_pay").val();
	var paydate = $("#txtpaydate").val();
	var contract = $("#txtclientA").val();
	
	var crud=$("#crud").val();
	var contrato=$("#txtcontract").val();
	
	
if(crud == 'E'){
		if(contrato == '' || contrato== null ){
			$.notify({
				message: "No se Puede Editar el contrato"
			},{
				type: 'warning',
				delay: 8000,
			});		
			$("#txtnombre").focus();
			
		}else{
				$("#txtcontract").disabled=true;
				swal({
						title: "Editar",
						text: "Desea Editar Datos de Cobranza de cliente ?",
						type: "warning",
						showCancelButton: true,
						confirmButtonClass: "btn-primary",
						confirmButtonText: "Actualizar",
						closeOnConfirm: true }, 
					function(){
					console.log("Editar datos de cobranza!!!");						
					//editar datos adicionales de empleo de cliente
					edit_cobranza2(contrato,id_client,payday,min_pay,paydate,payment_period);
				
				});
		}		
		
	}else{
	
	
	
	if(id_client == '' || id_client== null ){
		$.notify({
			message: "por favor ingrese contrato"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}
	
	if(payday == '' || payday== null ){
		$.notify({
			message: "por favor ingrese dias de pago"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}
	
	if(min_pay == '' || min_pay == null ){
		$.notify({
			message: "por favor ingrese  pago minimo"
		},{
			type: 'warning',
			delay: 8000,
		});		
		$("#txtclient").focus();
		return;
	}

	
	var value = {
			id_client : id_client,
			payday : payday,
			payment_period : payment_period,
			min_pay : min_pay,
			paydate: paydate,
			contract: contract,
				method : "saveadicionales2"
			};
			
			
			$.ajax(
			{
				url : "customer.php",
				type: "POST",
				data : value,
				success: function(data, textStatus, jqXHR)
				{
					 
					 //ocultar modal cobranza 2
					$("#modalClientes").modal("hide");	
					//ocultar modal cobranza 2
					$("#modalCobranza2").modal("hide");	
					
					$.notify({
						message: "Se Registraron datos de Cobranza! " 
					},{
						type: 'warning',
						delay:1000,
					});	
					$.notify({
						message: "Espere se Abrira Captura de articulos....! "
					},{
						type: 'warning',
						delay: 3000,
					});	
					
					var data = jQuery.parseJSON(data);
					
					var cliente = data.id_client;
				
					setTimeout( function() { 
					
					window.location.href = "../salesCredit/v_pos.php?id_client=" + cliente;

					}, 5000 );
				
					
				},
				error: function(jqXHR, textStatus, errorThrown)
				{
					$.notify({
						message: "Error: "  + data.error
					},{
						type: 'danger',
						delay: 8000,
					});	
					$("#saveCobranza2").prop('disabled', false);
				}
			});
	
	}	
	
});


//funcion cambio de selec cobrador
function handleChange(event){
    var selectedOption = event.target.options[event.target.selectedIndex];
    console.log("Option selected: " + selectedOption.value);
	colector_id = selectedOption.value;
	var crud = $("#crud").val();
	
	
	if(crud!='N'){
	
		swal({
			title: "Cliente",
			text: "Desea Actualizar Cobrador ?",
			type: "warning",
			showCancelButton: false,
			confirmButtonClass: "btn-primary",
			confirmButtonText: "Actualizar",
			closeOnConfirm: true }, 
			function(){
					
				//editamos dato de cobrador			
				edit_customer_collector($("#txtcontract").val(),colector_id);		
			});
	}else{
		console.log("Generar cliente nuevo");
	}	
			
		
}

//editar cobrador en customer
function edit_customer_collector(cod,id){
			let ajax = {
				method: "edit_customer_collector",
				contract :  cod,
				colector_id : id
			}
			$.ajax({
				url:  "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);

					if($resp['status'] == true){
						
						$.notify({
						message: "Se actualizo cobrador Correctamente!!"
						},{
							type: 'success',
							delay: 2000,
						});	
						
						//siguiente dato
						set_focus("#txtconyugue");	
						
	
					}else{
						
						$.notify({
						message: "Error al actualizar registro !!"
						},{
							type: 'danger',
							delay: 2000,
						});	
						
						
						document.getElementById("txtBuscarCliente").focus();
						
					}
				},
				error: function (request, textStatus, errorThrown) {
					swal("Error ", request.responseJSON.message, "error");
					
					console.log(request.responseJSON.message);

				}
			});
		}




//datos de cobranza
//edit_cobranza2(id_client,payday,min_pay,paydate,payment_period);
function edit_cobranza2(cont,id_client,payday,min_pay,paydate,payment_period){
			let ajax = {
				method: "edit_cobranzaADI",
				cont:cont,
				id_client :  id_client,
				payday : payday,
				min_pay:min_pay,
				paydate:paydate,
				payment_period:payment_period
			}
			$.ajax({
				url:  "customer.php",
				type: "POST",
				data: ajax,
				success: function(data, textStatus, jqXHR)
				{
					$resp = JSON.parse(data);

					if($resp['status'] == true){
						
						
						$.notify({
								message: "Registro de cobranza Actualizado correctamente"
							},{
								type: 'success',
								delay: 4000,
							});	
						
						
						swal("Se Actualizo Registro de cobranza de cliente! ");
						
						var cliente = $("#txtcontract").val();
						
						setTimeout( function() { 
							
							window.location.href = "../salesCredit/v_pos.php?id_client=" + cliente;

							}, 5000 );
						
						
					}else{
							
						document.getElementById("txtworkplace").focus();
						swal($resp['message']);
					}
				},
				error: function (request, textStatus, errorThrown) {
					swal("Error ", request.responseJSON.message, "error");

				}
			});
}
				



//abrir el modal de captura de clientes
$("#btn-add").click(function(){
				//modal-customer
				$("#modalClientes").modal("show");
				$("#myModalLabel").html("Nuevo Cliente");
				//$("#btnAbrirAdi").prop('disabled', true);
				$("#crud").val("N");
				
				set_focus("#txtcontract");
				$("#txtcontract").val("Buscar Numero de Contrato");
				
				document.getElementById('btnCancelar').style.visibility = "visible"; // show
				document.getElementById('btnedit').style.visibility = "visible"; // show
				document.getElementById('btnConfirmar').style.visibility = "hidden"; // show
				document.getElementById('txtBuscarCliente').style.visibility = "hidden"; // show
				
					console.log("Empezar registro/edit/baja");
				document.getElementById('txtcontract').select();
				
				document.getElementById('btnAbrirAdi').style.visibility = "hidden"; // show
				//EditCobranza
				document.getElementById('EditCobranza').style.visibility = "hidden"; // show
				
				document.getElementById('btnEditAval').style.visibility = "hidden"; // show
			
				document.getElementById('btnsaveAval').style.visibility = "visible"; // show
			
				document.getElementById('btnEditAval2').style.visibility = "hidden"; // show
				
				document.getElementById('saveCobranza').style.visibility = "visible"; // show
				
				document.getElementById('btnsaveitem').style.visibility = "visible"; // show
				$("#txtcontract").val("");
				$("#txtnombre").val("");
				$("#txtconyugue").val("");
				$("#txtdireccion").val("");
				$("#txtcome_in").val("");
				$("#txttelefono").val("");
				$("#cbocredito").val("");
				$("#txtpoblacion").val("");
				$("#selector-seller").val("");
				
	
			
});	


//modal-customer_job editar datos adicionales de empleo
$("#btnAbrirAdi").click(function(){
	
	var crud = $("#crud").val();
	
	if(crud=='E'){
		//modal-customer
		$("#modal-customer_job").modal("show");
		
		//txtworkplace
		set_focus("#txtworkplace");
		//document.getElementById('saveCobranza').style.visibility = "hidden"; // show
	
		
		$("#myModalLabel").html("Editar Datos adiciones de Cliente");
		//$("#txtclientA").prop('disabled', false);
		console.log("Empezar editar datos adicionales");
	}else{
		console.log("no aplica solo en editar cliente");
	}	
				
});		
	


$( "#txtBuscarCliente" ).autocomplete({
			search  : function(){$(this).addClass('working');},
			open    : function(){$(this).removeClass('working');},
			source: function(request, response) {
				$.getJSON("autocomplete_client.php", { term: $('#txtBuscarCliente').val() }, 
					response); },
				minLength:1,
				select:function(event, ui){
						console.log("mostramos los datos del cliente");
						$("#txtcontract").val(ui.item.contrato);
						$("#txtnombre").val(ui.item.nombre);
						$("#txtconyugue").val(ui.item.conyugue);
						$("#txtdireccion").val(ui.item.direccion);
						$("#txtcome_in").val(ui.item.come_in);
						//txtcode
						$("#txtcode").val(ui.item.id_client);
						$("#txttelefono").val(ui.item.phone);
						//
						$("#txtpoblacion").val(ui.item.poblacion);
						
						//agregamos cobrador
						document.getElementById('id_seller').innerHTML = ui.item.colector_id;
;						//agregamos cobrador
						var miMenu = document.getElementById("selector-seller");
						miMenu.value= ui.item.colector_id;
						console.log(ui.item.cobrador);
						
						set_focus("#txtcontract");
						//agregamos tambien los datos adicionales//
						//document.getElementById('txtBuscarCliente').style.visibility = "hidden"; // show
						$("#txtclientA").val(ui.item.id_client);
						
						$("#txtworkplace").val(ui.item.txtworkplace);
						$("#txtlaborOld").val(ui.item.txtlaborOld);
						$("#txtlaborOld_periodicity").val(ui.item.txtlaborOld_periodicity);
						$("#txtsalary").val(ui.item.txtsalary);
						$("#txtpayment_periodicity").val(ui.item.txtpayment_periodicity);
						
						
						//agregamos datos de cobranza
						$("#txtmin_pay").val(ui.item.min_pay);
						$("#txtpayment_period").val(ui.item.txtpayment_period);
						$("#txtpaydate").val(ui.item.paydate);
						$("#txtpayday").val(ui.item.payday);
						
						//agregamos aval 1
						$("#txtname").val(ui.item.aval_name);
						$("#txtparentesco").val(ui.item.aval_relationship);
						$("#txttel").val(ui.item.aval_phone);
						$("#txtcolonia").val(ui.item.aval_colonia);
						$("#txtdir").val(ui.item.aval_direction);
						$("#txtciudad").val(ui.item.aval_country);
						$("#avalActual_id").val(ui.item.aval_id);
						
						
						$("#txtIdclientCobranza").val(ui.item.id_client);
						
						
						
						document.getElementById('btnAbrirAdi').style.visibility = "visible"; // show
						
						
//EditCobranza
						document.getElementById('EditCobranza').style.visibility = "visible"; // show
						//limpiar datos
						document.getElementById('CleanDatos').style.visibility = "hidden"; // show
				
						
						
				}
			}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( "<dl><dt>"+item.name + "/*/" + "</dt>"+item.direccion+ "</dl>"  )
			.appendTo( ul );
};	
	
	
//editar cliente

$("#btnedit").click(function(){
				document.getElementById('btnConfirmar').style.visibility = "visible"; // show
				$("#crud").val("E");
				set_focus("#txtBuscarCliente");
				
				$("#myModalLabel").html("Editar Cliente");
				document.getElementById('btnCancelar').style.visibility = "hidden"; // show
				document.getElementById('btnsaveitem').style.visibility = "hidden"; // show
				document.getElementById('btnedit').style.visibility = "hidden"; // show
				
				document.getElementById('txtBuscarCliente').style.visibility = "visible"; // show
				document.getElementById('txtcontract').style.disabled = true;
			});		
	
//CONFIRMAMOS editar	
$(document).on( "click","#btnConfirmar", function() {
	$("#btnsaveitem").click();
});					

Youez - 2016 - github.com/yon3zu
LinuXploit