File: /home/cafsindia/cloud_cafsinfotech_in/application/controllers/Pt_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Pt_report extends Action_controller{
public function __construct(){
parent::__construct('pt_report');
if(!$this->Appconfig->isAppvalid()){
redirect('config');
}
}
// LOAD PAGE WITH TABLE DATA
public function index(){
$location_info = $this->db->query("CALL sp_a_run ('SELECT','SELECT * FROM `cw_professional_tax_location` where trans_status = 1')");
$location_result = $location_info->result();
$location_info->next_result();
$location[""] = "---- Select Location ----";
foreach($location_result as $for){
$location_id = $for->prime_professional_tax_location_id;
$location_name = $for->professional_tax_location;
$location[$location_id] = $location_name;
}
$data['location'] = $location;
$this->load->view("$this->control_name/manage",$data);
}
public function pt_save(){
$location_name = $this->input->post('location_name');
$process_month = $this->input->post('process_month');
$location = (int)$this->input->post('location');
$report_model = (int)$this->input->post('report_model');
$today_date = date("d-m-Y H:i:s");
$company = 'select company_name from cw_company_information where cw_company_information.trans_status = 1';
$comp_info = $this->db->query("CALL sp_a_run ('SELECT','$company')");
$comp_result = $comp_info->row();
$comp_info->next_result();
$company_name = $comp_result->company_name;
$address = $comp_result->address;
$loc_column_qry = 'select group_concat("cw_transactions.",db_column," as ",loc_name) as select_qry from cw_payroll_function_map where trans_status = 1';
$loc_column_info = $this->db->query("CALL sp_a_run ('SELECT','$loc_column_qry')");
$loc_column_rslt = $loc_column_info->result_array();
$loc_column_info->next_result();
$select_qry = $loc_column_rslt[0]['select_qry'];
if(!$select_qry){
echo json_encode(array('success'=>FALSE,'msg'=>'Column Not Mapped....'));
exit(0);
}
if($report_model === 1){
$qry = 'select cw_employees.employee_code,cw_employees.emp_name,cw_transactions.net_pay,'.$select_qry.' from cw_transactions inner join cw_employees on cw_employees.employee_code = cw_transactions.employee_code where transactions_month ="'.$process_month.'" and cw_transactions.professional_tax_location ="'.$location.'" and cw_transactions.trans_status = 1';
$qry_info = $this->db->query("CALL sp_a_run ('SELECT','$qry')");
$qry_result = $qry_info->result();
$qry_info->next_result();
$total_employees = count($qry_result);
$tr_line = "";
$total_pay = 0;
$total_pt = 0;
foreach($qry_result as $rslt){
$code = $rslt->employee_code;
$name = $rslt->emp_name;
$pt_gross = $rslt->pt_gross;
$professional_tax = $rslt->professional_tax_amount;
$total_pay = $total_pay + $pt_gross;
$total_pt = $total_pt + $professional_tax;
$tr_line .= "<tr><td>$code</td><td>$name</td><td>$pt_gross</td><td>$professional_tax</td></tr>";
}
$total_pay = number_format((float)$total_pay, 2, '.', '');
$total_pt = number_format((float)$total_pt, 2, '.', '');
if($employee_code == '' && $name == ''){
$tr_line .= "<tr style='text-align:center;font-weight:bold;'><td colspan='6'>No Data Found!!</td></tr>";
}else{
$tr_line .= "<tr style='text-align:center;font-weight:bold;'><td>Total Employees :$total_employees</td><td>Total</td><td>$total_pay</td><td>$total_pt</td></tr>";
}
$table_data = "<div style='width:700px; margin-left: auto; margin-right: auto; padding: 15px; background-color: #EEEEEE; border-radius: 3px; box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2);'>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;text-align: left;font-size: 14px;background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<tr>
<td colspan='2'><h3 style='text-align:center;'>PROFESSIONAL TAX REPORT</h3></td>
</tr>
<tr>
<td colspan='2' style='border-bottom:none !important;'>
<h3 style='color:#d3434d;margin:10px;font-size:21px;font-weight:bold;text-align:center;'>".$company_name."
</h3>
</td>
</tr>
<tr>
<td style='border-right:none !important;border-top:none !important;'>
<h3 style='color:#d3434d;margin:10px;font-size:16px;font-weight:bold;'>Professional Tax for the Month of ".strtoupper(date("M-Y",strtotime("01-".$this->input->post('process_month'))))."- Location -".$location_name."</h3>
</td>
<td style='text-align:center;font-weight:bold;border-top:none !important;border-left:none !important;'>".$today_date."</td>
</tr>
</table>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;font-size: 14px;background-color:#FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<thead>
</thead>
<tbody>
<tr style='background-color:#f2f2f2;color: #000000;font-weight:bold;'>
<th>Code</th>
<th>Name</th>
<th>Gross</th>
<th>Profession Tax</th>
</tr>
$tr_line
</tbody>
</table>
</div>";
$table_data = "<!DOCTYPE html><html> <body>".$table_data."</body></html>";
}else
if($report_model === 2){
//inner join cw_professional_tax_tax_range on prime_professional_tax_id=professional_tax_location
$qry = 'select '.$select_qry.',count(employees_id) as total_employees from cw_transactions WHERE transactions_month ="'.$process_month.'" and professional_tax_location ="'.$location.'" and cw_transactions.trans_status = 1 GROUP by professional_tax_location';
$stat_info = $this->db->query("CALL sp_a_run ('SELECT','$qry')");
$stat_result = $stat_info->result();
$stat_info->next_result();
$total_prof = 0;
foreach($stat_result as $stat){
$earning_range_from = $stat->earning_range_from;
$earning_range_to = $stat->earning_range_to;
$total_employees = $stat->total_employees;
$professional_tax = $stat->professional_tax_amount;
$tax_amt = $total_employees * $professional_tax;
$tax_amt = number_format((float)$tax_amt, 2, '.', '');
$total_prof = $total_prof + $tax_amt;
$stat_line .= "<tr><td>$earning_range_from - $earning_range_to</td><td>$total_employees</td><td>$professional_tax</td><td>$tax_amt</td></tr>";
}
$total_prof = number_format((float)$total_prof, 2, '.', '');
if($total_employees == ''){
$stat_line .= "<tr style='text-align:center;font-weight:bold;'><td colspan='4'>No Data Found!!</td></tr>";
}else{
$stat_line .= "<tr style='text-align:center;font-weight:bold;'><td colspan='3' style='text-align:right'>Total Rs.</td><td>$total_prof</td></tr>";
}
$table_data = "<div style='width:700px; margin-left: auto; margin-right: auto; padding: 0px; background-color: #EEEEEE; border-radius: 3px; box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2);'>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;text-align: left;font-size: 14px;background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<tr>
<td colspan='2'><h3 style='text-align:center;'>(See Rule 12)</h3>
<p><h3 style='text-align:center;'>RETURNS OF TAX PAYABLE BY EMPLOYER </h3></p>
<h4 style='margin-left:20px;'>Under Sub - Section (1) of Section 7 of the ".$location_name." Tax on <br/>Professions,Trades,Callings and Employments Act,1987</h4>
<h4 style='color:#d3434d;margin:10px;font-size:16px;font-weight:bold;'>Return of tax payable for the month ending on ".strtoupper(date("M-Y",strtotime("01-".$this->input->post('process_month'))))."</h4>
</td>
</tr>
<tr><td><h4>Name Of The Employer:</h4></td><td><h4 style='color:#d3434d;margin:10px;font-size:21px;font-weight:bold;text-align:center;'>".$company_name."</h4></td></tr>
<tr><td colspan='2'><h4>Address: ".$address."</h4></td></tr>
<tr><td colspan='2'><h4>Registration Certificate No.</h4>
<h4>Number of employees during the month in respect of whom the tax is payable is as under:</h4></td></tr>
</table>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;font-size: 14px;background-color:#FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<thead>
</thead>
<tbody>
<tr style='background-color:#f2f2f2;color: #000000;font-weight:bold;'>
<th>Employees Whose Monthly Salaries Or wages or both are</th>
<th>Number Of Employees</th>
<th>Rate Of Tax Per Month Rs.</th>
<th>Amount Of Tax Deducted Rs.</th>
</tr>
$stat_line
<tr><td colspan='3'><h5>Add: Simple Interest payable (if any) on the above amount at two percent per month or part there of(vide Section 11 of the Act)</h5></td><td></td></tr>
<tr><td colspan='3' style='text-align:right'>Grand Total</td><td>$total_prof</td></tr><tr><td>Amount Paid: $total_prof</td><td colspan='2'> Under challan no.</td><td>dated:</td></tr>
<tr><td colspan='4'>I Certify that all the employees who are liable to pay the tax in my employ during the period of return have been covered by the forgoing particulars..I also certify that the necessary revision in the amount of tax deductible from the salary of wages of the employees on account of variation in the salary or wages earned by team been made whatever necessary.<br/><br/></td></tr>
<tr><td colspan='3' style='border-bottom:none !important;border-right:none !important;'>I, shri</td><td style='border-bottom:none !important;border-left:none !important;'>Solemnly declare that the</td></tr>
<tr><td colspan='4' style='border-top:none !important;'>above statments are true to the best of my knowledge and belief.<br/></td></tr>
<tr><td colspan='2'>Place</td><td colspan='2'>Signature<span style='color:#bbbbbb;margin-left:70px;'>(Employer)</span></td></tr>
<tr><td colspan='2'>Date</td><td colspan='2'>Status</td></tr>
</tbody>
</table>
</div>";
$table_data = "<!DOCTYPE html><html> <body>".$table_data."</body></html>";
}
//$combine_data .= $table_data; //For Combine all pdf
$folder = $this->generate_pdf($table_data,$location_name,$process_month,$location,$report_model);
echo json_encode(array('success' => TRUE,'folder' => $folder,'process_month' => $process_month));
}
public function generate_pdf($table_data,$location_name,$process_month,$location,$report_model){
$location_name = strtolower(str_replace(" ","_",$location_name));
if($report_model == 1){
$model_name = "Detail";
}else
if($report_model == 2){
$model_name = "Statutory";
}
$set_paper = "portrait";
$folder = "ptax_report/".$process_month."/".$model_name;
$path = $this->common_generate_pdf($table_data,$folder,$location_name,$set_paper,'A4','','');
return $path;
}
}
?>