File: /home/cafsindia/hrms_patroniss_com/application/controllers/Payslip_view.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Payslip_view extends Action_controller{
public function __construct(){
parent::__construct('payslip_view');
$this->collect_base_info();
}
// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
public function index(){
$data['quick_link'] = $this->quick_link;
$data['table_head'] = $this->table_head;
$data['master_pick'] = $this->master_pick;
$data['fliter_list'] = $this->fliter_list;
$this->load->view("$this->control_name/manage",$data);
}
public function check_payslip(){
$cat_id = $this->input->post('category');
$emp_code = $this->input->post('emp_code');
$from_month = $this->input->post('from_month');
$to_month = $this->input->post('last_month');
$pdf_name_query = 'select print_info_name from cw_print_info inner join cw_pdf_setting on cw_pdf_setting.pdf_info_name = prime_print_info_id where pdf_block_for ="'.$cat_id.'"';
$pdf_name_info = $this->db->query("CALL sp_a_run ('SELECT','$pdf_name_query')");
$pdf_name_result = $pdf_name_info->result();
$pdf_name_info->next_result();
$pdf_name = $pdf_name_result[0]->print_info_name;
$pdf_name = strtolower(str_replace(" ","_",$pdf_name));
$category_info = $this->db->query("CALL sp_a_run ('SELECT','SELECT category_name FROM `cw_category` where trans_status = 1 and prime_category_id = $cat_id')");
$category_result = $category_info->result();
$category_info->next_result();
$category_name_view = $category_result[0]->category_name;
$category_name = strtolower(str_replace(" ","_",$category_name_view));
$start_date = "01-".$from_month;
$end_date = "01-".$to_month;
$start_date = date('Y-m-d', strtotime($start_date));
$end_date = date('Y-m-d', strtotime($end_date));
$start = strtotime($start_date);
$month = strtotime($start_date);
$end = strtotime($end_date);
$tble_line = "";
$tble_no_line = "";
$i = 0;
$j = 0;
while($month <= $end){
$payslip_month = date('m-Y', $month);
$payslip_month_name = date('F Y', $month);
$folder_name = $category_name."/".$payslip_month."_".$pdf_name;
$file_path = "payslip/$folder_name/$emp_code.pdf";
if(file_exists($file_path)){
$file_path = base_url().$file_path;
$filename = dirname(__FILE__).$file_path;
$filename = str_replace("application\controllers","",$filename);
$tble_line .= " <tr class='gradeU'>
<td>$payslip_month_name</td>
<td>
<a class='btn btn-primary btn-sm' href='$file_path' target='_blank' ><span class='fa fa-eye' > </span> view </a>
<a class='btn btn-primary btn-sm' id='download_$payslip_month' href='$file_path' download '><span class='fa fa-download' download> </span> Download </a>
</td>
</tr>";
$j++;
}else{
$tble_no_line = " <tr class='gradeU'>
<td colspan='2' style='text-align:center;'>No data found</td>
</tr>";
}
$month = strtotime("+1 month", $month);
$i++;
}
$tbl_body = "";
if((int)$j >= 1){
$tbl_body = $tble_line;
}else{
$tbl_body = $tble_no_line;
}
$table_data = " <table class='table table-striped table-bordered' id='emp_details'>
<thead>
<tr>
<th>Payslip Month</th>
<th>Action</th>
</tr>
</thead>
<tbody>
$tbl_body
</tbody>
</table>";
echo json_encode(array('success' => true,'table_data' => $table_data));
}
}
?>