Ejemplo n.º 1
0
 function dolist()
 {
     $ticketid = FSS_Input::getInt('ticketid');
     $ticket = new SupportTicket();
     $ticket->load($ticketid);
     echo SupportCanned::CannedList($ticket);
     exit;
 }
Ejemplo n.º 2
0
 function loadFromRows($rows)
 {
     foreach ($rows as $row) {
         $ticket = new SupportTicket();
         $ticket->loadFromRow($row);
         $this->ids[] = $ticket->id;
         $this->tickets[] = $ticket;
         $this->tickets_indexed[$ticket->id] = $ticket;
         static::$ref_lookup[$ticket->id] = $ticket->id . "-" . strtolower(preg_replace("/[^A-Za-z0-9]/", '-', $ticket->title));
     }
 }
Ejemplo n.º 3
0
 function preview()
 {
     $this->ticketid = FSS_Input::getInt('ticketid');
     $this->sigid = FSS_Input::getInt('sigid');
     $ticket = new SupportTicket();
     $ticket->load($this->ticketid);
     $ticket->loadAll();
     $this->ticket = $ticket;
     $this->signature = SupportCanned::AppendSig($this->sigid, $this->ticket);
     include $this->view->snippet(JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'views' . DS . 'admin_support' . DS . 'snippet' . DS . '_signature_preview.php');
     return true;
 }
Ejemplo n.º 4
0
 function process()
 {
     $posted = JRequest::get('post');
     $ticket_ids = array();
     foreach ($posted as $var => $value) {
         if (substr($var, 0, 7) == "ticket_") {
             $ticket_id = (int) substr($var, 7);
             if ($ticket_id > 0) {
                 $ticket_ids[$ticket_id] = $ticket_id;
             }
         }
     }
     if (count($ticket_ids) == 0) {
         return;
     }
     $db = JFactory::getDBO();
     $tickets = array();
     foreach ($ticket_ids as $ticketid) {
         $ticket = new SupportTicket();
         if ($ticket->Load($ticketid)) {
             $ticket->is_batch = true;
             $tickets[$ticketid] = $ticket;
         } else {
             unset($ticket_ids[$ticket_id]);
         }
     }
     $new_pri = FSS_Input::getInt('batch_priority');
     if ($new_pri > 0) {
         foreach ($ticket_ids as $ticketid) {
             $tickets[$ticketid]->updatePriority($new_pri);
         }
     }
     $new_status = FSS_Input::getInt('batch_status');
     if ($new_status > 0) {
         foreach ($ticket_ids as $ticketid) {
             $tickets[$ticketid]->updateStatus($new_status);
         }
     }
     if (FSS_Input::getString('batch_handler') != "") {
         foreach ($ticket_ids as $ticketid) {
             $tickets[$ticketid]->assignHandler(FSS_Input::getInt('batch_handler'));
         }
     }
     $should_delete = FSS_Input::getCmd('batch_status');
     if ($should_delete == "delete") {
         foreach ($ticket_ids as $ticketid) {
             $tickets[$ticketid]->delete();
         }
     }
 }
Ejemplo n.º 5
0
 function delete()
 {
     if (!$this->view->can_EditTicket()) {
         return;
     }
     // load in tickets to do
     $ticketid = FSS_Input::getInt('ticketid');
     $fileid = FSS_Input::getInt('fileid');
     $ticket = new SupportTicket();
     if ($ticket->load($ticketid)) {
         $ticket->deleteAttach($fileid);
     }
     JFactory::getApplication()->redirect(FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticketid, false));
     exit;
 }
Ejemplo n.º 6
0
 function display($tpl = NULL)
 {
     $this->ticket_ids = FSS_Input::getString("ticketids");
     $this->ticket_ids = explode(":", trim($this->ticket_ids));
     $this->tickets = array();
     foreach ($this->ticket_ids as $ticketid) {
         $ticket = new SupportTicket();
         if ($ticket->load($ticketid)) {
             $ticket->loadAll();
             $this->tickets[] = $ticket;
         }
     }
     $this->print = FSS_Input::getCmd('print');
     $this->_display();
 }
Ejemplo n.º 7
0
 public function actionTicket()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect('/');
     }
     $request = Yii::app()->request;
     $ticketid = $request->getParam('id');
     if (!$ticketid) {
         $this->redirect('/');
     }
     $user = Yii::app()->user->data();
     $model = new CreateTicketForm();
     $formData = $request->getPost(get_class($model), false);
     if ($formData) {
         $model->attributes = $formData;
         if (!$model->hasErrors()) {
             $newticket_message = new SupportTicketMessage();
             $newticket_message->body = $model->body;
             if (!Yii::app()->user->isGuest) {
                 $newticket_message->id_ticket = $ticketid;
                 $newticket_message->id_user = $user->id;
             }
             if (!$newticket_message->save()) {
                 Yii::app()->user->setFlash('error', Yii::t('translation', 'Unable to create ticket'));
             }
             Yii::app()->user->setFlash('success', Yii::t('translation', 'Ticket #{ticket_id} Updated', array('{ticket_id}' => $ticketid)));
         }
     }
     $messages = SupportTicketMessage::model()->findAllByAttributes(array('id_ticket' => $ticketid));
     $this->render('ticket', array('model' => SupportTicket::model()->findByPk($ticketid), 'updatemodel' => $model, 'user' => $user, 'messages' => $messages));
 }
