/**
  * @param REQUEST ticket_id
  * @param GET department_id
  */
 public function assign()
 {
     $ticket = $this->loadTicket($_REQUEST['ticket_id']);
     // Handle any Department choice passed in
     if (isset($_GET['department_id'])) {
         try {
             $currentDepartment = new Department($_GET['department_id']);
         } catch (\Exception $e) {
         }
     }
     if (!isset($currentDepartment)) {
         $currentDepartment = $_SESSION['USER']->getDepartment();
     }
     // Handle any stuff the user posts
     if (isset($_REQUEST['assignedPerson_id'])) {
         try {
             $ticket->setAssignedPerson_id($_REQUEST['assignedPerson_id']);
             $ticket->save();
             // add a record to ticket history
             $history = new TicketHistory();
             $history->setTicket($ticket);
             $history->setAction(new Action('assignment'));
             $history->setEnteredByPerson($_SESSION['USER']);
             $history->setActionPerson($ticket->getAssignedPerson());
             $history->setNotes($_REQUEST['notes']);
             $history->save();
             $history->sendNotification($ticket);
             $this->redirectToTicketView($ticket);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     // Display the view
     $this->template->setFilename('tickets');
     $this->template->blocks['ticket-panel'][] = new Block('departments/chooseDepartmentForm.inc', array('currentDepartment' => $currentDepartment));
     $this->template->blocks['ticket-panel'][] = new Block('tickets/assignTicketForm.inc', array('ticket' => $ticket, 'currentDepartment' => $currentDepartment));
     $this->addStandardInfoBlocks($ticket);
 }
Exemple #2
0
 /**
  * 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();
         // Create the entry in the history log
         $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();
         $this->getCategory()->onTicketAdd($this);
     } 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);
 }