Bugzilla – Attachment 43361 Details for
Bug 14920
Remove C4::Dates from circ/reserveratios.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14920 - Remove C4::Dates from circ/reserveratios.pl
SIGNED-OFF-Bug-14920---Remove-C4Dates-from-circres.patch (text/plain), 6.10 KB, created by
Héctor Eduardo Castro Avalos
on 2015-10-12 21:36:29 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14920 - Remove C4::Dates from circ/reserveratios.pl
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2015-10-12 21:36:29 UTC
Size:
6.10 KB
patch
obsolete
>From df7f5a10af928ceab2fc3862d18dcba40bec5cd8 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Tue, 29 Sep 2015 14:22:33 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 14920 - Remove C4::Dates from > circ/reserveratios.pl > >This patch removes C4::Dates from circ/reserveratios.pl > >To test: >- Make sure you have many holds for biblios with not so much items (e.g. 5 holds, 1 item) > or follow hint below >- Go to Home > Circulation > Hold ratios >- Verify that everything works the same without an dwith patch > >Hint: To get a big table you can set 'Hod ratio' in the filter to 0.1 (default value is 3). >This was will trigger biblios with less holds than items. > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >Works as advertised. Tested with dateformat syspref, datepiker Ok >--- > circ/reserveratios.pl | 39 ++++++++++---------- > .../prog/en/modules/circ/reserveratios.tt | 9 +++-- > 2 files changed, 24 insertions(+), 24 deletions(-) > >diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl >index 9675674..27cc86c 100755 >--- a/circ/reserveratios.pl >+++ b/circ/reserveratios.pl >@@ -27,10 +27,10 @@ use Date::Calc qw/Today Add_Delta_YM/; > use C4::Context; > use C4::Output; > use C4::Auth; >-use C4::Dates qw/format_date format_date_in_iso/; > use C4::Debug; > use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; > use C4::Acquisition qw/GetOrdersByBiblionumber/; >+use Koha::DateUtils; > > my $input = new CGI; > my $startdate = $input->param('from'); >@@ -55,22 +55,21 @@ if ($booksellerid && $basketno) { > $template->param( booksellerid => $booksellerid, basketno => $basketno ); > } > >-my ( $year, $month, $day ) = Today(); >-my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); >-# Find yesterday for the default shelf pull start and end dates >-# A default of the prior years's holds is a reasonable way to pull holds >-my $datelastyear = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YM($year, $month, $day, -1, 0)); >+$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); }; >+$enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); }; >+ >+my $todaysdate_dt = dt_from_string; >+my $todaysdate = output_pref( { dt => $todaysdate_dt, dateonly => 1, dateformat => 'iso' } ); >+ >+# A default of the prior years's holds is a reasonable way to pull holds >+my $datelastyear_dt = $todaysdate_dt->subtract( days => 1); >+my $datelastyear = output_pref( { dt => $datelastyear_dt, dateonly => 1, dateformat => 'iso' } ); >+ >+$startdate = $datelastyear unless $startdate; >+$enddate = $todaysdate unless $enddate; > >-# Predefine the start and end dates if they are not already defined >-# Check if null, should string match, if so set start and end date to yesterday >-if (!defined($startdate) or $startdate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint >- $startdate = format_date($datelastyear); >-} >-if (!defined($enddate) or $enddate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint >- $enddate = format_date($todaysdate); >-} > if (!defined($ratio)) { >- $ratio = 3; >+ $ratio = 3; > } > # Force to be a number > $ratio += 0; >@@ -80,15 +79,15 @@ if ($ratio <= 0) { > > my $dbh = C4::Context->dbh; > my $sqldatewhere = ""; >-$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); >+$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 }); > my @query_params = (); > if ($startdate) { > $sqldatewhere .= " AND reservedate >= ?"; >- push @query_params, format_date_in_iso($startdate); >+ push @query_params, $startdate ; > } > if ($enddate) { > $sqldatewhere .= " AND reservedate <= ?"; >- push @query_params, format_date_in_iso($enddate); >+ push @query_params, $enddate; > } > > my $nfl_comparison = $include_ordered ? '<=' : '='; >@@ -146,7 +145,7 @@ while ( my $data = $sth->fetchrow_hashref ) { > push( > @reservedata, > { >- reservedate => format_date( $data->{reservedate} ), >+ reservedate => $data->{reservedate}, > priority => $data->{priority}, > name => $data->{borrower}, > title => $data->{title}, >@@ -178,7 +177,7 @@ for my $rd ( @reservedata ) { > > $template->param( > ratio_atleast1 => $ratio_atleast1, >- todaysdate => format_date($todaysdate), >+ todaysdate => $todaysdate, > from => $startdate, > to => $enddate, > ratio => $ratio, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt >index 80fe4aa..67f4226 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt >@@ -1,3 +1,4 @@ >+[% USE KohaDates %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Circulation › Hold ratios</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -42,8 +43,8 @@ > <div id="yui-main"> > <div class="yui-b"> > <h1>Hold ratios to calculate items needed</h1> >- <h3>Calculated on [% todaysdate %]. From [% from %] >- to [% to %]</h3> >+ <h3>Calculated on [% todaysdate | $KohaDates %]. From [% from | $KohaDates %] >+ to [% to | $KohaDates %]</h3> > <p>These items have a hold ratio ≥ [% ratio %].</p> > <div class="sql">[% sql %]</div> > >@@ -108,12 +109,12 @@ > > <li> > <label for="from">Start date:</label> >- <input type="text" size="10" id="from" name="from" value="[% from %]" class="datepickerfrom" /> >+ <input type="text" size="10" id="from" name="from" value="[% from | $KohaDates %]" class="datepickerfrom" /> > </li> > > <li> > <label for="to">End date:</label> >- <input size="10" id="to" name="to" value="[% to %]" type="text" class="datepickerto" /> >+ <input size="10" id="to" name="to" value="[% to | $KohaDates %]" type="text" class="datepickerto" /> > </li> > </ol> > (inclusive) >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14920
:
42948
|
42949
|
42950
|
43358
|
43360
|
43361
|
43376
|
43377