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/application/views/house_rent_entry/manage.php
<?php 
	$this->load->view("partial/header"); 

	$access_data    = $this->session->userdata('access_data');
	$access_add     = (int)$access_data[$controller_name]['access_add'];
	$access_update  = (int)$access_data[$controller_name]['access_update'];
	$access_delete  = (int)$access_data[$controller_name]['access_delete'];
	$access_search  = (int)$access_data[$controller_name]['access_search']; 
	$access_export  = (int)$access_data[$controller_name]['access_export'];
	$access_import  = (int)$access_data[$controller_name]['access_import'];
	
	$page_name      = ucwords(str_replace("_"," ",$controller_name));
	$uniqueId       = "prime_".$controller_name."_id";
	$category       = $this->session->userdata('logged_role');
	$employee_code  = $this->session->userdata('logged_emp_code');
	$user_role      = $this->session->userdata('logged_user_role');
	$start_date     = $financial_info[0]->start_date;
	$end_date       = $financial_info[0]->end_date;
	
	$url = site_url("declartion_entry");
?>
<script type="text/javascript">
    $(document).ready(function (){
		$(function(){
			$(".datepicker").datetimepicker({
				format: 'MM-YYYY'
			});
		});
		$('#section_details').hide();
		/* //Date validation of change this updates
		$("#effective_month").datetimepicker({
			format: 'MM-YYYY',
			minDate: moment('<?php echo $start_date; ?>'),
			maxDate: moment('<?php echo $end_date; ?>')
		}); */
		
		$(function(){
			$('.select2').select2({
				placeholder: '---- Select ----',
			});
			$('.select2-tags').select2({
				tags: true,
				tokenSeparators: [',']
			});
		});

		var user_role    = '<?php echo $user_role; ?>';
		var category     = "";
        var emp_code     = ""; 
    	if(parseInt(user_role) !== 1 && parseInt(user_role) !== 4 && parseInt(user_role) !== 12){
			$('#category,#emp_code').attr('readonly','readonly');
			var category = '<?php echo $category; ?>';
	    	var emp_code = '<?php echo $employee_code; ?>';
		}

		if(parseInt(user_role) === 1 || parseInt(user_role) === 4 || parseInt(user_role) === 12){
			$('#emp_code_div').show();
			$('#category_div').show();
		}else{
			$('#emp_code_div').hide();
			$('#category_div').hide();
		}

		if(category){
			get_employee_list(category);
			$('#category').val(category);
			select_call();
		}
		$("#category").on('change', function(e){
			var category = $("#category").val();
			get_employee_list(category);						
		});
		
		$("#house_rent_form").validate({
			rules: {
				category         : "required",
				emp_code         : "required",
				effective_month  : "required",
			},
			submitHandler: function(form) {
				$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
				// $('#submit').attr('disabled','disabled');

				var effective_month = $('#effective_month').val();
				var category        = $('#category').val();
				var user_role    = '<?php echo $user_role; ?>';
				if((parseInt(user_role) === 1) || parseInt(user_role) === 4 || parseInt(user_role) === 12){
					var emp_code =  $("#emp_code").val();
				}else{
					var emp_code ='<?php echo $employee_code; ?>';
				}
				if(effective_month){
					//Encryption
					var key     = '<?php echo $key; ?>';
					var data    = {category:category,emp_code:emp_code,effective_month:effective_month};
					var encData = encrypt(key,data);
					$.ajax({
						type: "POST",
						url: '<?php echo site_url($controller_name . "/get_house_rent_list"); ?>',
						data:encData,				
						contentType: 'text/plain',
						dataType:'json',
						success: function (data) {
							if(data.status === "success"){
								$('#section_details').show();
								$('#section_details').html(data.table);
								$('#submit').show();
								$('#delete').show();
								$("#submit").html("View");
							}else{
								toastr.error(data.message);
								$("#submit").html("View");
							}
						},
					});
					$('#section_details').hide();
				}
			}
		});


		$(document).on("click","#save_data",function() {
			$("#save_data").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
			// $('#save_data').attr('disabled','disabled');

			var category        = $('#category').val();
			var month           = $("input[name='month[]']").map(function(){return $(this).val();}).get();
			var emp_code        = $('#emp_code').val();
			var effective_month = $('#effective_month').val();
			var metro           = $("input[name='metro[]']")
			.map(function(){return $(this).val();}).get();
			var non_metro       = $("input[name='non_metro[]']")
						.map(function(){return $(this).val();}).get();
			var metro_days      = $("input[name='metro_days[]']")
						.map(function(){return $(this).val();}).get();
			var non_metro_days  = $("input[name='non_metro_days[]']")
						.map(function(){return $(this).val();}).get();
			var metro_len          = $(metro).not(['0','0.00','']);
			var non_metro_len      = $(non_metro).not(['0','0.00','']);
			var metro_days_len     = $(metro_days).not(['0','0.00','']);
			var non_metro_days_len = $(non_metro_days).not(['0','0.00','']);
			// if(metro_len.length !== metro_days_len.length || non_metro_len.length !== non_metro_days_len.length){
			// 	toastr.warning('Metro or Non Metro Days Not Entered Correctly');
			// 	// $('#save_data').attr('disabled',false);
			// 	$("#save_data").html("Save");
			// 	return false;
			// }
			//Encryption
			var key     = '<?php echo $key; ?>';
			var data    = {month:month,category:category,emp_code:emp_code,effective_month:effective_month,metro:metro,non_metro:non_metro,metro_days:metro_days,non_metro_days:non_metro_days};
			var encData = encrypt(key,data);
			$.ajax({
				type: "POST",
				url: '<?php echo site_url($controller_name . "/save_house_rent"); ?>',
				data:encData,				
				contentType: 'text/plain',
				success: function (data) {
					var rslt = JSON.parse(data);
					if(rslt.success){
						toastr.success(rslt.message);
						// $('#save_data').attr('disabled',false);
						$("#save_data").html("Save");
						$('#section_details').hide();
					}else{
						toastr.error(rslt.message);
						$('#section_details').hide();
						// $('#save_data').attr('disabled',false);
						$("#save_data").html("Save");
					}
					//$("#declaration_form").trigger("reset");
					$(function(){
						$('.select2').select2({
							placeholder: '---- Select ----',
						});
						$('.select2-tags').select2({
							tags: true,
							tokenSeparators: [',']
						});
					});
				}
			});
		});		

		//function for delete
		// $(document).on("click","#delete",function() {
		// 	var effective_month = $('#effective_month').val();
		// 	var category        = $('#category').val();
		// 	var emp_code        = $('#emp_code').val();
		// 	if(confirm("Are you sure to delete?")){
		// 		if(emp_code){
		// 			$.ajax({
		// 				type: "POST",
		// 				url: '<?php echo site_url($controller_name . "/delete_section"); ?>',
		// 				data:{category:category,emp_code:emp_code,effective_month:effective_month},
		// 				success: function (data) {
		// 					var rslt = JSON.parse(data);
		// 					toastr.success(rslt.message);
		// 					location.reload(true);
		// 				}
		// 			});
		// 		}
		// 	}
		// });
    });
