my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -1));
# changed from delivered range of 10 years-yesterday to 2 days ago-today
-# Find two days ago for the default shelf pull start and end dates
-my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -2));
+# Find two days ago for the default shelf pull start and end dates, unless HoldsToPullStartDate sys pref is set.
+my $defaultstartdate = ( C4::Context->preference('HoldsToPullStartDate') ) ? "-".C4::Context->preference('HoldsToPullStartDate') : -2;
+my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, $defaultstartdate));
# Predefine the start and end dates if they are not already defined
$startdate =~ s/^\s+//;
AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
AND issues.itemnumber IS NULL
AND reserves.priority <> 0
+ AND reserves.suspend = 0
AND notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0
";
# GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when