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/hrms_cafsinfotech_in/application_bk14FEB2026/views/detailed_reconciliation/form.php
<ul class="nav nav-tabs" data-tabs="tabs">
	<li class="active" role="presentation">
		<a data-toggle="tab" href="#setting_info">Setting Information</a>
	</li>
	<li role="presentation">
		<a data-toggle="tab" href="#earn_info">Earning Information</a>
	</li>
	<li role="presentation">
		<a data-toggle="tab" href="#deduct_info">Deduction Information</a>
	</li>
</ul>
<div class="tab-content">
	<div class="tab-pane fade in active" id="setting_info">
			<?php  echo  form_open("$controller_name/save_setting/",array("id"=>"save_reconciliation","class"=>"form-inline")); ?>
			<div class="form-group">
				<?php
					echo form_input( array('name'=>'prime_reconciliation_id', 'id'=>'prime_reconciliation_id', 'type'=>'Hidden','value'=> $reconciliation_info->prime_reconciliation_id));
					echo form_label('Setting Name', 'setting_name', array('class' => 'required'));
					echo form_input(array('name' => 'setting_name', 'id' => 'setting_name', 'class' => 'form-control input-sm',  'value'=> $reconciliation_info->setting_name)); 
				?>
			</div>
			<div class="form-group">
				<button class='btn btn-primary btn-sm' id="submit">Submit</button>
			</div>
			<?php  echo form_close(); ?>
	</div>
	<div class="tab-pane fade" id="earn_info">
		<?php 
			echo form_open("$controller_name/save_earning_info/",array('id'=>'earning_info_form','class'=>'form-inline collapse'));
		?>
		<div class="form-group">
			<?php
				echo form_input( array('name'=>'reconciliation_id', 'id'=>'reconciliation_id', 'type'=>'Hidden','value'=>$reconciliation_info->prime_reconciliation_id));
				echo form_input( array('name'=>'prime_earning_id', 'id'=>'prime_earning_id', 'type'=>'Hidden','value'=>0));
				echo form_label("Earning Column", 'earning_column', array('class' => 'required'));
				echo form_dropdown(array('name' => 'earning_column','id' =>'earning_column','class' => 'form-control input-sm select2'),$earning_columns);
			?>
		</div>
		<div class="form-group">
			<?php					
				echo form_label("Display Name", 'display_name', array('class' => 'control-label required'));
				echo form_input(array( 'name' => 'display_name', 'id' => 'display_name', 'class' => 'form-control input-sm ', 'value' => ''));
			?>
		</div>
		<div class="form-group">
			<?php					
				echo form_label("Order No", 'earning_order', array('class' => 'control-label required'));
				echo form_input(array( 'name' => 'earning_order', 'id' => 'earning_order', 'class' => 'form-control input-sm  number', 'value' => ''));
			?>
		</div>
		<div class="form-group">
			<button type='submit' class='btn btn-sm btn-primary' id='add_earning_info_btn'>Add/Update</button>
			<button type='button' class='btn btn-sm btn-danger' id='cancel_earning_info_btn'>Cancel</button>
		</div>
		<?php echo form_close(); ?>
		<div class='col-md-12' style='background-color:#e2e2e2;padding:8px;margin-bottom: 10px;'>
			<div style='margin-bottom: 8px; text-align: right; padding: 0px 15px;'>
				<a class="btn btn-xs btn-primary" role="button" data-toggle="collapse" href="#earning_info_form" aria-expanded="false" aria-controls="collapseExample"> Add Earning</a>
			</div>
			<div id='earning_table'>
				<?php echo $earning_column_table;?>
			</div>
		</div>
	</div>
	<!-- Table Sort View -->
	<div class="tab-pane fade" id="deduct_info">
		<?php
			echo form_open("$controller_name/save_deduct_info/",array('id'=>'deduct_info_form','class'=>'form-inline collapse'));
		?>
		<div class="form-group">
			<?php
				echo form_input( array('name'=>'prime_deduct_reconciliation_id', 'id'=>'prime_deduct_reconciliation_id', 'type'=>'Hidden','value'=> $reconciliation_info->prime_reconciliation_id));
				echo form_input( array('name'=>'prime_deduct_id', 'id'=>'prime_deduct_id', 'type'=>'Hidden','value'=>0));
				echo form_label("Deduction Column", 'deduct_column', array('class' => 'required'));
				echo form_dropdown(array('name' => 'deduct_column','id' =>'deduct_column','class' => 'form-control input-sm select2'),$ded_columns);
			?>
		</div>
		<div class="form-group">
			<?php					
				echo form_label("Display Name", 'display_deduct_name', array('class' => 'control-label required'));
				echo form_input(array( 'name' => 'display_deduct_name', 'id' => 'display_deduct_name', 'class' => 'form-control input-sm ', 'value' => ''));
			?>
		</div>
		<div class="form-group">
			<?php					
				echo form_label("Order No", 'deduct_order', array('class' => 'control-label required'));
				echo form_input(array( 'name' => 'deduct_order', 'id' => 'deduct_order', 'class' => 'form-control input-sm number ', 'value' => ''));
			?>
		</div>
		<div class="form-group">
			<button type='submit' class='btn btn-sm btn-primary' id='add_deduct_info_btn'>Add/Update</button>
			<button type='button' class='btn btn-sm btn-danger' id='cancel_deduct_info_btn'>Cancel</button>
		</div>
		<?php echo form_close(); ?>
		<div class='col-md-12' style='background-color:#e2e2e2;padding:8px;margin-bottom: 10px;'>
			<div style='margin-bottom: 8px; text-align: right; padding: 0px 15px;'>
				<a class="btn btn-xs btn-primary" role="button" data-toggle="collapse" href="#deduct_info_form" aria-expanded="false" aria-controls="collapseExample"> Add Deduction</a>
			</div>
			<div id='deduction_table'>
				<?php echo $deduct_column_table;?>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	select_call();
	$table = $('.earn_table,.ded_table').DataTable({
		processing: true,
		lengthMenu: [[10,25,50,100,500,1000,-1],[10,25,50,100,500,1000,"All"]],
		// fixedColumns:{leftColumns: 4},
		scrollX: true,
		dom: 'Blfrtip',
		order:true,
		buttons: [
			{ extend: 'excelHtml5', footer: true },
		],
		language:{
			lengthMenu:"<span style='margin-top:12px;margin-left:10px;'>Display</span> _MENU_ <span style='margin-top:12px;'>Records</span>",
			searchPlaceholder: "Search records",
			search: "",
		},
	});
	$('input[type=search]').addClass('form-control input-sm');
	$("select[name='table_length']" ).addClass('form-control input-sm');
	$('.dt-button').addClass('btn btn-xs btn-edit');
	$('.btn-edit').removeClass('dt-button buttons-excel buttons-html5');
	
	// SAVE GENERAL INFORMTION
	$.validator.setDefaults({ignore:[]});
	$("#save_reconciliation").submit(function(event){ event.preventDefault(); }).validate({
		rules:{
			setting_name: "required",
		},
		submitHandler: function (form){	
			$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
			$('#submit').attr('disabled','disabled'); 
			//Encrypted
			let formData           = new FormData(form);
			// Convert FormData to JSON object
			let jsonData           = Object.fromEntries(formData.entries());
			var encKey             = '<?php echo $encKey; ?>';
			var encData            = encrypt(encKey,jsonData);
			$.ajax({
				type: "POST",
				url: '<?php echo site_url($controller_name . "/save_setting"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function (response){
					$('#submit').attr('disabled',false);
					$("#submit").html("Submit");
					if(response.success){
						toastr.success(response.message);
						$("#reconciliation_id").val(response.ins_id);
						$("#prime_deduct_reconciliation_id").val(response.ins_id);
						$('.nav-tabs a[href="#earn_info"]').tab('show');
						table_support.refresh();
					}else{
						toastr.error(response.message);
					}	
				},
				dataType: 'json'
			});
		}          
	});


	//SAVE EARNING INFORMTION
	$("#earning_info_form").submit(function(event){ event.preventDefault(); }).validate({
		rules:{
			earning_column: "required",
			display_name: "required",
			earning_order: "required"
		},
		submitHandler: function (form){	
			$("#add_earning_info_btn").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
			$('#add_earning_info_btn').attr('disabled','disabled');
			//Encrypted
			let formData           = new FormData(form);
			// Convert FormData to JSON object
			let jsonData           = Object.fromEntries(formData.entries());
			var encKey             = '<?php echo $encKey; ?>';
			var encData            = encrypt(encKey,jsonData);
			$.ajax({
				type: "POST",
				url: '<?php echo site_url($controller_name . "/save_earning_info"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function (response){
					$('#add_earning_info_btn').attr('disabled',false);
					$("#add_earning_info_btn").html("Submit");
					if(response.success){
						toastr.success(response.message);
						$('#prime_earning_id').val(0);
						$('#earning_info_form')[0].reset();
						$('#earning_info_form').collapse('hide');
						get_earning_info(response.prime_reconciliation_id)
					}else{
						$('#earning_info_form')[0].reset();
						toastr.error(response.message);
					}
				},
				dataType: 'json'
			});
		}
	});
	
	//SAVE DEDUCTION INFORMTION
	$("#deduct_info_form").submit(function(event){ event.preventDefault(); }).validate({
		rules:{
			display_deduct_name: "required",
			deduct_column: "required",
			deduct_order: "required"
		},
		submitHandler: function (form){	
			$("#add_deduct_info_btn").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
			$('#add_deduct_info_btn').attr('disabled','disabled');
			//Encrypted
			let formData           = new FormData(form);
			// Convert FormData to JSON object
			let jsonData           = Object.fromEntries(formData.entries());
			var encKey             = '<?php echo $encKey; ?>';
			var encData            = encrypt(encKey,jsonData);
			$.ajax({
				type: "POST",
				url: '<?php echo site_url($controller_name . "/save_deduct_info"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function (response){
					$('#add_deduct_info_btn').attr('disabled',false);
					$("#add_deduct_info_btn").html("Submit");
					if(response.success){
						toastr.success(response.message);
						$('#prime_deduct_id').val(0);
						$('#deduct_info_form')[0].reset();
						$('#deduct_info_form').collapse('hide');
						get_deduct_info(response.prime_reconciliation_id);
					}else{
						$('#deduct_info_form')[0].reset();
						toastr.error(response.message);
					}	
				},
				dataType: 'json'
			});
		}
	});
	
	$('#earning_column').on('change',function(){
		var earning_column = $('#earning_column option:selected').text();
		$('#display_name').val(earning_column);
	});
	
	$('#deduct_column').on('change',function(){
		var deduct_column = $('#deduct_column option:selected').text();
		$('#display_deduct_name').val(deduct_column);
	});
	
	$('#deduct_order').on('keyup',function(){
		var deduct_order                   = $('#deduct_order').val();
		var prime_deduct_reconciliation_id = $('#prime_deduct_reconciliation_id').val();
		if(prime_deduct_reconciliation_id){
			// Encryption
			var encKey  = '<?php echo $encKey; ?>';
			var data    = {prime_deduct_reconciliation_id:prime_deduct_reconciliation_id,deduct_order:deduct_order};
			var encData = encrypt(encKey,data);
			$.ajax({
				type: 'POST',
				url: '<?php echo site_url("detailed_reconciliation/check_deduct_order_num/"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function(response){
					var result = JSON.parse(response);
					if(result.success){
						$('#deduct_order').val(result.deduct_order);
					}else{
						toastr.error(result.message);
						$('#deduct_order').val(result.deduct_order);
					}
				},
			});
		}
		// else{
		// 	toastr.error("Please Fill privious Tab and try again");
		// }
	});
	
	$('#earning_order').on('keyup',function(){
		var earning_order                    = $('#earning_order').val();
		var prime_deduct_reconciliation_id   = $('#reconciliation_id').val();
		if(prime_deduct_reconciliation_id){
			// Encryption
			var encKey  = '<?php echo $encKey; ?>';
			var data    = {prime_deduct_reconciliation_id:prime_deduct_reconciliation_id,earning_order:earning_order};
			var encData = encrypt(encKey,data);
			$.ajax({
				type: 'POST',
				url: '<?php echo site_url("detailed_reconciliation/check_earning_order_num/"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function(response){
					var result = JSON.parse(response);
					if(result.success){
						$('#earning_order').val(result.earning_order);
					}else{
						toastr.error(result.message);
						$('#earning_order').val(result.earning_order);
					}
				},
			});
		}
		// else{
		// 	toastr.error("Please Fill privious Tab and try again");
		// }
	});
	
	$('#cancel_earning_info_btn').click(function(){
		$('#earning_info_form')[0].reset();
		$('#earning_info_form').collapse('hide');
	});
	
	$('#cancel_deduct_info_btn').click(function(){
		$('#deduct_info_form')[0].reset();
		$('#deduct_info_form').collapse('hide');
	});

	/* TABLE SORTABLE - START */
		default_sortable();
	/* TABLE SORTABLE - END */
});

