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 userid and
6 # issue items to that borrower.
20 use HTML::Template::Pro;
25 my ($template, $loggedinuser, $cookie)
26 = get_template_and_user({template_name => "sco/sco-main.tmpl",
30 flagsrequired => { managesco => 1},
33 my $dbh = C4::Context->dbh;
35 my $issuerid = $loggedinuser;
36 my ($op, $userid, $barcode, $confirmed, $timedout )= ($query->param("op"),
37 $query->param("userid"),
38 $query->param("barcode"),
39 $query->param( "confirmed"),
40 $query->param( "timedout"), #not actually using this...
42 my %confirmation_strings = ( RENEW_ISSUE => "This item is already checked out to you. Return it?", );
43 my $issuenoconfirm = 1; #don't need to confirm on issue.
45 #warn "issuerid: " . $issuerid;
46 my ($issuer, $flags) = GetMemberDetails($issuerid);
47 my $item = GetItem(undef,$barcode);
48 my ($borrower, $flags) = GetMemberDetails(undef,$userid);
50 my $branch = $issuer->{branchcode};
51 my $confirm_required = 0;
53 #warn "issuer cardnum: " . $issuer->{cardnumber};
54 #warn "cardnumber= ".$borrower->{cardnumber};
55 if ($op eq "logout") {
56 $query->param( userid => undef );
58 if ($op eq "returnbook") {
59 my ($doreturn ) = AddReturn($barcode, $branch);
60 #warn "returnbook: " . $doreturn;
61 ($borrower, $flags) = GetMemberDetails(undef, $userid);
64 if ($op eq "checkout" ) {
68 ($impossible,$needconfirm) = CanBookBeIssued($borrower,$barcode);
70 $confirm_required = scalar(keys(%$needconfirm));
71 #warn "confirm_required: " . $confirm_required ;
72 if (scalar(keys(%$impossible))) {
73 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
74 my ($issue_error) = keys %$impossible ;
75 # FIXME we assume only one error.
76 $template->param( impossible => $issue_error,
77 title => $item->{title} ,
80 #warn "issue_error: " . $issue_error ;
81 if ($issue_error eq "NO_MORE_RENEWALS") {
83 $template->param ( returnitem => 1,
87 } elsif ($needconfirm->{RENEW_ISSUE} ) {
90 AddRenewal($borrower,$item->{itemnumber});
92 #warn "renew confirmation";
93 $template->param( renew => 1,
95 confirm => $confirmation_strings{RENEW_ISSUE},
99 } elsif ( $confirm_required && !$confirmed ) {
100 #warn "failed confirmation";
101 my ($confirmation) = keys %$needconfirm ;
102 $template->param( impossible => $confirmation,
106 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
107 #warn "issuing book?";
108 AddIssue($borrower,$barcode);
109 # ($borrower, $flags) = getpatroninformation(undef,undef, $userid);
111 # $template->param( userid => $userid,
115 $confirm_required = 1;
116 #warn "issue confirmation";
117 $template->param( confirm => "Issuing title: " . $item->{title} ,
120 inputfocus => 'confirm',
126 if ($borrower->{cardnumber}) {
128 # warn "here's the issuer's branchcode: ".$issuer->{branchcode};
129 # warn "here's the user's branchcode: ".$borrower->{branchcode};
130 my $bornum = $borrower->{borrowernumber};
131 my $borrowername = $borrower->{firstname} . " " . $borrower->{surname};
133 my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
134 foreach my $it ( @$issueslist ) {
138 $template->param( validuser => 1,
139 borrowername => $borrowername,
140 issues_count => $cnt,
147 if ($return_only ==1) {
148 $inputfocus = 'returnbook' ;
149 }elsif ($confirm_required == 1) {
150 $inputfocus = 'confirm' ;
152 $inputfocus = 'barcode' ;
155 $template->param( inputfocus => $inputfocus,
161 $template->param( userid => $userid, nouser => $userid,
162 inputfocus => 'userid', );
165 output_html_with_http_headers $query, $cookie, $template->output;