File: /home/cafsindia/hrms_cafsinfotech_in/OLD/application/controllers/Esi_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Esi_report extends Action_controller{
public function __construct(){
parent::__construct('esi_report');
if(!$this->Appconfig->isAppvalid()){
redirect('config');
}
}
// LOAD PAGE WITH TABLE DATA
public function index(){
$role_info = $this->db->query("CALL sp_a_run ('SELECT','SELECT * FROM `cw_category` where trans_status = 1')");
$role_result = $role_info->result();
$role_info->next_result();
$process_role[""] = "---- Select Category ----";
foreach($role_result as $for){
$role_id = $for->prime_category_id;
$category_name = $for->category_name;
$process_role[$role_id] = $category_name;
}
$data['process_role'] = $process_role;
$data['key'] = $this->generateKey();
$this->load->view("$this->control_name/manage",$data);
}
public function esi_save(){
$encString = file_get_contents('php://input');
$_POST = $this->cryptoDecrypt($encString);
if(!$_POST){
echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
exit(0);
}
$category_name = $this->input->post('category');
$all_category = $this->input->post('all_category');
$process_month = $this->input->post('process_month');
$category_type = (int)$this->input->post('category_type');
$cheque_no = $this->input->post('cheque_no');
$cheque_date = $this->input->post('cheque_date');
$payment_date = $this->input->post('payment_date');
$report_type = (int)$this->input->post('report_type');
$process_role = (int)$this->input->post('process_role');
$show_trip = (int)$this->input->post('show_trip');
$today_date = date("m-d-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;
$loc_column_qry = 'select group_concat("cw_transactions.",db_column," as ",loc_name) as select_qry,group_concat("SUM(cw_transactions.",db_column,") as ",loc_name) as sum_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'];
$sum_select_qry = $loc_column_rslt[0]['sum_select_qry'];
if(!$select_qry){
echo json_encode(array('success'=>FALSE,'msg'=>'Column Not Mapped....'));
exit(0);
}
if($report_type === 1){
if($category_type === 2){
$query = " and cw_transactions.role = $process_role ";
}else{
$query ='';
}
$qry_qry = 'select cw_employees.employee_code,cw_employees.emp_name,'.$select_qry.' from cw_transactions inner join cw_employees on cw_employees.employee_code = cw_transactions.employee_code where transactions_month ="'.$process_month.'"'.$query.' and cw_transactions.trans_status = 1';
$qry_info = $this->db->query("CALL sp_a_run ('SELECT','$qry_qry')");
$qry_result = $qry_info->result_array();
$qry_info->next_result();
$tr_line = "";
$tot_gross = 0;
$tot_emp_con = 0;
$sr_no = 1;
foreach($qry_result as $rslt){
$employee_code = $rslt->employee_code;
$name = $rslt->emp_name;
$esi_number = $rslt->esi_number;
$days_worked = $rslt->days_worked;
$gross_salary = $rslt->gross_salary;
$employee_contribution = $rslt->emp_con;
$tot_gross = $tot_gross + $gross_salary;
$tot_emp_con = $tot_emp_con + $employee_contribution;
$tr_line .= "<tr><td>$sr_no.</td><td>$employee_code</td><td>$name</td><td>$esi_number</td><td>$days_worked</td><td>$gross_salary</td><td>$employee_contribution</td></tr>";
$sr_no++;
}
$tot_gross = number_format((float)$tot_gross, 2, '.', '');
$tot_emp_con = number_format((float)$tot_emp_con, 2, '.', '');
if($employee_code == '' && $name == ''){
$tr_line .= "<tr style='text-align:center;font-weight:bold;'><td colspan='7'>No Data Found!!</td></tr>";
}else{
$tr_line .= "<tr style='text-align:center;font-weight:bold;'><td colspan='5'>Total</td><td>$tot_gross</td><td>$tot_emp_con</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 style='border-bottom:none !important; border-right:none !important;'>
<h3 style='color:#d3434d;margin:10px;font-size:21px;font-weight:bold;'>".$company_name."
</h3>
</td>
<td style='text-align:right;font-weight:bold'>".$today_date."</td>
</tr>
<tr>
<td colspan='2'>
<h3 style='color:#d3434d;margin:10px;font-size:16px;font-weight:bold;'>ESI EXTRACT FOR THE MONTH OF ".strtoupper(date("M-Y",strtotime("01-".$this->input->post('process_month'))))."</h3>
</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>Sl.No.</th>
<th>Code</th>
<th>Name</th>
<th>Esi No</th>
<th>Days Worked</th>
<th>Gross Salary</th>
<th>Employee Contribution</th>
</tr>
$tr_line
</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,$category_type,$process_month,$category_name,$all_category,$cheque_no,$Cheque_date,$payment_date);
$folder = $this->esi_generate_pdf($table_data,$category_type,$process_month,$category_name,$all_category,$cheque_no,$Cheque_date,$payment_date,$report_type);
echo json_encode(array('success' => TRUE,'folder' => $folder,'process_month' => $process_month));
}else
if($report_type === 2){
$qry = 'select count(employees_id) as total_employees,SUM(net_pay) as total_wages ,'.$sum_select_qry.' from cw_transactions WHERE transactions_month ="'.$process_month.'" and termination_status != 1 and cw_transactions.trans_status = 1';
$qry_info = $this->db->query("CALL sp_a_run ('SELECT','$qry')");
$qry_result = $qry_info->row();
$qry_info->next_result();
$total_employees = $qry_result->total_employees;
$total_wages = $qry_result->total_wages;
$employees_cont = $qry_result->employees_cont;
$employer_cont = $qry_result->employer_cont;
$total_rs = $employees_cont + $employer_cont;
$total_rs = number_format((float)$total_rs, 2, '.', '');
$total_rs_words = $this->numberTowords($total_rs);
//check box not select
$original ="<div style='width:700px; margin-left: auto; margin-right: auto; padding: 15px; 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);'>
<div class='row'>
<div class='col-md-12'>
<p style='font-size:21px;'>ORIGINAL
<br/>(For Bank)<span style='margin-left:300px;'>FORMS-III</span></p>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<table>
<tr>
<td style='width:379px !important;'> </td>
<td>
Challan No.
</td>
<td style='border:1px solid #000;width:155px; height:30px;'>
</td>
</tr>
</table>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<h3 style='text-align:center;'>E.S.I.C</h3>
<p style='text-align:center;'>EMPLOYEES' STATE INSURANCE FUND ACCOUNT N<br/>
PAY - IN SLIP FOR CONTRIBUTION INTEREST/<br/>
DAMAGES / OTHER RECEIPTS<br/>
STATE BANK OF INDIA<br/>
</p>
<p>Station :<br/>
Employer's Code No :<br/>
Name and Address of Factory / Establishment<span style='margin-left:50px;'>".$company_name."</span>
</p>
<p>No Of Employees ".$total_employees."
<span style='margin-left:60px;'>Total Wages ".$total_wages."</span><br/>
Employees' Contribution Rs. ".$employees_cont."
<span style='margin-left:50px;'>Employers's Contribution ".$employer_cont."</span><br/>
Interest<br/>
Other Receipts
<span style='margin-left:150px;'>Damages</span><br/>
Total Rs. ".$total_rs."<br/>
Paid into the credit of the Employees' State Insurance Fund Account No. 1 Rs. ".$total_rs."<br/>
(".$total_rs_words."<br/>
in cash/by Cheque (on realisation)/ Draft for payment of contribution as per details given abover under the<br/>
Employees' State insurance Act 1948, for the month of ".strtoupper(date("F-Y",strtotime("01-".$this->input->post('process_month'))))."<br/>
Deposited by
<span style='margin-left:280px;'>Code No</span></p>
<p style='margin-left:380px;'>Rs.<span style='margin-left:20px;'>".$total_rs."</span></p>
<hr/>
<p style='text-align:center;font-weight:bold;'>ACKNOWLEDGEMENT</p>
<p style='text-align:center;'>To be filled by depositor</p>
<p>(Received payment with Cash/Cheque/Draft No<span style='margin-left:20px;'>".$cheque_no."</span><br/>
Date ".$cheque_date."
<span style='margin-left:140px;'>(for Rs.</span><span style='margin-left:90px;'>".$total_rs."</span><br/>
(drawn on
<span style='margin-left:290px;'>(Bank) in favourof Employees' State Insurance Fund</span><br/>Account No. 1<span style='margin-left:250px;'>".$payment_date."</span><br/>
Sl. No. in Bank's Scroll<br/><p>
<p>Dated :</span><br/>Account No. 1<span style='margin-left:190px;'>Authorised Signatory of the receiving bank</span></p>
</div>
</div>
</div>";
if($show_trip === 0){
$table_data = $original;
}else
if($show_trip === 1){
$table_data = "$original
<div style='page-break-after:always;'></div>
<div style='width:700px; margin-left: auto; margin-right: auto; padding: 15px; 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);'>
<div class='row'>
<div class='col-md-12'>
<p style='font-size:21px;'>DUPLICATE
<br/>(For ESIC through Bank)<span style='margin-left:300px;'>FORMS-III</span></p>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<table>
<tr>
<td style='width:379px !important;'> </td>
<td>
Challan No.
</td>
<td style='border:1px solid #000;width:155px; height:30px;'>
</td>
</tr>
</table>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<h3 style='text-align:center;'>E.S.I.C</h3>
<p style='text-align:center;'>EMPLOYEES' STATE INSURANCE FUND ACCOUNT N<br/>
PAY - IN SLIP FOR CONTRIBUTION INTEREST/<br/>
DAMAGES / OTHER RECEIPTS<br/>
STATE BANK OF INDIA<br/>
</p>
<p>Station :<br/>
Employer's Code No :<br/>
Name and Address of Factory / Establishment<span style='margin-left:50px;'>".$company_name."</span>
</p>
<p>No Of Employees ".$total_employees."
<span style='margin-left:60px;'>Total Wages ".$total_wages."</span><br/>
Employees' Contribution Rs. ".$employees_cont."
<span style='margin-left:50px;'>Employers's Contribution ".$employer_cont."</span><br/>
Interest<br/>
Other Receipts
<span style='margin-left:150px;'>Damages</span><br/>
Total Rs. ".$total_rs."<br/>
Paid into the credit of the Employees' State Insurance Fund Account No. 1 Rs. ".$total_rs."<br/>
(".$total_rs_words."<br/>
in cash/by Cheque (on realisation)/ Draft for payment of contribution as per details given abover under the<br/>
Employees' State insurance Act 1948, for the month of ".strtoupper(date("F-Y",strtotime("01-".$this->input->post('process_month'))))."<br/>
Deposited by
<span style='margin-left:280px;'>Code No</span></p>
<p style='margin-left:380px;'>Rs.<span style='margin-left:20px;'>".$total_rs."</span></p>
<hr/>
<p style='text-align:center;font-weight:bold;'>ACKNOWLEDGEMENT</p>
<p style='text-align:center;'>To be filled by depositor</p>
<p>(Received payment with Cash/Cheque/Draft No<span style='margin-left:20px;'>".$cheque_no."</span><br/>
Date ".$cheque_date."
<span style='margin-left:140px;'>(for Rs.</span><span style='margin-left:90px;'>".$total_rs."</span><br/>
(drawn on
<span style='margin-left:290px;'>(Bank) in favourof Employees' State Insurance Fund</span><br/>Account No. 1<span style='margin-left:250px;'>".$payment_date."</span><br/>
Sl. No. in Bank's Scroll<br/><p>
<p>Dated :</span><br/>Account No. 1<span style='margin-left:190px;'>Authorised Signatory of the receiving bank</span></p>
</div>
</div>
</div>
<div style='page-break-after:always;'></div>
<div style='width:700px; margin-left: auto; margin-right: auto; padding: 15px; 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);'>
<div class='row'>
<div class='col-md-12'>
<p style='font-size:21px;'>TRIPLICATE
<br/>For Depositor<span style='margin-left:300px;'>FORMS-III</span></p>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<table>
<tr>
<td style='width:379px !important;'> </td>
<td>
Challan No.
</td>
<td style='border:1px solid #000;width:155px; height:30px;'>
</td>
</tr>
</table>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<h3 style='text-align:center;'>E.S.I.C</h3>
<p style='text-align:center;'>EMPLOYEES' STATE INSURANCE FUND ACCOUNT N<br/>
PAY - IN SLIP FOR CONTRIBUTION INTEREST/<br/>
DAMAGES / OTHER RECEIPTS<br/>
STATE BANK OF INDIA<br/>
</p>
<p>Station :<br/>
Employer's Code No :<br/>
Name and Address of Factory / Establishment<span style='margin-left:50px;'>".$company_name."</span>
</p>
<p>No Of Employees ".$total_employees."
<span style='margin-left:60px;'>Total Wages ".$total_wages."</span><br/>
Employees' Contribution Rs. ".$employees_cont."
<span style='margin-left:50px;'>Employers's Contribution ".$employer_cont."</span><br/>
Interest<br/>
Other Receipts
<span style='margin-left:150px;'>Damages</span><br/>
Total Rs. ".$total_rs."<br/>
Paid into the credit of the Employees' State Insurance Fund Account No. 1 Rs. ".$total_rs."<br/>
(".$total_rs_words."<br/>
in cash/by Cheque (on realisation)/ Draft for payment of contribution as per details given abover under the<br/>
Employees' State insurance Act 1948, for the month of ".strtoupper(date("F-Y",strtotime("01-".$this->input->post('process_month'))))."<br/>
Deposited by
<span style='margin-left:280px;'>Code No</span></p>
<p style='margin-left:380px;'>Rs.<span style='margin-left:20px;'>".$total_rs."</span></p>
<hr/>
<p style='text-align:center;font-weight:bold;'>ACKNOWLEDGEMENT</p>
<p style='text-align:center;'>To be filled by depositor</p>
<p>(Received payment with Cash/Cheque/Draft No<span style='margin-left:20px;'>".$cheque_no."</span><br/>
Date ".$cheque_date."
<span style='margin-left:140px;'>(for Rs.</span><span style='margin-left:90px;'>".$total_rs."</span><br/>
(drawn on
<span style='margin-left:290px;'>(Bank) in favourof Employees' State Insurance Fund</span><br/>Account No. 1<span style='margin-left:250px;'>".$payment_date."</span><br/>
Sl. No. in Bank's Scroll<br/><p>
<p>Dated :</span><br/>Account No. 1<span style='margin-left:190px;'>Authorised Signatory of the receiving bank</span></p>
</div>
</div>
</div>
<div style='page-break-after:always;'></div>
<div style='width:700px; margin-left: auto; margin-right: auto; padding: 15px; 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);'>
<div class='row'>
<div class='col-md-12'>
<p style='font-size:21px;'>QUADRUPLICATE</p>
<p style='font-size:16px;'>For Depositor to be<br/>attached with return of<br/><br/>Contribution <span style='margin-left:300px;'>FORMS-III</span></p>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<table>
<tr>
<td style='width:379px !important;'> </td>
<td>
Challan No.
</td>
<td style='border:1px solid #000;width:155px; height:30px;'>
</td>
</tr>
</table>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<h3 style='text-align:center;'>E.S.I.C</h3>
<p style='text-align:center;'>EMPLOYEES' STATE INSURANCE FUND ACCOUNT N<br/>
PAY - IN SLIP FOR CONTRIBUTION INTEREST/<br/>
DAMAGES / OTHER RECEIPTS<br/>
STATE BANK OF INDIA<br/>
</p>
<p>Station :<br/>
Employer's Code No :<br/>
Name and Address of Factory / Establishment<span style='margin-left:50px;'>".$company_name."</span>
</p>
<p>No Of Employees ".$total_employees."
<span style='margin-left:60px;'>Total Wages ".$total_wages."</span><br/>
Employees' Contribution Rs. ".$employees_cont."
<span style='margin-left:50px;'>Employers's Contribution ".$employer_cont."</span><br/>
Interest<br/>
Other Receipts
<span style='margin-left:150px;'>Damages</span><br/>
Total Rs. ".$total_rs."<br/>
Paid into the credit of the Employees' State Insurance Fund Account No. 1 Rs. ".$total_rs."<br/>
(".$total_rs_words."<br/>
in cash/by Cheque (on realisation)/ Draft for payment of contribution as per details given abover under the<br/>
Employees' State insurance Act 1948, for the month of ".strtoupper(date("F-Y",strtotime("01-".$this->input->post('process_month'))))."<br/>
Deposited by
<span style='margin-left:280px;'>Code No</span></p>
<p style='margin-left:380px;'>Rs.<span style='margin-left:20px;'>".$total_rs."</span></p>
<hr/>
<p style='text-align:center;font-weight:bold;'>ACKNOWLEDGEMENT</p>
<p style='text-align:center;'>To be filled by depositor</p>
<p>(Received payment with Cash/Cheque/Draft No<span style='margin-left:20px;'>".$cheque_no."</span><br/>
Date ".$cheque_date."
<span style='margin-left:140px;'>(for Rs.</span><span style='margin-left:90px;'>".$total_rs."</span><br/>
(drawn on
<span style='margin-left:290px;'>(Bank) in favourof Employees' State Insurance Fund</span><br/>Account No. 1<span style='margin-left:250px;'>".$payment_date."</span><br/>
Sl. No. in Bank's Scroll<br/><p>
<p>Dated :</span><br/>Account No. 1<span style='margin-left:190px;'>Authorised Signatory of the receiving bank</span></p>
</div>
</div>
</div>";
}
$table_data = "<!DOCTYPE html><html> <body>".$table_data."</body></html>";
//$combine_data .= $table_data; //For Combine all pdf
$folder = $this->esi_generate_pdf($table_data,$category_type,$process_month,$category_name,$all_category,$cheque_no,$cheque_date,$payment_date,$report_type);
echo json_encode(array('success' => TRUE,'folder' => $folder,'process_month' => $process_month));
}
}
public function esi_generate_pdf($table_data,$category_type,$process_month,$category_name,$all_category,$cheque_no,$cheque_date,$payment_date,$report_type){
if($category_type == 1){
$category = "All";
$category_name = "All";
}else
if($category_type == 2){
$category = "Particular";
}
if($report_type == 2 && $category_type == ''){
$category = "Esi_challan_Report";
$category_name = "Esi_challan";
}
$set_paper = 'portrait';
$folder = "esi_report/".$process_month."/".$category;
$path = $this->common_generate_pdf($table_data,$folder,$category_name,$set_paper,'A4','','');
return $path;
}
public function numberTowords($number){
$no = round($number);
$point = round($number - $no, 2) * 100;
$hundred = null;
$digits_1 = strlen($no);
$i = 0;
$str = array();
$words = array('0' => '', '1' => 'One', '2' => 'Two',
'3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six',
'7' => 'Seven', '8' => 'Eight', '9' => 'Nine',
'10' => 'Ten', '11' => 'Eleven', '12' => 'Twelve',
'13' => 'Thirteen', '14' => 'Fourteen',
'15' => 'Fifteen', '16' => 'Sixteen', '17' => 'Seventeen',
'18' => 'Eighteen', '19' =>'Nineteen', '20' => 'Twenty',
'30' => 'Thirty', '40' => 'Forty', '50' => 'Fifty',
'60' => 'Sixty', '70' => 'Seventy',
'80' => 'Eighty', '90' => 'Ninety');
$digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
while ($i < $digits_1) {
$divider = ($i == 2) ? 10 : 100;
$number = floor($no % $divider);
$no = floor($no / $divider);
$i += ($divider == 10) ? 1 : 2;
if ($number) {
$plural = (($counter = count($str)) && $number > 9) ? 's' : null;
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
$str [] = ($number < 21) ? $words[$number] .
" " . $digits[$counter] . $plural . " " . $hundred
:
$words[floor($number / 10) * 10]
. " " . $words[$number % 10] . " "
. $digits[$counter] . $plural . " " . $hundred;
} else $str[] = null;
}
$str = array_reverse($str);
$result = implode('', $str);
$points = ($point) ?
"." . $words[$point / 10] . " " .
$words[$point = $point % 10] : '';
//echo $result . "Rupees " . $points . " Paise";
if($result === ""){
$result = "Zero ";
}
return $result . "INR Only ";
}
}
?>