blob: 7434af2075ae72d0de22829d956fe6eaae2d51ab [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshi330dae92013-09-10 13:46:15 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
6from webnotes.utils import cint, formatdate
7
Anand Doshib0d996f2013-09-10 18:29:39 +05308no_cache = True
9
Anand Doshi330dae92013-09-10 13:46:15 +053010def get_context():
11 return {
12 "title": "My Tickets",
13 "method": "support.doctype.support_ticket.templates.pages.tickets.get_tickets",
14 "icon": "icon-ticket",
15 "empty_list_message": "No Tickets Raised",
16 "page": "ticket"
17 }
18
19@webnotes.whitelist()
20def get_tickets(start=0):
21 tickets = webnotes.conn.sql("""select name, subject, status, creation
22 from `tabSupport Ticket` where raised_by=%s
23 order by modified desc
24 limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True)
25 for t in tickets:
26 t.creation = formatdate(t.creation)
27
Anand Doshifb109ad2013-09-11 18:58:20 +053028 return tickets
29
30@webnotes.whitelist()
31def make_new_ticket(subject, message):
32 if not (subject and message):
33 raise webnotes.throw(_("Please write something in subject and message!"))
34
Rushabh Mehta1f847992013-12-12 19:12:19 +053035 from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication
Anand Doshifb109ad2013-09-11 18:58:20 +053036 ticket = add_support_communication(subject, message, webnotes.session.user)
37
38 return ticket.doc.name