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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 1962-1968 sub AddReturn { Link Here
1962
    } else {
1962
    } else {
1963
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1963
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1964
    }
1964
    }
1965
1966
    # fix up the accounts.....
1965
    # fix up the accounts.....
1967
    if ( $item->{'itemlost'} ) {
1966
    if ( $item->{'itemlost'} ) {
1968
        $messages->{'WasLost'} = 1;
1967
        $messages->{'WasLost'} = 1;
Lines 2020-2027 sub AddReturn { Link Here
2020
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2019
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2021
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2020
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
2022
    if ($resfound) {
2021
    if ($resfound) {
2023
          $resrec->{'ResFound'} = $resfound;
2022
        $resrec->{'ResFound'} = $resfound;
2024
        $messages->{'ResFound'} = $resrec;
2023
        $messages->{'ResFound'} = $resrec;
2024
        C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2025
    }
2025
    }
2026
2026
2027
    # Record the fact that this book was returned.
2027
    # Record the fact that this book was returned.
(-)a/C4/Letters.pm (-8 / +10 lines)
Lines 781-795 sub _parseletter { Link Here
781
781
782
    # Work on a local copy of $values_in (passed by reference) to avoid side effects
782
    # Work on a local copy of $values_in (passed by reference) to avoid side effects
783
    # in callers ( by changing / formatting values )
783
    # in callers ( by changing / formatting values )
784
    my $values = $values_in ? { %$values_in } : {};
784
   my $values = $values_in ? { %$values_in } : {};
785
785
786
    if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){
786
   if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){
787
        $values->{'dateexpiry'} = output_pref({ str => $values->{dateexpiry}, dateonly => 1 });
787
       $values->{'dateexpiry'} = output_pref({ str => $values->{dateexpiry}, dateonly => 1 });
788
    }
788
   }
789
789
790
    if ( $table eq 'reserves' && $values->{'waitingdate'} ) {
790
# if ( $table eq 'reserves' && $values->{'waitingdate'}) {
791
        $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 });
791
#      $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 });
792
    }
792
#  }
793
793
794
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
794
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
795
        my $todaysdate = output_pref( DateTime->now() );
795
        my $todaysdate = output_pref( DateTime->now() );
Lines 806-812 sub _parseletter { Link Here
806
            my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $val });
806
            my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $val });
807
            $val = $av->count ? $av->next->lib : '';
807
            $val = $av->count ? $av->next->lib : '';
808
        }
808
        }
809
809
warn $table;
810
warn $field;
811
warn $val;
810
        # Dates replacement
812
        # Dates replacement
811
        my $replacedby   = defined ($val) ? $val : '';
813
        my $replacedby   = defined ($val) ? $val : '';
812
        if (    $replacedby
814
        if (    $replacedby
(-)a/C4/Reserves.pm (-11 / +123 lines)
Lines 121-127 BEGIN { Link Here
121
        &CanItemBeReserved
121
        &CanItemBeReserved
122
        &CanReserveBeCanceledFromOpac
122
        &CanReserveBeCanceledFromOpac
123
        &CancelExpiredReserves
123
        &CancelExpiredReserves
124
125
        &AutoUnsuspendReserves
124
        &AutoUnsuspendReserves
126
125
127
        &IsAvailableForItemLevelRequest
126
        &IsAvailableForItemLevelRequest
Lines 195-206 sub AddReserve { Link Here
195
194
196
        #The reserve-object doesn't exist yet in DB, so we must supply what information we have to GetLastPickupDate() so it can do it's work.
195
        #The reserve-object doesn't exist yet in DB, so we must supply what information we have to GetLastPickupDate() so it can do it's work.
197
        my $reserve = {borrowernumber => $borrowernumber, waitingdate => $waitingdate, branchcode => $branch};
196
        my $reserve = {borrowernumber => $borrowernumber, waitingdate => $waitingdate, branchcode => $branch};
198
        $lastpickupdate = GetLastPickupDate( $reserve, $item );
197
        my $patron = Koha::Patrons->find( {borrowernumber => $borrowernumber} );
198
        $lastpickupdate = GetLastPickupDate( $reserve, $item, $patron );
199
    }
199
    }
200
201
    # Don't add itemtype limit if specific item is selected
200
    # Don't add itemtype limit if specific item is selected
202
    $itemtype = undef if $checkitem;
201
    $itemtype = undef if $checkitem;
203
204
    # updates take place here
202
    # updates take place here
205
    my $hold = Koha::Hold->new(
203
    my $hold = Koha::Hold->new(
206
        {
204
        {
Lines 219-225 sub AddReserve { Link Here
219
        }
217
        }
220
    )->store();
218
    )->store();
221
    $hold->set_waiting() if $found eq 'W';
219
    $hold->set_waiting() if $found eq 'W';
222
223
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
220
    logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) )
224
        if C4::Context->preference('HoldsLog');
221
        if C4::Context->preference('HoldsLog');
225
222
Lines 647-652 sub GetReserveStatus { Link Here
647
    return ''; # empty string here will remove need for checking undef, or less log lines
644
    return ''; # empty string here will remove need for checking undef, or less log lines
648
}
645
}
649
646
647
648
=head2 GetLastPickupDate
649
650
  my $lastpickupdate = GetLastPickupDate($reserve, $item);
