View | Details | Raw Unified | Return to bug 15244
Collapse All | Expand All

(-)a/C4/Reserves.pm (-15 / +30 lines)
Lines 107-112 BEGIN { Link Here
107
        &GetReserveCount
107
        &GetReserveCount
108
        &GetReserveInfo
108
        &GetReserveInfo
109
        &GetReserveStatus
109
        &GetReserveStatus
110
        &GetAllowedReserves
110
111
111
        &GetOtherReserves
112
        &GetOtherReserves
112
113
Lines 458-475 sub CanItemBeReserved{ Link Here
458
459
459
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
460
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
460
461
461
    # we retrieve user rights on this itemtype and branchcode
462
    my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed
463
                             FROM issuingrules
464
                             WHERE (categorycode in (?,'*') )
465
                             AND (itemtype IN (?,'*'))
466
                             AND (branchcode IN (?,'*'))
467
                             ORDER BY
468
                               categorycode DESC,
469
                               itemtype     DESC,
470
                               branchcode   DESC;"
471
                           );
472
473
    my $querycount ="SELECT
462
    my $querycount ="SELECT
474
                            count(*) as count
463
                            count(*) as count
475
                            FROM reserves
464
                            FROM reserves
Lines 492-501 sub CanItemBeReserved{ Link Here
492
    }
481
    }
493
    
482
    
494
    # we retrieve rights 
483
    # we retrieve rights 
495
    $sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode);
484
    my $rights = GetAllowedReserves($borrower->{'categorycode'}, $item->{'itype'}, $branchcode);
496
    if(my $rights = $sth->fetchrow_hashref()){
485
486
    if( $rights ){
497
        $ruleitemtype    = $rights->{itemtype};
487
        $ruleitemtype    = $rights->{itemtype};
498
        $allowedreserves = $rights->{reservesallowed}; 
488
        $allowedreserves = $rights->{reservesallowed};
499
    }else{
489
    }else{
500
        $ruleitemtype = '*';
490
        $ruleitemtype = '*';
501
    }
491
    }
Lines 581-586 sub CanReserveBeCanceledFromOpac { Link Here
581
571
582
}
572
}
583
573
574
=head2 GetAllowedReserves
575
576
  $number = &GetAllowedReserves($borrowernumber, $itemtype, $branchcode);
577
578
this function returns the rights for a patron on itemtype and branchcode.
579
=cut
580
581
sub GetAllowedReserves {
582
    my ($categorycode, $itemtype, $branchcode) = @_;
583
    my $dbh = C4::Context->dbh;
584
    my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed
585
                             FROM issuingrules
586
                             WHERE (categorycode in (?,'*') )
587
                             AND (itemtype IN (?,'*'))
588
                             AND (branchcode IN (?,'*'))
589
                             ORDER BY
590
                               categorycode DESC,
591
                               itemtype     DESC,
592
                               branchcode   DESC;"
593
                           );
594
    $sth->execute($categorycode, $itemtype, $branchcode);
595
    return $sth->fetchrow_hashref();
596
}
597
598
584
=head2 GetReserveCount
599
=head2 GetReserveCount
585
600
586
  $number = &GetReserveCount($borrowernumber);
601
  $number = &GetReserveCount($borrowernumber);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-12 / +12 lines)
