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);
49 my ($borrower, $flags) = GetMemberDetails(undef,$userid);
51 my $branch = $issuer->{branchcode};
52 my $confirm_required = 0;
54 #warn "issuer cardnum: " . $issuer->{cardnumber};
55 #warn "cardnumber= ".$borrower->{cardnumber};
56 if ($op eq "logout") {
57 $query->param( userid => undef );
59 if ($op eq "returnbook") {
60 my ($doreturn ) = AddReturn($barcode, $branch);
61 #warn "returnbook: " . $doreturn;
62 ($borrower, $flags) = GetMemberDetails(undef, $userid);
65 if ($op eq "checkout" ) {
69 ($impossible,$needconfirm) = CanBookBeIssued($borrower,$barcode);
71 $confirm_required = scalar(keys(%$needconfirm));
72 #warn "confirm_required: " . $confirm_required ;
73 if (scalar(keys(%$impossible))) {
74 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
75 my ($issue_error) = keys %$impossible ;
76 # FIXME we assume only one error.
77 $template->param( impossible => $issue_error,
78 title => $item->{title} ,
81 #warn "issue_error: " . $issue_error ;
82 if ($issue_error eq "NO_MORE_RENEWALS") {
84 $template->param ( returnitem => 1,
88 } elsif ($needconfirm->{RENEW_ISSUE} ) {
91 AddRenewal($borrower,$item->{itemnumber});
93 #warn "renew confirmation";
94 $template->param( renew => 1,
96 confirm => $confirmation_strings{RENEW_ISSUE},
100 } elsif ( $confirm_required && !$confirmed ) {
101 #warn "failed confirmation";
102 my ($confirmation) = keys %$needconfirm ;
103 $template->param( impossible => $confirmation,
107 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
108 #warn "issuing book?";
109 AddIssue($borrower,$barcode);
110 # ($borrower, $flags) = getpatroninformation(undef,undef, $userid);
112 # $template->param( userid => $userid,
116 $confirm_required = 1;
117 #warn "issue confirmation";
118 $template->param( confirm => "Issuing title: " . $item->{title} ,
121 inputfocus => 'confirm',
127 if ($borrower->{cardnumber}) {
129 # warn "here's the issuer's branchcode: ".$issuer->{branchcode};
130 # warn "here's the user's branchcode: ".$borrower->{branchcode};
131 my $bornum = $borrower->{borrowernumber};
132 my $borrowername = $borrower->{firstname} . " " . $borrower->{surname};
134 my ($countissues,$issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
135 foreach my $it ( @$issueslist ) {
139 $template->param( validuser => 1,
140 borrowername => $borrowername,
141 issues_count => $cnt,
148 if ($return_only ==1) {
149 $inputfocus = 'returnbook' ;
150 }elsif ($confirm_required == 1) {
151 $inputfocus = 'confirm' ;
153 $inputfocus = 'barcode' ;
156 $template->param( inputfocus => $inputfocus,
162 $template->param( userid => $userid, nouser => $userid,
163 inputfocus => 'userid', );
166 output_html_with_http_headers $query, $cookie, $template->output;