Bugzilla – Attachment 178815 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), 14.30 KB, created by
Emmi Takkinen
on 2025-02-28 10:27:36 UTC
(
hide
)
Description:
Bug 22322: Self check-in without log in
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-02-28 10:27:36 UTC
Size:
14.30 KB
patch
obsolete
>From dbf8609c259bae4a15d7d2d31070e2d398ef509d Mon Sep 17 00:00:00 2001 >From: Johanna Raisa <johanna.raisa@gmail.com> >Date: Wed, 10 Jul 2019 13:42:25 +0300 >Subject: [PATCH] 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 | 76 ++++++++++++---- > opac/sco/sco-main.pl | 89 ++++++++++++++----- > 2 files changed, 126 insertions(+), 39 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 15f863e122..2f8a657c39 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 >@@ -302,7 +302,8 @@ > </div> > [% END %] > >- <div class="sco_entry"> >+ <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> >@@ -310,22 +311,22 @@ > <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> >- <div class="col-md-12"> >- <button type="submit" class="btn btn-primary">Log in</button> >- </div> >+ <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> >- <!-- /.row --> >+ <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> >+ <!-- /.row --> > [% ELSE %] > <div class="row"> > <div class="col-md-12"> >@@ -352,7 +353,39 @@ > </form> > <!-- /#mainform --> > </div> >- <!-- / .sco_entry --> >+ <!-- / .sco_entry_checkout --> >+ <div id="sco_entry_checkin" class="sco_entry col" > >+ <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <fieldset class="rows"> >+ <div class="row"> >+ <div class="col"> >+ <h4>Check in</h4> >+ </div> >+ </div> >+ <div class="row"> >+ <div class="col-auto"> >+ <label for="sco_entry_barcode">Please enter barcode:</label> >+ </div> >+ <div class="col-3"> >+ [% IF ( returned == 1 || returned == 0 || empty_return ) %] >+ <input type="text" id="sco_entry_barcode" class="form-control focus" name="sco_entry_barcode" autocomplete="off" /> >+ [% ELSE %] >+ <input type="text" id="sco_entry_barcode" class="form-control" name="sco_entry_barcode" autocomplete="off" /> >+ [% END %] >+ </div> >+ <div class="col"> >+ <button type="submit" class="btn btn-primary">Submit</button> >+ </div> >+ </div> >+ [% 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" /> >+ </fieldset> >+ </form> >+ </div> >+ <!-- / .sco_entry_checkin --> > [% IF ( SCOMainUserBlock ) %] > <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div> > [% END %] >@@ -452,7 +485,7 @@ > > $(document).ready(function() { > dofocus(); >- [% IF ( patronid ) %]sco_init();[% END %] >+ [% IF ( patronid || barcode ) %]sco_init();[% END %] > > var dTables = $("#loanTable, #holdst, #finestable"); > dTables.each(function(){ >@@ -710,7 +743,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..91fb989831 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; >@@ -67,10 +68,11 @@ $query->param( -name => 'sco_user_login', -values => [1] ); > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >- template_name => "sco/sco-main.tt", >- flagsrequired => { self_check => "self_checkout_module" }, >- query => $query, >- type => "opac", >+ template_name => "sco/sco-main.tt", >+ authnotrequired => 0, >+ flagsrequired => { self_check => "self_checkout_module" }, >+ query => $query, >+ type => "opac", > } > ); > >@@ -88,14 +90,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 +111,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 +159,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 +184,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 +192,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