Lines 233-239 function checkMultiHold() { Link Here
233
  [% IF ( messagetransfert ) %]
233
  [% IF ( messagetransfert ) %]
234
		<div class="dialog message">
234
		<div class="dialog message">
235
				<h2>Hold found for ([% nextreservtitle %]), please transfer</h2>
235
				<h2>Hold found for ([% nextreservtitle %]), please transfer</h2>
236
			<p>Hold placed by : <strong> [% nextreservsurname %] [% nextreservfirstname %]</strong> at : <strong> [% branchname %] </strong>, Please transfer this item.
236
                        <p>Hold placed by: <strong> [% nextreservsurname %] [% nextreservfirstname %]</strong> at : <strong> [% branchname %] </strong>. Please transfer this item.
237
			</p>
237
			</p>
238
			<form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
238
			<form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
239
				<input type="submit" class="button" />
239
				<input type="submit" class="button" />
Lines 305-327 function checkMultiHold() { Link Here
305
      <h3>Cannot place hold</h3>
305
      <h3>Cannot place hold</h3>
306
      <ul>
306
      <ul>
307
        [% IF ( exceeded_maxreserves ) %]
307
        [% IF ( exceeded_maxreserves ) %]
308
          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% maxreserves %] total holds.</li>
308
          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of total [% maxreserves %] holds.</li>
309
        [% ELSIF ( alreadypossession ) %]
309
        [% ELSIF ( alreadypossession ) %]
310
          <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possession</strong> of one item</li>
310
          <li><strong>Already in possession: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> has already one item checked out.</li>
311
        [% ELSIF ( alreadyreserved ) %]
311
        [% ELSIF ( alreadyreserved ) %]
312
          <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item </li>
312
          <li><strong>Hold already placed: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> already has a hold on this item.</li>
313
        [% ELSIF ( ageRestricted ) %]
313
        [% ELSIF ( ageRestricted ) %]
314
          <li><strong>Age restricted</strong></li>
314
          <li><strong>Age restricted: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> is not allowed to place this hold due to an age restriction.</li>
315
        [% ELSIF ( none_available ) %]
315
        [% ELSIF ( none_available ) %]
316
          <li> <strong>No items are available</strong> to be placed on hold</li>
316
          <li><strong>No items available: </strong>There are no items to be placed on hold.</li>
317
        [% ELSIF ( maxreserves ) %]
317
        [% ELSIF ( maxreserves ) %]
318
          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> has too many holds.</li>
318
          <li><strong>Too many holds: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> has already too many holds.</li>
319
        [% END %]
319
        [% END %]
320
      </ul>
320
      </ul>
321
    [% ELSE %]
321
    [% ELSE %]
322
        <h3>Cannot place hold on some items</h3>
322
        <h3>Cannot place hold on some items</h3>
323
        [% IF ( exceeded_maxreserves ) %]
323
        [% IF ( exceeded_maxreserves ) %]
324
          <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can place [% new_reserves_allowed %] of the requested [% new_reserves_count %] holds for a maximum of [% maxreserves %] total holds.</li>
324
          <li><strong>Too many holds: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can place [% new_reserves_allowed %] of the requested [% new_reserves_count %] holds for a maximum of [% maxreserves %] total holds.</li>
325
        [% END %]
325
        [% END %]
326
    [% END %]
326
    [% END %]
327
327
Lines 331-349 function checkMultiHold() { Link Here
331
[% IF ( expiry || diffbranch ) %]
331
[% IF ( expiry || diffbranch ) %]
332
<div class="dialog message"><ul>
332
<div class="dialog message"><ul>
333
    [% IF ( expiry ) %]
333
    [% IF ( expiry ) %]
334
    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s <strong>account has expired</strong></li>
334
    <li><strong>Account expired: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s account has expired.</li>
335
    [% END %]
335
    [% END %]
336
336
337
    [% IF restricted %]
337
    [% IF restricted %]
338
    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]#reldebarments">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>has restrictions</strong></li>
338
    <li><strong>Restricted: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]#reldebarments">[% borrowerfirstname %] [% borrowersurname %]</a> has restrictions.</li>
339
    [% END %]
339
    [% END %]
