Ejemplo n.º 1
0
 /**
  * @param REQUEST ticket_id
  */
 public function changeStatus()
 {
     $ticket = $this->loadTicket($_REQUEST['ticket_id']);
     if (isset($_POST['status'])) {
         try {
             $substatus_id = !empty($_POST['substatus_id']) ? $_POST['substatus_id'] : null;
             $ticket->setStatus($_POST['status'], $substatus_id);
             // add a record to ticket history
             $action = new Action($_POST['status']);
             $history = new TicketHistory();
             $history->setTicket($ticket);
             $history->setAction($action);
             $history->setNotes($_POST['notes']);
             if (defined('CLOSING_COMMENT_REQUIRED_LENGTH')) {
                 if ($action->getName() == 'closed') {
                     if (strlen($history->getNotes()) < CLOSING_COMMENT_REQUIRED_LENGTH) {
                         throw new \Exception('tickets/missingClosingComment');
                     }
                     // Display an alert, reminding them to respond to any citizens
                     $citizens = $ticket->getReportedByPeople();
                     if (count($citizens)) {
                         $_SESSION['errorMessages'][] = new \Exception('tickets/closingResponseReminder');
                     }
                 }
             }
             $history->save();
             $ticket->save();
             $this->redirectToTicketView($ticket);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     // Display the view
     $this->template->setFilename('tickets');
     $this->template->blocks['ticket-panel'][] = new Block('tickets/changeStatusForm.inc', array('ticket' => $ticket));
     $this->template->blocks['ticket-panel'][] = new Block('tickets/responseReminder.inc', array('ticket' => $ticket));
     $this->addStandardInfoBlocks($ticket);
 }
Ejemplo n.º 2
0
 /**
  * Does all the database work for TicketController::changeStatus
  *
  * Saves the ticket and creates history entries for the status change
  *
  * This function calls save() as needed.  After using this function,
  * there's no need to make an additional save() call.
  *
  * @param array $post[status=>'', 'substatus_id'=>'', 'notes'=>'']
  */
 public function handleChangeStatus($post)
 {
     $substatus_id = !empty($post['substatus_id']) ? $post['substatus_id'] : null;
     $this->setStatus($post['status'], $substatus_id);
     // add a record to ticket history
     $action = new Action($post['status']);
     $history = new TicketHistory();
     $history->setTicket($this);
     $history->setAction($action);
     $history->setNotes($post['notes']);
     if (defined('CLOSING_COMMENT_REQUIRED_LENGTH')) {
         if ($action->getName() === 'closed') {
             if (strlen($history->getNotes()) < CLOSING_COMMENT_REQUIRED_LENGTH) {
                 throw new \Exception('tickets/missingClosingComment');
             }
         }
     }
     $history->save();
     $this->save();
 }