Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 1 | {% extends base_template %} |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 2 | |
| 3 | {% set title=doc.name %} |
| 4 | |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 5 | {% set status_label = { |
| 6 | "Open": "label-success", |
| 7 | "To Reply": "label-danger", |
| 8 | "Closed": "label-default" |
| 9 | } %} |
| 10 | |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 11 | {% block content %} |
Anand Doshi | 0c8fd34 | 2013-11-21 14:55:45 +0530 | [diff] [blame] | 12 | <div class="container content"> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 13 | <ul class="breadcrumb"> |
Anand Doshi | f7e5648 | 2013-08-29 17:46:40 +0530 | [diff] [blame] | 14 | <li><a href="index">Home</a></li> |
Anand Doshi | f7e5648 | 2013-08-29 17:46:40 +0530 | [diff] [blame] | 15 | <li><a href="tickets">My Tickets</a></li> |
| 16 | <li class="active"><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</li> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 17 | </ul> |
Anand Doshi | f7e5648 | 2013-08-29 17:46:40 +0530 | [diff] [blame] | 18 | <h3><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</h3> |
Anand Doshi | a9c0f5d | 2013-09-05 12:19:00 +0530 | [diff] [blame] | 19 | {% if doc.name == "Not Allowed" -%} |
| 20 | <script>ask_to_login();</script> |
| 21 | {% else %} |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 22 | <hr> |
| 23 | {%- if doc.status -%} |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 24 | {% if doc.status == "Waiting for Customer" -%} |
| 25 | {% set status = "To Reply" %} |
| 26 | {% else %} |
| 27 | {% set status = doc.status %} |
| 28 | {%- endif -%} |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 29 | <div class="row"> |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 30 | <div class="col-md-2" style="margin-bottom: 7px;"> |
| 31 | <span class="label {{ status_label.get(status) or 'label-default' }}">{{ status }}</span> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 32 | </div> |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 33 | <div class="col-md-8"> |
| 34 | <div class="row col-md-12">{{ doc.subject }}</div> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 35 | </div> |
Anand Doshi | 3966c4c | 2013-09-16 19:28:06 +0530 | [diff] [blame] | 36 | <div class="col-md-2"> |
| 37 | <span class="text-muted pull-right">{{ utils.formatdate(doc.creation) }}</span> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 38 | </div> |
| 39 | </div> |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 40 | <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;"> </p> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 51 | {%- if doclist.get({"doctype":"Communication"}) -%} |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 52 | <div> |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 53 | <table class="table table-bordered table-striped" id="ticket-thread"> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 54 | <tbody> |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 55 | {%- for comm in |
| 56 | (doclist.get({"doctype":"Communication"})|sort(reverse=True, attribute="creation")) %} |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 57 | <tr> |
| 58 | <td> |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 59 | <h5 style="text-transform: none"> |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 60 | {{ comm.sender }} on {{ utils.formatdate(comm.creation) }}</h5> |
Anand Doshi | a9c0f5d | 2013-09-05 12:19:00 +0530 | [diff] [blame] | 61 | <hr> |
Anand Doshi | 85ef502 | 2013-09-04 16:46:08 +0530 | [diff] [blame] | 62 | <p>{{ webnotes.utils.is_html(comm.content) and comm.content or |
| 63 | comm.content.replace("\n", "<br>")}}</p> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 64 | </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 Doshi | a9c0f5d | 2013-09-05 12:19:00 +0530 | [diff] [blame] | 74 | {% endif -%} |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 75 | </div> |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 76 | {% 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 | |
| 117 | var msgprint = function(txt) { |
| 118 | if(txt) $("#ticket-alert").html(txt).toggle(true); |
| 119 | } |
| 120 | </script> |
Rushabh Mehta | da512ba | 2013-03-22 12:45:44 +0530 | [diff] [blame] | 121 | {% endblock %} |