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