3 # This code has been modified by Trendsetters (originally from opac-user.pl)
4 # This code has been modified by rch
5 # We're going to authenticate a self-check user. we'll add a flag to borrowers 'selfcheck'
7 # We're in a controlled environment; we trust the user.
8 # So the selfcheck station will accept a patronid and issue items to that borrower.
9 # FIXME: NOT really a controlled environment... We're on the internet!
11 # The checkout permission comes form the CGI cookie/session of a staff user.
12 # The patron is not really logging in here in the same way as they do on the
13 # rest of the OPAC. So don't confuse loggedinuser with the patron user.
15 # FIXME: inputfocus not really used in TMPL
33 my ($template, $loggedinuser, $cookie) = get_template_and_user({
34 template_name => "sco/sco-main.tmpl",
36 flagsrequired => { circulate => "circulate_remaining_permissions" },
42 my $issuerid = $loggedinuser;
43 my ($op, $patronid, $barcode, $confirmed, $timedout) = (
44 $query->param("op") || '',
45 $query->param("patronid") || '',
46 $query->param("barcode") || '',
47 $query->param("confirmed") || '',
48 $query->param("timedout") || '', #not actually using this...
51 my %confirmation_strings = ( RENEW_ISSUE => "This item is already checked out to you. Return it?", );
52 my $issuenoconfirm = 1; #don't need to confirm on issue.
53 #warn "issuerid: " . $issuerid;
54 my $issuer = GetMemberDetails($issuerid);
55 my $item = GetItem(undef,$barcode);
56 my $borrower = GetMemberDetails(undef,$patronid);
58 my $branch = $issuer->{branchcode};
59 my $confirm_required = 0;
61 #warn "issuer cardnumber: " . $issuer->{cardnumber};
62 #warn "patron cardnumber: " . $borrower->{cardnumber};
63 if ($op eq "logout") {
64 $query->param( patronid => undef );
66 elsif ( $op eq "returnbook" ) {
67 my ($doreturn) = AddReturn( $barcode, $branch );
68 #warn "returnbook: " . $doreturn;
69 $borrower = GetMemberDetails( undef, $patronid ); # update borrower
71 elsif ( $op eq "checkout" ) {
75 ( $impossible, $needconfirm ) = CanBookBeIssued( $borrower, $barcode );
77 $confirm_required = scalar keys %$needconfirm;
79 #warn "confirm_required: " . $confirm_required ;
80 if (scalar keys %$impossible) {
82 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
83 #warn join " ", keys %$impossible;
84 my $issue_error = (keys %$impossible)[0];
86 # FIXME we assume only one error.
88 impossible => $issue_error,
89 title => $item->{title},
92 #warn "issue_error: " . $issue_error ;
93 if ( $issue_error eq "NO_MORE_RENEWALS" ) {
100 } elsif ( $needconfirm->{RENEW_ISSUE} ) {
103 AddRenewal( $borrower, $item->{itemnumber} );
105 #warn "renew confirmation";
110 confirm_renew_issue => 1,
114 } elsif ( $confirm_required && !$confirmed ) {
115 #warn "failed confirmation";
117 impossible => (keys %$needconfirm)[0],
121 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
122 # warn "issuing book?";
123 AddIssue( $borrower, $barcode );
124 # ($borrower, $flags) = getpatroninformation(undef,undef, $patronid);
126 # patronid => $patronid,
130 $confirm_required = 1;
131 #warn "issue confirmation";
133 confirm => "Issuing title: " . $item->{title},
136 inputfocus => 'confirm',
142 if ($borrower->{cardnumber}) {
143 # warn "issuer's branchcode: " . $issuer->{branchcode};
144 # warn "user's branchcode: " . $borrower->{branchcode};
145 my $borrowername = sprintf "%s %s", ($borrower->{firstname} || ''), ($borrower->{surname} || '');
147 my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} );
148 foreach my $it (@$issueslist) {
149 my ($renewokay, $renewerror) = CanBookBeIssued($borrower, $it->{'barcode'},'','');
150 $it->{'norenew'} = 1 if $renewokay->{'NO_MORE_RENEWALS'};
156 borrowername => $borrowername,
157 issues_count => scalar(@issues),
159 patronid => $patronid,
162 my $inputfocus = ($return_only == 1) ? 'returnbook' :
163 ($confirm_required == 1) ? 'confirm' : 'barcode' ;
165 inputfocus => $inputfocus,
170 patronid => $patronid,
175 output_html_with_http_headers $query, $cookie, $template->output;