Ejemplo n.º 1
0
 function search()
 {
     if (($keyword = $this->get('keyword', '')) == '') {
         $this->redirect('');
     }
     $oTicket = new APP_Model_Ticket();
     $tickets = $oTicket->getTickets(compact('keyword'));
     $this->load('home/index', compact('tickets', 'keyword'));
 }
Ejemplo n.º 2
0
 function getAddEditFormStructure($p_sMode = 'create', array $p_aOptions = array())
 {
     $structure = array('fields' => array('title' => array('type' => 'text', 'label' => 'Title', 'size' => 60), 'category_id' => array('type' => 'dropdown', 'label' => 'Category', 'options' => array()), 'ticket_type' => array('type' => 'dropdown', 'label' => 'Type', 'options' => array()), 'severity' => array('type' => 'dropdown', 'label' => 'Severity', 'options' => array()), 'status' => array('type' => 'dropdown', 'label' => 'Status', 'options' => array()), 'version' => array('type' => 'dropdown', 'label' => 'Version', 'options' => array()), 'assigned_user_id' => array('type' => 'dropdown', 'label' => 'Assign', 'options' => array()), 'content' => array('type' => 'textarea', 'label' => 'Description', 'rows' => 10, 'cols' => 40), 'submit' => array('type' => 'submit', 'label' => '', 'value' => 'Create Ticket')), 'rules' => array('title' => array('type' => 'required', 'message' => 'Title cannot be blank'), 'content' => array('type' => 'required', 'message' => 'You must enter a description')));
     if (isset($p_aOptions['isAdmin']) && $p_aOptions['isAdmin'] === false) {
         unset($structure['fields']['assigned_user_id']);
         unset($structure['fields']['severity']);
         unset($structure['fields']['status']);
         unset($structure['fields']['version']);
     } else {
         $structure['fields']['severity']['options'] = array('minor' => 'minor', 'major' => 'major', 'critical' => 'critical');
         $structure['fields']['status']['options'] = array('open' => 'open', 'assigned' => 'assigned', 'closed' => 'closed');
         $oUser = new APP_Model_User();
         $oTicket = new APP_Model_Ticket();
         $structure['fields']['version']['options'] = $this->convertGetListToDropdown($oTicket->getVersionsForFormStructure(), 'version');
         $structure['fields']['assigned_user_id']['options'] = $this->convertGetListToDropdown($oUser->getList(), array('first_name', ' ', 'last_name'));
     }
     $oTicketCat = new APP_Model_Ticket_Category();
     $structure['fields']['ticket_type']['options'] = array('feature_request' => 'Feature request', 'bug' => 'Bug', 'enhancement' => 'Enhancement');
     $structure['fields']['category_id']['options'] = $this->convertGetListToDropdown($oTicketCat->getList(), 'title');
     return $structure;
 }
Ejemplo n.º 3
0
 /**
  *
  * @param string $p_sMode The Mode (Create or Edit)
  * @return void
  */
 protected function ticketAddEdit($p_sMode = 'create')
 {
     $bEdit = $p_sMode == 'edit';
     $oTicket = new APP_Model_Ticket();
     $oForm = new PPI_Model_Form();
     $oForm->init('admin_ticket_addedit');
     $oForm->setFormStructure($oTicket->getAdminAddEditFormStructure($p_sMode));
     if ($oForm->isSubmitted() && $oForm->isValidated()) {
         $aSubmitValues = $oForm->getSubmitValues();
         if (!$bEdit) {
             $aSubmitValues['user_id'] = $this->getAuthData(false)->id;
             $aSubmitValues['created'] = time();
         }
         // Edit mode to set the primary key so that it performs an update
         if ($bEdit && ($iTicketID = $this->oInput->get($p_sMode)) > 0) {
             $aSubmitValues[$oTicket->getPrimaryKey()] = $iTicketID;
         }
         // Put the record (insert/update)
         $oTicket->putRecord($aSubmitValues);
         $this->setFlashMessage('Ticket successfully ' . ($bEdit ? 'updated' : 'created') . '.');
         $this->redirect('admin/ticket');
     }
     if ($bEdit === true) {
         if (($iTicketID = $this->oInput->get('edit', 0)) < 1) {
             throw new PPI_Exception('Invalid User ID: ' . $iTicketID);
         }
         // Set the defaults here
         $oForm->setDefaults($oTicket->find($iTicketID));
     }
     $aViewVars = array('bEdit' => $bEdit, 'formBuilder' => $oForm->getRenderInformation(), 'leftMenu' => true);
     $this->adminLoad('admin/ticket_addedit', $aViewVars);
 }
Ejemplo n.º 4
0
 public function delete()
 {
     $this->loginCheck();
     $iTicketID = $this->_input->get('delete');
     $oTicket = new APP_Model_Ticket();
     $oTicket->delete($iTicketID);
     $this->redirect('ticket');
 }