/** * @param REQUEST ticket_id * @param REQUEST person_id */ public function refer() { $ticket = $this->loadTicket($_REQUEST['ticket_id']); if (isset($_REQUEST['person_id'])) { try { $person = new Person($_REQUEST['person_id']); } catch (\Exception $e) { } } // Handle any stuff the user posts if (isset($_POST['referredPerson_id'])) { try { $ticket->setReferredPerson_id($_POST['referredPerson_id']); $ticket->save(); // add a record to ticket history $history = new TicketHistory(); $history->setTicket($ticket); $history->setAction(new Action('referral')); $history->setEnteredByPerson($_SESSION['USER']); $history->setActionPerson($ticket->getReferredPerson()); $history->setNotes($_POST['notes']); $history->save(); $this->redirectToTicketView($ticket); } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } } // Display the view $this->template->setFilename('tickets'); if (isset($person)) { $this->template->blocks['ticket-panel'][] = new Block('tickets/referTicketForm.inc', array('ticket' => $ticket, 'person' => $person)); } else { $_REQUEST['return_url'] = BASE_URL . '/tickets/refer?ticket_id=' . $ticket->getId(); $this->template->blocks['ticket-panel'][] = new Block('people/searchForm.inc'); } $this->addStandardInfoBlocks($ticket); }
/** * 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(); }
/** * @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); }
/** * Does all the database work for TicketController::add * * Saves the ticket, the issue, and creates history entries * for the open and assignment actions. * * This function calls save() as needed. After using this function, * there's no need to make an additional save() call. * * @param array $post */ public function handleAdd($post) { $zend_db = Database::getConnection(); $zend_db->getDriver()->getConnection()->beginTransaction(); try { $this->handleUpdate($post); // We must add an issue to the ticket for validation to pass $issue = new Issue(); $issue->handleUpdate($post); $this->issues = array($issue); if (!$this->getEnteredByPerson_id() && $issue->getReportedByPerson_id()) { $this->setEnteredByPerson_id($issue->getReportedByPerson_id()); } $this->save(); $issue->setTicket($this); $issue->save(); $history = new TicketHistory(); $history->setTicket($this); $history->setAction(new Action('open')); if ($this->getEnteredByPerson_id()) { $history->setEnteredByPerson_id($this->getEnteredByPerson_id()); } $history->save(); $history = new TicketHistory(); $history->setTicket($this); $history->setAction(new Action('assignment')); $history->setActionPerson_id($this->getAssignedPerson_id()); if (!empty($post['notes'])) { $history->setNotes($post['notes']); } if ($this->getEnteredByPerson_id()) { $history->setEnteredByPerson_id($this->getEnteredByPerson_id()); } $history->save(); } catch (\Exception $e) { $zend_db->getDriver()->getConnection()->rollback(); $search = new Search(); $search->delete($this); $search->solrClient->commit(); throw $e; } $zend_db->getDriver()->getConnection()->commit(); $history->sendNotification($this); }