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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 3566-3572 sub UpdateHoldingbranch { Link Here
3566
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3566
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3567
3567
3568
this function calculates the due date given the start date and configured circulation rules,
3568
this function calculates the due date given the start date and configured circulation rules,
3569
checking against the holidays calendar as per the 'useDaysMode' syspref.
3569
checking against the holidays calendar as per the useDaysMode circulation rule.
3570
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3570
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3571
C<$itemtype>  = itemtype code of item in question
3571
C<$itemtype>  = itemtype code of item in question
3572
C<$branch>  = location whose calendar to use
3572
C<$branch>  = location whose calendar to use
Lines 3602-3609 sub CalcDateDue { Link Here
3602
    }
3602
    }
3603
3603
3604
3604
3605
    my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value(
3606
        {
3607
            categorycode => $borrower->{categorycode},
3608
            itemtype     => $itemtype,
3609
            branchcode   => $branch,
3610
        }
3611
    );
3612
3605
    # calculate the datedue as normal
3613
    # calculate the datedue as normal
3606
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3614
    if ( $useDaysMode_value eq 'Days' )
3607
    {    # ignoring calendar
3615
    {    # ignoring calendar
3608
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3616
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3609
            $datedue->add( hours => $loanlength->{$length_key} );
3617
            $datedue->add( hours => $loanlength->{$length_key} );
Lines 3620-3626 sub CalcDateDue { Link Here
3620
        else { # days
3628
        else { # days
3621
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3629
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3622
        }
3630
        }
3623
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3631
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3624
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3632
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3625
        if ($loanlength->{lengthunit} eq 'days') {
3633
        if ($loanlength->{lengthunit} eq 'days') {
3626
            $datedue->set_hour(23);
3634
            $datedue->set_hour(23);
Lines 3658-3665 sub CalcDateDue { Link Here
3658
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3666
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3659
            }
3667
            }
3660
        }
3668
        }
3661
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3669
        if ( $useDaysMode_value ne 'Days' ) {
3662
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3670
          my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3663
          if ( $calendar->is_holiday($datedue) ) {
3671
          if ( $calendar->is_holiday($datedue) ) {
3664
              # Don't return on a closed day
3672
              # Don't return on a closed day
3665
              $datedue = $calendar->prev_open_days( $datedue, 1 );
3673
              $datedue = $calendar->prev_open_days( $datedue, 1 );
(-)a/C4/UsageStats.pm (-1 lines)
Lines 154-160 sub BuildReport { Link Here
154
        ReturnBeforeExpiry
154
        ReturnBeforeExpiry
155
        TransfersMaxDaysWarning
155
        TransfersMaxDaysWarning
156
        UseBranchTransferLimits
156
        UseBranchTransferLimits
157
        useDaysMode
158
        UseTransportCostMatrix
157
        UseTransportCostMatrix
159
        UseCourseReserves
158
        UseCourseReserves
160
        finesCalendar
159
        finesCalendar
(-)a/Koha/CirculationRules.pm (+30 lines)
Lines 487-492 sub guess_article_requestable_itemtypes { Link Here
487
    return $res;
487
    return $res;
488
}
488
}
489
489
490
=head3 get_useDaysMode_effective_value
491
492
Return the value for useDaysMode defined in the circulation rules.
493
If not defined (or empty string), the value of the system preference useDaysMode is returned
494
495
=cut
496
497
sub get_useDaysMode_effective_value {
498
    my ( $class, $params ) = @_;
499
500
    my $categorycode     = $params->{categorycode};
501
    my $itemtype         = $params->{itemtype};
502
    my $branchcode       = $params->{branchcode};
503
504
    my $useDaysMode_rule = $class->get_effective_rule(
505
        {
506
            categorycode => $categorycode,
507
            itemtype     => $itemtype,
508
            branchcode   => $branchcode,
509
            rule_name    => 'useDaysMode',
510
        }
511
    );
512
513
    return ( defined($useDaysMode_rule)
514
          and $useDaysMode_rule->rule_value ne '' )
515
      ? $useDaysMode_rule->rule_value
516
      : C4::Context->preference('useDaysMode');
517
518
}
519
490
520
491
=head3 type
521
=head3 type
492
522
(-)a/t/db_dependent/UsageStats.t (-2 lines)
Lines 415-421 sub mocking_systempreferences_to_a_set_value { Link Here
415
        ReturnBeforeExpiry
415
        ReturnBeforeExpiry
416
        TransfersMaxDaysWarning
416
        TransfersMaxDaysWarning
417
        UseBranchTransferLimits
417
        UseBranchTransferLimits
418
        useDaysMode
419
        UseTransportCostMatrix
418
        UseTransportCostMatrix
420
        UseCourseReserves
419
        UseCourseReserves
421
        finesCalendar
420
        finesCalendar
422
- 

Return to bug 24159