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

(-)a/C4/Circulation.pm (-33 / +34 lines)
Lines 1176-1182 AddIssue does the following things : Link Here
1176
=cut
1176
=cut
1177
1177
1178
sub AddIssue {
1178
sub AddIssue {
1179
    my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_;
1179
    my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $auto_renew ) = @_;
1180
    my $dbh = C4::Context->dbh;
1180
    my $dbh = C4::Context->dbh;
1181
	my $barcodecheck=CheckValidBarcode($barcode);
1181
	my $barcodecheck=CheckValidBarcode($barcode);
1182
    if ($datedue && ref $datedue ne 'DateTime') {
1182
    if ($datedue && ref $datedue ne 'DateTime') {
Lines 1242-1253 sub AddIssue { Link Here
1242
                $sth->execute(C4::Context->userenv->{'branch'},$item->{'itemnumber'});
1242
                $sth->execute(C4::Context->userenv->{'branch'},$item->{'itemnumber'});
1243
            }
1243
            }
1244
1244
1245
        # If automatic renewal wasn't selected while issuing, set the value according to the issuing rule.
1246
        unless ($auto_renew) {
1247
            my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch);
1248
            $auto_renew = $issuingrule->{auto_renew};
1249
        }
1250
1245
        # Record in the database the fact that the book was issued.
1251
        # Record in the database the fact that the book was issued.
1246
        my $sth =
1252
        my $sth =
1247
          $dbh->prepare(
1253
          $dbh->prepare(
1248
                "INSERT INTO issues
1254
                "INSERT INTO issues
1249
                    (borrowernumber, itemnumber,issuedate, date_due, branchcode)
1255
                    (borrowernumber, itemnumber,issuedate, date_due, branchcode, auto_renew)
1250
                VALUES (?,?,?,?,?)"
1256
                VALUES (?,?,?,?,?,?)"
1251
          );
1257
          );
1252
        unless ($datedue) {
1258
        unless ($datedue) {
1253
            my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
1259
            my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
Lines 1260-1266 sub AddIssue { Link Here
1260
            $item->{'itemnumber'},              # itemnumber
1266
            $item->{'itemnumber'},              # itemnumber
1261
            $issuedate->strftime('%Y-%m-%d %H:%M:00'), # issuedate
1267
            $issuedate->strftime('%Y-%m-%d %H:%M:00'), # issuedate
1262
            $datedue->strftime('%Y-%m-%d %H:%M:00'),   # date_due
1268
            $datedue->strftime('%Y-%m-%d %H:%M:00'),   # date_due
1263
            C4::Context->userenv->{'branch'}    # branchcode
1269
            C4::Context->userenv->{'branch'},   # branchcode
1270
            $auto_renew ? 1 : 0                 # automatic renewal
1264
        );
1271
        );
1265
        if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart.
1272
        if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart.
1266
          CartToShelf( $item->{'itemnumber'} );
1273
          CartToShelf( $item->{'itemnumber'} );
Lines 2584-2590 C<$itemnumber> is the number of the item to renew. Link Here
2584
2591
2585
C<$override_limit>, if supplied with a true value, causes
2592
C<$override_limit>, if supplied with a true value, causes
2586
the limit on the number of times that the loan can be renewed
2593
the limit on the number of times that the loan can be renewed
2587
(as controlled by the item type) to be ignored.
2594
(as controlled by the item type) to be ignored. Overriding also allows
2595
to renew sooner than "No renewal before" und to manually renew loans
2596
that are automatically renewed.
2588
2597
2589
C<$CanBookBeRenewed> returns a true value if the item may be renewed. The
2598
C<$CanBookBeRenewed> returns a true value if the item may be renewed. The
2590
item must currently be on loan to the specified borrower; renewals
2599
item must currently be on loan to the specified borrower; renewals
Lines 2596-2605 already renewed the loan. $error will contain the reason the renewal can not pro Link Here
2596
sub CanBookBeRenewed {
2605
sub CanBookBeRenewed {
2597
    my ( $borrowernumber, $itemnumber, $override_limit ) = @_;
2606
    my ( $borrowernumber, $itemnumber, $override_limit ) = @_;
2598
2607
2599
    my $dbh       = C4::Context->dbh;
2608
    my $dbh    = C4::Context->dbh;
2600
    my $renews    = 1;
2609
    my $renews = 1;
2601
    my $renewokay = 1;
2602
    my $error;
2603
2610
2604
    my $item      = GetItem($itemnumber)      or return ( 0, 'no_item' );
2611
    my $item      = GetItem($itemnumber)      or return ( 0, 'no_item' );
2605
    my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' );
2612
    my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' );
Lines 2608-2649 sub CanBookBeRenewed { Link Here
2608
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2615
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2609
      or return;
2616
      or return;
2610
2617
2611
    my $branchcode  = _GetCircControlBranch($item, $borrower);
2618
    my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber);
2612
2619
2613
    my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
2620
    return ( 0, "on_reserve" ) if $resfound;    # '' when no hold was found
2621
2622
    return ( 1, undef ) if $override_limit;
2623
2624
    my $branchcode = _GetCircControlBranch( $item, $borrower );
2625
    my $issuingrule =
2626
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
2627
2628
    return ( 0, "too_many" )
2629
      if $issuingrule->{renewalsallowed} <= $itemissue->{renewals};
2614
2630
2615
    if ( $issuingrule->{norenewalbefore} ) {
2631
    if ( $issuingrule->{norenewalbefore} ) {
2616
2632
2617
        # Get current time and add norenewalbefore. If this is smaller than date_due, it's too soon for renewal.
2633
        # Get current time and add norenewalbefore.
2634
        # If this is smaller than date_due, it's too soon for renewal.
2618
        if (
2635
        if (
2619
            DateTime->now( time_zone => C4::Context->tz() )->add(
2636
            DateTime->now( time_zone => C4::Context->tz() )->add(
2620
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2637
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2621
            ) < $itemissue->{date_due}
2638
            ) < $itemissue->{date_due}
2622
        )
2639
          )
2623
        {
2640
        {
2624
            $renewokay = 0;
2641
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2625
            $error     = "too_soon";
2642
            return ( 0, "too_soon" );
2626
        }
2643
        }
2627
    }
2644
    }
2628
2645
2629
    if ( $issuingrule->{renewalsallowed} <= $itemissue->{renewals} ) {
2646
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2630
        $renewokay = 0;
2647
    return ( 1, undef );
2631
        $error = "too_many";
2632
    }
2633
2634
    if ( $override_limit ) {
2635
        $renewokay = 1;
2636
        $error     = undef;
2637
    }
2638
2639
    my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber );
2640
2641
    if ( $resfound ) { # '' when no hold was found
2642
        $renewokay = 0;
2643
        $error = "on_reserve";
2644
    }
2645
2646
    return ( $renewokay, $error );
2647
}
2648
}
2648
2649
2649
=head2 AddRenewal
2650
=head2 AddRenewal
(-)a/circ/circulation.pl (-1 / +6 lines)
Lines 145-150 if ( $barcode ) { Link Here
145
        $stickyduedate  = $query->param('stickyduedate');
145
        $stickyduedate  = $query->param('stickyduedate');
146
        $duedatespec    = $query->param('duedatespec');
146
        $duedatespec    = $query->param('duedatespec');
147
    }
147
    }
148
    $session->param('auto_renew', $query->param('auto_renew'));
149
}
150
else {
151
    $session->clear('auto_renew');
148
}
152
}
149
153
150
my ($datedue,$invalidduedate);
154
my ($datedue,$invalidduedate);
Lines 355-361 if ($barcode) { Link Here
355
            }
359
            }
356
        }
360
        }
357
        unless($confirm_required) {
361
        unless($confirm_required) {
358
            AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
362
            AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, $session->param('auto_renew') );
363
            $session->clear('auto_renew');
359
            $inprocess = 1;
364
            $inprocess = 1;
360
        }
365
        }
361
    }
366
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-2 / +17 lines)
Lines 528-533 No patron matched <span class="ex">[% message %]</span> Link Here
528
    [% END %]
528
    [% END %]
529
    <input type="submit" value="Check Out" />
529
    <input type="submit" value="Check Out" />
530
530
531
    <div class="date-select">
532
        [% IF NEEDSCONFIRMATION %]
533
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" />
534
        [% ELSE %]
535
            <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" />
536
        [% END %]
537
        <label for="auto_renew">Automatic renewal</label>
538
    </div>
539
531
    [% IF ( SpecifyDueDate ) %]<div class="date-select">
540
    [% IF ( SpecifyDueDate ) %]<div class="date-select">
532
        <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
541
        <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
533
        [% IF ( duedatespec ) %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />[% ELSE %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="" readonly="readonly" />
542
        [% IF ( duedatespec ) %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="[% duedatespec %]" readonly="readonly" />[% ELSE %]<input type="text" size="13" id="duedatespec" name="duedatespec" value="" readonly="readonly" />
Lines 789-795 No patron matched <span class="ex">[% message %]</span> Link Here
789
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" />
798
                    <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" />
790
                [% END %]
799
                [% END %]
791
                </span>
800
                </span>
792
                [% IF todayissue.renewsallowed && todayissue.renewsleft && !todayissue.renew_error_too_soon %]
801
                [% IF todayissue.renewsallowed && todayissue.renewsleft && !todayissue.renew_error_too_soon && !todayissue.renew_error_auto_renew && !todayissue.renew_error_auto_too_soon %]
793
                    <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span>
802
                    <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span>
794
                [% END %]
803
                [% END %]
795
                <span class="renewals-disabled">
804
                <span class="renewals-disabled">
Lines 798-803 No patron matched <span class="ex">[% message %]</span> Link Here
798
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% todayissue.biblionumber %]">On hold</a>
807
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% todayissue.biblionumber %]">On hold</a>
799
            [% ELSIF ( todayissue.renew_error_too_many ) %]
808
            [% ELSIF ( todayissue.renew_error_too_many ) %]
800
                Not renewable
809
                Not renewable
810
            [% ELSIF ( todayissue.renew_error_auto_renew || todayissue.renew_error_auto_too_soon ) %]
811
                Automatic renewal
812
                <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span>
801
            [% ELSIF ( todayissue.renew_error_too_soon ) %]
813
            [% ELSIF ( todayissue.renew_error_too_soon ) %]
802
                No renewal before [% todayissue.soonestrenewdate %]
814
                No renewal before [% todayissue.soonestrenewdate %]
803
                <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span>
815
                <span class="renewals">([% todayissue.renewsleft %] of [% todayissue.renewsallowed %] renewals remaining)</span>
Lines 886-892 No patron matched <span class="ex">[% message %]</span> Link Here
886
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" />
898
                    <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" />
887
                [% END %]
899
                [% END %]
888
                </span>
900
                </span>
889
                [% IF previssue.renewsallowed && previssue.renewsleft && !previssue.renew_error_too_soon %]
901
                [% IF previssue.renewsallowed && previssue.renewsleft && !previssue.renew_error_too_soon && !previssue.renew_error_auto_renew && !previssue.renew_error_auto_too_soon %]
890
                    <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span>
902
                    <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span>
891
                [% END %]
903
                [% END %]
892
                <span class="renewals-disabled">
904
                <span class="renewals-disabled">
Lines 895-900 No patron matched <span class="ex">[% message %]</span> Link Here
895
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% previssue.biblionumber %]">On Hold</a>
907
                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% previssue.biblionumber %]">On Hold</a>
896
            [% ELSIF ( previssue.renew_error_too_many ) %]
908
            [% ELSIF ( previssue.renew_error_too_many ) %]
897
                Not renewable
909
                Not renewable
910
            [% ELSIF ( previssue.renew_error_auto_renew || previssue.renew_error_auto_too_soon ) %]
911
                Automatic renewal
912
                <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span>
898
            [% ELSIF ( previssue.renew_error_too_soon ) %]
913
            [% ELSIF ( previssue.renew_error_too_soon ) %]
899
                No renewal before [% previssue.soonestrenewdate %]
914
                No renewal before [% previssue.soonestrenewdate %]
900
                <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span>
915
                <span class="renewals">([% previssue.renewsleft %] of [% previssue.renewsallowed %] renewals remaining)</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-2 / +4 lines)
Lines 497-503 function validate1(date) { Link Here
497
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" />
497
                        <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" />
498
                    [% END %]
498
                    [% END %]
499
                    </span>
499
                    </span>
500
                    [% IF issueloo.renewsallowed && issueloo.renewsleft && !issueloo.norenew_reason_too_soon %]
500
                    [% IF issueloo.renewsallowed && issueloo.renewsleft && !issueloo.norenew_reason_too_soon && !issueloo.norenew_reason_auto_renew && !issueloo.norenew_reason_auto_too_soon %]
501
                        <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span>
501
                        <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span>
502
                    [% END %]
502
                    [% END %]
503
                    <span class="renewals-disabled">
503
                    <span class="renewals-disabled">
Lines 506-511 function validate1(date) { Link Here
506
                    <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a>
506
                    <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a>
507
                [% ELSIF ( issueloo.norenew_reason_too_many ) %]
507
                [% ELSIF ( issueloo.norenew_reason_too_many ) %]
508
                    Not renewable
508
                    Not renewable
509
                [% ELSIF ( issueloo.norenew_reason_auto_renew || issueloo.norenew_reason_auto_too_soon ) %]
510
                    Automatic renewal
511
                    <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span>
509
                [% ELSIF ( issueloo.norenew_reason_too_soon ) %]
512
                [% ELSIF ( issueloo.norenew_reason_too_soon ) %]
510
                    No renewal before [% issueloo.soonestrenewdate %]
513
                    No renewal before [% issueloo.soonestrenewdate %]
511
                    <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span>
514
                    <span class="renewals">([% issueloo.renewsleft %] of [% issueloo.renewsallowed %] renewals remaining)</span>
512
- 

Return to bug 11577