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

(-)a/C4/Members.pm (-21 / +33 lines)
Lines 36-41 use C4::NewsChannels; #get slip news Link Here
36
use DateTime;
36
use DateTime;
37
use Koha::Database;
37
use Koha::Database;
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::Patrons;
39
use Koha::Patron::Debarments qw(IsDebarred);
40
use Koha::Patron::Debarments qw(IsDebarred);
40
use Text::Unaccent qw( unac_string );
41
use Text::Unaccent qw( unac_string );
41
use Koha::AuthUtils qw(hash_password);
42
use Koha::AuthUtils qw(hash_password);
Lines 998-1028 sub GetAllIssues { Link Here
998
    my ( $borrowernumber, $order, $limit ) = @_;
999
    my ( $borrowernumber, $order, $limit ) = @_;
999
1000
1000
    return unless $borrowernumber;
1001
    return unless $borrowernumber;
1002
1001
    $order = 'date_due desc' unless $order;
1003
    $order = 'date_due desc' unless $order;
1004
    my ( $column, $sort ) = split( / /, $order );
1005
    $column ||= 'date_due';
1006
    $sort ||= 'desc';
1002
1007
1003
    my $dbh = C4::Context->dbh;
1008
    my $borrower = Koha::Patrons->find( $borrowernumber );
1004
    my $query =
1009
    my $checkouts = $borrower->all_checkouts( { order => { column => $column, sort => $sort } , limit => $limit } );
1005
'SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
1010
1006
  FROM issues 
1011
    my @results;
1007
  LEFT JOIN items on items.itemnumber=issues.itemnumber
1012
    foreach my $checkout (@$checkouts) {
1008
  LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
1013
        my $item = $checkout->item( { deleted => 1 } );
1009
  LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
1014
        next unless $item;
1010
  WHERE borrowernumber=? 
1015
1011
  UNION ALL
1016
        my $biblio = $item->biblio( { deleted => 1 } );
1012
  SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp 
1017
        next unless $biblio;
1013
  FROM old_issues 
1018
1014
  LEFT JOIN items on items.itemnumber=old_issues.itemnumber
1019
        my $biblioitem = $item->biblioitem( { deleted => 1 } );
1015
  LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
1020
        next unless $biblioitem;
1016
  LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
1021
1017
  WHERE borrowernumber=? AND old_issues.itemnumber IS NOT NULL
1022
        my $checkout_hashref = $checkout->unblessed();
1018
  order by ' . $order;
1023
        my $item_hashref = $item->unblessed();
1019
    if ($limit) {
1024
        my $biblio_hashref = $biblio->unblessed();
1020
        $query .= " limit $limit";
1025
        my $biblioitem_hashref = $biblioitem->unblessed();
1026
1027
        my $hashref = { %$checkout_hashref, %$item_hashref, %$biblio_hashref, %$biblioitem_hashref };
1028
        $hashref->{issuestimestamp} = $checkout->timestamp();
1029
        $hashref->{renewals} = $checkout->renewals();
1030
        $hashref->{totalrenewals} = $item->renewals();
1031
        $hashref->{itemstimestamp} = $item->timestamp();
1032
        $hashref->{record_is_deleted} = ref($biblio) eq 'Koha::Deleted::Biblio';
1033
1034
        push( @results, $hashref );
1021
    }
1035
    }
1022
1036
1023
    my $sth = $dbh->prepare($query);
1037
    return \@results;
1024
    $sth->execute( $borrowernumber, $borrowernumber );
1025
    return $sth->fetchall_arrayref( {} );
1026
}
1038
}
1027
1039
1028
1040
(-)a/Koha/BiblioItem.pm (+8 lines)
Lines 1-5 Link Here
1
package Koha::BiblioItem;
1
package Koha::BiblioItem;
2
2
3
# Copyright ByWater Solutions 2015
4
#
3
# This file is part of Koha.
5
# This file is part of Koha.
4
#
6
#
5
# Koha is free software; you can redistribute it and/or modify it under the
7
# Koha is free software; you can redistribute it and/or modify it under the
Lines 41-44 sub _type { Link Here
41
    return 'Biblioitem';
43
    return 'Biblioitem';
42
}
44
}
43
45
46
=head1 AUTHOR
47
48
Kyle M Hall <kyle@bywatersolutions.com>
49
50
=cut
51
44
1;
52
1;
(-)a/Koha/Config/SysPref.pm (-1 / +4 lines)
Lines 23-28 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Koha::Checkouts;
27
use Koha::Old::Checkouts;
28
26
use base qw(Koha::Object);
29
use base qw(Koha::Object);
27
30
28
=head1 NAME
31
=head1 NAME
Lines 35-41 Koha::Config::SysPref - Koha System Preference Object class Link Here
35
38
36
=cut
39
=cut
37
40
38
=head3 type
41
=head3 _type
39
42
40
=cut
43
=cut
41
44
(-)a/Koha/Patron.pm (+52 lines)
Lines 94-99 sub siblings { Link Here
94
    );
94
    );
95
}
95
}
96
96
97
=head3 all_checkouts
98
99
=cut
100
101
sub all_checkouts {
102
    my ( $self, $params ) = @_;
103
104
    my $limit = $params->{limit};
105
106
    my $order_by_column = $params->{order} ? $params->{order}->{column} : 'date_due';
107
    my $order_by_sort   = $params->{order} ? $params->{order}->{sort}   : 'desc';
108
109
    my @results;
110
    my $results_found = 0;
111
112
    my $issues = Koha::Checkouts->search(
113
        {
114
            borrowernumber => $self->borrowernumber(),
115
        },
116
        {
117
            order_by => { "-$order_by_sort" => $order_by_column }
118
        }
119
    );
120
121
    while ( my $i = $issues->next() ) {
122
        push( @results, $i );
123
        $results_found++;
124
        last if ( $limit && $results_found >= $limit );
125
    }
126
127
    if ( !$limit || $results_found < $limit ) {
128
129
        $issues = Koha::Old::Checkouts->search(
130
            {
131
                borrowernumber => $self->borrowernumber(),
132
            },
133
            {
134
                order_by => { "-$order_by_sort" => $order_by_column }
135
            }
136
        );
137
138
        while ( my $i = $issues->next() ) {
139
            push( @results, $i );
140
            $results_found++;
141
            last if ( $limit && $results_found >= $limit );
142
        }
143
144
    }
145
146
    return wantarray ? @results : \@results;
147
}
148
97
=head3 type
149
=head3 type
98
150
99
=cut
151
=cut
(-)a/installer/data/mysql/atomicupdate/bug_8483.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE  `old_issues` DROP FOREIGN KEY  `old_issues_ibfk_2` ;
(-)a/installer/data/mysql/kohastructure.sql (-3 / +1 lines)
Lines 1176-1182 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1176
  KEY `branchcode_idx` (`branchcode`),
1176
  KEY `branchcode_idx` (`branchcode`),
1177
  KEY `bordate` (`borrowernumber`,`timestamp`),
1177
  KEY `bordate` (`borrowernumber`,`timestamp`),
1178
  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1178
  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1179
  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
1179
  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1180
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1180
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1181
1181
1182
--
1182
--
Lines 1675-1682 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1675
  KEY `branchcode_idx` (`branchcode`),
1675
  KEY `branchcode_idx` (`branchcode`),
1676
  KEY `old_bordate` (`borrowernumber`,`timestamp`),
1676
  KEY `old_bordate` (`borrowernumber`,`timestamp`),
1677
  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1677
  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1678
    ON DELETE SET NULL ON UPDATE SET NULL,
1679
  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1680
    ON DELETE SET NULL ON UPDATE SET NULL
1678
    ON DELETE SET NULL ON UPDATE SET NULL
1681
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1679
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1682
1680
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-2 / +7 lines)
Lines 97-103 Link Here
97
          <td>
97
          <td>
98
            <span title="[% issue.issuestimestamp %]">[% issue.issuestimestamp | $KohaDates with_hours => 1 %]</span>
98
            <span title="[% issue.issuestimestamp %]">[% issue.issuestimestamp | $KohaDates with_hours => 1 %]</span>
99
          </td>
99
          </td>
100
          <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% issue.biblionumber %]">[% issue.title |html %]</a></td>
100
          <td>
101
            [% IF issue.record_is_deleted %]
102
                [% issue.title |html %]
103
            [% ELSE %]
104
                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% issue.biblionumber %]">[% issue.title |html %]</a>
105
            [% END %]
106
          </td>
101
107
102
          <td>[% issue.author %]</td>
108
          <td>[% issue.author %]</td>
103
109
104
- 

Return to bug 8483