2 # This code has been modified by Trendsetters (originally from opac-user.pl)
3 # This code has been modified by rch
4 # We're going to authenticate a self-check user. we'll add a flag to borrowers 'selfcheck'
5 # We're in a controlled environment; we trust the user. so the selfcheck station will accept a patronid and
6 # issue items to that borrower.
21 #use HTML::Template::Pro;
27 my ($template, $loggedinuser, $cookie)
28 = get_template_and_user({template_name => "sco/sco-main.tmpl",
32 flagsrequired => { circulate => "circulate_remaining_permissions" },
35 my $dbh = C4::Context->dbh;
37 my $issuerid = $loggedinuser;
38 my ($op, $patronid, $barcode, $confirmed, $timedout) = (
39 $query->param("op") || '',
40 $query->param("patronid") || '',
41 $query->param("barcode") || '',
42 $query->param("confirmed") || '',
43 $query->param("timedout") || '', #not actually using this...
46 my %confirmation_strings = ( RENEW_ISSUE => "This item is already checked out to you. Return it?", );
47 my $issuenoconfirm = 1; #don't need to confirm on issue.
49 #warn "issuerid: " . $issuerid;
50 my ($issuer) = GetMemberDetails($issuerid);
51 my $item = GetItem(undef,$barcode);
53 ($borrower) = GetMemberDetails(undef,$patronid);
55 my $branch = $issuer->{branchcode};
56 my $confirm_required = 0;
58 #warn "issuer cardnum: " . $issuer->{cardnumber};
59 #warn "cardnumber= ".$borrower->{cardnumber};
60 if ($op eq "logout") {
61 $query->param( patronid => undef );
65 if ( $op eq "returnbook" ) {
66 my ($doreturn) = AddReturn( $barcode, $branch );
68 #warn "returnbook: " . $doreturn;
69 ($borrower) = GetMemberDetails( undef, $patronid );
72 if ( $op eq "checkout" ) {
76 ( $impossible, $needconfirm ) = CanBookBeIssued( $borrower, $barcode );
78 $confirm_required = scalar( keys(%$needconfirm) );
80 #warn "confirm_required: " . $confirm_required ;
81 if ( scalar( keys(%$impossible) ) ) {
83 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
84 my ($issue_error) = keys %$impossible;
86 # FIXME we assume only one error.
88 impossible => $issue_error,
89 title => $item->{title},
93 #warn "issue_error: " . $issue_error ;
94 if ( $issue_error eq "NO_MORE_RENEWALS" ) {
101 } elsif ( $needconfirm->{RENEW_ISSUE} ) {
105 AddRenewal( $borrower, $item->{itemnumber} );
108 #warn "renew confirmation";
113 confirm_renew_issue => 1,
117 } elsif ( $confirm_required && !$confirmed ) {
119 #warn "failed confirmation";
120 my ($confirmation) = keys %$needconfirm;
122 impossible => $confirmation,
126 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
127 #warn "issuing book?";
128 AddIssue( $borrower, $barcode );
130 # ($borrower, $flags) = getpatroninformation(undef,undef, $patronid);
132 # $template->param( patronid => $patronid,
136 $confirm_required = 1;
138 #warn "issue confirmation";
140 confirm => "Issuing title: " . $item->{title},
143 inputfocus => 'confirm',
149 if ($borrower->{cardnumber}) {
151 # warn "here's the issuer's branchcode: ".$issuer->{branchcode};
152 # warn "here's the user's branchcode: ".$borrower->{branchcode};
153 my $bornum = $borrower->{borrowernumber};
154 my $borrowername = $borrower->{firstname} . " " . $borrower->{surname};
157 my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} );
158 foreach my $it (@$issueslist) {
160 my ( $renewokay, $renewerror ) =
161 CanBookBeIssued( $borrower, $it->{'barcode'}, '', '' );
162 $it->{'norenew'} = 1 if $renewokay->{'NO_MORE_RENEWALS'} == 1;
167 $template->param( validuser => 1,
168 borrowername => $borrowername,
169 issues_count => $cnt,
171 patronid => $patronid ,
176 if ($return_only ==1) {
177 $inputfocus = 'returnbook' ;
178 }elsif ($confirm_required == 1) {
179 $inputfocus = 'confirm' ;
181 $inputfocus = 'barcode' ;
184 $template->param( inputfocus => $inputfocus,
190 $template->param( patronid => $patronid, nouser => $patronid,
191 inputfocus => 'patronid', );
194 output_html_with_http_headers $query, $cookie, $template->output;