示例#1
0
 public function action_close()
 {
     $user = Auth::instance()->get_user();
     $ticket_id = $this->request->param('id', 0);
     //getting the parent ticket
     $ticket = new Model_Ticket();
     //only supportadmin can close any ticket
     if (!$user->has_access('supportadmin')) {
         $ticket->where('id_user', '=', $user->id_user);
     }
     $ticket->where('id_ticket', '=', $ticket_id)->where('id_ticket_parent', 'IS', NULL)->limit(1)->find();
     if (!$ticket->loaded()) {
         Alert::set(Alert::ERROR, __('Not your ticket.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
     } else {
         //close ticket
         $ticket->status = Model_Ticket::STATUS_CLOSED;
         $ticket->save();
         Alert::set(Alert::SUCCESS, __('Ticket closed.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
     }
 }