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

(-)a/C4/Circulation.pm (-3 / +43 lines)
Lines 75-80 BEGIN { Link Here
75
	push @EXPORT, qw(
75
	push @EXPORT, qw(
76
		&CanBookBeIssued
76
		&CanBookBeIssued
77
		&CanBookBeRenewed
77
		&CanBookBeRenewed
78
        &HasWhateverRenewalToBeBlocked
78
		&AddIssue
79
		&AddIssue
79
		&AddRenewal
80
		&AddRenewal
80
		&GetRenewCount
81
		&GetRenewCount
Lines 2458-2464 already renewed the loan. $error will contain the reason the renewal can not pro Link Here
2458
sub CanBookBeRenewed {
2459
sub CanBookBeRenewed {
2459
2460
2460
    # check renewal status
2461
    # check renewal status
2461
    my ( $borrowernumber, $itemnumber, $override_limit ) = @_;
2462
    my ( $borrowernumber, $itemnumber, $override_limit, $overduesblockrenew ) = @_;
2462
    my $dbh       = C4::Context->dbh;
2463
    my $dbh       = C4::Context->dbh;
2463
    my $renews    = 1;
2464
    my $renews    = 1;
2464
    my $renewokay = 0;
2465
    my $renewokay = 0;
Lines 2467-2479 sub CanBookBeRenewed { Link Here
2467
    my $borrower    = C4::Members::GetMemberDetails( $borrowernumber, 0 )   or return;
2468
    my $borrower    = C4::Members::GetMemberDetails( $borrowernumber, 0 )   or return;
2468
    my $item        = GetItem($itemnumber)                                  or return;
2469
    my $item        = GetItem($itemnumber)                                  or return;
2469
    my $itemissue   = GetItemIssue($itemnumber)                             or return;
2470
    my $itemissue   = GetItemIssue($itemnumber)                             or return;
2471
    my $overdue = $itemissue->{'overdue'};
2470
2472
2471
    my $branchcode  = _GetCircControlBranch($item, $borrower);
2473
    my $branchcode  = _GetCircControlBranch($item, $borrower);
2472
2474
2473
    my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
2475
    my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
2474
2476
2475
    if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) {
2477
    if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) {
2476
        $renewokay = 1;
2478
            $renewokay =  ( $overduesblockrenew eq 'blockitem' and $overdue and !$override_limit ) ? 0 : 1;
2479
            $error = 'overdue' unless $renewokay;
2477
    } else {
2480
    } else {
2478
        $error = "too_many";
2481
        $error = "too_many";
2479
    }
2482
    }
Lines 2483-2492 sub CanBookBeRenewed { Link Here
2483
        $renewokay = 0;
2486
        $renewokay = 0;
2484
        $error = "on_reserve";
2487
        $error = "on_reserve";
2485
    }
2488
    }
2486
2487
    return ( $renewokay, $error );
2489
    return ( $renewokay, $error );
2488
}
2490
}
2489
2491
2492
=head2 HasWhateverRenewalToBeBlocked
2493
2494
  ($blockallitems, $reasonwhy, $overduesblockrenew) = &HasWhateverRenewalToBeBlocked($borrowernumber, $override_limit);
2495
2496
Check whether whatever renewal must be blocked in the case patron is restricted or any of his documents are late.
2497
2498
C<$blockallitems> if true, causes the renewal to be blocked for every items.
2499
2500
C<$reasonwhy> if $blockallitems is true, will be an information displayed in checkouts table on patron page.
2501
2502
C<$overduesblockrenew> is the value of the syspref OverduesBlockRenew.
2503
2504
=cut
2505
2506
sub HasWhateverRenewalToBeBlocked {
2507
    my $borrowernumber = shift;
2508
    my $override_limit = shift;
2509
    # get the option selected for the syspref OverduesBlockRenew
2510
    my $overduesblockrenew = C4::Context->preference('OverduesBlockRenew');
2511
    my $blockallitems;
2512
    my $reasonwhy;
2513
    unless ( $override_limit ) {
2514
        # check if patron is restricted or if any of his documents are late
2515
        my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber);
2516
        if ($memberblocked == 1) {
2517
            $reasonwhy = 'restriction';
2518
            $blockallitems = 1;
2519
        } elsif ($memberblocked == -1)  {
2520
            # check if renewal must be blocked for all the patron's documents on loan
2521
            if ( $overduesblockrenew eq 'blockall' ) {
2522
                $blockallitems = 1;
2523
                $reasonwhy = 'overdue';
2524
            }
2525
        }
2526
    }
2527
    return($blockallitems,$reasonwhy,$overduesblockrenew);
2528
}
2529
2490
=head2 AddRenewal
2530
=head2 AddRenewal
2491
2531
2492
  &AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate]);
2532
  &AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate]);
(-)a/C4/ILSDI/Services.pm (-3 / +2 lines)
Lines 561-571 sub RenewLoan { Link Here
561
    return { code => 'RecordNotFound' } unless $$item{itemnumber};
561
    return { code => 'RecordNotFound' } unless $$item{itemnumber};
562
562
563
    # Add renewal if possible
563
    # Add renewal if possible
564
    my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
564
    my ($blockallitems,$reasonwhy,$overduesblockrenew) = HasAnyRenewalToBeBlocked($borrowernumber,undef);
565
    my @renewal = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed( $borrowernumber, $itemnumber, undef, $overduesblockrenew );
565
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
566
    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
566
567
567
    my $issue = GetItemIssue($itemnumber);
568
569
    # Hashref building
568
    # Hashref building
570
    my $out;
569
    my $out;
571
    $out->{'renewals'} = $issue->{'renewals'};
570
    $out->{'renewals'} = $issue->{'renewals'};
(-)a/circ/circulation.pl (-3 / +5 lines)
Lines 435-440 my $displayrelissues; Link Here
435
435
436
our $totalprice = 0;
436
our $totalprice = 0;
437
437
438
my ($blockallitems, $reasonwhy, $overduesblockrenew) = HasWhateverRenewalToBeBlocked($borrowernumber, undef);
439
438
sub build_issue_data {
440
sub build_issue_data {
439
    my $issueslist = shift;
441
    my $issueslist = shift;
440
    my $relatives = shift;
442
    my $relatives = shift;
Lines 450-459 sub build_issue_data { Link Here
450
            $it->{'itemnumber'}, $it->{'borrowernumber'}
452
            $it->{'itemnumber'}, $it->{'borrowernumber'}
451
        );
453
        );
452
        $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
454
        $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
453
        my ($can_renew, $can_renew_error) = CanBookBeRenewed( 
455
        my ($can_renew, $can_renew_error) = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed(
454
            $it->{'borrowernumber'},$it->{'itemnumber'}
456
        $it->{'borrowernumber'},$it->{'itemnumber'}, undef, $overduesblockrenew);
455
        );
456
        $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
457
        $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
458
        $it->{'blockrenewal'} = ($can_renew_error=~/overdue|restriction/) ? 1 : 0;
457
        my $restype = C4::Reserves::GetReserveStatus( $it->{'itemnumber'} );
459
        my $restype = C4::Reserves::GetReserveStatus( $it->{'itemnumber'} );
458
        $it->{'can_renew'} = $can_renew;
460
        $it->{'can_renew'} = $can_renew;
459
        $it->{'can_confirm'} = !$can_renew && !$restype;
461
        $it->{'can_confirm'} = !$can_renew && !$restype;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 427-429 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
427
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverduesBlockRenew','allow','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|blockall','Choice');
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 6983-6988 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
6983
    SetVersion($DBversion);
6983
    SetVersion($DBversion);
6984
}
6984
}
6985
6985
6986
$DBversion = "3.13.00.XXX";
6987
if ( CheckVersion($DBversion) ) {
6988
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverduesBlockRenew','allow','If any of a patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|blockall','Choice')");
6989
    print "Upgrade to $DBversion done (Add system preference OverduesBlockRenew)\n";
6990
    SetVersion($DBversion);
6991
}
6992
6986
6993
6987
=head1 FUNCTIONS
6994
=head1 FUNCTIONS
6988
6995
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+8 lines)
Lines 298-303 Circulation: Link Here
298
                  confirmation: Ask for confirmation
298
                  confirmation: Ask for confirmation
299
            - when checking out to a borrower that has overdues outstanding	    
299
            - when checking out to a borrower that has overdues outstanding	    
300
        -
300
        -
301
            - If any of a patron's checked out items are late,
302
            - pref: OverduesBlockRenew
303
              type: choice
304
              choices:
305
                  allow: allow renewing of items.
306
                  blockall: block renewing for all items.
307
                  blockitem: block renewing only for overdue items.
308
        -
301
            - On checkin route the returned item to
309
            - On checkin route the returned item to
302
            - pref: HomeOrHoldingBranchReturn
310
            - pref: HomeOrHoldingBranchReturn
303
              type: choice
311
              type: choice
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-14 / +39 lines)
Lines 20-29 Link Here
20
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
20
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
21
<script type="text/javascript">
21
<script type="text/javascript">
22
//<![CDATA[
22
//<![CDATA[
23
23
[% IF ( UseTablesortForCirc && dateformat == 'metric' ) %]dt_add_type_uk_date();[% END %]
24
[% IF ( UseTablesortForCirc && dateformat == 'metric' ) %]dt_add_type_uk_date();[% END %]
24
[% IF ( borrowernumber ) %]if($.cookie("holdfor") != [% borrowernumber %]){ $.cookie("holdfor",null, { path: "/", expires: 0 }); }[% ELSE %]$.cookie("holdfor",null, { path: "/", expires: 0 });[% END %]
25
[% IF ( borrowernumber ) %]if($.cookie("holdfor") != [% borrowernumber %]){ $.cookie("holdfor",null, { path: "/", expires: 0 }); }[% ELSE %]$.cookie("holdfor",null, { path: "/", expires: 0 });[% END %]
25
[% UNLESS ( borrowernumber ) %][% UNLESS ( CGIselectborrower ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
26
[% UNLESS ( borrowernumber ) %][% UNLESS ( CGIselectborrower ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
26
	 $(document).ready(function() {
27
	 $(document).ready(function() {
28
        $(function(){ hiderenew() });
27
        $('#patronlists').tabs([% IF ( UseTablesortForCirc ) %]{
29
        $('#patronlists').tabs([% IF ( UseTablesortForCirc ) %]{
28
            // Correct table sizing for tables hidden in tabs
30
            // Correct table sizing for tables hidden in tabs
29
            // http://www.datatables.net/examples/api/tabs_and_scrolling.html
31
            // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 67-74 Link Here
67
        $( '#override_limit' ).click( function () {
69
        $( '#override_limit' ).click( function () {
68
            if ( this.checked ) {
70
            if ( this.checked ) {
69
                $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
71
                $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
72
                $("input[name='renew_checked']").val('Renew or Return checked items');
73
                $("input[name='renew_all']").css('display','inline');
74
70
            } else {
75
            } else {
71
                $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
76
                $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
77
                hiderenew();
72
            }
78
            }
73
        } ).attr( 'checked', false );
79
        } ).attr( 'checked', false );
74
        [% END %][% IF ( CircAutoPrintQuickSlip ) %]
80
        [% END %][% IF ( CircAutoPrintQuickSlip ) %]
Lines 78-84 Link Here
78
            return printx_window('qslip'); }
84
            return printx_window('qslip'); }
79
        });[% END %]
85
        });[% END %]
80
86
81
82
var allcheckboxes = $(".checkboxed");
87
var allcheckboxes = $(".checkboxed");
83
	$("#renew_all").click(function(){
88
	$("#renew_all").click(function(){
84
		$(allcheckboxes).checkCheckboxes(":input[name*=items]"); 
89
		$(allcheckboxes).checkCheckboxes(":input[name*=items]"); 
Lines 235-240 function validate1(date) { Link Here
235
        return false;
240
        return false;
236
     }
241
     }
237
};
242
};
243
244
function hiderenew () {
245
    var valid=false;
246
    $("input[name^=items]").parent().each(function(){
247
        if($(this).css('display') !='none'){
248
            valid = true;
249
            return;
250
        }
251
    });
252
    if(!valid){
253
        $("input[name='renew_checked']").val('Return checked items');
254
        $("input[name='renew_all']").css('display','none');
255
    }
256
    return;
257
};
258
238
//]]>
259
//]]>
239
</script>
260
</script>
240
</head>
261
</head>
Lines 841-855 No patron matched <span class="ex">[% message %]</span> Link Here
841
        <td><span style="padding: 0 1em;">[% IF ( todayissue.renewals ) %][% todayissue.renewals %][% ELSE %]0[% END %]</span>
862
        <td><span style="padding: 0 1em;">[% IF ( todayissue.renewals ) %][% todayissue.renewals %][% ELSE %]0[% END %]</span>
842
        [% IF ( todayissue.can_renew ) %]
863
        [% IF ( todayissue.can_renew ) %]
843
        <input type="checkbox" name="all_items[]" value="[% todayissue.itemnumber %]" checked="checked" style="display: none;" />
864
        <input type="checkbox" name="all_items[]" value="[% todayissue.itemnumber %]" checked="checked" style="display: none;" />
844
        [% IF ( todayissue.od ) %]
865
        [% IF ( todayissue.od) %]
845
            <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" checked="checked" />
866
            <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" checked="checked" />
846
        [% ELSE %]
847
            <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" />
848
        [% END %]
867
        [% END %]
849
        [% ELSE %]
868
        [% ELSE %]
850
            [% IF ( todayissue.can_confirm ) %]<span class="renewals-allowed" style="display: none">
869
            [% IF ( todayissue.can_confirm ) %]<span class="renewals-allowed" style="display: none">
851
                <input type="checkbox" name="all_items[]" value="[% todayissue.itemnumber %]" checked="checked" style="display: none;" />
870
                <input type="checkbox" name="all_items[]" value="[% todayissue.itemnumber %]" checked="checked" style="display: none;" />
852
                [% IF ( todayissue.od ) %]
871
                [% IF ( todayissue.od and !todayissue.blockrenewal ) %]
853
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" checked="checked" />
872
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" checked="checked" />
854
                [% ELSE %]
873
                [% ELSE %]
855
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" />
874
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" />
Lines 860-868 No patron matched <span class="ex">[% message %]</span> Link Here
860
		[% IF ( todayissue.renew_error_on_reserve ) %]
879
		[% IF ( todayissue.renew_error_on_reserve ) %]
861
            <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% todayissue.biblionumber %]">On hold</a>
880
            <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% todayissue.biblionumber %]">On hold</a>
862
		[% END %]
881
		[% END %]
863
                [% IF ( todayissue.renew_error_too_many ) %]
882
            [% IF ( todayissue.renew_error_restriction ) %]
864
            Not renewable
883
                Renewal not allowed (restriction)
865
                [% END %]
884
            [% ELSIF ( todayissue.renew_error_overdue ) %]
885
                Renewal not allowed (overdue)
886
            [% ELSIF ( todayissue.renew_error_too_many ) %]
887
                Not renewable
888
            [% END %]
866
            [% IF ( todayissue.can_confirm ) %]
889
            [% IF ( todayissue.can_confirm ) %]
867
                </span>
890
                </span>
868
            [% END %]
891
            [% END %]
Lines 932-944 No patron matched <span class="ex">[% message %]</span> Link Here
932
        <input type="checkbox" name="all_items[]" value="[% previssue.itemnumber %]" checked="checked" style="display: none;" />
955
        <input type="checkbox" name="all_items[]" value="[% previssue.itemnumber %]" checked="checked" style="display: none;" />
933
        [% IF ( previssue.od ) %]
956
        [% IF ( previssue.od ) %]
934
            <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" checked="checked" />
957
            <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" checked="checked" />
935
        [% ELSE %]
936
            <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" />
937
        [% END %]
958
        [% END %]
938
        [% ELSE %]
959
        [% ELSE %]
939
            [% IF ( previssue.can_confirm ) %]<span class="renewals-allowed" style="display: none">
960
            [% IF ( previssue.can_confirm ) %]<span class="renewals-allowed" style="display: none">
940
                <input type="checkbox" name="all_items[]" value="[% previssue.itemnumber %]" checked="checked" style="display: none;" />
961
                <input type="checkbox" name="all_items[]" value="[% previssue.itemnumber %]" checked="checked" style="display: none;" />
941
                [% IF ( previssue.od ) %]
962
                [% IF ( previssue.od and !previssue.blockrenewal ) %]
942
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" checked="checked" />
963
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" checked="checked" />
943
                [% ELSE %]
964
                [% ELSE %]
944
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" />
965
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" />
Lines 949-957 No patron matched <span class="ex">[% message %]</span> Link Here
949
		[% IF ( previssue.renew_error_on_reserve ) %]
970
		[% IF ( previssue.renew_error_on_reserve ) %]
950
            <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% previssue.biblionumber %]">On hold</a>
971
            <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% previssue.biblionumber %]">On hold</a>
951
		[% END %]
972
		[% END %]
952
                [% IF ( previssue.renew_error_too_many ) %]
973
            [% IF ( previssue.renew_error_restriction ) %]
953
            Not renewable
974
                Renewal not allowed (restriction)
954
                [% END %]
975
            [% ELSIF ( previssue.renew_error_overdue ) %]
976
                Renewal not allowed (overdue)
977
            [% ELSIF ( previssue.renew_error_too_many ) %]
978
                Not renewable
979
            [% END %]
955
            [% IF ( previssue.can_confirm ) %]
980
            [% IF ( previssue.can_confirm ) %]
956
                </span>
981
                </span>
957
            [% END %]
982
            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-3 / +27 lines)
Lines 18-23 Link Here
18
<script type="text/JavaScript">
18
<script type="text/JavaScript">
19
//<![CDATA[
19
//<![CDATA[
20
$(document).ready(function() {
20
$(document).ready(function() {
21
    $(function(){ hiderenew() });
21
    $('#finesholdsissues').tabs({
22
    $('#finesholdsissues').tabs({
22
        // Correct table sizing for tables hidden in tabs
23
        // Correct table sizing for tables hidden in tabs
23
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
24
        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
Lines 85-92 $(document).ready(function() { Link Here
85
    $( '#override_limit' ).click( function () {
86
    $( '#override_limit' ).click( function () {
86
        if ( this.checked ) {
87
        if ( this.checked ) {
87
           $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
88
           $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
89
           $("input[name='renew_checked']").val('Renew or Return checked items');
90
           $("input[name='renew_all']").css('display','inline');
88
        } else {
91
        } else {
89
           $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
92
           $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
93
           hiderenew();
90
        }
94
        }
91
    } ).attr( 'checked', false );
95
    } ).attr( 'checked', false );
92
    [% END %]
96
    [% END %]
Lines 141-146 function validate1(date) { Link Here
141
        return false;
145
        return false;
142
     }
146
     }
143
};
147
};
148
149
function hiderenew () {
150
    var valid=false;
151
    $("input[name^=items]").parent().each(function(){
152
        if($(this).css('display') !='none'){
153
            valid = true;
154
            return;
155
        }
156
    });
157
    if(!valid){
158
        $("input[name='renew_checked']").val('Return checked items');
159
        $("input[name='renew_all']").css('display','none');
160
    }
161
    return;
162
};
163
144
//]]>
164
//]]>
145
</script>
165
</script>
146
166
Lines 496-502 function validate1(date) { Link Here
496
            [% IF ( issueloo.norenew ) %]
516
            [% IF ( issueloo.norenew ) %]
497
                [% IF ( issueloo.can_confirm ) %]<span class="renewals-allowed" style="display: none">
517
                [% IF ( issueloo.can_confirm ) %]<span class="renewals-allowed" style="display: none">
498
                    <input type="checkbox" name="all_items[]" value="[% issueloo.itemnumber %]" checked="checked" style="display: none;" />
518
                    <input type="checkbox" name="all_items[]" value="[% issueloo.itemnumber %]" checked="checked" style="display: none;" />
499
                    [% IF ( issueloo.od ) %]
519
                    [% IF ( issueloo.od  and !issueloo.blockrenewal ) %]
500
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" checked="checked" />
520
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" checked="checked" />
501
                    [% ELSE %]
521
                    [% ELSE %]
502
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" />
522
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" />
Lines 507-515 function validate1(date) { Link Here
507
                [% IF ( issueloo.norenew_reason_on_reserve ) %]
527
                [% IF ( issueloo.norenew_reason_on_reserve ) %]
508
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a>
528
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a>
509
                [% END %]
529
                [% END %]
510
                    [% IF ( issueloo.norenew_reason_too_many ) %]
530
                [% IF ( issueloo.norenew_reason_restriction ) %]
531
                    Renewal not allowed (restriction)
532
                [% ELSIF ( issueloo.norenew_reason_overdue ) %]
533
                    Renewal not allowed (overdue)
534
                [% ELSIF ( issueloo.norenew_reason_too_many ) %]
511
                        Not renewable
535
                        Not renewable
512
                    [% END %]
536
                [% END %]
513
                [% IF ( issueloo.can_confirm ) %]
537
                [% IF ( issueloo.can_confirm ) %]
514
                    </span>
538
                    </span>
515
                [% END %]
539
                [% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt (-1 / +5 lines)
Lines 195-202 $.tablesorter.addParser({ Link Here
195
                [% IF ( OpacRenewalAllowed ) %]
195
                [% IF ( OpacRenewalAllowed ) %]
196
                    <td class="renew">[% IF ( ISSUE.status ) %][% IF ( canrenew ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
196
                    <td class="renew">[% IF ( ISSUE.status ) %][% IF ( canrenew ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
197
                        [% ELSE %]
197
                        [% ELSE %]
198
                        [% IF ( ISSUE.norenew_overdue ) %]
199
                           Renewal not allowed <span class="renewals">(overdue on a document)</span>
200
                        [% ELSE %]
198
                        Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %] 
201
                        Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %] 
199
                        [% END %]</td>
202
                        [% END %][% END %]</td>
200
                [% END %]
203
                [% END %]
201
[% IF ( OPACFinesTab ) %]
204
[% IF ( OPACFinesTab ) %]
202
                <td class="fines">[% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]</td>
205
                <td class="fines">[% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]</td>
Lines 339-344 $.tablesorter.addParser({ Link Here
339
[% ELSIF ( OVERDUE.status ) %]
342
[% ELSIF ( OVERDUE.status ) %]
340
[% IF ( canrenew ) %]<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber %]&amp;bornum=[% OVERDUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining)</span>
343
[% IF ( canrenew ) %]<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber %]&amp;bornum=[% OVERDUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining)</span>
341
[% ELSIF ( OVERDUE.onreserve ) %]On hold
344
[% ELSIF ( OVERDUE.onreserve ) %]On hold
345
[% ELSIF ( OVERDUE.norenew_overdue ) %]Renewal not allowed<span class="renewals">(overdue on a document)</span>
342
[% ELSE %]No renewals left
346
[% ELSE %]No renewals left
343
[% END %]
347
[% END %]
344
</td>[% END %]
348
</td>[% END %]
(-)a/members/moremember.pl (-3 / +4 lines)
Lines 251-256 my @borrowers_with_issues; Link Here
251
my $overdues_exist = 0;
251
my $overdues_exist = 0;
252
my $totalprice = 0;
252
my $totalprice = 0;
253
253
254
my ($blockallitems, $reasonwhy, $overduesblockrenew) = HasWhateverRenewalToBeBlocked($borrowernumber, $override_limit);
255
254
my @issuedata = build_issue_data($issue);
256
my @issuedata = build_issue_data($issue);
255
my @relissuedata = build_issue_data($relissue);
257
my @relissuedata = build_issue_data($relissue);
256
258
Lines 502-513 sub build_issue_data { Link Here
502
504
503
        $row{'charge'} = sprintf( "%.2f", $charge );
505
        $row{'charge'} = sprintf( "%.2f", $charge );
504
506
505
        my ( $renewokay, $renewerror ) =
507
        my ( $renewokay, $renewerror ) = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed( $borrowernumber, $issue->{itemnumber}, $override_limit, $overduesblockrenew );
506
          CanBookBeRenewed( $borrowernumber, $issue->{itemnumber},
507
            $override_limit );
508
        $row{'norenew'} = !$renewokay;
508
        $row{'norenew'} = !$renewokay;
509
        $row{'can_confirm'} = ( !$renewokay && $renewerror ne 'on_reserve' );
509
        $row{'can_confirm'} = ( !$renewokay && $renewerror ne 'on_reserve' );
510
        $row{"norenew_reason_$renewerror"} = 1 if $renewerror;
510
        $row{"norenew_reason_$renewerror"} = 1 if $renewerror;
511
        $row{'blockrenewal'} = ($renewerror=~ /overdue|restriction/) ? 1 : 0;
511
        $row{renew_failed}  = $renew_failed{ $issue->{itemnumber} };
512
        $row{renew_failed}  = $renew_failed{ $issue->{itemnumber} };
512
        $row{return_failed} = $return_failed{ $issue->{barcode} };
513
        $row{return_failed} = $return_failed{ $issue->{barcode} };
513
        push( @{$localissue}, \%row );
514
        push( @{$localissue}, \%row );
(-)a/opac/opac-renew.pl (-1 / +5 lines)
Lines 46-53 my @items = $query->param('item'); Link Here
46
my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
46
my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
47
47
48
my $errorstring='';
48
my $errorstring='';
49
50
my ($blockallitems, $reasonwhy, $overduesblockrenew) = HasWhateverRenewalToBeBlocked($borrowernumber, $override_limit);
51
49
for my $itemnumber ( @items ) {
52
for my $itemnumber ( @items ) {
50
    my ($status,$error) = CanBookBeRenewed( $borrowernumber, $itemnumber );
53
54
    my ($status,$error) = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed( $borrowernumber, $itemnumber, undef, $overduesblockrenew );
51
    if ( $status == 1 && $opacrenew == 1 ) {
55
    if ( $status == 1 && $opacrenew == 1 ) {
52
	my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
56
	my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
53
	my $branchcode;
57
	my $branchcode;
(-)a/opac/opac-user.pl (-1 / +10 lines)
Lines 155-160 my @overdues; Link Here
155
my @issuedat;
155
my @issuedat;
156
my $itemtypes = GetItemTypes();
156
my $itemtypes = GetItemTypes();
157
my $issues = GetPendingIssues($borrowernumber);
157
my $issues = GetPendingIssues($borrowernumber);
158
159
160
my ($blockallitems, $reasonwhy, $overduesblockrenew) = HasWhateverRenewalToBeBlocked($borrowernumber, undef);
161
158
if ($issues){
162
if ($issues){
159
    foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
163
    foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
160
        # check for reserves
164
        # check for reserves
Lines 178-188 if ($issues){ Link Here
178
        $issue->{'charges'} = $charges;
182
        $issue->{'charges'} = $charges;
179
183
180
        # check if item is renewable
184
        # check if item is renewable
181
        my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
185
        my ($status,$renewerror) = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'}, undef, $overduesblockrenew);
182
        ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
186
        ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
183
        if($status && C4::Context->preference("OpacRenewalAllowed")){
187
        if($status && C4::Context->preference("OpacRenewalAllowed")){
184
            $issue->{'status'} = $status;
188
            $issue->{'status'} = $status;
185
        }
189
        }
190
        $issue->{'norenew_overdue'} = 1 if $renewerror and $renewerror eq 'overdue';
186
        $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
191
        $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
187
        $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';
192
        $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';
188
193
Lines 218-229 if ($issues){ Link Here
218
                }
223
                }
219
    }
224
    }
220
}
225
}
226
227
$canrenew =  0 if ($overduesblockrenew ne 'allow' and $overdues_count == $count);
228
221
$template->param( ISSUES       => \@issuedat );
229
$template->param( ISSUES       => \@issuedat );
222
$template->param( issues_count => $count );
230
$template->param( issues_count => $count );
223
$template->param( canrenew     => $canrenew );
231
$template->param( canrenew     => $canrenew );
224
$template->param( OVERDUES       => \@overdues );
232
$template->param( OVERDUES       => \@overdues );
225
$template->param( overdues_count => $overdues_count );
233
$template->param( overdues_count => $overdues_count );
226
234
235
227
my $show_barcode = C4::Members::AttributeTypes::AttributeTypeExists( ATTRIBUTE_SHOW_BARCODE );
236
my $show_barcode = C4::Members::AttributeTypes::AttributeTypeExists( ATTRIBUTE_SHOW_BARCODE );
228
if ($show_barcode) {
237
if ($show_barcode) {
229
    my $patron_show_barcode = GetBorrowerAttributeValue($borrowernumber, ATTRIBUTE_SHOW_BARCODE);
238
    my $patron_show_barcode = GetBorrowerAttributeValue($borrowernumber, ATTRIBUTE_SHOW_BARCODE);
(-)a/reserve/renewscript.pl (-3 / +3 lines)
Lines 81-91 my $borrowernumber = $input->param("borrowernumber"); Link Here
81
my $exemptfine     = $input->param("exemptfine") || 0;
81
my $exemptfine     = $input->param("exemptfine") || 0;
82
my $override_limit = $input->param("override_limit") || 0;
82
my $override_limit = $input->param("override_limit") || 0;
83
my $failedrenews   = q{};
83
my $failedrenews   = q{};
84
my ($blockallitems, $reasonwhy, $overduesblockrenew) = HasWhateverRenewalToBeBlocked($borrowernumber, $override_limit);
85
84
foreach my $itemno (@data) {
86
foreach my $itemno (@data) {
85
87
86
    # check status before renewing issue
88
    # check status before renewing issue
87
    my ( $renewokay, $error ) =
89
    my ( $renewokay, $error ) = $blockallitems ? (0, $reasonwhy) : CanBookBeRenewed( $borrowernumber, $itemno, $override_limit, $overduesblockrenew );
88
      CanBookBeRenewed( $borrowernumber, $itemno, $override_limit );
89
    if ($renewokay) {
90
    if ($renewokay) {
90
        AddRenewal( $borrowernumber, $itemno, $branch, $datedue );
91
        AddRenewal( $borrowernumber, $itemno, $branch, $datedue );
91
    }
92
    }
92
- 

Return to bug 8236