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/controllers/Hr_overtime_entry.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Hr_overtime_entry  extends Action_controller{	
	public function __construct(){
		parent::__construct('hr_overtime_entry');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		$data['encKey']        = $this->generateKey();
		$this->page_info();
		$data['module_sts']    = (int)$this->module_sts;
		$data['quick_link']    = $this->quick_link;
		$data['pick_list']     = $this->pick_list;
		$data['form_info']     = $this->form_info;
		$data['table_head']    = $this->table_head;
		$data['fliter_list']   = $this->fliter_list;
		$data['freeze_list']   = $this->freeze_list;

		$role_info             = $this->db->query("CALL sp_a_run ('SELECT','SELECT * FROM `cw_category` where trans_status = 1 and prime_category_id != 1')");
        $role_result           = $role_info->result();
        $role_info->next_result();
        $category_list[""] = "---- Select Category ----";
        foreach ($role_result as $for) {
            $role_id                 = $for->prime_category_id;
            $category_name           = $for->category_name;
            $category_list[$role_id] = $category_name;
        }
        $data['category_list']       = $category_list; 

	 	//TIME OFFICE FINANCIAL YEAR GET FUNCTION
		$financial_info              = $this->get_leave_financial_details();
		$prime_financial_id          = $financial_info[0]->prime_leave_financial_year_id;	
		$fin_start_date              = date("Y-m-d",strtotime($financial_info[0]->starting_date));	
		$fin_end_date                = date("Y-m-d",strtotime($financial_info[0]->ending_date));

	    /*APPROVAL STATUS 2 VIEW OPTION BY ANDREWS*/
	   /* $approval_type_qry         = 'SELECT prime_time_entry_id,approval_type FROM cw_time_entry WHERE cw_time_entry.trans_status = 1 and cw_time_entry.att_date >= "'.$fin_start_date.'" and cw_time_entry.att_date <= "'.$fin_end_date.'"';
		$approval_type_info          = $this->db->query("CALL sp_a_run ('SELECT','$approval_type_qry')");
		$approval_type_rslt          = $approval_type_info->result_array();
		$approval_type_info->next_result();

		$approval_type_arr           = array();
		foreach($approval_type_rslt as $arr){
			$approval_type_arr[$arr['prime_time_entry_id']]  = $arr['approval_type'];
		}
		$data['approval_type_arr']  = $approval_type_arr;*/

		$this->load->view("$this->control_name/manage",$data);
	}
	
	//LOAD TABEL WITH FILTERS
	public function search(){
		$dec_data         = $this->cryptoDecrypt($_POST['Payload']);
		$_POST            = $dec_data['data'];
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..'));
			exit(0);
		}	
		$this->search_info();
		$module_sts       = (int)$this->module_sts;
		if(!$module_sts){
			echo json_encode(array('success' => FALSE, 'message' => "Search  Info Query Process Error..!"));
			exit(0);
		}else{
			// add role based condition 
			$process_month = $this->input->post('process_month');
			$draw          = $this->input->post('draw');
			$start         = $this->input->post('start');
			$per_page      = $this->input->post('length');
			$order         = $this->input->post('order');
			$order_col     = $this->input->post('columns');
			$search        = $this->input->post('search');
			$column        = $order[0]['column'];
			$order_sor     = $order[0]['dir'];
			$order_col     = $order_col[$column]['data'];
			$search        = trim($search['value']);

			//ADDED BASIC,FILTER,COMMON QUERY HERE 
			$role_condition   = "";
			if($this->role_condition){
				$role_condition = $this->role_condition;
			}
			
			//CURRENT FINANCIAL YEAR ID
			$leave_financial_info = $this->get_leave_financial_details();
			$prime_financial_id   = $leave_financial_info[0]->prime_leave_financial_year_id;

			//filter list
			$fliter_query = "";
			foreach($this->fliter_list as $fliter){
				$label_id         = $fliter->label_name;
				$field_isdefault  = (int)$fliter->field_isdefault;
				$field_type       = (int)$fliter->field_type;
				$prime_form_id 	  = $fliter->prime_form_id;

				if($field_isdefault === 1){
					$search_val  = $this->input->post("$label_id");
					if($label_id === 'approved_over_time'){
						$label_id = 'approved_ot_mins';
					}
					//CATEGORY AND DEPARTMENT COLUMN SHOULD CHANGE
					$column_name = "cw_time_entry.$label_id";	
					if($column_name === "cw_time_entry.category"){
						$column_name ="cw_employees.role";
					}else if($column_name === "cw_time_entry.department"){
						$column_name ="cw_employees.department";
					}	
					if($search_val){
						if($field_type === 4){
							$search_val    = date('Y-m-d',strtotime($search_val));
							$fliter_query .= ' and '.$column_name.' = "'.$search_val.'"';
						}else
						if(($field_type === 5) || ($field_type === 7)){
							$search_val    = trim(implode('","',$search_val ?? []));
							$fliter_query .= ' and '.$column_name.' in ("'.$search_val.'")';  
						}else
						if($field_type === 9){
							$search_id     = 'filter_'.$label_id.'_hidden_'.$prime_form_id;
							$search_val    = $this->input->post("$search_id");
							$fliter_query .= ' and '.$column_name.' in ("'.$search_val.'")';  
						}else
						if($field_type === 13){
							$search_val    = date('Y-m-d H:i:s',strtotime($search_val));
							$fliter_query .= ' and '.$column_name.' = "'.$search_val.'"';
						}else{
							$fliter_query .= ' and '.$column_name.' LIKE "'.$search_val.'%"';
						}
					}
				}
			}

			/* COMMON SEARCH */ 
			$common_search = "";
			if($search){
				foreach($this->form_info as $setting){
					$prime_form_id   = $setting->prime_form_id;
					$field_type      = (int)$setting->field_type;
					$pick_list       = $setting->pick_list;
					$pick_table      = $setting->pick_table;
					$pick_list_type  = $setting->pick_list_type;
					$input_view_type = (int)$setting->input_view_type;
					$auto_prime_id      = $setting->auto_prime_id;
					$auto_dispaly_value = $setting->auto_dispaly_value;
					$label_id        = strtolower(str_replace(" ","_",$setting->label_name));
					if($label_id === 'approved_over_time'){
						$label_id = 'approved_ot_mins';
					}
					$field_isdefault    = (int)$setting->field_isdefault;
					if($field_isdefault === 1){
						if(($input_view_type === 1) || ($input_view_type === 2)){
							$search_label = "cw_time_entry.$label_id";
							if($search_label === "cw_time_entry.category"){
								$search_label ="cw_employees.role";
							}else if($search_label === "cw_time_entry.department"){
								$search_label ="cw_employees.department";
							}
							$search_val   = "";
							if($field_type === 4){ // having issues in date search
								if(strtotime($search)){
									$search_val = date('Y-m-d',strtotime($search));
									$common_search .= ' or '. $search_label .' like "%'.$search_val.'%"';
								}
							}else
							if(($field_type === 5) || ($field_type === 7) || ($field_type === 9)){
								$result = array_filter($this->pick_list[$label_id]['array_list'] ?? [] ?? [], function ($item) use ($search) {
									if (stripos($item, $search) !== false) {
										return true;
									}
									return false;
								});
								if($result){
									$pick_key = implode('", "', array_keys($result ?? []) ?? []);
									$common_search .= ' or '. $search_label .' in("'.$pick_key.'")';
								}
							}else{
								$common_search .= ' or '. $search_label .' like "%'.$search.'%"';
							}
						}
					}
				}
				if($common_search){
					$common_search = ltrim($common_search,' or ');
					$common_search = " and ($common_search)";
					$common_search = str_replace("(,","(",$common_search);
					$common_search = str_replace("()","(0)",$common_search);
				}
			}
			if($process_month){
				//get Process from date and to date.
				$salary_date_arr   = $this->tos_sal_strt_end_info("4",$process_month); // 4 => Posting Entry
				$salary_start_date =  date("Y-m-d",strtotime($salary_date_arr['salary_start_date']));
				$salary_end_date   =  date("Y-m-d",strtotime($salary_date_arr['salary_end_date']));
			}

			$count_all_query    = 'SELECT COUNT(*) as allcount from cw_time_entry inner join cw_employees on cw_employees.employee_code = cw_time_entry.employee_code  inner join cw_department on cw_employees.department = cw_department.prime_department_id inner join cw_day_status_legends on cw_day_status_legends.legends = cw_time_entry.whole_day_status inner join cw_approval_leave_status on cw_approval_leave_status.prime_approval_leave_status_id = cw_time_entry.approval_type inner join cw_shift_master on cw_shift_master.prime_shift_master_id = cw_time_entry.shift_id where cw_time_entry.trans_status = 1 and cw_time_entry.approval_type = 1 and cw_time_entry.att_date >= "'.$salary_start_date.'" and cw_time_entry.att_date <= "'.$salary_end_date.'" and cw_time_entry.total_excess_hours > 0 '.$common_search .$fliter_query .$role_condition;		
			$search_total       = $this->db->query($count_all_query);
			$search_total_info  = $search_total->result();
			$total_count        = $search_total_info[0]->allcount;

			$search_query = 'SELECT cw_time_entry.employee_code,prime_time_entry_id,att_date,if(cw_time_entry.total_excess_hours > 0,time_format(concat(floor(cw_time_entry.total_excess_hours /60),":",lpad(mod(cw_time_entry.total_excess_hours,60),2,"0")),"%H:%i"),cw_time_entry.total_excess_hours) as total_excess_hours,if(cw_time_entry.final_total_work_hours > 0,time_format(concat(floor(cw_time_entry.final_total_work_hours /60),":",lpad(mod(cw_time_entry.final_total_work_hours,60),2,"0")),"%H:%i"),cw_time_entry.final_total_work_hours) as total_work_hours,cw_shift_master.shift_name as shift_id,cw_time_entry.punch_in,cw_time_entry.punch_out,approved_ot_mins as approved_over_time,cw_action_status.action_status as approval_type,cw_employees.role as category,cw_department.department,cw_day_status_legends.legends as whole_day_status from cw_time_entry inner join cw_employees on cw_employees.employee_code = cw_time_entry.employee_code  inner join cw_department on cw_employees.department = cw_department.prime_department_id inner join cw_day_status_legends on cw_day_status_legends.legends = cw_time_entry.whole_day_status inner join cw_action_status on cw_action_status.prime_action_status_id = cw_time_entry.approval_type inner join cw_shift_master on cw_shift_master.prime_shift_master_id = cw_time_entry.shift_id where cw_time_entry.trans_status = 1 and cw_time_entry.att_date >= "'.$salary_start_date.'" and cw_time_entry.att_date <= "'.$salary_end_date.'" and cw_time_entry.total_excess_hours > 0 and cw_time_entry.approved_ot_mins = 0 and cw_time_entry.approval_type in (1,5) '.$common_search .$fliter_query .$role_condition;	
			$search_query      .= " ORDER BY  $order_col $order_sor ";
			if((int)$per_page !== -1){
				$search_query  .= " LIMIT  $start,$per_page";
			} 
			// echo $search_query; die;
			$search_data        = $this->db->query($search_query);
			$search_result      = $search_data->result();
			$search_count       = count($search_result ?? []);
			$filtered_count     = $total_count;
			if($search_count < $per_page){
				$filtered_count = $search_count;
			}
			echo json_encode(array("draw" => intval($draw),"recordsTotal" => $total_count,"recordsFiltered" => $filtered_count,"data" => $search_result));	
		}	
	}
	
	//LOAD MODEL PAGE VIEW WITH DATA
	public function view($form_view_id=-1){
		$data['primeId']     = $form_view_id;
		if($form_view_id !== -1){
			//Decrypt prime id from URL
			$decRslt          = $this->cryptoDecrypt(base64_decode(urldecode($form_view_id)));
			$form_view_id     = $decRslt['prime_id'];
			if(!$form_view_id){
				echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
				exit(0);
			}
		}
		//VIEW INFO FUNCTION
		$this->view_info($form_view_id);
		$data['encKey']                 = $this->generateKey();
		$data['module_sts']             = (int)$this->module_sts;
		//VIEW, FORM INPUT
		$data['view_info']              = $this->view_info;
		$data['form_info']              = $this->form_info;
		$data['formula_result']         = $this->formula_result;//for label color change
		$data['role_based_condition']   = $this->role_based_condition;//for label name readonly options
		$data['all_pick']               = $this->pick_list;//all pick result

		//DEPENDENT AUTO PICKLIST
		$data['auto_pick']              = $this->depen_auto_list;//dependent auto result			
		$data['condition_list']         = $this->form_condition_list;

		$view_query  ='SELECT *,cw_employees.department,cw_employees.role as category,prime_time_entry_id,att_date,if(cw_time_entry.total_excess_hours > 0,time_format(concat(floor(cw_time_entry.total_excess_hours /60),":",lpad(mod(cw_time_entry.total_excess_hours,60),2,"0")),"%H:%i"),cw_time_entry.total_excess_hours) as total_excess_hours,if(cw_time_entry.final_total_work_hours > 0,time_format(concat(floor(cw_time_entry.final_total_work_hours /60),":",lpad(mod(cw_time_entry.final_total_work_hours,60),2,"0")),"%H:%i"),cw_time_entry.final_total_work_hours) as total_work_hours,if(cw_time_entry.approved_ot_mins > 0,time_format(concat(floor(cw_time_entry.approved_ot_mins /60),":",lpad(mod(cw_time_entry.approved_ot_mins,60),2,"0")),"%H:%i"),cw_time_entry.approved_ot_mins) as approved_over_time,cw_time_entry.approval_type from cw_time_entry inner join cw_employees on cw_employees.employee_code = cw_time_entry.employee_code  inner join cw_department on cw_employees.department = cw_department.prime_department_id where cw_time_entry.prime_time_entry_id = "'.$form_view_id.'"and cw_time_entry.trans_status = 1 and cw_time_entry.approval_type = 1';
		$view_data   = $this->db->query("CALL sp_a_run ('SELECT','$view_query')");
		$view_result = $view_data->result();
		$view_data->next_result();
		$data['form_view']   = $view_result[0];	
		
		$view_qry    = 'select * from cw_form_view_setting where  prime_view_module_id = "'.$this->control_name.'" and  form_view_type = "3" and trans_status = 1';
		$view_data   = $this->db->query("CALL sp_a_run ('SELECT','$view_qry')");
		$view_result = $view_data->result();
		$view_data->next_result();
		$row_view_list = array();
		foreach($view_result as $view){
			$prime_form_view_id   = $view->prime_form_view_id;
			$row_set_data = $this->get_row_set_data($prime_form_view_id,$form_view_id);
			$row_view_list[$prime_form_view_id] = $row_set_data;
		}
		$data['row_view_list']   = $row_view_list;
		//FOR DEPENDENT
		$data['get_depend_prime_id']   = $this->get_depend_fun();
		$data['depend_label_id']   	   = $this->depend_label_fun();	

		$this->load->view("$this->control_name/form",$data);
	}
	
	//SAVE MODEL DATA TO DATA BASE
	public function save(){
		//Encryption
		$encString      = file_get_contents('php://input');
		$_POST          = $this->cryptoDecrypt($encString);
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
			exit(0);
		}
		//SAVE INFO FUNCTION
		$this->save_info();	
		$module_sts          = (int)$this->module_sts;
		if(!$module_sts){
			echo json_encode(array('success' => FALSE, 'message' => "Save Info Query Process Error...!"));
			exit(0);
		}else{
			$financial_info      = $this->get_leave_financial_details();
			$prime_financial_id  = $financial_info[0]->prime_leave_financial_year_id;	
			$att_date            = $this->input->post('att_date');	
			$category            = $this->input->post('category');
			$shift_id            = $this->input->post('shift_id');
			$in_time             = date("H:i",strtotime($this->input->post('punch_in')));
			$out_time            = date("H:i",strtotime($this->input->post('punch_out')));
			$prime_time_entry_id = $this->input->post("prime_time_entry_id");
			if($prime_time_entry_id !== '-1'){ //Decryption
				$decRslt     = $this->cryptoDecrypt(base64_decode(urldecode($prime_time_entry_id)));
				$prime_time_entry_id     = (int)$decRslt['prime_id'];
				if(!$prime_time_entry_id){
					echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
					exit(0);
				}
			}else{
				$prime_time_entry_id = 0;
			}
			$rejected_reason     = $this->input->post("rejected_reason");
			$approval_type       = $this->input->post("approval_type");
			$total_work_hours    = $this->input->post("total_work_hours");
			$approved_over_time  = $this->input->post("approved_over_time");
			$total_excess_hours  = $this->input->post("total_excess_hours");
			$employee_code       = $this->input->post("employee_code");
			$ot_type             = $this->input->post("ot_type");
			$total_min           = $this->hourstomins($approved_over_time); 
			$created_on          = date("Y-m-d H:i:s");
			if($total_excess_hours < $approved_over_time){
				echo json_encode(array('success' => FALSE, 'message' => 'Approved Overtime Should Be Equal Or Less Than Overtime Worked!!'));
				exit(0);
			}
			if($approved_over_time === "00:00" && (int)$approval_type === 2){
				echo json_encode(array('success' => FALSE, 'message' => 'Approved Overtime Should not be Zero!!'));
				exit(0);
			}
			//Get Month Days start and end date
			$month_day_qry     = 'select day_conditions,day_count,day_start,day_end from cw_tos_month_day where cw_tos_month_day.trans_status = 1 and entry_parameter = 4';	
			$month_day_data    = $this->db->query("CALL sp_a_run ('SELECT','$month_day_qry')");
			$month_day_result  = $month_day_data->result();
			$month_day_data->next_result();

			if($month_day_result){
				$day_conditions = $month_day_result[0]->day_conditions;
				$day_count      = $month_day_result[0]->day_count;
				$day_start      = $month_day_result[0]->day_start;
				$day_end        = $month_day_result[0]->day_end;

				if((int)$day_conditions === 3){
					if(date('d',strtotime($att_date))  >  $day_end){
						$end_month = date("Y-m-".$day_end,strtotime("+1 month", strtotime($att_date)));
					}else{
						$end_month  = date("Y-m-".$day_end, strtotime($att_date));
					}				
				}else{
					$sal_start  = '01';
					if((int)$day_conditions === 2){
						$day_end = date("t");
					}
					$end_month  = date("Y-m-".$day_end,strtotime($att_date));
				}
			}
			$process_month  = date("m-Y",strtotime($end_month));

			$exist_posting_lock_cateory_qry = 'SELECT count(*) as exist_count from cw_payroll_posting_lock where trans_status = 1 and category = "'.$category.'" and posting_month = "'.$process_month.'"';  
			$exist_posting_lock_cateory_info = $this->db->query("CALL sp_a_run ('SELECT','$exist_posting_lock_cateory_qry')");
			$exist_posting_lock_cateory_rslt = $exist_posting_lock_cateory_info->result();
			$exist_posting_lock_cateory_info->next_result();
			$exist_count = (int)$exist_posting_lock_cateory_rslt[0]->exist_count;
			if($exist_count > 0){
				echo json_encode(array('success' => false, 'message' => "Payroll Lock for this Month!"));
				exit(0);
			}
			if($this->config->item("db_name") !== 'rebar_hrms_db'){
				$exist_emp_payroll_process_qry = 'SELECT count(*) as exist_payroll_count from cw_transactions where trans_status = 1 and employee_code = "'.$employee_code.'" and transactions_month  = "'.$process_month.'" ';
				$exist_emp_payroll_process_info = $this->db->query("CALL sp_a_run ('SELECT','$exist_emp_payroll_process_qry')");
				$exist_emp_payroll_process_result = $exist_emp_payroll_process_info->result();
				$exist_emp_payroll_process_info->next_result();
				$exist_payroll_count = (int)$exist_emp_payroll_process_result[0]->exist_payroll_count;			
				if($exist_payroll_count > 0){ // Commented for rebar
					echo json_encode(array('success' => false, 'message' => "Payroll Already Processed for this Month!"));
					exit(0);
				}
			}
			$att_date_convert = date("Y-m-d",strtotime($att_date));
			//CHECK EXIST COUNT IN OVERTIME ENTRY TABLE
			$check_ot_exist_qry    = 'select count(prime_overtime_entry_id) as count from cw_overtime_entry where cw_overtime_entry.employee_code = "'.$employee_code.'" and approval_status in (1,2) and cw_overtime_entry.entry_date  = "'.$att_date_convert.'" and cw_overtime_entry.trans_status = 1';
			$check_ot_exist_info   = $this->db->query("CALL sp_a_run ('SELECT','$check_ot_exist_qry')");
			$check_ot_exist_rslt   = $check_ot_exist_info->result();
			$check_ot_exist_info->next_result();
			$ot_exist_count        = (int)$check_ot_exist_rslt[0]->count;
			if($ot_exist_count > 0){
				echo json_encode(array('success' => FALSE, 'message' => "This Request Already Exist in Overtime Entry.. Please Check it.!"));
				exit(0);
			}

			//OT ENTRY INSERT QUERY
			$overtime_ins_qry  = 'INSERT INTO cw_overtime_entry (financial_setting_id,category,employee_code,shift_name,entry_date,in_time,out_time,ot_in_time,ot_out_time,excess_work,over_time,approval_status,ot_type,hr_overtime,trans_created_by,trans_created_date) values ("'.$prime_financial_id.'","'.$category.'","'.$employee_code.'","'.$shift_id.'","'.$att_date_convert.'","'.$in_time.'","'.$out_time.'","'.$in_time.'","'.$out_time.'","'.$total_excess_hours.'","'.$approved_over_time.'","'.$approval_type.'","'.$ot_type.'","1","'.$this->logged_id.'","'.$created_on.'")';
			$overtime_ins_info = $this->db->query("CALL sp_a_run ('INSERT','$overtime_ins_qry')");
			$overtime_ins_rslt = $overtime_ins_info->result();
			$overtime_ins_info->next_result();

			/*this code add by andrews start*/ 
			$form_id             = (int)$this->input->post($this->prime_id);

			//Check Coff Settings Based Validations
			if((int)$ot_type === 4 && (int)$approval_type === 2){
				$this->compoff_validation($employee_code,$category,$approved_over_time,$ot_type);
				$this->coff_update($employee_code,$prime_financial_id,$created_on,$category,$approved_over_time,$approval_type,$att_date,$form_id);
			}

			if((int)$approval_type === 2){ //Approved
				$approval_type = 3;
			}else
			if((int)$approval_type === 3){ //Rejected
				$approval_type = 4;
				$total_min = 0;
			}			
			/*this code add by andrews end*/
			//Time entry update query
			$prime_upd_query    .= 'approval_type = "'.$approval_type.'",approved_ot_mins = "'.$total_min.'",rejected_reason = "'.$rejected_reason.'", trans_updated_by = "'. $this->logged_id .'",trans_updated_date = "'.$created_on.'"';		
			$prime_update_query  = 'UPDATE cw_time_entry SET '. $prime_upd_query .' WHERE prime_time_entry_id = "'. $prime_time_entry_id .'"';
			$this->db->query("CALL sp_a_run ('UPDATE','$prime_update_query')");
			echo json_encode(array('success' => TRUE, 'message' => "Successfully updated",'insert_id' => $prime_time_entry_id));
		}
	}
	//CHECK UNIQUE FIELD STATUS
	public function check_delete_status(){
		$check_delete_query  = 'SELECT GROUP_CONCAT(unique_field) as unique_field from cw_form_setting WHERE prime_module_id = "'. $this->control_name .'" and  trans_status = 1 ';
		$check_delete_info   = $this->db->query("CALL sp_a_run ('SELECT','$check_delete_query')");
		$check_delete_rlst   = $check_delete_info->row();
		$check_delete_info->next_result();
		$unique_info         = explode(",",$check_delete_rlst->unique_field);
		if(in_array('1', $unique_info ?? [])){
			return TRUE;
		}else{
			return FALSE;
		}
	}
	
	//UPDATE STATUS TO DELETE FOR UPLOAD FILES or DOCUMENTS
	public function remove_file(){
		$encString     = file_get_contents('php://input');
		$_POST         = $this->cryptoDecrypt($encString);
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
			exit(0);
		}
		$prime_id_val   = $this->input->post('prime_id_val');
		$is_defult      = (int)$this->input->post('is_defult');
		$input_name     = $this->input->post('input_name');
		$input_val      = $this->input->post('input_val');
		if($input_val){
			chmod($input_val, 0777);
			unlink($input_val);
		}
		$table_name = '';
		if($is_defult === 1){
			$table_name = $this->prime_table;
		}else
		if($is_defult === 2){
			$table_name = $this->cf_table;
		}
		if($table_name){
			$created_on    = date("Y-m-d h:i:s");
			$set_query     = $input_name .' = "" ,trans_updated_by = "'. $this->logged_id .'",trans_updated_date = "'.$created_on.'"';
			$update_query  = 'UPDATE '.$table_name .' SET '. $set_query .' WHERE '. $this->prime_id .' = "'. $prime_id_val .'"';
			$this->db->query("CALL sp_a_run ('UPDATE','$update_query')");
			echo json_encode(array('success' => TRUE, 'message' => "Successfully updated"));
		}else{
			echo json_encode(array('success' => FALSE, 'message' => "Unable to process your request"));
		}
	}
}
?>