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

(-)a/circ/overdue.pl (-59 / +1 lines)
Lines 31-37 use DateTime; Link Here
31
use DateTime::Format::MySQL;
31
use DateTime::Format::MySQL;
32
32
33
my $input = new CGI;
33
my $input = new CGI;
34
my $order           = $input->param('order') || '';
35
my $showall         = $input->param('showall');
34
my $showall         = $input->param('showall');
36
my $bornamefilter   = $input->param('borname') || '';
35
my $bornamefilter   = $input->param('borname') || '';
37
my $borcatfilter    = $input->param('borcat') || '';
36
my $borcatfilter    = $input->param('borcat') || '';
Lines 105-124 for my $attrcode (grep { /^patron_attr_filter_/ } $input->multi_param) { Link Here
105
my $have_pattr_filter_data = keys(%cgi_attrcode_to_attrvalues) > 0;
104
my $have_pattr_filter_data = keys(%cgi_attrcode_to_attrvalues) > 0;
106
105
107
my @patron_attr_filter_loop;   # array of [ domid cgivalue ismany isclone ordinal code description repeatable authorised_value_category ]
106
my @patron_attr_filter_loop;   # array of [ domid cgivalue ismany isclone ordinal code description repeatable authorised_value_category ]
108
my @patron_attr_order_loop;    # array of { label => $patron_attr_label, value => $patron_attr_order }
109
110
my @sort_roots = qw(borrower title barcode date_due);
111
push @sort_roots, map {$_ . " desc"} @sort_roots;
112
my @order_loop = ({selected => $order ? 0 : 1});   # initial blank row
113
foreach (@sort_roots) {
114
    my $tmpl_name = $_;
115
    $tmpl_name =~ s/\s/_/g;
116
    push @order_loop, {
117
        selected => $order eq $_ ? 1 : 0,
118
        ordervalue => $_,
119
        'order_' . $tmpl_name => 1,
120
    };
121
}
122
107
123
my $sth = $dbh->prepare('SELECT code,description,repeatable,authorised_value_category
108
my $sth = $dbh->prepare('SELECT code,description,repeatable,authorised_value_category
124
    FROM borrower_attribute_types
109
    FROM borrower_attribute_types
Lines 139-157 while (my $row = $sth->fetchrow_hashref) { Link Here
139
        $row->{isclone} = $isclone;
124
        $row->{isclone} = $isclone;
140
        push @patron_attr_filter_loop, { %$row };  # careful: must store a *deep copy* of the modified row
125
        push @patron_attr_filter_loop, { %$row };  # careful: must store a *deep copy* of the modified row
141
    } continue { $isclone = 1, ++$serial }
126
    } continue { $isclone = 1, ++$serial }
142
    foreach my $sortorder ('asc', 'desc') {
143
        my $ordervalue = "patron_attr_${sortorder}_${code}";
144
        push @order_loop, {
145
            selected => $order eq $ordervalue ? 1 : 0,
146
            ordervalue => $ordervalue,
147
            label => $row->{description},
148
            $sortorder => 1,
149
        };
150
    }
151
} continue { ++$ordinal }
127
} continue { ++$ordinal }
152
for (@patron_attr_order_loop) { $_->{selected} = 1 if $order eq $_->{value} }
153
154
$template->param(ORDER_LOOP => \@order_loop);
155
128
156
my %borrowernumber_to_attributes;    # hash of { borrowernumber => { attrcode => [ [val,display], [val,display], ... ] } }
129
my %borrowernumber_to_attributes;    # hash of { borrowernumber => { attrcode => [ [val,display], [val,display], ... ] } }
157
                                     #   i.e. val differs from display when attr is an authorised value
130
                                     #   i.e. val differs from display when attr is an authorised value
