Esempio n. 1
0
 public function action_create()
 {
     if (Input::method() == 'POST') {
         $val = Model_Salary::validate('create');
         if ($val->run()) {
             $salary = Model_Salary::forge(array('employee_id' => Input::post('employee_id'), 'month' => Input::post('month'), 'year' => Input::post('year'), 'pf_applicable' => Input::post('pf_applicable'), 'pf_date' => Input::post('pf_date'), 'pf_scheme' => Input::post('pf_scheme'), 'pf_number' => Input::post('pf_number'), 'gross' => Input::post('gross'), 'sdxo' => Input::post('sdxo'), 'pf_adjust' => Input::post('pf_adjust'), 'basic' => Input::post('basic'), 'hra' => Input::post('hra'), 'lta' => Input::post('lta'), 'medical' => Input::post('medical'), 'travel' => Input::post('travel'), 'pf_value' => Input::post('pf_value'), 'credit_other' => Input::post('credit_other'), 'bonus1' => Input::post('bonus1'), 'bonus2' => Input::post('bonus2'), 'bonus3' => Input::post('bonus3'), 'leave' => Input::post('leave'), 'misc1' => Input::post('misc1'), 'misc2' => Input::post('misc2'), 'misc3' => Input::post('misc3'), 'income_tax' => Input::post('income_tax'), 'net' => Input::post('net')));
             if ($salary and $salary->save()) {
                 Session::set_flash('success', 'Added salary #' . $salary->id . '.');
                 Response::redirect('salaries');
             } else {
                 Session::set_flash('error', 'Could not save salary.');
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "Salaries";
     $this->template->content = View::forge('salaries/create');
 }
Esempio n. 2
0
 public function action_create($id = null)
 {
     parent::has_access("add_salary");
     is_null($id) and Response::redirect('salaries');
     $data['employees'] = Model_Employee::find('all', array('where' => array('id' => $id)));
     $c_basic = Model_Constant::find('first', array('where' => array('name' => 'basic')));
     $var_basic_frac = $c_basic->value;
     $c_hra = Model_Constant::find('first', array('where' => array('name' => 'hra')));
     $var_hra_frac = $c_hra->value;
     $c_pf_adjust = Model_Constant::find('first', array('where' => array('name' => 'pf_adjust')));
     $var_pf_adjust_frac = $c_pf_adjust->value;
     $c_lta = Model_Constant::find('first', array('where' => array('name' => 'lta')));
     $var_lta_frac = $c_lta->value;
     $c_pf = Model_Constant::find('first', array('where' => array('name' => 'pf')));
     $pf = $c_pf->value;
     $c_medical = Model_Constant::find('first', array('where' => array('name' => 'medical')));
     $var_medical = $c_medical->value;
     $c_travel = Model_Constant::find('first', array('where' => array('name' => 'travel')));
     $var_travel = $c_travel->value;
     $data['basic'] = $var_basic_frac;
     $data['hra'] = $var_hra_frac;
     $data['pf_adjust'] = $var_pf_adjust_frac;
     $data['lta'] = $var_lta_frac;
     $data['pf'] = $pf;
     $data['medical'] = $var_medical;
     $data['travel'] = $var_travel;
     if (Input::method() == 'POST') {
         $val = Model_Salary::validate('create');
         if ($val->run()) {
             $var_pf_applicable = Input::post('pf_applicable');
             $var_month = Input::post('month');
             $var_year = Input::post('year');
             $var_gross = Input::post('gross');
             $var_sdxo = Input::post('sdxo');
             $var_bonus1 = Input::post('bonus1');
             $var_bonus2 = Input::post('bonus2');
             $var_allowance1 = Input::post('allowance1');
             $var_leave = Input::post('leave');
             $var_allowance2 = Input::post('allowance2');
             $var_allowance3 = Input::post('allowance3');
             $var_income_tax = Input::post('income_tax');
             $var_professional_tax = Input::post('professional_tax');
             $var_deduction1 = Input::post('deduction1');
             $var_deduction2 = Input::post('deduction2');
             $var_deduction3 = Input::post('deduction3');
             $var_adj_sdxo = $var_gross - $var_sdxo;
             $var_pf_adjust = Input::post('pf_applicable') == "1" ? $var_adj_sdxo / $var_pf_adjust_frac : $var_adj_sdxo;
             $var_basic = $var_basic_frac * $var_pf_adjust;
             $var_hra = $var_hra_frac * $var_pf_adjust;
             $var_lta = $var_lta_frac * $var_pf_adjust;
             $var_pf_value = Input::post('pf_applicable') == "1" ? $pf * $var_basic : 0;
             $var_credit_other = $var_pf_adjust - ($var_basic + $var_hra + $var_lta + $var_medical + $var_travel + $var_pf_value);
             $var_credit_total = $var_basic + $var_hra + $var_lta + $var_medical + $var_travel + $var_pf_value + $var_credit_other + $var_leave + $var_bonus1 + $var_bonus2 + $var_allowance1 + $var_allowance2 + $var_allowance3;
             $var_total_debit = $var_professional_tax + $var_income_tax + $var_pf_value + $var_deduction1 + $var_deduction2 + $var_deduction3;
             $var_net = $var_credit_total - $var_total_debit;
             $salary = Model_Salary::forge(array('employee_id' => $id, 'month' => $var_month, 'year' => $var_year, 'lock' => 'false', 'pf_applicable' => $var_pf_applicable, 'gross' => $var_gross, 'sdxo' => $var_sdxo, 'pf_adjust' => $var_pf_adjust, 'basic' => $var_basic, 'hra' => $var_hra, 'lta' => $var_lta, 'medical' => $var_medical, 'travel' => $var_travel, 'pf_value' => $var_pf_value, 'credit_other' => $var_credit_other, 'bonus1' => $var_bonus1, 'bonus2' => $var_bonus2, 'allowance1' => $var_allowance1, 'leave' => $var_leave, 'allowance2' => $var_allowance2, 'allowance3' => $var_allowance3, 'credit_total' => $var_credit_total, 'income_tax' => $var_income_tax, 'professional_tax' => $var_professional_tax, 'deduction1' => $var_deduction1, 'deduction2' => $var_deduction2, 'deduction3' => $var_deduction3, 'total_debit' => $var_total_debit, 'net' => $var_net, 'sick_balance' => 0, 'vacation_balance' => 0));
             if ($salary and $salary->save()) {
                 Session::set_flash('success', 'Added salary for #' . $salary->employee_id . '.');
                 Response::redirect('salaries');
             } else {
                 Session::set_flash('error', 'Could not save employee.');
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "salaries";
     $this->template->content = View::forge('salaries/create', $data);
 }