View | Details | Raw Unified | Return to bug 33260
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (-1 / +4 lines)
Lines 7-13 Link Here
7
        <ul>
7
        <ul>
8
            <li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools home</a></li>
8
            <li><a href="/cgi-bin/koha/tools/tools-home.pl">Tools home</a></li>
9
        </ul>
9
        </ul>
10
        [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons  || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons  || CAN_user_tools_edit_patrons || CAN_user_tools_moderate_tags || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || CAN_user_tools_rotating_collections ) %]
10
        [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons  || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons  || CAN_user_tools_edit_patrons || CAN_user_tools_moderate_tags || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || CAN_user_tools_rotating_collections ) || ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %]
11
            <h5>Patrons and circulation</h5>
11
            <h5>Patrons and circulation</h5>
12
            <ul>
12
            <ul>
13
                [% IF ( CAN_user_tools_manage_patron_lists ) %]
13
                [% IF ( CAN_user_tools_manage_patron_lists ) %]
Lines 28-33 Link Here
28
                [% IF ( CAN_user_tools_edit_notice_status_triggers ) %]
28
                [% IF ( CAN_user_tools_edit_notice_status_triggers ) %]
29
                    <li><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></li>
29
                    <li><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></li>
30
                [% END %]
30
                [% END %]
31
                [% IF ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %]
32
                    <li><a href="/cgi-bin/koha/tools/notices.pl">Notices management</a></li>
33
                [% END %]
31
                [% IF ( CAN_user_tools_label_creator ) %]
34
                [% IF ( CAN_user_tools_label_creator ) %]
32
                    <li><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></li>
35
                    <li><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></li>
33
                [% END %]
36
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt (+264 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE KohaDates %]
4
[% USE Branches %]
5
[% USE Categories %]
6
[% USE TablesSettings %]
7
[% SET footerjs = 1 %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
<title>Notices management &rsaquo; Tools &rsaquo; Koha</title>
10
[% PROCESS "patron-search.inc" %]
11
[% SET libraries = Branches.all %]
12
[% SET categories = Categories.all.unblessed %]
13
[% SET columns = ['name', 'cardnumber', 'dateofbirth', 'category', 'branch', 'address', 'phone'] %]
14
[% INCLUDE 'doc-head-close.inc' %]
15
<style>
16
    .notice { display: none; }
17
</style>
18
</head>
19
20
<body id="tools_notices_mgmt" class="tools">
21
[% WRAPPER 'header.inc' %]
22
    [% INCLUDE 'circ-search.inc' %]
23
[% END %]
24
25
[% WRAPPER 'sub-header.inc' %]
26
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27
    <ol>
28
        <li>
29
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30
        </li>
31
        <li>
32
            <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
33
        </li>
34
        <li>
35
            <a href="#" aria-current="page">
36
                Notices management
37
            </a>
38
        </li>
39
    </ol>
40
</nav>
41
[% END %]
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
                <h1>Notices management</h1>
49
50
                [% IF notices %]
51
52
                <table id="notices">
53
                    <thead>
54
                        <tr>
55
                            <th>Time created</th>
56
                            <th>Patron</th>
57
                            <th>Notice</th>
58
                            <th>Type</th>
59
                            <th>Status</th>
60
                            <th>Updated on</th>
61
                            <th>Actions</th>
62
                        </tr>
63
                    </thead>
64
                    <tbody>
65
                        [% FOREACH notice IN notices %]
66
                        <tr>
67
                            <td>[% notice.time_queued | $KohaDates with_hours = 1 %]</td>
68
                            <td>[% INCLUDE 'patron-title.inc' patron=notice.patron hide_patron_infos_if_needed=1 %]</td>
69
                            <td>
70
                                <a class="notice-title" data-noticeid="[% notice.message_id | html %]" href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% notice.borrowernumber | uri %]&amp;noticeid=[% notice.message_id | uri %]">[% notice.subject | html %]</a>
71
                                <iframe class="notice" id="notice[% notice.message_id | html %]" srcdoc="[% notice.content | html | html_line_break %]"></iframe>
72
                            </td>
73
                            <td>[% notice.message_transport_type | html %]</td>
74
                            <td>[% notice.status | html %]</td>
