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/uds.cafsinfotech.in/Dump/ZRM/application/controllers/Declaration_lock.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Declaration_lock  extends Action_controller{	
	public function __construct(){
		parent::__construct('declaration_lock');
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		//PAGE INFO FUNCTION
		$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;

		$prime_table_query     = $this->db->query("SELECT COLUMN_NAME AS label_name, COLUMN_KEY AS key_exist FROM information_schema.COLUMNS
		WHERE TABLE_SCHEMA ='".$this->config->item("db_name")."' AND TABLE_NAME = 'cw_employees' AND COLUMN_NAME IN 
		('employee_code','emp_name','income_tax_type','declaration_lock') ORDER BY ORDINAL_POSITION");
		$prime_table_col       = $prime_table_query->result();
		$data['table_head']    = $prime_table_col;
		$this->load->view("$this->control_name/manage",$data);
	}
	
	//LOAD TABEL WITH FILTERS
	public function search(){
		$financial_year     = $this->input->post('financial_year');
		$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']);
		
		$search_query      .= "SELECT cw_employees.prime_employees_id,cw_employees.employee_code,cw_employees.emp_name,cw_income_tax_type.income_tax_type,cw_lock_status.lock_status_value as declaration_lock FROM cw_employees inner JOIN cw_income_tax_type ON cw_employees.income_tax_type = cw_income_tax_type.prime_income_tax_type_id LEFT JOIN cw_lock_status ON cw_employees.declaration_lock = cw_lock_status.prime_lock_status_id WHERE cw_employees.trans_status=1 ";
		$common_search = "";
		if($search){
			$common_search .= "and cw_employees.employee_code like '%".$search."%' or cw_employees.emp_name like '%".$search."%' or cw_employees.income_tax_type like '%".$search."%'";
		}
		$search_total       = $this->db->query("SELECT count(*) as allcount from cw_employees ");
		$search_total_info  = $search_total->result();
		$total_count        = $search_total_info[0]->allcount;
		$search_count       = "";
		$search_count       = $this->db->query("SELECT count(*) as allcount from cw_employees where cw_employees.trans_status = 1 $common_search");
		
		$search_info        = $search_count->result();
		$filtered_count     = $search_info[0]->allcount;

		$search_query      .= "$common_search ORDER BY  emp_name $order_sor";
		if((int)$per_page !== -1){
			$search_query  .= " LIMIT  $start,$per_page";
		}		
		$search_data        = $this->db->query($search_query);
		$search_result      = $search_data->result();
		echo json_encode(array("draw" => intval($draw),"recordsTotal" => $total_count,"recordsFiltered" => $filtered_count,"data" => $search_result));		
	}
	public function dec_lock_update(){
		$lock_id=$this->input->post('lock_id');
		$submit_val=$this->input->post('submit_val');
		$upd_lock_id=implode(',', $lock_id);
		if($submit_val === 'Lock'){
			$update_query =$this->db->query('UPDATE cw_employees set declaration_lock=1 where prime_employees_id IN ('.$upd_lock_id.')');
			echo json_encode(array("success"=>TRUE,"message"=>'Selected Record is Locked'));
		}else
		if($submit_val === 'Unlock'){
			$update_query =$this->db->query('UPDATE cw_employees set declaration_lock=2 where prime_employees_id IN ('.$upd_lock_id.')');
			echo json_encode(array("success"=>TRUE,"message"=>'Selected Record is Unlocked'));
		}
		else{
			echo json_encode(array("success"=>false,"message"=>'INVALID'));
		}
	}
}
?>