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/cpaqua.cafsinfotech.in/dist/highcharts/claim_dashboard.js
/**
 * Smart HRMS Claim Dashboard JavaScript
 * Highcharts Integration
 */

// Define base_url if not already defined
if (typeof base_url === 'undefined') {
    // Try to get from window or use default
    var base_url = (typeof window !== 'undefined' && window.base_url) ? 
                   window.base_url : 
                   'http://localhost/smart_hrms_8_3/';
    console.log('base_url defined in claim_dashboard.js:', base_url);
}

function get_claim_master_count(){
	var key        = '<?php echo $encKey; ?>';
	
	// Temporarily disable encryption to test if endpoints work
	// TODO: Fix encryption compatibility
	var encData    = { /*encrypt(key,{})*/};
	$.ajax({
		url: base_url+'Claim_dashboard/get_claim_master_count',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#total_claims').html(data.table_data.total_claims);
				$('#pending_claims').html(data.table_data.pending_claims);
				$('#approved_claims').html(data.table_data.approved_claims);
				$('#rejected_claims').html(data.table_data.rejected_claims);
				$('#total_amount_claimed').html(data.table_data.total_amount_claimed);
				$('#total_amount_approved').html(data.table_data.total_amount_approved);
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function get_claim_statistics_info(encData){
	// Temporarily disable encryption to test
	// TODO: Fix encryption compatibility
	var encData = { /*encrypt(key, encData)*/};
		url: base_url+'Claim_dashboard/get_claim_statistics',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#claim_statistics_info').html(data.table_data);
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function get_claim_category_info(encData){
	// Temporarily disable encryption to test
	// TODO: Fix encryption compatibility
	var encData = { /*encrypt(key, encData)*/};
		url: base_url+'Claim_dashboard/get_claim_category_sts',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#get_claim_category_info').html(data.table_data);
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function get_claim_details(get_cell,table_id,from_date,to_date,branch,date_period,key){
	// Temporarily disable encryption to test
	// TODO: Fix encryption compatibility
	var encData = {get_cell:get_cell,table_id:table_id,from_date:from_date,to_date:to_date,branch:branch,date_period:date_period};
	$.ajax({
		url: base_url+'Claim_dashboard/get_claim_details',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#detail_'+table_id).html(data.table_data);
				$('#detail_'+table_id).DataTable({
					"destroy": true,
					"bSort": true,
					"bPaginate": true,
					"bLengthChange": true,
					"bInfo": true,
					"bAutoWidth": true,
					"bFilter": false,
					"bStateSave": true,
					"scrollX": true,
					"scrollY": "300px",
					"scrollCollapse": true,
					"pageLength": 10,
					"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
					"language": {
						"lengthMenu": "Display _MENU_ records per page",
						"loadingRecords": "Please wait - loading...",
						"emptyTable": "No data available in table",
						"info": "Showing _START_ to _END_ of _TOTAL_ entries",
						"search": "Search:",
						"zeroRecords": "No matching records found",
						"paginate": {
							"first": "First",
							"last": "Last",
							"next": "Next",
							"previous": "Previous"
						}
					}
				});
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function get_category_details(get_cell,table_id,from_date,to_date,branch,date_period,category,key){
	var encData = encrypt(key,{get_cell:get_cell,table_id:table_id,from_date:from_date,to_date:to_date,branch:branch,date_period:date_period,category:category});
	$.ajax({
		url: base_url+'Claim_dashboard/get_category_details',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#detail_'+table_id).html(data.table_data);
				$('#detail_'+table_id).DataTable({
					"destroy": true,
					"bSort": true,
					"bPaginate": true,
					"bLengthChange": true,
					"bInfo": true,
					"bAutoWidth": true,
					"bFilter": false,
					"bStateSave": true,
					"scrollX": true,
					"scrollY": "300px",
					"scrollCollapse": true,
					"pageLength": 10,
					"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
					"language": {
						"lengthMenu": "Display _MENU_ records per page",
						"loadingRecords": "Please wait - loading...",
						"emptyTable": "No data available in table",
						"info": "Showing _START_ to _END_ of _TOTAL_ entries",
						"search": "Search:",
						"zeroRecords": "No matching records found",
						"paginate": {
							"first": "First",
							"last": "Last",
							"next": "Next",
							"previous": "Previous"
						}
					}
				});
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function claim_category_count_chart(encData){
	$.ajax({
		url: base_url+'Claim_dashboard/claim_category_count_chart',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.length > 0){
				$('#showCustom').hide();
				Highcharts.chart('claim_category_count_chart', {
					chart: {
						type: 'column'
					},
					title: {
						text: 'Claim Category Wise'
					},
					xAxis: {
						categories: data[0].data,
						title: {
							text: 'Category'
						}
					},
					yAxis: {
						title: {
							text: 'Count'
						}
					},
					legend: {
						enabled: false
					},
					plotOptions: {
						column: {
							dataLabels: {
								enabled: true,
								rotation: -90,
								color: '#FFFFFF',
								align: 'right',
								y: 10
							}
						}
					},
					series: [{
						name: data[1].name,
						data: data[1].data,
						color: '#0288d1'
					}]
				});
			}else{
				$('#showCustom').show();
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function claim_status_details_info(encData){
	$.ajax({
		url: base_url+'Claim_dashboard/claim_status_details_info',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#claim_status_details_info').html(data.table_data);
				$('#claim_status_info_tab').DataTable({
					"destroy": true,
					"bSort": true,
					"bPaginate": true,
					"bLengthChange": true,
					"bInfo": true,
					"bAutoWidth": true,
					"bFilter": false,
					"bStateSave": true,
					"scrollX": true,
					"scrollY": "300px",
					"scrollCollapse": true,
					"pageLength": 10,
					"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
					"language": {
						"lengthMenu": "Display _MENU_ records per page",
						"loadingRecords": "Please wait - loading...",
						"emptyTable": "No data available in table",
						"info": "Showing _START_ to _END_ of _TOTAL_ entries",
						"search": "Search:",
						"zeroRecords": "No matching records found",
						"paginate": {
							"first": "First",
							"last": "Last",
							"next": "Next",
							"previous": "Previous"
						}
					}
				});
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function claim_approval_status_chart(encData){
	$.ajax({
		url: base_url+'Claim_dashboard/claim_approval_status_chart',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.length > 0){
				$('#showCustom').hide();
				Highcharts.chart('claim_approval_status_chart', {
					chart: {
						type: 'pie'
					},
					title: {
						text: 'Claim Approval Status'
					},
					tooltip: {
						pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
					},
					accessibility: {
						point: {
							valueSuffix: '%'
						}
					},
					plotOptions: {
						pie: {
							allowPointSelect: true,
							cursor: 'pointer',
							dataLabels: {
								enabled: true,
								format: '<b>{point.name}</b>: {point.percentage:.1f} %'
							},
							showInLegend: true
						}
					},
					series: [{
						name: 'Status',
						colorByPoint: true,
						data: data[1].data.map(function(point, i) {
							if (point.name === 'Approved') {
								return {
									name: point.name,
									y: point.y,
									color: '#4DB6AC'
								};
							} else if (point.name === 'Pending') {
								return {
									name: point.name,
									y: point.y,
									color: '#FFCA28'
								};
							} else if (point.name === 'Rejected') {
								return {
									name: point.name,
									y: point.y,
									color: '#FF5252'
								};
							} else {
								return {
									name: point.name,
									y: point.y,
									color: '#BA68C8'
								};
							}
						})
					}]
				});
			}else{
				$('#showCustom').show();
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}

function get_claim_team_data(encData){
	$.ajax({
		url: base_url+'Claim_dashboard/get_claim_team_data',
		type: 'POST',
		data: encData,
		dataType: 'json',
		success: function(data){
			if(data.success){
				$('#claim_team_info_tab').html(data.table_data);
				$('#claim_team_info_tab').DataTable({
					"destroy": true,
					"bSort": true,
					"bPaginate": true,
					"bLengthChange": true,
					"bInfo": true,
					"bAutoWidth": true,
					"bFilter": false,
					"bStateSave": true,
					"scrollX": true,
					"scrollY": "300px",
					"scrollCollapse": true,
					"pageLength": 10,
					"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
					"language": {
						"lengthMenu": "Display _MENU_ records per page",
						"loadingRecords": "Please wait - loading...",
						"emptyTable": "No data available in table",
						"info": "Showing _START_ to _END_ of _TOTAL_ entries",
						"search": "Search:",
						"zeroRecords": "No matching records found",
						"paginate": {
							"first": "First",
							"last": "Last",
							"next": "Next",
							"previous": "Previous"
						}
					}
				});
			}else{
				toastr.error(data.message);
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			toastr.error('Something went wrong..!!');
		}
	});
}