651
  my $lastpickupdate = GetLastPickupDate($reserve, $item, $borrower);
652
  my $lastpickupdate = GetLastPickupDate(undef,    $item);
653
654
  Gets the last pickup date from the issuingrules for the given reserves-row and sets the
655
  $reserve->{lastpickupdate}.-value.
656
657
  If the reserves-row is not passed, function tries to figure it out from the item-row.
658
  Calculating the last pickup date respects Calendar holidays and skips to the next open day.
659
  If the issuingrule's holdspickupwait is 0 or less, means that the lastpickupdate-feature
660
  is disabled for this kind of material.
661
662
  @PARAM1 koha.reserves-row
663
  @PARAM2 koha.items-row, If the reserve is not given, an item must be given to be
664
  able to find a reservation
665
  @PARAM3 koha.borrowers-row, OPTIONAL
666
  RETURNS DateTime, depicting the last pickup date.
667
  OR undef if there is an error or if the issuingrules disable this feature for this material.
668
669
=cut
670
671
sub GetLastPickupDate {
672
    my ($reserve, $item, $borrower) = @_;
673
    ##Verify parameters
674
    if ( not defined $reserve and not defined $item ) {
675
        warn "C4::Reserves::GetMaxPickupDate(), is called without a reserve and an item";
676
        return;
677
    }
678
    if ( defined $reserve and not defined $item ) {
679
        $item = C4::Items::GetItem( $reserve->{itemnumber} );
680
    }
681
682
    unless ( defined $borrower) {
683
        my $borrower = Koha::Patrons->find( $reserve->{borrowernumber} );
684
        $borrower = $borrower->unblessed;
685
    }
686
687
    unless ( defined $reserve ) {
688
        my $reserve = GetReservesFromItemnumber( $item->{itemnumber} );
689
    }
690
    my $date = $reserve->{waitingdate};
691
    unless ( $date ) { #It is possible that a reserve is just caught and it doesn't have a waitingdate yet.
692
       $date = DateTime->now( time_zone => C4::Context->tz() ); #So default to NOW()
693
    }
694
    else {
695
       $date = (ref $reserve->{waitingdate} eq 'DateTime') ? $reserve->{waitingdate}  :  dt_from_string($reserve->{waitingdate});
696
    }
697
    ##Get churning the LastPickupDate
698
699
    # Get the controlbranch
700
    my $controlbranch = GetReservesControlBranch( $item, $borrower );
701
    my $hbr = C4::Context->preference('HomeOrHoldingBranch') || "homebranch";
702
    my $branchcode    = "*";
703
    if ( $controlbranch eq "ItemHomeLibrary" ) {
704
         $branchcode = $item->{$hbr};
705
    } elsif ( $controlbranch eq "PatronLibrary" ) {
706
         $branchcode = $borrower->branchcode;
707
    }
708
    warn 'getlastpickup';
709
    warn $branchcode;
710
    warn $borrower->{'categorycode'};
711
    warn $item->{itype};
712
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
713
            branchcode   => $branchcode,
714
            categorycode => $borrower->{'categorycode'},
715
            itemtype     => $item->{itype},
716
    });