75
                            <td>[% notice.updated_on | $KohaDates with_hours = 1 %]</td>
76
                            <td class="actions"><button class="btn btn-default btn-xs print"><i class="fa fa-print"></i> Print</button></td>
77
                        </tr>
78
                        [% END %]
79
                    </tbody>
80
                </table>
81
82
                [% ELSE %]
83
84
                <div class="dialog message">
85
                    Use the search form on the left to find sent notices.
86
                </div>
87
88
                [% END %]
89
90
            </main>
91
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
92
93
        <div class="col-sm-2 col-sm-pull-10">
94
            <aside>
95
                <fieldset class="sidebar brief">
96
                    <h3>Go to a patron's notices</h3>
97
                    <ol>
98
                        <li>
99
                            <div id="notices_patronsearch_pane" role="tabpanel" class="tab-pane active">
100
                                [% PROCESS patron_search_filters_simple %]
101
                                [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
102
                            </div>
103
                        </li>
104
                    </ol>
105
                </fieldset>
106
                <fieldset class="sidebar brief">
107
                    <form id="notices-search" action="/cgi-bin/koha/tools/notices.pl" method="post">
108
                        <input type="hidden" name="op" value="search">
109
                        <h3>Search filters</h3>
110
                        <ol>
111
                            <li>
112
                                <label for="branchcode">Library:</label>
113
                                <select id="branchcode" name="branchcode">
114
                                    <option value="">All libraries</option>
115
                                    [% FOREACH branch IN Branches.all( selected => branchcode ) %]
116
                                        [% IF ( branch.selected ) %]
117
                                            <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
118
                                        [% ELSE %]
119
                                            <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
120
                                        [% END %]
121
                                    [% END %]
122
                                </select>
123
                            </li>
124
                            <li>
125
                                <label for="letter_code">Notice:</label>
126
                                <select id="letter_code" name="letter_code">
127
                                    <option value="">All notices</option>
128
                                    [% FOREACH letter IN letters %]
129
                                        [% IF ( letter.code == letter_code ) %]
130
                                            <option selected="selected" value="[% letter.code | html %]">[% letter.name | html %] ([% letter.code | html %])</option>
131
                                        [% ELSE %]
132
                                            <option value="[% letter.code | html %]">[% letter.name | html %] ([% letter.code | html %])</option>
133
                                        [% END %]
134
                                    [% END %]
135
                                </select>
136
                            </li>
137
                            <li>
138
                                <label for="status">Notice status:</label>
139
                                <select id="status" name="status">
140
                                    <option value="">All statuses</option>
141
                                    [% IF status == 'sent' %]
142
                                    <option selected="selected" value="sent">Sent</option>
143
                                    [% ELSE %]
144
                                    <option value="sent">Sent</option>
145
                                    [% END %]
146
                                    [% IF status == 'sent' %]
147
                                    <option selected="selected" value="pending">Pending</option>
148
                                    [% ELSE %]
149
                                    <option value="pending">Pending</option>
150
                                    [% END %]
151
                                    [% IF status == 'sent' %]
152
                                    <option selected="selected" value="failed">Failed</option>
153
                                    [% ELSE %]
154
                                    <option value="failed">Failed</option>
155
                                    [% END %]
156
                                    [% IF status == 'sent' %]
157
                                    <option selected="selected" value="deleted">Deleted</option>
158
                                    [% ELSE %]
159
                                    <option value="deleted">Deleted</option>
160
                                    [% END %]
161
                                </select>
162
                            </li>
163
                            <li>
164
                                <fieldset class="brief">
165
                                    <legend>Date queued</legend>
166
                                    <ol>
167
                                        <li>
168
                                            <label for="from">From:</label>
169
                                            <input type="text" id="from" name="from" size="10" value="[% from | html %]" class="flatpickr" data-date_to="to" />
170
                                            <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
171
                                        </li>
172
                                        <li>
173
                                            <label for="to">To:</label>
174
                                            <input type="text" id="to" name="to" size="10" value="[% to | html %]" class="flatpickr" />
175
                                            <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
176
                                        </li>
177
                                    </ol>
178
                                </fieldset>
179
                            </li>
180
                            <li>
181
                                <label for="categorycode">Patron category:</label>
182
                                <select id="categorycode" name="categorycode">
183
                                    <option value="">All patron categories</option>
184
                                    [% FOREACH category IN Categories.all %]
185
                                        [% IF ( category.categorycode == categorycode ) %]
186
                                            <option selected="selected" value="[% category.categorycode | html %]">[% category.description | html %]</option>
187
                                        [% ELSE %]
188
                                            <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
189
                                        [% END %]
190
                                    [% END %]
191
                                </select>
192
                            </li>
193
                        </ol>
194
                        <fieldset class="action">
195
                            <input type="submit" class="btn btn-primary" value="Search">
196
                        </fieldset>
197
                    </form>
198
                </fieldset>
199
                [% INCLUDE 'tools-menu.inc' %]
200
            </aside>
201
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
202
     </div> <!-- /.row -->
203
204
<!-- Modal -->
205
<div class="modal" id="noticeModal" tabindex="-1" aria-labelledby="noticeModalLabel" aria-hidden="true">
206
    <div class="modal-dialog">
207
        <div class="modal-content">
208
            <div class="modal-header">
209
                <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">
210
                    <span aria-hidden="true">&times;</span>
211
                </button>
212
                <h5 class="modal-title" id="noticeModalLabel">Notice</h5>
213
            </div>
214
            <div class="modal-body">
215
                ...
216
            </div>
217
            <div class="modal-footer">
218
                <button type="button" class="btn btn-default deny cancel" data-dismiss="modal"><i class="fa fa-remove"></i> Close</button>
219
            </div>
220
        </div> <!-- /.modal-content -->
221
    </div> <!-- /.modal-dialog -->
222
</div> <!-- /.modal -->
223
224
[% MACRO jsinclude BLOCK %]
225
    [% Asset.js("js/tools-menu.js") | $raw %]
226
    [% INCLUDE 'calendar.inc' %]
227
    [% INCLUDE 'datatables.inc' %]
228
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/tools/notices.pl?', redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/tools/notices.pl?', redirect_if_attribute_equal => 'cardnumber' %]
229
230
    <script>
