blob: 1732e770cb1985c7fc4943592a51facd0976da71 [file] [log] [blame]
Anand Doshi330dae92013-09-10 13:46:15 +05301{% extends base_template %}
Rushabh Mehtada512ba2013-03-22 12:45:44 +05302
3{% set title=doc.name %}
4
Anand Doshi85ef5022013-09-04 16:46:08 +05305{% set status_label = {
6 "Open": "label-success",
7 "To Reply": "label-danger",
8 "Closed": "label-default"
9} %}
10
Rushabh Mehtada512ba2013-03-22 12:45:44 +053011{% block content %}
Anand Doshi0c8fd342013-11-21 14:55:45 +053012<div class="container content">
Rushabh Mehtada512ba2013-03-22 12:45:44 +053013 <ul class="breadcrumb">
Anand Doshif7e56482013-08-29 17:46:40 +053014 <li><a href="index">Home</a></li>
Anand Doshif7e56482013-08-29 17:46:40 +053015 <li><a href="tickets">My Tickets</a></li>
16 <li class="active"><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</li>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053017 </ul>
Anand Doshif7e56482013-08-29 17:46:40 +053018 <h3><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</h3>
Anand Doshia9c0f5d2013-09-05 12:19:00 +053019 {% if doc.name == "Not Allowed" -%}
20 <script>ask_to_login();</script>
21 {% else %}
Rushabh Mehtada512ba2013-03-22 12:45:44 +053022 <hr>
23 {%- if doc.status -%}
Anand Doshi85ef5022013-09-04 16:46:08 +053024 {% if doc.status == "Waiting for Customer" -%}
25 {% set status = "To Reply" %}
26 {% else %}
27 {% set status = doc.status %}
28 {%- endif -%}
Rushabh Mehtada512ba2013-03-22 12:45:44 +053029 <div class="row">
Anand Doshi85ef5022013-09-04 16:46:08 +053030 <div class="col-md-2" style="margin-bottom: 7px;">
31 <span class="label {{ status_label.get(status) or 'label-default' }}">{{ status }}</span>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053032 </div>
Anand Doshi85ef5022013-09-04 16:46:08 +053033 <div class="col-md-8">
34 <div class="row col-md-12">{{ doc.subject }}</div>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053035 </div>
Anand Doshi3966c4c2013-09-16 19:28:06 +053036 <div class="col-md-2">
37 <span class="text-muted pull-right">{{ utils.formatdate(doc.creation) }}</span>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053038 </div>
39 </div>
Anand Doshifb109ad2013-09-11 18:58:20 +053040 <div class="row">
41 <h4 class="col-xs-6">Messages</h4>
42 <div class="col-xs-6">
43 <button class="btn btn-sm btn-primary pull-right" id="ticket-reply">
44 <i class="icon-envelope icon-fixed-width"></i> Reply</button>
45 <button class="btn btn-sm btn-success pull-right hide" id="ticket-reply-send">
46 <i class="icon-arrow-right icon-fixed-width"></i> Send</button>
47 </div>
48 </div>
49 <p id="ticket-alert" class="alert alert-danger"
50 style="display: none;">&nbsp;</p>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053051 {%- if doclist.get({"doctype":"Communication"}) -%}
Anand Doshi85ef5022013-09-04 16:46:08 +053052 <div>
Anand Doshifb109ad2013-09-11 18:58:20 +053053 <table class="table table-bordered table-striped" id="ticket-thread">
Rushabh Mehtada512ba2013-03-22 12:45:44 +053054 <tbody>
Anand Doshifb109ad2013-09-11 18:58:20 +053055 {%- for comm in
56 (doclist.get({"doctype":"Communication"})|sort(reverse=True, attribute="creation")) %}
Rushabh Mehtada512ba2013-03-22 12:45:44 +053057 <tr>
58 <td>
Anand Doshi85ef5022013-09-04 16:46:08 +053059 <h5 style="text-transform: none">
Anand Doshifb109ad2013-09-11 18:58:20 +053060 {{ comm.sender }} on {{ utils.formatdate(comm.creation) }}</h5>
Anand Doshia9c0f5d2013-09-05 12:19:00 +053061 <hr>
Anand Doshi85ef5022013-09-04 16:46:08 +053062 <p>{{ webnotes.utils.is_html(comm.content) and comm.content or
63 comm.content.replace("\n", "<br>")}}</p>
Rushabh Mehtada512ba2013-03-22 12:45:44 +053064 </td>
65 </tr>
66 {% endfor -%}
67 </tbody>
68 </table>
69 </div>
70 {%- else -%}
71 <div class="alert">No messages</div>
72 {%- endif -%}
73 {%- endif -%}
Anand Doshia9c0f5d2013-09-05 12:19:00 +053074 {% endif -%}
Rushabh Mehtada512ba2013-03-22 12:45:44 +053075</div>
Anand Doshifb109ad2013-09-11 18:58:20 +053076{% endblock %}
77
78{% block javascript %}
79<script>
80$(document).ready(function() {
81 $("#ticket-reply").on("click", function() {
82 if(!$("#ticket-reply-editor").length) {
83 $('<tr id="ticket-reply-editor"><td>\
84 <h5 style="text-transform: none">Reply</h5>\
85 <hr>\
86 <textarea rows=10 class="form-control" style="resize: vertical;"></textarea>\
87 </td></tr>').prependTo($("#ticket-thread").find("tbody"));
88 $("#ticket-reply").addClass("hide");
89 $("#ticket-reply-send").removeClass("hide");
90 }
91 });
92
93 $("#ticket-reply-send").on("click", function() {
94 var reply = $("#ticket-reply-editor").find("textarea").val().trim();
95 if(!reply) {
96 msgprint("Please write something in reply!");
97 } else {
98 wn.call({
99 type: "POST",
100 method: "support.doctype.support_ticket.templates.pages.ticket.add_reply",
101 btn: this,
102 args: { ticket: "{{ doc.name }}", message: reply },
103 callback: function(r) {
104 if(r.exc) {
105 msgprint(r._server_messages
106 ? JSON.parse(r._server_messages).join("<br>")
107 : "Something went wrong!");
108 } else {
109 window.location.reload();
110 }
111 }
112 })
113 }
114 });
115});
116
117var msgprint = function(txt) {
118 if(txt) $("#ticket-alert").html(txt).toggle(true);
119}
120</script>
Rushabh Mehtada512ba2013-03-22 12:45:44 +0530121{% endblock %}