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_cafsindia_com/application/views/loan/installment.php
<?php
//Monthly Installment Details
$tr_line = "";
$i = 1;
foreach($install_result as $loan){
	$installment_id        = $loan->prime_loan_installment_id;
	$loan_id               = $loan->loan_id;
	$category              = $loan->category;
	$emp_code              = $loan->emp_code;
	$loan_type             = $loan->loan_type;
	$loan_date             = $loan->loan_date;
	$apply_year            = $loan->apply_year;
	$loan_amount           = $loan->loan_amount;
	$interest_rate         = $loan->interest_rate;
	$number_of_installment = $loan->number_of_installment;
	$per_month             = $loan->per_month;
	$total_amount          = $loan->total_amount;
	$installment_count     = $loan->installment_count;
	$install_amount        = $loan->install_amount;
	$install_year          = $loan->install_year;
	$paid_status           = $loan->paid_status;
	$install_month         = $loan->install_month;
	
	$curr_year = $payroll_month;
	if ($curr_year === $install_year && (int)$paid_status !== 1) {
		$read = '';
		$btn  = "<button class='btn btn-sm btn-info' onclick=update_data('$installment_id','$loan_id','$loan_amount','$per_month','$installment_count','$number_of_installment','$install_year','$loan_type')>update</button>";
	}else{
		$read = 'readonly';
		$btn  = ' ';		
	}
	if((int)$paid_status === 1){
		$paid_status = 'Paid';
	}else{
		$paid_status = 'Not Paid';
	}
	
	$tr_line  .= "<tr id='install_row_$installment_id'>
					<td>$install_year</td>
					<td><input class='numbersOnly' type='text' name='install_amount' id='install_amount_$installment_id' value='$install_amount' $read/></td>
					<td>$paid_status</td>
					<td>$btn</td>
				</tr>";
	}
	
	$last_install_year = date("Y-m-d",strtotime("01-".$install_year));
	$next_installment = date('m-Y', strtotime('+1 month', strtotime($last_install_year)));
	
echo "<div style='padding:15px;'>
		<div id='installment'>
			<table id='installment_data' class='table table-bordered col-style' style='padding:10px;'>
				<thead>
					<tr>
						<th>Installment Month and Year</th>
						<th>Monthly Amount Deduct</th>
						<th>Paid Status</th>
						<th>Option<th/>
					</tr>
				</thead>
				<tbody>$tr_line</tbody>
			</table>
		</div>
	</div>";
?>

<script type="text/javascript">
$(document).ready(function(){
	jQuery('.numbersOnly').keyup(function () { 
		this.value = this.value.replace(/[^0-9\.]/g,'');
	});
	
});

function update_data(installment_id,loan_id,loan_amount,per_month,installment_count,installments,install_year,loan_type){
	var install_amount  = $('#install_amount_'+installment_id).val();
	if(installment_id){
		$.ajax({
			type: 'POST',
			url: '<?php echo site_url("$this->control_name/update_data");?>',
			data:{loan_id:loan_id,installment_id:installment_id,install_amount:install_amount,loan_amount:loan_amount,per_month:per_month,installment_count:installment_count,installments:installments,install_year:install_year,loan_type:loan_type},
			success: function(data){
				var rslt = JSON.parse(data);
				if(rslt.success){
					toastr.success(rslt.message);
					/*$("input[name^='install_amount']").prop("readonly", true);
					$(".check").attr("disabled", true);
					$(".close").attr("disabled", true);
					$("#close").attr("disabled", true);*/
					$('.modal').modal('toggle');
					$('#notify_list_model').modal('hide');
				}else{
					toastr.error(rslt.message);
				}				

				//bal_amt_cal();
			}
		});
	}
}


	/*var install_amount  = $('#install_amount_'+installment_id).val();
	var total_amount    = '<?php echo $total_amount; ?>';
	var pay_amt = $("input[name^='install_amount']").map(function (idx, ele) {
		return $(ele).val();
	}).get();
	
	var pay_total = 0;
	for (var i = 0; i < pay_amt.length; i++) {
		pay_total += pay_amt[i] << 0;
	}
	
	if (install_amount.length === 0) {
		toastr.error("Please enter amount?");
		return false;
	}
	
	//if(parseInt(pay_total) < parseInt(total_amount)){
		$.ajax({
			type: 'POST',
			url: '<?php //echo site_url("$this->control_name/edit_data");?>',
			data:{installment_id:installment_id,install_amount:install_amount},
			success: function(data){
				var rslt = JSON.parse(data);
				if(rslt.success){
					toastr.success(rslt.message);
					$("input[name^='install_amount']").prop("readonly", true);
					$(".check").attr("disabled", true);
					$(".close").attr("disabled", true);
					$("#close").attr("disabled", true);
				}else{
					toastr.error(rslt.message);
				}
				bal_amt_cal();
			}
		});
	/*}else{
		alert("Your enter amount is more than total loan amount?");
	}
}*/

/*
function bal_amt_cal(){
	var loan_id                 = '<?php echo $loan_id; ?>';
	var total_amount            = '<?php echo $total_amount; ?>';
	var install_amount          = '<?php echo $install_amount; ?>';
	var installment_id          = '<?php echo $installment_id; ?>';
	var next_installment        = '<?php echo $next_installment; ?>';
	var pay_amt = $("input[name^='install_amount']").map(function (idx, ele) {
		return $(ele).val();
	}).get();
	
	var pay_total = 0;
	for (var i = 0; i < pay_amt.length; i++) {
		pay_total += pay_amt[i] << 0;
	}
	rslt_amt =  parseInt(total_amount) - parseInt(pay_total);
	last_amt =  parseInt(install_amount) + parseInt(rslt_amt);	
	
	if(rslt_amt > 0){
		tr = "<tr><td>"+next_installment+"</td><td>"+rslt_amt+"</td><td ><button id='save' class='btn btn-xs btn-primary' onclick=add_install("+loan_id+",'"+next_installment+"',"+rslt_amt+");> <i class='fa fa-file-o' aria-hidden='true'></i>  Save</button></td><td><button id='cancel' class='btn btn-xs btn-danger' onclick=add_prev("+installment_id+","+last_amt+");> <i class='fa fa-file-o' aria-hidden='true'></i>  Cancel</button></td></tr>";
		$("#installment_data").append(tr);
	}
}

function add_install(loan_id,next_installment,rslt_amt){
	if(loan_id){
		$.ajax({
			type: 'POST',
			url: '<?php //echo site_url("$this->control_name/add_install");?>',
			data:{loan_id:loan_id,next_installment:next_installment,rslt_amt:rslt_amt},
			success: function(data){
				var rslt = JSON.parse(data);
				if(rslt.success){
					toastr.success(rslt.message);			
				}else{
					toastr.error(rslt.message);
				}
				$('.modal').modal('toggle');
			}
		});
	}
}

function add_prev(installment_id,last_amt){
	if(installment_id){
		$.ajax({
			type: 'POST',
			url: '<?php echo site_url("$this->control_name/add_prev");?>',
			data:{installment_id:installment_id,last_amt:last_amt},
			success: function(data){
				var rslt = JSON.parse(data);
				if(rslt.success){
					toastr.success(rslt.msg);			
				}else{
					toastr.error(rslt.msg);
				}
				$('.modal').modal('toggle');
			}
		});
	}
}*/
</script>