function get_employee_list(category){
	if(category){
		//Encryption
		var key     = '<?php echo $key; ?>';
		var data    = {category:category};
		var encData = encrypt(key,data);
		$.ajax({
			type: "POST",
			url: '<?php echo site_url($controller_name . "/get_employee_list"); ?>',
			data:encData,				
			contentType: 'text/plain',
			success: function(data){
				var user_role    = '<?php echo $user_role; ?>';
				if(parseInt(user_role) === 1  || parseInt(user_role) === 4 || parseInt(user_role) === 12){
					$('#emp_code').html(data);
				}else{
					$('#emp_code').val("");
				}
				var emp_code = '<?php echo $employee_code; ?>';
				if(emp_code){
					$('#emp_code').val(emp_code);
					select_call();
				}
			},
		});
	}
}
function get_nonmetro_days(val,month_day,month){	
	//Encryption
	var key     = '<?php echo $key; ?>';
	var data    = {val:val,month_day:month_day};
	var encData = encrypt(key,data);
	$.ajax({
		type: "POST",
		url: '<?php echo site_url($controller_name . "/get_days"); ?>',
		data:encData,				
		contentType: 'text/plain',
		success: function (data) {
			$('#non_metro_days_'+month).val(data);
		}
	});
}
function get_metro_days(val,month_day,month){
	//Encryption
	var key     = '<?php echo $key; ?>';
	var data    = {val:val,month_day:month_day};
	var encData = encrypt(key,data);
	$.ajax({
		type: "POST",
		url: '<?php echo site_url($controller_name . "/get_days"); ?>',
		data:encData,				
		contentType: 'text/plain',
		success: function (data) {
			$('#metro_days_'+month).val(data);
		}
	});
}
function select_call(){
	$(function(){
		$('.select2').select2({
			placeholder: '---- Select ----',
		});
		$('.select2-tags').select2({
			tags: true,
			tokenSeparators: [',']
		});
	});
}
</script>
<div class='row title_content'>
	<div class='col-md-2 col-xs-4'>
		<h1 class='page_txt'><?php echo $page_name;?></h1>
	</div>

	<ul class="declaration_entry"><div class="floatright"><li>
		<a href='<?php echo $url ?>' class='btn btn-xs btn-primary'>Back to Declaration Entry
		</a></li></div>
	</ul>
	<div class='col-md-10 col-xs-8'>			
	</div>
