Bugzilla – Attachment 123299 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), 20.45 KB, created by
Emmi Takkinen
on 2021-07-30 11:25:02 UTC
(
hide
)
Description:
Bug 22322: Self check-in without log in
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2021-07-30 11:25:02 UTC
Size:
20.45 KB
patch
obsolete
>From 75015b2d3194f0d1348085771a217456ff379244 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. Set "SelfCheckoutByLogin" as "cardnumber". >2. Find patron with loan or add one. >3. Go to /cgi-bin/koha/sco/sco-main.pl >4. Return loan by passing items barcode >=> confirm loans is returned succesfully > >Sponsored-by: Koha-Suomi Oy >--- > .../en/includes/masthead-sco-self.inc | 35 +++++ > .../bootstrap/en/modules/sco/help.tt | 2 +- > .../bootstrap/en/modules/sco/sco-main.tt | 129 +++++++++++++----- > opac/sco/sco-main.pl | 86 +++++++++++- > 4 files changed, 209 insertions(+), 43 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco-self.inc > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco-self.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco-self.inc >new file mode 100644 >index 0000000000..c6be929d7e >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco-self.inc >@@ -0,0 +1,35 @@ >+[% USE Koha %] >+[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] >+<!-- <div id="wrap"> --> >+ <div class="navbar navbar-inverse navbar-static-top navbar-black"> >+ <div class="navbar-inner navbar-black"> >+ <div class="container-fluid navbar-black"> >+ <a class="brand" href="/cgi-bin/koha/sco/sco-main.pl"><img src="[% interface %]/[% theme %]/images/koha-logo-navbar.png" alt=""></a> >+ <div id="checkouthelp"> >+ <ul class="nav pull-right"> >+ <li><a href="/cgi-bin/koha/sco/help.pl"><i class="icon help"></i> Help</a></li> >+ </ul> >+ </div> >+ >+ [% IF ( opaclanguagesdisplay ) %] >+ <div id="members"> >+ <ul class="nav pull-right"> >+ [% INCLUDE 'masthead-langmenu.inc' %] >+ </ul> >+ </div> <!-- /members --> >+ [% END # / IF opaclanguagedisplay %] >+ >+ </div> <!-- /container-fluid --> >+ </div> <!-- /navbar-inner --> >+ </div> <!-- /navbar --> >+<!-- </div> --> >+ >+ [% IF ( opacheader ) %] >+ <div class="container-fluid"> >+ <div class="row-fluid"> >+ <div id="opacheader"> >+ [% opacheader %] >+ </div> >+ </div> >+ </div> >+ [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/help.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/help.tt >index 5228221a71..766c11cbd4 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/help.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/help.tt >@@ -18,7 +18,7 @@ > [% Asset.js("lib/modernizr.min.js") | $raw %] > </head> > <body id="sco_help" class="sco"> >- [% INCLUDE 'masthead-sco.inc' %] >+[% INCLUDE 'masthead-sco-self.inc' %] > > <div class="main"> > <div class="container-fluid"> >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 40521d7e00..d00ef4115a 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 >@@ -36,9 +36,9 @@ > [% Asset.js("lib/modernizr.min.js") | $raw %] > </head> > <body id="sco_main" class="sco" onload="dofocus();" onunload="mungeHistory();"> >- [% INCLUDE 'masthead-sco.inc' %] >+[% INCLUDE 'masthead-sco.inc' %] > >- <div class="main"> >+ <div class="main"> > <div class="container-fluid"> > <div class="row"> > [% IF ( display_patron_image ) %] >@@ -397,46 +397,89 @@ > </div> > </div> > [% ELSE # IF validuser %] >- <div class="sco_entry" > >- <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post"> >- <fieldset> >- [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %] >- <legend>Log in to your account</legend> >- <label for="patronlogin">Login:</label> >- <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" /> >- <label for="patronpw">Password:</label> >- <input type="password" id="patronpw" size="20" name="patronpw" /> >- <fieldset class="action"> >- <button type="submit" class="btn btn-primary">Log in</button> >- </fieldset> >- [% ELSE %] >- <div class="form-row"> >- <div class="col-auto"> >- <label for="patronid">Please enter your card number:</label> >- </div> >- <div class="col-3"> >- <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" /> >- </div> >- <div class="col-auto"> >- <button type="submit" class="btn btn-primary">Submit</button> >- </div> >- </div> <!-- /.form-row --> >- [% END %] >+ <div class="sco_entry"> >+ <table> >+ <tr> >+ <th><h4>Check out</h4></th> >+ <th><h4>Check in</h4></th> >+ </tr> >+ <tr> >+ <td> >+ <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post"> >+ <fieldset> >+ [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %] >+ <legend>Log in to your account</legend> >+ <label for="patronlogin">Login:</label> >+ <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" /> >+ <label for="patronpw">Password:</label> >+ <input type="password" id="patronpw" size="20" name="patronpw" /> >+ <fieldset class="action"> >+ <button type="submit" class="btn btn-primary">Log in</button> >+ </fieldset> >+ [% ELSE %] >+ <div class="form-row"> >+ <div class="col-auto"> >+ <label for="patronid">Please enter your card number:</label> >+ </div> >+ <div class="col-3"> >+ [% IF ( checkinmessage )%] >+ <input type="text" id="patronid" size="20" name="patronid" autocomplete="off" /> >+ [% ELSE %] >+ <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" /> >+ [% END %] >+ </div> >+ <div class="col-auto"> >+ <button type="submit" class="btn btn-primary">Submit</button> >+ </div> >+ </div> <!-- /.form-row --> >+ [% END %] > >- [% FOREACH INPUT IN INPUTS %] >- <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]"> >- [% END %] >- <input type="hidden" name="op" value="login" /> >- </fieldset> >- </form> >+ [% FOREACH INPUT IN INPUTS %] >+ <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]"> >+ [% END %] >+ <input type="hidden" name="op" value="login" /> >+ </fieldset> >+ </form> >+ </td> >+ <td> >+ <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post"> >+ <fieldset> >+ [% IF ( !Koha.Preference('SelfCheckoutByLogin') ) %] >+ <div class="form-row"> >+ <div class="col-auto"> >+ <label for="uibarcode">Please enter barcode:</label> >+ </div> >+ <div class="col-3"> >+ [% IF ( checkinmessage ) %] >+ <input type="text" id="uibarcode" class="form-control focus" size="20" name="uibarcode" autocomplete="off" /> >+ [% ELSE %] >+ <input type="text" id="uibarcode" class="form-control" size="20" name="uibarcode" autocomplete="off" /> >+ [% END %] >+ </div> >+ <div class="col-auto"> >+ <button type="submit" class="btn btn-primary">Submit</button> >+ </div> >+ </div> >+ [% END # / IF SelfCheckoutByLogin %] >+ >+ [% FOREACH INPUT IN INPUTS %] >+ <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]"> >+ [% END %] >+ <input type="hidden" name="op" value="checkin" /> >+ </fieldset> >+ </form> >+ </td> >+ </tr> >+ </table> > </div> <!-- / .sco_entry --> > [% END # / IF validuser %] > [% END # / UNLESS ( hide_main %] >+ <b>[% checkinmessage %]</b> > [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %] > </div> <!-- / .span12 --> > </div> <!-- / .row --> > </div> <!-- / .container-fluid --> >- </div> <!-- / .main --> >+ </div> <!-- / .main --> > <span id="audio-alert"></span> > > [% INCLUDE 'opac-bottom.inc' %] >@@ -498,7 +541,7 @@ > > $(document).ready(function() { > dofocus(); >- [% IF ( patronid ) %]sco_init();[% END %] >+ [% IF ( patronid || uibarcode ) %]sco_init();[% END %] > $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, { > "dom": "t", > "order": [ 0 ], >@@ -509,6 +552,7 @@ > ] > })); > >+ > $("#logout_form").on("click", function(e){ > e.preventDefault(e); > clearTimeout(mainTimeout); >@@ -525,7 +569,22 @@ > [% ELSE %] > location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; > [% END %] >+ return true; >+ }); > >+ $("#logout_form_vara").on("click", function() { >+ clearTimeout(mainTimeout); >+ [% IF Koha.Preference('SelfCheckReceiptPrompt') %] >+ var confirmStart = Date.now(); >+ if(confirm(_("Would you like to print a receipt?"))){ >+ if ( (Date.now() - confirmStart) < [% SelfCheckTimeout %] ) { >+ window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&print=qslip"); >+ } >+ else { >+ alert(_("Timeout while waiting for print confirmation")); >+ } >+ } >+ [% END %] > return true; > }); > }); >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index 40d591519b..96940f530d 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -36,10 +36,12 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > > use C4::Auth qw( in_iprange get_template_and_user checkpw ); >-use C4::Circulation qw( AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal ); >-use C4::Reserves; >+use C4::Circulation qw( AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal updateWrongTransfer ); >+use C4::Reserves qw( ModReserveAffect ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Members; >+use C4::Biblio qw( GetBiblioData ); >+use C4::Items qw( ModItemTransfer ); > use Koha::DateUtils qw( dt_from_string ); > use Koha::Acquisition::Currencies; > use Koha::Items; >@@ -47,6 +49,7 @@ use Koha::Patrons; > use Koha::Patron::Images; > use Koha::Patron::Messages; > use Koha::Token; >+use Koha::Calendar; > > my $query = CGI->new; > >@@ -75,9 +78,11 @@ $query->param(-name=>'sco_user_login',-values=>[1]); > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "sco/sco-main.tt", >+ authnotrequired => 0, > flagsrequired => { self_check => "self_checkout_module" }, > query => $query, > type => "opac", >+ debug => 1, > } > ); > >@@ -95,7 +100,7 @@ if (defined C4::Context->preference('SCOAllowCheckin')) { > } > > my $issuerid = $loggedinuser; >-my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = ( >+my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $uibarcode, $checkinmessage) = ( > $query->param("op") || '', > $query->param("patronid") || '', > $query->param("patronlogin")|| '', >@@ -103,12 +108,29 @@ my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = > $query->param("barcode") || '', > $query->param("confirmed") || '', > $query->param("newissues") || '', >+ $query->param("uibarcode") || '', >+ $query->param("checkinmessage") || undef, > ); > > my @newissueslist = split /,/, $newissues; > my $issuenoconfirm = 1; #don't need to confirm on issue. > my $issuer = Koha::Patrons->find( $issuerid )->unblessed; > my $item = Koha::Items->find({ barcode => $barcode }); >+ >+my $checkinitem; >+my $checkinbranchcode; >+my $userenv = C4::Context->userenv; >+my $userenv_branch = $userenv->{'branch'} // ''; >+my $daysmode = Koha::CirculationRules->get_effective_daysmode( >+ { >+ branchcode => $userenv_branch, >+ } >+); >+my $calendar = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode ); >+my $today = DateTime->now( time_zone => C4::Context->tz()); >+#my $dropboxdate = $calendar->addDays($today, -1); >+#my $returndate = $calendar->addDays($today); >+ > if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { > my $dbh = C4::Context->dbh; > my $resval; >@@ -130,8 +152,8 @@ if ($op eq "logout") { > $template->param( loggedout => 1 ); > $query->param( patronid => undef, patronlogin => undef, patronpw => undef ); > } >-elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { >- my $success = 0; >+elsif ( ($op eq "checkin" && $uibarcode) || $op eq "returnbook" && $allowselfcheckreturns ) { >+ #my $success = 0; > my $human_required = 0; > if ( C4::Context->preference("CircConfirmItemParts") ) { > my $item = Koha::Items->find( { barcode => $barcode } ); >@@ -142,8 +164,58 @@ elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { > } > } > >- ($success) = AddReturn( $barcode, $branch ) >- unless $human_required; >+ $uibarcode =~ s/^\s+|\s+$//g; >+ $checkinitem = Koha::Items->find({ barcode => $uibarcode }); >+ if( !$checkinitem ){ >+ $checkinmessage = "Item not found."; >+ } >+ my $tobranch = $checkinitem->homebranch; >+ my ($success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless $human_required; >+ my $needstransfer = $messages->{'NeedsTransfer'}; >+ if($messages->{'ResFound'}) { >+ my $reserve = $messages->{'ResFound'}; >+ my $reserve_id = $reserve->{'reserve_id'}; >+ my $resborrower = $reserve->{'borrowernumber'}; >+ my $diffBranchReturned = $reserve->{'branchcode'}; >+ my $itemnumber = $checkinitem->itemnumber; >+ my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef; >+ if($diffBranchSend) { >+ ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id); >+ ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound'); >+ } >+ else { >+ my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0; >+ ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id); >+ } >+ $borrower = Koha::Patrons->find({ cardnumber => $patronid }); >+ } >+ else { >+ if($needstransfer) { >+ ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer'); >+ } >+ } >+ >+ if($messages->{'WrongTransfer'}) { >+ updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch); >+ } >+ >+ my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber }); >+ if ( $biblio && $success ) { >+ $checkinmessage = "Returned ".$biblio->title; >+ } >+ >+ if ( $issuer ) { >+ $checkinbranchcode = $issuer->{branchcode}; >+ #home branch of item >+ if ($checkinbranchcode) { >+ my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode ); >+ $checkinmessage.=", ".$checkinlibrary->branchname; >+ } >+ } >+ >+ $template->param(checkinmessage => $checkinmessage || undef); >+ $template->param(SelfCheckTimeout => 10000); #don't show returns long >+ $template->param(uibarcode => $uibarcode); > $template->param( returned => $success ); > } > elsif ( $patron && ( $op eq 'checkout' ) ) { >-- >2.25.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