Ejemplo n.º 1
0
 function display($tpl = NULL)
 {
     parent::init();
     $this->plugins = $this->load_plugins();
     $this->mode = FSS_Input::getcmd('mode', 'pick');
     $this->usergroup = FSS_Input::getInt('usergroup');
     foreach ($this->plugins as $plugin) {
         $plugin->mode = $this->mode;
     }
     $limitstart = FSS_Input::getInt('limitstart');
     $mainframe = JFactory::getApplication();
     $limit = $mainframe->getUserStateFromRequest('users.limit', 'limit', 10, 'int');
     $search = FSS_Input::getString('search');
     $this->lists = array();
     $this->lists['order_Dir'] = FSS_Input::getCmd('filter_order_Dir');
     $this->lists['order'] = FSS_Input::getCmd('filter_order');
     $ticket_has_groups = false;
     // load in ticket if there is one
     $this->ticketid = FSS_Input::getInt("ticketid");
     if ($this->mode == "user" || $this->mode == "admin") {
         $this->ticket = new SupportTicket();
         $this->ticket->load($this->ticketid);
         $this->ticket->loadCC();
         $this->ticket->loadGroups();
         if (count($this->ticket->groups) > 0) {
             $ticket_has_groups = true;
         }
     }
     // ticket group, default to t if we are in user or admin mode
     $this->ticketgroup = null;
     if ($ticket_has_groups && $this->mode == "user") {
         $this->ticketgroup = "t";
     }
     $this->ticketgroup = FSS_Input::getcmd('ticketgroup', $this->ticketgroup);
     $db = JFactory::getDBO();
     $qry = "SELECT * FROM #__users ";
     $where = array();
     if ($search != "") {
         $search_parts = array();
         $search_parts[] = "username LIKE '%" . $db->escape($search) . "%'";
         $search_parts[] = "name LIKE '%" . $db->escape($search) . "%'";
         $search_parts[] = "email LIKE '%" . $db->escape($search) . "%'";
         $this->searchFields($search_parts);
         foreach ($this->plugins as $plugin) {
             $ids = $plugin->search($search);
             if (count($ids) > 0) {
                 $search_parts[] = "id IN ('" . implode("', '", $ids) . "')";
             }
         }
         $where[] = "( " . implode(" OR ", $search_parts) . " )";
     }
     // filter by usergroup
     if ($this->usergroup > 0) {
         $where[] = "id IN (SELECT user_id FROM #__user_usergroup_map WHERE group_id = " . $db->escape($this->usergroup) . ")";
     }
     // filter by ticket group
     if ($this->ticketgroup == "t") {
         $group_ids = array();
         $group_ids[] = 0;
         foreach ($this->ticket->groups as $group) {
             $group_ids[] = $group->id;
         }
         $where[] = "id IN (SELECT user_id FROM #__fss_ticket_group_members WHERE group_id IN (" . implode(", ", $group_ids) . "))";
     } elseif ($this->ticketgroup > 0) {
         $where[] = "id IN (SELECT user_id FROM #__fss_ticket_group_members WHERE group_id = " . $db->escape($this->ticketgroup) . ")";
     }
     if ($this->mode == "admin") {
         $handlers = SupportUsers::getHandlers(false, false);
         $ids = array();
         $ids[] = 0;
         foreach ($handlers as $handler) {
             $ids[] = $handler->id;
         }
         $where[] = "id IN (" . implode(", ", $ids) . ")";
     }
     // add where
     if (count($where) > 0) {
         $qry .= " WHERE " . implode(" AND ", $where);
     }
     $order = FSS_Input::getCmd('filter_order');
     $dir = FSS_Input::getCmd('filter_order_Dir', 'asc');
     if ($order == "username" || $order == "name" || $order == "email") {
         // Sort ordering
         $qry .= " ORDER BY {$order} {$dir} ";
     } else {
         $qry .= " ORDER BY name ";
     }
     //echo $qry . "<br>";
     // get max items
     $db->setQuery($qry);
     $db->query();
     $maxitems = $db->getNumRows();
     // select picked items
     $db->setQuery($qry, $limitstart, $limit);
     $this->users = $db->loadObjectList();
     //print_p(reset($this->users));
     // build pagination
     $this->pagination = new JPaginationEx($maxitems, $limitstart, $limit);
     $this->search = $search;
     if ($this->mode != "admin") {
         // load in joomla user groups
         $qry = "SELECT * FROM #__usergroups ORDER BY lft";
         $db->setQuery($qry);
         $this->groups = $db->loadObjectList();
         $group_index = array();
         foreach ($this->groups as &$group) {
             $group_index[$group->id] =& $group;
             if ($group->parent_id == 0) {
                 $group->level = 0;
             } else {
                 $group->level = $group_index[$group->parent_id]->level + 1;
             }
             $group->display = str_repeat("- ", $group->level) . $group->title;
         }
         array_unshift($this->groups, JHTML::_('select.option', '', JText::_("JOOMLA_USERGROUP"), 'id', 'display'));
         $this->jgroup_select = JHTML::_('select.genericlist', $this->groups, 'usergroup', 'class="inputbox" size="1" onchange="document.fssForm.submit( );"', 'id', 'display', $this->usergroup);
         // load ticket groups
         $qry = "SELECT * FROM #__fss_ticket_group ORDER BY groupname";
         $db->setQuery($qry);
         $this->ticketgroups = $db->loadObjectList();
         if ($this->ticketid > 0 && $ticket_has_groups) {
             array_unshift($this->ticketgroups, JHTML::_('select.option', 't', JText::_("CURRENT_TICKET"), 'id', 'groupname'));
         }
         array_unshift($this->ticketgroups, JHTML::_('select.option', '', JText::_("ALL_TICKET_GROUPS"), 'id', 'groupname'));
         $this->ticketgroup_select = JHTML::_('select.genericlist', $this->ticketgroups, 'ticketgroup', 'class="inputbox" size="1" onchange="document.fssForm.submit( );"', 'id', 'groupname', $this->ticketgroup);
     }
     $this->_display();
 }