340
340
341
    [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
341
    [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
342
    <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>owes [% amount_outstanding | format('%.2f') %]</strong></li>
342
    <li><strong>Outstanding fines: </strong><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> owes [% amount_outstanding | format('%.2f') %].</li>
343
    [% END %]
343
    [% END %]
344
344
345
    [% IF ( diffbranch ) %]
345
    [% IF ( diffbranch ) %]
346
    <li> <strong>Pickup library is different</strong> than <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s home library ([% borrower_branchname %] / [% borrower_branchcode %] )</li>
346
    <li><strong>Pickup library different: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a>'s home library ([% borrower_branchname %] / [% borrower_branchcode %] ) does not match the pickup library.</li>
347
    [% END %]
347
    [% END %]
348
348
349
</ul></div>
349
</ul></div>
(-)a/reserve/request.pl (-1 / +9 lines)
Lines 82-87 my $messageborrower; Link Here
82
my $warnings;
82
my $warnings;
83
my $messages;
83
my $messages;
84
my $exceeded_maxreserves;
84
my $exceeded_maxreserves;
85
my $maxreserves = C4::Context->preference('maxreserves');
85
86
86
my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
87
my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
87
my $action = $input->param('action');
88
my $action = $input->param('action');
Lines 150-156 if ($borrowernumber_hold && !$action) { Link Here
150
151
151
    my $new_reserves_count = scalar( @biblionumbers );
152
    my $new_reserves_count = scalar( @biblionumbers );
152
153
153
    my $maxreserves = C4::Context->preference('maxreserves');
154
    if ( $maxreserves
154
    if ( $maxreserves
155
        && ( $reserves_count + $new_reserves_count > $maxreserves ) )
155
        && ( $reserves_count + $new_reserves_count > $maxreserves ) )
156
    {
156
    {
Lines 225-230 foreach my $biblionumber (@biblionumbers) { Link Here
225
    }
225
    }
226
    elsif ( $canReserve eq 'tooManyReserves' ) {
226
    elsif ( $canReserve eq 'tooManyReserves' ) {
227
        $exceeded_maxreserves = 1;
227
        $exceeded_maxreserves = 1;
228
229
        my $rights = GetAllowedReserves($borrowerinfo->{'categorycode'}, $dat->{'itype'}, $borrowerinfo->{'branchcode'} );
230
231
        if ( $rights ) {
232
           $maxreserves = $rights->{reservesallowed}
233
               if ( $maxreserves && ( $maxreserves > $rights->{reservesallowed} ) );
234
       }
228
    }
235
    }
229
    elsif ( $canReserve eq 'ageRestricted' ) {
236
    elsif ( $canReserve eq 'ageRestricted' ) {
230
        $template->param( $canReserve => 1 );
237
        $template->param( $canReserve => 1 );
Lines 614-619 foreach my $biblionumber (@biblionumbers) { Link Here
614
$template->param( biblioloop => \@biblioloop );
621
$template->param( biblioloop => \@biblioloop );
615
$template->param( biblionumbers => $biblionumbers );
622
$template->param( biblionumbers => $biblionumbers );
616
$template->param( exceeded_maxreserves => $exceeded_maxreserves );
623
$template->param( exceeded_maxreserves => $exceeded_maxreserves );
624
$template->param( maxreserves => $maxreserves );
617
625
618
if ($multihold) {
626
if ($multihold) {
619
    $template->param( multi_hold => 1 );
627
    $template->param( multi_hold => 1 );
(-)a/t/db_dependent/Reserves.t (-2 / +6 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 73;
20
use Test::More tests => 74;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use MARC::Record;
23
use MARC::Record;
Lines 679-684 MoveReserve( $itemnumber, $borrowernumber ); Link Here
679
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
679
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
680
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
680
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
681
681
682
# Test GetAllowedReserves (Bug 15243)
683
C4::Context->set_preference( 'maxreserves', 100 );
684
my $rights = GetAllowedReserves('PT', 'BK', 'CPL' );
685
is ($rights->{reservesallowed}, 25, 'GetAllowedReserves should be 25 (defined in issuingrules');
686
682
# we reached the finish
687
# we reached the finish
683
$dbh->rollback;
688
$dbh->rollback;
684
689
685
- 

Return to bug 15244