|
Lines 36-45
use Modern::Perl;
Link Here
|
| 36 |
use CGI qw ( -utf8 ); |
36 |
use CGI qw ( -utf8 ); |
| 37 |
|
37 |
|
| 38 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
38 |
use C4::Auth qw( in_iprange get_template_and_user checkpw ); |
| 39 |
use C4::Circulation qw( AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); |
39 |
use C4::Circulation qw( AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal updateWrongTransfer ); |
| 40 |
use C4::Reserves; |
40 |
use C4::Reserves qw( ModReserveAffect ); |
| 41 |
use C4::Output qw( output_html_with_http_headers ); |
41 |
use C4::Output qw( output_html_with_http_headers ); |
| 42 |
use C4::Members; |
42 |
use C4::Members; |
|
|
43 |
use C4::Biblio qw( GetBiblioData ); |
| 44 |
use C4::Items qw( ModItemTransfer ); |
| 43 |
use Koha::DateUtils qw( dt_from_string ); |
45 |
use Koha::DateUtils qw( dt_from_string ); |
| 44 |
use Koha::Acquisition::Currencies; |
46 |
use Koha::Acquisition::Currencies; |
| 45 |
use Koha::Items; |
47 |
use Koha::Items; |
|
Lines 47-52
use Koha::Patrons;
Link Here
|
| 47 |
use Koha::Patron::Images; |
49 |
use Koha::Patron::Images; |
| 48 |
use Koha::Patron::Messages; |
50 |
use Koha::Patron::Messages; |
| 49 |
use Koha::Token; |
51 |
use Koha::Token; |
|
|
52 |
use Koha::Calendar; |
| 50 |
|
53 |
|
| 51 |
my $query = CGI->new; |
54 |
my $query = CGI->new; |
| 52 |
|
55 |
|
|
Lines 75-83
$query->param(-name=>'sco_user_login',-values=>[1]);
Link Here
|
| 75 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
78 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 76 |
{ |
79 |
{ |
| 77 |
template_name => "sco/sco-main.tt", |
80 |
template_name => "sco/sco-main.tt", |
|
|
81 |
authnotrequired => 0, |
| 78 |
flagsrequired => { self_check => "self_checkout_module" }, |
82 |
flagsrequired => { self_check => "self_checkout_module" }, |
| 79 |
query => $query, |
83 |
query => $query, |
| 80 |
type => "opac", |
84 |
type => "opac", |
|
|
85 |
debug => 1, |
| 81 |
} |
86 |
} |
| 82 |
); |
87 |
); |
| 83 |
|
88 |
|
|
Lines 95-101
if (defined C4::Context->preference('SCOAllowCheckin')) {
Link Here
|
| 95 |
} |
100 |
} |
| 96 |
|
101 |
|
| 97 |
my $issuerid = $loggedinuser; |
102 |
my $issuerid = $loggedinuser; |
| 98 |
my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = ( |
103 |
my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $uibarcode, $checkinmessage) = ( |
| 99 |
$query->param("op") || '', |
104 |
$query->param("op") || '', |
| 100 |
$query->param("patronid") || '', |
105 |
$query->param("patronid") || '', |
| 101 |
$query->param("patronlogin")|| '', |
106 |
$query->param("patronlogin")|| '', |
|
Lines 103-114
my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) =
Link Here
|
| 103 |
$query->param("barcode") || '', |
108 |
$query->param("barcode") || '', |
| 104 |
$query->param("confirmed") || '', |
109 |
$query->param("confirmed") || '', |
| 105 |
$query->param("newissues") || '', |
110 |
$query->param("newissues") || '', |
|
|
111 |
$query->param("uibarcode") || '', |
| 112 |
$query->param("checkinmessage") || undef, |
| 106 |
); |
113 |
); |
| 107 |
|
114 |
|
| 108 |
my @newissueslist = split /,/, $newissues; |
115 |
my @newissueslist = split /,/, $newissues; |
| 109 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
116 |
my $issuenoconfirm = 1; #don't need to confirm on issue. |
| 110 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
117 |
my $issuer = Koha::Patrons->find( $issuerid )->unblessed; |
| 111 |
my $item = Koha::Items->find({ barcode => $barcode }); |
118 |
my $item = Koha::Items->find({ barcode => $barcode }); |
|
|
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 |
#my $dropboxdate = $calendar->addDays($today, -1); |
| 132 |
#my $returndate = $calendar->addDays($today); |
| 133 |
|
| 112 |
if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { |
134 |
if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { |
| 113 |
my $dbh = C4::Context->dbh; |
135 |
my $dbh = C4::Context->dbh; |
| 114 |
my $resval; |
136 |
my $resval; |
|
Lines 130-137
if ($op eq "logout") {
Link Here
|
| 130 |
$template->param( loggedout => 1 ); |
152 |
$template->param( loggedout => 1 ); |
| 131 |
$query->param( patronid => undef, patronlogin => undef, patronpw => undef ); |
153 |
$query->param( patronid => undef, patronlogin => undef, patronpw => undef ); |
| 132 |
} |
154 |
} |
| 133 |
elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { |
155 |
elsif ( ($op eq "checkin" && $uibarcode) || $op eq "returnbook" && $allowselfcheckreturns ) { |
| 134 |
my $success = 0; |
156 |
#my $success = 0; |
| 135 |
my $human_required = 0; |
157 |
my $human_required = 0; |
| 136 |
if ( C4::Context->preference("CircConfirmItemParts") ) { |
158 |
if ( C4::Context->preference("CircConfirmItemParts") ) { |
| 137 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
159 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
|
Lines 142-149
elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
Link Here
|
| 142 |
} |
164 |
} |
| 143 |
} |
165 |
} |
| 144 |
|
166 |
|
| 145 |
($success) = AddReturn( $barcode, $branch ) |
167 |
$uibarcode =~ s/^\s+|\s+$//g; |
| 146 |
unless $human_required; |
168 |
$checkinitem = Koha::Items->find({ barcode => $uibarcode }); |
|
|
169 |
if( !$checkinitem ){ |
| 170 |
$checkinmessage = "Item not found."; |
| 171 |
} |
| 172 |
my $tobranch = $checkinitem->homebranch; |
| 173 |
my ($success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless $human_required; |
| 174 |
my $needstransfer = $messages->{'NeedsTransfer'}; |
| 175 |
if($messages->{'ResFound'}) { |
| 176 |
my $reserve = $messages->{'ResFound'}; |
| 177 |
my $reserve_id = $reserve->{'reserve_id'}; |
| 178 |
my $resborrower = $reserve->{'borrowernumber'}; |
| 179 |
my $diffBranchReturned = $reserve->{'branchcode'}; |
| 180 |
my $itemnumber = $checkinitem->itemnumber; |
| 181 |
my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef; |
| 182 |
if($diffBranchSend) { |
| 183 |
ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id); |
| 184 |
ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound'); |
| 185 |
} |
| 186 |
else { |
| 187 |
my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0; |
| 188 |
ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id); |
| 189 |
} |
| 190 |
$borrower = Koha::Patrons->find({ cardnumber => $patronid }); |
| 191 |
} |
| 192 |
else { |
| 193 |
if($needstransfer) { |
| 194 |
ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer'); |
| 195 |
} |
| 196 |
} |
| 197 |
|
| 198 |
if($messages->{'WrongTransfer'}) { |
| 199 |
updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch); |
| 200 |
} |
| 201 |
|
| 202 |
my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber }); |
| 203 |
if ( $biblio && $success ) { |
| 204 |
$checkinmessage = "Returned ".$biblio->title; |
| 205 |
} |
| 206 |
|
| 207 |
if ( $issuer ) { |
| 208 |
$checkinbranchcode = $issuer->{branchcode}; |
| 209 |
#home branch of item |
| 210 |
if ($checkinbranchcode) { |
| 211 |
my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode ); |
| 212 |
$checkinmessage.=", ".$checkinlibrary->branchname; |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
$template->param(checkinmessage => $checkinmessage || undef); |
| 217 |
$template->param(SelfCheckTimeout => 10000); #don't show returns long |
| 218 |
$template->param(uibarcode => $uibarcode); |
| 147 |
$template->param( returned => $success ); |
219 |
$template->param( returned => $success ); |
| 148 |
} |
220 |
} |
| 149 |
elsif ( $patron && ( $op eq 'checkout' ) ) { |
221 |
elsif ( $patron && ( $op eq 'checkout' ) ) { |
| 150 |
- |
|
|