Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'hall/Circulation_Rules' into Bug3507

Conflicts:

	installer/data/mysql/en/mandatory/sysprefs.sql
	installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
  • Loading branch information...
commit b5a1fc6e82e04ce4eda7b3c4f576cd753e150875 2 parents 9c54d01 + e2b1087
J. David Bavousett authored
View
3  C4/Auth.pm
@@ -598,7 +598,8 @@ sub checkauth {
$userid = undef;
$sessionID = undef;
}
- elsif ( $ip ne $ENV{'REMOTE_ADDR'} ) {
+ elsif ( 0 ) {
+# elsif ( $ip ne $ENV{'REMOTE_ADDR'} ) {
# Different ip than originally logged in from
$info{'oldip'} = $ip;
$info{'newip'} = $ENV{'REMOTE_ADDR'};
View
20 C4/Biblio.pm
@@ -111,6 +111,7 @@ BEGIN {
&TransformHtmlToXml
&PrepareItemrecordDisplay
&GetNoZebraIndexes
+ &GetAvailableItemsCount
);
}
@@ -435,6 +436,25 @@ sub DelBiblio {
return;
}
+sub GetAvailableItemsCount {
+ my ( $biblionumber ) = @_;
+ warn "GetAvailableItemsCount( $biblionumber )";
+ my $dbh = C4::Context->dbh;
+
+ my $query = "SELECT COUNT( * ) AS ItemsAvailableCount
+ FROM items
+ LEFT JOIN issues ON issues.itemnumber = items.itemnumber
+ WHERE issues.timestamp IS NULL
+ AND items.biblionumber = ?";
+ my $sth = $dbh->prepare( $query );
+ $sth->execute( $biblionumber );
+
+ my $row = $sth->fetchrow_hashref();
+ my $items_available_count = $row->{'ItemsAvailableCount'};
+
+ return $items_available_count;
+}
+
=head2 LinkBibHeadingsToAuthorities
=over 4
View
10 C4/Circulation.pm
@@ -718,15 +718,21 @@ sub CanBookBeIssued {
C4::Members::GetMemberAccountRecords( $borrower->{'borrowernumber'}, '' && $duedate->output('iso') );
if ( C4::Context->preference("IssuingInProcess") ) {
my $amountlimit = C4::Context->preference("noissuescharge");
+
if ( $amount > $amountlimit && !$inprocess ) {
$issuingimpossible{DEBT} = sprintf( "%.2f", $amount );
}
- elsif ( $amount > 0 && $amount <= $amountlimit && !$inprocess ) {
+ elsif ( $amount > 0 && $amount <= $amountlimit && !$inprocess && !C4::Context->preference('WarnOnlyOnMaxFine') ) {
$needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
}
}
else {
- if ( $amount > 0 ) {
+ my $max_fine = 0;
+ if ( C4::Context->preference('WarnOnlyOnMaxFine') ) {
+ $max_fine = C4::Context->preference("noissuescharge");
+ }
+
+ if ( $amount > $max_fine ) {
$needsconfirmation{DEBT} = sprintf( "%.2f", $amount );
}
}
View
1  C4/Overdues.pm
@@ -267,6 +267,7 @@ sub CalcFine {
} else {
# a zero (or null) chargeperiod means no charge.
}
+ $amount = $data->{'max_fine'} if ( C4::Context->preference('UseGranularMaxFines') && ( $amount > $data->{'max_fine'} ));
$amount = C4::Context->preference('maxFine') if(C4::Context->preference('maxFine') && ( $amount > C4::Context->preference('maxFine')));
$debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $days_minus_grace, $daystocharge);
return ($amount, $data->{'chargename'}, $days_minus_grace, $daystocharge);
View
69 C4/Reserves.pm
@@ -331,30 +331,83 @@ sub GetReservesFromBorrowernumber {
my $data = $sth->fetchall_arrayref({});
return @$data;
}
+
+=item GetReservesByBorrowernumberAndItemtype
+
+ $borrowerreserv = GetReservesByBorrowernumberAndItemtypeOf($borrowernumber, $biblionumber);
+
+ TODO :: Descritpion
+
+=cut
+
+sub GetReservesByBorrowernumberAndItemtypeOf {
+ my ( $borrowernumber, $biblionumber ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth;
+
+ $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+ $sth->execute( $biblionumber );
+ my $res = $sth->fetchrow_hashref();
+ my $itemtype = $res->{'itemtype'};
+
+ $sth = $dbh->prepare("
+ SELECT *
+ FROM reserves, biblioitems
+ WHERE borrowernumber=?
+ AND reserves.biblionumber = biblioitems.biblionumber
+ AND biblioitems.itemtype = ?
+ ORDER BY reservedate
+ ");
+ $sth->execute($borrowernumber,$itemtype);
+ my $data = $sth->fetchall_arrayref({});
+ return @$data;
+}
+
#-------------------------------------------------------------------------------------
=item GetReserveCount
-$number = &GetReserveCount($borrowernumber);
+$number = &GetReserveCount($borrowernumber [, $today [, $shelf_holds_only] ]);
this function returns the number of reservation for a borrower given on input arg.
+If optional $today is true, will return only holds placed today.
+
+If option $shelf_holds_only is true, will only return the count of holds placed on items not checked out.
=cut
sub GetReserveCount {
- my ($borrowernumber) = @_;
+ my ($borrowernumber, $today, $shelf_holds_only ) = @_;
my $dbh = C4::Context->dbh;
- my $query = '
- SELECT COUNT(*) AS counter
- FROM reserves
- WHERE borrowernumber = ?
- ';
+ my $query = "SELECT COUNT(*) AS counter FROM reserves WHERE borrowernumber = ?";
+
+ if ( $today ) {
+ $query .= ' AND DATE( reserves.timestamp ) = DATE( NOW() )';
+ }
+
+ if ( $shelf_holds_only ) {
+ warn "GetReserveCount: Shelf Holds Only";
+ $query = "
+ SELECT COUNT( DISTINCT ( items.biblionumber ) ) AS counter
+ FROM items
+ LEFT JOIN issues ON issues.itemnumber = items.itemnumber
+ LEFT JOIN reserves ON reserves.biblionumber = items.biblionumber
+ WHERE issues.timestamp IS NULL
+ AND reserves.biblionumber IS NOT NULL
+ AND reserves.borrowernumber = ?
+ AND DATE( reserves.timestamp ) = DATE( NOW( ) )
+ ";
+ }
+
my $sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
my $row = $sth->fetchrow_hashref;
- return $row->{counter};
+
+ my $res_count = $row->{counter};
+ warn "GetReservesCount: Found $res_count holds, shelf: $shelf_holds_only";
+ return $res_count;
}
=item GetOtherReserves
View
20 admin/smart-rules.pl
@@ -99,8 +99,8 @@
# save the values entered
elsif ($op eq 'add') {
my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?");
- my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, issuelength, fine, firstremind, chargeperiod) VALUES(?,?,?,?,?,?,?,?)");
- my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, firstremind=?, chargeperiod=?, maxissueqty=?, issuelength=? WHERE branchcode=? AND categorycode=? AND itemtype=?");
+ my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, issuelength, fine, firstremind, chargeperiod, max_fine, max_holds) VALUES(?,?,?,?,?,?,?,?,?,?)");
+ my $sth_update = $dbh->prepare("UPDATE issuingrules SET fine=?, firstremind=?, chargeperiod=?, maxissueqty=?, issuelength=?, max_fine = ?, max_holds = ? WHERE branchcode=? AND categorycode=? AND itemtype=?");
my $br = $branch; # branch
my $bor = $input->param('categorycode'); # borrower category
@@ -109,6 +109,9 @@
my $firstremind = $input->param('firstremind');
my $chargeperiod = $input->param('chargeperiod');
my $maxissueqty = $input->param('maxissueqty');
+ my $max_fine = $input->param('max_fine');
+ my $max_holds = $input->param('max_holds');
+
$maxissueqty =~ s/\s//g;
$maxissueqty = undef if $maxissueqty !~ /^\d+/;
my $issuelength = $input->param('issuelength');
@@ -117,9 +120,9 @@
$sth_search->execute($br,$bor,$cat);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
- $sth_update->execute($fine, $firstremind, $chargeperiod, $maxissueqty,$issuelength,$br,$bor,$cat);
+ $sth_update->execute($fine, $firstremind, $chargeperiod, $maxissueqty, $issuelength, $max_fine, $max_holds, $br, $bor, $cat );
} else {
- $sth_insert->execute($br,$bor,$cat,$maxissueqty,$issuelength,$fine,$firstremind,$chargeperiod);
+ $sth_insert->execute($br, $bor, $cat, $maxissueqty, $issuelength, $fine, $firstremind, $chargeperiod, $max_fine, $max_holds);
}
}
elsif ($op eq "set-branch-defaults") {
@@ -372,6 +375,7 @@
$row->{'humancategorycode'} ||= $row->{'categorycode'};
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
$row->{'fine'} = sprintf('%.2f', $row->{'fine'});
+ $row->{'max_fine'} = sprintf('%.2f', $row->{'max_fine'});
push @row_loop, $row;
}
$sth->finish;
@@ -471,6 +475,14 @@
$template->param(default_rules => ($defaults ? 1 : 0));
+if ( C4::Context->preference('UseGranularMaxFines') ) {
+ $template->param( UseGranularMaxFines => 1 );
+}
+
+if ( C4::Context->preference('UseGranularMaxHolds') ) {
+ $template->param( UseGranularMaxHolds => 1 );
+}
+
$template->param(categoryloop => \@category_loop,
itemtypeloop => \@itemtypes,
rules => \@sorted_row_loop,
View
2  installer/data/mysql/kohastructure.sql
@@ -1154,6 +1154,8 @@ CREATE TABLE `issuingrules` (
`maxissueqty` int(4) default NULL,
`issuelength` int(4) default NULL,
`branchcode` varchar(10) NOT NULL default '',
+ `max_fine` decimal(28,6) default NULL,
+ `max_holds` int(4) default NULL,
PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`),
KEY `categorycode` (`categorycode`),
KEY `itemtype` (`itemtype`)
View
78 koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl
@@ -13,6 +13,36 @@ $(document).ready(function() {
//]]>
</script>
+<!-- TMPL_LOOP NAME="invoice_types_loop" -->
+type_fees['<!-- TMPL_VAR NAME="lib" -->'] = "<!-- TMPL_VAR NAME="authorised_value" -->";
+<!-- /TMPL_LOOP -->
+</script>
+
+<script type="text/javascript">
+ var categorycodes = new Array();
+ categorycodes['*'] = '*';
+ <!-- TMPL_LOOP NAME="categoryloop" -->
+ categorycodes['<!-- TMPL_VAR NAME="description" -->'] = '<!-- TMPL_VAR NAME="categorycode" -->';
+ <!-- /TMPL_LOOP -->
+
+ var itemtypes = new Array();
+ itemtypes['*'] = '*';
+ <!-- TMPL_LOOP NAME="itemtypeloop" -->
+ itemtypes['<!-- TMPL_VAR NAME="description" -->'] = '<!-- TMPL_VAR NAME="itemtype" -->';
+ <!-- /TMPL_LOOP -->
+</script>
+
+<script type="text/javascript">
+function selectValueSet(selectName, Value) {
+ eval('selectObject = document.' + selectName + ';');
+ for(index = 0; index < selectObject.length; index++) {
+ if(selectObject[index].value == Value) {
+ selectObject.selectedIndex = index;
+ }
+ }
+}
+</script>
+
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
@@ -58,7 +88,7 @@ $(document).ready(function() {
</form>
<br />
<br />
- <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
+ <form name="rulesform" id="rulesform" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
<input type="hidden" name="op" value="add" />
<table>
<tr>
@@ -68,7 +98,15 @@ $(document).ready(function() {
<th>Fine Grace Period</th>
<th>Fine Charging Interval</th>
<th>Current Checkouts Allowed</th>
- <th>Loan Period</th><th>&nbsp;</th>
+ <th>Loan Period</th>
+ <!-- TMPL_IF NAME="UseGranularMaxFines" -->
+ <th>Max Accruable Fine Per Issue</th>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="UseGranularMaxHolds" -->
+ <th>Max Number of Holds</th>
+ <!-- /TMPL_IF -->
+ <th>&nbsp;</th>
+ <th>&nbsp;</th>
</tr>
<!-- TMPL_LOOP NAME="rules" -->
<!-- TMPL_UNLESS NAME="__odd__" -->
@@ -98,6 +136,27 @@ $(document).ready(function() {
<!-- /TMPL_IF -->
</td>
<td><!-- TMPL_IF NAME="issuelength" --><!-- TMPL_VAR NAME="issuelength" --> day(s)<!-- /TMPL_IF --></td>
+ <!-- TMPL_IF NAME="UseGranularMaxFines" -->
+ <td><!-- TMPL_IF NAME="max_fine" -->$<!-- TMPL_VAR NAME="max_fine" --><!-- /TMPL_IF --></td>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="UseGranularMaxHolds" -->
+ <td><!-- TMPL_IF NAME="max_holds" --><!-- TMPL_VAR NAME="max_holds" --><!-- /TMPL_IF --></td>
+ <!-- /TMPL_IF -->
+
+ <td>
+ <a onclick="
+ selectValueSet('rulesform.categorycode', categorycodes['<!-- TMPL_VAR NAME="humancategorycode" -->'] );
+ selectValueSet('rulesform.itemtype', itemtypes['<!-- TMPL_VAR NAME="humanitemtype" -->'] );
+ document.rulesform.fine.value='<!-- TMPL_VAR NAME="fine" -->';
+ document.rulesform.firstremind.value='<!-- TMPL_VAR NAME="firstremind" -->';
+ document.rulesform.chargeperiod.value='<!-- TMPL_VAR NAME="chargeperiod" -->';
+ document.rulesform.maxissueqty.value='<!-- TMPL_VAR NAME="maxissueqty" -->';
+ document.rulesform.issuelength.value='<!-- TMPL_VAR NAME="issuelength" -->';
+ <!-- TMPL_IF NAME="UseGranularMaxFines" -->document.rulesform.max_fine.value='<!-- TMPL_VAR NAME="max_fine" -->';<!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="UseGranularMaxHolds" -->document.rulesform.max_holds.value='<!-- TMPL_VAR NAME="max_holds" -->';<!-- /TMPL_IF -->
+ document.rulesform.rulesformSubmit.value = 'Update';
+ ">Edit</a>
+ </td>
<td>
<a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=<!-- TMPL_VAR NAME="itemtype" -->&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
</td>
@@ -125,7 +184,20 @@ $(document).ready(function() {
<td><input name="chargeperiod" size="2" /> day(s)</td>
<td><input name="maxissueqty" size="3" /></td>
<td><input name="issuelength" size="3" /> day(s)</td>
- <td><input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/><input type="submit" value="Add" class="submit" /></td>
+
+ <!-- TMPL_IF NAME="UseGranularMaxFines" -->
+ <td>$<input name="max_fine" size="4" /></td>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="UseGranularMaxHolds" -->
+ <td><input name="max_holds" size="3" /></td>
+ <!-- /TMPL_IF -->
+ <td>
+ <input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/>
+ <input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/>
+ <input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/>
+ <input name="rulesformSubmit" id="rulesformSubmit" type="submit" value="Add" class="submit" />
+ </td>
+ <td>&nbsp;</td>
</tr>
</table>
</form>
View
11 koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -246,6 +246,17 @@ function refocus(calendar) {
<form method="post" action="/cgi-bin/koha/circ/circulation.pl">
+<!-- TMPL_IF NAME="DisableHoldsIssueOverrideUnlessAuthorised" -->
+ <p>
+ <label><strong>Superlibrarian Authorization Required</strong></label>
+ </p><p>
+ <label for="auth_username">Username:</label>
+ <input type="text" id="auth_username" name="auth_username" />
+ <label for="auth_password">Password:</label>
+ <input type="password" id="auth_password" name="auth_password" />
+ </p>
+<!-- /TMPL_IF -->
+
<!-- TMPL_IF NAME="RESERVED" -->
<p>
<input type="checkbox" id="cancelreserve" name="cancelreserve" value="1" />
View
6 koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl
@@ -105,7 +105,7 @@ function checkMultiHold() {
return confirm(msg);
});
$("input.warning").click(function() {
- return confirm( _( 'None of these items can normally be put on hold for this patron.' ) + "\n\n" + _( 'Place hold?' ) );
+ return confirm( _( 'Patron has exceeded hold limits.' ) + "\n\n" + _( 'Place hold?' ) );
});
$("#requestany").click(function() {
if(this.checked){
@@ -197,13 +197,15 @@ function checkMultiHold() {
<!-- TMPL_IF NAME="warnings" -->
<div class="dialog alert">
-
<!-- TMPL_UNLESS NAME="multi_hold" -->
<h3>Cannot Place Hold</h3>
<ul>
<!-- TMPL_IF NAME="maxreserves" -->
<li><strong>Too Many Holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --> </a> has too many holds.</li>
<!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="max_shelf_holds_per_day" -->
+ <li><strong>Too Many Shelf Holds Today: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --> </a> has placed too many holds in one day for bibs with at least one available item.</li>
+ <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="alreadyreserved" -->
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --></a> <strong>already has a hold</strong> on this item </li>
<!-- /TMPL_IF -->
View
13 koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
@@ -162,6 +162,7 @@
<div id="holds" class="container">
<!-- TMPL_IF NAME="message" -->
+
<!-- TMPL_IF NAME="GNA" -->
<div class="dialog alert">
<strong>Sorry</strong>, you cannot place holds because the library doesn't have up-to-date <a href="/cgi-bin/koha/opac-userdetails.pl">contact information</a> on file.
@@ -192,7 +193,11 @@
<div class="dialog alert">Sorry, you cannot place more than <!-- TMPL_VAR NAME="too_many_reserves" --> holds.
</div>
<!-- /TMPL_IF -->
- <!-- TMPL_IF NAME="bad_biblionumber" -->
+ <!-- TMPL_IF NAME="too_many_shelf_holds_per_day" -->
+ <div class="dialog alert">Sorry, you cannot place more than <!-- TMPL_VAR NAME="too_many_shelf_holds_per_day" --> holds on available items in a single day.
+ </div>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="bad_biblionumber" -->
<div class="dialog alert">ERROR: No biblio record found for biblionumber <!-- TMPL_VAR NAME="bad_biblionumber" -->.</div>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="no_items_selected" -->
@@ -227,6 +232,7 @@
<form action="/cgi-bin/koha/opac-reserve.pl" method="post">
<input type="hidden" name="place_reserve" value="1"/>
+
<!-- These values are set dynamically by js -->
<input type="hidden" name="biblionumbers" id="biblionumbers"/>
<input type="hidden" name="selecteditems" id="selections"/>
@@ -398,6 +404,11 @@
</select>
</td>
<!-- /TMPL_UNLESS -->
+
+ <!-- TMPL_IF NAME="singleBranchMode" -->
+ <input type="hidden" name="branch" id="branch_<!-- TMPL_VAR NAME="biblionumber" -->" value="<!-- TMPL_VAR NAME="branch" -->" />
+ <!-- /TMPL_IF -->
+
</tr>
<!-- TMPL_IF NAME="OPACItemHolds" -->
View
46 opac/opac-reserve.pl
@@ -54,6 +54,10 @@ ($$$)
# get borrower information ....
my ( $borr ) = GetMemberDetails( $borrowernumber );
+if ( C4::Context->preference('singleBranchMode') ) {
+ $template->param( branch => $borr->{'branchcode'} );
+}
+
# get branches and itemtypes
my $branches = GetBranches();
my $itemTypes = GetItemTypes();
@@ -262,11 +266,51 @@ ($$$)
my @reserves = GetReservesFromBorrowernumber( $borrowernumber );
$template->param( RESERVES => \@reserves );
-if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
+if ( C4::Context->preference('UseGranularMaxHolds') ) {
+ foreach my $biblionumber (@biblionumbers) {
+ ## Since we can't limit by branchcode in the opac, we use the * rule for branch
+ ## Get the reserves for the borrower, limited by itemtype
+ ## If the borrower is over the limit for their borrower.categorycode and the given itemtype
+ ## Disable ability to make a reserve
+ my $itemtype;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+ $sth->execute($biblionumber);
+ ($itemtype) = $sth->fetchrow_array;
+
+ my @reservesByItemtype = C4::Reserves::GetReservesByBorrowernumberAndItemtypeOf($borrowernumber, $biblionumber);
+ my $res_count = scalar( @reservesByItemtype );
+
+ my $irule = GetIssuingRule($borr->{'categorycode'}, $itemtype, $borr->{'branchcode'} );
+
+ if ( !$irule->{'max_holds'} ) {
+ $template->param( message => 1, none_available => 1 );
+ $noreserves = 1;
+ } elsif ( $res_count >= $irule->{'max_holds'} ) {
+ $template->param( message => 1, too_many_reserves => $res_count );
+ $noreserves = 1;
+ $template->param( too_many_reserves => scalar(@reserves));
+ }
+ }
+} elsif ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
$template->param( message => 1 );
$noreserves = 1;
$template->param( too_many_reserves => scalar(@reserves));
}
+
+if ( C4::Context->preference('MaxShelfHoldsPerDay') ) {
+ foreach my $biblionumber (@biblionumbers) {
+ if ( GetAvailableItemsCount( $biblionumber ) ) {
+ my $reserves_today = GetReserveCount( $borrowernumber, my $today = 1, my $shelf_holds_only = 1 );
+ if ( $reserves_today >= C4::Context->preference('MaxShelfHoldsPerDay') ) {
+ $noreserves = 1;
+ $template->param( message => 1 );
+ $template->param( too_many_shelf_holds_per_day => C4::Context->preference('MaxShelfHoldsPerDay') );
+ }
+ }
+ }
+}
+
foreach my $res (@reserves) {
foreach my $biblionumber (@biblionumbers) {
if ( $res->{'biblionumber'} == $biblionumber && $res->{'borrowernumber'} == $borrowernumber) {
View
43 reserve/request.pl
@@ -121,13 +121,15 @@ =head1 request.pl
# we check the reserves of the borrower, and if he can reserv a document
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
- my $number_reserves =
- GetReserveCount( $borrowerinfo->{'borrowernumber'} );
-
+ my $number_reserves = GetReserveCount( $borrowerinfo->{'borrowernumber'} );
+ if ( ! C4::Context->preference('UseGranularMaxHolds') ) {
if ( $number_reserves > C4::Context->preference('maxreserves') ) {
- $warnings = 1;
- $maxreserves = 1;
+ $warnings = 1;
+ $maxreserves = 1;
}
+ }
+
+
# we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
my $expiry_date = $borrowerinfo->{dateexpiry};
@@ -214,6 +216,37 @@ =head1 request.pl
my @biblioloop = ();
foreach my $biblionumber (@biblionumbers) {
+ my $number_reserves = GetReserveCount( $borrowerinfo->{'borrowernumber'} );
+ if ( C4::Context->preference('UseGranularMaxHolds') ) {
+ my $itemtype;
+ $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+ $sth->execute($biblionumber);
+ ($itemtype) = $sth->fetchrow_array;
+
+ my $irule = GetIssuingRule($borrowerinfo->{'categorycode'}, $itemtype, C4::Context->userenv->{'branch'} );
+ my $max_holds = $irule->{'max_holds'};
+ if ( $max_holds && $number_reserves >= $max_holds ) {
+ $template->param( warnings => 1 );
+ $template->param( maxreserves => 1);
+ $template->param( override_required => 1 );
+ }
+ }
+
+ if ( C4::Context->preference('MaxShelfHoldsPerDay') ) {
+ if ( GetAvailableItemsCount( $biblionumber ) ) {
+ my $shelf_holds_today = GetReserveCount( $borrowerinfo->{'borrowernumber'}, my $today = 1, my $shelf_holds_only = 1 );
+ my $max_shelf_holds_per_day = C4::Context->preference('MaxShelfHoldsPerDay');
+
+ if ( $shelf_holds_today >= $max_shelf_holds_per_day ) {
+ $warnings = 1;
+ $template->param(
+ override_required => 1,
+ max_shelf_holds_per_day => $max_shelf_holds_per_day
+ );
+ }
+ }
+ }
+
my %biblioloopiter = ();
my $dat = GetBiblioData($biblionumber);
Please sign in to comment.
Something went wrong with that request. Please try again.