コード例 #1
0
ファイル: Dashboard.php プロジェクト: nirix-old/ticketer
 public function indexAction()
 {
     $information = ['tickets' => []];
     // Tickets
     $information['tickets']['open'] = Ticket::select()->where('is_closed = ?', 0)->rowCount();
     $information['tickets']['resolved'] = Ticket::select()->where('is_closed = ?', 1)->rowCount();
     $information['tickets']['total'] = $information['tickets']['open'] + $information['tickets']['resolved'];
     // Tickets
     $information['users']['newest'] = User::select()->orderBy('id', 'DESC')->fetch();
     $information['users']['total'] = User::select('id')->rowCount();
     $this->set(compact('information'));
 }
コード例 #2
0
ファイル: Tickets.php プロジェクト: nirix-old/ticketer
 /**
  * Update ticket.
  *
  * @param integer $id
  */
 public function updateAction($id)
 {
     if (Request::method() != 'post') {
         Request::redirectTo('/');
     }
     // Get the ticket
     $ticket = Ticket::find($id);
     // Ticket changes
     $changes = [];
     foreach (['department', 'status', 'priority'] as $property) {
         if ($ticket->{$property . '_id'} != Request::$post[$property]) {
             $change = ['property' => $property];
             switch ($property) {
                 case 'department':
                 case 'status':
                     $class = "\\Ticketer\\Models\\" . Inflector::classify($property);
                     $change['from'] = $class::find($ticket->{"{$property}_id"})->name;
                     $change['to'] = $class::find(Request::$post[$property])->name;
                     break;
                 case 'priority':
                     $change['from'] = getPriorityName($ticket->priority_id);
                     $change['to'] = getPriorityName(Request::$post['priority']);
                     break;
             }
             $changes[] = $change;
         }
     }
     // Update ticket properties
     $ticket->set(['department_id' => Request::$post['department'], 'status_id' => Request::$post['status'], 'priority_id' => Request::$post['priority']]);
     // Ticket reply
     $reply = new TicketReply(['message' => Request::$post['message'], 'user_id' => $this->currentUser->id, 'ticket_id' => $ticket->id, 'changes' => json_encode($changes)]);
     if (count($changes) or Request::$post['message'] != '') {
         if ($reply->save() and $ticket->save()) {
             Request::redirectTo($ticket->href());
         }
     } else {
         Request::redirectTo($ticket->href());
     }
     $this->set(compact('ticket', 'reply'));
     $this->render['view'] = 'tickets/view';
 }