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 |
|