Lines 42-47
use Text::Unaccent qw( unac_string );
Link Here
|
42 |
use Koha::AuthUtils qw(hash_password); |
42 |
use Koha::AuthUtils qw(hash_password); |
43 |
use Koha::Database; |
43 |
use Koha::Database; |
44 |
use Module::Load; |
44 |
use Module::Load; |
|
|
45 |
use Koha::Borrowers; |
46 |
|
45 |
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { |
47 |
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { |
46 |
load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync ); |
48 |
load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync ); |
47 |
} |
49 |
} |
Lines 1122-1152
sub GetAllIssues {
Link Here
|
1122 |
my ( $borrowernumber, $order, $limit ) = @_; |
1124 |
my ( $borrowernumber, $order, $limit ) = @_; |
1123 |
|
1125 |
|
1124 |
return unless $borrowernumber; |
1126 |
return unless $borrowernumber; |
|
|
1127 |
|
1125 |
$order = 'date_due desc' unless $order; |
1128 |
$order = 'date_due desc' unless $order; |
|
|
1129 |
my ( $column, $sort ) = split( / /, $order ); |
1130 |
$column ||= 'date_due'; |
1131 |
$sort ||= 'desc'; |
1126 |
|
1132 |
|
1127 |
my $dbh = C4::Context->dbh; |
1133 |
my $borrower = Koha::Borrowers->find( $borrowernumber ); |
1128 |
my $query = |
1134 |
my $checkouts = $borrower->all_checkouts( { order => { column => $column, sort => $sort } , limit => $limit } ); |
1129 |
'SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp |
1135 |
|
1130 |
FROM issues |
1136 |
my @results; |
1131 |
LEFT JOIN items on items.itemnumber=issues.itemnumber |
1137 |
foreach my $checkout (@$checkouts) { |
1132 |
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber |
1138 |
my $item = $checkout->item( { deleted => 1 } ); |
1133 |
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber |
1139 |
next unless $item; |
1134 |
WHERE borrowernumber=? |
1140 |
|
1135 |
UNION ALL |
1141 |
my $biblio = $item->biblio( { deleted => 1 } ); |
1136 |
SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp |
1142 |
next unless $biblio; |
1137 |
FROM old_issues |
1143 |
|
1138 |
LEFT JOIN items on items.itemnumber=old_issues.itemnumber |
1144 |
my $biblioitem = $item->biblioitem( { deleted => 1 } ); |
1139 |
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber |
1145 |
next unless $biblioitem; |
1140 |
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber |
1146 |
|
1141 |
WHERE borrowernumber=? AND old_issues.itemnumber IS NOT NULL |
1147 |
my $checkout_hashref = $checkout->unblessed(); |
1142 |
order by ' . $order; |
1148 |
my $item_hashref = $item->unblessed(); |
1143 |
if ($limit) { |
1149 |
my $biblio_hashref = $biblio->unblessed(); |
1144 |
$query .= " limit $limit"; |
1150 |
my $biblioitem_hashref = $biblioitem->unblessed(); |
|
|
1151 |
|
1152 |
my $hashref = { %$checkout_hashref, %$item_hashref, %$biblio_hashref, %$biblioitem_hashref }; |
1153 |
$hashref->{issuestimestamp} = $checkout->timestamp(); |
1154 |
$hashref->{renewals} = $checkout->renewals(); |
1155 |
$hashref->{totalrenewals} = $item->renewals(); |
1156 |
$hashref->{itemstimestamp} = $item->timestamp(); |
1157 |
$hashref->{record_is_deleted} = ref($biblio) eq 'Koha::Deleted::Biblio'; |
1158 |
|
1159 |
push( @results, $hashref ); |
1145 |
} |
1160 |
} |
1146 |
|
1161 |
|
1147 |
my $sth = $dbh->prepare($query); |
1162 |
return \@results; |
1148 |
$sth->execute( $borrowernumber, $borrowernumber ); |
|
|
1149 |
return $sth->fetchall_arrayref( {} ); |
1150 |
} |
1163 |
} |
1151 |
|
1164 |
|
1152 |
|
1165 |
|