231
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
232
        $(document).ready(function() {
233
            $("#notices").dataTable($.extend(true, {}, dataTablesDefaults, {
234
                "aaSorting": [[ 3, "desc" ]],
235
                "sPaginationType": "full"
236
            }));
237
238
            $("#notices").on("click", ".notice-title", function(e){
239
                e.preventDefault();
240
                var title = $(this).text();
241
                var noticeid = $(this).data("noticeid");
242
                var body = $("#notice" + noticeid ).attr("srcdoc");
243
                $("#noticeModalLabel").text( title );
244
                $("#noticeModal .modal-body").html( body );
245
                $("#noticeModal").modal("show");
246
            });
247
248
            $("#noticeModal").on("hide.bs.modal", function(){
249
                $("#noticeModalLabel").text("");
250
                $("#noticeModal .modal-body").html("");
251
            });
252
253
            $("#notices_patronsearch").on("submit", filter);
254
            [% UNLESS patron %]
255
                [% IF ( PatronAutoComplete ) %]
256
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'notices', 'url-params': '[% url_biblio_params | url %]' });
257
                [% END %]
258
            [% END %]
259
        });
260
    </script>
261
262
[% END %]
263
264
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-1 / +6 lines)
Lines 32-38 Link Here
32
            <h1>Tools</h1>
32
            <h1>Tools</h1>
33
            <div class="row">
33
            <div class="row">
34
                <div class="col-sm-6">
34
                <div class="col-sm-6">
35
                    [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons  || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons  || CAN_user_tools_edit_patrons || CAN_user_tools_batch_extend_due_dates || CAN_user_tools_moderate_tags || CAN_user_tools_rotating_collections || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) ) %]
35
                    [% IF ( CAN_user_tools_manage_patron_lists || CAN_user_clubs || CAN_user_tools_moderate_comments || CAN_user_tools_import_patrons  || CAN_user_tools_edit_notices || CAN_user_tools_edit_notice_status_triggers || CAN_user_tools_label_creator || CAN_user_tools_delete_anonymize_patrons  || CAN_user_tools_edit_patrons || CAN_user_tools_batch_extend_due_dates || CAN_user_tools_moderate_tags || CAN_user_tools_rotating_collections || ( CAN_user_tools_batch_upload_patron_images && Koha.Preference('patronimages') ) || ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) ) %]