Ejemplo n.º 8
0
 public function loadModel($id)
 {
     $model = SupportTicket::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 9
0
 function delete()
 {
     // load in tickets to do
     $ticketid = FSS_Input::getInt('ticketid');
     $tickets = FSS_Input::getCmd('tickets');
     $def_archive = FSS_Ticket_Helper::GetStatusID('def_archive');
     if ($ticketid > 0) {
         $ticket = new SupportTicket();
         if ($ticket->load($ticketid)) {
             $ticket->delete();
         }
     } else {
         if ($tickets != '') {
             $tickets = new SupportTickets();
             $tickets->limitstart = 0;
             $tickets->limit = 100;
             $tickets->loadTicketsByStatus($tickets);
             foreach ($tickets->tickets as $ticket) {
                 $ticket->delete();
             }
         }
     }
     JFactory::getApplication()->redirect($_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 10
0
 /**
  * Build and return admin interface
  *
  * Any module providing an admin interface is required to have this function, which
  * returns a string containing the (x)html of it's admin interface.
  * @return string
  */
 function getAdminInterface()
 {
     require_once 'include/SupportTicket.php';
     $ticket = new SupportTicket();
     $form = $ticket->getAddEditForm();
     if ($form->validate()) {
         header('Location: /admin/Support');
         die;
     }
     switch (@$_REQUEST['section']) {
         case 'bug':
             $bugid = $_REQUEST['id'];
             $ticket = new SupportTicket($bugid);
             $soapdetails = $ticket->getSoapBugDetails();
             $this->smarty->assign('ticket', $soapdetails);
             return $this->smarty->fetch('admin/ticket.tpl');
             break;
         default:
             $tickets = SupportTicket::getUserSupportTickets();
             $this->smarty->assign('tickets', $tickets);
             $this->smarty->assign('form', $form);
             return $this->smarty->fetch('admin/support.tpl');
     }
 }
Ejemplo n.º 11
0
 public function manageTickets($app)
 {
     if (!$app->user->isLoggedIn() || !$app->user->isRank('Support Technician')) {
         $app->logger->log('Unauthorized access to Admin CP', 'ALERT', array(), 'admin');
         $app->output->redirect('/');
     }
     $tickets = SupportTicket::find('all', array('order' => 'last_reply DESC'));
     $app->output->addBreadcrumb('admin', 'Dashboard');
     $app->output->addBreadcrumb('admin/tickets', 'Manage Support Tickets');
     $app->output->setTitle('Manage Support Tickets');
     $app->output->setActiveTab('admin');
     $app->output->render('admin.tickets', ['tickets' => $tickets]);
 }
Ejemplo n.º 12
0
 static function attachDownload($ticketid, $fileid, $for_user = false)
 {
     $ticket = new SupportTicket();
     if ($ticket->load($ticketid, $for_user)) {
         $attach = $ticket->getAttach($fileid);
         if (substr($attach->diskfile, 0, 7) == "http://" || substr($attach->diskfile, 0, 8) == "https://") {
             header('Location: ' . $attach->diskfile);
             exit;
         }
         $file = JPATH_SITE . DS . FSS_Settings::get('attach_location') . DS . "support" . DS . $attach->diskfile;
         $display_filename = FSS_Helper::basename($attach->filename);
         if (!$for_user) {
             $user = JFactory::GetUser($attach->user_id);
             $type = FSS_Settings::get('support_filename');
             switch ($type) {
                 case 1:
                     $display_filename = $user->username . "_" . $display_filename;
                     break;
                 case 2:
                     $display_filename = $user->username . "_" . date("Y-m-d") . "_" . $display_filename;
                     break;
                 case 3:
                     $display_filename = date("Y-m-d") . "_" . $user->username . "_" . $display_filename;
                     break;
                 case 4:
                     $display_filename = date("Y-m-d") . "_" . $display_filename;
                     break;
             }
         }
         require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'files.php';
         FSS_File_Helper::DownloadFile($file, $display_filename);
     }
     exit;
 }
Ejemplo n.º 13
0
 function saveTicket()
 {
     $subject = FSS_Input::getString('subject');
     $body = FSS_Input::getBBCode('body');
     $prodid = FSS_Input::getInt('prodid');
     $deptid = FSS_Input::getInt('deptid');
     $catid = FSS_Input::getInt('catid');
     $priid = FSS_Input::getInt('priid');
     $handler = FSS_Input::getInt('handler');
     $user = JFactory::getUser();
     $userid = $user->get('id');
     $name = "";
     $session = JFactory::getSession();
     $this->admin_create = 0;
     if ($session->Get('admin_create')) {
         $this->admin_create = $session->Get('admin_create');
     }
     if ($this->admin_create == 1) {
         $this->admin_create = 1;
         $userid = $session->Get('admin_create_user_id');
     } else {
         if ($this->admin_create == 2) {
             $userid = 0;
         }
     }
     $db = JFactory::getDBO();
     if ($priid < 1) {
         $priid = FSS_Settings::get('support_default_priority');
     }
     $ticket['subject'] = $subject;
     $ticket['body'] = $body;
     $ticket['priid'] = $priid;
     $ticket['handler'] = $handler;
     $ok = true;
     $errors['subject'] = '';
     $errors['body'] = '';
     $errors['cat'] = '';
     $errors['captcha'] = '';
     $fields = FSSCF::GetCustomFields(0, $prodid, $deptid);
     if (FSS_Settings::get('support_subject_message_hide') == "subject") {
         $ticket['subject'] = substr(strip_tags($ticket['body']), 0, 40);
         $subject = $ticket['subject'];
     }
     if (FSS_Settings::get('support_altcat')) {
         $cats = $this->get('Cats');
         if (count($cats) > 0 && FSS_Input::getInt('catid') < 1) {
             $errors['cat'] = JText::_("YOU_MUST_SELECT_A_CATEGORY");
             $ok = false;
         }
     }
     if ($body == "" && FSS_Settings::get('support_subject_message_hide') != "message" && FSS_Settings::get('support_subject_message_hide') != "both") {
         $errors['body'] = JText::_("YOU_MUST_ENTER_A_MESSAGE_FOR_YOUR_SUPPORT_TICKET");
         $ok = false;
     }
     if (!FSSCF::ValidateFields($fields, $errors)) {
         $ok = false;
     }
     $email = "";
     $password = "";
     $now = FSS_Helper::CurDate();
     $this->sortCaptchaType();
     $captcha = new FSS_Captcha();
     if (!$captcha->ValidateCaptcha('support_captcha_type')) {
         $errors['captcha'] = JText::_("INVALID_SECURITY_CODE");
         $ok = false;
     }
     if ($userid < 1) {
         $email = FSSJ3Helper::getEscaped($db, $session->Get('ticket_email'));
         if ($session->Get('ticket_name')) {
             $name = FSSJ3Helper::getEscaped($db, $session->Get('ticket_name'));
         }
         if ($email == "" && $this->admin_create != 2) {
             $ok = false;
         } else {
             $password = FSS_Helper::createRandomPassword();
             $session->Set('ticket_pass', $password);
         }
     }
     // assign handler to ticket
     $admin_id = $handler;
     if (!$admin_id) {
         $admin_id = FSS_Ticket_Helper::AssignHandler($prodid, $deptid, $catid);
     }
     $now = FSS_Helper::CurDate();
     $def_open = FSS_Ticket_Helper::GetStatusID('def_open');
     if (FSS_Settings::get('support_subject_format') != "") {
         $parser = new FSSParser();
         foreach ($_POST as $var => $value) {
             $parser->setVar($var, FSS_Input::GetString($var));
         }
         foreach ($fields as $field) {
             $parser->setVar('custom_' . $field['alias'], FSS_Input::GetString('custom_' . $field['id']));
         }
         $user = JFactory::getUser($userid);
         $parser->setVar('userid', $userid);
         $parser->setVar('username', $user->username);
         $parser->setVar('name', $user->name);
         $parser->setVar('email', $user->email);
         $parser->setVar('subject', $subject);
         $parser->SetVar('product', FSS_EMail::GetProduct($prodid));
         $parser->SetVar('department', FSS_EMail::GetDepartment($deptid));
         $parser->SetVar('category', FSS_EMail::Getcategory($catid));
         $parser->SetVar('date', FSS_Helper::Date($now, FSS_DATE_SHORT));
         $parser->SetVar('time', FSS_Helper::Date($now, FSS_DATETIME_SHORT));
         $parser->SetTemplate(FSS_Settings::get('support_subject_format'));
         $result = $parser->Parse();
         if (trim($result) == "") {
             $sj = array();
             foreach ($fields as $field) {
                 $sj[] = FSS_Input::GetString('custom_' . $field['id']);
             }
             $result = implode(", ", $sj);
         }
         $ticket['subject'] = $result;
         $subject = $ticket['subject'];
         if ($subject == "") {
             $errors['subject'] = JText::_("YOU_MUST_ENTER_A_SUBJECT_FOR_YOUR_SUPPORT_TICKET");
             $ok = false;
         }
     }
     if ($ok) {
         $qry = "INSERT INTO #__fss_ticket_ticket (reference, ticket_status_id, ticket_pri_id, ticket_cat_id, ticket_dept_id, prod_id, title, opened, lastupdate, user_id, admin_id, email, password, unregname, lang) VALUES ";
         $qry .= "('', {$def_open}, '" . FSSJ3Helper::getEscaped($db, $priid) . "', '" . FSSJ3Helper::getEscaped($db, $catid) . "', '" . FSSJ3Helper::getEscaped($db, $deptid) . "', '" . FSSJ3Helper::getEscaped($db, $prodid) . "', '" . FSSJ3Helper::getEscaped($db, $subject) . "', '{$now}', '{$now}', '" . FSSJ3Helper::getEscaped($db, $userid) . "', '" . FSSJ3Helper::getEscaped($db, $admin_id) . "', '{$email}', '" . FSSJ3Helper::getEscaped($db, $password) . "', '{$name}', '" . JFactory::getLanguage()->getTag() . "')";
         $db->setQuery($qry);
         $db->Query();
         $this->ticketid = $db->insertid();
         $ref = FSS_Ticket_Helper::createRef($this->ticketid);
         $session->Set('ticket_reference', $ref);
         $qry = "UPDATE #__fss_ticket_ticket SET reference = '" . FSSJ3Helper::getEscaped($db, $ref) . "' WHERE id = '" . FSSJ3Helper::getEscaped($db, $this->ticketid) . "'";
         $db->setQuery($qry);
         $db->Query();
         if ($this->admin_create) {
             $curuser = JFactory::getUser();
             $premsg = date("Y-m-d H:i:s", strtotime($now) - 1);
             $msg = JText::sprintf('TICKET_OPENED_BY', $curuser->name, $curuser->username);
             $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, posted, admin) VALUES ('";
             $qry .= FSSJ3Helper::getEscaped($db, $this->ticketid) . "','" . FSSJ3Helper::getEscaped($db, $subject) . "','" . FSSJ3Helper::getEscaped($db, $msg) . "','" . FSSJ3Helper::getEscaped($db, $curuser->id) . "','{$premsg}', 6)";
             $db->setQuery($qry);
             $db->Query();
         }
         $qry = "INSERT INTO #__fss_ticket_messages (ticket_ticket_id, subject, body, user_id, posted) VALUES ('";
         $qry .= FSSJ3Helper::getEscaped($db, $this->ticketid) . "','" . FSSJ3Helper::getEscaped($db, $subject) . "','" . FSSJ3Helper::getEscaped($db, $body) . "','" . FSSJ3Helper::getEscaped($db, $userid) . "','{$now}')";
         $db->setQuery($qry);
         $db->Query();
         $messageid = $db->insertid();
         FSSCF::StoreFields($fields, $this->ticketid);
         // store tags if there are any posted
         $tags_input = FSS_Input::getString('tags');
         $parts = explode("|", $tags_input);
         foreach ($parts as $part) {
             $tag = trim($part);
             if (!$tag || $tag == "") {
                 continue;
             }
             $tags[] = $tag;
             $qry = "INSERT INTO #__fss_ticket_tags (ticket_id, tag) VALUES ('" . $this->ticketid . "', '" . $db->escape($tag) . "')";
             $db->setQuery($qry);
             $db->Query();
         }
         $t = new SupportTicket();
         $t->load($this->ticketid, true);
         $files = $t->addFilesFromPost($messageid, $userid);
         $t->stripImagesFromMessage($messageid);
         $subject = FSS_Input::getString('subject');
         $body = FSS_Input::getBBCode('body');
         $action_name = "User_Open";
         $action_params = array('subject' => $subject, 'user_message' => $body, 'files' => $files);
         SupportActions::DoAction($action_name, $t, $action_params);
         // additional users and emails if posted
         if ($this->admin_create > 0) {
             $additionalusers = JRequest::getVar('additionalusers');
             $additionalusers = explode(",", $additionalusers);
             $t->addCC($additionalusers, 0, 0);
             $additionalemails = JRequest::getVar('additionalemails');
             $additionalemails = explode(",", $additionalemails);
             foreach ($additionalemails as $email) {
                 $email = trim($email);
                 if ($email == "") {
                     continue;
                 }
                 $t->addEMailCC($email);
             }
             if ($t->admin_id != JFactory::getUser()->id) {
                 $t->addCC(JFactory::getUser()->id, 1, 0);
             }
         }
         $this->cleanAdminCreate();
         // if related is passed as part of ticket open, relate the 2 tickets
         $related = JRequest::getVar('related');
         if ($related > 0) {
             $t->addRelated($related);
         }
     }
     $this->errors = $errors;
     $this->ticket = $ticket;
     return $ok;
 }
Ejemplo n.º 14
0
 function AttachFiles($ticketid, $userid, $messageid)
 {
     $db = JFactory::getDBO();
     if (empty($this->attachments)) {
         return false;
     }
     if (!is_array($this->attachments)) {
         return false;
     }
     if (count($this->attachments) == 0) {
         return false;
     }
     $now = FSS_Helper::CurDate();
     $st = new SupportTicket();
     $st->load($ticketid);
     foreach ($this->attachments as $filename => &$data) {
         $new = imap_mime_header_decode($filename);
         $filename = @mb_convert_encoding($new[0]->text, "UTF-8", $new[0]->charset);
         $this->Log("Attachment : {$filename} - " . strlen($data));
         $destpath = JPATH_SITE . DS . FSS_Settings::get('attach_location') . DS . 'support' . DS;
         $destname = FSS_File_Helper::makeAttachFilename("support", $filename, date("Y-m-d"), $st, $userid);
         if (JFile::write($destpath . $destname, $data)) {
             $this->Log("Wrote file to {$destname}");
             $qry = "INSERT INTO #__fss_ticket_attach (ticket_ticket_id, filename, diskfile, size, user_id, added, message_id) VALUES ('";
             $qry .= FSSJ3Helper::getEscaped($db, $ticketid) . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $filename) . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $destname) . "',";
             $qry .= "'" . strlen($data) . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $userid) . "',";
             $qry .= "'{$now}', {$messageid} )";
             $db->setQuery($qry);
             $db->Query();
             $file_obj = new stdClass();
             $file_obj->filename = $filename;
             $file_obj->diskfile = $destname;
             $file_obj->size = strlen($data);
             $this->files[] = $file_obj;
         } else {
             // ERROR : File cannot be uploaded! try permissions
         }
     }
     return count($this->files);
 }
