Lines 33-42
use Modern::Perl;
Link Here
|
33 |
use CGI qw ( -utf8 ); |
33 |
use CGI qw ( -utf8 ); |
34 |
|
34 |
|
35 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
35 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
36 |
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); |
36 |
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal updateWrongTransfer ); |
37 |
use C4::Reserves; |
37 |
use C4::Reserves qw( ModReserveAffect ); |
38 |
use C4::Output qw( output_html_with_http_headers ); |
38 |
use C4::Output qw( output_html_with_http_headers ); |
39 |
use C4::Members; |
39 |
use C4::Members; |
|
|
40 |
use C4::Biblio qw( GetBiblioData ); |
41 |
use C4::Items qw( ModItemTransfer ); |
40 |
use Koha::DateUtils qw( dt_from_string ); |
42 |
use Koha::DateUtils qw( dt_from_string ); |
41 |
use Koha::Acquisition::Currencies; |
43 |
use Koha::Acquisition::Currencies; |
42 |
use Koha::Items; |
44 |
use Koha::Items; |
Lines 45-50
use Koha::Patron::Images;
Link Here
|
45 |
use Koha::Patron::Messages; |
47 |
use Koha::Patron::Messages; |
46 |
use Koha::Plugins; |
48 |
use Koha::Plugins; |
47 |
use Koha::Token; |
49 |
use Koha::Token; |
|
|
50 |
use Koha::Calendar; |
48 |
|
51 |
|
49 |
my $query = CGI->new; |
52 |
my $query = CGI->new; |
50 |
|
53 |
|
Lines 73-81
$query->param(-name=>'sco_user_login',-values=>[1]);
Link Here
|
73 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
76 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
74 |
{ |
77 |
{ |
75 |
template_name => "sco/sco-main.tt", |
78 |
template_name => "sco/sco-main.tt", |
|
|
79 |
authnotrequired => 0, |
76 |
flagsrequired => { self_check => "self_checkout_module" }, |
80 |
flagsrequired => { self_check => "self_checkout_module" }, |
77 |
query => $query, |
81 |
query => $query, |
78 |
type => "opac", |
82 |
type => "opac", |
|
|
83 |
debug => 1, |
79 |
} |
84 |
} |
80 |
); |
85 |
); |
81 |
|
86 |
|
Lines 93-99
if (defined C4::Context->preference('SCOAllowCheckin')) {
Link Here
|
93 |
} |
98 |
} |
94 |
|
99 |
|
95 |
my $issuerid = $loggedinuser; |
100 |
my $issuerid = $loggedinuser; |
96 |
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts ) = ( |
101 |
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts, $uibarcode, $checkinmessage ) = ( |
97 |
$query->param("op") || '', |
102 |
$query->param("op") || '', |
98 |
$query->param("patronlogin") || '', |
103 |
$query->param("patronlogin") || '', |
99 |
$query->param("patronpw") || '', |
104 |
$query->param("patronpw") || '', |
Lines 101-106
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_check
Link Here
|
101 |
$query->param("confirmed") || '', |
106 |
$query->param("confirmed") || '', |
102 |
$query->param("newissues") || '', |
107 |
$query->param("newissues") || '', |
103 |
$query->param("load_checkouts") || '', |
108 |
$query->param("load_checkouts") || '', |
|
|
109 |
$query->param("uibarcode") || '', |
110 |
$query->param("checkinmessage") || undef, |
104 |
); |
111 |
); |
105 |
|
112 |
|
106 |
my $jwt = $query->cookie('JWT'); |
113 |
my $jwt = $query->cookie('JWT'); |
Lines 116-121
my @newissueslist = split /,/, $newissues;
Link Here
|
116 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
123 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
117 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
124 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
118 |
|
125 |
|
|
|
126 |
my $checkinitem; |
127 |
my $checkinbranchcode; |
128 |
my $userenv = C4::Context->userenv; |
129 |
my $userenv_branch = $userenv->{'branch'} // ''; |
130 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
131 |
{ |
132 |
branchcode => $userenv_branch, |
133 |
} |
134 |
); |
135 |
my $calendar = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode ); |
136 |
my $today = DateTime->now( time_zone => C4::Context->tz()); |
137 |
|
119 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef; |
138 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef; |
120 |
unless ( $patronid ) { |
139 |
unless ( $patronid ) { |
121 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
140 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
Lines 140-146
my $branch = $issuer->{branchcode};
Link Here
|
140 |
my $confirm_required = 0; |
159 |
my $confirm_required = 0; |
141 |
my $return_only = 0; |
160 |
my $return_only = 0; |
142 |
|
161 |
|
143 |
if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) { |
162 |
if ( ( $op eq "checkin" && $uibarcode ) || $patron && $op eq "returnbook" && $allowselfcheckreturns ) { |
144 |
my $success = 1; |
163 |
my $success = 1; |
145 |
|
164 |
|
146 |
|
165 |
|
Lines 153-168
if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) {
Link Here
|
153 |
} |
172 |
} |
154 |
} |
173 |
} |
155 |
|
174 |
|
156 |
if ($success) { |
175 |
if ($success && ( $op ne "checkin" && !$uibarcode )) { |
157 |
# Patron cannot checkin an item they don't own |
176 |
# Patron cannot checkin an item they don't own |
158 |
$success = 0 |
177 |
$success = 0 |
159 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
178 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
160 |
} |
179 |
} |
161 |
|
180 |
|
162 |
if ( $success ) { |
181 |
$uibarcode =~ s/^\s+|\s+$//g; |
163 |
($success) = AddReturn( $barcode, $branch ) |
182 |
$checkinitem = Koha::Items->find({ barcode => $uibarcode }); |
|
|
183 |
if( !$checkinitem ){ |
184 |
$checkinmessage = "Item not found."; |
185 |
} |
186 |
my $tobranch = $checkinitem->homebranch; |
187 |
|
188 |
my ($return_success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless !$success; |
189 |
|
190 |
my $needstransfer = $messages->{'NeedsTransfer'}; |
191 |
if($messages->{'ResFound'}) { |
192 |
my $reserve = $messages->{'ResFound'}; |
193 |
my $reserve_id = $reserve->{'reserve_id'}; |
194 |
my $resborrower = $reserve->{'borrowernumber'}; |
195 |
my $diffBranchReturned = $reserve->{'branchcode'}; |
196 |
my $itemnumber = $checkinitem->itemnumber; |
197 |
my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef; |
198 |
if($diffBranchSend) { |
199 |
ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id); |
200 |
ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound'); |
201 |
} |
202 |
else { |
203 |
my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0; |
204 |
ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id); |
205 |
} |
206 |
$borrower = Koha::Patrons->find({ cardnumber => $patronid }); |
207 |
} |
208 |
else { |
209 |
if($needstransfer) { |
210 |
ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer'); |
211 |
} |
212 |
} |
213 |
|
214 |
if($messages->{'WrongTransfer'}) { |
215 |
updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch); |
216 |
} |
217 |
|
218 |
my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber }); |
219 |
if ( $biblio && ( $success || $return_success )) { |
220 |
$checkinmessage = "Returned ".$biblio->title; |
221 |
} |
222 |
|
223 |
if ( $issuer ) { |
224 |
$checkinbranchcode = $issuer->{branchcode}; |
225 |
#home branch of item |
226 |
if ($checkinbranchcode) { |
227 |
my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode ); |
228 |
$checkinmessage.=", ".$checkinlibrary->branchname; |
229 |
} |
164 |
} |
230 |
} |
165 |
|
231 |
|
|
|
232 |
$template->param(checkinmessage => $checkinmessage || undef); |
233 |
$template->param(SelfCheckTimeout => 10000); #don't show returns long |
234 |
$template->param(uibarcode => $uibarcode); |
166 |
$template->param( returned => $success ); |
235 |
$template->param( returned => $success ); |
167 |
} |
236 |
} |
168 |
elsif ( $patron && ( $op eq 'checkout' ) ) { |
237 |
elsif ( $patron && ( $op eq 'checkout' ) ) { |
169 |
- |
|
|