</div>

<div id="holder" class="form-inline" style="margin-top:20px;">

	<div class="row" style='margin-bottom:0px;'>
		<div class="col-md-12">
			<form id='house_rent_form'>
			<div class="form-group"  style="display:none;" id="category_div">
				<?php
					echo form_label('Category', 'category', array('class' => 'required'));
					echo form_dropdown(array( 'name' => 'category', 'id' => 'category', 'class' => 'form-control input-sm select2'), $category_list);
				?>
			</div>
			<div class="form-group" style="display:none;" id="emp_code_div">
				<?php
					echo form_label('Employee Code', 'emp_code', array('class' => 'required'));
					echo form_dropdown(array( 'name' => 'emp_code', 'id' => 'emp_code', 'class' => 'form-control input-sm select2'));
				?>
			</div>
			<div class="form-group">
				<?php
					echo form_label('Effective Month', 'effective_month', array('class' => 'required'));
					echo form_input(array('name' => 'effective_month', 'id' => 'effective_month', 'class' => 'form-control input-sm datepicker',  'value'=> '')); 
				?>
			</div>
			<div class="form-group">
				<button class='btn btn-primary btn-sm' id="submit">View</button>
				<!-- <button class='btn btn-primary btn-sm' id="submit">Save</button> -->
				<!-- <a class='btn btn-danger btn-sm' id="delete">Delete</a> -->
			</div>
			<div id="section_details" style="margin:20px !important; padding:15px;background-color: #f2f2f2;"></div>
			</form>
		</div>
	</div>
</div>
<style>
	.pull-right.search {
		display: none !important;
	}
	.columns.columns-right.btn-group.pull-right {
		display: none !important;
	}
	.declaration_entry {
		list-style: none;
	    padding: 1em 0;
	}
	.floatright {
		float:right;
		display: inline;
	    padding: 0 1.5em;
	}
	<?php 
		if($access_search === 1){
			echo ".pull-right.search { display: block !important; }";
		}
		if($access_export === 1){
			echo ".columns.columns-right.btn-group.pull-right{display: block !important;}";
		}
	?>
</style>
<?php $this->load->view("partial/footer"); ?>