File: //home/cafsindia/cloud_cafsinfotech_in/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 ='cadd_hrms' 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,
(CASE
WHEN cw_employees.income_tax_type = 1 THEN 'With Declaration'
WHEN cw_employees.income_tax_type = 2 THEN 'Without Declaration'
ELSE ''
END) AS income_tax_type ,
cw_lock_status.lock_status_value as declaration_lock
FROM cw_employees
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));
}
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'));
}
}
}
?>