Exemplo n.º 1
0
 public function action_edit($id = null)
 {
     parent::has_access("create_employee");
     is_null($id) and Response::redirect('employees/view' . $id);
     if (!($bank = Model_Bank::find('first', array('where' => array('employee_id' => $id))))) {
         Session::set_flash('error', 'Could not find user #' . $id);
         Response::redirect('employees/view/' . $id);
     }
     if (Input::method() == 'POST') {
         $bank->account_no = Input::post('account_no');
         $bank->account_type = Input::post('account_type');
         $bank->branch = Input::post('branch');
         $bank->city = Input::post('city');
         $bank->state = Input::post('state');
         $bank->ifsc_code = Input::post('ifsc_code');
         $bank->payment_type = Input::post('payment_type');
         if ($bank->save()) {
             Session::set_flash('success', 'Updated bank details #' . $id);
             Response::redirect('employees/view/' . $id);
         } else {
             Session::set_flash('error', 'Could not update bank #' . $id);
         }
     }
     $this->template->title = "Banks";
     $this->template->content = View::forge('banks/edit');
 }
Exemplo n.º 2
0
 public function action_process($month = null, $year = null)
 {
     parent::has_access("add_salary");
     (is_null($month) or is_null($year)) and Response::redirect('salaries');
     if ($month == 1) {
         $m = 12;
         $y = $year - 1;
     } else {
         $m = $month - 1;
         $y = $year;
     }
     $salaries = Model_Salary::find('all', array('where' => array(array('month' => $m), array('year' => $y))));
     $data['month'] = $month;
     $data['year'] = $year;
     foreach ($salaries as $salary) {
         $emp = new Model_Salary();
         $emp->employee_id = $salary->employee_id;
         $emp->month = $month;
         $emp->year = $year;
         $emp->lock = 'false';
         $emp->pf_applicable = $salary->pf_applicable;
         $emp->gross = $salary->gross;
         $emp->sdxo = $salary->sdxo;
         $emp->pf_adjust = $salary->pf_adjust;
         $emp->basic = $salary->basic;
         $emp->hra = $salary->hra;
         $emp->lta = $salary->lta;
         $emp->medical = $salary->medical;
         $emp->travel = $salary->travel;
         $emp->pf_value = $salary->pf_value;
         $emp->credit_other = $salary->credit_other;
         $emp->bonus1 = $salary->bonus1;
         $emp->bonus2 = $salary->bonus2;
         $emp->allowance1 = $salary->allowance1;
         $emp->leave = $salary->leave;
         $emp->allowance2 = $salary->allowance2;
         $emp->allowance3 = $salary->allowance3;
         $emp->credit_total = $salary->credit_total;
         $emp->income_tax = $salary->income_tax;
         $emp->professional_tax = $salary->professional_tax;
         $emp->deduction1 = $salary->deduction1;
         $emp->deduction2 = $salary->deduction2;
         $emp->deduction3 = $salary->deduction3;
         $emp->total_debit = $salary->total_debit;
         $emp->net = $salary->net;
         $emp->sick_balance = 0;
         $emp->vacation_balance = 0;
         $emp->save();
     }
     Response::redirect('salaries');
 }
Exemplo n.º 3
0
 public function action_delete($id = null)
 {
     parent::has_access("add_leave");
     is_null($id) and Response::redirect('leaves');
     if ($leave = Model_Leave::find($id)) {
         $leave->delete();
         Session::set_flash('success', 'Deleted leave #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete leave #' . $id);
     }
     Response::redirect('leaves/view/' . $leave->employee_id);
 }
Exemplo n.º 4
0
 public function action_delete($id = null)
 {
     parent::has_access("archive_employee");
     is_null($id) and Response::redirect('employees');
     if ($employee = Model_Employee::find($id)) {
         $employee->activity_status = "delete";
         if ($employee->save()) {
             Session::set_flash('success', 'Deleted employee #' . $id);
         } else {
             Session::set_flash('error', 'Could not delete employee #' . $id);
         }
     } else {
         Session::set_flash('error', 'Could not find employee #' . $id);
     }
     if ($salaries = Model_Salary::find('all', array('where' => array('employee_id' => $id)))) {
         foreach ($salaries as $salary) {
             $salary->lock = "delete";
             $salary->save();
         }
     } else {
         // Session::set_flash('error', 'Could not delete employee #' . $id);
     }
     Response::redirect('employees/viewarchive');
 }
Exemplo n.º 5
0
 public function action_delete($id = null)
 {
     parent::has_access("add_user");
     is_null($id) and Response::redirect('users');
     if ($user = Model_User::find($id)) {
         $user->delete();
         Session::set_flash('success', 'Deleted user #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete user #' . $id);
     }
     Response::redirect('users');
 }