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

(-)a/C4/Circulation.pm (-5 / +13 lines)
Lines 3576-3582 sub updateWrongTransfer { Link Here
3576
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3576
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower);
3577
3577
3578
this function calculates the due date given the start date and configured circulation rules,
3578
this function calculates the due date given the start date and configured circulation rules,
3579
checking against the holidays calendar as per the 'useDaysMode' syspref.
3579
checking against the holidays calendar as per the useDaysMode circulation rule.
3580
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3580
C<$startdate>   = DateTime object representing start date of loan period (assumed to be today)
3581
C<$itemtype>  = itemtype code of item in question
3581
C<$itemtype>  = itemtype code of item in question
3582
C<$branch>  = location whose calendar to use
3582
C<$branch>  = location whose calendar to use
Lines 3610-3617 sub CalcDateDue { Link Here
3610
    }
3610
    }
3611
3611
3612
3612
3613
    my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value(
3614
        {
3615
            categorycode => $borrower->{categorycode},
3616
            itemtype     => $itemtype,
3617
            branchcode   => $branch,
3618
        }
3619
    );
3620
3613
    # calculate the datedue as normal
3621
    # calculate the datedue as normal
3614
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3622
    if ( $useDaysMode_value eq 'Days' )
3615
    {    # ignoring calendar
3623
    {    # ignoring calendar
3616
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3624
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3617
            $datedue->add( hours => $loanlength->{$length_key} );
3625
            $datedue->add( hours => $loanlength->{$length_key} );
Lines 3628-3634 sub CalcDateDue { Link Here
3628
        else { # days
3636
        else { # days
3629
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3637
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3630
        }
3638
        }
3631
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3639
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3632
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3640
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3633
        if ($loanlength->{lengthunit} eq 'days') {
3641
        if ($loanlength->{lengthunit} eq 'days') {
3634
            $datedue->set_hour(23);
3642
            $datedue->set_hour(23);
Lines 3666-3673 sub CalcDateDue { Link Here
3666
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3674
                $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
3667
            }
3675
            }
3668
        }
3676
        }
3669
        if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
3677
        if ( $useDaysMode_value ne 'Days' ) {
3670
          my $calendar = Koha::Calendar->new( branchcode => $branch );
3678
          my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value );
3671
          if ( $calendar->is_holiday($datedue) ) {
3679
          if ( $calendar->is_holiday($datedue) ) {
3672
              # Don't return on a closed day
3680
              # Don't return on a closed day
3673
              $datedue = $calendar->prev_open_days( $datedue, 1 );
3681
              $datedue = $calendar->prev_open_days( $datedue, 1 );
(-)a/C4/UsageStats.pm (-1 lines)
Lines 155-161 sub BuildReport { Link Here
155
        ReturnBeforeExpiry
155
        ReturnBeforeExpiry
156
        TransfersMaxDaysWarning
156
        TransfersMaxDaysWarning
157
        UseBranchTransferLimits
157
        UseBranchTransferLimits
158
        useDaysMode
159
        UseTransportCostMatrix
158
        UseTransportCostMatrix
160
        UseCourseReserves
159
        UseCourseReserves
161
        finesCalendar
160
        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 416-422 sub mocking_systempreferences_to_a_set_value { Link Here
416
        ReturnBeforeExpiry
416
        ReturnBeforeExpiry
417
        TransfersMaxDaysWarning
417
        TransfersMaxDaysWarning
418
        UseBranchTransferLimits
418
        UseBranchTransferLimits
419
        useDaysMode
420
        UseTransportCostMatrix
419
        UseTransportCostMatrix
421
        UseCourseReserves
420
        UseCourseReserves
422
        finesCalendar
421
        finesCalendar
423
- 

Return to bug 24159