Ejemplo n.º 15
0
 function loadRelated()
 {
     $db = JFactory::getDBO();
     $qry = "SELECT * FROM #__fss_ticket_related WHERE source_id = " . $this->id;
     $db->setQuery($qry);
     $rows = $db->loadObjectList();
     foreach ($rows as $row) {
         $this->related_ids[$row->dest_id] = $row->dest_id;
         $ticket = new SupportTicket();
         if ($ticket->load($row->dest_id)) {
             $this->related[$row->dest_id] = $ticket;
         }
     }
 }
Ejemplo n.º 16
0
 function saveReply()
 {
     $this->removeDraft(FSS_Input::getInt('draft'));
     // get posted data
     $ticketid = FSS_Input::getInt('ticketid');
     $reply_type = FSS_Input::getCmd('reply_type');
     $user_message = FSS_Input::getBBCode('body');
     $handler_message = FSS_Input::getBBCode('body2');
     $subject = FSS_Input::getString('subject');
     // load ticket
     $ticket = new SupportTicket();
     if (!$ticket->load($ticketid)) {
         exit;
     }
     // set up some variables
     $user_id = JFactory::getUser()->id;
     $handler_id = $user_id;
     $old_st = $ticket->getStatus();
     $action_name = "";
     $action_params = array();
     $message_id = 0;
     $files_private = 0;
     // add signatures to messages
     if (FSS_Input::getInt('signature')) {
         if ($user_message) {
             $user_message .= SupportCanned::AppendSig(FSS_Input::getInt('signature'), $ticket);
         }
         if ($handler_message) {
             $handler_message .= SupportCanned::AppendSig(FSS_Input::getInt('signature'), $ticket);
         }
     }
     $extra_time = 0;
     $timestart = 0;
     $timeend = 0;
     if (FSS_Settings::Get('time_tracking') != "") {
         if (FSS_Settings::get('time_tracking_type') == 'se') {
             $timestart = strtotime("1970-01-01 " . FSS_Input::getString('timetaken_start'));
             $timeend = strtotime("1970-01-01 " . FSS_Input::getString('timetaken_end'));
             $extra_time = (int) (($timeend - $timestart) / 60);
         } elseif (FSS_Settings::get('time_tracking_type') == 'tm') {
             $timestart = strtotime(FSS_Input::getString('timetaken_start'));
             $timeend = strtotime(FSS_Input::getString('timetaken_end'));
             $extra_time = (int) (($timeend - $timestart) / 60);
         } else {
             $extra_time = (int) (FSS_Input::getInt('timetaken_hours') * 60 + FSS_Input::getInt('timetaken_mins'));
         }
     }
     // different reply types
     switch ($reply_type) {
         case 'reply':
             // post reply to user
             if ($user_message) {
                 $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
             } elseif ($extra_time > 0) {
                 // no message, add time if needed
                 $ticket->addTime($extra_time, "", true, $timestart, $timeend);
             }
             // update status
             $new_status = FSS_Input::getInt('reply_status');
             $ticket->updateStatus($new_status);
             // reassign ticket if needed
             if (FSS_Settings::get('support_assign_reply') == 1 && FSS_Input::getInt('dontassign') == 0) {
                 $ticket->assignHandler($handler_id, TICKET_ASSIGN_TOOK_OWNER);
             } elseif (FSS_Settings::get('support_autoassign') == 3 && $ticket->admin_id == 0 && FSS_Input::getInt('dontassign') == 0) {
                 $ticket->assignHandler($handler_id, TICKET_ASSIGN_ASSIGNED);
             }
             // call SupportActions handler for admin reply
             $action_name = "Admin_Reply";
             $action_params = array('subject' => $subject, 'user_message' => $user_message, 'status' => $new_status);
             break;
         case 'private':
             // add message to ticket
             if ($handler_message) {
                 $message_id = $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
             } else {
                 if ($extra_time > 0) {
                     $ticket->addTime($extra_time, "", true, $timestart, $timeend);
                 }
             }
             $files_private = 1;
             // call support actions for private comment
             $action_name = "Admin_Private";
             $action_params = array('subject' => $subject, 'handler_message' => $handler_message);
             break;
         case 'user':
             // update user on ticket
             $new_user_id = FSS_Input::getInt("user_id");
             $ticket->updateUser($new_user_id);
             if ($user_message) {
                 $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
             } else {
                 if ($extra_time > 0) {
                     $ticket->addTime($extra_time, "", true, $timestart, $timeend);
                     $extra_time = 0;
                 }
             }
             $action_name = "Admin_ForwardUser";
             $action_params = array('subject' => $subject, 'user_message' => $user_message, 'user_id' => $new_user_id);
             //
             break;
         case 'product':
             $new_handler_id = FSS_Input::getInt('new_handler');
             // update product and department
             $new_product_id = FSS_Input::getInt("new_product_id");
             $new_department_id = FSS_Input::getInt("new_department_id");
             $ticket->updateProduct($new_product_id);
             $ticket->updateDepartment($new_department_id);
             /**
              * -2 - Auto Assign
              * -1 - Unchanged
              * 0 - Unassigned
              * X - Hander
              **/
             if ($new_handler_id == -1) {
                 //$ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD);
             } else {
                 if ($new_handler_id == 0) {
                     $ticket->assignHandler(0, -1);
                 } else {
                     if ($new_handler_id > 0) {
                         $ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD);
                     } else {
                         if ($new_handler_id == -2) {
                             // auto assign new handler
                             $admin_id = FSS_Ticket_Helper::AssignHandler($new_product_id, $new_department_id, $ticket->ticket_cat_id, true);
                             $ticket->assignHandler($admin_id, TICKET_ASSIGN_FORWARD);
                         }
                     }
                 }
             }
             if ($user_message) {
                 $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
                 $extra_time = 0;
             }
             if ($handler_message) {
                 $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
                 $extra_time = 0;
             }
             if ($extra_time > 0) {
                 $ticket->addTime($extra_time, "", true, $timestart, $timeend);
             }
             $action_name = "Admin_ForwardProduct";
             $action_params = array('subject' => $subject, 'user_message' => $user_message, 'handler_message' => $handler_message, 'product_id' => $new_product_id, 'department_id' => $new_department_id);
             break;
         case 'handler':
             $new_handler_id = FSS_Input::getInt('new_handler');
             if ($new_handler_id == -2) {
                 // auto assign new handler
                 $admin_id = FSS_Ticket_Helper::AssignHandler($ticket->prod_id, $ticket->ticket_dept_id, $ticket->ticket_cat_id, true);
                 $ticket->assignHandler($admin_id, TICKET_ASSIGN_FORWARD);
             } else {
                 if ($new_handler_id != -1) {
                     $ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD);
                 }
             }
             // update status
             $new_status = FSS_Input::getCmd('reply_status');
             $ticket->updateStatus($new_status);
             if ($user_message) {
                 $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
                 $extra_time = 0;
             }
             if ($handler_message) {
                 $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend);
                 $ticket->addTime($extra_time);
                 $extra_time = 0;
             }
             if ($extra_time > 0) {
                 $ticket->addTime($extra_time, "", true, $timestart, $timeend);
             }
             $action_name = "Admin_ForwardHandler";
             $action_params = array('subject' => $subject, 'user_message' => $user_message, 'handler_message' => $handler_message, 'handler_id' => $new_handler_id);
             break;
     }
     // add posted files
     $files = $ticket->addFilesFromPost($message_id, -1, $files_private);
     $ticket->stripImagesFromMessage($message_id);
     $action_params['files'] = $files;
     // call action handler
     SupportActions::DoAction($action_name, $ticket, $action_params);
     // Redirect to new page
     $link = FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket->id, false);
     $new_st = $ticket->getStatus();
     if ($reply_type == "reply") {
         if ($new_st->is_closed && SupportUsers::getSetting("return_on_close")) {
             $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_close"));
         } else {
             if (SupportUsers::getSetting("return_on_reply")) {
                 $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_reply"));
             }
         }
     }
     JFactory::getApplication()->redirect($link);
 }
