MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/lifemaze_in/js/lp_chart.js
$(document).ready(function() {
	
	Highcharts.theme = {
		//colors: [ '#4F87CE', '#666666', '#CEC7C7','#CC3366','#B39DDB','#FFEB3B','#009688','#E91E63','#795548'],
		title: {
			style: {
				color: '#000',
				font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
			}
		},
	};
	Highcharts.setOptions(Highcharts.theme);
	
	$("#in_out_flow_btn").click(function() {
		in_out_flow_info(); // IN OUT FLOW DETAILED INFORMATION
	});
	$("#in_out_years").change(function() {
		in_out_flow_chart();
	});
	$("#in_out_inflation").change(function() {
		in_out_flow_chart();
	});
	$("#income_hike").change(function() {
		salary_income_chart();	
		other_income_chart();
		in_out_flow_chart();
	});
	

	$("input:radio[name='salary_income']").change(function(){
		salary_income_chart();
		other_income_chart();
    });
	$("input:radio[name='loan_option']").change(function(){
		loan_chart();
    });

	income_chart();			// OVER ALL INCOME
	salary_income_chart();	// SALARY INCOME NEXT 10 YEARS
	other_income_chart();	// OTHER INCOME NEXT 10 YEARS
	expense_chart();		// EXPENSE CHART
	loan_chart();			// LOAN CHART
	investment_chart();	    // INVESTMENT CHART
	in_out_flow_chart();	// IN OUT FLOW CHART
	protection_suggested(); // PROTECTION INFORMATION
	goal_info(); // GOAL INFORMATION
});

//PIE CHART COMMON SETTING
function get_pie_chart_option(render_to,title,legend){
	return options = {
		chart: {
			type: 'pie',
			renderTo: render_to,
		},
		plotOptions: {
			pie: {
				center: ["30%", "50%"],
				allowPointSelect: true,
				cursor: 'pointer',
				dataLabels: {
					enabled: true,
					formatter: function() {
						shortText = this.point.name;
						if(this.point.name.length >= 7){
							shortText = jQuery.trim(this.point.name).substring(0,6)+"...";
						}						
						return shortText;
					}
				},
				showInLegend: legend
			}			
		},
		title: {
			text: title
		},
		legend: {
			enabled: true,
			floating: true,
			verticalAlign: 'bottom',
			align:'right',
			width:230,
			x:0,
			y:0,
			useHTML: true,
			labelFormatter: function() {
				percentage = this.percentage.toFixed(2);
				return "<div class='col-md-12 pd0' style='display:inline-flex;font-size:11px !important;border:1px dotted #CCCCCC;border-bottom:0px;    font-weight: 400 !important;'><div style='float:left;width:65px;padding:2px;overflow:hidden; text-overflow:ellipsis;border-right: 1px dotted #CCCCCC;'>"+this.name+"</div><div style='float:left;padding:2px;width:75px;text-align:center;border-right: 1px dotted #CCCCCC;'>"+ this.y +"</div><div style='float:left;padding:2px;width:43px;'>"+percentage+"%</div></div>";
			}
		},
		series: [],
		drilldown: {
			series: []
		}
	};
}

//LINE AND COLUME CHART COMMON SETTING
function get_line_colume_chart_option(chart_type,render_to){
	return options = {
		chart: {
			type: chart_type,
			renderTo: render_to,
		},
		title: {
			text: ''
		},    
		yAxis: {
			min: 0,
			title: {
				text: ''
			}
		},
		tooltip: {
			headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
			pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
				'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
			footerFormat: '</table>',
			shared: true,
			useHTML: true
		},
		plotOptions: {
			column: {
				pointPadding: 0.2,
				borderWidth: 0
			},
			pie: {
				center: ["30%", "50%"],
				allowPointSelect: true,
				cursor: 'pointer',
				dataLabels: {
					enabled: true,
					formatter: function() {
						shortText = this.point.name;
						if(this.point.name.length >= 7){
							shortText = jQuery.trim(this.point.name).substring(0,6)+"...";
						}						
						return shortText;
					}
				},
				//showInLegend: false
			}
		},
		/*
		legend: {
            enabled: false
        },
		*/
		xAxis: {
			categories: [],
			crosshair: true
		},
		series: [],
		drilldown: {
			series: []
		}
	};
}

/*** DRAW OVER ALL INCOME CHART  ***/
function income_chart(){
	var frm = "over_all_income_chart";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {			
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			options = get_pie_chart_option("income_chart",'Yearly Income',true);
			options.series = rslt.series; 
			options.drilldown.series = rslt.drill_list;
			chart = new Highcharts.Chart(options);
			$("#income_total").html(rslt.income_total);
			window.dispatchEvent(new Event('resize'));
		},
	});
}

/*** DRAW 10 YEARS SALARY INCOME CHART  ***/
function salary_income_chart(){
	var frm      = "salary_income_chart";
	var char_opt = $('input[name=salary_income]:checked').val();
	var income_hike = $("#income_hike").val();
	if(income_hike === ""){
		income_hike = 10;
	}
		
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,income_hike:income_hike},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			options = get_line_colume_chart_option(char_opt,"in_salary_tab");
			options.series = rslt.series; 
			options.xAxis.categories = rslt.categories;
			chart = new Highcharts.Chart(options);
			window.dispatchEvent(new Event('resize'));
		},
	});
}

/*** DRAW 10 YEARS OTHER INCOME CHART  ***/
function other_income_chart(){
	var frm      = "other_income_chart";
	var char_opt = $('input[name=salary_income]:checked').val();
	var income_hike = $("#income_hike").val();
	if(income_hike === ""){
		income_hike = 10;
	}	
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,income_hike:income_hike},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			options = get_line_colume_chart_option(char_opt,"in_other_tab");
			options.series = rslt.series; 
			options.xAxis.categories = rslt.categories;
			chart = new Highcharts.Chart(options);
			window.dispatchEvent(new Event('resize'));
		},
	});
}

