[Koha-patches] [PATCH] bug 6039: Cancel All waiting holds button TransferWhenCancelAllWaitingHolds syspref
Srdjan Jankovic
srdjan at catalyst.net.nz
Mon Apr 4 03:48:50 CEST 2011
---
circ/waitingreserves.pl | 107 +++++++++++++-------
installer/data/mysql/en/mandatory/sysprefs.sql | 2 +-
installer/data/mysql/updatedatabase.pl | 7 ++
.../en/modules/admin/preferences/circulation.pref | 6 +
.../prog/en/modules/circ/waitingreserves.tmpl | 28 ++++--
5 files changed, 106 insertions(+), 44 deletions(-)
diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl
index 9850114..09ab3d2 100755
--- a/circ/waitingreserves.pl
+++ b/circ/waitingreserves.pl
@@ -46,6 +46,7 @@ my $borrowernumber = $input->param('borrowernumber');
my $fbr = $input->param('fbr') || '';
my $tbr = $input->param('tbr') || '';
my $all_branches = $input->param('allbranches') || '';
+my $cancelall = $input->param('cancelall');
my $cancel;
@@ -62,42 +63,23 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $default = C4::Context->userenv->{'branch'};
+my $transfer_when_cancel_all = C4::Context->preference('TransferWhenCancelAllWaitingHolds');
+$template->param( TransferWhenCancelAllWaitingHolds => 1 ) if $transfer_when_cancel_all;
+
+my @cancel_result;
# if we have a return from the form we launch the subroutine CancelReserve
if ($item) {
- my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
- # if we have a result
- if ($nextreservinfo) {
- my $borrowerinfo = GetMemberDetails( $nextreservinfo );
- my $iteminfo = GetBiblioFromItemNumber($item);
- if ( $messages->{'transfert'} ) {
- $template->param(
- messagetransfert => $messages->{'transfert'},
- branchname => GetBranchName($messages->{'transfert'}),
- );
- }
-
- $template->param(
- message => 1,
- nextreservnumber => $nextreservinfo,
- nextreservsurname => $borrowerinfo->{'surname'},
- nextreservfirstname => $borrowerinfo->{'firstname'},
- nextreservitem => $item,
- nextreservtitle => $iteminfo->{'title'},
- waiting => ($messages->{'waiting'}) ? 1 : 0,
- );
- }
-
-# if the document is not in his homebranch location and there is not reservation after, we transfer it
- if ($fbr ne $tbr and not $nextreservinfo) {
- ModItemTransfer( $item, $fbr, $tbr );
- }
+ my $res = cancel( $item, $borrowernumber, $fbr, $tbr );
+ push @cancel_result, $res if $res;
}
+
if ( C4::Context->preference('IndependantBranches') ) {
undef $all_branches;
} else {
- $template->param( all_branches_link => $input->url . '?allbranches=1&' . $input->query_string )
+ $template->param( all_branches_link => $input->url . '?allbranches=1' )
unless $all_branches;
}
+$template->param( all_branches => 1 ) if $all_branches;
my (@reservloop, @overloop);
my ($reservcount, $overcount);
@@ -107,11 +89,27 @@ my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch(
my $today = Date_to_Days(&Today);
foreach my $num (@getreserves) {
next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
- my %getreserv;
- my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
+
+ my $itemnumber = $num->{'itemnumber'};
+ my $gettitle = GetBiblioFromItemNumber( $itemnumber );
+ my $borrowernum = $num->{'borrowernumber'};
+ my $holdingbranch = $gettitle->{'holdingbranch'};
+ my $homebranch = $gettitle->{'homebranch'};
+
+ if ($cancelall) {
+ my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all );
+ push @cancel_result, $res if $res;
+ next;
+ }
+
+ my %getreserv = (
+ itemnumber => $itemnumber,
+ borrowernum => $borrowernum,
+ );
+
# fix up item type for display
$gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
- my $getborrower = GetMemberDetails( $num->{'borrowernumber'} );
+ my $getborrower = GetMemberDetails( $borrowernum );
my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
$getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} );
@@ -123,16 +121,13 @@ foreach my $num (@getreserves) {
$getreserv{'itemtype'} = $itemtypeinfo->{'description'};
$getreserv{'title'} = $gettitle->{'title'};
- $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
$getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
$getreserv{'barcode'} = $gettitle->{'barcode'};
- $getreserv{'homebranch'} = GetBranchName($gettitle->{'homebranch'});
- $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
+ $getreserv{'homebranch'} = GetBranchName($homebranch);
$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
- if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) {
+ if ( $homebranch ne $holdingbranch ) {
$getreserv{'dotransfer'} = 1;
}
- $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
$getreserv{'borrowername'} = $getborrower->{'surname'};
$getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
$getreserv{'borrowerphone'} = $getborrower->{'phone'};
@@ -150,6 +145,7 @@ foreach my $num (@getreserves) {
}
+$template->param(cancel_result => \@cancel_result) if @cancel_result;
$template->param(
reserveloop => \@reservloop,
reservecount => $reservcount,
@@ -161,3 +157,42 @@ $template->param(
);
output_html_with_http_headers $input, $cookie, $template->output;
+
+exit;
+
+sub cancel {
+ my ($item, $borrowernumber, $fbr, $tbr, $skip_transfers ) = @_;
+
+ my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo;
+
+ return if $transfer && $skip_transfers;
+
+ my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
+
+# if the document is not in his homebranch location and there is not reservation after, we transfer it
+ if ($transfer && !$nextreservinfo) {
+ ModItemTransfer( $item, $fbr, $tbr );
+ }
+ # if we have a result
+ if ($nextreservinfo) {
+ my %res;
+ my $borrowerinfo = GetMemberDetails( $nextreservinfo );
+ my $iteminfo = GetBiblioFromItemNumber($item);
+ if ( $messages->{'transfert'} ) {
+ $res{messagetransfert} = $messages->{'transfert'};
+ $res{branchname} = GetBranchName($messages->{'transfert'});
+ }
+
+ $res{message} = 1;
+ $res{nextreservnumber} = $nextreservinfo;
+ $res{nextreservsurname} = $borrowerinfo->{'surname'};
+ $res{nextreservfirstname} = $borrowerinfo->{'firstname'};
+ $res{nextreservitem} = $item;
+ $res{nextreservtitle} = $iteminfo->{'title'};
+ $res{waiting} = $messages->{'waiting'} ? 1 : 0;
+
+ return \%res;
+ }
+
+ return;
+}
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index 3ce2c18..fa96901 100755
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -308,4 +308,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Display856uAsImage','OFF','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','OFF|Details|Results|Both','Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AlternateHoldingsField','','The MARC field/subfield that contains alternate holdings information for bibs taht do not have items attached (e.g. 852abchi for libraries converting from MARC Magician).',NULL,'free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AlternateHoldingsSeparator','','The string to use to separate subfields in alternate holdings displays.',NULL,'free');
-
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 5c71849..cd72af6 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4209,6 +4209,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.03.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo')");
+ print "Upgrade to $DBversion done (Add sysprefs to control transfer when cancel all waiting holds)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
index 9e74e4a..7cae48f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -290,6 +290,12 @@ Circulation:
yes: Enable
no: "Don't enable"
- "the ability to place holds on multiple biblio from the search results"
+ -
+ - pref: TransferWhenCancelAllWaitingHolds
+ choices:
+ yes: Transfer
+ no: "Don't transfer"
+ - items when cancelling all waiting holds.
Fines Policy:
-
- Calculate fines based on days overdue
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
index e25c491..67a6be1 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
@@ -44,7 +44,9 @@ $.tablesorter.addParser({
View all branches</a></span>
<!-- /TMPL_IF -->
</h2>
- <!-- TMPL_IF NAME="messagetransfert" -->
+ <!-- TMPL_IF NAME="cancel_result" -->
+ <!-- TMPL_LOOP NAME="cancel_result" -->
+ <!-- TMPL_IF NAME="messagetransfert" -->
<div>
<h2>Hold find for (<!-- TMPL_VAR NAME="nextreservtitle" -->), must be transferred</h2>
<p>This hold placed by : <b> <!-- TMPL_VAR NAME="nextreservsurname" --> <!-- TMPL_VAR NAME="nextreservfirstname" --></b> at the library : <b> <!-- TMPL_VAR NAME="branchname" --> </b>, Please transfer this hold.
@@ -53,8 +55,8 @@ $.tablesorter.addParser({
<input type="submit" class="button" />
</form>
</div>
- <!-- /TMPL_IF -->
- <!-- TMPL_IF NAME="waiting" -->
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="waiting" -->
<div id="bloc25">
<h2>This hold is waiting</h2>
<p>This hold (<!-- TMPL_VAR NAME="nextreservtitle" -->) was placed by <b> : <!-- TMPL_VAR NAME="nextreservsurname" --> <!-- TMPL_VAR NAME="nextreservfirstname" --></b>,
@@ -64,8 +66,9 @@ $.tablesorter.addParser({
<input type="submit" />
</form>
</div>
- <!-- /TMPL_IF -->
- <!-- TMPL_UNLESS NAME="message" -->
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ <!-- TMPL_ELSE -->
<div id="resultlist" class="toptabs">
<ul>
<li><a href="/cgi-bin/koha/circ/waitingreserves.pl#holdswaiting"><!-- TMPL_VAR NAME="reservecount" --> Hold(s) waiting</a></li>
@@ -118,6 +121,17 @@ $.tablesorter.addParser({
<div id="holdsover">
<p>Holds listed here have been awaiting pickup for more than <!-- TMPL_VAR NAME="ReservesMaxPickUpDelay" --> days.</p>
<!-- TMPL_IF NAME="overloop" -->
+ <p>
+ <form name="cancelAllReserve" action="waitingreserves.pl" method="post">
+ <input type="hidden" name="cancelall" value="1" />
+ <input type="hidden" name="allbranches" value="<!-- TMPL_VAR NAME="allbranches" -->" />
+ <input type="submit" value="Cancel <!-- TMPL_IF NAME="TransferWhenCancelAllWaitingHolds" -->and Transfer <!-- /TMPL_IF -->All" />
+ </form>
+ <!-- TMPL_UNLESS NAME="TransferWhenCancelAllWaitingHolds" -->
+ Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds sypref)
+ <!-- /TMPL_UNLESS -->
+ </p>
+ <br/>
<table id="holdso">
<thead><tr>
<th>Available since</th>
@@ -153,13 +167,13 @@ $.tablesorter.addParser({
</td>
</tr>
<!-- /TMPL_LOOP --></tbody>
- </table>
+ </table>
<!-- TMPL_ELSE -->
<div class="dialog message">No holds found.</div>
<!-- /TMPL_IF -->
</div>
</div>
- <!-- /TMPL_UNLESS -->
+ <!-- /TMPL_IF -->
</div>
</div>
--
1.6.5
More information about the Koha-patches
mailing list