|
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 46-51
use Koha::Patron::Messages;
Link Here
|
| 46 |
use Koha::Plugins; |
48 |
use Koha::Plugins; |
| 47 |
use Koha::Token; |
49 |
use Koha::Token; |
| 48 |
use Koha::CookieManager; |
50 |
use Koha::CookieManager; |
|
|
51 |
use Koha::Calendar; |
| 49 |
|
52 |
|
| 50 |
my $query = CGI->new; |
53 |
my $query = CGI->new; |
| 51 |
|
54 |
|
|
Lines 66-74
$query->param(-name=>'sco_user_login',-values=>[1]);
Link Here
|
| 66 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
69 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 67 |
{ |
70 |
{ |
| 68 |
template_name => "sco/sco-main.tt", |
71 |
template_name => "sco/sco-main.tt", |
|
|
72 |
authnotrequired => 0, |
| 69 |
flagsrequired => { self_check => "self_checkout_module" }, |
73 |
flagsrequired => { self_check => "self_checkout_module" }, |
| 70 |
query => $query, |
74 |
query => $query, |
| 71 |
type => "opac", |
75 |
type => "opac", |
|
|
76 |
debug => 1, |
| 72 |
} |
77 |
} |
| 73 |
); |
78 |
); |
| 74 |
|
79 |
|
|
Lines 86-92
if (defined C4::Context->preference('SCOAllowCheckin')) {
Link Here
|
| 86 |
} |
91 |
} |
| 87 |
|
92 |
|
| 88 |
my $issuerid = $loggedinuser; |
93 |
my $issuerid = $loggedinuser; |
| 89 |
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts ) = ( |
94 |
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts, $uibarcode, $checkinmessage ) = ( |
| 90 |
$query->param("op") || '', |
95 |
$query->param("op") || '', |
| 91 |
$query->param("patronlogin") || '', |
96 |
$query->param("patronlogin") || '', |
| 92 |
$query->param("patronpw") || '', |
97 |
$query->param("patronpw") || '', |
|
Lines 94-99
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_check
Link Here
|
| 94 |
$query->param("confirmed") || '', |
99 |
$query->param("confirmed") || '', |
| 95 |
$query->param("newissues") || '', |
100 |
$query->param("newissues") || '', |
| 96 |
$query->param("load_checkouts") || '', |
101 |
$query->param("load_checkouts") || '', |
|
|
102 |
$query->param("uibarcode") || '', |
| 103 |
$query->param("checkinmessage") || undef, |
| 97 |
); |
104 |
); |
| 98 |
|
105 |
|
| 99 |
my $jwt = $query->cookie('JWT'); |
106 |
my $jwt = $query->cookie('JWT'); |
|
Lines 110-115
my @newissueslist = split /,/, $newissues;
Link Here
|
| 110 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
117 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
| 111 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
118 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
| 112 |
|
119 |
|
|
|
120 |
my $checkinitem; |
| 121 |
my $checkinbranchcode; |
| 122 |
my $userenv = C4::Context->userenv; |
| 123 |
my $userenv_branch = $userenv->{'branch'} // ''; |
| 124 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
| 125 |
{ |
| 126 |
branchcode => $userenv_branch, |
| 127 |
} |
| 128 |
); |
| 129 |
my $calendar = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode ); |
| 130 |
my $today = DateTime->now( time_zone => C4::Context->tz()); |
| 131 |
|
| 113 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef; |
132 |
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef; |
| 114 |
unless ( $patronid ) { |
133 |
unless ( $patronid ) { |
| 115 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
134 |
if ( C4::Context->preference('SelfCheckoutByLogin') ) { |
|
Lines 134-140
my $branch = $issuer->{branchcode};
Link Here
|
| 134 |
my $confirm_required = 0; |
153 |
my $confirm_required = 0; |
| 135 |
my $return_only = 0; |
154 |
my $return_only = 0; |
| 136 |
|
155 |
|
| 137 |
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
156 |
if ( ( $op eq "cud-checkin" && $uibarcode ) || $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { |
| 138 |
my $success = 1; |
157 |
my $success = 1; |
| 139 |
|
158 |
|
| 140 |
|
159 |
|
|
Lines 147-162
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
Link Here
|
| 147 |
} |
166 |
} |
| 148 |
} |
167 |
} |
| 149 |
|
168 |
|
| 150 |
if ($success) { |
169 |
if ($success && ( $op ne "cud-checkin" && !$uibarcode )) { |
| 151 |
# Patron cannot checkin an item they don't own |
170 |
# Patron cannot checkin an item they don't own |
| 152 |
$success = 0 |
171 |
$success = 0 |
| 153 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
172 |
unless $patron->checkouts->find( { itemnumber => $item->itemnumber } ); |
| 154 |
} |
173 |
} |
| 155 |
|
174 |
|
| 156 |
if ( $success ) { |
175 |
$uibarcode =~ s/^\s+|\s+$//g; |
| 157 |
($success) = AddReturn( $barcode, $branch ) |
176 |
$checkinitem = Koha::Items->find({ barcode => $uibarcode }); |
|
|
177 |
if( !$checkinitem ){ |
| 178 |
$checkinmessage = "Item not found."; |
| 179 |
} |
| 180 |
my $tobranch = $checkinitem->homebranch; |
| 181 |
|
| 182 |
my ($return_success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless !$success; |
| 183 |
|
| 184 |
my $needstransfer = $messages->{'NeedsTransfer'}; |
| 185 |
if($messages->{'ResFound'}) { |
| 186 |
my $reserve = $messages->{'ResFound'}; |
| 187 |
my $reserve_id = $reserve->{'reserve_id'}; |
| 188 |
my $resborrower = $reserve->{'borrowernumber'}; |
| 189 |
my $diffBranchReturned = $reserve->{'branchcode'}; |
| 190 |
my $itemnumber = $checkinitem->itemnumber; |
| 191 |
my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef; |
| 192 |
if($diffBranchSend) { |
| 193 |
ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id); |
| 194 |
ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound'); |
| 195 |
} |
| 196 |
else { |
| 197 |
my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0; |
| 198 |
ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id); |
| 199 |
} |
| 200 |
$borrower = Koha::Patrons->find({ cardnumber => $patronid }); |
| 201 |
} |
| 202 |
else { |
| 203 |
if($needstransfer) { |
| 204 |
ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer'); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
if($messages->{'WrongTransfer'}) { |
| 209 |
updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch); |
| 210 |
} |
| 211 |
|
| 212 |
my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber }); |
| 213 |
if ( $biblio && ( $success || $return_success )) { |
| 214 |
$checkinmessage = "Returned ".$biblio->title; |
| 215 |
} |
| 216 |
|
| 217 |
if ( $issuer ) { |
| 218 |
$checkinbranchcode = $issuer->{branchcode}; |
| 219 |
#home branch of item |
| 220 |
if ($checkinbranchcode) { |
| 221 |
my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode ); |
| 222 |
$checkinmessage.=", ".$checkinlibrary->branchname; |
| 223 |
} |
| 158 |
} |
224 |
} |
| 159 |
|
225 |
|
|
|
226 |
$template->param(checkinmessage => $checkinmessage || undef); |
| 227 |
$template->param(SelfCheckTimeout => 10000); #don't show returns long |
| 228 |
$template->param(uibarcode => $uibarcode); |
| 160 |
$template->param( returned => $success ); |
229 |
$template->param( returned => $success ); |
| 161 |
} |
230 |
} |
| 162 |
elsif ( $patron && ( $op eq 'cud-checkout' ) ) { |
231 |
elsif ( $patron && ( $op eq 'cud-checkout' ) ) { |
| 163 |
- |
|
|