Example #1
0
 /**
  * This locks a timesheet (and all its records) off so that those 
  * records cannot be used in other timesheets. 
  */
 public function lockAction()
 {
     $user = $this->userService->getUserByField('username', $this->_getParam('username'));
     $client = $this->clientService->getClient($this->_getParam('clientid'));
     if ($user == null && $client == null) {
         throw new Exception("User or client not found");
     }
     $item = $this->byId(null, 'ExpenseReport');
     $this->expenseService->lockExpenseReport($item);
     if ($user) {
         $this->redirect('expense', 'listforuser', array('username' => $user->username));
     } else {
         if ($client) {
             $this->redirect('client', 'view', array('id' => $client->id, '#expenses'));
         } else {
             $this->redirect('expense', 'editreport', array('id' => $item->id, 'clientid' => $item->clientid, 'username' => $item->username));
         }
     }
 }