File: //home/cafsindia/hrms_allyindian_com/application_bk/controllers/Transaction_count.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Transaction_count extends Action_controller{
public function __construct(){
parent::__construct('transaction_count');
if(!$this->Appconfig->isAppvalid()){
redirect('config');
}
}
// LOAD PAGE WITH TABLE DATA
public function index(){
// DATATABLE HEADERS DEFINED _ARN FOR (8.3)
$db_name = $this->config->item("db_name");
$prime_table_query = $this->db->query("SELECT COLUMN_NAME AS label_name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '$db_name' AND TABLE_NAME = 'cw_transactions' AND COLUMN_NAME IN ('transactions_month')");
$prime_table_col = $prime_table_query->result();
$data['table_head'] = $prime_table_col;
$data['encKey'] = $this->generateKey();
$this->load->view("$this->control_name/manage",$data);
}
//LOAD PAGE TABLE VIEW WITH DATA BASED ON SEARCH FILTERS
public function search(){
$draw = $this->input->post('draw');
$start = $this->input->post('start');
$per_page = $this->input->post('length');
$search = $this->input->post('search');
$search = trim($search['value']);
$common_search = '';
$searchterm = $this->db->escape_like_str($search);
if($search){
$common_search .= " AND DATE_FORMAT(STR_TO_DATE(CONCAT(cw_transactions.transactions_month, '-01'), '%m-%Y-%d'), '%b-%Y') LIKE '%" . $searchterm . "%'";
}
//FETCH RECORDS DATA
$search_total = $this->db->query("SELECT count(*) as allcount from cw_transactions where trans_status = 1 GROUP BY transactions_month ");
$search_total_info = $search_total->result();
$total_count = $search_total_info[0]->allcount;
$search_count = $this->db->query("SELECT count(*) as allcount from cw_transactions where trans_status = 1 $common_search GROUP BY transactions_month");
$search_info = $search_count->result();
$filtered_count = $search_info[0]->allcount;
$search_query = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT(transactions_month, '-01'), '%m-%Y-%d'), '%b-%Y') AS transactions_month,trans_status FROM cw_transactions WHERE trans_status = 1 $common_search GROUP BY transactions_month";
if((int)$per_page !== -1){
$search_query .= " LIMIT $start,$per_page";
}
$search_data = $this->db->query($search_query);
$search_result = $search_data->result();
$search_data->next_result();
echo json_encode(array("draw" => intval($draw),"recordsTotal" => $total_count,"recordsFiltered" => $filtered_count,"data" => $search_result));
}
}
?>