File: /home/cafsindia/hrms_cafsindia_com/application/controllers/Tax_entry_wise_report.php
<?php
if (!defined('BASEPATH')) exit('No direct script is allowed');
require_once("Base_controller.php");
class tax_entry_wise_report extends Base_controller{
public function __construct(){
parent::__construct('tax_entry_wise_report');
if (!$this->Appconfig->isAppvalid()) {
redirect('config');
}
$this->collect_base_info();
// Load pdf library
require_once "./dist/eos-1.0.0/eos.class.php";
$eq = new eqEOS();
$this->load->library('pdf');
}
// LOAD PAGE WITH TABLE DATA
public function index(){
$data['module_id'] = $this->control_name;
$category_info = $this->db->query("CALL sp_a_run ('SELECT','SELECT * FROM `cw_category` where trans_status = 1 and prime_category_id !=1')");
$category_result = $category_info->result();
$category_info->next_result();
$category_list[""] = "---- Category For ----";
foreach($category_result as $for){
$cat_id = $for->prime_category_id;
$category_name = $for->category_name;
$category_list[$cat_id] = $category_name;
}
$data['category_list'] = $category_list;
$data['table_headers'] = $this->xss_clean(get_dbtable_headers($this->table_info));
$data['fliter_list'] = $this->fliter_list;
$data['link_info'] = $this->quick_link;
$this->load->view("$this->control_name/manage", $data);
}
public function emp_suggest(){
$search_term = $this->input->post_get('term');
$final_qry = 'select employee_code,emp_name from cw_employees where trans_status = 1 and employee_code like "' . $search_term . '%"';
$final_data = $this->db->query("CALL sp_a_run ('SELECT','$final_qry')");
$final_result = $final_data->result();
$final_data->next_result();
foreach ($final_result as $rslt) {
$employee_code = $rslt->employee_code;
$emp_name = $rslt->emp_name;
$suggestions[] = array(
'value' => $employee_code,
'label' => "$employee_code - $emp_name"
);
}
if (empty($suggestions)) {
$suggestions[] = array(
'value' => "0",
'label' => "No data found for this search"
);
}
echo json_encode($suggestions);
}
//SAVE MODEL DATA TO DATA BASE
public function tax_entry_wise_report(){
require_once "./dist/eos-1.0.0/eos.class.php";
$eq = new eqEOS();
$process_month = $this->input->post('process_month');
$process_emp_code = $this->input->post('emp_code');
$process_category = $this->input->post('category');
$tax_entry_type = $this->input->post('tax_entry_type');
$month_name = date("F", strtotime("01-" . $process_month));
$logged_id = $this->session->userdata('logged_id');
$today_date = date("Y-m-d H:i:s");
if ((int)$tax_entry_type === 1) {
$cw_declaration_entry_query = "";
if($process_emp_code) {
$cw_declaration_entry_query = 'SELECT effective_month,emp_code,cw_employees.emp_name FROM `cw_declaration_entry` inner join cw_employees on cw_employees.employee_code = cw_declaration_entry.emp_code WHERE cw_declaration_entry.emp_code = "' . $process_emp_code . '" and cw_declaration_entry.effective_month = "' . $process_month . '" and cw_declaration_entry.trans_status = 1';
}
else {
$cw_declaration_entry_query = 'SELECT effective_month,emp_code,cw_employees.emp_name FROM `cw_declaration_entry` inner join cw_employees on cw_employees.employee_code = cw_declaration_entry.emp_code WHERE cw_declaration_entry.category = "' . $process_category . '" and cw_declaration_entry.effective_month = "' . $process_month . '" and cw_declaration_entry.trans_status = 1';
}
$cw_declaration_entry_data = $this->db->query("CALL sp_a_run ('SELECT','$cw_declaration_entry_query')");
$cw_declaration_entry_result = $cw_declaration_entry_data->result_array();
$cw_declaration_entry_data->next_result();
$tr_line = "";
foreach ($cw_declaration_entry_result as $value) {
$effective_month = $value['effective_month'];
$emp_code = $value['emp_code'];
$emp_name = $value['emp_name'];
$tr_line .= "<tr><td>$effective_month</td><td>$emp_code</td><td>$emp_name</td></tr>";
}
$table_data = "<table class='table table-striped table-hover' id='table_info'>
<thead>
<th>Effective Month</th><th>Employee Code</th><th>Employee name</th>
</thead>
<tbody>$tr_line</tbody>
</table>";
if($cw_declaration_entry_result ){
echo json_encode(array('success' => TRUE,'table_data' => $table_data));
}else{
echo json_encode(array('success' => FALSE,'msg' => "No Entry From Declaration Wise For This Month..."));
}
}else
if((int)$tax_entry_type === 2) {
$cw_house_rent_entry_query = "";
if($process_emp_code) {
$cw_house_rent_entry_query = 'SELECT process_month,employee_code,cw_employees.emp_name FROM `cw_house_rent_entry` inner join cw_employees on cw_employees.employee_code = cw_house_rent_entry.employee_code WHERE cw_house_rent_entry.employee_code = "' . $process_emp_code . '" and cw_house_rent_entry.effective_month = "' . $process_month . '" and cw_house_rent_entry.trans_status = 1';
}
else {
$cw_house_rent_entry_query = 'SELECT process_month,employee_code,cw_employees.emp_name FROM `cw_house_rent_entry` inner join cw_employees on cw_employees.employee_code = cw_house_rent_entry.employee_code WHERE cw_house_rent_entry.category = "' . $process_category . '" and cw_house_rent_entry.effective_month = "' . $process_month . '" and cw_house_rent_entry.trans_status = 1';
}
$cw_house_rent_entry_data = $this->db->query("CALL sp_a_run ('SELECT','$cw_house_rent_entry_query')");
$cw_house_rent_entry_result = $cw_house_rent_entry_data->result_array();
$cw_house_rent_entry_data->next_result();
$tr_line = "";
foreach ($cw_house_rent_entry_result as $value) {
$process_month = $value['process_month'];
$emp_code = $value['employee_code'];
$emp_name = $value['emp_name'];
$tr_line .= "<tr><td>$process_month</td><td>$emp_code</td><td>$emp_name</td></tr>";
}
$table_data = "<table class='table table-striped table-hover' id='table_info'>
<thead>
<th>Process Month</th><th>Employee Code</th><th>Employee name</th>
</thead>
<tbody>$tr_line</tbody>
</table>";
if($cw_house_rent_entry_result ){
echo json_encode(array('success' => TRUE,'table_data' => $table_data));
}else{
echo json_encode(array('success' => FALSE,'msg' => "No Entry From House Rent Wise For This Month..."));
}
}else
if ((int)$tax_entry_type === 3) {
$cw_tax_proof_query = "";
if($process_emp_code) {
$cw_tax_proof_query = 'SELECT *,cw_employees.emp_name,emp_code FROM `cw_tax_proof_entry` inner join cw_employees on cw_employees.employee_code = cw_tax_proof_entry.emp_code WHERE cw_tax_proof_entry.emp_code = "' . $process_emp_code . '" and cw_tax_proof_entry.trans_status = 1';
}
else {
$cw_tax_proof_query = 'SELECT *,cw_employees.emp_name,emp_code FROM `cw_tax_proof_entry` inner join cw_employees on cw_employees.employee_code = cw_tax_proof_entry.emp_code WHERE cw_tax_proof_entry.category = "' . $process_category . '" and cw_tax_proof_entry.trans_status = 1';
}
$cw_tax_proof_data = $this->db->query("CALL sp_a_run ('SELECT','$cw_tax_proof_query')");
$cw_tax_proof_result = $cw_tax_proof_data->result_array();
$cw_tax_proof_data->next_result();
$tr_line = "";
foreach ($cw_tax_proof_result as $value) {
$emp_code = $value['emp_code'];
$emp_name = $value['emp_name'];
$tr_line .= "<tr><td>$emp_code</td><td>$emp_name</td></tr>";
}
$table_data = "<table class='table table-striped table-hover' id='table_info'>
<thead>
<th>Employee Code</th><th>Employee name</th>
</thead>
<tbody>$tr_line</tbody>
</table>";
if($cw_tax_proof_result){
echo json_encode(array('success' => TRUE,'table_data' => $table_data));
}else{
echo json_encode(array('success' => FALSE,'msg' => "No Entry From Proof Wise For This Month..."));
}
}else
if((int)$tax_entry_type === 4) {
$cw_offline_tds_entry_query = "";
if($process_emp_code) {
$cw_offline_tds_entry_query = 'SELECT *,cw_employees.emp_name,employee_code,payroll_month FROM `cw_offline_tds_entry` inner join cw_employees on cw_employees.employee_code = cw_offline_tds_entry.employee_code WHERE cw_offline_tds_entry.employee_code = "' . $process_emp_code . '" and cw_offline_tds_entry.payroll_month = "' . $process_month . '" and cw_offline_tds_entry.trans_status = 1';
}else {
$cw_offline_tds_entry_query = 'SELECT *,cw_employees.emp_name,employee_code,payroll_month FROM `cw_offline_tds_entry` inner join cw_employees on cw_employees.employee_code = cw_offline_tds_entry.employee_code WHERE cw_offline_tds_entry.category = "' . $process_category . '" and cw_offline_tds_entry.payroll_month = "' . $process_month . '" and cw_offline_tds_entry.trans_status = 1';
}
$cw_offline_tds_entry_data = $this->db->query("CALL sp_a_run ('SELECT','$cw_offline_tds_entry_query')");
$cw_offline_tds_entry_result = $cw_offline_tds_entry_data->result_array();
$cw_offline_tds_entry_data->next_result();
$tr_line = "";
foreach ($cw_offline_tds_entry_result as $value) {
$process_month = $value['payroll_month'];
$emp_code = $value['employee_code'];
$emp_name = $value['emp_name'];
$tr_line .= "<tr><td>$process_month</td><td>$emp_code</td><td>$emp_name</td></tr>";
}
$table_data = "<table class='table table-striped table-hover' id='table_info'>
<thead>
<th>Process Month</th><th>Employee Code</th><th>Employee name</th>
</thead>
<tbody>$tr_line</tbody>
</table>";
if($cw_offline_tds_entry_result ){
echo json_encode(array('success' => TRUE,'table_data' => $table_data));
}else{
echo json_encode(array('success' => FALSE,'msg' => "No Entry From Offline Tds Wise For This Month..."));
}
}else
if((int)$tax_entry_type === 5) {
$cw_other_income_entry_query = "";
if($process_emp_code) {
$cw_other_income_entry_query = 'SELECT *,cw_employees.emp_name,employee_code,effective_month FROM `cw_other_income_entry` inner join cw_employees on cw_employees.employee_code = cw_other_income_entry.emp_code WHERE cw_other_income_entry.emp_code = "' . $process_emp_code . '" and cw_other_income_entry.effective_month = "' . $process_month . '" and cw_other_income_entry.trans_status = 1';
}else {
$cw_other_income_entry_query = 'SELECT *,cw_employees.emp_name,employee_code,effective_month FROM `cw_other_income_entry` inner join cw_employees on cw_employees.employee_code = cw_other_income_entry.emp_code WHERE cw_other_income_entry.category = "' . $process_category . '" and cw_other_income_entry.effective_month = "' . $process_month . '" and cw_other_income_entry.trans_status = 1';
}
$cw_other_income_entry_data = $this->db->query("CALL sp_a_run ('SELECT','$cw_other_income_entry_query')");
$cw_other_income_entry_result = $cw_other_income_entry_data->result_array();
$cw_other_income_entry_data->next_result();
$tr_line = "";
foreach ($cw_other_income_entry_result as $value) {
$process_month = $value['effective_month'];
$emp_code = $value['employee_code'];
$emp_name = $value['emp_name'];
$tr_line .= "<tr><td>$process_month</td><td>$emp_code</td><td>$emp_name</td></tr>";
}
$table_data = "<table class='table table-striped table-hover' id='table_info'>
<thead>
<th>Process Month</th><th>Employee Code</th><th>Employee name</th>
</thead>
<tbody>$tr_line</tbody>
</table>";
if($cw_other_income_entry_result ){
echo json_encode(array('success' => TRUE,'table_data' => $table_data));
}else{
echo json_encode(array('success' => FALSE,'msg' => "No Entry From Other Income Wise For This Month..."));
}
}
}
}
?>