예제 #1
0
파일: banks.php 프로젝트: cloudetm/payroll
 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');
 }
예제 #2
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('banks');
     if ($bank = Model_Bank::find($id)) {
         $bank->delete();
         Session::set_flash('success', 'Deleted bank #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete bank #' . $id);
     }
     Response::redirect('banks');
 }