Ejemplo n.º 2
0
 function doReply()
 {
     $this->ticketid = FSS_Input::getInt('ticketid');
     $this->ticket = new SupportTicket();
     if (!$this->ticket->load($this->ticketid)) {
         return JError::raiseWarning(404, JText::_('Ticket not found'));
     }
     $this->ticket->loadAll();
     if (FSS_Settings::get('time_tracking') != "") {
         if (FSS_Settings::get('time_tracking_type') == 'se') {
             $this->time_start = FSS_Helper::Date(time(), FSS_DATE_CUSTOM, "H:i:s");
             $this->time_end = FSS_Helper::Date(time(), FSS_DATE_CUSTOM, "H:i:s");
         } elseif (FSS_Settings::get('time_tracking_type') == 'tm') {
             $this->time_start = FSS_Helper::Date(time(), FSS_DATE_CUSTOM, FSS_Helper::getFormat());
             $this->time_end = FSS_Helper::Date(time(), FSS_DATE_CUSTOM, FSS_Helper::getFormat());
         } else {
             $this->taken_hours = 0;
             $this->taken_mins = 0;
         }
     }
     if (FSS_Settings::get('time_tracking') == "auto") {
         $session = JFactory::getSession();
         $taken = $session->get('ticket_' . $this->ticket->id . "_opened");
         if (FSS_Settings::get('time_tracking_type') == 'se') {
             $document = JFactory::getDocument();
             $document->addScript(JURI::root() . 'components/com_fss/assets/js/bootstrap/bootstrap-timepicker.min.js');
             $document->addScriptDeclaration("jQuery(document).ready(function () {jQuery('#timetaken_start').timepicker({minuteStep:5, showMeridian: false});jQuery('#timetaken_end').timepicker({minuteStep:5, showMeridian: false});});");
             $this->time_start = FSS_Helper::Date($taken, FSS_DATE_CUSTOM, "H:i:s");
         } else {
             if ($taken > 0) {
                 $taken = time() - $taken;
             }
             $this->time_taken = $taken;
             $taken = ceil($taken / 60);
             $this->taken_hours = floor($taken / 60);
             $this->taken_mins = $taken % 60 + 1;
         }
     }
     $this->fields = FSSCF::GetCustomFields($this->ticket->id, $this->ticket->prod_id, $this->ticket->ticket_dept_id, 3);
     $this->fieldvalues = FSSCF::GetTicketValues($this->ticket->id, $this->ticket);
     $pathway = JFactory::getApplication()->getPathway();
     $pathway->addItem(JText::_("SUPPORT"), FSSRoute::_('index.php?option=com_fss&view=admin_support&tickets=' . $this->ticket_view, false));
     $pathway->addItem(JText::_("VIEW_TICKET") . " : " . $this->ticket->reference . " - " . $this->ticket->title, FSSRoute::_('index.php?option=com_fss&view=admin_support&tickets=' . $this->ticket_view . "&ticketid=" . $this->ticket->id, false));
     $this->reply_type = FSS_Input::getCmd('type', 'reply');
     if ($this->reply_type == "") {
         $this->reply_type = "reply";
     }
     switch ($this->reply_type) {
         case 'reply':
             $this->reply_title = "REPLY_TO_SUPORT_TICKET";
             $this->reply_button = "POST_REPLY";
             $pathway->addItem(JText::_("POST_REPLY"));
             break;
         case 'private':
             $this->reply_title = "ADD_HANDLER_COMMENT_TO_TICKET";
             $this->reply_button = "POST_COMMENT";
             $pathway->addItem(JText::_("ADD_COMMENT"));
             break;
         case 'user':
             $this->reply_title = "FORWARD_TICKET_TO_A_DIFFERENT_USER";
             $this->reply_button = "FORWARD_TICKET";
             if ($this->ticket->user_id > 0) {
                 $user = JFactory::getUser($this->ticket->user_id);
             } else {
                 $user = new stdClass();
                 $user->username = $this->ticket->email;
                 $user->name = $this->ticket->unregname;
             }
             $this->user = $user;
             $pathway->addItem(JText::_("FORWARD_TO_USER"));
             break;
         case 'product':
             $this->reply_title = "FORWARD_TICKET_TO_A_DIFFERENT_DEPARTMENT";
             $this->reply_button = "FORWARD_TICKET";
             $this->handlers = SupportUsers::getHandlers(false, true);
             $pathway->addItem(JText::_("FORWARD_TO_DEPARTMENT"));
             break;
         case 'handler':
             $this->reply_title = "FORWARD_TICKET_TO_A_DIFFERENT_HANDLER";
             $this->reply_button = "FORWARD_TICKET";
             $this->handlers = SupportUsers::getHandlers(false, true);
             $pathway->addItem(JText::_("FORWARD_TO_HANDLER"));
             break;
     }
     $this->draft = FSS_Input::getInt('draft');
     $this->user_message = $this->loadDraft($this->draft);
     $this->support_assign_reply = FSS_Settings::get('support_assign_reply');
     FSS_Helper::IncludeModal();
     FSS_Helper::AddSCEditor();
     parent::_display();
 }