X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fsco%2Fsco-main.pl;h=0a59d3b0c6b264608b55eaf1cbbc9d4f3564bcc0;hb=649956b216aa21fee70a75d2f9f9f0ac213415d0;hp=7e4f8103ddfcb1e81a47af638f87f6fd8f4b0bbf;hpb=5baff558a53fabb7b719bf627064cf2c1680f246;p=srvgit diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 7e4f8103dd..0a59d3b0c6 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -6,18 +6,18 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . # We're going to authenticate a self-check user. we'll add a flag to borrowers 'selfcheck' # @@ -34,19 +34,20 @@ use strict; use warnings; -use CGI; +use CGI qw ( -utf8 ); use Digest::MD5 qw(md5_base64); use C4::Auth qw(get_template_and_user checkpw); use C4::Koha; -use C4::Dates qw/format_date/; use C4::Circulation; use C4::Reserves; use C4::Output; use C4::Members; -use C4::Dates; use C4::Biblio; use C4::Items; +use Koha::Acquisition::Currencies; +use Koha::Patron::Images; +use Koha::Patron::Messages; my $query = new CGI; @@ -58,20 +59,22 @@ unless (C4::Context->preference('WebBasedSelfCheck')) { if (C4::Context->preference('AutoSelfCheckAllowed')) { - my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); - my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass'); - $query->param(-name=>'userid',-values=>[$AutoSelfCheckID]); - $query->param(-name=>'password',-values=>[$AutoSelfCheckPass]); + my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); + my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass'); + $query->param(-name=>'userid',-values=>[$AutoSelfCheckID]); + $query->param(-name=>'password',-values=>[$AutoSelfCheckPass]); $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.tmpl", + template_name => "sco/sco-main.tt", authnotrequired => 0, - flagsrequired => { circulate => "circulate_remaining_permissions" }, + flagsrequired => { circulate => "self_checkout" }, query => $query, type => "opac", debug => 1, }); + if (C4::Context->preference('SelfCheckoutByLogin')) { $template->param(authbylogin => 1); @@ -93,14 +96,13 @@ $template->param(AllowSelfCheckReturns => $allowselfcheckreturns); my $issuerid = $loggedinuser; -my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $timedout) = ( +my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = ( $query->param("op") || '', $query->param("patronid") || '', $query->param("patronlogin")|| '', $query->param("patronpw") || '', $query->param("barcode") || '', $query->param("confirmed") || '', - $query->param("timedout") || '', #not actually using this... ); my $issuenoconfirm = 1; #don't need to confirm on issue. @@ -114,6 +116,10 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { } my $borrower = GetMemberDetails(undef,$patronid); +my $currencySymbol = ""; +if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) { + $currencySymbol = $active_currency->symbol; +} my $branch = $issuer->{branchcode}; my $confirm_required = 0; @@ -132,7 +138,7 @@ elsif ( $op eq "checkout" ) { my $impossible = {}; my $needconfirm = {}; if ( !$confirmed ) { - ( $impossible, $needconfirm ) = CanBookBeIssuedCheckout( + ( $impossible, $needconfirm ) = CanBookBeIssued( $borrower, $barcode, undef, @@ -157,7 +163,7 @@ elsif ( $op eq "checkout" ) { hide_main => 1, ); if ($issue_error eq 'DEBT') { - $template->param(amount => $impossible->{DEBT}); + $template->param(amount => $currencySymbol.$impossible->{DEBT}); } #warn "issue_error: " . $issue_error ; if ( $issue_error eq "NO_MORE_RENEWALS" ) { @@ -189,6 +195,9 @@ elsif ( $op eq "checkout" ) { "circ_error_$issue_error" => 1, hide_main => 1, ); + if ($issue_error eq 'DEBT') { + $template->param(amount => $currencySymbol.$needconfirm->{DEBT}); + } } else { if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues. # warn "issuing book?"; @@ -218,7 +227,6 @@ if ($borrower->{cardnumber}) { my @issues; my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} ); foreach my $it (@$issueslist) { - $it->{date_due_display} = format_date($it->{date_due}); my ($renewokay, $renewerror) = CanBookBeIssued( $borrower, $it->{'barcode'}, @@ -227,6 +235,7 @@ if ($borrower->{cardnumber}) { C4::Context->preference("AllowItemsOnHoldCheckout") ); $it->{'norenew'} = 1 if $renewokay->{'NO_MORE_RENEWALS'}; + $it->{date_due} = $it->{date_due_sql}; push @issues, $it; } @@ -239,22 +248,33 @@ if ($borrower->{cardnumber}) { patronlogin => $patronlogin, patronpw => $patronpw, noitemlinks => 1 , + borrowernumber => $borrower->{'borrowernumber'}, + ); + + my $patron_messages = Koha::Patron::Messages->search( + { + borrowernumber => $borrower->{'borrowernumber'}, + message_type => 'B', + } + ); + $template->param( + patron_messages => $patron_messages, + opacnote => $borrower->{opacnote}, ); + my $inputfocus = ($return_only == 1) ? 'returnbook' : ($confirm_required == 1) ? 'confirm' : 'barcode' ; $template->param( inputfocus => $inputfocus, - nofines => 1, - "dateformat_" . C4::Context->preference('dateformat') => 1, + nofines => 1, + ); if (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { - my ($image, $dberror) = GetPatronImage($borrower->{cardnumber}); - if ($image) { - $template->param( - display_patron_image => 1, - cardnumber => $borrower->{cardnumber}, - ); - } + my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber}); + $template->param( + display_patron_image => 1, + cardnumber => $borrower->{cardnumber}, + ) if $patron_image; } } else { $template->param( @@ -263,4 +283,9 @@ if ($borrower->{cardnumber}) { ); } -output_html_with_http_headers $query, $cookie, $template->output; +$template->param( + SCOUserJS => C4::Context->preference('SCOUserJS'), + SCOUserCSS => C4::Context->preference('SCOUserCSS'), +); + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };