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 (-2 / +10 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 25-31 use base qw(Koha::Object); Link Here
25
27
26
=head1 NAME
28
=head1 NAME
27
29
28
Koha::Biblioitem - Koha Biblioitem Object class
30
Koha::BiblioItem - Koha BiblioItem Object class
29
31
30
=head1 API
32
=head1 API
31
33
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 (+55 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-40 Koha::Config::SysPref - Koha System Preference Object class Link Here
35
38
36
=cut
39
=cut
37
40
41
=head3 all_checkouts
42
43
=cut
44
45
sub all_checkouts {
46
    my ( $self, $params ) = @_;
47
48
    my $limit = $params->{limit};
49
50
    my $order_by_column = $params->{order} ? $params->{order}->{column} : 'date_due';
51
    my $order_by_sort   = $params->{order} ? $params->{order}->{sort}   : 'desc';
52
53
    my @results;
54
    my $results_found = 0;
55
56
    my $issues = Koha::Checkouts->search(
57
        {
58
            borrowernumber => $self->borrowernumber(),
59
        },
60
        {
61
            order_by => { "-$order_by_sort" => $order_by_column }
62
        }
63
    );
64
65
    while ( my $i = $issues->next() ) {
66
        push( @results, $i );
67
        $results_found++;
68
        last if ( $limit && $results_found >= $limit );
69
    }
70
71
    if ( !$limit || $results_found < $limit ) {
72
73
        $issues = Koha::Old::Checkouts->search(
74
            {
75
                borrowernumber => $self->borrowernumber(),
76
            },
77
            {
78
                order_by => { "-$order_by_sort" => $order_by_column }
79
            }
80
        );
81
82
        while ( my $i = $issues->next() ) {
83
            push( @results, $i );
84
            $results_found++;
85
            last if ( $limit && $results_found >= $limit );
86
        }
87
88
    }
89
90
    return wantarray ? @results : \@results;
91
}
92
38
=head3 type
93
=head3 type
39
94
40
=cut
95
=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