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 );
63 if ($op eq "returnbook") {
64 my ($doreturn ) = AddReturn($barcode, $branch);
65 #warn "returnbook: " . $doreturn;
66 ($borrower) = GetMemberDetails(undef, $patronid);
69 if ($op eq "checkout" ) {
73 ($impossible,$needconfirm) = CanBookBeIssued($borrower,$barcode);
75 $confirm_required = scalar(keys(%$needconfirm));
76 #warn "confirm_required: " . $confirm_required ;
77 if (scalar(keys(%$impossible))) {
78 # warn "impossible: numkeys: " . scalar (keys(%$impossible));
79 my ($issue_error) = keys %$impossible ;
80 # FIXME we assume only one error.
81 $template->param( impossible => $issue_error,
82 title => $item->{title} ,
85 #warn "issue_error: " . $issue_error ;
86 if ($issue_error eq "NO_MORE_RENEWALS") {
88 $template->param ( returnitem => 1,
92 } elsif ($needconfirm->{RENEW_ISSUE} ) {
95 AddRenewal($borrower,$item->{itemnumber});
97 #warn "renew confirmation";
98 $template->param( renew => 1,
101 confirm_renew_issue => 1,
105 } elsif ( $confirm_required && !$confirmed ) {
106 #warn "failed confirmation";
107 my ($confirmation) = keys %$needconfirm ;
108 $template->param( impossible => $confirmation,
112 if ( $confirmed || $issuenoconfirm ) { # we'll want to call getpatroninfo again to get updated issues.
113 #warn "issuing book?";
114 AddIssue($borrower,$barcode);
115 # ($borrower, $flags) = getpatroninformation(undef,undef, $patronid);
117 # $template->param( patronid => $patronid,
121 $confirm_required = 1;
122 #warn "issue confirmation";
123 $template->param( confirm => "Issuing title: " . $item->{title} ,
126 inputfocus => 'confirm',
132 if ($borrower->{cardnumber}) {
134 # warn "here's the issuer's branchcode: ".$issuer->{branchcode};
135 # warn "here's the user's branchcode: ".$borrower->{branchcode};
136 my $bornum = $borrower->{borrowernumber};
137 my $borrowername = $borrower->{firstname} . " " . $borrower->{surname};
139 my ($issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
140 foreach my $it ( @$issueslist ) {
144 $template->param( validuser => 1,
145 borrowername => $borrowername,
146 issues_count => $cnt,
148 patronid => $patronid ,
153 if ($return_only ==1) {
154 $inputfocus = 'returnbook' ;
155 }elsif ($confirm_required == 1) {
156 $inputfocus = 'confirm' ;
158 $inputfocus = 'barcode' ;
161 $template->param( inputfocus => $inputfocus,
167 $template->param( patronid => $patronid, nouser => $patronid,
168 inputfocus => 'patronid', );
171 output_html_with_http_headers $query, $cookie, $template->output;