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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 3581-3587 sub UpdateHoldingbranch { Link Here
3581
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3581
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3582
3582
3583
this function calculates the due date given the start date and configured circulation rules,
3583
this function calculates the due date given the start date and configured circulation rules,
3584
checking against the holidays calendar as per the 'useDaysMode' syspref.
3584
checking against the holidays calendar as per the useDaysMode circulation rule.
3585
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3585
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3586
C<$itemtype>  = itemtype code of item in question
3586
C<$itemtype>  = itemtype code of item in question
3587
C<$branch>  = location whose calendar to use
3587
C<$branch>  = location whose calendar to use
Lines 3617-3624 sub CalcDateDue { Link Here
3617
    }
3617
    }
3618
3618
3619
3619
3620
    my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value(
3621
        {
3622
            categorycode => $borrower->{categorycode},
3623
            itemtype     => $itemtype,
3624
            branchcode   => $branch,
3625
        }
3626
    );
3627
3620
    # calculate the datedue as normal
3628
    # calculate the datedue as normal
3621
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3629
    if ( $useDaysMode_value eq 'Days' )
3622
    {    # ignoring calendar
3630
    {    # ignoring calendar
3623
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3631
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3624
            $datedue->add( hours => $loanlength->{$length_key} );
3632
            $datedue->add( hours => $loanlength->{$length_key} );
Lines 3635-3641 sub CalcDateDue { Link Here
3635
        else { # days
3643
        else { # days
3636
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3644
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3637
        }
3645
        }
3638
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3646
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3639
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3647
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3640
        if ($loanlength->{lengthunit} eq 'days') {
3648
        if ($loanlength->{lengthunit} eq 'days') {
3641
            $datedue->set_hour(23);
3649
            $datedue->set_hour(23);
Lines 3673-3680 sub CalcDateDue { Link Here
3673
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3681
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3674
            }
3682
            }
3675
        }
3683
        }
3676
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3684
        if ( $useDaysMode_value ne 'Days' ) {
3677
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3685
          my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3678
          if ( $calendar->is_holiday($datedue) ) {
3686
          if ( $calendar->is_holiday($datedue) ) {
3679
              # Don't return on a closed day
3687
              # Don't return on a closed day
3680
              $datedue = $calendar->prev_open_days( $datedue, 1 );
3688
              $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