//Select Call 
function select_call(){
	$(function () {
		$(".datepicker").datetimepicker({
			format: 'DD-MM-YYYY',
			//debug: true
		});
		$("#process_month").datetimepicker({
			format: 'MM-YYYY',
			//debug: true
		});
		$(".datepicker_time").datetimepicker({
			format: 'DD-MM-YYYY HH:mm:ss',
			//debug: true
		});
		$('.select2').select2({
			placeholder: '---- Select ----',
			allowClear: true,
			dropdownParent: $('.modal-dialog')
		});
		$('.select2-tags').select2({
			tags: true,
			tokenSeparators: [',']
		});
		$('textarea').on('keyup keypress', function(e) {
			if(e.keyCode === 13) {    
				e.stopPropagation();
			}else
			if(e.shiftKey){
				e.stopPropagation();
			}
		});
		$(".number").bind('keyup', function(e) {
			this.value = this.value.replace(/[^0-9_.]/g,'');
		});
		$('.alpha').bind('keypress', function (event) {
			var regex = new RegExp("^[a-zA-Z0-9\-_.@\/\\s]+$");
			var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
			if (!regex.test(key)) {
			   event.preventDefault();
			   return false;
			}
		});
	});
}

//EDIT EARNING REQUEST INFO
function edit_earning_info(prime_earning_id){
	if(prime_earning_id){
		// Encryption
		var encKey  = '<?php echo $encKey; ?>';
		var data    = {prime_earning_id:prime_earning_id};
		var encData = encrypt(encKey,data);
		$.ajax({
				type: "POST",
				url:'<?php echo site_url("detailed_reconciliation/edit_earning_info/");?>',
				data:encData,				
				contentType: 'text/plain',
				success: function(rslt){
					var result = JSON.parse(rslt);
					if(result.success){
						$('#earning_info_form')[0].reset();
						$('#earning_info_form').collapse('show');
						$('#reconciliation_id').val(result.earning_edit_info[0].prime_reconciliation_id);
						$('#prime_earning_id').val(result.earning_edit_info[0].prime_earning_id);
						$('#earning_column').val(result.earning_edit_info[0].earning_column);
						$('#display_name').val(result.earning_edit_info[0].display_name);
						$('#earning_order').val(result.earning_edit_info[0].earning_order);	
					}else{
						toastr.error(result.earning_edit_info);
					}					
				}
			});
	}
}

