Bugzilla – Attachment 106091 Details for
Bug 23258
Batch tool for placing and cancelling holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23258: Batch holding
Bug-23258-Batch-holding.patch (text/plain), 13.41 KB, created by
Matthias Meusburger
on 2020-06-19 13:16:02 UTC
(
hide
)
Description:
Bug 23258: Batch holding
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2020-06-19 13:16:02 UTC
Size:
13.41 KB
patch
obsolete
>From 8159df2867d6496bafed77128eb7da3be738aa51 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 6 Sep 2016 16:43:04 +0200 >Subject: [PATCH] Bug 23258: Batch holding > >This patch allows to batch place or cancel holds. > >Test plan: > > 1) Apply the patch > 2) Go to Circulation -> Batch holding > 3) Check that you can either upload a barcode file or use the textarea > 4) Check that you can place holds on items > 5) Check that you can cancel holds on items >--- > circ/batch_holding.pl | 152 +++++++++++++++++++ > .../prog/en/modules/circ/batch_holding.tt | 165 +++++++++++++++++++++ > .../prog/en/modules/circ/circulation-home.tt | 3 + > 3 files changed, 320 insertions(+) > create mode 100755 circ/batch_holding.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/batch_holding.tt > >diff --git a/circ/batch_holding.pl b/circ/batch_holding.pl >new file mode 100755 >index 0000000..dcbed73 >--- /dev/null >+++ b/circ/batch_holding.pl >@@ -0,0 +1,152 @@ >+#!/usr/bin/perl >+ >+# Copyright 2019 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Output; >+use C4::Auth; >+use Koha::Items; >+use C4::Reserves; >+use List::MoreUtils qw/uniq/; >+ >+ >+my $input = new CGI; >+my $op = $input->param('op'); >+my @itemnumbers; >+ >+my @errors; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "circ/batch_holding.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ } >+); >+ >+if ($op eq "show"){ >+ my $filefh = $input->upload('uploadfile'); >+ my $filecontent = $input->param('filecontent'); >+ my $borrowernumber = $input->param('borrowernumber'); >+ my $branch = $input->param('branch'); >+ my $action = $input->param('action'); >+ my @notfoundbarcodes; >+ >+ my @contentlist; >+ if ($filefh){ >+ while (my $content=<$filefh>){ >+ $content =~ s/[\r\n]*$//; >+ push @contentlist, $content if $content; >+ } >+ >+ foreach my $barcode (@contentlist) { >+ my $item = Koha::Items->find({ barcode => $barcode }); >+ if ($item) { >+ push @itemnumbers,$item->itemnumber; >+ } else { >+ push @notfoundbarcodes, $barcode; >+ } >+ } >+ } else { >+ if ( my $list=$input->param('barcodelist')){ >+ push my @barcodelist, uniq( split(/\s\n/, $list) ); >+ >+ foreach my $barcode (@barcodelist) { >+ >+ my $item = Koha::Items->find({ barcode => $barcode }); >+ if ($item) { >+ push @itemnumbers,$item->itemnumber; >+ } else { >+ push @notfoundbarcodes, $barcode; >+ } >+ } >+ >+ } >+ } >+ if (@notfoundbarcodes) { >+ my @notfoundbarcodesloop = map{{barcode=>$_}}@notfoundbarcodes; >+ $template->param(notfoundbarcodes => \@notfoundbarcodesloop); >+ } >+ my @holdloop; >+ if (@itemnumbers) { >+ foreach my $itemnumber (@itemnumbers) { >+ my $item = Koha::Items->find({ itemnumber => $itemnumber }); >+ my $holdable = CanItemBeReserved($borrowernumber, $item->itemnumber)->{status}; >+ push @holdloop, { >+ 'itemnumber' => $item->itemnumber, >+ 'barcode' => $item->barcode, >+ 'holdable' => ($action eq "cancel" || $holdable eq 'OK') ? 1 : 0, >+ }; >+ } >+ >+ } >+ $template->param( >+ show => 1, >+ holdloop => \@holdloop, >+ borrowernumber => $borrowernumber, >+ branch => $branch, >+ action => $action, >+ ); >+} >+ >+elsif ($op eq "result") { >+ my $branch = $input->param('branch'); >+ my $borrowernumber = $input->param('borrowernumber'); >+ my $action = $input->param('action'); >+ my @itemnumbers = $input->multi_param('holdable'); >+ my @holdloop; >+ foreach my $itemnumber (@itemnumbers) { >+ if ($action eq "place") { >+ my $item = Koha::Items->find({ itemnumber => $itemnumber }); >+ my $biblionumber = $item->biblionumber; >+ my $reserve_id = AddReserve({ >+ branchcode => $branch, >+ borrowernumber => $borrowernumber, >+ biblionumber => $biblionumber, >+ itemnumber => $itemnumber >+ }); >+ push @holdloop, { >+ 'itemnumber' => $itemnumber, >+ 'reserve_id' => $reserve_id, >+ }; >+ } else { >+ my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); >+ if ($holds) { >+ while ( my $hold = $holds->next ) { >+ $hold->cancel; >+ } >+ >+ push @holdloop, { >+ 'itemnumber' => $itemnumber, >+ }; >+ } >+ } >+ } >+ >+ $template->param( >+ result => 1, >+ holdloop => \@holdloop, >+ cancel => $action eq "cancel" ? 1 : 0, >+ place => $action eq "place" ? 1 : 0, >+ ); >+ >+} >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/batch_holding.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/batch_holding.tt >new file mode 100644 >index 0000000..9ecc04f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/batch_holding.tt >@@ -0,0 +1,165 @@ >+[% USE Branches %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Circulation › Batch holding</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<script> >+ // <![CDATA[ >+ $(document).ready(function() { >+ $("#batchholdform").submit(function() { >+ if (!$("#borrowernumber").val()) { >+ alert(_("Please select a valid borrower.")); >+ return false; >+ } >+ }); >+ $("#findborrowerhold").autocomplete({ >+ source: "/cgi-bin/koha/circ/ysearch.pl", >+ minLength: 3, >+ select: function( event, ui ) { >+ $( "#findborrowerhold" ).val( ui.item.surname + ', ' + ui.item.firstname + ' (' + ui.item.cardnumber + ')' ); >+ $( "#borrowernumber").val( ui.item.borrowernumber ); >+ return false; >+ } >+ }) >+ .data( "ui-autocomplete" )._renderItem = function( ul, item ) { >+ return $( "<li></li>" ) >+ .data( "ui-autocomplete-item", item ) >+ .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" ) >+ .appendTo( ul ); >+ }; >+ }); >+ // ]]> >+</script> >+</head> >+<body id="batch_holding"> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cataloging-search.inc' %] >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> › Batch holding</div> >+ >+<div id="doc" class="yui-t7"> >+ >+<div id="bd"> >+ <div id="yui-main"> >+[% IF show %] >+ [% IF ( notfoundbarcodes ) %] >+ <div class="dialog alert"><p>Warning, the following barcodes were not found:</p></div> >+ <table style="margin:auto;"> >+ <thead> >+ <tr><th>Barcodes not found</th></tr> >+ </thead> >+ <tbody> >+ [% FOREACH notfoundbarcode IN notfoundbarcodes %] >+ <tr><td>[% notfoundbarcode.barcode %]</td></td> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] <!-- /notfoundbarcodes --> >+ >+ [% IF (holdloop) %] >+ <h1>[% action %] holds on the following barcodes</h1> >+ <form action="batch_holding.pl" method="POST"> >+ <ul> >+ [% FOREACH hold IN holdloop %] >+ <li> >+ [% IF hold.holdable %] >+ <input type="checkbox" name="holdable" checked="checked" value="[% hold.itemnumber %]" /> >+ [% hold.barcode %] >+ [% ELSE %] >+ [% hold.barcode %] (This item cannot be reserved) >+ [% END %] >+ </li> >+ [% END %] >+ </ul> >+ <input type="hidden" name="op" value="result" /> >+ <input type="hidden" name="action" value="[% action %]" /> >+ <input type="hidden" name="branch" value="[% branch %]" /> >+ <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >+ <input type="submit" /> >+ </form> >+ [% ELSE %] >+ <p>No reservation can be placed or cancelled.</p> >+ <a href="batch_holding.pl">Batch place or cancel other items</a> >+ [% END %] >+ >+[% ELSIF result %] >+ [% IF (holdloop) %] >+ <h1>Results</h1> >+ <ul> >+ [% IF place %] >+ The following items have been reserved: >+ <ul> >+ [% FOREACH hold IN holdloop %] >+ <li>itemnumber [% hold.itemnumber %], reserve_id [% hold.reserve_id %]</li> >+ [% END %] >+ </ul> >+ [% END %] >+ [% IF cancel %] >+ The following reservations were cancelled: >+ <ul> >+ [% FOREACH hold IN holdloop %] >+ <li>itemnumber [% hold.itemnumber %]</li> >+ [% END %] >+ </ul> >+ [% END %] >+ </ul> >+ [% ELSE %] >+ <p>No reservation could be placed or cancelled.</p> >+ [% END %] >+ <a href="batch_holding.pl">Batch place or cancel other items</a> >+[% ELSE %] >+ <h1>Batch holding</h1> >+ <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/circ/batch_holding.pl" id="batchholdform"> >+ <fieldset class="rows"> >+ <legend>Use a barcode file</legend> >+ <label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>Or scan items one by one</legend> >+ <ol> >+ <li> >+ <label for="barcodelist">Barcode list (one barcode per line): </label> >+ <textarea rows="10" cols="30" id="barcodelist" name="barcodelist"></textarea> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>Holding informations</legend> >+ <ol> >+ <li> >+ <label for="findborrowerhold">Borrower:</label> >+ <input type="hidden" id="borrowernumber" name="borrowernumber" /> >+ <div class="autocomplete"> >+ <input autocomplete="on" id="findborrowerhold" name="findborrowerhold" size="40" class="focus" type="text" /> >+ </div> >+ </li> >+ <li> >+ <label for="branch">Holding branch:</label> >+ <select name="branch" id="branch" style="width:10em;"> >+ [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %] >+ </select> >+ >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>Action</legend> >+ <ol> >+ <li> >+ <input type="radio" name="action" id="action_place_holds" value="place" checked="checked"> >+ <label for="action_place_holds">Place holds</label> >+ </li> >+ <li> >+ <input type="radio" name="action" id="action_cancel_holds" value="cancel"> >+ <label for="action_cancel_holds">Cancel holds</label> >+ </li> >+ </ol> >+ </fieldset> >+ <input type="hidden" name="op" value="show" /> >+ <input type="submit" value="Continue" class="button" /> >+ </form> >+[% END %] >+</div> >+</div> >+</div> >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >index fbabec6..a16f72c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >@@ -69,6 +69,9 @@ > <li> > <a class="circ-button" href="/cgi-bin/koha/circ/reserveratios.pl"><i class="fa fa-line-chart"></i> Hold ratios</a> > </li> >+ <li> >+ <a class="circ-button" href="/cgi-bin/koha/circ/batch_holding.pl"><i class="fa fa-tasks"></i> Batch holding</a> >+ </li> > </ul> > </div> > >-- >2.7.4
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 23258
:
91230
|
106055
|
106077
|
106091
|
106598
|
107408
|
108498
|
108504
|
108628
|
108630
|
180199
|
180231