Beispiel #1
0
 function getLimits()
 {
     $mainframe = JFactory::getApplication();
     $limit = $mainframe->getUserStateFromRequest('global.list.limit_ticket', 'limit', SupportUsers::getSetting('per_page'), 'int');
     $limitstart = FSS_Input::getInt('limitstart');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
 }
Beispiel #2
0
 function display($tpl = NULL)
 {
     // view a ticket!
     $this->ticketid = FSS_Input::getInt('ticketid');
     $document = JFactory::getDocument();
     $document->addScript(JURI::root() . 'components/com_fss/assets/js/bootstrap/bootstrap-timepicker.min.js');
     $this->ticket = new SupportTicket();
     if (!$this->ticket->load($this->ticketid)) {
         if ($this->ticket->checkExist($this->ticketid)) {
             return $this->_display("noperm");
         } else {
             return JError::raiseWarning(404, JText::_('Ticket not found'));
         }
     }
     if ($this->ticket->merged > 0 && FSS_Input::getInt('no_redirect') != '1') {
         JFactory::getApplication()->redirect(FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $this->ticket->merged . "&Itemid=" . FSS_Input::getInt('Itemid'), false));
     }
     $reverse = JRequest::getInt('sort', null);
     if ($reverse !== null) {
         if ($reverse) {
             // we want messages in opposite order to normal
             if (SupportUsers::getSetting("reverse_order")) {
                 $reverse = true;
             } else {
                 $reverse = false;
             }
         } else {
             // we want messages in normal order
             $reverse = null;
         }
     }
     $this->ticket->loadAll($reverse);
     $this->loadMerged();
     $pathway = JFactory::getApplication()->getPathway();
     $pathway->addItem(JText::_("SUPPORT"), FSSRoute::_('index.php?option=com_fss&view=admin_support&tickets=' . $this->ticket_view));
     $pathway->addItem(JText::_("VIEW_TICKET") . " : " . $this->ticket->reference . " - " . $this->ticket->title);
     $this->assignOnOpen();
     $this->tryLock();
     if ($this->ticket->admin_id > 0) {
         $this->adminuser = SupportUsers::getUser($this->ticket->admin_id);
     }
     $this->ticket_view = $this->ticket->ticket_status_id;
     $this->HandleRefresh();
     if (FSS_Settings::get('time_tracking') == "auto") {
         $session = JFactory::getSession();
         $session->set('ticket_' . $this->ticket->id . "_opened", time());
     }
     FSS_Helper::IncludeModal();
     FSS_Helper::AddSCEditor();
     $this->HandleRefresh();
     $this->print = FSS_Input::getCmd('print');
     if ($this->print) {
         return $this->_display("print");
     }
     $this->_display();
 }
Beispiel #3
0
 function ticket_status_id()
 {
     // update status in ticket
     // redirect if the config is set to
     $ticketid = FSS_Input::getInt('ticketid');
     $ticket_status_id = FSS_Input::getInt('ticket_status_id');
     if ($ticketid < 1) {
         exit;
     }
     if ($ticket_status_id < 1) {
         exit;
     }
     $link = FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticketid, false);
     // check permission for new status
     $statuss = SupportHelper::getStatuss();
     $new_status = $statuss[$ticket_status_id];
     if ($new_status->is_closed && !$this->view->can_Close()) {
         JFactory::getApplication()->redirect($link);
         exit;
     }
     $ticket = new SupportTicket();
     if ($ticket->Load($ticketid)) {
         $old_st = $ticket->getStatus();
         $ticket->updateStatus($ticket_status_id);
         $new_st = $ticket->getStatus();
         // if we have closed the ticket, and return on close is set, then we should do a redirect dependant on the setting
         if ($new_st->is_closed && SupportUsers::getSetting("return_on_close")) {
             $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_close"));
         }
         if ($new_st->is_closed && !$old_st->is_closed) {
             // SEND CLOSED EMAIL HERE!
             if (!FSS_Settings::get('support_email_on_close_no_dropdown')) {
                 FSS_EMail::Admin_Close($ticket, $ticket->title, '', array());
             }
         }
     }
     JFactory::getApplication()->redirect($link);
     exit;
 }
