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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 1876-1882 sub AddReturn { Link Here
1876
    # find reserves.....
1876
    # find reserves.....
1877
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1877
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1878
    my ($resfound, $resrec);
1878
    my ($resfound, $resrec);
1879
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ) unless ( $item->{'wthdrawn'} );
1879
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
1880
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'wthdrawn'} );
1880
    if ($resfound) {
1881
    if ($resfound) {
1881
          $resrec->{'ResFound'} = $resfound;
1882
          $resrec->{'ResFound'} = $resfound;
1882
        $messages->{'ResFound'} = $resrec;
1883
        $messages->{'ResFound'} = $resrec;
(-)a/C4/Reserves.pm (-10 / +13 lines)
Lines 775-784 sub GetReserveStatus { Link Here
775
775
776
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
776
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
777
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
777
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
778
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber,undef,$lookahead);
778
779
779
Find a book in the reserves.
780
Find a book in the reserves.
780
781
781
C<$itemnumber> is the book's item number.
782
C<$itemnumber> is the book's item number.
783
C<$lookahead> is the number of days to look in advance for future reserves.
782
784
783
As I understand it, C<&CheckReserves> looks for the given item in the
785
As I understand it, C<&CheckReserves> looks for the given item in the
784
reserves. If it is found, that's a match, and C<$status> is set to
786
reserves. If it is found, that's a match, and C<$status> is set to
Lines 799-805 table in the Koha database. Link Here
799
=cut
801
=cut
800
802
801
sub CheckReserves {
803
sub CheckReserves {
802
    my ( $item, $barcode ) = @_;
804
    my ( $item, $barcode, $lookahead_days) = @_;
803
    my $dbh = C4::Context->dbh;
805
    my $dbh = C4::Context->dbh;
804
    my $sth;
806
    my $sth;
805
    my $select;
807
    my $select;
Lines 846-852 sub CheckReserves { Link Here
846
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
848
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
847
849
848
    # Find this item in the reserves
850
    # Find this item in the reserves
849
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber );
851
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days);
850
852
851
    # $priority and $highest are used to find the most important item
853
    # $priority and $highest are used to find the most important item
852
    # in the list returned by &_Findgroupreserve. (The lower $priority,
854
    # in the list returned by &_Findgroupreserve. (The lower $priority,
Lines 1728-1738 sub _FixPriority { Link Here
1728
1730
1729
=head2 _Findgroupreserve
1731
=head2 _Findgroupreserve
1730
1732
1731
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber);
1733
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead);
1732
1734
1733
Looks for an item-specific match first, then for a title-level match, returning the
1735
Looks for an item-specific match first, then for a title-level match, returning the
1734
first match found.  If neither, then we look for a 3rd kind of match based on
1736
first match found.  If neither, then we look for a 3rd kind of match based on
1735
reserve constraints.
1737
reserve constraints.
1738
Lookahead is the number of days to look in advance.
1736
1739
1737
TODO: add more explanation about reserve constraints
1740
TODO: add more explanation about reserve constraints
1738
1741
Lines 1744-1750 C<biblioitemnumber>. Link Here
1744
=cut
1747
=cut
1745
1748
1746
sub _Findgroupreserve {
1749
sub _Findgroupreserve {
1747
    my ( $bibitem, $biblio, $itemnumber ) = @_;
1750
    my ( $bibitem, $biblio, $itemnumber, $lookahead) = @_;
1748
    my $dbh   = C4::Context->dbh;
1751
    my $dbh   = C4::Context->dbh;
1749
1752
1750
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
1753
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
Lines 1768-1778 sub _Findgroupreserve { Link Here
1768
        AND priority > 0
1771
        AND priority > 0
1769
        AND item_level_request = 1
1772
        AND item_level_request = 1
1770
        AND itemnumber = ?
1773
        AND itemnumber = ?
1771
        AND reservedate <= CURRENT_DATE()
1774
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1772
        AND suspend = 0
1775
        AND suspend = 0
1773
    /;
1776
    /;
1774
    my $sth = $dbh->prepare($item_level_target_query);
1777
    my $sth = $dbh->prepare($item_level_target_query);
1775
    $sth->execute($itemnumber);
1778
    $sth->execute($itemnumber, $lookahead||0);
1776
    my @results;
1779
    my @results;
1777
    if ( my $data = $sth->fetchrow_hashref ) {
1780
    if ( my $data = $sth->fetchrow_hashref ) {
1778
        push( @results, $data );
1781
        push( @results, $data );
Lines 1799-1809 sub _Findgroupreserve { Link Here
1799
        AND priority > 0
1802
        AND priority > 0
1800
        AND item_level_request = 0
1803
        AND item_level_request = 0
1801
        AND hold_fill_targets.itemnumber = ?
1804
        AND hold_fill_targets.itemnumber = ?
1802
        AND reservedate <= CURRENT_DATE()
1805
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1803
        AND suspend = 0
1806
        AND suspend = 0
1804
    /;
1807
    /;
1805
    $sth = $dbh->prepare($title_level_target_query);
1808
    $sth = $dbh->prepare($title_level_target_query);
1806
    $sth->execute($itemnumber);
1809
    $sth->execute($itemnumber, $lookahead||0);
1807
    @results = ();
1810
    @results = ();
1808
    if ( my $data = $sth->fetchrow_hashref ) {
1811
    if ( my $data = $sth->fetchrow_hashref ) {
1809
        push( @results, $data );
1812
        push( @results, $data );
Lines 1831-1841 sub _Findgroupreserve { Link Here
1831
          AND reserves.reservedate    = reserveconstraints.reservedate )
1834
          AND reserves.reservedate    = reserveconstraints.reservedate )
1832
          OR  reserves.constrainttype='a' )
1835
          OR  reserves.constrainttype='a' )
1833
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1836
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1834
          AND reserves.reservedate <= CURRENT_DATE()
1837
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1835
          AND suspend = 0
1838
          AND suspend = 0
1836
    /;
1839
    /;
1837
    $sth = $dbh->prepare($query);
1840
    $sth = $dbh->prepare($query);
1838
    $sth->execute( $biblio, $bibitem, $itemnumber );
1841
    $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0);
1839
    @results = ();
1842
    @results = ();
1840
    while ( my $data = $sth->fetchrow_hashref ) {
1843
    while ( my $data = $sth->fetchrow_hashref ) {
1841
        push( @results, $data );
1844
        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 55-61 Circulation: Link Here
55
            - Set the default start date for the Holds to pull list to
55
            - Set the default start date for the Holds to pull list to
56
            - pref: HoldsToPullStartDate
56
            - pref: HoldsToPullStartDate
57
              class: integer
57
              class: integer
58
            - day(s) ago.
58
            - day(s) ago. Note that the default end date is controlled by preference ConfirmFutureHolds.
59
        -
59
        -
60
            - pref: AllowAllMessageDeletion
60
            - pref: AllowAllMessageDeletion
61
              choices:
61
              choices:
Lines 358-363 Circulation: Link Here
358
                  no: "Don't allow"
358
                  no: "Don't allow"
359
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
359
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
360
        -
360
        -
361
            - Confirm future hold requests at checkin within
362
            - pref: ConfirmFutureHolds
363
              class: integer
364
            - 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.
365
        -
361
            - Check the
366
            - Check the
362
            - pref: ReservesControlBranch
367
            - pref: ReservesControlBranch
363
              choices:
368
              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