# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-#use warnings; FIXME - Bug 2505
+use Modern::Perl;
use CGI qw ( -utf8 );
import C4::External::BakerTaylor qw(&image_url &link_url);
}
}
-my $logout='';
-# CAS Single Sign Out
-if (C4::Context->preference('casAuthentication')){
- # Check we havent been hit by a logout call
- my $xml = $query->param('logoutRequest');
- if ($xml) {
- my $dom = XML::LibXML->load_xml(string => $xml);
- my $ticket;
- foreach my $node ($dom->findnodes('/samlp:LogoutRequest')){
- $ticket = $node->findvalue('./samlp:SessionIndex');
- }
- $query->param(-name =>'logout.x', -value => 1);
- $query->param(-name =>'cas_ticket', -value => $ticket);
- $logout=1;
- }
-}
+
+# CAS single logout handling
+# Will print header and exit
+C4::Context->preference('casAuthentication') and C4::Auth_with_cas::logout_if_required($query);
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
}
);
-if ($logout){
- print $query->header;
- exit;
-}
-
-
-my %renewed = map { $_ => 1 } split( ':', $query->param('renewed') );
+my %renewed = map { $_ => 1 } split( ':', $query->param('renewed') || '' );
my $show_priority;
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') );
-if (!$borrowernumber) {
- $template->param( adminWarning => 1 );
-}
-
# get borrower information ....
my $patron = Koha::Patrons->find( $borrowernumber );
my $borr = $patron->unblessed;
+# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
+my $borcat = $borr ? $borr->{categorycode} : q{};
my ( $today_year, $today_month, $today_day) = Today();
my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'};
}
my $amountoutstanding = $patron->account->balance;
-if ( $amountoutstanding > 5 ) {
- $borr->{'amountoverfive'} = 1;
-}
-if ( 5 >= $amountoutstanding && $amountoutstanding > 0 ) {
- $borr->{'amountoverzero'} = 1;
-}
my $no_renewal_amt = C4::Context->preference( 'OPACFineNoRenewals' );
$no_renewal_amt = undef unless looks_like_number( $no_renewal_amt );
);
}
-if ( $amountoutstanding < 0 ) {
- $borr->{'amountlessthanzero'} = 1;
- $amountoutstanding = -1 * ( $amountoutstanding );
-}
-
# Warningdate is the date that the warning starts appearing
if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') ) {
my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) - Date_to_Days( $today_year, $today_month, $today_day );
# pass on any renew errors to the template for displaying
my $renew_error = $query->param('renew_error');
-$template->param( BORROWER_INFO => $borr,
+$template->param(
amountoutstanding => $amountoutstanding,
borrowernumber => $borrowernumber,
patron_flagged => $borr->{flagged},
my @overdues;
my @issuedat;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
-my $issues = GetPendingIssues($borrowernumber);
-if ($issues){
- foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
+my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
+if ( $pending_checkouts->count ) { # Useless test
+ while ( my $c = $pending_checkouts->next ) {
+ my $issue = $c->unblessed_all_relateds;
# check for reserves
my $restype = GetReserveStatus( $issue->{'itemnumber'} );
if ( $restype ) {
{
borrowernumber => $patron->borrowernumber,
amountoutstanding => { '>' => 0 },
- accounttype => [ 'F', 'FU', 'L' ],
+ accounttype => [ 'OVERDUE', 'L' ],
itemnumber => $issue->{itemnumber}
},
- { select => [ { sum => 'amountoutstanding' } ], as => ['charges'] }
);
- $issue->{charges} = $charges->count ? $charges->next->get_column('charges') : 0;
+ $issue->{charges} = $charges->total_outstanding;
my $rental_fines = Koha::Account::Lines->search(
{
amountoutstanding => { '>' => 0 },
accounttype => 'Rent',
itemnumber => $issue->{itemnumber}
- },
- {
- select => [ { sum => 'amountoutstanding' } ],
- as => ['rental_fines']
}
);
- $issue->{rentalfines} = $charges->count ? $charges->next->get_column('rental_fines') : 0;
+ $issue->{rentalfines} = $rental_fines->total_outstanding;
- my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} });
+ my $marcrecord = GetMarcBiblio({
+ biblionumber => $issue->{'biblionumber'},
+ embed_items => 1,
+ opac => 1,
+ borcat => $borcat });
$issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
# check if item is renewable
my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber );
+ $issue->{itemtype_object} = Koha::ItemTypes->find( Koha::Items->find( $issue->{itemnumber} )->effective_itemtype );
if($status && C4::Context->preference("OpacRenewalAllowed")){
$issue->{'status'} = $status;
}
$issue->{'auto_too_soon'} = 1 if $renewerror eq 'auto_too_soon';
$issue->{'auto_too_late'} = 1 if $renewerror eq 'auto_too_late';
$issue->{'auto_too_much_oweing'} = 1 if $renewerror eq 'auto_too_much_oweing';
+ $issue->{'item_denied_renewal'} = 1 if $renewerror eq 'item_denied_renewal';
if ( $renewerror eq 'too_soon' ) {
$issue->{'too_soon'} = 1;
}
}
- if ( $issue->{'overdue'} ) {
+ if ( $c->is_overdue ) {
push @overdues, $issue;
$overdues_count++;
$issue->{'overdue'} = 1;
showpriority => $show_priority,
);
-# current alert subscriptions
-my $alerts = getalert($borrowernumber);
-foreach ( @$alerts ) {
- $_->{ $_->{type} } = 1;
- $_->{relatedto} = findrelatedto( $_->{type}, $_->{externalid} );
-}
-
if (C4::Context->preference('BakerTaylorEnabled')) {
$template->param(
BakerTaylorEnabled => 1,
OverDriveCirculation => C4::Context->preference('OverDriveCirculation') || 0,
overdrive_error => scalar $query->param('overdrive_error') || undef,
overdrive_tab => scalar $query->param('overdrive_tab') || 0,
+ RecordedBooksCirculation => C4::Context->preference('RecordedBooksClientSecret') && C4::Context->preference('RecordedBooksLibraryID'),
);
my $patron_messages = Koha::Patron::Messages->search(
}
$template->param(
- borrower => scalar Koha::Patrons->find($borrowernumber),
patron_messages => $patron_messages,
opacnote => $borr->{opacnote},
patronupdate => $patronupdate,
failed_holds => scalar $query->param('failed_holds'),
);
+# if not an empty string this indicates to return
+# back to the opac-results page
+my $search_query = $query->param('has-search-query');
+
+if ($search_query) {
+
+ print $query->redirect(
+ -uri => "/cgi-bin/koha/opac-search.pl?$search_query",
+ -cookie => $cookie,
+ );
+}
+
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };