|
Lines 49-165
Link Here
|
| 49 |
|
49 |
|
| 50 |
[% IF ( QUEUED_MESSAGES ) %] |
50 |
[% IF ( QUEUED_MESSAGES ) %] |
| 51 |
<div class="page-section"> |
51 |
<div class="page-section"> |
| 52 |
<table id="noticestable"> |
52 |
<span id="checkbox_actions" |
| 53 |
<thead> |
53 |
><a href="#" class="select_all"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="clear_all"><i class="fa fa-remove"></i> Clear all</a></span |
| 54 |
<tr> |
54 |
> |
| 55 |
<th>Notice</th> |
55 |
<form id="print_multiple" action="/cgi-bin/koha/tools/print_notice.pl" method="post" target="_blank"> |
| 56 |
<th>Type</th> |
56 |
[% INCLUDE 'csrf-token.inc' %] |
| 57 |
<th>Status</th> |
57 |
|
| 58 |
<th>Updated on</th> |
58 |
<table id="noticestable"> |
| 59 |
<th>Time created</th> |
59 |
<thead> |
| 60 |
<th>Delivery note</th> |
|
|
| 61 |
[% IF CAN_user_tools_view_generated_notices %] |
| 62 |
<th>Actions</th> |
| 63 |
[% END %] |
| 64 |
</tr> |
| 65 |
</thead> |
| 66 |
<tbody> |
| 67 |
[% FOREACH QUEUED_MESSAGE IN QUEUED_MESSAGES %] |
| 68 |
<tr> |
60 |
<tr> |
| 69 |
<td> |
61 |
<th class="nosort"> </th> |
| 70 |
<a |
62 |
<th>Time created</th> |
| 71 |
class="notice-title" |
63 |
<th>Notice</th> |
| 72 |
data-noticeid="[% QUEUED_MESSAGE.message_id | html %]" |
64 |
<th>Type</th> |
| 73 |
href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | uri %]&noticeid=[% QUEUED_MESSAGE.message_id | uri %]" |
65 |
<th>Status</th> |
| 74 |
>[% QUEUED_MESSAGE.subject | html %]</a |
66 |
<th>Updated on</th> |
| 75 |
> |
67 |
<th>Delivery note</th> |
| 76 |
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.html_content | html %]"></iframe> |
68 |
<th>Actions</th> |
| 77 |
</td> |
69 |
</tr> |
| 78 |
<td> |
70 |
</thead> |
| 79 |
[% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %] |
71 |
<tbody> |
| 80 |
<span>email</span> |
72 |
[% FOREACH QUEUED_MESSAGE IN QUEUED_MESSAGES %] |
| 81 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'print' ) %] |
73 |
<tr> |
| 82 |
<span>print</span> |
74 |
<td><input type="checkbox" name="message_ids" value="[% QUEUED_MESSAGE.message_id | html %]" [% IF QUEDUE_MESSAGE.status == 'pending' %]disabled="disabled"[% END %] /></td> |
| 83 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'feed' ) %] |
75 |
<td data-order="[% QUEUED_MESSAGE.time_queued | html %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</td> |
| 84 |
<span>feed</span> |
76 |
<td> |
| 85 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'sms' ) %] |
77 |
<a |
| 86 |
<span>sms</span> |
78 |
class="notice-title" |
| 87 |
[% ELSE %] |
79 |
data-noticeid="[% QUEUED_MESSAGE.message_id | html %]" |
| 88 |
[% QUEUED_MESSAGE.message_transport_type | html %] |
80 |
data-status="[% QUEUED_MESSAGE.status | html %]" |
| 89 |
[% END %] |
81 |
data-borrowernumber="[% borrowernumber | html %]" |
| 90 |
</td> |
82 |
href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | uri %]&noticeid=[% QUEUED_MESSAGE.message_id | uri %]" |
| 91 |
<td> |
83 |
>[% QUEUED_MESSAGE.subject | html %]</a |
| 92 |
[% IF ( QUEUED_MESSAGE.status == 'sent' ) %] |
84 |
> |
| 93 |
<span>sent</span> |
85 |
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.html_content | html %]"></iframe> |
| 94 |
[% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %] |
86 |
</td> |
| 95 |
<span>pending</span> |
87 |
<td> |
| 96 |
[% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %] |
88 |
[% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %] |
| 97 |
<span>failed</span> |
89 |
<span>email</span> |
| 98 |
[% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %] |
90 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'print' ) %] |
| 99 |
<span>deleted</span> |
91 |
<span>print</span> |
| 100 |
[% ELSE %] |
92 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'feed' ) %] |
| 101 |
[% QUEUED_MESSAGE.status | html %] |
93 |
<span>feed</span> |
| 102 |
[% END %] |
94 |
[% ELSIF ( QUEUED_MESSAGE.message_transport_type == 'sms' ) %] |
| 103 |
[% IF ( QUEUED_MESSAGE.status != 'pending' ) %] |
95 |
<span>sms</span> |
| 104 |
<div class="notice"> |
|
|
| 105 |
<form id="resend_notice[% QUEUED_MESSAGE.message_id | html %]" action="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | html %]" method="POST"> |
| 106 |
[% INCLUDE 'csrf-token.inc' %] |
| 107 |
<input type="hidden" name="op" value="cud-resend_notice" /> |
| 108 |
<input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" /> |
| 109 |
<input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id | html %]" /> |
| 110 |
</form> |
| 111 |
</div> |
| 112 |
[% END %] |
| 113 |
</td> |
| 114 |
<td data-order="[% QUEUED_MESSAGE.updated_on | html %]">[% QUEUED_MESSAGE.updated_on | $KohaDates with_hours => 1 %]</td> |
| 115 |
<td data-order="[% QUEUED_MESSAGE.time_queued | html %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</td> |
| 116 |
<td> |
| 117 |
[% IF ( QUEUED_MESSAGE.failure_code ) %] |
| 118 |
[% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %] |
| 119 |
<span class="clearfix">Invalid borrowernumber [% borrowernumber | html %]</span> |
| 120 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %] |
| 121 |
<span class="clearfix">Unable to find an email address for this patron</span> |
| 122 |
[% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %] |
| 123 |
<span class="clearfix">Invalid [% matches.0 | html %] email address found [% borrowernumber | html %]</span> |
| 124 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %] |
| 125 |
<span class="clearfix">Missing from email address</span> |
| 126 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %] |
| 127 |
<span class="clearfix">Missing SMS number</span> |
| 128 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %] |
| 129 |
<span class="clearfix">Message is duplicate</span> |
| 130 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %] |
| 131 |
<span class="clearfix">No notes from SMS driver</span> |
| 132 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'SMS_SEND_DRIVER_MISSING' ) %] |
| 133 |
<span class="clearfix">The SMS driver could not be loaded</span> |
| 134 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %] |
| 135 |
<span class="clearfix">Unhandled email failure, check the logs for further details</span> |
| 136 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %] |
| 137 |
<span class="clearfix">Unknown error</span> |
| 138 |
[% ELSE %] |
96 |
[% ELSE %] |
| 139 |
<span class="clearfix">Message failed to send with the following error: [% QUEUED_MESSAGE.failure_code | html %]</span> |
97 |
[% QUEUED_MESSAGE.message_transport_type | html %] |
| 140 |
[% END %] |
98 |
[% END %] |
| 141 |
[% END %] |
99 |
</td> |
| 142 |
[% IF ( QUEUED_MESSAGE.status == 'sent' ) %] |
100 |
<td> |
| 143 |
[% IF ( QUEUED_MESSAGE.from_address ) %] |
101 |
[% IF ( QUEUED_MESSAGE.status == 'sent' ) %] |
| 144 |
<span class="clearfix"><span class="label">From:</span> [% QUEUED_MESSAGE.from_address | html %]</span> |
102 |
<span>sent</span> |
|
|
103 |
[% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %] |
| 104 |
<span>pending</span> |
| 105 |
[% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %] |
| 106 |
<span>failed</span> |
| 107 |
[% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %] |
| 108 |
<span>deleted</span> |
| 109 |
[% ELSE %] |
| 110 |
[% QUEUED_MESSAGE.status | html %] |
| 145 |
[% END %] |
111 |
[% END %] |
| 146 |
[% IF ( QUEUED_MESSAGE.to_address ) %] |
112 |
</td> |
| 147 |
<span class="clearfix"><span class="label">To:</span> [% QUEUED_MESSAGE.to_address | html %]</span> |
113 |
<td data-order="[% QUEUED_MESSAGE.updated_on | html %]">[% QUEUED_MESSAGE.updated_on | $KohaDates with_hours => 1 %]</td> |
|
|
114 |
<td> |
| 115 |
[% IF ( QUEUED_MESSAGE.failure_code ) %] |
| 116 |
[% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %] |
| 117 |
<span class="clearfix">Invalid borrowernumber [% borrowernumber | html %]</span> |
| 118 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %] |
| 119 |
<span class="clearfix">Unable to find an email address for this patron</span> |
| 120 |
[% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %] |
| 121 |
<span class="clearfix">Invalid [% matches.0 | html %] email address found [% borrowernumber | html %]</span> |
| 122 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %] |
| 123 |
<span class="clearfix">Missing from email address</span> |
| 124 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %] |
| 125 |
<span class="clearfix">Missing SMS number</span> |
| 126 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %] |
| 127 |
<span class="clearfix">Message is duplicate</span> |
| 128 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %] |
| 129 |
<span class="clearfix">No notes from SMS driver</span> |
| 130 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'SMS_SEND_DRIVER_MISSING' ) %] |
| 131 |
<span class="clearfix">The SMS driver could not be loaded</span> |
| 132 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %] |
| 133 |
<span class="clearfix">Unhandled email failure, check the logs for further details</span> |
| 134 |
[% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %] |
| 135 |
<span class="clearfix">Unknown error</span> |
| 136 |
[% ELSE %] |
| 137 |
<span class="clearfix">Message failed to send with the following error: [% QUEUED_MESSAGE.failure_code | html %]</span> |
| 138 |
[% END %] |
| 148 |
[% END %] |
139 |
[% END %] |
| 149 |
[% IF ( QUEUED_MESSAGE.cc_address ) %] |
140 |
[% IF ( QUEUED_MESSAGE.status != 'pending' ) %] |
| 150 |
<span class="clearfix"><span class="label">CC:</span> [% QUEUED_MESSAGE.cc_address | html %]</span> |
141 |
[% IF ( QUEUED_MESSAGE.from_address ) %] |
|
|
142 |
<span class="clearfix"><span class="label">From:</span> [% QUEUED_MESSAGE.from_address | html %]</span> |
| 143 |
[% END %] |
| 144 |
[% IF ( QUEUED_MESSAGE.to_address ) %] |
| 145 |
<span class="clearfix"><span class="label">To:</span> [% QUEUED_MESSAGE.to_address | html %]</span> |
| 146 |
[% END %] |
| 147 |
[% IF ( QUEUED_MESSAGE.cc_address ) %] |
| 148 |
<span class="clearfix"><span class="label">CC:</span> [% QUEUED_MESSAGE.cc_address | html %]</span> |
| 149 |
[% END %] |
| 151 |
[% END %] |
150 |
[% END %] |
| 152 |
[% END %] |
151 |
</td> |
| 153 |
</td> |
|
|
| 154 |
[% IF CAN_user_tools_view_generated_notices %] |
| 155 |
<td class="actions" |
152 |
<td class="actions" |
| 156 |
><a target="_blank" class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/print_notice.pl?message_ids=[% QUEUED_MESSAGE.message_id | uri %]"><i class="fa fa-print"></i> Print</a></td |
153 |
><a target="_blank" class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/print_notice.pl?message_ids=[% QUEUED_MESSAGE.message_id | uri %]"><i class="fa fa-print"></i> Print</a></td |
| 157 |
> |
154 |
> |
| 158 |
[% END %] |
155 |
</tr> |
| 159 |
</tr> |
156 |
[% END %] |
| 160 |
[% END %] |
157 |
</tbody> |
| 161 |
</tbody> |
158 |
</table> |
| 162 |
</table> |
159 |
<fieldset class="action"> |
|
|
160 |
<input type="submit" class="btn btn-primary" value="Print selected notices" id="print_multiple_button" /> |
| 161 |
</fieldset> |
| 162 |
</form> |
| 163 |
</div> |
163 |
</div> |
| 164 |
<!-- /.page-section --> |
164 |
<!-- /.page-section --> |
| 165 |
[% ELSE %] |
165 |
[% ELSE %] |
|
Lines 176-183
Link Here
|
| 176 |
</div> |
176 |
</div> |
| 177 |
<div class="modal-body"> ... </div> |
177 |
<div class="modal-body"> ... </div> |
| 178 |
<div class="modal-footer"> |
178 |
<div class="modal-footer"> |
| 179 |
<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> |
179 |
<form id="resend_notice" action="/cgi-bin/koha/members/notices.pl" method="POST" style="display:none"> |
| 180 |
<button type="button" class="btn btn-default deny cancel" data-bs-dismiss="modal"><i class="fa fa-times"></i> Close</button> |
180 |
[% INCLUDE 'csrf-token.inc' %] |
|
|
181 |
<input type="hidden" name="op" value="cud-resend_notice" /> |
| 182 |
<input type="hidden" name="borrowernumber" value="" /> |
| 183 |
<input type="hidden" name="message_id" value="" /> |
| 184 |
<button type="submit" id="resend_notice_button" class="btn btn-default"><i class="fa-solid fa-rotate" aria-hidden="true"></i> Resend</button> |
| 185 |
</form> |
| 186 |
<button type="button" class="btn btn-default deny cancel" data-bs-dismiss="modal"><i class="fa fa-remove"></i> Close</button> |
| 181 |
</div> |
187 |
</div> |
| 182 |
</div> |
188 |
</div> |
| 183 |
<!-- /.modal-content --> |
189 |
<!-- /.modal-content --> |
|
Lines 200-225
Link Here
|
| 200 |
var title = $(this).text(); |
206 |
var title = $(this).text(); |
| 201 |
var noticeid = $(this).data("noticeid"); |
207 |
var noticeid = $(this).data("noticeid"); |
| 202 |
var body = $("#notice" + noticeid).attr("srcdoc"); |
208 |
var body = $("#notice" + noticeid).attr("srcdoc"); |
| 203 |
if ($("#resend_notice" + noticeid).length) { |
209 |
if ($(this).data("status") !== "pending") { |
| 204 |
$("#resend-notice").show(); |
210 |
let borrowerNumber = $(this).data("borrowernumber"); |
|
|
211 |
$('#resend_notice input[name="borrowernumber"]').val(borrowerNumber); |
| 212 |
$('#resend_notice input[name="message_id"]').val(noticeid); |
| 213 |
$("#resend_notice").show(); |
| 205 |
} |
214 |
} |
| 206 |
$("#resend-notice").data("noticeid", noticeid); |
|
|
| 207 |
$("#noticeModalLabel").text(title); |
215 |
$("#noticeModalLabel").text(title); |
| 208 |
$("#noticeModal .modal-body").html(body); |
216 |
$("#noticeModal .modal-body").html(body); |
| 209 |
$("#noticeModal").modal("show"); |
217 |
$("#noticeModal").modal("show"); |
| 210 |
}); |
218 |
}); |
| 211 |
|
219 |
|
| 212 |
$("#resend-notice").on("click", function (e) { |
|
|
| 213 |
e.preventDefault(); |
| 214 |
var noticeid = $(this).data("noticeid"); |
| 215 |
$("#resend_notice" + noticeid).submit(); |
| 216 |
}); |
| 217 |
|
| 218 |
$("#noticeModal").on("hide.bs.modal", function () { |
220 |
$("#noticeModal").on("hide.bs.modal", function () { |
| 219 |
$("#resend-notice").removeData("noticeid").hide(); |
221 |
$('#resend_notice input[name="borrowernumber"]').val(""); |
|
|
222 |
$('#resend_notice input[name="message_id"]').val(""); |
| 223 |
$("#resend_notice").hide(); |
| 220 |
$("#noticeModalLabel").text(""); |
224 |
$("#noticeModalLabel").text(""); |
| 221 |
$("#noticeModal .modal-body").html(""); |
225 |
$("#noticeModal .modal-body").html(""); |
| 222 |
}); |
226 |
}); |
|
|
227 |
|
| 228 |
$("#print_multiple_button").click(function (e) { |
| 229 |
var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked"); |
| 230 |
if (selected_notices.length == 0) { |
| 231 |
alert(_("Please select at least one sent notice.")); |
| 232 |
e.preventDefault(); |
| 233 |
return false; |
| 234 |
} |
| 235 |
}); |
| 236 |
|
| 237 |
$(".select_all").click(function (e) { |
| 238 |
e.preventDefault(); |
| 239 |
$("input[name='message_ids']").each(function () { |
| 240 |
$(this).prop("checked", true); |
| 241 |
}); |
| 242 |
}); |
| 243 |
|
| 244 |
$(".clear_all").click(function (e) { |
| 245 |
e.preventDefault(); |
| 246 |
$("input[name='message_ids']").each(function () { |
| 247 |
$(this).prop("checked", false); |
| 248 |
}); |
| 249 |
}); |
| 223 |
}); |
250 |
}); |
| 224 |
</script> |
251 |
</script> |
| 225 |
[% INCLUDE 'str/members-menu.inc' %] |
252 |
[% INCLUDE 'str/members-menu.inc' %] |