Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
| 6 | from webnotes.utils import cint, formatdate |
| 7 | |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 8 | no_cache = True |
| 9 | |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 10 | def 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() |
| 20 | def 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 Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 28 | return tickets |
| 29 | |
| 30 | @webnotes.whitelist() |
| 31 | def make_new_ticket(subject, message): |
| 32 | if not (subject and message): |
| 33 | raise webnotes.throw(_("Please write something in subject and message!")) |
| 34 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 35 | from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 36 | ticket = add_support_communication(subject, message, webnotes.session.user) |
| 37 | |
| 38 | return ticket.doc.name |