Permalink
Browse files

+ Added Ticket Stats as a plugin

  • Loading branch information...
1 parent 96a844d commit f696c44ac7cbdce6968775e8fe184788ecd1bdde Jeremy D committed Nov 5, 2011
View
30 sd_plugins_lang/SDPluginStats.english.php
@@ -0,0 +1,30 @@
+<?php
+###############################################################
+# Simple Desk Project - www.simpledesk.net #
+###############################################################
+# An advanced help desk modifcation built on SMF #
+###############################################################
+# #
+# * Copyright 2010 - SimpleDesk.net #
+# #
+# This file and its contents are subject to the license #
+# included with this distribution, license.txt, which #
+# states that this software is New BSD Licensed. #
+# Any questions, please contact SimpleDesk.net #
+# #
+###############################################################
+# SimpleDesk Version: 2.0 Anatidae #
+# File Info: SDPluginFrontPage.english.php / 2.0 Anatidae #
+###############################################################
+// Version: 2.0 Anatidae; SimpleDesk main language file
+
+// Important! Before editing these language files please read the text at the top of index.english.php.
+
+$txt['shdp_stats'] = 'Statistics';
+$txt['shdp_stats_desc'] = 'This plugin allows you to view statistics of your helpdesk.';
+
+$txt['shdp_enable_stats'] = 'Enable stats';
+
+
+$txt['shdp_stats_main'] ='j';
+$txt['shdp_stats_main_desc'] ='Stats';
View
407 sd_plugins_source/stats/SDPluginStats.php
@@ -0,0 +1,407 @@
+<?php
+###############################################################
+# Simple Desk Project - www.simpledesk.net #
+###############################################################
+# An advanced help desk modifcation built on SMF #
+###############################################################
+# #
+# * Copyright 2010 - SimpleDesk.net #
+# #
+# This file and its contents are subject to the license #
+# included with this distribution, license.txt, which #
+# states that this software is New BSD Licensed. #
+# Any questions, please contact SimpleDesk.net #
+# #
+###############################################################
+# SimpleDesk Version: 2.0 Anatidae #
+# File Info: SDPluginFrontPage.php / 2.0 Anatidae #
+###############################################################
+
+/**
+ * This file handles the replacement front page.
+ *
+ * @package plugin-stats
+ * @since 2.0
+ */
+
+if (!defined('SMF'))
+ die('Hacking attempt...');
+
+/*
+ * Called from the SMF admin menu hook
+ */
+function shd_stats_adminmenu(&$admin_areas)
+{
+ global $context, $modSettings, $txt;
+
+ if (allowedTo('admin_forum') && !empty($modSettings['shdp_enable_stats']))
+ $admin_areas['helpdesk_info']['areas']['helpdesk_info']['subsections']['stats'] = array($txt['shdp_stats']);
+}
+
+function shd_stats_hdadmininfo(&$subactions)
+{
+ global $context, $modSettings, $txt;
+
+ if (!allowedTo('admin_forum') || empty($modSettings['shdp_enable_stats']))
+ return;
+
+ $subactions['stats'] = array(
+ 'function' => 'shd_stats_source',
+ 'icon' => '../reports.gif',
+ 'title' => $txt['shdp_stats']
+ );
+
+ $context[$context['admin_menu_name']]['tab_data']['tabs']['stats'] = $subactions['stats'];
+}
+
+/*
+ * The options screen for the stats
+ */
+function shd_stats_admin($config_vars)
+{
+ $config_vars[] = '';
+ $config_vars[] = array('check', 'shdp_enable_stats');
+}
+
+/*
+ * The source file for the actual stats page.
+ */
+function shd_stats_source()
+{
+ global $modSettings, $context;
+
+ // All possible stat info.
+ $stats = array(
+ 'status',
+ 'today',
+ 'most',
+ 'average',
+ 'totals',
+ 'urgency',
+ 'history',
+ );
+
+ // Loop out the stat info.
+ $context['shd_stats'] = array();
+ foreach ($stats as $function)
+ {
+ $func = 'shd_stats_' . $function;
+ $context['shd_stats'][$function] = $func();
+
+ }
+
+ loadTemplate('sd_plugins_template/SDPluginStats');
+}
+
+// This gets our ticket status info.
+function shd_stats_status()
+{
+ global $smcFunc;
+
+ $status = array(
+ TICKET_STATUS_NEW => 0,
+ TICKET_STATUS_PENDING_STAFF => 0,
+ TICKET_STATUS_PENDING_USER => 0,
+ TICKET_STATUS_CLOSED => 0,
+ TICKET_STATUS_WITH_SUPERVISOR => 0,
+ TICKET_STATUS_ESCALATED => 0,
+ TICKET_STATUS_DELETED => 0
+ );
+
+ // Collect up some numbers.
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(id_ticket) AS count, status
+ FROM {db_prefix}helpdesk_tickets
+ WHERE status IN ({array_int:status})
+ GROUP BY status',
+ array(
+ 'status' => array_keys($status)
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $status[$row['status']] = $row['count'];
+ $smcFunc['db_free_result']($request);
+
+ $status['total_open'] = $status[TICKET_STATUS_NEW] + $status[TICKET_STATUS_PENDING_STAFF] + $status[TICKET_STATUS_PENDING_USER] + $status[TICKET_STATUS_WITH_SUPERVISOR] + $status[TICKET_STATUS_ESCALATED];
+ $status['total_closed'] = $status[TICKET_STATUS_CLOSED] + $status[TICKET_STATUS_DELETED];
+
+ $status['total_total'] = $status['total_open'] + $status['total_closed'];
+
+ // We are fast.
+ if ($status['total_open'] == $status['total_closed'])
+ $status['ratio'] = '1:1';
+ elseif ($status['total_open'] == 0)
+ $status['ratio'] = '0:' . $status['total_closed'];
+ elseif ($status['total_closed'] == 0)
+ $status['ratio'] = $status['total_open'] . ':0';
+ elseif ($status['total_open'] > $status['total_closed'])
+ $status['ratio'] = round($status['total_open'] / $status['total_closed']) . ':1';
+ elseif ($status['total_open'] < $status['total_closed'])
+ $status['ratio'] = '1:' . round($status['total_closed'] / $status['total_open']);
+
+ return $status;
+}
+
+// This gets our ticket open/closed info.
+function shd_stats_today()
+{
+ global $smcFunc;
+
+ $actions = array(
+ // These are open tickets.
+ 'newticket' => TICKET_STATUS_NEW,
+ 'unresolve' => TICKET_STATUS_NEW,
+
+ // These are resolved tickets.
+ 'resolve' => TICKET_STATUS_CLOSED,
+ );
+
+ $totals = array(
+ TICKET_STATUS_NEW => 0,
+ TICKET_STATUS_CLOSED => 0,
+ );
+
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(la.id_ticket) AS count, t.status
+ FROM {db_prefix}helpdesk_log_action AS la
+ INNER JOIN {db_prefix}helpdesk_tickets AS t ON (la.id_ticket = t.id_ticket)
+ WHERE la.action IN ({array_string:actions})
+ AND la.log_time > {int:today}
+ GROUP BY la.action',
+ array(
+ 'actions' => array_keys($actions),
+ // we could use strtotime from a date(n j Y), but this seems safer calculations
+ 'today' => mktime(0, 0, 0, date('n'), date('j'), date('Y'))
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $totals[$row['status']] = $row['count'];
+ $smcFunc['db_free_result']($request);
+
+ return $totals;
+}
+
+// This gets our ticket open/closed info.
+function shd_stats_most()
+{
+ global $smcFunc;
+
+ $actions = array(
+ TICKET_STATUS_NEW => array('newticket'),
+ TICKET_STATUS_CLOSED => array('resolve')
+ );
+
+ $most = array(
+ TICKET_STATUS_NEW => array(0, 0),
+ TICKET_STATUS_CLOSED => array(0, 0),
+ );
+
+ foreach ($actions as $action)
+ {
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(la.id_ticket) AS count, t.status, log_time
+ FROM {db_prefix}helpdesk_log_action AS la
+ INNER JOIN {db_prefix}helpdesk_tickets AS t ON (la.id_ticket = t.id_ticket)
+ WHERE la.action IN ({array_string:actions})
+ GROUP BY unix_timestamp() - log_time < {int:24hrs} AND unix_timestamp() - log_time + {int:24hrs} > 0
+ ORDER BY count DESC
+ LIMIT 1',
+ array(
+ 'actions' => $action,
+ '24hrs' => 86400,
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $most[$row['status']] = array($row['count'], $row['log_time']);
+ $smcFunc['db_free_result']($request);
+ }
+
+ return $most;
+}
+
+// This gets our ticket open/closed info.
+function shd_stats_average()
+{
+ global $smcFunc;
+
+ $actions = array(
+ TICKET_STATUS_NEW => array('newticket', 'unresolve'),
+ TICKET_STATUS_CLOSED => array('resolve'),
+ TICKET_STATUS_PENDING_STAFF => array('assign'),
+ );
+
+ $average = array(
+ TICKET_STATUS_NEW => 0,
+ TICKET_STATUS_CLOSED => 0,
+ TICKET_STATUS_PENDING_STAFF => 0,
+ );
+
+ foreach ($actions as $action)
+ $request = $smcFunc['db_query']('', '
+ SELECT AVG(la.id_ticket) AS count, t.status
+ FROM {db_prefix}helpdesk_log_action AS la
+ INNER JOIN {db_prefix}helpdesk_tickets AS t ON (la.id_ticket = t.id_ticket)
+ WHERE la.action IN ({array_string:actions})
+ GROUP BY (la.id_ticket)',
+ array(
+ 'actions' => $action,
+ '24hrs' => 86400,
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $average[$row['status']] = $row['count'];
+ $smcFunc['db_free_result']($request);
+
+ return $average;
+}
+
+// This gets our user info.
+function shd_stats_totals()
+{
+ global $smcFunc;
+
+ // Count Admins separately for now.!
+ $admins = array();
+ if (empty($totals[ROLE_ADMIN]))
+ {
+ $request = $smcFunc['db_query']('', '
+ SELECT id_member
+ FROM {db_prefix}members
+ WHERE id_group = {int:admin} OR FIND_IN_SET({int:admin}, additional_groups)',
+ array(
+ 'admin' => 1
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $admins[] = $row['id_member'];
+
+ $smcFunc['db_free_result']($request);
+ }
+
+ // @TODO: This most likely will filesort and be slow on large helpdesks.
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(mem.id_member) AS count, hdr.template
+ FROM {db_prefix}members AS mem
+ INNER JOIN {db_prefix}helpdesk_role_groups AS hdrg ON (mem.id_group = hdrg.id_group OR FIND_IN_SET(hdrg.id_group, mem.additional_groups))
+ INNER JOIN {db_prefix}helpdesk_roles AS hdr ON (hdrg.id_role = hdr.id_role)
+ WHERE mem.id_member NOT IN ({array_int:admins})
+ GROUP BY hdr.template',
+ array(
+ 'admins' => $admins
+ ));
+
+ $totals = array(
+ ROLE_USER => 0,
+ ROLE_STAFF => 0,
+// ROLE_SUPERVISOR => 0,
+ ROLE_ADMIN => 0
+ );
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $totals[$row['template']] = $row['count'];
+ $smcFunc['db_free_result']($request);
+
+ // Add in the admins.
+ $totals[ROLE_ADMIN] += count($admins);
+
+ return $totals;
+}
+
+// This gets our urgency.
+function shd_stats_urgency()
+{
+ global $smcFunc;
+
+ $urgency = array(
+ TICKET_URGENCY_LOW => 0,
+ TICKET_URGENCY_MEDIUM => 0,
+ TICKET_URGENCY_HIGH => 0,
+ TICKET_URGENCY_VHIGH => 0,
+ TICKET_URGENCY_SEVERE => 0,
+ TICKET_URGENCY_CRITICAL => 0,
+ );
+
+ // We reformat it now.
+ $urgency = array(
+ 'open' => $urgency,
+ 'closed' => $urgency
+ );
+
+ // Open or closed is all we need to know.
+ $status = array(
+ TICKET_STATUS_NEW => 'open',
+ TICKET_STATUS_PENDING_STAFF => 'open',
+ TICKET_STATUS_PENDING_USER => 'open',
+ TICKET_STATUS_CLOSED => 'closed',
+ TICKET_STATUS_WITH_SUPERVISOR => 'open',
+ TICKET_STATUS_ESCALATED => 'open',
+ TICKET_STATUS_DELETED => 'closed',
+ );
+
+ // Collect up some numbers.
+ $request = $smcFunc['db_query']('', '
+ SELECT COUNT(id_ticket) AS count, urgency, status
+ FROM {db_prefix}helpdesk_tickets
+ WHERE urgency IN ({array_string:urgency})
+ GROUP BY urgency, status',
+ array(
+ 'urgency' => array_keys($urgency)
+ ));
+
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ $urgency[$status[$row['status']]][$row['urgency']] = $row['count'];
+ $smcFunc['db_free_result']($request);
+
+ return $urgency;
+}
+
+// Time to become Archeologists.
+function shd_stats_history()
+{
+ global $smcFunc;
+
+ // What tasks we want to perform.
+ $tasks = array(
+ 'open' => 0,
+ 'resolved' => 0,
+ 'assigned' => 0,
+ 'reopen' => 0,
+ 'child' => array(),
+ );
+
+ $conversion = array(
+ 'newticket' => 'open',
+ 'assign' => 'assigned',
+ 'resolve' => 'resolved',
+ );
+
+ // @TODO: In future, use ajax to support selecting years/months totals
+ $request = $smcFunc['db_query']('', '
+ SELECT log_time, action
+ FROM {db_prefix}helpdesk_log_action');
+
+ $history = array();
+ while ($row = $smcFunc['db_fetch_assoc']($request))
+ {
+ list($year, $month, $day) = explode(' ', date('Y m d', $row['log_time']));
+
+ // If only we had to do this once a year.
+ if (!isset($history[$year]))
+ $history[$year] = $tasks;
+ $history[$year][$conversion[$row['action']]] += 1;
+
+ // Now we do the monthly stats
+ if (!isset($history[$year]['child'][$month]))
+ $history[$year]['child'][$month] = $tasks;
+ $history[$year]['child'][$month][$conversion[$row['action']]] += 1;
+
+ // For day we just simply do it.
+ if (!isset($history[$year]['child'][$month]['child'][$day]))
+ $history[$year]['child'][$month]['child'][$day] = $tasks;
+ $history[$year]['child'][$month]['child'][$day][$conversion[$row['action']]] += 1;
+ }
+ $smcFunc['db_free_result']($request);
+
+ // We now return to the history channel.
+ return $history;
+}
View
80 sd_plugins_source/stats/index.php
@@ -0,0 +1,80 @@
+<?php
+###########################################################
+# Simple Desk Project - www.simpledesk.net #
+###########################################################
+# An advanced help desk modifcation built on SMF #
+###########################################################
+# #
+# * Copyright 2010 - SimpleDesk.net #
+# #
+# This file and its contents are subject to the license #
+# included with this distribution, license.txt, which #
+# states that this software is New BSD Licensed. #
+# Any questions, please contact SimpleDesk.net #
+# #
+###########################################################
+# SimpleDesk Version: 2.0 Anatidae #
+# File Info: index.php / 2.0 Anatidae #
+###########################################################
+
+/**
+ * @package plugin-stats
+ * @since 2.0
+*/
+
+if (!defined('SHD_VERSION'))
+ die('Hacking attempt...');
+
+/*
+ * Return information about this plugin.
+ *
+ * details
+ * - name: a $txt reference for the plugin's name (so it can be translated), if not present as a $txt will be used as a literal. (Note, see includes - language below)
+ * - description: a $txt reference one line description of the mod (translatable) - if not present, it will be used as a literal.
+ * - author: Author's name, literal
+ * - website: Website to link back to the author
+ * - version: Plugin version
+ * - compatibility: Array of supported SD version-strings
+ *
+ * includes
+ * - source: a key-value pair array of file names to include at strategic points, key name is the point to include it on, value is a filename or array of filenames to include within the plugin's dir
+ * - language: a key-value pair of array of language files to include, much like source.
+ *
+ * hooks
+ * - key-value pair of hook name to function name or array of function names to be called at the hook point
+ *
+ * @since 2.1
+*/
+function shdplugin_stats()
+{
+ return array(
+ 'details' => array( // general plugin details
+ 'title' => 'shdp_stats',
+ 'description' => 'shdp_stats_desc',
+ 'author' => 'SimpleDesk Team',
+ 'website' => 'http://www.simpledesk.net/',
+ 'version' => '1.0',
+ 'compatibility' => array(
+ 'SimpleDesk 2.0 Anatidae', // should tie up with the SHD_VERSION constants
+ ),
+ 'acp_url' => 'action=admin;area=helpdesk_options;sa=stats',
+ ),
+ 'includes' => array(
+ 'source' => array(
+ 'init' => 'SDPluginStats.php',
+ ),
+ 'language' => array(
+ 'hdadmin' => 'SDPluginStats',
+ 'helpdesk' => 'SDPluginStats',
+ ),
+ ),
+ 'hooks' => array( // what functions to call when
+ 'adminmenu' => 'shd_stats_adminmenu',
+ 'hdadmininfo' => 'shd_stats_hdadmininfo',
+ 'admin_admin' => 'shd_stats_admin',
+
+ ),
+ );
+}
+
+
View
216 sd_plugins_template/SDPluginStats.template.php
@@ -0,0 +1,216 @@
+<?php
+// Version: 2.0 Anatidae; SimpleDesk alternate front page template
+
+/**
+ * This file handles the replacement front page.
+ *
+ * @package plugin-frontpage
+ * @since 2.0
+*/
+
+/**
+ * Display the replacement front page.
+ *
+ * @since 2.0
+*/
+function template_main()
+{
+ global $context, $txt, $settings, $scripturl;
+
+$txt['general_stats'] = 'General Statistics';
+$txt['new_tickets_today'] = 'New Tickets Today';
+$txt['closed_tickets_today'] = 'Closed Tickets Today';
+$txt['total_open_tickets'] = 'Total Open Tickets';
+$txt['total_closed_tickets'] = 'Total Closed Tickets';
+$txt['total_total_tickets'] = 'Total Tickets';
+$txt['most_open_tickets'] = 'Most Tickets Created';
+$txt['most_closed_tickets'] = 'Most Tickets Closed';
+$txt['average_new_tickets'] = 'Average New Tickets';
+$txt['average_closed_tickets'] = 'Average Closed Tickets';
+$txt['average_assign_tickets'] = 'Average Assigned Tickets';
+$txt['total_users'] = 'Total Users';
+$txt['total_staff'] = 'Total Staff';
+$txt['total_admins'] = 'Total Administrators';
+$txt['open_closed_ratio'] = 'Open/Closed Ratio';
+
+$txt['urgency_stats'] = 'Urgency Statistics';
+$txt['urgency_open'] = 'Open';
+$txt['urgency_closed'] = 'Closed';
+
+$txt['urgency_type_0'] = 'Low Urgency Tickets';
+$txt['urgency_type_1'] = 'Medium Urgency Tickets';
+$txt['urgency_type_2'] = 'High Urgency Tickets';
+$txt['urgency_type_3'] = 'Very High Urgency Tickets';
+$txt['urgency_type_4'] = 'Severe Urgency Tickets';
+$txt['urgency_type_5'] = 'Critical Urgency Tickets';
+
+$txt['ticket_history'] = 'Ticket History';
+$txt['yearly_summary'] = 'Yearly Summary';
+$txt['new_tickets'] = 'New Tickets';
+$txt['assigned_tickets'] = 'Assigned Tickets';
+$txt['reopen_tickets'] = 'Re-opened Tickets';
+$txt['closed_tickets'] = 'Closed Tickets';
+
+ echo '
+ <div class="title_bar">
+ <h4 class="titlebg">
+ <span class="ie6_header floatleft">
+ <img src="', $settings['images_url'], '/stats_info.gif" class="icon" alt="" /> ', $txt['general_stats'], '
+ </span>
+ </h4>
+ </div>
+ <div class="flow_hidden">
+ <div id="stats_left">
+ <div class="windowbg2">
+ <span class="topslice"><span></span></span>
+ <div class="content top_row">
+ <dl class="stats">
+ <dt>', $txt['new_tickets_today'], '</dt>
+ <dd>', $context['shd_stats']['today'][TICKET_STATUS_NEW], '</dd>
+ <dt>', $txt['closed_tickets_today'], '</dt>
+ <dd>', $context['shd_stats']['today'][TICKET_STATUS_CLOSED], '</dd>
+ <dt>', $txt['total_open_tickets'], '</dt>
+ <dd>', $context['shd_stats']['status']['total_open'], '</dd>
+ <dt>', $txt['total_closed_tickets'], '</dt>
+ <dd>', $context['shd_stats']['status']['total_closed'], '</dd>
+ <dt>', $txt['total_total_tickets'], '</dt>
+ <dd>', $context['shd_stats']['status']['total_total'], '</dd>
+ <dt>', $txt['most_open_tickets'], '</dt>
+ <dd>', $context['shd_stats']['most'][TICKET_STATUS_NEW][0], ' &mdash; ', date('F d, Y', $context['shd_stats']['most'][TICKET_STATUS_NEW][1]), '</dd>
+ <dt>', $txt['most_closed_tickets'], '</dt>
+ <dd>', $context['shd_stats']['most'][TICKET_STATUS_CLOSED][0], ' &mdash; ', date('F d, Y', $context['shd_stats']['most'][TICKET_STATUS_CLOSED][1]), '</dd>
+ </dl>
+ <div class="clear"></div>
+ </div>
+ <span class="botslice"><span></span></span>
+ </div>
+ </div>
+ <div id="stats_right">
+ <div class="windowbg2">
+ <span class="topslice"><span></span></span>
+ <div class="content top_row">
+ <dl class="stats">
+ <dt>', $txt['average_new_tickets'], ':</dt>
+ <dd>', $context['shd_stats']['average'][TICKET_STATUS_NEW], '</dd>
+ <dt>', $txt['average_closed_tickets'], ':</dt>
+ <dd>', $context['shd_stats']['average'][TICKET_STATUS_CLOSED], '</dd>
+ <dt>', $txt['average_assign_tickets'], ':</dt>
+ <dd>', $context['shd_stats']['average'][TICKET_STATUS_PENDING_STAFF], '</dd>
+ <dt>', $txt['total_users'], ':</dt>
+ <dd>', $context['shd_stats']['totals'][ROLE_USER], '</dd>
+ <dt>', $txt['total_staff'], ':</dt>
+ <dd>', $context['shd_stats']['totals'][ROLE_STAFF], '</dd>
+ <dt>', $txt['total_admins'], ':</dt>
+ <dd>', $context['shd_stats']['totals'][ROLE_ADMIN], '</dd>
+ <dt>', $txt['open_closed_ratio'], ':</dt>
+ <dd>', $context['shd_stats']['status']['ratio'], '</dd>
+ </dl>
+ <div class="clear"></div>
+ </div>
+ <span class="botslice"><span></span></span>
+ </div>
+ </div>
+ </div>
+
+ <div class="title_bar">
+ <h4 class="titlebg">
+ <span class="ie6_header floatleft">
+ <img src="', $settings['images_url'], '/stats_posters.gif" class="icon" alt="" /> ', $txt['urgency_stats'], '
+ </span>
+ </h4>
+ </div>
+ <div class="flow_hidden">
+ <div id="stats_left">
+ <div class="windowbg2">
+ <span class="topslice"><span></span></span>
+ <div class="content top_row">
+ <dl class="stats">';
+
+ foreach ($context['shd_stats']['urgency']['open'] as $type => $count)
+ echo '
+ <dt>', $txt['urgency_type_' . $type ], ' (', $txt['urgency_open'], ')</dt>
+ <dd>', $count, '</dd>';
+
+ echo '
+ </dl>
+ <div class="clear"></div>
+ </div>
+ <span class="botslice"><span></span></span>
+ </div>
+ </div>
+ <div id="stats_right">
+ <div class="windowbg2">
+ <span class="topslice"><span></span></span>
+ <div class="content top_row">
+ <dl class="stats">';
+
+ foreach ($context['shd_stats']['urgency']['closed'] as $type => $count)
+ echo '
+ <dt>', $txt['urgency_type_' . $type ], ' (', $txt['urgency_closed'], ')</dt>
+ <dd>', $count, '</dd>';
+
+ echo '
+ </dl>
+ <div class="clear"></div>
+ </div>
+ <span class="botslice"><span></span></span>
+ </div>
+ </div>
+ </div>
+ <div class="cat_bar">
+ <h3 class="catbg">
+ <span class="ie6_header floatleft">
+ <img src="', $settings['images_url'], '/stats_history.gif" class="icon" alt="" /> ', $txt['ticket_history'], '
+ </span>
+ </h3>
+ </div>
+ <table border="0" width="100%" cellspacing="1" cellpadding="4" class="table_grid" id="stats">
+ <thead>
+ <tr class="titlebg" valign="middle" align="center">
+ <th class="first_th lefttext" width="25%">', $txt['yearly_summary'], '</th>
+ <th width="15%">', $txt['new_tickets'], '</th>
+ <th width="15%">', $txt['assigned_tickets'], '</th>
+ <th width="15%">', $txt['reopen_tickets'], '</th>
+ <th class="last_th" width="15%">', $txt['closed_tickets'], '</th>
+ </tr>
+ </thead>
+ <tbody>';
+
+ foreach ($context['shd_stats']['history'] as $year_id => $year)
+ {
+ echo '
+ <tr class="windowbg2" valign="middle" align="center" id="year_', $id, '">
+ <th class="lefttext" width="25%">', $year_id, '</th>
+ <th width="15%">', $year['open'], '</th>
+ <th width="15%">', $year['assigned'], '</th>
+ <th width="15%">', $year['reopen'], '</th>
+ <th width="15%">', $year['resolved'], '</th>
+ </tr>';
+
+ foreach ($year['child'] as $month_id => $month)
+ {
+ echo '
+ <tr class="windowbg2" valign="middle" align="center" id="tr_month_', $month_id, '">
+ <th class="stats_month">', $txt['months_titles'][$month_id], ' ', $year_id, '</th>
+ <th width="15%">', $month['open'], '</th>
+ <th width="15%">', $month['assigned'], '</th>
+ <th width="15%">', $month['reopen'], '</th>
+ <th width="15%">', $month['resolved'], '</th>
+ </tr>';
+
+ foreach ($month['child'] as $day_id => $day)
+ echo '
+ <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $year_id, '-', $month_id, '-', $day_id, '">
+ <td class="stats_day">', $year_id, '-', $month_id, '-', $day_id, '</td>
+ <th width="15%">', $day['open'], '</th>
+ <th width="15%">', $day['assigned'], '</th>
+ <th width="15%">', $day['reopen'], '</th>
+ <th width="15%">', $day['resolved'], '</th>
+ </tr>';
+ }
+ }
+
+ echo '
+ </tbody>
+ </table>';
+}
View
8 sd_source/SimpleDesk-Admin.php
@@ -171,10 +171,8 @@ function shd_admin_info()
'title' => $txt['shd_admin_support'],
),
);
- $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main';
$context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => '<img src="' . $settings['images_url'] . '/admin/shd/' . $subactions[$_REQUEST['sa']]['icon'] . '" class="icon" alt="*" />' . $subactions[$_REQUEST['sa']]['title'],
'description' => $txt['shd_admin_options_desc'],
'tabs' => array(
'main' => array(
@@ -189,6 +187,12 @@ function shd_admin_info()
),
);
+ call_integration_hook('shd_hook_hdadmininfo', array(&$subactions));
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main';
+
+ // Now that we have validated the subaction.
+ $context[$context['admin_menu_name']]['tab_data']['title'] = '<img src="' . $settings['images_url'] . '/admin/shd/' . $subactions[$_REQUEST['sa']]['icon'] . '" class="icon" alt="*" />' . $subactions[$_REQUEST['sa']]['title'];
+
// Are we doing the main page, or leaving here?
if (!empty($subactions[$_REQUEST['sa']]['function']))
{
View
1 sd_source/SimpleDesk-AdminPlugins.php
@@ -363,6 +363,7 @@ function shd_list_hooks()
'shd_hook_helpdesk', // functions to run when starting the main helpdesk (before going off to subactions)
'shd_hook_hdadmin', // functions to run when starting the main SimpleDesk admin area (probably should include via _include_hdadmin)
'shd_hook_hdadminopts', // functions to run when working in the SimpleDesk options submenu structure (probably should include via _include_hdadmin)
+ 'shd_hook_hdadmininfo', // functions to run when working in the SimpleDesk info submenu structure (probably should include via _include_hdadmin)
'shd_hook_hdadminoptssrch', // functions to run when setting up admin panel search for SimpleDesk options submenu structure (probably should include via _include_hdadmin)
'shd_hook_hdprofile', // functions to call when going into the helpdesk profile area
);

0 comments on commit f696c44

Please sign in to comment.