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

(-)a/circ/reserveratios.pl (-20 / +19 lines)
Lines 27-36 use Date::Calc qw/Today Add_Delta_YM/; Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Output;
28
use C4::Output;
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Dates qw/format_date format_date_in_iso/;
31
use C4::Debug;
30
use C4::Debug;
32
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/;
31
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/;
33
use C4::Acquisition qw/GetOrdersByBiblionumber/;
32
use C4::Acquisition qw/GetOrdersByBiblionumber/;
33
use Koha::DateUtils;
34
34
35
my $input = new CGI;
35
my $input = new CGI;
36
my $startdate       = $input->param('from');
36
my $startdate       = $input->param('from');
Lines 55-76 if ($booksellerid && $basketno) { Link Here
55
     $template->param( booksellerid => $booksellerid, basketno => $basketno );
55
     $template->param( booksellerid => $booksellerid, basketno => $basketno );
56
}
56
}
57
57
58
my ( $year, $month, $day ) = Today();
58
$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); };
59
my $todaysdate     = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
59
$enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); };
60
# Find yesterday for the default shelf pull start and end dates
60
61
#    A default of the prior years's holds is a reasonable way to pull holds 
61
my $todaysdate_dt = dt_from_string;
62
my $datelastyear = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YM($year, $month, $day, -1, 0));
62
my $todaysdate  = output_pref( { dt => $todaysdate_dt, dateonly => 1, dateformat => 'iso' } );
63
64
#    A default of the prior years's holds is a reasonable way to pull holds
65
my $datelastyear_dt = $todaysdate_dt->subtract( days => 1);
66
my $datelastyear = output_pref( { dt => $datelastyear_dt, dateonly => 1, dateformat => 'iso' } );
67
68
$startdate = $datelastyear unless $startdate;
69
$enddate = $todaysdate unless $enddate;
63
70
64
#		Predefine the start and end dates if they are not already defined
65
#		Check if null, should string match, if so set start and end date to yesterday
66
if (!defined($startdate) or $startdate !~ s/^\s*(\S+)\s*$/$1/) {   # strip spaces, remove Taint
67
	$startdate = format_date($datelastyear);
68
}
69
if (!defined($enddate)   or $enddate   !~ s/^\s*(\S+)\s*$/$1/) {   # strip spaces, remove Taint
70
	$enddate   = format_date($todaysdate);
71
}
72
if (!defined($ratio)) {
71
if (!defined($ratio)) {
73
	$ratio = 3;
72
    $ratio = 3;
74
}
73
}
75
# Force to be a number
74
# Force to be a number
76
$ratio += 0;
75
$ratio += 0;
Lines 80-94 if ($ratio <= 0) { Link Here
80
79
81
my $dbh    = C4::Context->dbh;
80
my $dbh    = C4::Context->dbh;
82
my $sqldatewhere = "";
81
my $sqldatewhere = "";
83
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
82
$debug and warn output_pref({ dt => dt_from_string( $startdate ), dateformat => 'iso', dateonly => 1 }) . "\n" . output_pref({ dt => dt_from_string( $enddate ), dateformat => 'iso', dateonly => 1 });
84
my @query_params = ();
83
my @query_params = ();
85
if ($startdate) {
84
if ($startdate) {
86
    $sqldatewhere .= " AND reservedate >= ?";
85
    $sqldatewhere .= " AND reservedate >= ?";
87
    push @query_params, format_date_in_iso($startdate);
86
    push @query_params, $startdate ;
88
}
87
}
89
if ($enddate) {
88
if ($enddate) {
90
    $sqldatewhere .= " AND reservedate <= ?";
89
    $sqldatewhere .= " AND reservedate <= ?";
91
    push @query_params, format_date_in_iso($enddate);
90
    push @query_params, $enddate;
92
}
91
}
93
92
94
my $nfl_comparison = $include_ordered ? '<=' : '=';
93
my $nfl_comparison = $include_ordered ? '<=' : '=';
Lines 146-152 while ( my $data = $sth->fetchrow_hashref ) { Link Here
146
    push(
145
    push(
147
        @reservedata,
146
        @reservedata,
148
        {
147
        {
149
            reservedate        => format_date( $data->{reservedate} ),
148
            reservedate        => $data->{reservedate},
150
            priority           => $data->{priority},
149
            priority           => $data->{priority},
151
            name               => $data->{borrower},
150
            name               => $data->{borrower},
152
            title              => $data->{title},
151
            title              => $data->{title},
Lines 178-184 for my $rd ( @reservedata ) { Link Here
178
177
179
$template->param(
178
$template->param(
180
    ratio_atleast1  => $ratio_atleast1,
179
    ratio_atleast1  => $ratio_atleast1,
181
    todaysdate      => format_date($todaysdate),
180
    todaysdate      => $todaysdate,
182
    from            => $startdate,
181
    from            => $startdate,
183
    to              => $enddate,
182
    to              => $enddate,
184
    ratio           => $ratio,
183
    ratio           => $ratio,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt (-5 / +5 lines)
Lines 1-3 Link Here
1
[% USE KohaDates %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Circulation &rsaquo; Hold ratios</title>
3
<title>Koha &rsaquo; Circulation &rsaquo; Hold ratios</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 42-49 Link Here
42
    <div id="yui-main">
43
    <div id="yui-main">
43
    <div class="yui-b">
44
    <div class="yui-b">
44
<h1>Hold ratios to calculate items needed</h1>
45
<h1>Hold ratios to calculate items needed</h1>
45
   <h3>Calculated on [% todaysdate %]. From [% from %]
46
   <h3>Calculated on [% todaysdate | $KohaDates %]. From [% from | $KohaDates %]
46
    to [% to %]</h3>
47
    to [% to | $KohaDates %]</h3>
47
<p>These items have a hold ratio &ge; [% ratio %].</p>
48
<p>These items have a hold ratio &ge; [% ratio %].</p>
48
<div class="sql">[% sql %]</div>
49
<div class="sql">[% sql %]</div>
49
50
Lines 108-119 Link Here
108
109
109
    <li>
110
    <li>
110
        <label for="from">Start date:</label>
111
        <label for="from">Start date:</label>
111
        <input type="text" size="10" id="from" name="from" value="[% from %]" class="datepickerfrom" />
112
        <input type="text" size="10" id="from" name="from" value="[% from | $KohaDates %]" class="datepickerfrom" />
112
    </li>
113
    </li>
113
114
114
    <li>
115
    <li>
115
        <label for="to">End date:</label>
116
        <label for="to">End date:</label>
116
        <input size="10" id="to" name="to" value="[% to %]" type="text" class="datepickerto" />
117
        <input size="10" id="to" name="to" value="[% to | $KohaDates %]" type="text" class="datepickerto" />
117
    </li>
118
    </li>
118
</ol>
119
</ol>
119
(inclusive)
120
(inclusive)
120
- 

Return to bug 14920