717
718
    my $reservebranch;
719
    if ($reserve->{'branchcode'}) {
720
        $reservebranch = $reserve->{'branchcode'};
721
    } else {
722
        $reservebranch = $reserve->branchcode;
723
    }
724
    if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) { #If holdspickupwait is <= 0, it means this feature is disabled for this type of material.
725
        $date->add( days => $issuingrule->holdspickupwait );
726
        my $calendar = Koha::Calendar->new( branchcode => $reservebranch );
727
        my $is_holiday = $calendar->is_holiday( $date );
728
        while ( $is_holiday ) {
729
               $date->add( days => 1 );
730
               $is_holiday = $calendar->is_holiday( $date );
731
        }
732
        $reserve->{lastpickupdate} = $date->ymd();
733
        return $date;
734
     }
735
     #Without explicitly setting the return value undef, the lastpickupdate-column is
736
     #  set as 0000-00-00 instead of NULL in DBD::MySQL.
737
     #This causes this hold to always expire any lastpickupdate check,
738
     ##  effectively canceling it as soon as cancel_expired_holds.pl is ran.
739
     ##This is exactly the opposite of disabling the autoexpire feature.
740
     ##So please let me explicitly return undef, because Perl cant always handle everything.
741
     delete $reserve->{lastpickupdate};
742
     return undef;
