diff --git a/helpdesk/templates/helpdesk/base.html b/helpdesk/templates/helpdesk/base.html index aa8af360..45eba476 100644 --- a/helpdesk/templates/helpdesk/base.html +++ b/helpdesk/templates/helpdesk/base.html @@ -19,10 +19,8 @@ {% if helpdesk_settings.HELPDESK_USE_CDN %} - - + {% else %} - {% endif %} @@ -34,11 +32,30 @@ + {% if helpdesk_settings.HELPDESK_USE_CDN %} + + {% else %} + {% endif %} + + {% if helpdesk_settings.HELPDESK_USE_CDN %} + + {% else %} + + {% endif %} + + + + {% if helpdesk_settings.HELPDESK_USE_CDN %} + + {% else %} + + {% endif %} + @@ -98,34 +115,9 @@ {% include "helpdesk/debug.html" %} - - - - - - {% if helpdesk_settings.HELPDESK_USE_CDN %} - - {% else %} - - {% endif %} - - - - - - - - - - - - - - - diff --git a/helpdesk/templates/helpdesk/include/stats.html b/helpdesk/templates/helpdesk/include/stats.html index 81c2da03..f9184821 100644 --- a/helpdesk/templates/helpdesk/include/stats.html +++ b/helpdesk/templates/helpdesk/include/stats.html @@ -1,19 +1,41 @@ {% load i18n %} - - - - - - - - - -{% for entry in basic_ticket_stats.open_ticket_stats %} - - - - -{% endfor %} - -
{% trans "Current Ticket Stats" %}
- {% trans "Average number of days until ticket is closed (all tickets): " %}{{ basic_ticket_stats.average_nbr_days_until_ticket_closed }}.
- {% trans "Average number of days until ticket is closed (tickets opened in last 60 days): " %}{{ basic_ticket_stats.average_nbr_days_until_ticket_closed_last_60_days }}. -{% trans "Click" %} here {% trans "for detailed average by month." %}
- {% trans "Distribution of open tickets, grouped by time period:" %}
{% trans "Days since opened" %}{% trans "Number of open tickets" %}
{{ entry.0 }}{% if entry.1 > 0 %}{{ entry.1 }}{% else %}{{ entry.1 }}{% endif %}
\ No newline at end of file + +
+
+
+
+ {% trans "Helpdesk Summary" %} +
+ +
+ {% for entry in basic_ticket_stats.open_ticket_stats %} + + {% endfor %} +
+ +
+ +
+
+ diff --git a/helpdesk/templates/helpdesk/include/summary.html b/helpdesk/templates/helpdesk/include/summary.html index 8f1d308b..f6388e5d 100644 --- a/helpdesk/templates/helpdesk/include/summary.html +++ b/helpdesk/templates/helpdesk/include/summary.html @@ -1,17 +1,42 @@ {% load i18n %} - - - - - - -{% for queue in dash_tickets %} -{% url 'helpdesk_list' as hdlist %} - - - - - -{% endfor %} - -
{% trans "Helpdesk Summary" %}
{% trans "Queue" %}{% trans "Open" %}{% trans "Resolved" %}{% trans "Closed" %}
{{ queue.name }}{% if queue.open %}{% endif %}{{ queue.open }}{% if queue.open %}{% endif %}{% if queue.resolved %}{% endif %}{{ queue.resolved }}{% if queue.resolved %}{% endif %}{% if queue.closed %}{% endif %}{{ queue.closed }}{% if queue.closed %}{% endif %}
\ No newline at end of file + +
+
+
+
+ {% trans "Helpdesk Summary" %} +
+ +
+
+ + + + + + + + + + + {% for queue in dash_tickets %} + {% url 'helpdesk_list' as hdlist %} + + + + + + {% empty %} + + {% endfor %} + +
{% trans "Queue" %}{% trans "Open" %}{% trans "Resolved" %}{% trans "Closed" %}
{{ queue.name }}{% if queue.open %}{% endif %}{{ queue.open }}{% if queue.open %}{% endif %}{% if queue.resolved %}{% endif %}{{ queue.resolved }}{% if queue.resolved %}{% endif %}{% if queue.closed %}{% endif %}{{ queue.closed }}{% if queue.closed %}{% endif %}
{% trans "There are no unassigned tickets." %}
+
+ +
+ +
+ +
+
+ diff --git a/helpdesk/templates/helpdesk/include/tickets.html b/helpdesk/templates/helpdesk/include/tickets.html index 91ecfe5b..7b12ce28 100644 --- a/helpdesk/templates/helpdesk/include/tickets.html +++ b/helpdesk/templates/helpdesk/include/tickets.html @@ -1,21 +1,46 @@ {% load i18n humanize %} -{% if ticket_list_caption %} -{% endif %} - - - - -{% for ticket in ticket_list %} - - - - - - - - -{% empty %}{% if ticket_list_empty_message %} - -{% endif %}{% endfor %} - -
{{ ticket_list_caption }}
#{% trans "Pr" %}{% trans "Title" %}{% trans "Queue" %}{% trans "Status" %}{% trans "Last Update" %}
{{ ticket.ticket }}{{ ticket.priority }}{{ ticket.title }}{{ ticket.queue }}{{ ticket.get_status }}{{ ticket.modified|naturaltime }}
{{ ticket_list_empty_message }}
+ +
+
+
+
+ {% if ticket_list_caption %}{{ ticket_list_caption }}{% else %}{% trans "Your Tickets" %}{% endif %} +
+ +
+
+ + + + + + + + + + + + + {% for ticket in ticket_list %} + + + + + + + + + {% empty %} + {% if ticket_list_empty_message %}{% else %}{% endif %} + {% endfor %} + +
#{% trans "Pr" %}{% trans "Title" %}{% trans "Queue" %}{% trans "Status" %}{% trans "Last Update" %}
{{ ticket.ticket }}{{ ticket.priority }}{{ ticket.title }}{{ ticket.queue }}{{ ticket.get_status }}{{ ticket.modified|naturaltime }}
{{ ticket_list_empty_message }}{% trans "You do not have any pending tickets." %}
+
+ +
+ +
+ +
+
+ diff --git a/helpdesk/templates/helpdesk/include/unassigned.html b/helpdesk/templates/helpdesk/include/unassigned.html index 30babb51..ba4e3d57 100644 --- a/helpdesk/templates/helpdesk/include/unassigned.html +++ b/helpdesk/templates/helpdesk/include/unassigned.html @@ -1,21 +1,45 @@ {% load i18n humanize %} - - - - - - -{% for ticket in unassigned_tickets %} - - - - - - - - -{% empty %} - -{% endfor %} - -
{% trans "Unassigned Tickets" %} {% trans "(pick up a ticket if you start to work on it)" %}
#{% trans "Pr" %}{% trans "Title" %}{% trans "Queue" %}{% trans "Created" %} 
{{ ticket.ticket }}{{ ticket.priority }}{{ ticket.title }}{{ ticket.queue }}{{ ticket.created|naturaltime }}{% trans "Take" %} | {% trans "Delete" %}
{% trans "There are no unassigned tickets." %}
+ +
+
+
+
+ {% trans "Unassigned Tickets" %} {% trans "(pick up a ticket if you start to work on it)" %} +
+ +
+
+ + + + + + + + + + + + + {% for ticket in unassigned_tickets %} + + + + + + + + + {% empty %} + + {% endfor %} + +
#{% trans "Pr" %}{% trans "Title" %}{% trans "Queue" %}{% trans "Created" %} 
{{ ticket.ticket }}{{ ticket.priority }}{{ ticket.title }}{{ ticket.queue }}{{ ticket.created|naturaltime }}{% trans "Take" %} | {% trans "Delete" %}
{% trans "There are no unassigned tickets." %}
+
+ +
+ +
+ +
+
diff --git a/helpdesk/templates/helpdesk/public_base.html b/helpdesk/templates/helpdesk/public_base.html index 1acf5c58..4171b010 100644 --- a/helpdesk/templates/helpdesk/public_base.html +++ b/helpdesk/templates/helpdesk/public_base.html @@ -17,10 +17,8 @@ {% if helpdesk_settings.HELPDESK_USE_CDN %} - - + {% else %} - {% endif %} @@ -64,12 +62,16 @@ {% include "helpdesk/debug.html" %} + {% if helpdesk_settings.HELPDESK_USE_CDN %} + + {% else %} + {% endif %} {% if helpdesk_settings.HELPDESK_USE_CDN %} - + {% else %} {% endif %} diff --git a/helpdesk/templates/helpdesk/report_index.html b/helpdesk/templates/helpdesk/report_index.html index 6a8b2e85..6e6ef907 100644 --- a/helpdesk/templates/helpdesk/report_index.html +++ b/helpdesk/templates/helpdesk/report_index.html @@ -9,24 +9,92 @@

