Bugzilla – Attachment 2852 Details for
Bug 5320
Estimate optionally next planned date for serials without periodicity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
0019-bug5320-serest-v33p_patch.txt (text/plain), 2.88 KB, created by
Marcel de Rooy
on 2010-12-15 13:15:00 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2010-12-15 13:15:00 UTC
Size:
2.88 KB
patch
obsolete
>From 62bdebe113a5ac94bbfa993e462762e8317da2be Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 28 Oct 2010 15:18:36 +0200 >Subject: [PATCH] Enhancement 5320 (Estimate optionally next planned date for serials without periodicity) >Content-Type: text/plain; charset="utf-8" > >For periodicity Irregular, Unknown or "Without periodicity", it would be >helpful if Koha could suggest a next planned date when receiving an issue based >on the time interval between the last two receivals of this serial. > >This option is triggered by new local-use preference SerialEstimatePlannedDate. >If this option exists and contains uppercase W for without periodicity, I for >irregular or U for unknown, or a combination of those characters, the option is >enabled for these particular periodicities. Behavior does not change for other >periodicities. >--- > C4/Serials.pm | 36 +++++++++++++++++++++++++++++++++++- > 1 files changed, 35 insertions(+), 1 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 32e46be..3835e2e 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -2178,7 +2178,12 @@ sub GetNextDate(@) { > > # warn "DOW $dayofweek"; > if ( $subscription->{periodicity} % 16 == 0 ) { # 'without regularity' || 'irregular' >- return 0; >+ return 0 unless _estimate_option_enabled($subscription->{periodicity}); >+ my $estimate_days=_get_estimate_for_no_periodicity($subscription); >+ if(!$estimate_days) { #return today >+ ($year, $month, $day)= (localtime)[5,4,3]; $year+=1900; $month++; >+ } >+ @resultdate = Add_Delta_Days($year,$month,$day,$estimate_days); > } > > # daily : n / week >@@ -2305,6 +2310,35 @@ sub GetNextDate(@) { > > return "$resultdate"; > } >+sub _estimate_option_enabled { #check preference >+ my $periodicity= shift; >+ my $pref=C4::Context->preference('SerialEstimatePlannedDate'); >+ my $period_char= substr("WIU",-1+$periodicity/16,1); >+ #16=Without,32=Irreg,48=Unknwn >+ return $pref=~ /$period_char/; >+} >+sub _get_estimate_for_no_periodicity { >+ my ($subscription) = @_; >+ >+ my $dbh= C4::Context->dbh; >+ my $sth= $dbh->prepare('SELECT >+ YEAR(COALESCE(publisheddate,planneddate)), >+ MONTH(COALESCE(publisheddate,planneddate)), >+ DAY(COALESCE(publisheddate,planneddate)) >+ FROM serial >+ WHERE subscriptionid = ? AND >+ (planneddate IS NOT NULL OR publisheddate IS NOT NULL) >+ ORDER BY serialid DESC LIMIT 2'); >+ $sth->execute($subscription->{subscriptionid}); >+ my $dates= $sth->fetchall_arrayref; #last two non-null dates >+ $sth->finish; >+ return if @$dates<2 || >+ !check_date(@{$dates->[1]}) || !check_date(@{$dates->[0]}); >+ >+ #pass args in chronological order to Delta_Days, return difference in days >+ #check on positive result >+ my $d; return ($d=Delta_Days(@{$dates->[1]}, @{$dates->[0]}))>0? $d: 1; >+} > > =head2 itemdata > >-- >1.6.0.6 >
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 5320
:
2851
| 2852