/*** EXPENSE CHART  ***/
function expense_chart(){
	var frm = "expense_chart";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			options = get_pie_chart_option("expense_chart",'Yearly Expense',true);
			options.series = rslt.series; 
			options.drilldown.series = rslt.drill_list;
			chart = new Highcharts.Chart(options);
			$("#expense_total").html(rslt.expense_total);
			window.dispatchEvent(new Event('resize'));
		},
	});
}

/*** LOAN CHART  ***/
function loan_chart(){
	var frm = "loan_chart";
	var char_opt = $('input[name=loan_option]:checked').val();
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			if(rslt.sts){
				if(char_opt === "pie"){
					options = get_pie_chart_option("loan_chart",'Yearly Loan',true);
				}else{
					options = get_line_colume_chart_option(char_opt,"loan_chart");
				}				
				options.series = rslt.series; 
				chart = new Highcharts.Chart(options);
				$("#loan_total").html(rslt.loan_total);
				window.dispatchEvent(new Event('resize'));
			}else{
				no_data = "<div style='font-size:16px;font-weight:bold;font-family:Trebuchet MS;text-align:center;padding:10px;'>Hurray!!! No Loan</div><div style='font-size:60px;color:#ed780e;padding:10%;text-align:center;'><i class='fa fa-grav fa-2x' aria-hidden='true'></i></div>";
				$("#loan_chart").html(no_data);
			}
			
			
		},
	});
}

/*** INVESTMENT CHART  ***/
function investment_chart(){
	var frm = "investment_chart";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			$("#investment_total").html(rslt.investment_total);
			if(parseInt(rslt.inv_total) === 0){
				no_data = "<div style='font-size:16px;font-weight:bold;font-family:Trebuchet MS;text-align:center;padding:10px;'>Oops!!! Not yet planned for your future ??</div><div style='font-size:60px;color:#ed780e;padding:10%;text-align:center;'><i class='fa fa-heartbeat fa-2x' aria-hidden='true'></i></div>";
				$("#investment_chart").html(no_data);
			}else{
				options = get_pie_chart_option("investment_chart",'Yearly Investment',true);
				options.series = rslt.series; 
				options.drilldown.series = rslt.drill_list;
				chart = new Highcharts.Chart(options);
				window.dispatchEvent(new Event('resize'));
			}
			
		},
	});
}

/*** IN OUT FLOW CHART  ***/
function in_out_flow_chart(){
	var frm = "in_out_flow_chart";
	var in_out_years = $("#in_out_years").val();
	if(in_out_years === ""){
		in_out_years = 14;
	}
	var in_out_inflation = $("#in_out_inflation").val();
	if(in_out_inflation === ""){
		in_out_inflation = 7;
	}
	var income_hike = $("#income_hike").val();
	if(income_hike === ""){
		income_hike = 10;
	}
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,in_out_years:in_out_years,in_out_inflation:in_out_inflation,income_hike:income_hike},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			options = {
				chart: {
					type: "column",
					renderTo: "in_out_flow_chart",
				},
				title: {
					text: 'In vs Out flow'
				},
				legend: {
					enabled: true
				},
				yAxis: {
					title: {
						text: ''
					}
				},
				xAxis: {
					categories: [],
				},
				credits: {
					enabled: false
				},
				series: []
			};
			options.series = rslt.series; 
			options.xAxis.categories = rslt.categories;
			chart = new Highcharts.Chart(options);
			window.dispatchEvent(new Event('resize'));
		},
	});
}
/*** IN OUT FLOW DETAILED INFORMATION  ***/
function in_out_flow_info(){
	var frm = "in_out_flow_info";
	var in_out_years = $("#in_out_years").val();
	if(in_out_years === ""){
		in_out_years = 14;
	}
	var in_out_inflation = $("#in_out_inflation").val();
	if(in_out_inflation === ""){
		in_out_inflation = 7;
	}
	var income_hike = $("#income_hike").val();
	if(income_hike === ""){
		income_hike = 10;
	}
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,in_out_years:in_out_years,in_out_inflation:in_out_inflation,income_hike:income_hike},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}	
			$("#in_out_flow_content").html(rslt.content);
			window.dispatchEvent(new Event('resize'));
		},
	});
}
/*** PROTECTION SUGGESTED  ***/
function protection_suggested(){
	var frm = "protection_suggested";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			$("#suggested_content").html(rslt.content);
			$('.modal').modal();
		},
	});
}
/*** GOAL INFORMTION  ***/
function goal_info(){
	var frm = "goal_info";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			$("#goal_info").html(rslt.content);
		},
	});
}
function goal_data(goal_id){	
	var frm = "goal_info_detail";
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,goal_id:goal_id},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			$('#goal_modal').modal('open');
			$("#goal_modal_content").html(rslt.content);
			$('select').formSelect();
		},
	});
}
function suggestion_returs(){	
	var frm = "suggestion_returs";
	var suggestion_id = $("#suggestion_id").val();	
	var suggestion_returs = $("#suggestion_returs").val();
	if(suggestion_returs === ""){
		suggestion_returs = 6;
	}
	$.ajax({
		type: "POST",
		url: "./bend/chart_callback",
		data:{frm:frm,goal_id:suggestion_id,suggestion_returs:suggestion_returs},
		success: function(data) {
			var rslt = JSON.parse(data);
			if(rslt.info === "Required Login"){
				send_login();
				return false;
			}
			$('#goal_modal').modal('open');
			$("#goal_modal_content").html(rslt.content);
			$('select').formSelect();
		},
	});
}