{% trans "You haven't created any tickets yet, so you cannot run any reports." %}

{% else %} - +
+
+
+
+ {% trans "Generate Report" %} +
+ + + +
+ +
+
{% endifequal %}{% endblock %} diff --git a/helpdesk/templates/helpdesk/report_output.html b/helpdesk/templates/helpdesk/report_output.html index 37b26ffb..88f34f9e 100644 --- a/helpdesk/templates/helpdesk/report_output.html +++ b/helpdesk/templates/helpdesk/report_output.html @@ -4,17 +4,38 @@ {% block helpdesk_title %}{% trans "Reports & Statistics" %}{% endblock %} {% block helpdesk_head %} - - - - - - + + + + + + + + + + + + {% if helpdesk_settings.HELPDESK_USE_CDN %} + + + {% else %} + + + {% endif %} + {% endblock %} {% block helpdesk_body %}

{% trans "Reports & Statistics" %}

+
+
+
+
+ Saved Queries +
+ +
{% if user_saved_queries_ %}

{% trans "You can run this query on filtered data by using one of your saved queries." %}

@@ -28,22 +49,59 @@ {% else %}

{% trans "Want to filter this report to just show a subset of data? Go to the Ticket List, filter your query, and save your query." %}

{% endif %} +
+ +
+ +
+
- - - -{% for h in headings %}{% endfor %} - - -{% for d in data %} -{% for f in d %}{% endfor %}{% endfor %} - -
{{ title }}
{% if forloop.first %}{{ h|title }}{% else %}{{ h }}{% endif %}
{{ f }}
+
+
+
+
+ {{ title }} +
+ +
+
+ + + {% for h in headings %} + {% endfor %} + + + + {% for d in data %} + {% for f in d %}{% endfor %} + {% endfor %} + +
{% if forloop.first %}{{ h|title }}{% else %}{{ h }}{% endif %}
{{ f }}
+
+ +
+
+
+
+ +
+ +
+
-
{% ifequal charttype "date" %} {% endifequal %} {% ifequal charttype "bar" %} {% endifequal %} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 021ac329..afd1f797 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -1017,10 +1017,50 @@ rss_list = staff_member_required(rss_list) def report_index(request): number_tickets = Ticket.objects.all().count() saved_query = request.GET.get('saved_query', None) + + user_queues = _get_user_queues(request.user) + Tickets = Ticket.objects.filter( + queue__in=user_queues, + ) + basic_ticket_stats = calc_basic_ticket_stats(Tickets) + + # The following query builds a grid of queues & ticket statuses, + # to be displayed to the user. EG: + # Open Resolved + # Queue 1 10 4 + # Queue 2 4 12 + + queues = _get_user_queues(request.user).values_list('id', flat=True) + + from_clause = """FROM helpdesk_ticket t, + helpdesk_queue q""" + if queues: + where_clause = """WHERE q.id = t.queue_id AND + q.id IN (%s)""" % (",".join(("%d" % pk for pk in queues))) + else: + where_clause = """WHERE q.id = t.queue_id""" + + cursor = connection.cursor() + cursor.execute(""" + SELECT q.id as queue, + q.title AS name, + COUNT(CASE t.status WHEN '1' THEN t.id WHEN '2' THEN t.id END) AS open, + COUNT(CASE t.status WHEN '3' THEN t.id END) AS resolved, + COUNT(CASE t.status WHEN '4' THEN t.id END) AS closed + %s + %s + GROUP BY queue, name + ORDER BY q.id; + """ % (from_clause, where_clause)) + + dash_tickets = query_to_dict(cursor.fetchall(), cursor.description) + return render(request, template_name='helpdesk/report_index.html', context = { 'number_tickets': number_tickets, 'saved_query': saved_query, + 'basic_ticket_stats': basic_ticket_stats, + 'dash_tickets': dash_tickets, }) report_index = staff_member_required(report_index) @@ -1072,7 +1112,8 @@ def run_report(request, report): periods = [] year, month = first_year, first_month working = True - periods.append("%s %s" % (month_name(month), year)) + #periods.append("%s %s" % (month_name(month), year)) + periods.append("%s-%s" % (year,month)) while working: month += 1 @@ -1081,7 +1122,7 @@ def run_report(request, report): month = 1 if (year > last_year) or (month > last_month and year >= last_year): working = False - periods.append("%s %s" % (month_name(month), year)) + periods.append("%s-%s" % (year,month)) if report == 'userpriority': title = _('User by Priority') @@ -1148,7 +1189,7 @@ def run_report(request, report): elif report == 'usermonth': metric1 = u'%s' % ticket.get_assigned_to - metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year) + metric2 = u'%s-%s' % (ticket.created.year, ticket.created.month) elif report == 'queuepriority': metric1 = u'%s' % ticket.queue.title @@ -1160,11 +1201,11 @@ def run_report(request, report): elif report == 'queuemonth': metric1 = u'%s' % ticket.queue.title - metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year) + metric2 = u'%s-%s' % (ticket.created.year, ticket.created.month) elif report == 'daysuntilticketclosedbymonth': metric1 = u'%s' % ticket.queue.title - metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year) + metric2 = u'%s-%s' % (ticket.created.year, ticket.created.month) metric3 = ticket.modified - ticket.created metric3 = metric3.days @@ -1191,12 +1232,29 @@ def run_report(request, report): data.append(summarytable[item, hdr]) table.append([item] + data) + # Zip data and headers together in one list for Morris.js charts + # will get a list like [(Header1, Data1), (Header2, Data2)...] + seriesnum = 0 + morrisjs_data = [] + for label in column_headings[1:]: + seriesnum += 1 + datadict = { "x": label } + for n in range(0,len(table)): + datadict[n] = table[n][seriesnum] + morrisjs_data.append(datadict) + + series_names = [] + for series in table: + series_names.append(series[0]) + return render(request, 'helpdesk/report_output.html', { 'title': title, 'charttype': charttype, 'data': table, 'headings': column_headings, + 'series_names': series_names, + 'morrisjs_data': morrisjs_data, 'from_saved_query': from_saved_query, 'saved_query': saved_query, })