Ejemplo n.º 17
0
	</div>
<?php 
}
?>

<?php 
if ($this->ticket->merged > 0) {
    ?>
	<div class="alert alert-error">
		<p><?php 
    echo JText::_('TICKET_MERGED_NOTICE_INTO');
    ?>
</p>
		<ul>
			<?php 
    $ticket_m = new SupportTicket();
    if ($ticket_m->load($this->ticket->merged)) {
        ?>
				<li>
					<a href="<?php 
        echo FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket_m->id . "&Itemid=" . FSS_Input::getInt('Itemid'), false);
        ?>
">
						<?php 
        echo $ticket_m->reference;
        ?>
 - <?php 
        echo $ticket_m->title;
        ?>
					</a>
				</li>	
Ejemplo n.º 18
0
 function delete_message()
 {
     if (!$this->view->can_EditTicket()) {
         exit;
     }
     $messageid = FSS_Input::getInt('messageid');
     $subject = FSS_Input::getString('subject');
     $body = FSS_Input::getBBCode('body');
     $body = urldecode($body);
     $subject = urldecode($subject);
     $db = JFactory::getDBO();
     $qry = "SELECT * FROM #__fss_ticket_messages WHERE id = " . FSSJ3Helper::getEscaped($db, $messageid);
     $db->setQuery($qry);
     $row = $db->LoadAssoc();
     $ticket = new SupportTicket();
     if ($ticket->load($row['ticket_ticket_id'])) {
         $ticket->deleteMessage($messageid, $subject, $body);
         if ($row['time'] > 0) {
             $ticket->addTime(-$row['time']);
         }
     }
     exit;
 }
Ejemplo n.º 19
0
 function doTickets()
 {
     $db = JFactory::getDBO();
     $import_limit = 100;
     if ($this->offset < 1) {
         $db->setQuery("TRUNCATE #__fss_ticket_ticket");
         $db->Query();
         $db->setQuery("TRUNCATE #__fss_ticket_messages");
         $db->Query();
     }
     $qry = "SELECT hu.*, u.username FROM {$this->sp}_huruhelpdesk_users as hu LEFT JOIN {$this->sp}_users as u ON hu.joomla_id = u.id WHERE isrep = 1";
     $db->setQuery($qry);
     $reps = $db->loadObjectList('id');
     $rep_jid = $db->loadObjectList('username');
     $qry = "SELECT * FROM {$this->sp}_huruhelpdesk_problems LIMIT {$this->offset}, {$import_limit}";
     $db->setQuery($qry);
     $problems = $db->loadObjectList();
     $missing_rep = array();
     foreach ($problems as $problem) {
         $ticket = new SupportTicket();
         $data = array();
         $data['id'] = $problem->id;
         $data['ticket_status_id'] = $problem->status;
         $data['title'] = $problem->title;
         $data['opened'] = $problem->start_date;
         $data['lastupdate'] = $problem->start_date;
         $data['ticket_pri_id'] = $problem->priority;
         $data['ticket_cat_id'] = $problem->category;
         $data['closed'] = $problem->close_date;
         $data['timetaken'] = $problem->time_spent;
         $data['user_id'] = static::getUser($problem->uid);
         $data['admin_id'] = 0;
         if (!array_key_exists($problem->rep, $reps)) {
             $missing_rep[$problem->rep] = "Missing Rep : {$problem->rep}";
         } else {
             $admin = $reps[$problem->rep];
             if ($admin->username) {
                 $data['admin_id'] = static::getUser($admin->username);
             } else {
                 $missing_rep[$problem->rep] = "No User for Rep : {$problem->rep}, Joomla User ID : {$admin->joomla_id}";
             }
         }
         $ticket->create($data);
         $mid = $ticket->addMessage($problem->description, "Problem", $data['user_id']);
         $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$problem->start_date}' WHERE id = " . $mid);
         $db->Query();
         $qry = "SELECT * FROM {$this->sp}_huruhelpdesk_notes WHERE id = '{$problem->id}' ORDER BY adddate ASC";
         $db->setQuery($qry);
         $notes = $db->loadObjectList();
         $last_date = $problem->close_date ? $problem->close_date : $problem->start_date;
         foreach ($notes as $note) {
             $type = TICKET_MESSAGE_USER;
             if (array_key_exists($note->uid, $rep_jid)) {
                 $type = TICKET_MESSAGE_ADMIN;
             }
             if ($note->priv) {
                 $type = TICKET_MESSAGE_PRIVATE;
             }
             $mid = $ticket->addMessage($note->note, "", static::getUser($note->uid), $type);
             $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$note->adddate}' WHERE id = " . $mid);
             $db->Query();
             $last_date = $note->adddate;
         }
         // missing from problems
         /*
         uemail
         ulocation
         uphone
         */
         if ($problem->solution != "") {
             $mid = $ticket->addMessage($problem->solution, "Solution", $data['admin_id'], TICKET_MESSAGE_ADMIN);
             $db->setQuery("UPDATE #__fss_ticket_messages SET posted = '{$problem->close_date}' WHERE id = " . $mid);
             $db->Query();
         }
         $db->setQuery("UPDATE #__fss_ticket_ticket SET lastupdate = '{$last_date}' WHERE id = " . $problem->id);
         $db->Query();
         $this->count++;
     }
     $log = "<h4>Imported {$this->count} tickets, Nos {$this->offset} to " . ($this->offset + $this->count) . "</h4>";
     if ($this->count == $import_limit) {
         $log .= "<a href='" . JRoute::_("index.php?option=com_fss&view=import&source=huru&offset=" . ($this->offset + $import_limit)) . "'>Run next {$import_limit}</a><Br/>";
     }
     $log .= "<h3>Missing Rep Lookups</h3>";
     $log .= "<pre>" . print_r($missing_rep, true) . "</pre>";
     $log .= "<h3>Missing Usernames</h3>";
     $log .= "<pre>" . print_r(static::$missing, true) . "</pre>";
     return $log;
 }
