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