File: //home/cafsindia/hrms_patroniss_com/application/models/Formula_model.php
<?php
class Formula_model extends CI_Model{
public function import_formula($trans_array){
foreach($trans_array as $trans){
$employee_code = $trans["employee_code"];
if((int)$trans["role"] === 1){
$date_1 = new DateTime($trans['date_of_birth']);
$date_2 = new DateTime(date('Y-m-d') );
$differ = $date_2->diff($date_1);
$age = (string)$differ ->y;
$trans['emp_age']= $age;$trans['fixed_basic']= round($trans['fixed_gross']*(40/100));$trans['fixed_hra']= round(($trans['fixed_gross']*(30/100)));$trans['fixed_da']= round($trans['fixed_basic']*(50/100));
$trans['fo_allowance']= round(($trans['fixed_da']*(50/100)));
$x = round($trans['yearly_ctc']/12);
$trans['fixed_gross']= $x;$a = $trans['pf']+$trans['esi']+$trans['professional_tax']+$trans['other_deduction']+$trans['emp_esi']+$trans['employer_pf'];
$trans['total_deductions']= $a;
}
if((int)$trans["role"] === 2){
$date_1 = new DateTime($trans['date_of_birth']);
$date_2 = new DateTime(date('Y-m-d') );
$differ = $date_2->diff($date_1);
$age = (string)$differ ->y;
$trans['emp_age']= $age;$trans['fixed_basic']= round($trans['fixed_gross']*(40/100));$trans['fixed_hra']= round(($trans['fixed_gross']*(30/100)));$trans['fixed_da']= round($trans['fixed_basic']*(50/100));
$trans['fo_allowance']= round(($trans['fixed_da']*(50/100)));
$x = round($trans['yearly_ctc']/12);
$trans['fixed_gross']= $x;$a = $trans['pf']+$trans['esi']+$trans['professional_tax']+$trans['other_deduction']+$trans['emp_esi']+$trans['employer_pf'];
$trans['total_deductions']= $a;
}
if((int)$trans["role"] === 3){
$date_1 = new DateTime($trans['date_of_birth']);
$date_2 = new DateTime(date('Y-m-d') );
$differ = $date_2->diff($date_1);
$age = (string)$differ ->y;
$trans['emp_age']= $age;$trans['fixed_basic']= round($trans['fixed_gross']*(40/100));$trans['fixed_hra']= round(($trans['fixed_gross']*(30/100)));$trans['fixed_da']= round($trans['fixed_basic']*(50/100));
$trans['fo_allowance']= round(($trans['fixed_da']*(50/100)));
$x = round($trans['yearly_ctc']/12);
$trans['fixed_gross']= $x;$a = $trans['pf']+$trans['esi']+$trans['professional_tax']+$trans['other_deduction']+$trans['emp_esi']+$trans['employer_pf'];
$trans['total_deductions']= $a;
}
if((int)$trans["role"] === 4){
$date_1 = new DateTime($trans['date_of_birth']);
$date_2 = new DateTime(date('Y-m-d') );
$differ = $date_2->diff($date_1);
$age = (string)$differ ->y;
$trans['emp_age']= $age;$trans['fixed_basic']= round($trans['fixed_gross']*(40/100));$trans['fixed_hra']= round(($trans['fixed_gross']*(30/100)));$trans['fixed_da']= round($trans['fixed_basic']*(50/100));
$trans['fo_allowance']= round(($trans['fixed_da']*(50/100)));
$a = $trans['pf']+$trans['esi']+$trans['professional_tax']+$trans['other_deduction']+$trans['emp_esi']+$trans['employer_pf'];
$trans['total_deductions']= $a;
}
$trans_array[$employee_code] = $trans;
}
return $trans_array;
}
}
?>