Ejemplo n.º 20
0
 static function StoreFields(&$fields, $ticketid)
 {
     $ticket = new SupportTicket();
     $ticket->load($ticketid, true);
     $allfields = FSSCF::GetAllCustomFields(false);
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $userid = $ticket->user_id;
     if (count($fields) > 0) {
         foreach ($fields as &$field) {
             // only place this is called is creating a new ticket, so dont overwrite any per user fields that have permissions > 0
             if (array_key_exists($field['id'], $allfields) && $allfields[$field['id']]['peruser'] && $allfields[$field['id']]['permissions'] > 0 && $allfields[$field['id']]['permissions'] < 4) {
                 continue;
             }
             $value = FSS_Input::getString("custom_" . $field['id'], "XX--XX--XX");
             if ($field['type'] == "plugin") {
                 $aparams = FSSCF::GetValues($field);
                 $plugin = FSSCF::get_plugin($aparams['plugin']);
                 $value = $plugin->Save($field['id'], $aparams['plugindata']);
             }
             if ($value != "XX--XX--XX") {
                 if (array_key_exists($field['id'], $allfields) && $allfields[$field['id']]['peruser'] && $userid > 0) {
                     $qry = "REPLACE INTO #__fss_ticket_user_field (user_id, field_id, value) VALUES ('" . FSSJ3Helper::getEscaped($db, $userid) . "','";
                     $qry .= FSSJ3Helper::getEscaped($db, $field['id']) . "','";
                     $qry .= FSSJ3Helper::getEscaped($db, $value) . "')";
                     $db->setQuery($qry);
                     $db->Query();
                 } else {
                     $qry = "REPLACE INTO #__fss_ticket_field (ticket_id, field_id, value) VALUES ('" . FSSJ3Helper::getEscaped($db, $ticketid) . "','";
                     $qry .= FSSJ3Helper::getEscaped($db, $field['id']) . "','";
                     $qry .= FSSJ3Helper::getEscaped($db, $value) . "')";
                     $db->setQuery($qry);
                     $db->Query();
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
 function CleanInline()
 {
     $db = JFactory::getDBO();
     $qry = "SELECT ticket_ticket_id, id FROM #__fss_ticket_messages WHERE body LIKE '%[img]data:%'";
     $db->setQuery($qry);
     $this->messages = $db->loadObjectList();
     foreach ($this->messages as $message) {
         $st = new SupportTicket();
         $st->load($message->ticket_ticket_id);
         $st->stripImagesFromMessage($message->id);
     }
     $count = count($this->messages);
     JFactory::getApplication()->redirect("index.php?option=com_fss&view=attachclean", "{$count} inline images converted to attachments.", "message");
 }
Ejemplo n.º 22
0
    function removerelated()
    {
        $source_id = FSS_Input::getInt('source_id');
        $dest_id = FSS_Input::getInt('dest_id');
        if ($source_id < 1) {
            return $this->cancel();
        }
        if ($dest_id < 1) {
            return $this->cancel();
        }
        $source = new SupportTicket();
        if (!$source->load($source_id)) {
            return $this->cancel();
        }
        $dest = new SupportTicket();
        if (!$dest->load($dest_id)) {
            return $this->cancel();
        }
        $source->removeRelated($dest->id);
        ?>
<script>
window.location = '<?php 
        echo FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $source_id, false);
        ?>
';
</script>
<?php 
        exit;
    }
Ejemplo n.º 23
0
 public function create($app)
 {
     $request = $app->router->flight->request();
     if ($request->method != 'POST') {
         $app->output->addBreadcrumb('', 'CSGOShop');
         $app->output->addBreadcrumb('support/', 'Support');
         $app->output->addBreadcrumb('support/create', 'Create a Ticket');
         $app->output->setTitle('Create a Ticket');
         $app->output->setActiveTab('support');
         $app->output->render('support.create', []);
     } else {
         SupportTicket::create(['user_id' => $app->user->id, 'subject' => '[' . $request->data->category . '] ' . $request->data->subject, 'body' => $request->data->body]);
         $app->output->redirect('/support');
     }
 }
Ejemplo n.º 24
0
 public function actionCreatesupport()
 {
     $model = new SupportTicket();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->support_ticket_code = $model->supportCode();
     $model->customer_id = Yii::app()->user->customerId;
     $model->date_added = new CDbExpression('NOW()');
     if (isset($_POST['SupportTicket'])) {
         $model->attributes = $_POST['SupportTicket'];
         if ($model->save()) {
             $this->redirect(array('supports'));
         }
     }
     $this->render('create_support', array('model' => $model));
 }