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;
26 my ($template, $loggedinuser, $cookie)
27 = get_template_and_user({template_name => "sco/sco-main.tmpl",
31 flagsrequired => { managesco => 1},
34 my $dbh = C4::Context->dbh;
36 my $issuerid = $loggedinuser;
37 my ($op, $userid, $barcode, $confirmed, $timedout )= ($query->param("op"),
38 $query->param("userid"),
39 $query->param("barcode"),
40 $query->param( "confirmed"),
41 $query->param( "timedout"), #not actually using this...
43 my %confirmation_strings = ( RENEW_ISSUE => "This item is already checked out to you. Return it?", );
44 my $issuenoconfirm = 1; #don't need to confirm on issue.
46 #warn "issuerid: " . $issuerid;
47 my ($issuer, $flags) = GetMemberDetails($issuerid);
48 my $item = GetItem(undef,$barcode);
50 ($borrower, $flags) = GetMemberDetails(undef,$userid);
52 my $branch = $issuer->{branchcode};
53 my $confirm_required = 0;
55 #warn "issuer cardnum: " . $issuer->{cardnumber};
56 #warn "cardnumber= ".$borrower->{cardnumber};
57 if ($op eq "logout") {
58 $query->param( userid => undef );
60 if ($op eq "returnbook") {
61 my ($doreturn ) = AddReturn($barcode, $branch);
62 #warn "returnbook: " . $doreturn;
63 ($borrower, $flags) = GetMemberDetails(undef, $userid);
66 if ($op eq "checkout" ) {
70 ($impossible,$needconfirm) = CanBookBeIssued($borrower,$barcode);
72 $confirm_required = scalar(keys(%$needconfirm));
73 #warn "confirm_required: " . $confirm_required ;
74 if (scalar(keys(%$impossible))) {
75 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
76 my ($issue_error) = keys %$impossible ;
77 # FIXME we assume only one error.
78 $template->param( impossible => $issue_error,
79 title => $item->{title} ,
82 #warn "issue_error: " . $issue_error ;
83 if ($issue_error eq "NO_MORE_RENEWALS") {
85 $template->param ( returnitem => 1,
89 } elsif ($needconfirm->{RENEW_ISSUE} ) {
92 AddRenewal($borrower,$item->{itemnumber});
94 #warn "renew confirmation";
95 $template->param( renew => 1,
97 confirm => $confirmation_strings{RENEW_ISSUE},
101 } elsif ( $confirm_required && !$confirmed ) {
102 #warn "failed confirmation";
103 my ($confirmation) = keys %$needconfirm ;
104 $template->param( impossible => $confirmation,
108 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
109 #warn "issuing book?";
110 AddIssue($borrower,$barcode);
111 # ($borrower, $flags) = getpatroninformation(undef,undef, $userid);
113 # $template->param( userid => $userid,
117 $confirm_required = 1;
118 #warn "issue confirmation";
119 $template->param( confirm => "Issuing title: " . $item->{title} ,
122 inputfocus => 'confirm',
128 if ($borrower->{cardnumber}) {
130 # warn "here's the issuer's branchcode: ".$issuer->{branchcode};
131 # warn "here's the user's branchcode: ".$borrower->{branchcode};
132 my $bornum = $borrower->{borrowernumber};
133 my $borrowername = $borrower->{firstname} . " " . $borrower->{surname};
135 my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
136 foreach my $it ( @$issueslist ) {
140 $template->param( validuser => 1,
141 borrowername => $borrowername,
142 issues_count => $cnt,
149 if ($return_only ==1) {
150 $inputfocus = 'returnbook' ;
151 }elsif ($confirm_required == 1) {
152 $inputfocus = 'confirm' ;
154 $inputfocus = 'barcode' ;
157 $template->param( inputfocus => $inputfocus,
163 $template->param( userid => $userid, nouser => $userid,
164 inputfocus => 'userid', );
167 output_html_with_http_headers $query, $cookie, $template->output;