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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 2005-2011 sub AddReturn { Link Here
2005
        }
2005
        }
2006
        $validTransfert = 1;
2006
        $validTransfert = 1;
2007
    }
2007
    }
2008
2009
    # fix up the accounts.....
2008
    # fix up the accounts.....
2010
    if ( $item->itemlost ) {
2009
    if ( $item->itemlost ) {
2011
        $messages->{'WasLost'} = 1;
2010
        $messages->{'WasLost'} = 1;
Lines 2061-2068 sub AddReturn { Link Here
2061
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2060
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
2062
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2061
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn );
2063
    if ($resfound) {
2062
    if ($resfound) {
2064
          $resrec->{'ResFound'} = $resfound;
2063
        $resrec->{'ResFound'} = $resfound;
2065
        $messages->{'ResFound'} = $resrec;
2064
        $messages->{'ResFound'} = $resrec;
2065
        C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2066
    }
2066
    }
2067
2067
2068
    # Record the fact that this book was returned.
2068
    # Record the fact that this book was returned.
(-)a/C4/Letters.pm (-5 / +7 lines)
Lines 786-800 sub _parseletter { Link Here
786
786
787
    # Work on a local copy of $values_in (passed by reference) to avoid side effects
787
    # Work on a local copy of $values_in (passed by reference) to avoid side effects
788
    # in callers ( by changing / formatting values )
788
    # in callers ( by changing / formatting values )
789
    my $values = $values_in ? { %$values_in } : {};
789
   my $values = $values_in ? { %$values_in } : {};
790
790
791
    if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){
791
    if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){
792
        $values->{'dateexpiry'} = output_pref({ dt => dt_from_string( $values->{'dateexpiry'} ), dateonly => 1 });
792
        $values->{'dateexpiry'} = output_pref({ dt => dt_from_string( $values->{'dateexpiry'} ), dateonly => 1 });
793
    }
793
    }
794
794
795
    if ( $table eq 'reserves' && $values->{'waitingdate'} ) {
795
# if ( $table eq 'reserves' && $values->{'waitingdate'}) {
796
        $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 });
796
#      $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 });
797
    }
797
#  }
798
798
799
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
799
    if ($letter->{content} && $letter->{content} =~ /<<today>>/) {
800
        my $todaysdate = output_pref( DateTime->now() );
800
        my $todaysdate = output_pref( DateTime->now() );
Lines 811-817 sub _parseletter { Link Here
811
            my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $val });
811
            my $av = Koha::AuthorisedValues->search({ category => 'ROADTYPE', authorised_value => $val });
812
            $val = $av->count ? $av->next->lib : '';
812
            $val = $av->count ? $av->next->lib : '';
813
        }
813
        }
814
814
warn $table;
815
warn $field;
816
warn $val;
815
        # Dates replacement
817
        # Dates replacement
816
        my $replacedby   = defined ($val) ? $val : '';
818
        my $replacedby   = defined ($val) ? $val : '';