Beispiel #4
0
                echo $this->grouping("cat", $ticket->category, $ticket);
                $grp_cat = $ticket->ticket_cat_id;
                $grp_group = -1;
            }
        }
        if (SupportUsers::getSetting("group_group")) {
            if ($ticket->group_id != $grp_group) {
                if ($grp_open == 1) {
                    echo "</table></div>";
                }
                $grp_open = 0;
                echo $this->grouping("group", $ticket->groupname, 0);
                $grp_group = $ticket->group_id;
            }
        }
        if (SupportUsers::getSetting("group_pri")) {
            if ($ticket->ticket_pri_id != $grp_pri) {
                if ($grp_open == 1) {
                    echo "</table></div>";
                }
                $grp_open = 0;
                echo $this->grouping("pri", $ticket->priority, 0);
                $grp_pri = $ticket->ticket_pri_id;
            }
        }
        if ($grp_open == 0) {
            ?>
							<div <?php 
            echo $tab_style;
            ?>
><table class='table table-bordered table-ticketborders table-condensed' style="border-top: none;">
Beispiel #5
0
 function outputCSV()
 {
     if (ob_get_level() > 0) {
         ob_end_clean();
     }
     $report_name = $this->report->title . " " . date("Y-m-d H.i.s");
     header('Content-Encoding: UTF-8');
     header("Content-type: text/csv; charset=UTF-8");
     header("Content-Disposition: attachment; filename=" . $report_name . ".csv");
     header("Pragma: no-cache");
     header("Expires: 0");
     $sep = FSS_Settings::get('reports_separator');
     if (SupportUsers::getSetting('reports_separator') != "") {
         $sep = SupportUsers::getSetting('reports_separator');
     }
     echo "";
     $outline = array();
     foreach ($this->report->field as $field) {
         $outline[] = $field->text;
     }
     $fp = fopen('php://output', 'w');
     fputcsv($fp, $outline, $sep);
     foreach ($this->report->data as $row) {
         $outline = array();
         foreach ($this->report->field as $field) {
             $name = $field->name;
             $value = $row->{$name};
             if (isset($field->format)) {
                 if ($field->format == "date") {
                     if ($value != "" && $value != "0000-00-00" && $value != "0000-00-00 00:00:00") {
                         $format = "Y-m-d";
                         if (isset($field->dateformat)) {
                             $format = $field->dateformat;
                         }
                         if (substr($format, 0, 5) == "DATE_") {
                             $format = JText::_($format);
                         }
                         $jdate = new JDate($value);
                         $value = $jdate->format($format);
                     } elseif (isset($field->blank)) {
                         $value = $field->blank;
                     }
                 } else {
                     if ($field->format == "messagetime") {
                         if ($value < 1) {
                             $value = "";
                         } else {
                             if ($value > 0 && $value < 86400 * 10) {
                                 $value = date("H:i", $value);
                             } else {
                                 $format = "Y-m-d";
                                 if (isset($field->dateformat)) {
                                     $format = $field->dateformat;
                                 }
                                 if (substr($format, 0, 5) == "DATE_") {
                                     $format = JText::_($format);
                                 }
                                 $jdate = new JDate($value);
                                 $value = $jdate->format($format);
                             }
                         }
                     } else {
                         if ($field->format == "hm") {
                             $val = $value;
                             $mins = $val % 60;
                             $hrs = floor($val / 60);
                             $value = sprintf("%d:%02d", $hrs, $mins);
                         } else {
                             if ($field->format == "bbcode") {
                                 $value = preg_replace("/\\[img\\]data(.*)\\[\\/img\\]/i", "", $value);
                                 //$value = FSS_Helper::ParseBBCode($value, null, true, true);
                             }
                         }
                     }
                 }
             }
             $outline[] = $value;
         }
         //echo implode($sep, $outline) . "\n";
         fputcsv($fp, $outline, $sep);
     }
     fclose($fp);
     exit;
 }
 function loadTicketsBySearch()
 {
     $db = JFactory::getDBO();
     $query = "SELECT t.*, s.title as status, s.color, u.name, au.name as assigned, u.email as useremail, u.username as username, au.email as handleremail, au.username as handlerusername, \n";
     $query .= " dept.title as department, cat.title as category, prod.title as product, pri.title as priority, pri.color as pricolor, \n";
     $query .= " grp.groupname as groupname, grp.id as group_id \n";
     $query .= " , pri.translation as ptl, dept.translation as dtr, s.translation as str, cat.translation as ctr, prod.translation as prtr\n";
     $query .= " FROM #__fss_ticket_ticket as t \n";
     $query .= " LEFT JOIN #__fss_ticket_status as s ON t.ticket_status_id = s.id \n";
     $query .= " LEFT JOIN #__users as u ON t.user_id = u.id \n";
     $query .= " LEFT JOIN #__users as au ON t.admin_id = au.id \n";
     $query .= " LEFT JOIN #__fss_ticket_dept as dept ON t.ticket_dept_id = dept.id \n";
     $query .= " LEFT JOIN #__fss_ticket_cat as cat ON t.ticket_cat_id = cat.id \n";
     $query .= " LEFT JOIN #__fss_prod as prod ON t.prod_id = prod.id \n";
     $query .= " LEFT JOIN #__fss_ticket_pri as pri ON t.ticket_pri_id = pri.id \n";
     $query .= " LEFT JOIN (SELECT group_id, user_id FROM #__fss_ticket_group_members GROUP BY user_id) as mem ON t.user_id = mem.user_id \n";
     $query .= " LEFT JOIN #__fss_ticket_group as grp ON grp.id = mem.group_id \n";
     // add custom fields to the sql
     foreach (FSSCF::GetAllCustomFields() as $field) {
         if (!$field['inlist']) {
             continue;
         }
         $id = $field['id'];
         if ($field['peruser']) {
             $query .= " LEFT JOIN #__fss_ticket_user_field as cf{$id} ON cf{$id}.user_id = t.user_id AND cf{$id}.field_id = {$id} \n";
         } else {
             $query .= " LEFT JOIN #__fss_ticket_field as cf{$id} ON cf{$id}.ticket_id = t.id AND cf{$id}.field_id = {$id} \n";
         }
     }
     $searchtype = FSS_Input::getCmd('searchtype', 'basic');
     $wherebits = array();
     if ($searchtype == "basic") {
         $search = FSS_Input::getString('search', '');
         if ($search != "") {
             $mode = "";
             if (FSS_Helper::contains($search, array('*', '+', '-', '<', '>', '(', ')', '~', '"'))) {
                 $mode = "IN BOOLEAN MODE";
             }
             //$wherebits[] = " t.title LIKE '%".FSSJ3Helper::getEscaped($db, $search)."%' ";
             $wherebits[] = " MATCH (t.title) AGAINST ('" . $db->escape($search) . "' {$mode}) /* Title */ ";
             $wherebits[] = " t.reference LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* Reference */ ";
             // search custom fields that are set to be searched
             $this->searchFields($wherebits, "basicsearch");
             // basic search optional fields
             if (FSS_Settings::get('support_basic_name')) {
                 $wherebits[] = " u.name LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* Name */ ";
                 $wherebits[] = " unregname LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* UnReg Name */ ";
             }
             if (FSS_Settings::get('support_basic_username')) {
                 $wherebits[] = " u.username LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* Username */ ";
             }
             if (FSS_Settings::get('support_basic_email')) {
                 $wherebits[] = " u.email LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* User email */ ";
                 $wherebits[] = " t.email LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' /* Unreg Email */ ";
             }
             if (FSS_Settings::get('support_basic_messages')) {
                 $qry = "SELECT ticket_ticket_id FROM #__fss_ticket_messages WHERE subject LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%' OR ";
                 $qry .= " MATCH (body) AGAINST ('" . $db->escape($search) . "' {$mode}) GROUP BY ticket_ticket_id";
                 $qry .= " AND admin IN (0, 1, 2, 4) ";
                 $db->setQuery($qry);
                 $wherebits[] = $this->TicketIDsToWhere($db->loadObjectList(), "ticket_ticket_id") . " /* Messages */ ";
             }
         }
         if (count($wherebits) == 0) {
             $wherebits[] = "1 /* Catch All */";
         }
         $query .= "\n WHERE (" . implode("\n OR ", $wherebits) . ")";
     } else {
         if ($searchtype == "advanced") {
             $search = FSS_Input::getString('search', '');
             $wherebits = array();
             $subject = FSS_Input::getString('subject', '');
             if ($subject) {
                 $wherebits[] = " t.title LIKE '%" . FSSJ3Helper::getEscaped($db, $subject) . "%' /* Title */ ";
             }
             $reference = FSS_Input::getString('reference', '');
             if ($reference) {
                 $wherebits[] = " t.reference LIKE '%" . FSSJ3Helper::getEscaped($db, $reference) . "%' /* Reference */ ";
             }
             $username = FSS_Input::getString('username', '');
             if ($username) {
                 $wherebits[] = " u.username LIKE '%" . FSSJ3Helper::getEscaped($db, $username) . "%' /* Username */ ";
             }
             $useremail = FSS_Input::getString('useremail', '');
             if ($useremail) {
                 $wherebits[] = " ( u.email LIKE '%" . FSSJ3Helper::getEscaped($db, $useremail) . "%' OR t.email LIKE '%" . FSSJ3Helper::getEscaped($db, $useremail) . "%' ) /* EMail */";
             }
             $userfullname = FSS_Input::getString('userfullname', '');
             if ($userfullname) {
                 $wherebits[] = " ( u.name LIKE '%" . FSSJ3Helper::getEscaped($db, $userfullname) . "%' OR unregname LIKE '%" . FSSJ3Helper::getEscaped($db, $userfullname) . "%' ) /* Name */";
             }
             $content = FSS_Input::getString('content', '');
             if ($content) {
                 $mode = "";
                 if (FSS_Helper::contains($search, array('*', '+', '-', '<', '>', '(', ')', '~', '"'))) {
                     $mode = "IN BOOLEAN MODE";
                 }
                 $qry = "SELECT ticket_ticket_id FROM #__fss_ticket_messages WHERE subject LIKE '%" . FSSJ3Helper::getEscaped($db, $content) . "%' OR ";
                 $qry .= " MATCH (body) AGAINST ('" . $db->escape($content) . "' {$mode})";
                 $qry .= " AND admin IN (0, 1, 2, 4) ";
                 $db->setQuery($qry);
                 $wherebits[] = $this->TicketIDsToWhere($db->loadObjectList(), "ticket_ticket_id") . " /* Messages */ ";
             }
             $handler = FSS_Input::getInt('handler', '');
             if ($handler) {
                 $user = JFactory::getUser();
                 if ($handler == -5) {
                     $wherebits[] = " t.admin_id = '" . $user->id . "' /* Handler -1 */ ";
                 } else {
                     if ($handler == -2) {
                         $wherebits[] = " t.admin_id != '" . $user->id . "' /* Handler -2 */ ";
                         $wherebits[] = " t.admin_id != 0 /* Handler -2 */";
                     } else {
                         if ($handler == -3) {
                             $wherebits[] = " t.admin_id = 0 /* Handler -3 */";
                         } elseif ($handler == -4) {
                             $temp_where[] = " t.admin_id = '" . $db->escape($user->id) . "' ";
                             $qry = "SELECT ticket_id FROM #__fss_ticket_cc WHERE isadmin = 1 AND user_id = " . $db->escape($user->id);
                             $db->setQuery($qry);
                             $wherebits[] = $this->TicketIDsToWhere($db->loadObjectList(), "ticket_id") . " /* Handler -4 */";
                         } else {
                             // handler
                             if ($handler == -1) {
                                 $handler = JFactory::getUser()->id;
                             }
                             $qry = "SELECT * FROM #__fss_ticket_cc WHERE isadmin = 1 AND user_id = " . $db->escape($handler);
                             $db->setQuery($qry);
                             $temp_where[] = $this->TicketIDsToWhere($db->loadObjectList(), "ticket_id");
                             $temp_where[] = " t.admin_id = '" . $db->escape($handler) . "' ";
                             $wherebits[] = " ( " . implode(" OR ", $temp_where) . " ) /* Handler specified */ ";
                             //$wherebits[] = " t.admin_id = '".FSSJ3Helper::getEscaped($db, $handler)."' ";
                         }
                     }
                 }
             }
             $status = FSS_Input::getCmd('status', '');
             if ($status) {
                 if ($status == "open") {
                     $open = FSS_Ticket_Helper::GetStatusIDs("def_open");
                     // tickets that arent closed
                     $wherebits[] = " t.ticket_status_id IN ( " . implode(", ", $open) . ") /* Def open */ ";
                 } elseif ($status == 'allopen') {
                     $allopen = FSS_Ticket_Helper::GetStatusIDs("is_closed", true);
                     // tickets that arent closed
                     $wherebits[] = " t.ticket_status_id IN ( " . implode(", ", $allopen) . ") /* All open */ ";
                 } elseif ($status == 'closed') {
                     $allopen = FSS_Ticket_Helper::GetStatusIDs("is_closed");
                     // remove the archived tickets from the list to deal with
                     $def_archive = FSS_Ticket_Helper::GetStatusID('def_archive');
                     foreach ($allopen as $offset => $value) {
                         if ($value == $def_archive) {
                             unset($allopen[$offset]);
                         }
                     }
                     // tickets that are closed
                     $wherebits[] = " t.ticket_status_id IN ( " . implode(", ", $allopen) . ") /* all closed */";
                 } elseif ($status == 'all') {
                     // need all tickets that arent archived
                     $allopen = FSS_Ticket_Helper::GetStatusIDs("def_archive", true);
                     $wherebits[] = " t.ticket_status_id IN ( " . implode(", ", $allopen) . " ) /* all (not archived) */ ";
                 } elseif ($status == 'archived') {
                     // need all tickets that arent archived
                     $allopen = FSS_Ticket_Helper::GetStatusIDs("def_archive");
                     $wherebits[] = " t.ticket_status_id IN ( " . implode(", ", $allopen) . " ) /* archived */ ";
                 } else {
                     $wherebits[] = " t.ticket_status_id = " . (int) FSSJ3Helper::getEscaped($db, $status) . " /* specified status */";
                 }
             }
             $product = FSS_Input::getInt('product', '');
             if ($product) {
                 $wherebits[] = " t.prod_id = '" . FSSJ3Helper::getEscaped($db, $product) . "' /* Product */";
             }
             $department = FSS_Input::getInt('department', '');
             if ($department) {
                 $wherebits[] = " t.ticket_dept_id = '" . FSSJ3Helper::getEscaped($db, $department) . "' /* Department */ ";
             }
             $cat = FSS_Input::getInt('cat', '');
             if ($cat) {
                 $wherebits[] = " t.ticket_cat_id = '" . FSSJ3Helper::getEscaped($db, $cat) . "' /* Category */";
             }
             $pri = FSS_Input::getInt('priority', '');
             if ($pri) {
                 $wherebits[] = " t.ticket_pri_id = '" . FSSJ3Helper::getEscaped($db, $pri) . "' /* Priority */";
             }
             $group = FSS_Input::getInt('group', '');
             if ($group > 0) {
                 $wherebits[] = " t.user_id IN (SELECT user_id FROM #__fss_ticket_group_members WHERE group_id = '" . FSSJ3Helper::getEscaped($db, $group) . "' GROUP BY user_id) /* Ticket Group */";
             }
             $date_from = FSS_Helper::DateValidate(FSS_Input::getString('date_from', ''));
             $date_to = FSS_Helper::DateValidate(FSS_Input::getString('date_to', ''));
             if ($date_from) {
                 $wherebits[] = " t.lastupdate > DATE_SUB('" . FSSJ3Helper::getEscaped($db, $date_from) . "',INTERVAL 1 DAY) /* Date From */";
             }
             if ($date_to) {
                 $wherebits[] = " t.opened < DATE_ADD('" . FSSJ3Helper::getEscaped($db, $date_to) . "',INTERVAL 1 DAY) /* Date To */";
             }
             $this->searchFields($wherebits, "advancedsearch");
             if (count($wherebits) == 0) {
                 $wherebits[] = "1  /* Catch All */";
             }
             $query .= "\n WHERE " . implode("\n AND ", $wherebits);
         } else {
             $query .= " WHERE 1  /* Catch All */";
         }
     }
     $query .= "\n AND " . $this->getTagFilter() . " /* Tag Filter */";
     $query .= "\n AND " . SupportUsers::getAdminWhere() . " /* getAdminWhere */";
     $query .= "\n AND " . SupportSource::admin_show_sql() . " /* admin_show_sql */";
     $order = array();
     if (SupportUsers::getSetting("group_products")) {
         $order[] = "prod.ordering";
     }
     if (SupportUsers::getSetting("group_departments")) {
         $order[] = "dept.title";
     }
     if (SupportUsers::getSetting("group_cats")) {
         $order[] = "cat.title";
     }
     if (SupportUsers::getSetting("group_pri")) {
         $order[] = "pri.ordering DESC";
     }
     if (SupportUsers::getSetting("group_group")) {
         $order[] = "case when grp.groupname is null then 1 else 0 end";
         $order[] = "grp.groupname";
     }
     $ordering = JFactory::getApplication()->getUserStateFromRequest("fss_admin.ordering", "ordering", "");
     if ($ordering) {
         $order = array();
         $ordering = str_replace(".asc", " ASC", $ordering);
         $ordering = str_replace(".desc", " DESC", $ordering);
         $order[] = $ordering;
     } else {
         $order[] = "lastupdate DESC";
     }
     $query .= "\n ORDER BY " . implode(", ", $order);
     $session = JFactory::getSession();
     $session->set("last_admin_query", (string) $query);
     $session->set("last_admin_list", $_SERVER['REQUEST_URI']);
     $session->set("last_admin_post", $_POST);
     //echo "<br>".str_replace("\n", "<br>", $query)."<br>";
     $db->setQuery($query);
     $db->query();
     $this->ticket_count = $db->getNumRows();
     $db->setQuery($query, $this->limitstart, $this->limit);
     $this->LoadFromRows($db->loadObjectList());
 }
 function loadMessages($reverse = null, $types = array())
 {
     if (!$this->loaded_messages) {
         $query = "SELECT m.*, u.name FROM #__fss_ticket_messages as m LEFT JOIN #__users as u ON m.user_id = u.id WHERE ticket_ticket_id = {$this->id}";
         if (count($types) > 0) {
             $query .= " AND m.admin IN (" . implode(", ", $types) . ") ";
         }
         if ($reverse === null) {
             if (SupportUsers::getSetting("reverse_order")) {
                 $query .= " ORDER BY posted ASC";
             } else {
                 $query .= " ORDER BY posted DESC";
             }
         } else {
             if ($reverse) {
                 $query .= " ORDER BY posted DESC";
             } else {
                 $query .= " ORDER BY posted ASC";
             }
         }
         $db = JFactory::getDBO();
         $db->setQuery($query);
         $this->messages = $db->loadObjectList();
         $this->loaded_messages = true;
     }
 }
Beispiel #8
0
if (SupportUsers::getSetting('reports_separator') == "") {
    echo " SELECTED";
}
?>
 ><?php 
echo JText::_('DEFAULT');
?>
</option>
				<option value="," <?php 
if (SupportUsers::getSetting('reports_separator') == ",") {
    echo " SELECTED";
}
?>
 >,</option>
				<option value=";" <?php 
if (SupportUsers::getSetting('reports_separator') == ";") {
    echo " SELECTED";
}
?>
 >;</option>
			</select>
		</div>
	</div>

</div>
</form>

<?php 
include JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . '_powered.php';
echo FSS_Helper::PageStyleEnd();
?>
Beispiel #9
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);
 }