//DELETE EARNING INFORMTION
function delete_earning_info(prime_earning_id,prime_reconciliation_id){
	if(prime_earning_id){
		$.confirm({
			title: 'Confirm Delete!',
			content: 'Are you sure want to delete the column?',
			escapeKey: 'Yes',
			buttons: {
				Yes: function(){
					// Encryption
					var encKey  = '<?php echo $encKey; ?>';
					var data    = {prime_earning_id:prime_earning_id,prime_reconciliation_id:prime_reconciliation_id};
					var encData = encrypt(encKey,data);
					$.ajax({
						type: "POST",
						url:'<?php echo site_url("detailed_reconciliation/delete_earning_info/");?>',
						data:encData,				
						contentType: 'text/plain',
						success: function(rslt){
							var result = JSON.parse(rslt);
							if(result.success){
								toastr.success(result.earning_delete_info);
								$('#earning_info_form')[0].reset();
								$('#earning_info_form').collapse('hide');
								get_earning_info(prime_reconciliation_id)					
							}else{
								toastr.error(result.earning_delete_info);
							}					
						}
					});
				},
				No: function(){
					
				}
			}
		});
	}
}

//EDIT DEDUCTION REQUEST INFO
function edit_deduct_info(prime_deduct_id){
	if(prime_deduct_id){
		// Encryption
		var encKey  = '<?php echo $encKey; ?>';
		var data    = {prime_deduct_id:prime_deduct_id};
		var encData = encrypt(encKey,data);
		$.ajax({
			type: "POST",
			url:'<?php echo site_url("detailed_reconciliation/edit_deduct_info/");?>',
			data:encData,				
			contentType: 'text/plain',
			success: function(rslt){
				var result = JSON.parse(rslt);
				if(result.success){
					$('#deduct_info_form')[0].reset();
					$('#deduct_info_form').collapse('show');
					$('#prime_deduct_reconciliation_id').val(result.deduct_edit_info[0].prime_reconciliation_id);
					$('#prime_deduct_id').val(result.deduct_edit_info[0].prime_deduct_id);
					$('#deduct_column').val(result.deduct_edit_info[0].deduct_column);
					$('#display_deduct_name').val(result.deduct_edit_info[0].display_name);
					$('#deduct_order').val(result.deduct_edit_info[0].deduct_order);	
				}else{
					toastr.error(result.deduct_edit_info);
				}
			}
		});
	}
}