Lines 213-219 $template->param( Link Here
213
    itemtypeloop => \@itemtypeloop,
186
    itemtypeloop => \@itemtypeloop,
214
    patron_attr_filter_loop => \@patron_attr_filter_loop,
187
    patron_attr_filter_loop => \@patron_attr_filter_loop,
215
    borname => $bornamefilter,
188
    borname => $bornamefilter,
216
    order => $order,
217
    showall => $showall,
189
    showall => $showall,
218
    dateduefrom => $dateduefrom,
190
    dateduefrom => $dateduefrom,
219
    datedueto   => $datedueto,
191
    datedueto   => $datedueto,
Lines 300-313 if ($noreport) { Link Here
300
    my $bnlist = $have_pattr_filter_data ? join(',',keys %borrowernumber_to_attributes) : '';
272
    my $bnlist = $have_pattr_filter_data ? join(',',keys %borrowernumber_to_attributes) : '';
301
    $strsth =~ s/WHERE 1=1/WHERE 1=1 AND borrowers.borrowernumber IN ($bnlist)/ if $bnlist;
273
    $strsth =~ s/WHERE 1=1/WHERE 1=1 AND borrowers.borrowernumber IN ($bnlist)/ if $bnlist;
302
    $strsth =~ s/WHERE 1=1/WHERE 0=1/ if $have_pattr_filter_data  && !$bnlist;  # no match if no borrowers matched patron attrs
274
    $strsth =~ s/WHERE 1=1/WHERE 0=1/ if $have_pattr_filter_data  && !$bnlist;  # no match if no borrowers matched patron attrs
303
    $strsth.=" ORDER BY " . (
275
    $strsth.=" ORDER BY date_due, surname, firstname";
304
        ($order eq "borrower")                              ? "surname, firstname, date_due"               : 
305
        ($order eq "borrower desc")                         ? "surname desc, firstname desc, date_due"     : 
306
        ($order eq "title"    or $order eq    "title desc") ? "$order, date_due, surname, firstname"       :
307
        ($order eq "barcode"  or $order eq  "barcode desc") ? "items.$order, date_due, surname, firstname" :
308
                                ($order eq "date_due desc") ? "date_due DESC, surname, firstname"          :
309
                                                            "date_due, surname, firstname"  # default sort order
310
    );
311
    $template->param(sql=>$strsth);
276
    $template->param(sql=>$strsth);
312
    my $sth=$dbh->prepare($strsth);
277
    my $sth=$dbh->prepare($strsth);
313
    $sth->execute(
278
    $sth->execute(
Lines 363-391 if ($noreport) { Link Here
363
        };
328
        };
364
    }
329
    }
365
330
366
    my ($attrorder) = $order =~ /patron_attr_(.*)$/; 
367
    my $patrorder = '';
368
    my $sortorder = 'asc';
369
    if (defined $attrorder) {
370
        ($sortorder, $patrorder) = split /_/, $attrorder, 2;
371
    }
372
    print STDERR ">>> order is $order, patrorder is $patrorder, sortorder is $sortorder\n" if $debug;
373
374
    if (my @attrtype = grep { $_->{'code'} eq $patrorder } @patron_attr_filter_loop) {        # sort by patron attrs perhaps?
375
        my $ordinal = $attrtype[0]{ordinal};
376
        print STDERR ">>> sort ordinal is $ordinal\n" if $debug;
377
378
        sub patronattr_sorter_asc {
379
            lc $a->{patron_attr_value_loop}[$ordinal]{value}
380
            cmp
381
            lc $b->{patron_attr_value_loop}[$ordinal]{value} }
382
383
        sub patronattr_sorter_des { -patronattr_sorter_asc() }
384
385
        my $sorter = $sortorder eq 'desc' ? \&patronattr_sorter_des : \&patronattr_sorter_asc;
386
        @overduedata = sort $sorter @overduedata;
387
    }
388
389
    if ($op eq 'csv') {
331
    if ($op eq 'csv') {
390
        binmode(STDOUT, ":encoding(UTF-8)");
332
        binmode(STDOUT, ":encoding(UTF-8)");
391
        my $csv = build_csv(\@overduedata);
333
        my $csv = build_csv(\@overduedata);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt (-27 / +8 lines)
Lines 3-8 Link Here
3
<title>Koha &rsaquo; Circulation &rsaquo; Items overdue as of [% todaysdate %]</title>
3
<title>Koha &rsaquo; Circulation &rsaquo; Items overdue as of [% todaysdate %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
[% INCLUDE 'datatables.inc' %]
7
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6
[%- USE Branches -%]
8
[%- USE Branches -%]
7
<script type="text/javascript">
9
<script type="text/javascript">
8
 //<![CDATA[
10
 //<![CDATA[
Lines 59-64 Link Here
59
            };
61
            };
60
        });
62
        });
61
    }
63
    }
64
65
    $(document).ready(function(){
66
        $("#overduest").dataTable($.extend(true, {}, dataTablesDefaults, {
67
            "sPaginationType": "four_button"
68
        }));
69
    });
62
//]]>
70
//]]>
63
</script>
71
</script>
64
<style type="text/css">
72
<style type="text/css">
Lines 233-264 Link Here
233
        </select>
241
        </select>
234
    </li>
242
    </li>
235
243
236
    <li><label for="order">Sort by:</label> <select name="order" id="order">
237
[% FOREACH ORDER_LOO IN ORDER_LOOP %]
238
    [% IF ( ORDER_LOO.selected ) %]
239
    <option value="[% ORDER_LOO.ordervalue %]" selected="selected">
240
    [% ELSE %]
241
    <option value="[% ORDER_LOO.ordervalue %]">
242
    [% END %]
243
    [% IF ( ORDER_LOO.order_date_due ) %]Due date
244
    [% ELSIF ( ORDER_LOO.order_borrower ) %]Patron
245
    [% ELSIF ( ORDER_LOO.order_barcode ) %]Barcode
246
    [% ELSIF ( ORDER_LOO.order_title ) %]Title
247
    [% ELSIF ( ORDER_LOO.order_date_due_desc ) %]Due date desc
248
    [% ELSIF ( ORDER_LOO.order_borrower_desc ) %]Patron desc
249
    [% ELSIF ( ORDER_LOO.order_barcode_desc ) %]Barcode desc
250
    [% ELSIF ( ORDER_LOO.order_title_desc ) %]Title desc
251
    [% ELSE %][% ORDER_LOO.label %]
252
        [% IF ( ORDER_LOO.desc ) %]desc[% END %]
253
    [% END %]
254
    </option>
255
[% END %]
256
	[% FOREACH patron_attr_order_loo IN patron_attr_order_loop %]
257
        [% IF ( patron_attr_order_loo.selected ) %]<option value="[% patron_attr_order_loo.value |html %]" selected="selected">[% patron_attr_order_loo.label %]</option>
258
        [% ELSE %]<option value="[% patron_attr_order_loo.value |html %]">[% patron_attr_order_loo.label %]</option>[% END %]
259
	[% END %]
260
</select></li>
261
262
<li class="radio"><label for="showall">Show any items currently checked out:</label>
244
<li class="radio"><label for="showall">Show any items currently checked out:</label>
263
	[% IF ( showall ) %]
245
	[% IF ( showall ) %]
264
            <input type="checkbox" id="showall" name="showall" value="show" checked="checked" />
246
            <input type="checkbox" id="showall" name="showall" value="show" checked="checked" />
265
- 

Return to bug 8548