Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / notices.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE AuthorisedValues %]
5 [% USE Branches %]
6 [% USE KohaDates %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Sent notices for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 <style>
12     .notice { display: none; }
13 </style>
14 </head>
15
16 <body id="pat_notices" class="pat">
17     [% WRAPPER 'header.inc' %]
18     [% INCLUDE 'patron-search-header.inc' %]
19 [% END %]
20
21     [% WRAPPER 'sub-header.inc' %]
22     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
23         <ol>
24             <li>
25                 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
26             </li>
27             <li>
28                 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
29             </li>
30             <li>
31                 <a href="#" aria-current="page">
32                     Sent notices for [% INCLUDE 'patron-title.inc' %]
33                 </a>
34             </li>
35         </ol>
36     </nav>
37     [% END %]
38
39     <div class="main container-fluid">
40         <div class="row">
41             <div class="col-sm-10 col-sm-push-2">
42                 <main>
43
44                     [% INCLUDE 'members-toolbar.inc' %]
45                     <h1>Sent notices for [% INCLUDE 'patron-title.inc' %]</h1>
46
47                     [% IF ( QUEUED_MESSAGES ) %]
48                         <table id="noticestable">
49                             <thead>
50                                 <tr>
51                                     <th>Notice</th>
52                                     <th>Type</th>
53                                     <th>Status</th>
54                                     <th>Updated on</th>
55                                     <th>Time created</th>
56                                     <th>Delivery note</th>
57                                 </tr>
58                             </thead>
59                             <tbody>
60                                 [% FOREACH QUEUED_MESSAGE IN QUEUED_MESSAGES %]
61                                     <tr>
62                                         <td>
63                                             <a class="notice-title" data-noticeid="[% QUEUED_MESSAGE.message_id | html %]" href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | uri %]&amp;noticeid=[% QUEUED_MESSAGE.message_id | uri %]">[% QUEUED_MESSAGE.subject | html %]</a>
64                                             <iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.content | html | html_line_break %]"></iframe>
65                                         </td>
66                                         <td>
67                                             [% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %]<span>email</span>
68                                             [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'print' ) %]<span>print</span>
69                                             [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'feed' ) %]<span>feed</span>
70                                             [% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'sms' ) %]<span>sms</span>
71                                             [% ELSE %][% QUEUED_MESSAGE.message_transport_type | html %][% END %]
72                                         </td>
73                                         <td>
74                                             [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]<span>sent</span>
75                                             [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]<span>pending</span>
76                                             [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]<span>failed</span>
77                                             [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]<span>deleted</span>
78                                             [% ELSE %][% QUEUED_MESSAGE.status | html %][% END %]
79                                             [% IF ( QUEUED_MESSAGE.status != 'pending' ) %]
80                                                 <div class="notice">
81                                                     <form id="resend_notice[% QUEUED_MESSAGE.message_id | html %]" action="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | html %]" method="POST">
82                                                         <input type="hidden" name="op" value="resend_notice" />
83                                                         <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
84                                                         <input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id | html %]" />
85                                                     </form>
86                                                 </div>
87                                             [% END %]
88                                         </td>
89                                         <td data-order="[% QUEUED_MESSAGE.updated_on | html %]">[% QUEUED_MESSAGE.updated_on | $KohaDates  with_hours => 1 %]</td>
90                                         <td data-order="[% QUEUED_MESSAGE.time_queued | html %]">[% QUEUED_MESSAGE.time_queued | $KohaDates  with_hours => 1 %]</td>
91                                         <td>
92                                             [% IF ( QUEUED_MESSAGE.failure_code ) %]
93             [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %]<span>Invalid borrowernumber [% borrowernumber | html %]</span>
94             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %]<span>Unable to find an email address for this borrower</span>
95             [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %]<span>Invalid [% matches.0 | html %] email address found [% borrowernumber | html %]</span>
96             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %]<span>Missing from email address</span>
97             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %]<span>Missing SMS number</span>
98             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %]<span>Message is duplicate</span>
99             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %]<span>No notes from SMS driver</span>
100             [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %]<span>Unhandled email failure, check the logs for further details</span>
101             [% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %]<span>Unknown error</span>
102             [% ELSE %]<span>Error occurred while sending email.</span>
103                                                 [% END %]
104                                             [% END %]
105                                         </td>
106                                     </tr>
107                                 [% END %]
108                             </tbody>
109                         </table>
110                     [% ELSE %]
111                         <div class="dialog message">There is no record of any messages that have been sent to this patron.</div>
112                     [% END %]
113
114                 </main>
115             </div> <!-- /.col-sm-10.col-sm-push-2 -->
116
117             <div class="col-sm-2 col-sm-pull-10">
118                 <aside>
119                     [% INCLUDE 'circ-menu.inc' %]
120                 </aside>
121             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
122         </div> <!-- /.row -->
123
124         <!-- Modal -->
125         <div class="modal" id="noticeModal" tabindex="-1" aria-labelledby="noticeModalLabel" aria-hidden="true">
126             <div class="modal-dialog">
127                 <div class="modal-content">
128                     <div class="modal-header">
129                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">
130                             <span aria-hidden="true">&times;</span>
131                         </button>
132                         <h5 class="modal-title" id="noticeModalLabel">Notice</h5>
133                     </div>
134                     <div class="modal-body">
135                         ...
136                     </div>
137                     <div class="modal-footer">
138                         <button type="button" id="resend-notice" class="btn btn-default" style="display:none"><i class="fa fa-refresh" aria-hidden="true"></i> Resend</button>
139                         <button type="button" class="btn btn-default deny cancel" data-dismiss="modal"><i class="fa fa-remove"></i> Close</button>
140                     </div>
141                 </div> <!-- /.modal-content -->
142             </div> <!-- /.modal-dialog -->
143         </div> <!-- /.modal -->
144
145 [% MACRO jsinclude BLOCK %]
146     [% INCLUDE 'datatables.inc' %]
147     <script>
148         $(document).ready(function() {
149             $("#noticestable").dataTable($.extend(true, {}, dataTablesDefaults, {
150                 "aaSorting": [[ 3, "desc" ]],
151                 "sPaginationType": "full"
152             }));
153
154             $("#noticestable").on("click", ".notice-title", function(e){
155                 e.preventDefault();
156                 var title = $(this).text();
157                 var noticeid = $(this).data("noticeid");
158                 var body = $("#notice" + noticeid ).attr("srcdoc");
159                 if( $("#resend_notice" + noticeid ).length ){
160                     $("#resend-notice").show();
161                 }
162                 $("#resend-notice").data("noticeid", noticeid );
163                 $("#noticeModalLabel").text( title );
164                 $("#noticeModal .modal-body").html( body );
165                 $("#noticeModal").modal("show");
166             });
167
168             $("#resend-notice").on("click", function(e){
169                 e.preventDefault();
170                 var noticeid = $(this).data("noticeid");
171                 $("#resend_notice" + noticeid ).submit();
172             });
173
174             $("#noticeModal").on("hide.bs.modal", function(){
175                 $("#resend-notice").removeData("noticeid").hide();
176                 $("#noticeModalLabel").text("");
177                 $("#noticeModal .modal-body").html("");
178             });
179         });
180     </script>
181     [% INCLUDE 'str/members-menu.inc' %]
182     [% Asset.js("js/members-menu.js") | $raw %]
183 [% END %]
184
185 [% INCLUDE 'intranet-bottom.inc' %]