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