Beispiel #10
0
 static function GetAllSigs($ticket)
 {
     if (empty(self::$all_sigs)) {
         $userid = JFactory::getUser()->id;
         $db = JFactory::getDBO();
         $query = 'SELECT * FROM #__fss_ticket_fragments WHERE type = 1';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         self::$all_sigs = array();
         foreach ($rows as $row) {
             $row->params = json_decode($row->params, true);
             if (is_string($row->params)) {
                 $row->params = array();
             }
             $row->default = 0;
             $row->personal = 0;
             if (isset($row->params['userid'])) {
                 if ($row->params['userid'] > 0 && $userid != $row->params['userid']) {
                     continue;
                 }
                 $row->personal = 1;
             }
             self::$all_sigs[] = $row;
         }
         $qry = "SELECT * FROM #__fss_users WHERE user_id = {$userid}";
         $db->setQuery($qry);
         $user = $db->loadObject();
         if ($user) {
             $settings = json_decode($user->settings, true);
         }
         $def_sig = SupportUsers::getSetting('default_sig');
         $ds = 0;
         if ($def_sig > 0) {
             foreach (self::$all_sigs as &$sig) {
                 if ($sig->id == $def_sig) {
                     $sig->default = 1;
                 }
             }
         }
     }
     return self::$all_sigs;
 }
