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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt (-56 / +24 lines)
Lines 7-16 Link Here
7
[% PROCESS 'i18n.inc' %]
7
[% PROCESS 'i18n.inc' %]
8
[% SET footerjs = 1 %]
8
[% SET footerjs = 1 %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
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
<title
10
<title
15
    >[% FILTER collapse %]
11
    >[% FILTER collapse %]
16
        [% t("Notices management") | html %]
12
        [% t("Notices management") | html %]
Lines 51-59 Link Here
51
47
52
                <h1>Notices management</h1>
48
                <h1>Notices management</h1>
53
49
54
                <div class="dialog message">Printing a notice will mark it as sent.</div>
50
                <div class="page-section bg-warning">Printing a notice will mark it as sent.</div>
55
51
56
                [% IF notices && notices.count > 0 %]
52
                [% IF notices.count == 0 %]
53
                    <div class="page-section bg-info"> No sent notices were found with those search parameters. </div>
54
                [% ELSE %]
57
                    <div class="page-section">
55
                    <div class="page-section">
58
                        <span id="checkbox_actions"
56
                        <span id="checkbox_actions"
59
                            ><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
57
                            ><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
Lines 101-123 Link Here
101
                            <input type="submit" class="btn btn-primary" value="Print selected notices" id="print_multiple_button" />
99
                            <input type="submit" class="btn btn-primary" value="Print selected notices" id="print_multiple_button" />
102
                        </form>
100
                        </form>
103
                    </div>
101
                    </div>
104
                [% ELSE %]
105
                    Use the search form on the left to find sent notices, or go directly to a patron's notices.
106
                    [% WRAPPER tabs id= "notices_patronsearch" %]
107
                        [% WRAPPER tabs_nav %]
108
                            [% WRAPPER tab_item tabname= "notices_patronsearch_pane" bt_active= 1 %]<span>Patrons</span>[% END %]
109
                        [% END %]
110
                        [% WRAPPER tab_panels %]
111
                            [% WRAPPER tab_panel tabname="notices_patronsearch_pane" bt_active= 1 %]
112
                                [% PROCESS patron_search_filters_simple %]
113
                                [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
114
                            [% END %]
115
                        [% END %]
116
                    [% END %]
117
118
                    [% IF notices && notices.count == 0 %]
119
                        <div class="dialog message"> No sent notices were found with those search parameters. </div>
120
                    [% END %]
121
                [% END %]
102
                [% END %]
122
            </main>
103
            </main>
123
        </div>
104
        </div>
Lines 126-134 Link Here
126
        <div class="col-md-2 order-md-1 order-sm-1">
107
        <div class="col-md-2 order-md-1 order-sm-1">
127
            <aside>
108
            <aside>
128
                <fieldset class="sidebar brief">
109
                <fieldset class="sidebar brief">
129
                    <form id="notices-search" action="/cgi-bin/koha/tools/notices.pl" method="post">
110
                    <form id="notices-search" action="/cgi-bin/koha/tools/notices.pl" method="get">
130
                        [% INCLUDE 'csrf-token.inc' %]
131
                        <input type="hidden" name="op" value="cud-search" />
132
                        <h3>Search filters</h3>
111
                        <h3>Search filters</h3>
133
                        <ol>
112
                        <ol>
134
                            <li>
113
                            <li>
Lines 252-316 Link Here
252
        [% INCLUDE 'calendar.inc' %]
231
        [% INCLUDE 'calendar.inc' %]
253
        [% INCLUDE 'datatables.inc' %]
232
        [% INCLUDE 'datatables.inc' %]
254
        <script>
233
        <script>
255
            table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
234
            $(document).ready(function () {
256
            $(document).ready(function() {
235
                $("#notices").dataTable(
257
                $("#notices").dataTable($.extend(true, {}, dataTablesDefaults, {
236
                    $.extend(true, {}, dataTablesDefaults, {
258
                    "aoColumnDefs": [
237
                        aoColumnDefs: [{ bSortable: false, aTargets: ["nosort"] }],
259
                        { 'bSortable': false, 'aTargets': [ 'nosort' ] }
238
                        aaSorting: [[1, "desc"]],
260
                    ],
239
                        sPaginationType: "full",
261
                    "aaSorting": [[1, "desc" ]],
240
                    })
262
                    "sPaginationType": "full"
241
                );
263
                }));
264
242
265
                $("#notices").on("click", ".notice-title", function(e){
243
                $("#notices").on("click", ".notice-title", function (e) {
266
                    e.preventDefault();
244
                    e.preventDefault();
267
                    var title = $(this).text();
245
                    var title = $(this).text();
268
                    var noticeid = $(this).data("noticeid");
246
                    var noticeid = $(this).data("noticeid");
269
                    var body = $("#notice" + noticeid ).attr("srcdoc");
247
                    var body = $("#notice" + noticeid).attr("srcdoc");
270
                    $("#noticeModalLabel").text( title );
248
                    $("#noticeModalLabel").text(title);
271
                    $("#noticeModal .modal-body").html( body );
249
                    $("#noticeModal .modal-body").html(body);
272
                    $("#noticeModal").modal("show");
250
                    $("#noticeModal").modal("show");
273
                });
251
                });
274
252
275
                $("#noticeModal").on("hide.bs.modal", function(){
253
                $("#noticeModal").on("hide.bs.modal", function () {
276
                    $("#noticeModalLabel").text("");
254
                    $("#noticeModalLabel").text("");
277
                    $("#noticeModal .modal-body").html("");
255
                    $("#noticeModal .modal-body").html("");
278
                });
256
                });
279
257
280
                $("#notices_patronsearch").on("submit", filter);
258
                $("#print_multiple_button").click(function (e) {
281
                [% UNLESS notices %]
282
                    [% IF ( Koha.Preference('PatronAutoComplete') ) %]
283
                        patron_autocomplete($(".search_patron_filter"), { 'link-to': 'notices' });
284
                    [% END %]
285
                [% END %]
286
287
                $("#print_multiple_button").click(function(e){
288
                    var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked");
259
                    var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked");
289
                    if ( selected_notices.length == 0 ) {
260
                    if (selected_notices.length == 0) {
290
                        alert(_("Please select at least one sent notice."));
261
                        alert(_("Please select at least one sent notice."));
291
                        e.preventDefault();
262
                        e.preventDefault();
292
                        return false;
263
                        return false;
293
                    }
264
                    }
294
                });
265
                });
295
266
296
                $(".select_all").click(function(e){
267
                $(".select_all").click(function (e) {
297
                    e.preventDefault();
268
                    e.preventDefault();
298
                    $("input[name='message_ids']").each(function(){
269
                    $("input[name='message_ids']").each(function () {
299
                        $(this).prop("checked", true);
270
                        $(this).prop("checked", true);
300
                    });
271
                    });
301
                });
272
                });
302
273
303
                $(".clear_all").click(function(e){
274
                $(".clear_all").click(function (e) {
304
                    e.preventDefault();
275
                    e.preventDefault();
305
                    $("input[name='message_ids']").each(function(){
276
                    $("input[name='message_ids']").each(function () {
306
                        $(this).prop("checked", false);
277
                        $(this).prop("checked", false);
307
                    });
278
                    });
308
                });
279
                });
309
            });
280
            });
310
        </script>
281
        </script>
311
        [% SET search_results_block_id = 'notices_patronsearch_pane_panel' %]
312
        [%# adjusting variable for patron-search.inc %]
313
        [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/members/notices.pl?', redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/members/notices.pl?', redirect_if_attribute_equal => 'cardnumber' %]
314
    [% END %]
282
    [% END %]
315
283
316
    [% INCLUDE 'intranet-bottom.inc' %]</div
284
    [% INCLUDE 'intranet-bottom.inc' %]</div
(-)a/tools/notices.pl (-38 / +35 lines)
Lines 39-85 unless ( C4::Context->preference('NoticesManagement') ) { Link Here
39
39
40
my $op = $query->param('op');
40
my $op = $query->param('op');
41
41
42
if ( $op and $op eq 'cud-search' ) {
42
my $letter_code  = $query->param('letter_code')  || undef;
43
    my $letter_code  = $query->param('letter_code')  || undef;
43
my $categorycode = $query->param('categorycode') || undef;
44
    my $categorycode = $query->param('categorycode') || undef;
44
my $branchcode   = $query->param('branchcode')   || undef;
45
    my $branchcode   = $query->param('branchcode')   || undef;
45
my $from         = $query->param('from')         || undef;
46
    my $from         = $query->param('from')         || undef;
46
my $to           = $query->param('to')           || undef;
47
    my $to           = $query->param('to')           || undef;
47
my $status       = $query->param('status')       || undef;
48
    my $status       = $query->param('status')       || undef;
49
48
50
    my %where = ();
49
my %where = ();
51
    $where{'me.letter_code'}              = $letter_code  if ($letter_code);
50
$where{'me.letter_code'}              = $letter_code  if ($letter_code);
52
    $where{'borrowernumber.categorycode'} = $categorycode if ($categorycode);
51
$where{'borrowernumber.categorycode'} = $categorycode if ($categorycode);
53
    $where{'borrowernumber.branchcode'}   = $branchcode   if ($branchcode);
52
$where{'borrowernumber.branchcode'}   = $branchcode   if ($branchcode);
54
    if ($from) {
53
if ($from) {
55
        if ($to) {
54
    if ($to) {
56
            $where{'me.time_queued'} = [
55
        $where{'me.time_queued'} = [
57
                -and => { '<=', $to },
56
            -and => { '<=', $to },
58
                { '>=', $from }
57
            { '>=', $from }
59
            ];
58
        ];
60
        } else {
59
    } else {
61
            $where{'me.time_queued'} = { '>=', $from };
60
        $where{'me.time_queued'} = { '>=', $from };
62
        }
63
    } elsif ($to) {
64
        $where{'me.time_queued'} = { '<=', $to };
65
    }
61
    }
66
    $where{'me.status'} = $status if ($status);
62
} elsif ($to) {
63
    $where{'me.time_queued'} = { '<=', $to };
64
}
65
$where{'me.status'} = $status if ($status);
67
66
68
    my $notices = Koha::Notice::Messages->search_limited(
67
my $notices = Koha::Notice::Messages->search_limited(
69
        {%where},
68
    {%where},
70
        { order_by => { -desc => 'time_queued' } }
69
    { order_by => { -desc => 'time_queued' } }
71
    );
70
);
72
71
73
    $template->param(
72
$template->param(
74
        notices      => $notices,
73
    notices      => $notices,
75
        letter_code  => $letter_code,
74
    letter_code  => $letter_code,
76
        categorycode => $categorycode,
75
    categorycode => $categorycode,
77
        branchcode   => $branchcode,
76
    branchcode   => $branchcode,
78
        from         => $from,
77
    from         => $from,
79
        to           => $to,
78
    to           => $to,
80
        status       => $status,
79
    status       => $status,
81
    );
80
);
82
}
83
81
84
$template->param(
82
$template->param(
85
    letters => Koha::Notice::Templates->search(
83
    letters => Koha::Notice::Templates->search(
86
- 

Return to bug 33260