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 1116-1146
sub GetAllIssues {
Link Here
|
1116 |
my ( $borrowernumber, $order, $limit ) = @_; |
1118 |
my ( $borrowernumber, $order, $limit ) = @_; |
1117 |
|
1119 |
|
1118 |
return unless $borrowernumber; |
1120 |
return unless $borrowernumber; |
|
|
1121 |
|
1119 |
$order = 'date_due desc' unless $order; |
1122 |
$order = 'date_due desc' unless $order; |
|
|
1123 |
my ( $column, $sort ) = split( / /, $order ); |
1124 |
$column ||= 'date_due'; |
1125 |
$sort ||= 'desc'; |
1120 |
|
1126 |
|
1121 |
my $dbh = C4::Context->dbh; |
1127 |
my $borrower = Koha::Borrowers->find( $borrowernumber ); |
1122 |
my $query = |
1128 |
my $checkouts = $borrower->all_checkouts( { order => { column => $column, sort => $sort } , limit => $limit } ); |
1123 |
'SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp |
1129 |
|
1124 |
FROM issues |
1130 |
my @results; |
1125 |
LEFT JOIN items on items.itemnumber=issues.itemnumber |
1131 |
foreach my $checkout (@$checkouts) { |
1126 |
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber |
1132 |
my $item = $checkout->item( { deleted => 1 } ); |
1127 |
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber |
1133 |
next unless $item; |
1128 |
WHERE borrowernumber=? |
1134 |
|
1129 |
UNION ALL |
1135 |
my $biblio = $item->biblio( { deleted => 1 } ); |
1130 |
SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp |
1136 |
next unless $biblio; |
1131 |
FROM old_issues |
1137 |
|
1132 |
LEFT JOIN items on items.itemnumber=old_issues.itemnumber |
1138 |
my $biblioitem = $item->biblioitem( { deleted => 1 } ); |
1133 |
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber |
1139 |
next unless $biblioitem; |
1134 |
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber |
1140 |
|
1135 |
WHERE borrowernumber=? AND old_issues.itemnumber IS NOT NULL |
1141 |
my $checkout_hashref = $checkout->unblessed(); |
1136 |
order by ' . $order; |
1142 |
my $item_hashref = $item->unblessed(); |
1137 |
if ($limit) { |
1143 |
my $biblio_hashref = $biblio->unblessed(); |
1138 |
$query .= " limit $limit"; |
1144 |
my $biblioitem_hashref = $biblioitem->unblessed(); |
|
|
1145 |
|
1146 |
my $hashref = { %$checkout_hashref, %$item_hashref, %$biblio_hashref, %$biblioitem_hashref }; |
1147 |
$hashref->{issuestimestamp} = $checkout->timestamp(); |
1148 |
$hashref->{renewals} = $checkout->renewals(); |
1149 |
$hashref->{totalrenewals} = $item->renewals(); |
1150 |
$hashref->{itemstimestamp} = $item->timestamp(); |
1151 |
|
1152 |
push( @results, $hashref ); |
1139 |
} |
1153 |
} |
1140 |
|
1154 |
|
1141 |
my $sth = $dbh->prepare($query); |
1155 |
return \@results; |
1142 |
$sth->execute( $borrowernumber, $borrowernumber ); |
|
|
1143 |
return $sth->fetchall_arrayref( {} ); |
1144 |
} |
1156 |
} |
1145 |
|
1157 |
|
1146 |
|
1158 |
|