743
}
744
650
=head2 CheckReserves
745
=head2 CheckReserves
651
746
652
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
747
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
Lines 993-999 sub ModReserveFill { Link Here
993
1088
994
=head2 ModReserveStatus
1089
=head2 ModReserveStatus
995
1090
996
  &ModReserveStatus($itemnumber, $newstatus);
1091
  &ModReserveStatus($itemnumber, $newstatus, $holdtype);
997
1092
998
Update the reserve status for the active (priority=0) reserve.
1093
Update the reserve status for the active (priority=0) reserve.
999
1094
Lines 1004-1015 $newstatus is the new status. Link Here
1004
=cut
1099
=cut
1005
1100
1006
sub ModReserveStatus {
1101
sub ModReserveStatus {
1007
1008
    #first : check if we have a reservation for this item .
1102
    #first : check if we have a reservation for this item .
1009
    my ($itemnumber, $newstatus) = @_;
1103
    my ($itemnumber, $newstatus) = @_;
1010
    my $dbh = C4::Context->dbh;
1104
    my $dbh = C4::Context->dbh;
1011
1105
1012
    my $now = dt_from_string;
1106
    my $now = dt_from_string;
1107
1013
    my $reserve = $dbh->selectrow_hashref(q{
1108
    my $reserve = $dbh->selectrow_hashref(q{
1014
        SELECT *
1109
        SELECT *
1015
        FROM reserves
1110
        FROM reserves
Lines 1017-1026 sub ModReserveStatus { Link Here
1017
            AND found IS NULL
1112
            AND found IS NULL
1018
            AND priority = 0
1113
            AND priority = 0
1019
    }, {}, $itemnumber);
1114
    }, {}, $itemnumber);
1020
    return unless $reserve;
1021
1115
1022
    my $lastpickupdate = GetLastPickupDate( $reserve );
1116
    return unless $reserve;
1117
    my $borrower = Koha::Patrons->find( $reserve->{borrowernumber} );
1118
    $borrower = $borrower->unblessed;
1119
    my $item = C4::Items::GetItem( $reserve->{itemnumber} );
1023
1120
1121
    my $lastpickupdate = GetLastPickupDate( $reserve, $item, $borrower );
1024
    my $query = q{
1122
    my $query = q{
1025
        UPDATE reserves
1123
        UPDATE reserves
1026
        SET found = ?,
1124
        SET found = ?,
Lines 1081-1092 sub ModReserveAffect { Link Here
1081
    $hold->itemnumber($itemnumber);
1179
    $hold->itemnumber($itemnumber);
1082
    $hold->set_waiting($transferToDo);
1180
    $hold->set_waiting($transferToDo);
1083
1181
1182
    my $item = C4::Items::GetItem( $itemnumber );
1183
    my $borrower = Koha::Patrons->find( $borrowernumber );
1184
    $borrower = $borrower->unblessed;
1185
    my $lastpickupdate = GetLastPickupDate( $hold, $item, $borrower );
1186
    warn $lastpickupdate;
1187
    my $query = "
1188
        UPDATE reserves
1189
        SET lastpickupdate = ?
1190
        WHERE borrowernumber = ?
1191
        AND itemnumber = ?
1192
    ";
1193
     $sth = $dbh->prepare($query);
1194
     $sth->execute( $lastpickupdate, $borrowernumber,$itemnumber);
1195
1084
    _koha_notify_reserve( $hold->reserve_id )
1196
    _koha_notify_reserve( $hold->reserve_id )
1085
      if ( !$transferToDo && !$already_on_shelf );
1197
      if ( !$transferToDo && !$already_on_shelf );
1086
1198
1087
    _FixPriority( { biblionumber => $biblionumber } );
1199
    _FixPriority( { biblionumber => $biblionumber } );
1088
1200
1089
    if ( C4::Context->preference("ReturnToShelvingCart") ) {
1201
        if ( C4::Context->preference("ReturnToShelvingCart") ) {
1090
        CartToShelf($itemnumber);
1202
        CartToShelf($itemnumber);
1091
    }
1203
    }
1092
1204
Lines 2025-2031 sub ReserveSlip { Link Here
2025
2137
2026
    return unless $hold;
2138
    return unless $hold;
2027
    my $reserve = $hold->unblessed;
2139
    my $reserve = $hold->unblessed;
2028
2140
warn Dumper($reserve);
2029
    return  C4::Letters::GetPreparedLetter (
2141
    return  C4::Letters::GetPreparedLetter (
2030
        module => 'circulation',
2142
        module => 'circulation',
2031
        letter_code => 'HOLD_SLIP',
2143
        letter_code => 'HOLD_SLIP',
(-)a/Koha/Hold.pm (-2 / +30 lines)
Lines 33-38 use Koha::Items; Link Here
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Old::Holds;
34
use Koha::Old::Holds;
35
use Koha::Calendar;
35
use Koha::Calendar;
36
use Koha::IssuingRules;
36
37
37
use base qw(Koha::Object);
38
use base qw(Koha::Object);
38
39
Lines 167-176 sub set_waiting { Link Here
167
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
168
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
168
169
169
    my $expirationdate = $today->clone;
170
    my $expirationdate = $today->clone;
170
    $expirationdate->add(days => $max_pickup_delay);
171
172
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
173
    my $item = Koha::Items->find( $self->itemnumber() );
174
    my $hold = Koha::Holds->find( $self->reserve_id );
175
#    my $lastpickupdate = C4::Reserves->GetLastPickupDate( $hold, $item, $patron);
176
177
    # Get the controlbranch
178
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
179
    my $hbr = C4::Context->preference('HomeOrHoldingBranch') || "homebranch";
180
    my $branchcode    = "*";
181
    if ( $controlbranch eq "ItemHomeLibrary" ) {
182
        $branchcode = $item->{$hbr};
183
    } elsif ( $controlbranch eq "PatronLibrary" ) {
184
        $branchcode = $patron->branchcode;
185
    }
186
187
     warn $branchcode;
188
     warn $patron->categorycode;
189
     warn $item->itype;
190
     my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
191
             branchcode   => $branchcode,
192
             categorycode => $patron->categorycode,
193
             itemtype     => $item->itype,
194
     });
195
196
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
197
        $expirationdate->add(days => $issuingrule->holdspickupwait);
198
    }
171
199
172
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
200
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
173
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
201
        $expirationdate = $calendar->days_forward( dt_from_string(), $issuingrule->{holdspickupwait} );
174
    }
202
    }
175
203
176
    # If patron's requested expiration date is prior to the
204
    # If patron's requested expiration date is prior to the
(-)a/Koha/IssuingRules.pm (-1 / +1 lines)
Lines 22-28 use Modern::Perl; Link Here
22
22
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Caches;
24
use Koha::Caches;
25
25
use Data::Dumper;
26
use Koha::IssuingRule;
26
use Koha::IssuingRule;
27
27
28
use base qw(Koha::Objects);
28
use base qw(Koha::Objects);
(-)a/admin/smart-rules.pl (+1 lines)
Lines 182-187 elsif ($op eq 'add') { Link Here
182
        maxonsiteissueqty             => $maxonsiteissueqty,
182
        maxonsiteissueqty             => $maxonsiteissueqty,
183
        renewalsallowed               => $renewalsallowed,
183
        renewalsallowed               => $renewalsallowed,
184
        renewalperiod                 => $renewalperiod,
184
        renewalperiod                 => $renewalperiod,
185
        holdspickupwait               => $holdspickupwait,
185
        norenewalbefore               => $norenewalbefore,
186
        norenewalbefore               => $norenewalbefore,
186
        auto_renew                    => $auto_renew,
187
        auto_renew                    => $auto_renew,
187
        no_auto_renewal_after         => $no_auto_renewal_after,
188
        no_auto_renewal_after         => $no_auto_renewal_after,
(-)a/circ/returns.pl (+1 lines)
Lines 422-427 if ( $messages->{'ResFound'}) { Link Here
422
422
423
        my $diffBranchSend = ($userenv_branch ne $reserve->{branchcode}) ? $reserve->{branchcode} : undef;
423
        my $diffBranchSend = ($userenv_branch ne $reserve->{branchcode}) ? $reserve->{branchcode} : undef;
424
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} );
424
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} );
425
        ModReserveStatus($reserve->{itemnumber}, 'W');
425
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
426
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
426
427
427
        my $patron = Koha::Patrons->find( $nextreservinfo );
428
        my $patron = Koha::Patrons->find( $nextreservinfo );
(-)a/circ/waitingreserves.pl (-27 / +26 lines)
Lines 27-37 use C4::Circulation; Link Here
27
use C4::Members;
27
use C4::Members;
28
use C4::Biblio;
28
use C4::Biblio;
29
use C4::Items;
29
use C4::Items;
30
use Date::Calc qw(
30
#use Date::Calc qw(
31
  Today
31
#  Today
32
  Add_Delta_Days
32
#  Add_Delta_Days
33
  Date_to_Days
33
#  Date_to_Days
34
);
34
#);
35
use C4::Reserves;
35
use C4::Reserves;
36
use C4::Koha;
36
use C4::Koha;
37
use Koha::DateUtils;
37
use Koha::DateUtils;
Lines 39-44 use Koha::BiblioFrameworks; Link Here
39
use Koha::Items;
39
use Koha::Items;
40
use Koha::ItemTypes;
40
use Koha::ItemTypes;
41
use Koha::Patrons;
41
use Koha::Patrons;
42
use Data::Dumper;
42
43
43
my $input = new CGI;
44
my $input = new CGI;
44
45
Lines 87-110 my ($reservcount, $overcount); Link Here
87
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] });
88
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] });
88
# get reserves for the branch we are logged into, or for all branches
89
# get reserves for the branch we are logged into, or for all branches
89
90
90
my $today = Date_to_Days(&Today);
91
#my $today = Date_to_Days(&Today);
92
my $today = dt_from_string;
91
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay');
93
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay');
92
94
93
while ( my $hold = $holds->next ) {
95
while ( my $hold = $holds->next ) {
94
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
96
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
95
96
    my $item = $hold->item;
97
    my $item = $hold->item;
97
    my $patron = $hold->borrower;
98
    my $patron = $hold->borrower;
98
    my $biblio = $item->biblio;
99
    my $biblio = $item->biblio;
99
    my $holdingbranch = $item->holdingbranch;
100
    my $holdingbranch = $item->holdingbranch;
100
    my $homebranch = $item->homebranch;
101
    my $homebranch = $item->homebranch;
101
102
    my %getreserv = (
102
    my %getreserv = (
103
        title             => $biblio->title,
103
        title             => $biblio->title,
104
        itemnumber        => $item->itemnumber,
104
        itemnumber        => $item->itemnumber,
105
        waitingdate       => $hold->waitingdate,
105
        waitingdate       => $hold->waitingdate,
106
        reservedate       => $hold->reservedate,
106
        reservedate       => $hold->reservedate,
107
        borrowernum       => $patron->borrowernumber,
107
        borrowernumber       => $patron->borrowernumber,
108
        biblionumber      => $biblio->biblionumber,
108
        biblionumber      => $biblio->biblionumber,
109
        barcode           => $item->barcode,
109
        barcode           => $item->barcode,
110
        homebranch        => $homebranch,
110
        homebranch        => $homebranch,
Lines 119-127 while ( my $hold = $holds->next ) { Link Here
119
    );
119
    );
120
120
121
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
121
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
122
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
123
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
124
125
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
122
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
126
    $getreserv{'subtitle'}       = GetRecordValue(
123
    $getreserv{'subtitle'}       = GetRecordValue(
127
        'subtitle',
124
        'subtitle',
Lines 132-152 while ( my $hold = $holds->next ) { Link Here
132
    }
129
    }
133
130
134
    $getreserv{patron} = $patron;
131
    $getreserv{patron} = $patron;
135
132
    warn $getreserv{'waitingdate'};
136
    if ($today > $calcDate) {
133
    warn $getreserv{'lastpickupdate'};
137
        if ($cancelall) {
134
    if ( $getreserv{'waitingdate'} ) {
138
            my $res = cancel( $item->itemnumber, $patron->borrowernumber, $holdingbranch, $homebranch, !$transfer_when_cancel_all );
135
        my $lastpickupdate = dt_from_string($getreserv{'lastpickupdate'});
139
            push @cancel_result, $res if $res;
136
        if ( DateTime->compare( $today, $lastpickupdate ) == 1 ) {
140
            next;
137
            if ($cancelall) {
141
        } else {
138
                my $res = cancel( $item->itemnumber, $patron->borrowernumber, $item->holdingbranch, $homebranch, !$transfer_when_cancel_all );
142
            push @overloop,   \%getreserv;
139
                push @cancel_result, $res if $res;
143
            $overcount++;
140
                next;
141
            } else {
142
                push @overloop,   \%getreserv;
143
                $overcount++;
144
            }
145
        }else{
146
            push @reservloop, \%getreserv;
147
            $reservcount++;
144
        }
148
        }
145
    }else{
146
        push @reservloop, \%getreserv;
147
        $reservcount++;
148
    }
149
    }
149
    
150
}
150
}
151
151
152
$template->param(cancel_result => \@cancel_result) if @cancel_result;
152
$template->param(cancel_result => \@cancel_result) if @cancel_result;
Lines 159-165 $template->param( Link Here
159
    show_date   => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
159
    show_date   => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
160
    ReservesMaxPickUpDelay => $max_pickup_delay,
160
    ReservesMaxPickUpDelay => $max_pickup_delay,
161
    tab => $tab,
161
    tab => $tab,
162
    show_date   => format_date(C4::Dates->today('iso')),
162
    show_date   => $today,
163
);
163
);
164
164
165
# Checking if there is a Fast Cataloging Framework
165
# Checking if there is a Fast Cataloging Framework
Lines 181-187 sub cancel { Link Here
181
    my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo;
181
    my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo;
182
182
183
    return if $transfer && $skip_transfers;
183
    return if $transfer && $skip_transfers;
184
185
    my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
184
    my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
186
185
187
# 	if the document is not in his homebranch location and there is not reservation after, we transfer it
186
# 	if the document is not in his homebranch location and there is not reservation after, we transfer it
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (+1 lines)
Lines 172-177 Link Here
172
                            <td>[% rule.suspension_chargeperiod | html %]</td>
172
                            <td>[% rule.suspension_chargeperiod | html %]</td>
173
							<td>[% rule.renewalsallowed | html %]</td>
173
							<td>[% rule.renewalsallowed | html %]</td>
174
                            <td>[% rule.renewalperiod | html %]</td>
174
                            <td>[% rule.renewalperiod | html %]</td>
175
                            <td>[% rule.holdspickupwait | html %]</td>
175
                            <td>[% rule.norenewalbefore | html %]</td>
176
                            <td>[% rule.norenewalbefore | html %]</td>
176
                            <td>
177
                            <td>
177
                                [% IF ( rule.auto_renew ) %]
178
                                [% IF ( rule.auto_renew ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt (-2 / +2 lines)
Lines 71-77 Link Here
71
            [% IF ( reserveloop ) %]
71
            [% IF ( reserveloop ) %]
72
               <table id="holdst">
72
               <table id="holdst">
73
               <thead><tr>
73
               <thead><tr>
74
                    <th class="title-string">Waiting since</th>
74
                    <th class="title-string">Available since-until</th>
75
                    <th class="title-string">Date hold placed</th>
75
                    <th class="title-string">Date hold placed</th>
76
                    <th class="anti-the">Title</th>
76
                    <th class="anti-the">Title</th>
77
                    <th>Patron</th>
77
                    <th>Patron</th>
Lines 104-110 Link Here
104
                    <td>[% reserveloo.enumchron | html %]</td>
104
                    <td>[% reserveloo.enumchron | html %]</td>
105
                    <td>
105
                    <td>
106
                        <form name="cancelReserve" action="waitingreserves.pl" method="post">
106
                        <form name="cancelReserve" action="waitingreserves.pl" method="post">
107
                            <input type="hidden" name="borrowernumber" value="[% reserveloo.borrowernum | html %]" />
107
                            <input type="hidden" name="borrowernumber" value="[% reserveloo.patron.borrowernumber | html %]" />
108
                            <input type="hidden" name="itemnumber" value="[% reserveloo.itemnumber | html %]" />
108
                            <input type="hidden" name="itemnumber" value="[% reserveloo.itemnumber | html %]" />
109
                            <input type="hidden" name="fbr" value="[% reserveloo.holdingbranch | html %]" />
109
                            <input type="hidden" name="fbr" value="[% reserveloo.holdingbranch | html %]" />
110
                            <input type="hidden" name="tbr" value="[% reserveloo.homebranch | html %]" />
110
                            <input type="hidden" name="tbr" value="[% reserveloo.homebranch | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/smart-rules.tt (-16 / +16 lines)
Lines 7-29 Link Here
7
<p>The rules are applied from most specific to less specific, using the first found in this order:</p>
7
<p>The rules are applied from most specific to less specific, using the first found in this order:</p>
8
8
9
<ul>
9
<ul>
10
	<li>same library, same patron type, same item type</li>
10
 <li>same library, same patron type, same item type</li>
11
	<li>same library, same patron type, all item type</li>
11
 <li>same library, same patron type, all item type</li>
12
	<li>same library, all patron types, same item type</li>
12
 <li>same library, all patron types, same item type</li>
13
	<li>same library, all patron types, all item types</li>
13
 <li>same library, all patron types, all item types</li>
14
	<li>all libraries, same patron type, same item type</li>
14
 <li>all libraries, same patron type, same item type</li>
15
	<li>all libraries, same patron type, all item types</li>
15
 <li>all libraries, same patron type, all item types</li>
16
	<li>all libraries, all patron types, same item type</li>
16
 <li>all libraries, all patron types, same item type</li>
17
	<li>all libraries, all patron types, all item types</li>
17
 <li>all libraries, all patron types, all item types</li>
18
</ul>
18
</ul>
19
19
20
<p>The CircControl and HomeOrHoldingBranch also come in to play when figuring out which circulation rule to follow.</p>
20
<p>The CircControl and HomeOrHoldingBranch also come in to play when figuring out which circulation rule to follow.</p>
21
21
22
<ul>
22
<ul>
23
	<li>If CircControl is set to "the library you are logged in at" circ rules will be selected based on the library you are logged in at</li>
23
 <li>If CircControl is set to "the library you are logged in at" circ rules will be selected based on the library you are logged in at</li>
24
	<li>If CircControl is set to "the library the patron is from" circ rules will be selected based on the patron's library</li>
24
 <li>If CircControl is set to "the library the patron is from" circ rules will be selected based on the patron's library</li>
25
	<li>If CircControl is set to "the library the item is from" circ rules will be selected based on the item's library where HomeOrHoldingBranch chooses if item's home library is used or holding library is used.</li>
25
 <li>If CircControl is set to "the library the item is from" circ rules will be selected based on the item's library where HomeOrHoldingBranch chooses if item's home library is used or holding library is used.</li>
26
	<li>If IndependentBranches is set to 'Prevent' then the value of HomeOrHoldingBranch is used in figuring out if the item can be checked out. If the item's home library does not match the logged in library, the item cannot be checked out unless you are a superlibrarian.</li>
26
 <li>If IndependentBranches is set to 'Prevent' then the value of HomeOrHoldingBranch is used in figuring out if the item can be checked out. If the item's home library does not match the logged in library, the item cannot be checked out unless you are a superlibrarian.</li>
27
</ul>
27
</ul>
28
28
29
<p>If you are a single library system choose your branch name before creating rules (sometimes having only rules for the 'all libraries' option can cause issues with holds)</p>
29
<p>If you are a single library system choose your branch name before creating rules (sometimes having only rules for the 'all libraries' option can cause issues with holds)</p>
Lines 37-45 Link Here
37
<p>From the matrix you can choose any combination of patron categories and item types to apply the rules to</p>
37
<p>From the matrix you can choose any combination of patron categories and item types to apply the rules to</p>
38
38
39
<ul>
39
<ul>
40
	<li>First choose which patron category you'd like the rule to be applied to. If you leave this to 'All' it will apply to all patron categories</li>
40
 <li>First choose which patron category you'd like the rule to be applied to. If you leave this to 'All' it will apply to all patron categories</li>
41
	<li>Choose the 'Item Type' you would like this rule to apply to. If you leave this to 'All' it will apply to all item types</li>
41
 <li>Choose the 'Item Type' you would like this rule to apply to. If you leave this to 'All' it will apply to all item types</li>
42
	<li>Limit the number of items a patron can have checked out at the same time by entering a number in the 'Current Checkouts Allowed' field</li>
42
 <li>Limit the number of items a patron can have checked out at the same time by entering a number in the 'Current Checkouts Allowed' field</li>
43
    <li>Define the period of time an item can be checked out to a patron by entering the number of units (days or hours) in the 'Loan Period' box.</li>
43
    <li>Define the period of time an item can be checked out to a patron by entering the number of units (days or hours) in the 'Loan Period' box.</li>
44
    <li>Choose which unit of time, Days or Hours, that the loan period and fines will be calculate in</li>
44
    <li>Choose which unit of time, Days or Hours, that the loan period and fines will be calculate in</li>
45
    <li>You can also define a hard due date for a specific patron category and item type. A hard due date ignores your usual circulation rules and makes it so that all items of the type defined are due on, before or after the date you specify.</li>
45
    <li>You can also define a hard due date for a specific patron category and item type. A hard due date ignores your usual circulation rules and makes it so that all items of the type defined are due on, before or after the date you specify.</li>
Lines 119-125 Link Here
119
</li>
119
</li>
120
</ul>
120
</ul>
121
</li>
121
</li>
122
	<li>Once your policy is set, you can unset it by clicking the 'Unset' link to the right of the rule</li>
122
 <li>Once your policy is set, you can unset it by clicking the 'Unset' link to the right of the rule</li>
123
</ul>
123
</ul>
124
124
125
<h4>Checkouts Per Patron</h4>
125
<h4>Checkouts Per Patron</h4>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+1 lines)
Lines 730-735 Link Here
730
                                            <thead>
730
                                            <thead>
731
                                                <tr>
731
                                                <tr>
732
                                                    <th>Hold date</th>
732
                                                    <th>Hold date</th>
733
                                                    <th>Last pickup date</th>
733
                                                    <th>Title</th>
734
                                                    <th>Title</th>
734
                                                    <th>Call number</th>
735
                                                    <th>Call number</th>
735
                                                    <th>Barcode</th>
736
                                                    <th>Barcode</th>
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-1 / +3 lines)
Lines 18-23 $(document).ready(function() { Link Here
18
                        "mDataProp": "reservedate_formatted"
18
                        "mDataProp": "reservedate_formatted"
19
                    },
19
                    },
20
                    {
20
                    {
21
                        "mDataProp": "lastpickupdate_formatted"
22
                    },
23
                    {
21
                        "mDataProp": function ( oObj ) {
24
                        "mDataProp": function ( oObj ) {
22
                            title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber="
25
                            title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber="
23
                                  + oObj.biblionumber
26
                                  + oObj.biblionumber
24
- 

Return to bug 8367