//DELETE DEDUCTION INFORMTION
function delete_deduct_info(prime_deduct_id,prime_reconciliation_id){
	if(prime_deduct_id){
		$.confirm({
			title: 'Confirm Delete!',
			content: 'Are you sure want to delete the column?',
			escapeKey: 'Yes',
			buttons: {
				Yes: function(){
						// Encryption
						var encKey  = '<?php echo $encKey; ?>';
						var data    = {prime_deduct_id:prime_deduct_id,prime_reconciliation_id:prime_reconciliation_id};
						var encData = encrypt(encKey,data);
						$.ajax({
								type: "POST",
								url:'<?php echo site_url("detailed_reconciliation/delete_deduct_info/");?>',
								data:encData,				
								contentType: 'text/plain',
								success: function(rslt){
									var result = JSON.parse(rslt);
									if(result.success){
										toastr.success(result.deduct_delete_info);
										$('#deduct_info_form')[0].reset();
										$('#deduct_info_form').collapse('hide');
										get_deduct_info(prime_reconciliation_id);					
									}else{
										toastr.error(result.deduct_delete_info);
									}					
								}
							});
					},
				  No: function(){
					
					}
				}
			});
	}
}

//GET EARNING INFORMATION LIST
function get_earning_info(prime_reconciliation_id){
	if(prime_reconciliation_id){
		// Encryption
		var encKey  = '<?php echo $encKey; ?>';
		var data    = {prime_reconciliation_id:prime_reconciliation_id};
		var encData = encrypt(encKey,data);
		$.ajax({
			type: "POST",
			url:'<?php echo site_url("detailed_reconciliation/get_earning_info_list_table/");?>',
			data:encData,				
			contentType: 'text/plain',
			success: function(rslt){
				var result = JSON.parse(rslt);
				if(result.success){
					$('#earning_table').html(result.earning_table);
					$table = $('.earn_table').DataTable({
						processing: true,
						lengthMenu: [[10,25,50,100,500,1000,-1],[10,25,50,100,500,1000,"All"]],
						scrollX: true,
						dom: 'Blfrtip',
						order:true,
						buttons: [
							{ extend: 'excelHtml5', footer: true },
						],
						language:{
							lengthMenu:"<span style='margin-top:12px;margin-left:10px;'>Display</span> _MENU_ <span 				style='margin-top:12px;'>Records</span>",
							searchPlaceholder: "Search records",
							search: "",
						},
					});
					$('input[type=search]').addClass('form-control input-sm');
					$("select[name='table_length']" ).addClass('form-control input-sm');
					$('.dt-button').addClass('btn btn-xs btn-edit');
					$('.btn-edit').removeClass('dt-button buttons-excel buttons-html5');
				}
			}
		});
	}
}

