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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 1843-1849 sub AddReturn { Link Here
1843
    # find reserves.....
1843
    # find reserves.....
1844
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1844
    # if we don't have a reserve with the status W, we launch the Checkreserves routine
1845
    my ($resfound, $resrec);
1845
    my ($resfound, $resrec);
1846
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ) unless ( $item->{'wthdrawn'} );
1846
    my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
1847
    ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'wthdrawn'} );
1847
    if ($resfound) {
1848
    if ($resfound) {
1848
          $resrec->{'ResFound'} = $resfound;
1849
          $resrec->{'ResFound'} = $resfound;
1849
        $messages->{'ResFound'} = $resrec;
1850
        $messages->{'ResFound'} = $resrec;
(-)a/C4/Reserves.pm (-10 / +13 lines)
Lines 751-760 sub GetReserveStatus { Link Here
751
751
752
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
752
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber);
753
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
753
  ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode);
754
  ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber,undef,$lookahead);
754
755
755
Find a book in the reserves.
756
Find a book in the reserves.
756
757
757
C<$itemnumber> is the book's item number.
758
C<$itemnumber> is the book's item number.
759
C<$lookahead> is the number of days to look in advance for future reserves.
758
760
759
As I understand it, C<&CheckReserves> looks for the given item in the
761
As I understand it, C<&CheckReserves> looks for the given item in the
760
reserves. If it is found, that's a match, and C<$status> is set to
762
reserves. If it is found, that's a match, and C<$status> is set to
Lines 775-781 table in the Koha database. Link Here
775
=cut
777
=cut
776
778
777
sub CheckReserves {
779
sub CheckReserves {
778
    my ( $item, $barcode ) = @_;
780
    my ( $item, $barcode, $lookahead_days) = @_;
779
    my $dbh = C4::Context->dbh;
781
    my $dbh = C4::Context->dbh;
780
    my $sth;
782
    my $sth;
781
    my $select;
783
    my $select;
Lines 822-828 sub CheckReserves { Link Here
822
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
824
    return ( '' ) if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
823
825
824
    # Find this item in the reserves
826
    # Find this item in the reserves
825
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber );
827
    my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days);
826
828
827
    # $priority and $highest are used to find the most important item
829
    # $priority and $highest are used to find the most important item
828
    # in the list returned by &_Findgroupreserve. (The lower $priority,
830
    # in the list returned by &_Findgroupreserve. (The lower $priority,
Lines 1704-1714 sub _FixPriority { Link Here
1704
1706
1705
=head2 _Findgroupreserve
1707
=head2 _Findgroupreserve
1706
1708
1707
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber);
1709
  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead);
1708
1710
1709
Looks for an item-specific match first, then for a title-level match, returning the
1711
Looks for an item-specific match first, then for a title-level match, returning the
1710
first match found.  If neither, then we look for a 3rd kind of match based on
1712
first match found.  If neither, then we look for a 3rd kind of match based on
1711
reserve constraints.
1713
reserve constraints.
1714
Lookahead is the number of days to look in advance.
1712
1715
1713
TODO: add more explanation about reserve constraints
1716
TODO: add more explanation about reserve constraints
1714
1717
Lines 1720-1726 C<biblioitemnumber>. Link Here
1720
=cut
1723
=cut
1721
1724
1722
sub _Findgroupreserve {
1725
sub _Findgroupreserve {
1723
    my ( $bibitem, $biblio, $itemnumber ) = @_;
1726
    my ( $bibitem, $biblio, $itemnumber, $lookahead) = @_;
1724
    my $dbh   = C4::Context->dbh;
1727
    my $dbh   = C4::Context->dbh;
1725
1728
1726
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
1729
    # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var.
Lines 1744-1754 sub _Findgroupreserve { Link Here
1744
        AND priority > 0
1747
        AND priority > 0
1745
        AND item_level_request = 1
1748
        AND item_level_request = 1
1746
        AND itemnumber = ?
1749
        AND itemnumber = ?
1747
        AND reservedate <= CURRENT_DATE()
1750
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1748
        AND suspend = 0
1751
        AND suspend = 0
1749
    /;
1752
    /;
1750
    my $sth = $dbh->prepare($item_level_target_query);
1753
    my $sth = $dbh->prepare($item_level_target_query);
1751
    $sth->execute($itemnumber);
1754
    $sth->execute($itemnumber, $lookahead||0);
1752
    my @results;
1755
    my @results;
1753
    if ( my $data = $sth->fetchrow_hashref ) {
1756
    if ( my $data = $sth->fetchrow_hashref ) {
1754
        push( @results, $data );
1757
        push( @results, $data );
Lines 1775-1785 sub _Findgroupreserve { Link Here
1775
        AND priority > 0
1778
        AND priority > 0
1776
        AND item_level_request = 0
1779
        AND item_level_request = 0
1777
        AND hold_fill_targets.itemnumber = ?
1780
        AND hold_fill_targets.itemnumber = ?
1778
        AND reservedate <= CURRENT_DATE()
1781
        AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1779
        AND suspend = 0
1782
        AND suspend = 0
1780
    /;
1783
    /;
1781
    $sth = $dbh->prepare($title_level_target_query);
1784
    $sth = $dbh->prepare($title_level_target_query);
1782
    $sth->execute($itemnumber);
1785
    $sth->execute($itemnumber, $lookahead||0);
1783
    @results = ();
1786
    @results = ();
1784
    if ( my $data = $sth->fetchrow_hashref ) {
1787
    if ( my $data = $sth->fetchrow_hashref ) {
1785
        push( @results, $data );
1788
        push( @results, $data );
Lines 1807-1817 sub _Findgroupreserve { Link Here
1807
          AND reserves.reservedate    = reserveconstraints.reservedate )
1810
          AND reserves.reservedate    = reserveconstraints.reservedate )
1808
          OR  reserves.constrainttype='a' )
1811
          OR  reserves.constrainttype='a' )
1809
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1812
          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
1810
          AND reserves.reservedate <= CURRENT_DATE()
1813
          AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY)
1811
          AND suspend = 0
1814
          AND suspend = 0
1812
    /;
1815
    /;
1813
    $sth = $dbh->prepare($query);
1816
    $sth = $dbh->prepare($query);
1814
    $sth->execute( $biblio, $bibitem, $itemnumber );
1817
    $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0);
1815
    @results = ();
1818
    @results = ();
1816
    while ( my $data = $sth->fetchrow_hashref ) {
1819
    while ( my $data = $sth->fetchrow_hashref ) {
1817
        push( @results, $data );
1820
        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 351-356 Circulation: Link Here
351
                  no: "Don't allow"
351
                  no: "Don't allow"
352
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
352
            - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)."
353
        -
353
        -
354
            - Confirm future hold requests at checkin within
355
            - pref: ConfirmFutureHolds
356
              class: integer
357
            - 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.
358
        -
354
            - Check the
359
            - Check the
355
            - pref: ReservesControlBranch
360
            - pref: ReservesControlBranch
356
              choices:
361
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-2 / +1 lines)
Lines 156-162 $(document).ready(function() { Link Here
156
<input type="text" size="10" id="to" name="to" value="[% to %]" class="datepickerto" />
156
<input type="text" size="10" id="to" name="to" value="[% to %]" class="datepickerto" />
157
</li>
157
</li>
158
</ol>
158
</ol>
159
<p><i>(Inclusive, default is [% HoldsToPullStartDate %] days ago to today, set other date ranges as needed. )</i></p>
159
<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>
160
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
160
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
161
</fieldset>
161
</fieldset>
162
</form>
162
</form>
163
- 

Return to bug 9761