36
                        <h3>Patrons and circulation</h3>
36
                        <h3>Patrons and circulation</h3>
37
                    [% END %]
37
                    [% END %]
38
                    <dl>
38
                    <dl>
Lines 71-76 Link Here
71
                            <dd>Set notice/status triggers for overdue items</dd>
71
                            <dd>Set notice/status triggers for overdue items</dd>
72
                        [% END %]
72
                        [% END %]
73
73
74
                        [% IF ( CAN_user_tools_view_generated_notices && Koha.Preference('NoticesManagement') ) %]
75
                            <dt><a href="/cgi-bin/koha/tools/notices.pl">Notices management</a></dt>
76
                            <dd>View and print generated notices</dd>
77
                        [% END %]
78
74
                        [% IF ( CAN_user_tools_label_creator ) %]
79
                        [% IF ( CAN_user_tools_label_creator ) %]
75
                            <dt><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></dt>
80
                            <dt><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></dt>
76
                            <dd>Create printable patron cards</dd>
81
                            <dd>Create printable patron cards</dd>
(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-1 / +3 lines)
Lines 71-77 function patron_autocomplete(node, options) { Link Here
71
                ? "/cgi-bin/koha/circ/circulation.pl"
71
                ? "/cgi-bin/koha/circ/circulation.pl"
72
                : link_to == 'reserve'
72
                : link_to == 'reserve'
73
                    ? "/cgi-bin/koha/reserve/request.pl"
73
                    ? "/cgi-bin/koha/reserve/request.pl"
74
                    : "/cgi-bin/koha/members/moremember.pl";
74
                    : link_to == 'notices'
75
                        ? "/cgi-bin/koha/members/notices.pl"
76
                        : "/cgi-bin/koha/members/moremember.pl";
75
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
77
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
76
        } else {
78
        } else {
77
            item.link = null;
79
            item.link = null;
(-)a/tools/notices.pl (-1 / +79 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw ( -utf8 );
21
use C4::Auth qw( get_template_and_user );
22
use C4::Output qw( output_html_with_http_headers );
23
use Koha::Notice::Messages;
24
use Koha::DateUtils qw( dt_from_string );
25
26
my $query = CGI->new;
27
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
28
    {
29
        template_name   => "tools/notices.tt",
30
        query           => $query,
31
        type            => "intranet",
32
        flagsrequired   => { tools => 'view_generated_notices' },
33
    }
34
);
35
36
my $op = $query->param('op');
37
38
if ( $op and $op eq 'search' ) {
39
    my $letter_code = $query->param('letter_code') || undef;
40
    my $categorycode = $query->param('categorycode') || undef;
41
    my $branchcode = $query->param('branchcode') || undef;
42
    my $from = $query->param('from') || undef;
43
    my $to = $query->param('to') || undef;
44
    my $status = $query->param('status') || undef;
45
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
46
47
    my %where = ();
48
    $where{'me.letter_code'} = $letter_code if ( $letter_code );
49
    $where{'borrowernumber.categorycode'} = $categorycode if ( $categorycode );
50
    $where{'borrowernumber.branchcode'} = $branchcode if ( $branchcode );
51
    $where{'me.time_queued'} = { '<=', $dtf->format_datetime( dt_from_string($to) ) } if ( $to );
52
    $where{'me.time_queued'} = { '>=', $dtf->format_datetime( dt_from_string($from) ) } if ( $from );
53
    $where{'me.status'} = $status if ( $status );
54
55
    my $notices = Koha::Notice::Messages->search(
56
        { %where },
57
        { join => 'borrowernumber', order_by => { -desc => 'time_queued' } }
58
    );
59
60
    $template->param(
61
        notices => $notices,
62
        letter_code => $letter_code,
63
        categorycode => $categorycode,
64
        branchcode => $branchcode,
65
        from => $from,
66
        to => $to,
67
        status => $status,
68
    );
69
}
70
71
$template->param(
72
    letters => Koha::Notice::Templates->search({}, { order_by => { -asc => 'code' } }),
73
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
74
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
75
        : []
76
    ),
77
);
78
79
output_html_with_http_headers $query, $cookie, $template->output;

Return to bug 33260