//GET DEDUCTION INFORMATION LIST
function get_deduct_info(prime_reconciliation_id){
	if(prime_reconciliation_id){
		// Encryption
		var encKey  = '<?php echo $encKey; ?>';
		var data    = {prime_reconciliation_id:prime_reconciliation_id};
		var encData = encrypt(encKey,data);
		$.ajax({
			type: "POST",
			url:'<?php echo site_url("detailed_reconciliation/get_deduct_info_list_table/");?>',
			data:encData,				
			contentType: 'text/plain',
			success: function(rslt){
				var result = JSON.parse(rslt);
				if(result.success){
					$('#deduction_table').html(result.deduct_table);
					$table = $('.ded_table').DataTable({
						processing: true,
						lengthMenu: [[10,25,50,100,500,1000,-1],[10,25,50,100,500,1000,"All"]],
						scrollX: true,
						dom: 'Blfrtip',
						order:true,
						buttons: [
							{ extend: 'excelHtml5', footer: true },
						],
						language:{
							lengthMenu:"<span style='margin-top:12px;margin-left:10px;'>Display</span> _MENU_ <span 				style='margin-top:12px;'>Records</span>",
							searchPlaceholder: "Search records",
							search: "",
						},
					});
					$('input[type=search]').addClass('form-control input-sm');
					$("select[name='table_length']" ).addClass('form-control input-sm');
					$('.dt-button').addClass('btn btn-xs btn-edit');
					$('.btn-edit').removeClass('dt-button buttons-excel buttons-html5');
				}
			}
		});
	}
}
function default_sortable(){
	var table_idsInOrder = [];
	$( ".default_table" ).sortable({
		update: function( event, ui ){
			table_idsInOrder = [];
			$('#deduction_info_table tr > th').each(function() {
				table_idsInOrder.push($(this).attr('id'));
			});
			if(table_idsInOrder){
				prime_earning_id = $("#prime_earning_id").val();
				// Encryption
				var encKey  = '<?php echo $encKey; ?>';
				var data    = {table_idsInOrder:table_idsInOrder,prime_earning_id:prime_earning_id};
				var encData = encrypt(encKey,data);
				$.ajax({
					type: "POST",
					url: '<?php echo site_url($controller_name . "/update_table_sortorder"); ?>',
					data:encData,				
					contentType: 'text/plain',
					success: function(data) {
						var rslt = JSON.parse(data);
						if(rslt.success){
							toastr.success(rslt.message);
						}
					},
				});
				get_table_view_data();
			}
		},connectWith: '.default_table'
	});
}
</script>
<style type="text/css">
	.dataTables_scrollHeadInner{
		width: 100% !important;
	}
</style>