Beispiel #11
0
    function grouping($type, $name, $ticket)
    {
        if (empty($this->group_nest)) {
            $this->group_nest = array();
            $this->group_nest['prod'] = 0;
            $this->group_nest['dept'] = 0;
            $this->group_nest['cat'] = 0;
            $this->group_nest['group'] = 0;
            $this->group_nest['pri'] = 0;
            $base = 0;
            if (SupportUsers::getSetting("group_products")) {
                $this->group_nest['prod'] = $base;
                $base++;
            }
            if (SupportUsers::getSetting("group_departments")) {
                $this->group_nest['dept'] = $base;
                $base++;
            }
            if (SupportUsers::getSetting("group_cats")) {
                $this->group_nest['cat'] = $base;
                $base++;
            }
            if (SupportUsers::getSetting("group_group")) {
                $this->group_nest['group'] = $base;
                $base++;
            }
            if (SupportUsers::getSetting("group_pri")) {
                $this->group_nest['pri'] = $base;
                $base++;
            }
        }
        if ($name == "") {
            if ($type == "prod") {
                $name = JText::_('NO_PRODUCT');
            }
            if ($type == "dept") {
                $name = JText::_('NO_DEPARTMENT');
            }
            if ($type == "cat") {
                $name = JText::_('NO_CATEGORY');
            }
            if ($type == "group") {
                $name = JText::_('NO_GROUP');
            }
        }
        $style = "style='padding-left: " . 16 * $this->group_nest[$type] . "px;'";
        ?>

	<div class="fss_ticket_grouping" <?php 
        echo $style;
        ?>
>
		<img src='<?php 
        echo JURI::root(true);
        ?>
/components/com_fss/assets/images/support/<?php 
        echo $type;
        ?>
.png' width="16" height="16">
		<?php 
        echo $name;
        ?>
	</div>

<?php 
    }
<?php

/**
 * @package Freestyle Joomla
 * @author Freestyle Joomla
 * @copyright (C) 2013 Freestyle Joomla
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
defined('_JEXEC') or die;
$def_sig = SupportUsers::getSetting("default_sig");
?>
<select name="signature" id="signature">
	<optgroup label="<?php 
echo JText::_('Signatures');
?>
:">
		<?php 
foreach (SupportCanned::GetAllSigs(null) as $sig) {
    ?>
			<?php 
    if ($sig_txt == "") {
        $sig_txt = $sig->content;
    }
    ?>
			<option value="<?php 
    echo $sig->id;
    ?>
" 
				<?php 
    if ($sig->id == $def_sig) {
        echo "selected";