X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fsco%2Fsco-main.pl;h=dcb4c9278b40d4ac1a9ead1d4c53e20f989d4865;hb=0b61c8e5d05dcdb3acd4b6772b7fc51e66653a0a;hp=4a148585f779778573221ec4b13c608cf0b637b9;hpb=d8dc86bc4bde4b5744cd0bc954e1e5767250dde2;p=koha.git diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 4a148585f7..dcb4c9278b 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -67,14 +67,17 @@ if (C4::Context->preference('AutoSelfCheckAllowed')) $query->param(-name=>'koha_login_context',-values=>['sco']); } $query->param(-name=>'sco_user_login',-values=>[1]); -my ($template, $loggedinuser, $cookie) = get_template_and_user({ - template_name => "sco/sco-main.tt", - authnotrequired => 0, - flagsrequired => { circulate => "self_checkout" }, - query => $query, - type => "opac", - debug => 1, -}); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "sco/sco-main.tt", + authnotrequired => 0, + flagsrequired => { self_check => "self_checkout_module" }, + query => $query, + type => "opac", + debug => 1, + } +); # Get the self checkout timeout preference, or use 120 seconds as a default my $selfchecktimeout = 120000; @@ -90,15 +93,16 @@ if (defined C4::Context->preference('AllowSelfCheckReturns')) { } my $issuerid = $loggedinuser; -my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = ( +my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = ( $query->param("op") || '', $query->param("patronid") || '', $query->param("patronlogin")|| '', $query->param("patronpw") || '', $query->param("barcode") || '', $query->param("confirmed") || '', + $query->param("newissues") || '', ); - +my @newissueslist = split /,/, $newissues; my $issuenoconfirm = 1; #don't need to confirm on issue. my $issuer = Koha::Patrons->find( $issuerid )->unblessed; my $item = GetItem(undef,$barcode); @@ -114,23 +118,20 @@ if ( $patronid ) { $borrower = $patron->unblessed if $patron; } -my $currencySymbol = ""; -if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) { - $currencySymbol = $active_currency->symbol; -} - my $branch = $issuer->{branchcode}; my $confirm_required = 0; my $return_only = 0; #warn "issuer cardnumber: " . $issuer->{cardnumber}; #warn "patron cardnumber: " . $borrower->{cardnumber}; if ($op eq "logout") { + $template->param( loggedout => 1 ); $query->param( patronid => undef, patronlogin => undef, patronpw => undef ); } elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { my ($doreturn) = AddReturn( $barcode, $branch ); + $template->param( returned => $doreturn ); } -elsif ( $patron and $op eq "checkout" ) { +elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) { my $impossible = {}; my $needconfirm = {}; ( $impossible, $needconfirm ) = CanBookBeIssued( @@ -163,7 +164,7 @@ elsif ( $patron and $op eq "checkout" ) { hide_main => 1, ); if ($issue_error eq 'DEBT') { - $template->param(amount => $currencySymbol.$impossible->{DEBT}); + $template->param(DEBT => $impossible->{DEBT}); } #warn "issue_error: " . $issue_error ; if ( $issue_error eq "NO_MORE_RENEWALS" ) { @@ -173,10 +174,12 @@ elsif ( $patron and $op eq "checkout" ) { barcode => $barcode, ); } - } elsif ( $needconfirm->{RENEW_ISSUE} ) { + } elsif ( $needconfirm->{RENEW_ISSUE} || $op eq 'renew' ) { if ($confirmed) { #warn "renewing"; AddRenewal( $borrower->{borrowernumber}, $item->{itemnumber} ); + push @newissueslist, $barcode; + $template->param( renewed => 1 ); } else { #warn "renew confirmation"; $template->param( @@ -195,7 +198,7 @@ elsif ( $patron and $op eq "checkout" ) { hide_main => 1, ); if ($issue_error eq 'DEBT') { - $template->param(amount => $currencySymbol.$needconfirm->{DEBT}); + $template->param(DEBT => $needconfirm->{DEBT}); } } else { if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. @@ -216,11 +219,14 @@ elsif ( $patron and $op eq "checkout" ) { } )->count; } + AddIssue( $borrower, $barcode ); + push @newissueslist, $barcode; if ( $hold_existed ) { my $dtf = Koha::Database->new->schema->storage->datetime_parser; $template->param( + issued => 1, # If the hold existed before the check in, let's confirm that the charge line exists # Note that this should not be needed but since we do not have proper exception handling here we do it this way patron_has_hold_fee => Koha::Account::Lines->search( @@ -250,24 +256,26 @@ if ($borrower) { # warn "issuer's branchcode: " . $issuer->{branchcode}; # warn "user's branchcode: " . $borrower->{branchcode}; my $borrowername = sprintf "%s %s", ($borrower->{firstname} || ''), ($borrower->{surname} || ''); - my @issues; - my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} ); - foreach my $it (@$issueslist) { + my $pending_checkouts = $patron->pending_checkouts; + my @checkouts; + while ( my $c = $pending_checkouts->next ) { + my $checkout = $c->unblessed_all_relateds; my ($can_be_renewed, $renew_error) = CanBookBeRenewed( $borrower->{borrowernumber}, - $it->{itemnumber}, + $checkout->{itemnumber}, ); - $it->{can_be_renewed} = $can_be_renewed; - $it->{renew_error} = $renew_error; - $it->{date_due} = $it->{date_due_sql}; - push @issues, $it; + $checkout->{can_be_renewed} = $can_be_renewed; # In the future this will be $checkout->can_be_renewed + $checkout->{renew_error} = $renew_error; + $checkout->{overdue} = $c->is_overdue; + push @checkouts, $checkout; } $template->param( validuser => 1, borrowername => $borrowername, - issues_count => scalar(@issues), - ISSUES => \@issues, + issues_count => scalar(@checkouts), + ISSUES => \@checkouts, + newissues => join(',',@newissueslist), patronid => $patronid, patronlogin => $patronlogin, patronpw => $patronpw,