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

(-)a/C4/Circulation.pm (-17 / +21 lines)
Lines 1335-1343 sub GetLoanLength { Link Here
1335
1335
1336
    # try to find issuelength & return the 1st available.
1336
    # try to find issuelength & return the 1st available.
1337
    # check with borrowertype, itemtype and branchcode, then without one of those parameters
1337
    # check with borrowertype, itemtype and branchcode, then without one of those parameters
1338
1339
    $sth->execute( $borrowertype, $itemtype, $branchcode );
1338
    $sth->execute( $borrowertype, $itemtype, $branchcode );
1340
    my $loanlength = $sth->fetchrow_hashref;
1339
    my $loanlength = $sth->fetchrow_hashref;
1340
1341
    return $loanlength
1341
    return $loanlength
1342
      if defined($loanlength) && $loanlength->{issuelength};
1342
      if defined($loanlength) && $loanlength->{issuelength};
1343
1343
Lines 2411-2418 END_SQL Link Here
2411
2411
2412
Find out whether a borrowed item may be renewed.
2412
Find out whether a borrowed item may be renewed.
2413
2413
2414
C<$dbh> is a DBI handle to the Koha database.
2415
2416
C<$borrowernumber> is the borrower number of the patron who currently
2414
C<$borrowernumber> is the borrower number of the patron who currently
2417
has the item on loan.
2415
has the item on loan.
2418
2416
Lines 2422-2428 C<$override_limit>, if supplied with a true value, causes Link Here
2422
the limit on the number of times that the loan can be renewed
2420
the limit on the number of times that the loan can be renewed
2423
(as controlled by the item type) to be ignored.
2421
(as controlled by the item type) to be ignored.
2424
2422
2425
C<$CanBookBeRenewed> returns a true value iff the item may be renewed. The
2423
C<$CanBookBeRenewed> returns a true value if the item may be renewed. The
2426
item must currently be on loan to the specified borrower; renewals
2424
item must currently be on loan to the specified borrower; renewals
2427
must be allowed for the item's type; and the borrower must not have
2425
must be allowed for the item's type; and the borrower must not have
2428
already renewed the loan. $error will contain the reason the renewal can not proceed
2426
already renewed the loan. $error will contain the reason the renewal can not proceed
Lines 2984-2989 C<$startdate> = C4::Dates object representing start date of loan period (assum Link Here
2984
C<$itemtype>  = itemtype code of item in question
2982
C<$itemtype>  = itemtype code of item in question
2985
C<$branch>  = location whose calendar to use
2983
C<$branch>  = location whose calendar to use
2986
C<$borrower> = Borrower object
2984
C<$borrower> = Borrower object
2985
C<$isrenewal> = Boolean: is true if we want to calculate the date due for a renewal. Else is false.
2987
2986
2988
=cut
2987
=cut
2989
2988
Lines 3001-3022 sub CalcDateDue { Link Here
3001
            : qq{issuelength};
3000
            : qq{issuelength};
3002
3001
3003
    my $datedue;
3002
    my $datedue;
3003
    if ( $startdate ) {
3004
        if (ref $startdate ne 'DateTime' ) {
3005
            $datedue = dt_from_string($datedue);
3006
        } else {
3007
            $datedue = $startdate->clone;
3008
        }
3009
    } else {
3010
        $datedue =
3011
          DateTime->now( time_zone => C4::Context->tz() )
3012
          ->truncate( to => 'minute' );
3013
    }
3014
3004
3015
3005
    # calculate the datedue as normal
3016
    # calculate the datedue as normal
3006
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3017
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3007
    {    # ignoring calendar
3018
    {    # ignoring calendar
3008
        my $dt =
3009
          DateTime->now( time_zone => C4::Context->tz() )
3010
          ->truncate( to => 'minute' );
3011
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3019
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3012
            $dt->add( hours => $loanlength->{$length_key} );
3020
            $datedue->add( hours => $loanlength->{$length_key} );
3013
        } else {    # days
3021
        } else {    # days
3014
            $dt->add( days => $loanlength->{$length_key} );
3022
            $datedue->add( days => $loanlength->{$length_key} );
3015
            $dt->set_hour(23);
3023
            $datedue->set_hour(23);
3016
            $dt->set_minute(59);
3024
            $datedue->set_minute(59);
3017
        }
3025
        }
3018
        # break
3019
        return $dt;
3020
    } else {
3026
    } else {
3021
        my $dur;
3027
        my $dur;
3022
        if ($loanlength->{lengthunit} eq 'hours') {
3028
        if ($loanlength->{lengthunit} eq 'hours') {
Lines 3025-3035 sub CalcDateDue { Link Here
3025
        else { # days
3031
        else { # days
3026
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3032
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3027
        }
3033
        }
3028
        if (ref $startdate ne 'DateTime' ) {
3029
            $startdate = dt_from_string($startdate);
3030
        }
3031
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3034
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3032
        $datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} );
3035
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3033
        if ($loanlength->{lengthunit} eq 'days') {
3036
        if ($loanlength->{lengthunit} eq 'days') {
3034
            $datedue->set_hour(23);
3037
            $datedue->set_hour(23);
3035
            $datedue->set_minute(59);
3038
            $datedue->set_minute(59);
Lines 3053-3058 sub CalcDateDue { Link Here
3053
        }
3056
        }
3054
3057
3055
        # in all other cases, keep the date due as it is
3058
        # in all other cases, keep the date due as it is
3059
3056
    }
3060
    }
3057
3061
3058
    # if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate
3062
    # if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +1 lines)
Lines 75-81 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
75
                <th>Overdue Fines Cap ($)</th>
75
                <th>Overdue Fines Cap ($)</th>
76
                <th>Suspension in days (day)</th>
76
                <th>Suspension in days (day)</th>
77
                <th>Renewals allowed (count)</th>
77
                <th>Renewals allowed (count)</th>
78
                <th>Renewals period</th>
78
                <th>Renewal period</th>
79
                <th>Holds allowed (count)</th>
79
                <th>Holds allowed (count)</th>
80
		<th>Rental discount (%)</th>
80
		<th>Rental discount (%)</th>
81
				<th>&nbsp;</th>
81
				<th>&nbsp;</th>
82
- 

Return to bug 8365