817
        if (    $replacedby
819
        if (    $replacedby
(-)a/C4/Reserves.pm (-10 / +122 lines)
Lines 120-126 BEGIN { Link Here
120
        &CanItemBeReserved
120
        &CanItemBeReserved
121
        &CanReserveBeCanceledFromOpac
121
        &CanReserveBeCanceledFromOpac
122
        &CancelExpiredReserves
122
        &CancelExpiredReserves
123
124
        &AutoUnsuspendReserves
123
        &AutoUnsuspendReserves
125
124
126
        &IsAvailableForItemLevelRequest
125
        &IsAvailableForItemLevelRequest
Lines 194-205 sub AddReserve { Link Here
194
193
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.
194
        #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.
196
        my $reserve = {borrowernumber => $borrowernumber, waitingdate => $waitingdate, branchcode => $branch};
195
        my $reserve = {borrowernumber => $borrowernumber, waitingdate => $waitingdate, branchcode => $branch};
197
        $lastpickupdate = GetLastPickupDate( $reserve, $item );
196
        my $patron = Koha::Patrons->find( {borrowernumber => $borrowernumber} );
197
        $lastpickupdate = GetLastPickupDate( $reserve, $item, $patron );
198
    }
198
    }
199
200
    # Don't add itemtype limit if specific item is selected
199
    # Don't add itemtype limit if specific item is selected
201
    $itemtype = undef if $checkitem;
200
    $itemtype = undef if $checkitem;
202
203
    # updates take place here
201
    # updates take place here
204
    my $hold = Koha::Hold->new(
202
    my $hold = Koha::Hold->new(
205
        {
203
        {
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 666-671 sub GetReserveStatus { Link Here
666
    return ''; # empty string here will remove need for checking undef, or less log lines
663
    return ''; # empty string here will remove need for checking undef, or less log lines
667
}
664
}
668
665
666
667
=head2 GetLastPickupDate
668
669
  my $lastpickupdate = GetLastPickupDate($reserve, $item);
670
  my $lastpickupdate = GetLastPickupDate($reserve, $item, $borrower);
671
  my $lastpickupdate = GetLastPickupDate(undef,    $item);
672
673
  Gets the last pickup date from the issuingrules for the given reserves-row and sets the
674
  $reserve->{lastpickupdate}.-value.
675
676
  If the reserves-row is not passed, function tries to figure it out from the item-row.
677
  Calculating the last pickup date respects Calendar holidays and skips to the next open day.
678
  If the issuingrule's holdspickupwait is 0 or less, means that the lastpickupdate-feature
679
  is disabled for this kind of material.
680
681
  @PARAM1 koha.reserves-row
682
  @PARAM2 koha.items-row, If the reserve is not given, an item must be given to be
683
  able to find a reservation
684
  @PARAM3 koha.borrowers-row, OPTIONAL
685
  RETURNS DateTime, depicting the last pickup date.
686
  OR undef if there is an error or if the issuingrules disable this feature for this material.
687
688
=cut
689
690
sub GetLastPickupDate {
691
    my ($reserve, $item, $borrower) = @_;
692
    ##Verify parameters
693
    if ( not defined $reserve and not defined $item ) {
694
        warn "C4::Reserves::GetMaxPickupDate(), is called without a reserve and an item";
695
        return;
696
    }
697
    if ( defined $reserve and not defined $item ) {
698
        $item = C4::Items::GetItem( $reserve->{itemnumber} );
699
    }
700
701
    unless ( defined $borrower) {
702
        my $borrower = Koha::Patrons->find( $reserve->{borrowernumber} );
703
        $borrower = $borrower->unblessed;
704
    }
705
706
    unless ( defined $reserve ) {
707
        my $reserve = GetReservesFromItemnumber( $item->{itemnumber} );
708
    }
709
    my $date = $reserve->{waitingdate};
710
    unless ( $date ) { #It is possible that a reserve is just caught and it doesn't have a waitingdate yet.
711
       $date = DateTime->now( time_zone => C4::Context->tz() ); #So default to NOW()
712
    }
713
    else {
714
       $date = (ref $reserve->{waitingdate} eq 'DateTime') ? $reserve->{waitingdate}  :  dt_from_string($reserve->{waitingdate});
715
    }
716
    ##Get churning the LastPickupDate
717
718
    # Get the controlbranch
719
    my $controlbranch = GetReservesControlBranch( $item, $borrower );
720
    my $hbr = C4::Context->preference('HomeOrHoldingBranch') || "homebranch";
721
    my $branchcode    = "*";
722
    if ( $controlbranch eq "ItemHomeLibrary" ) {
723
         $branchcode = $item->{$hbr};
724
    } elsif ( $controlbranch eq "PatronLibrary" ) {
725
         $branchcode = $borrower->branchcode;
726
    }
727
    warn 'getlastpickup';
728
    warn $branchcode;
729
    warn $borrower->{'categorycode'};
730
    warn $item->{itype};
731
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
732
            branchcode   => $branchcode,
733
            categorycode => $borrower->{'categorycode'},
734
            itemtype     => $item->{itype},
735
    });
736
737
    my $reservebranch;
738
    if ($reserve->{'branchcode'}) {
739
        $reservebranch = $reserve->{'branchcode'};
740
    } else {
741
        $reservebranch = $reserve->branchcode;
742
    }
743
    if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) { #If holdspickupwait is <= 0, it means this feature is disabled for this type of material.
744
        $date->add( days => $issuingrule->holdspickupwait );
745
        my $calendar = Koha::Calendar->new( branchcode => $reservebranch );
746
        my $is_holiday = $calendar->is_holiday( $date );
747
        while ( $is_holiday ) {
748
               $date->add( days => 1 );
749
               $is_holiday = $calendar->is_holiday( $date );
750
        }
751
        $reserve->{lastpickupdate} = $date->ymd();
752
        return $date;
753
     }
754
     #Without explicitly setting the return value undef, the lastpickupdate-column is
755
     #  set as 0000-00-00 instead of NULL in DBD::MySQL.
756
     #This causes this hold to always expire any lastpickupdate check,
757
     ##  effectively canceling it as soon as cancel_expired_holds.pl is ran.
758
     ##This is exactly the opposite of disabling the autoexpire feature.
759
     ##So please let me explicitly return undef, because Perl cant always handle everything.
760
     delete $reserve->{lastpickupdate};
761
     return undef;
762
}
763
669
=head2 CheckReserves
764
=head2 CheckReserves
670
765
671
  ($status, $matched_reserve, $possible_reserves) = &CheckReserves($itemnumber);
766
  ($status, $matched_reserve, $possible_reserves) = &CheckReserves($itemnumber);
Lines 1011-1017 sub ModReserveFill { Link Here
1011
1106
1012
=head2 ModReserveStatus
1107
=head2 ModReserveStatus
1013
1108
1014
  &ModReserveStatus($itemnumber, $newstatus);
1109
  &ModReserveStatus($itemnumber, $newstatus, $holdtype);
1015
1110
1016
Update the reserve status for the active (priority=0) reserve.
1111
Update the reserve status for the active (priority=0) reserve.
1017
1112
Lines 1022-1033 $newstatus is the new status. Link Here
1022
=cut
1117
=cut
1023
1118
1024
sub ModReserveStatus {
1119
sub ModReserveStatus {
1025
1026
    #first : check if we have a reservation for this item .
1120
    #first : check if we have a reservation for this item .
1027
    my ($itemnumber, $newstatus) = @_;
1121
    my ($itemnumber, $newstatus) = @_;
1028
    my $dbh = C4::Context->dbh;
1122
    my $dbh = C4::Context->dbh;
1029
1123
1030
    my $now = dt_from_string;
1124
    my $now = dt_from_string;
1125
1031
    my $reserve = $dbh->selectrow_hashref(q{
1126
    my $reserve = $dbh->selectrow_hashref(q{
1032
        SELECT *
1127
        SELECT *
1033
        FROM reserves
1128
        FROM reserves
Lines 1035-1044 sub ModReserveStatus { Link Here
1035
            AND found IS NULL
1130
            AND found IS NULL
1036
            AND priority = 0
1131
            AND priority = 0
1037
    }, {}, $itemnumber);
1132
    }, {}, $itemnumber);
1038
    return unless $reserve;
1039
1133
1040
    my $lastpickupdate = GetLastPickupDate( $reserve );
1134
    return unless $reserve;
1135
    my $borrower = Koha::Patrons->find( $reserve->{borrowernumber} );
1136
    $borrower = $borrower->unblessed;
1137
    my $item = C4::Items::GetItem( $reserve->{itemnumber} );
1041
1138
1139
    my $lastpickupdate = GetLastPickupDate( $reserve, $item, $borrower );
1042
    my $query = q{
1140
    my $query = q{
1043
        UPDATE reserves
1141
        UPDATE reserves
1044
        SET found = ?,
1142
        SET found = ?,
Lines 1100-1105 sub ModReserveAffect { Link Here
1100
    $hold->itemnumber($itemnumber);
1198
    $hold->itemnumber($itemnumber);
1101
    $hold->set_waiting($transferToDo);
1199
    $hold->set_waiting($transferToDo);
1102
1200
1201
    my $item = C4::Items::GetItem( $itemnumber );
1202
    my $borrower = Koha::Patrons->find( $borrowernumber );
1203
    $borrower = $borrower->unblessed;
1204
    my $lastpickupdate = GetLastPickupDate( $hold, $item, $borrower );
1205
    warn $lastpickupdate;
1206
    my $query = "
1207
        UPDATE reserves
1208
        SET lastpickupdate = ?
1209
        WHERE borrowernumber = ?
1210
        AND itemnumber = ?
1211
    ";
1212
     $sth = $dbh->prepare($query);
1213
     $sth->execute( $lastpickupdate, $borrowernumber,$itemnumber);
1214
1103
    _koha_notify_reserve( $hold->reserve_id )
1215
    _koha_notify_reserve( $hold->reserve_id )
1104
      if ( !$transferToDo && !$already_on_shelf );
1216
      if ( !$transferToDo && !$already_on_shelf );
1105
1217
Lines 2057-2063 sub ReserveSlip { Link Here
2057
2169
2058
    return unless $hold;
2170
    return unless $hold;
2059
    my $reserve = $hold->unblessed;
2171
    my $reserve = $hold->unblessed;
2060
2172
warn Dumper($reserve);
2061
    return  C4::Letters::GetPreparedLetter (
2173
    return  C4::Letters::GetPreparedLetter (
2062
        module => 'circulation',
2174
        module => 'circulation',
2063
        letter_code => 'HOLD_SLIP',
2175
        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 Koha::Exceptions::Hold;
38
use Koha::Exceptions::Hold;
38
39
Lines 181-190 sub set_waiting { Link Here
181
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
182
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
182
183
183
    my $expirationdate = $today->clone;
184
    my $expirationdate = $today->clone;
184
    $expirationdate->add(days => $max_pickup_delay);
185
186
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
187
    my $item = Koha::Items->find( $self->itemnumber() );
188
    my $hold = Koha::Holds->find( $self->reserve_id );
189
#    my $lastpickupdate = C4::Reserves->GetLastPickupDate( $hold, $item, $patron);
190
191
    # Get the controlbranch
192
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
193
    my $hbr = C4::Context->preference('HomeOrHoldingBranch') || "homebranch";
194
    my $branchcode    = "*";
195
    if ( $controlbranch eq "ItemHomeLibrary" ) {
196
        $branchcode = $item->{$hbr};
197
    } elsif ( $controlbranch eq "PatronLibrary" ) {
198
        $branchcode = $patron->branchcode;
199
    }
200
201
     warn $branchcode;
202
     warn $patron->categorycode;
203
     warn $item->itype;
204
     my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
205
             branchcode   => $branchcode,
206
             categorycode => $patron->categorycode,
207
             itemtype     => $item->itype,
208
     });
209
210
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
211
        $expirationdate->add(days => $issuingrule->holdspickupwait);
212
    }
185
213
186
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
214
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
187
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
215
        $expirationdate = $calendar->days_forward( dt_from_string(), $issuingrule->{holdspickupwait} );
188
    }
216
    }
189
217
190
    # If patron's requested expiration date is prior to the
218
    # 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 278-283 elsif ($op eq 'add') { Link Here
278
        chargeperiod_charge_at        => $chargeperiod_charge_at,
278
        chargeperiod_charge_at        => $chargeperiod_charge_at,
279
        renewalsallowed               => $renewalsallowed,
279
        renewalsallowed               => $renewalsallowed,
280
        renewalperiod                 => $renewalperiod,
280
        renewalperiod                 => $renewalperiod,
281
        holdspickupwait               => $holdspickupwait,
281
        norenewalbefore               => $norenewalbefore,
282
        norenewalbefore               => $norenewalbefore,
282
        auto_renew                    => $auto_renew,
283
        auto_renew                    => $auto_renew,
283
        no_auto_renewal_after         => $no_auto_renewal_after,
284
        no_auto_renewal_after         => $no_auto_renewal_after,
(-)a/circ/returns.pl (+1 lines)
Lines 424-429 if ( $messages->{'ResFound'}) { Link Here
424
424
425
        my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef;
425
        my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef;
426
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} );
426
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} );
427
        ModReserveStatus($reserve->{itemnumber}, 'W');
427
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
428
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
428
429
429
        my $patron = Koha::Patrons->find( $nextreservinfo );
430
        my $patron = Koha::Patrons->find( $nextreservinfo );
(-)a/circ/waitingreserves.pl (-24 / +36 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-109 my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : Link Here
87
88
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 = dt_from_string;
92
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay');
91
93
92
while ( my $hold = $holds->next ) {
94
while ( my $hold = $holds->next ) {
93
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
95
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
94
95
    my $item = $hold->item;
96
    my $item = $hold->item;
96
    my $patron = $hold->borrower;
97
    my $patron = $hold->borrower;
97
    my $biblio = $item->biblio;
98
    my $biblio = $item->biblio;
98
    my $holdingbranch = $item->holdingbranch;
99
    my $holdingbranch = $item->holdingbranch;
99
    my $homebranch = $item->homebranch;
100
    my $homebranch = $item->homebranch;
100
101
    my %getreserv = (
101
    my %getreserv = (
102
        title             => $biblio->title,
102
        title             => $biblio->title,
103
        itemnumber        => $item->itemnumber,
103
        itemnumber        => $item->itemnumber,
104
        waitingdate       => $hold->waitingdate,
104
        waitingdate       => $hold->waitingdate,
105
        reservedate       => $hold->reservedate,
105
        reservedate       => $hold->reservedate,
106
        borrowernum       => $patron->borrowernumber,
106
        borrowernumber       => $patron->borrowernumber,
107
        biblionumber      => $biblio->biblionumber,
107
        biblionumber      => $biblio->biblionumber,
108
        barcode           => $item->barcode,
108
        barcode           => $item->barcode,
109
        homebranch        => $homebranch,
109
        homebranch        => $homebranch,
Lines 118-138 while ( my $hold = $holds->next ) { Link Here
118
    );
118
    );
119
119
120
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
120
    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
121
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
121
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
122
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
122
    $getreserv{'subtitle'}       = GetRecordValue(
123
123
        'subtitle',
124
    if ($today > $calcDate) {
124
        GetMarcBiblio({ biblionumber => $biblio->biblionumber }),
125
        if ($cancelall) {
125
        $biblio->frameworkcode);
126
            my $res = cancel( $hold->item->itemnumber, $hold->borrowernumber, $hold->item->holdingbranch, $hold->item->homebranch, !$transfer_when_cancel_all );
126
    if ( $homebranch ne $holdingbranch ) {
127
            push @cancel_result, $res if $res;
127
        $getreserv{'dotransfer'} = 1;
128
            next;
128
    }
129
        } else {
129
130
            push @over_loop, $hold;
130
    $getreserv{patron} = $patron;
131
    warn $getreserv{'waitingdate'};
132
    warn $getreserv{'lastpickupdate'};
133
    if ( $getreserv{'waitingdate'} ) {
134
        my $lastpickupdate = dt_from_string($getreserv{'lastpickupdate'});
135
        if ( DateTime->compare( $today, $lastpickupdate ) == 1 ) {
136
            if ($cancelall) {
137
                my $res = cancel( $item->itemnumber, $patron->borrowernumber, $item->holdingbranch, $homebranch, !$transfer_when_cancel_all );
138
                push @cancel_result, $res if $res;
139
                next;
140
            } else {
141
                push @overloop,   \%getreserv;
142
                $overcount++;
143
            }
144
        }else{
145
            push @reservloop, \%getreserv;
146
            $reservcount++;
131
        }
147
        }
132
    }else{
133
        push @reserve_loop, $hold;
134
    }
148
    }
135
    
136
}
149
}
137
150
138
$template->param(cancel_result => \@cancel_result) if @cancel_result;
151
$template->param(cancel_result => \@cancel_result) if @cancel_result;
Lines 144-150 $template->param( Link Here
144
    overcount   => scalar @over_loop,
157
    overcount   => scalar @over_loop,
145
    show_date   => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
158
    show_date   => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
146
    tab => $tab,
159
    tab => $tab,
147
    show_date   => format_date(C4::Dates->today('iso')),
160
    show_date   => $today,
148
);
161
);
149
162
150
# Checking if there is a Fast Cataloging Framework
163
# Checking if there is a Fast Cataloging Framework
Lines 166-172 sub cancel { Link Here
166
    my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo;
179
    my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo;
167
180
168
    return if $transfer && $skip_transfers;
181
    return if $transfer && $skip_transfers;
169
170
    my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
182
    my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber );
171
183
172
# 	if the document is not in his homebranch location and there is not reservation after, we transfer it
184
# 	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 196-201 Link Here
196
                            <td>[% rule.suspension_chargeperiod | html %]</td>
196
                            <td>[% rule.suspension_chargeperiod | html %]</td>
197
							<td>[% rule.renewalsallowed | html %]</td>
197
							<td>[% rule.renewalsallowed | html %]</td>
198
                            <td>[% rule.renewalperiod | html %]</td>
198
                            <td>[% rule.renewalperiod | html %]</td>
199
                            <td>[% rule.holdspickupwait | html %]</td>
199
                            <td>[% rule.norenewalbefore | html %]</td>
200
                            <td>[% rule.norenewalbefore | html %]</td>
200
                            <td>
201
                            <td>
201
                                [% IF ( rule.auto_renew ) %]
202
                                [% IF ( rule.auto_renew ) %]
(-)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 750-755 Link Here
750
                                            <thead>
750
                                            <thead>
751
                                                <tr>
751
                                                <tr>
752
                                                    <th>Hold date</th>
752
                                                    <th>Hold date</th>
753
                                                    <th>Last pickup date</th>
753
                                                    <th>Title</th>
754
                                                    <th>Title</th>
754
                                                    <th>Call number</th>
755
                                                    <th>Call number</th>
755
                                                    <th>Barcode</th>
756
                                                    <th>Barcode</th>
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-1 / +3 lines)
Lines 18-23 $(document).ready(function() { Link Here
18
                        "data": { _: "reservedate_formatted", "sort": "reservedate" }
18
                        "data": { _: "reservedate_formatted", "sort": "reservedate" }
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