Bugzilla – Attachment 180953 Details for
Bug 22322
Self-checkin module should provide for automatic logins (like self-checkout)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22322: Self check-in without log in
0001-Bug-22322-Self-check-in-without-log-in.patch (text/plain), 18.20 KB, created by
Emmi Takkinen
on 2025-04-15 09:38:48 UTC
(
hide
)
Description:
Bug 22322: Self check-in without log in
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-04-15 09:38:48 UTC
Size:
18.20 KB
patch
obsolete
>From 097c069d803955b6c0591bfba064ae126aced040 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Tue, 15 Apr 2025 10:06:33 +0300 >Subject: [PATCH 1/2] Bug 22322: Self check-in without log in > >One should be able to return loans via SCO without >login required. This patch adds check in box where >patrons can check in their loans with barcode. > >To test: >1. Find patron with loan or add one. >2. Go to /cgi-bin/koha/sco/sco-main.pl. >3. Return loan by passing items barcode. >=> Confirm loans is returned succesfully. >4. Attempt to return item again. >=> Confirm that "Item not checked in:..." message >is displayed. >5. Attempt to return empty barcode field. >=> Confirm that "Please enter barcode." message is >displayed. > >Sponsored-by: Koha-Suomi Oy >--- > .../bootstrap/en/modules/sco/sco-main.tt | 125 ++++++++++++------ > opac/sco/sco-main.pl | 80 ++++++++--- > 2 files changed, 146 insertions(+), 59 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >index 52530b7e18..4c1655f1d9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >@@ -303,60 +303,94 @@ > </div> > [% END %] > >- <div class="sco_entry"> >- <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post"> >- [% INCLUDE 'csrf-token.inc' %] >- <fieldset> >- <legend>Log in to your account</legend> >- <div class="row"> >- <div class="col-md-6"> >- [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %] >- <div class="row"> >- <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div> >- <div class="col-md-12"> >- <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" /> >- </div> >- <div class="col-md-12"> >- <label for="patronpw">Password:</label> >- </div> >- <div class="col-md-12"> >- <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" /> >+ <div class="row"> >+ <div id="sco_entry_checkout" class="sco_entry col" > >+ <h4>Check out</h4> >+ <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <fieldset> >+ <legend>Log in to your account</legend> >+ <div class="col-md-6"> >+ [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %] >+ <div class="row"> >+ <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div> >+ <div class="col-md-12"> >+ <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" /> >+ </div> >+ <div class="col-md-12"> >+ <label for="patronpw">Password:</label> >+ </div> >+ <div class="col-md-12"> >+ <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" /> >+ </div> >+ <div class="col-md-12"> >+ <button type="submit" class="btn btn-primary">Log in</button> >+ </div> > </div> >- <div class="col-md-12"> >- <button type="submit" class="btn btn-primary">Log in</button> >+ <!-- /.row --> >+ [% ELSE %] >+ <div class="row"> >+ <div class="col-md-12"> >+ <label for="patronid">Please enter your card number:</label> >+ </div> >+ <div class="col-md-12"> >+ <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" /> >+ </div> >+ <div class="col-md-12"> >+ <button type="submit" class="btn btn-primary">Submit</button> >+ </div> > </div> >- </div> >- <!-- /.row --> >- [% ELSE %] >+ <!-- /.row --> >+ [% END %] >+ </div> >+ <!-- /.col-md-6 --> >+ [% FOREACH INPUT IN INPUTS %] >+ <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]" /> >+ [% END %] >+ <input type="hidden" name="op" value="cud-login" /> >+ </fieldset> >+ </form> >+ <!-- /#mainform --> >+ </div> >+ <!-- / #sco_entry_checkout --> >+ <div id="sco_entry_checkin" class="sco_entry col" > >+ <h4>Check in</h4> >+ <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <fieldset> >+ <div class="col-md-6"> > <div class="row"> > <div class="col-md-12"> >- <label for="patronid">Please enter your card number:</label> >+ <label for="sco_entry_barcode">Please enter barcode:</label> > </div> > <div class="col-md-12"> >- <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" /> >+ [% IF ( returned == 1 || returned == 0 || empty_return ) %] >+ <input type="text" id="sco_entry_barcode" class="form-control focus" size="20" name="sco_entry_barcode" autocomplete="off" /> >+ [% ELSE %] >+ <input type="text" id="sco_entry_barcode" class="form-control" size="20" name="sco_entry_barcode" autocomplete="off" /> >+ [% END %] > </div> > <div class="col-md-12"> > <button type="submit" class="btn btn-primary">Submit</button> > </div> > </div> > <!-- /.row --> >- [% END %] >- </div> >- <!-- /.col-md-6 --> >- </div> >- <!-- /.row --> >- [% FOREACH INPUT IN INPUTS %] >- <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]" /> >- [% END %] >- <input type="hidden" name="op" value="cud-login" /> >- </fieldset> >- </form> >- <!-- /#mainform --> >+ [% FOREACH INPUT IN INPUTS %] >+ <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]"> >+ [% END %] >+ <input type="hidden" name="op" value="cud-sco_entry_checkin" /> >+ </div> >+ <!-- /.col-md-6 --> >+ </fieldset> >+ </form> >+ <!-- /#barcodeform --> >+ </div> >+ <!-- / #sco_entry_checkin --> >+ [% IF ( SCOMainUserBlock ) %] >+ <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div> >+ [% END %] > </div> >- <!-- / .sco_entry --> >- [% IF ( SCOMainUserBlock ) %] >- <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div> >- [% END %] >+ <!-- / .row --> > </div> > <!-- / .span12 --> > </div> >@@ -453,7 +487,7 @@ > > $(document).ready(function() { > dofocus(); >- [% IF ( patronid ) %]sco_init();[% END %] >+ [% IF ( patronid || barcode ) %]sco_init();[% END %] > > var dTables = $("#loanTable, #holdst, #finestable"); > dTables.each(function(){ >@@ -711,7 +745,12 @@ > [% ELSIF ( returned == 1 ) %] > <span class="sco-alert-success return"></span> > <div class="alert alert-info"> >- <p>Item checked in <i>([% barcode | html %])</i></p> >+ <p>Item checked in: [% title | html %] <i>([% barcode | html %])</i>[% IF library %], [% library | html %][% END %]</p> >+ </div> >+ [% ELSIF ( empty_return == 1 ) %] >+ <span class="sco-alert-success return"></span> >+ <div class="alert alert-info"> >+ <p>Please enter barcode.</p> > </div> > [% END %] > [% END %] >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index 9ecae7c76c..b94299ade1 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -34,9 +34,10 @@ use CGI qw ( -utf8 ); > > use C4::Auth qw( in_iprange get_template_and_user checkpw ); > use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); >-use C4::Reserves; >+use C4::Reserves qw ( ModReserveAffect ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Members; >+use C4::Items qw( ModItemTransfer ); > use Koha::DateUtils qw( dt_from_string ); > use Koha::Acquisition::Currencies; > use Koha::Items; >@@ -88,14 +89,15 @@ if ( defined C4::Context->preference('SCOAllowCheckin') ) { > } > > my $issuerid = $loggedinuser; >-my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts ) = ( >- $query->param("op") || '', >- $query->param("patronlogin") || '', >- $query->param("patronpw") || '', >- $query->param("barcode") || '', >- $query->param("confirmed") || '', >- $query->param("newissues") || '', >- $query->param("load_checkouts") || '', >+my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts, $sco_entry_barcode ) = ( >+ $query->param("op") || '', >+ $query->param("patronlogin") || '', >+ $query->param("patronpw") || '', >+ $query->param("barcode") || '', >+ $query->param("confirmed") || '', >+ $query->param("newissues") || '', >+ $query->param("load_checkouts") || '', >+ $query->param("sco_entry_barcode") || '', > ); > > my $jwt = $query->cookie('JWT'); >@@ -108,8 +110,8 @@ if ( $op eq "logout" ) { > } > > my $barcodes = []; >-if ($barcodestr) { >- push @$barcodes, split( /\s\n/, $barcodestr ); >+if ( $barcodestr || $sco_entry_barcode ) { >+ push @$barcodes, split( /\s\n/, $barcodestr ? $barcodestr : $sco_entry_barcode ); > $barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ]; > } > >@@ -156,11 +158,23 @@ if ($patron) { > } > } > >-if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { >+if ( ( $op eq "cud-sco_entry_checkin" ) || ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) ) { > my $success = 1; > >+ if ( !@$barcodes ) { >+ $template->param( empty_return => 1 ); >+ } >+ > foreach my $barcode (@$barcodes) { > my $item = Koha::Items->find( { barcode => $barcode } ); >+ >+ my $title = $item ? Koha::Biblios->find( { biblionumber => $item->biblionumber } )->title : undef; >+ my $checkinlibrary = $issuer && $branch ? Koha::Libraries->find($branch)->branchname : undef; >+ >+ if ( !$item ) { >+ $success = 0; >+ } >+ > if ( $success && C4::Context->preference("CircConfirmItemParts") ) { > if ( defined($item) > && $item->materials ) >@@ -169,7 +183,7 @@ if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { > } > } > >- if ($success) { >+ if ( $success && ( $op ne "cud-sco_entry_checkin" ) ) { > > # Patron cannot checkin an item they don't own > $success = 0 >@@ -177,12 +191,46 @@ if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { > } > > if ($success) { >- ($success) = AddReturn( $barcode, $branch ); >+ >+ my $to_branch = $item->homebranch; >+ my $messages; >+ >+ ( $success, $messages ) = AddReturn( $barcode, $branch ); >+ >+ if ( $messages->{'ResFound'} ) { >+ my $reserve = $messages->{'ResFound'}; >+ my $reserve_id = $reserve->{'reserve_id'}; >+ my $resborrower = $reserve->{'borrowernumber'}; >+ my $resbranch = $reserve->{'branchcode'}; >+ my $itemnumber = $item->itemnumber; >+ my $diff_branch_send = ( $branch ne $resbranch ) ? $resbranch : undef; >+ >+ if ($diff_branch_send) { >+ ModReserveAffect( $itemnumber, $resborrower, $diff_branch_send, $reserve_id ); >+ ModItemTransfer( $itemnumber, $branch, $resbranch, 'ResFound' ); >+ } else { >+ my $set_transit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups'); >+ ModReserveAffect( $itemnumber, $resborrower, $set_transit, $reserve_id ); >+ } >+ } elsif ( $messages->{'NeedsTransfer'} ) { >+ ModItemTransfer( $item->itemnumber, $branch, $to_branch, 'NeedsTransfer' ); >+ } >+ >+ if ( $messages->{'WrongTransfer'} ) { >+ my $item = Koha::Items->find( $messages->{'WrongTransferItem'} ); >+ my $old_transfer = $item->get_transfer; >+ my $new_transfer = $item->request_transfer( >+ { to => $old_transfer->tobranch, reason => $old_transfer->reason, replace => 'WrongTransfer' } ); >+ } >+ > } > > $template->param( >- returned => $success, >- barcode => $barcode >+ SelfCheckTimeout => 10000, #don't show returns long >+ returned => $success, >+ barcode => $barcode, >+ title => $title, >+ library => $checkinlibrary > ); > } # foreach barcode in barcodes > >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22322
:
123299
|
139170
|
140162
|
143764
|
150770
|
150776
|
161722
|
161723
|
165722
|
165723
|
178815
|
179010
| 180953 |
180954