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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 1884-1890 sub AddReturn { Link Here
1884
    # find reserves.....
1884
    # find reserves.....
1885
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1885
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1886
    my ($resfound, $resrec);
1886
    my ($resfound, $resrec);
1887
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ) unless ( $item->{'withdrawn'} );
1887
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
1888
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} );
1888
    if ($resfound) {
1889
    if ($resfound) {
1889
          $resrec->{'ResFound'} = $resfound;
1890
          $resrec->{'ResFound'} = $resfound;
1890
        $messages->{'ResFound'} = $resrec;
1891
        $messages->{'ResFound'} = $resrec;
(-)a/C4/Reserves.pm (-10 / +13 lines)
Lines 812-821 sub GetReserveStatus { Link Here
812
812
813
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
813
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
814
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
814
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
815
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber,undef,$lookahead);
815
816
816
Find a book in the reserves.
817
Find a book in the reserves.
817
818
818
C<$itemnumber> is the book's item number.
819
C<$itemnumber> is the book's item number.
820
C<$lookahead> is the number of days to look in advance for future reserves.
819
821
820
As I understand it, C<&CheckReserves> looks for the given item in the
822
As I understand it, C<&CheckReserves> looks for the given item in the
821
reserves. If it is found, that's a match, and C<$status> is set to
823
reserves. If it is found, that's a match, and C<$status> is set to
Lines 836-842 table in the Koha database. Link Here
836
=cut
838
=cut
837
839
838
sub CheckReserves {
840
sub CheckReserves {
839
    my ( $item, $barcode ) = @_;
841
    my ( $item, $barcode, $lookahead_days) = @_;
840
    my $dbh = C4::Context->dbh;
842
    my $dbh = C4::Context->dbh;
841
    my $sth;
843
    my $sth;
842
    my $select;
844
    my $select;
Lines 883-889 sub CheckReserves { Link Here
883
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
885
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
884
886
885
    # Find this item in the reserves
887
    # Find this item in the reserves
886
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber );
888
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days);
887
889
888
    # $priority and $highest are used to find the most important item
890
    # $priority and $highest are used to find the most important item
889
    # in the list returned by &_Findgroupreserve. (The lower $priority,
891
    # in the list returned by &_Findgroupreserve. (The lower $priority,
Lines 1706-1716 sub _FixPriority { Link Here
1706
1708
1707
=head2 _Findgroupreserve
1709
=head2 _Findgroupreserve
1708
1710
1709
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber);
1711
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead);
1710
1712
1711
Looks for an item-specific match first, then for a title-level match, returning the
1713
Looks for an item-specific match first, then for a title-level match, returning the
1712
first match found.  If neither, then we look for a 3rd kind of match based on
1714
first match found.  If neither, then we look for a 3rd kind of match based on
1713
reserve constraints.
1715
reserve constraints.
1716
Lookahead is the number of days to look in advance.
1714
1717
1715
TODO: add more explanation about reserve constraints
1718
TODO: add more explanation about reserve constraints
1716
1719
Lines 1722-1728 C<biblioitemnumber>. Link Here
1722
=cut
1725
=cut
1723
1726
1724
sub _Findgroupreserve {
1727
sub _Findgroupreserve {
1725
    my ( $bibitem, $biblio, $itemnumber ) = @_;
1728
    my ( $bibitem, $biblio, $itemnumber, $lookahead) = @_;
1726
    my $dbh   = C4::Context->dbh;
1729
    my $dbh   = C4::Context->dbh;
1727
1730
1728
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
1731
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
Lines 1747-1757 sub _Findgroupreserve { Link Here
1747
        AND priority > 0
1750
        AND priority > 0
1748
        AND item_level_request = 1
1751
        AND item_level_request = 1
1749
        AND itemnumber = ?
1752
        AND itemnumber = ?
1750
        AND reservedate <= CURRENT_DATE()
1753
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1751
        AND suspend = 0
1754
        AND suspend = 0
1752
    /;
1755
    /;
1753
    my $sth = $dbh->prepare($item_level_target_query);
1756
    my $sth = $dbh->prepare($item_level_target_query);
1754
    $sth->execute($itemnumber);
1757
    $sth->execute($itemnumber, $lookahead||0);
1755
    my @results;
1758
    my @results;
1756
    if ( my $data = $sth->fetchrow_hashref ) {
1759
    if ( my $data = $sth->fetchrow_hashref ) {
1757
        push( @results, $data );
1760
        push( @results, $data );
Lines 1778-1788 sub _Findgroupreserve { Link Here
1778
        AND priority > 0
1781
        AND priority > 0
1779
        AND item_level_request = 0
1782
        AND item_level_request = 0
1780
        AND hold_fill_targets.itemnumber = ?
1783
        AND hold_fill_targets.itemnumber = ?
1781
        AND reservedate <= CURRENT_DATE()
1784
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1782
        AND suspend = 0
1785
        AND suspend = 0
1783
    /;
1786
    /;
1784
    $sth = $dbh->prepare($title_level_target_query);
1787
    $sth = $dbh->prepare($title_level_target_query);
1785
    $sth->execute($itemnumber);
1788
    $sth->execute($itemnumber, $lookahead||0);
1786
    @results = ();
1789
    @results = ();
1787
    if ( my $data = $sth->fetchrow_hashref ) {
1790
    if ( my $data = $sth->fetchrow_hashref ) {
1788
        push( @results, $data );
1791
        push( @results, $data );
Lines 1810-1820 sub _Findgroupreserve { Link Here
1810
          AND reserves.reservedate    = reserveconstraints.reservedate )
1813
          AND reserves.reservedate    = reserveconstraints.reservedate )
1811
          OR  reserves.constrainttype='a' )
1814
          OR  reserves.constrainttype='a' )
1812
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1815
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1813
          AND reserves.reservedate <= CURRENT_DATE()
1816
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1814
          AND suspend = 0
1817
          AND suspend = 0
1815
    /;
1818
    /;
1816
    $sth = $dbh->prepare($query);
1819
    $sth = $dbh->prepare($query);
1817
    $sth->execute( $biblio, $bibitem, $itemnumber );
1820
    $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0);
1818
    @results = ();
1821
    @results = ();
1819
    while ( my $data = $sth->fetchrow_hashref ) {
1822
    while ( my $data = $sth->fetchrow_hashref ) {
1820
        push( @results, $data );
1823
        push( @results, $data );
(-)a/circ/pendingreserves.pl (-11 / +14 lines)
Lines 25-30 Link Here
25
25
26
use strict;
26
use strict;
27
#use warnings; FIXME - Bug 2505
27
#use warnings; FIXME - Bug 2505
28
29
use constant TWO_DAYS => 2;
30
use constant TWO_DAYS_AGO => -2;
31
28
use C4::Context;
32
use C4::Context;
29
use C4::Output;
33
use C4::Output;
30
use CGI;
34
use CGI;
Lines 66-91 my $author; Link Here
66
70
67
my ( $year, $month, $day ) = Today();
71
my ( $year, $month, $day ) = Today();
68
my $todaysdate     = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
72
my $todaysdate     = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
69
my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day,   0, 0, -1));
70
# changed from delivered range of 10 years-yesterday to 2 days ago-today
71
# Find two days ago for the default shelf pull start and end dates, unless HoldsToPullStartDate sys pref is set.
72
my $defaultstartdate = ( C4::Context->preference('HoldsToPullStartDate') ) ? "-".C4::Context->preference('HoldsToPullStartDate') : -2;
73
my $pastdate       = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, $defaultstartdate));
74
75
# Predefine the start and end dates if they are not already defined
76
$startdate =~ s/^\s+//;
73
$startdate =~ s/^\s+//;
77
$startdate =~ s/\s+$//;
74
$startdate =~ s/\s+$//;
78
$enddate =~ s/^\s+//;
75
$enddate =~ s/^\s+//;
79
$enddate =~ s/\s+$//;
76
$enddate =~ s/\s+$//;
80
# Check if null, should string match, if so set start and end date to yesterday
77
81
if (!defined($startdate) or $startdate eq "") {
78
if (!defined($startdate) or $startdate eq "") {
79
    # changed from delivered range of 10 years-yesterday to 2 days ago-today
80
    # Find two days ago for the default shelf pull start date, unless HoldsToPullStartDate sys pref is set.
81
    my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO ));
82
    $startdate = format_date($pastdate);
82
    $startdate = format_date($pastdate);
83
}
83
}
84
84
if (!defined($enddate) or $enddate eq "") {
85
if (!defined($enddate) or $enddate eq "") {
85
    $enddate = format_date($todaysdate);
86
    #similarly: calculate end date with ConfirmFutureHolds (days)
87
    my $d=sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, C4::Context->preference('ConfirmFutureHolds')||0 ));
88
    $enddate = format_date($d);
86
}
89
}
87
90
88
89
my @reservedata;
91
my @reservedata;
90
if ( $run_report ) {
92
if ( $run_report ) {
91
    my $dbh    = C4::Context->dbh;
93
    my $dbh    = C4::Context->dbh;
Lines 202-208 $template->param( Link Here
202
    run_report          => $run_report,
204
    run_report          => $run_report,
203
    reserveloop         => \@reservedata,
205
    reserveloop         => \@reservedata,
204
    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
206
    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
205
    HoldsToPullStartDate        => (C4::Context->preference('HoldsToPullStartDate')?C4::Context->preference('HoldsToPullStartDate'):2),
207
    HoldsToPullStartDate=> C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS,
208
    HoldsToPullEndDate  => C4::Context->preference('ConfirmFutureHolds')||0,
206
);
209
);
207
210
208
output_html_with_http_headers $input, $cookie, $template->output;
211
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 61-67 Circulation: Link Here
61
            - Set the default start date for the Holds to pull list to
61
            - Set the default start date for the Holds to pull list to
62
            - pref: HoldsToPullStartDate
62
            - pref: HoldsToPullStartDate
63
              class: integer
63
              class: integer
64
            - day(s) ago.
64
            - day(s) ago. Note that the default end date is controlled by preference ConfirmFutureHolds.
65
        -
65
        -
66
            - pref: AllowAllMessageDeletion
66
            - pref: AllowAllMessageDeletion
67
              choices:
67
              choices:
Lines 370-375 Circulation: Link Here
370
                  no: "Don't allow"
370
                  no: "Don't allow"
371
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
371
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
372
        -
372
        -
373
            - Confirm future hold requests at checkin within
374
            - pref: ConfirmFutureHolds
375
              class: integer
376
            - day(s). Note that this number of days will be used too in calculating the default end date for the Holds to pull-report. (As may be obvious, use of this preference becomes useful only when allowing future holds.
377
        -
373
            - Check the
378
            - Check the
374
            - pref: ReservesControlBranch
379
            - pref: ReservesControlBranch
375
              choices:
380
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-2 / +1 lines)
Lines 174-180 $(document).ready(function() { Link Here
174
<input type="text" size="10" id="to" name="to" value="[% to %]" class="datepickerto" />
174
<input type="text" size="10" id="to" name="to" value="[% to %]" class="datepickerto" />
175
</li>
175
</li>
176
</ol>
176
</ol>
177
<p><i>(Inclusive, default is [% HoldsToPullStartDate %] days ago to today, set other date ranges as needed. )</i></p>
177
<p><i>(Inclusive, default is [% HoldsToPullStartDate %] days ago to [% IF ( HoldsToPullEndDate ) %][% HoldsToPullEndDate %] days ahead[% ELSE %]today[% END %], set other date ranges as needed. )</i></p>
178
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
178
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
179
</fieldset>
179
</fieldset>
180
</form>
180
</form>
181
- 

Return to bug 9761