Bugzilla – Attachment 69814 Details for
Bug 17656
Irregularities in serial prediction pattern are planned only for current subscription
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17656 - Keep irregularities during subscription renewals
Bug-17656---Keep-irregularities-during-subscriptio.patch (text/plain), 27.77 KB, created by
Alex Arnaud
on 2017-12-15 09:45:04 UTC
(
hide
)
Description:
Bug 17656 - Keep irregularities during subscription renewals
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-12-15 09:45:04 UTC
Size:
27.77 KB
patch
obsolete
>From 2103d0c60821162be83dc32e9f3a32ae26f016bd Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 18 Oct 2017 14:52:34 +0000 >Subject: [PATCH] Bug 17656 - Keep irregularities during subscription renewals > >When renewing a subscription, irregularities are lost. This patch >allows to keep them for monthly, daily or weekly serials ( 1 unit per issue >only). > >Test plan: > - Apply this patch, > - Launch installer/data/mysql/updatedatabase.pl > - Launch misc/devel/update_dbix_class_files.pl > > - Create a daily subscription. i.e: > - From: 2017-10-09, To: 2017-10-15, > - Frequency: 1/day, > - 7 issues, > - test prediction pattern > - check Wednesday and Thursday as irregularity, > - save > - Edit subscription, > - Check that Wednesday and Thursday are still checked > - Renew subscription from 2017-10-16 > - Edit subscription, > - Make sure that Wednesday and Thursday are still checked > with corresponding serials > > - Do the same for a monthly and weekly subscription > >Rebased - 2017-12-15 - Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/Serials.pm | 102 ++++++++------------- > Koha/DateUtils.pm | 31 ++++++- > Koha/Subscription.pm | 24 +++++ > .../Bug_17656-add-permanent-irregularities.sql | 1 + > koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 7 ++ > .../includes/serials/subscription_daily_choice.inc | 21 +++++ > .../serials/subscription_monthly_choice.inc | 21 +++++ > .../serials/subscription_weekly_choice.inc | 28 ++++++ > .../en/modules/serials/showpredictionpattern.tt | 27 ++---- > .../intranet-tmpl/prog/js/showpredictionpattern.js | 19 +++- > serials/showpredictionpattern.pl | 15 ++- > serials/subscription-add.pl | 13 ++- > t/Koha/DateUtils.t | 46 ++++++++++ > t/db_dependent/Serials/SubscriptionIrregularity.t | 35 +++++++ > 14 files changed, 294 insertions(+), 96 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_weekly_choice.inc > create mode 100644 t/Koha/DateUtils.t > create mode 100644 t/db_dependent/Serials/SubscriptionIrregularity.t > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 45bae8c..57e3eb6 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1301,37 +1301,6 @@ sub ModNextExpected { > > } > >-=head2 GetSubscriptionIrregularities >- >-=over 4 >- >-=item @irreg = &GetSubscriptionIrregularities($subscriptionid); >-get the list of irregularities for a subscription >- >-=back >- >-=cut >- >-sub GetSubscriptionIrregularities { >- my $subscriptionid = shift; >- >- return unless $subscriptionid; >- >- my $dbh = C4::Context->dbh; >- my $query = qq{ >- SELECT irregularity >- FROM subscription >- WHERE subscriptionid = ? >- }; >- my $sth = $dbh->prepare($query); >- $sth->execute($subscriptionid); >- >- my ($result) = $sth->fetchrow_array; >- my @irreg = split /;/, $result; >- >- return @irreg; >-} >- > =head2 ModSubscription > > this function modifies a subscription. Put all new values on input args. >@@ -1342,23 +1311,23 @@ returns the number of rows affected > sub ModSubscription { > my ( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, >- $periodicity, $firstacquidate, $irregularity, $numberpattern, $locale, >- $numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, >- $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, >- $biblionumber, $callnumber, $notes, $letter, $manualhistory, >- $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, >- $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, >- $itemtype, $previousitemtype >+ $periodicity, $firstacquidate, $irregularity, $permanent_irregularity, >+ $numberpattern, $locale, $numberlength, $weeklength, $monthlength, >+ $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, >+ $innerloop3, $status, $biblionumber, $callnumber, $notes, $letter, >+ $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >+ $skip_serialseq, $itemtype, $previousitemtype > ) = @_; > > my $dbh = C4::Context->dbh; > my $query = "UPDATE subscription > SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?, > startdate=?, periodicity=?, firstacquidate=?, irregularity=?, >- numberpattern=?, locale=?, numberlength=?, weeklength=?, monthlength=?, >- lastvalue1=?, innerloop1=?, lastvalue2=?, innerloop2=?, >- lastvalue3=?, innerloop3=?, status=?, biblionumber=?, >- callnumber=?, notes=?, letter=?, manualhistory=?, >+ permanent_irregularity=?, numberpattern=?, locale=?, numberlength=?, >+ weeklength=?, monthlength=?, lastvalue1=?, innerloop1=?, >+ lastvalue2=?, innerloop2=?, lastvalue3=?, innerloop3=?, status=?, >+ biblionumber=?, callnumber=?, notes=?, letter=?, manualhistory=?, > internalnotes=?, serialsadditems=?, staffdisplaycount=?, > opacdisplaycount=?, graceperiod=?, location = ?, enddate=?, > skip_serialseq=?, itemtype=?, previousitemtype=? >@@ -1366,17 +1335,19 @@ sub ModSubscription { > > my $sth = $dbh->prepare($query); > $sth->execute( >- $auser, $branchcode, $aqbooksellerid, $cost, >- $aqbudgetid, $startdate, $periodicity, $firstacquidate, >- $irregularity, $numberpattern, $locale, $numberlength, >- $weeklength, $monthlength, $lastvalue1, $innerloop1, >- $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, >- $status, $biblionumber, $callnumber, $notes, >- $letter, ($manualhistory ? $manualhistory : 0), >- $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, >- $graceperiod, $location, $enddate, $skip_serialseq, >- $itemtype, $previousitemtype, >- $subscriptionid >+ $auser, $branchcode, $aqbooksellerid, >+ $cost, $aqbudgetid, $startdate, >+ $periodicity, $firstacquidate, $irregularity, >+ $permanent_irregularity, $numberpattern, $locale, >+ $numberlength, $weeklength, $monthlength, >+ $lastvalue1, $innerloop1, $lastvalue2, >+ $innerloop2, $lastvalue3, $innerloop3, >+ $status, $biblionumber, $callnumber, >+ $notes, $letter, ($manualhistory ? $manualhistory : 0), >+ $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, >+ $enddate, $skip_serialseq, $itemtype, >+ $previousitemtype, $subscriptionid > ); > my $rows = $sth->rows; > >@@ -1407,9 +1378,10 @@ sub NewSubscription { > $startdate, $periodicity, $numberlength, $weeklength, $monthlength, > $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, > $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, >- $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >- $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype >+ $permanent_irregularity, $numberpattern, $locale, $callnumber, >+ $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, >+ $itemtype, $previousitemtype > ) = @_; > my $dbh = C4::Context->dbh; > >@@ -1420,11 +1392,11 @@ sub NewSubscription { > biblionumber, startdate, periodicity, numberlength, weeklength, > monthlength, lastvalue1, innerloop1, lastvalue2, innerloop2, > lastvalue3, innerloop3, status, notes, letter, firstacquidate, >- irregularity, numberpattern, locale, callnumber, >- manualhistory, internalnotes, serialsadditems, staffdisplaycount, >- opacdisplaycount, graceperiod, location, enddate, skip_serialseq, >- itemtype, previousitemtype) >- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) >+ irregularity, permanent_irregularity, numberpattern, locale, >+ callnumber, manualhistory, internalnotes, serialsadditems, >+ staffdisplaycount, opacdisplaycount, graceperiod, location, >+ enddate, skip_serialseq, itemtype, previousitemtype) >+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) > |; > my $sth = $dbh->prepare($query); > $sth->execute( >@@ -1432,10 +1404,10 @@ sub NewSubscription { > $startdate, $periodicity, $numberlength, $weeklength, > $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, > $lastvalue3, $innerloop3, $status, $notes, $letter, >- $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, >- $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >- $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, >- $itemtype, $previousitemtype >+ $firstacquidate, $irregularity, $permanent_irregularity, >+ $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype > ); > > my $subscriptionid = $dbh->{'mysql_insertid'}; >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index 2b8ee8b..a53454e 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -18,13 +18,14 @@ package Koha::DateUtils; > > use Modern::Perl; > use DateTime; >+use Date::Calc qw( Day_of_Week ); > use C4::Context; > use Koha::Exceptions; > > use base 'Exporter'; > > our @EXPORT = ( >- qw( dt_from_string output_pref format_sqldatetime ) >+ qw( dt_from_string output_pref format_sqldatetime issue_number ) > ); > > =head1 DateUtils >@@ -317,4 +318,32 @@ sub format_sqldatetime { > return q{}; > } > >+=head2 issue_number >+ >+my $week_number = issue_number('2017-01-01', 'week'); >+ >+=cut >+ >+sub issue_number { >+ my ($date, $issue_type) = @_; >+ >+ unless ( ref($date) eq 'DateTime' ) { >+ Koha::Exceptions::WrongParameter->throw("Date passed to issue_number is not a valid DateTime object" ); >+ } >+ >+ if ($issue_type eq 'day') { >+ return Day_of_Week(split /-/, $date->ymd); >+ } >+ >+ if ($issue_type eq 'week') { >+ return $date->week_number; >+ } >+ >+ if ($issue_type eq 'month') { >+ return $date->month; >+ } >+ >+ return 0; >+} >+ > 1; >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index 2a793e5..839f17a 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -48,6 +48,30 @@ sub biblio { > return scalar Koha::Biblios->find($self->biblionumber); > } > >+=head2 irregularities >+ >+Returns an array containing irregularities >+ >+=cut >+ >+sub irregularities { >+ my ($self) = @_; >+ >+ return split(';', $self->irregularity); >+} >+ >+=head2 permanent_irregularities >+ >+Returns an array containing permanent irregularities >+ >+=cut >+ >+sub permanent_irregularities { >+ my ($self) = @_; >+ >+ return split(';', $self->permanent_irregularity); >+} >+ > =head3 type > > =cut >diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql >new file mode 100644 >index 0000000..cb9cd1d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql >@@ -0,0 +1 @@ >+ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity; >diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >index 9a18b09..769fa30 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >@@ -3050,6 +3050,7 @@ fieldset.rows + fieldset.action { > display: none; > } > >+<<<<<<< af7d618d2b12655631e9febae74c222367495900 > #interlibraryloans h1 { > margin: 1em 0; > } >@@ -3137,3 +3138,9 @@ fieldset.rows + fieldset.action { > table#ill-requests { > width: 100% !important; > } >+ >+.week-columns{ >+ -moz-column-count: 2; /* Firefox */ >+ -webkit-column-count: 2; /* Safari and Chrome */ >+ column-count: 3; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc >new file mode 100644 >index 0000000..4e1688d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc >@@ -0,0 +1,21 @@ >+<p><em> >+ If there is a day (or more) in the week where issues are never >+ published, you can check corresponding boxes below. >+</em></p> >+[% daily_choice = [ {name => 'monday', desc => 'Monday', value => 1}, {name => 'tuesday', desc => 'Tuesday', value => 2}, {name => 'wednesday', desc => 'Wednesday', value => 3}, {name => 'thursday', desc => 'Thursday', value => 4}, {name => 'friday', desc => 'Friday', value => 5}, {name => 'saturday', desc => 'Saturday', value => 6}, {name => 'sunday', desc => 'Sunday', value => 7} ] %] >+ >+[% FOREACH day IN daily_choice %] >+ [% IF permanent_irreg.grep( day.value ).0 == day.value %] >+ <input type="checkbox" name="permanent_irregularity" >+ id="[% day.name %]" data-dow="[% day.value %]" >+ value="[% day.value %]" class="skip" >+ checked="checked" >+ /> >+ [% ELSE %] >+ <input type="checkbox" name="permanent_irregularity" >+ id="[% day.name %]" data-dow="[% day.value %]" >+ value="[% day.value %]" class="skip" >+ /> >+ [% END %] >+ <label for="[% day.name %]">[% day.desc %]</label> >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc >new file mode 100644 >index 0000000..29bf9fd >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc >@@ -0,0 +1,21 @@ >+<p><em> >+ If there is a month (or more) in the year where issues are never >+ published, you can check corresponding boxes below. >+</em></p> >+[% monthly_choice = [ {name => 'january', desc => 'January', value => 1}, {name => 'february', desc => 'February', value => 2}, {name => 'march', desc => 'March', value => 3}, {name => 'april', desc => 'April', value => 4}, {name => 'may', desc => 'May', value => 5}, {name => 'june', desc => 'June', value => 6}, {name => 'july', desc => 'July', value => 7}, {name => 'august', desc => 'August', value => 8}, {name => 'september', desc => 'September', value => 9}, {name => 'october', desc => 'October', value => 10}, {name => 'november', desc => 'November', value => 11}, {name => 'december', desc => 'December', value =>12} ] %] >+ >+[% FOREACH month IN monthly_choice %] >+ [% IF permanent_irreg.grep( month.value ).0 == month.value %] >+ <input type="checkbox" name="permanent_irregularity" >+ id="[% month.name %]" data-dow="[% month.value %]" >+ value="[% month.value %]" class="skip" >+ checked="checked" >+ /> >+ [% ELSE %] >+ <input type="checkbox" name="permanent_irregularity" >+ id="[% month.name %]" data-dow="[% month.value %]" >+ value="[% month.value %]" class="skip" >+ /> >+ [% END %] >+ <label for="[% month.name %]">[% month.desc %]</label> >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_weekly_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_weekly_choice.inc >new file mode 100644 >index 0000000..594243e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_weekly_choice.inc >@@ -0,0 +1,28 @@ >+<div class="row select-weeks"> >+ <div class="col-lg-12"> >+ <div class="button-group"> >+ <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> >+ Week(s) not published >+ <span class="caret"></span> >+ </button> >+ <ul class="dropdown-menu week-columns"> >+ [% FOREACH p IN predictions_loop %] >+ <li> >+ <a href="#" class="small"> >+ [% IF permanent_irreg.grep( p.dow ).0 == p.dow %] >+ <input type="checkbox" name="permanent_irregularity" value="[% p.dow %]" data-dow="[% p.dow %]" class="skip" checked="checked"/> >+ [% ELSE %] >+ <input type="checkbox" name="permanent_irregularity" value="[% p.dow %]" data-dow="[% p.dow %]" class="skip"/> >+ [% END %] >+ Week <b>#[% p.dow %]</b> ([% p.publicationdate | $KohaDates %]) >+ </a> >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ </div> >+</div> >+<p> >+ <em>Choice the week(s) in the year where issues are never >+ published.</em> >+</p> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >index c137a77..c8b315e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >@@ -5,25 +5,14 @@ > [% END %] > [% IF (ask_for_irregularities) %] > <p><em>Please check issues that are NOT published (irregularities)</em></p> >- [% IF (daily_options) %] >- <p><em> >- If there is a day (or more) in the week where issues are never >- published, you can check corresponding boxes below. >- </em></p> >- <input type="checkbox" id="monday" data-dow="1" class="skipday" /> >- <label for="monday">Monday</label> >- <input type="checkbox" id="tuesday" data-dow="2" class="skipday" /> >- <label for="tuesday">Tuesday</label> >- <input type="checkbox" id="wednesday" data-dow="3" class="skipday" /> >- <label for="wednesday">Wednesday</label> >- <input type="checkbox" id="thursday" data-dow="4" class="skipday" /> >- <label for="thursday">Thursday</label> >- <input type="checkbox" id="friday" data-dow="5" class="skipday" /> >- <label for="friday">Friday</label> >- <input type="checkbox" id="saturday" data-dow="6" class="skipday" /> >- <label for="saturday">Saturday</label> >- <input type="checkbox" id="sunday" data-dow="7" class="skipday" /> >- <label for="sunday">Sunday</label> >+ [% IF (show_irregularity_options) %] >+ [% IF (show_irregularity_options == 'day') %] >+ [% INCLUDE 'serials/subscription_daily_choice.inc' %] >+ [% ELSIF (show_irregularity_options == 'month') %] >+ [% INCLUDE 'serials/subscription_monthly_choice.inc' %] >+ [% ELSIF (show_irregularity_options == 'week') %] >+ [% INCLUDE 'serials/subscription_weekly_choice.inc' %] >+ [% END %] > [% END %] > [% END %] > [% IF (predictions_loop) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js b/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >index f5c38a0..b2d78cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js >@@ -10,7 +10,24 @@ function Check_boxes(dow) { > } > } > $(document).ready(function(){ >- $("#displayexample").on("change",".skipday",function(){ >+ $(".skip").on("change",function(){ > Check_boxes( $(this).data("dow")); > }); >+ >+ nothing_checked = 1; >+ $("input[name='irregularity']").each(function() { >+ if ($(this).is(':checked')) { >+ nothing_checked = 0; >+ } >+ }); >+ >+ // No day/month/week are checked, could be after a renewal. >+ // So check them according to permanent irregularity >+ if (nothing_checked) { >+ $(".skip").each(function() { >+ if ($(this).is(':checked')) { >+ Check_boxes( $(this).data("dow")); >+ } >+ }); >+ } > }); >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 6986b5e..ba64466 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -112,15 +112,19 @@ if(defined $subscriptionid) { > > my @predictions_loop; > my ($calculated) = GetSeq(\%subscription, \%pattern); >+my $dow = issue_number( dt_from_string($date), $frequency->{unit} ); > push @predictions_loop, { > number => $calculated, > publicationdate => $date, > issuenumber => $issuenumber, >- dow => Day_of_Week(split /-/, $date), >+ dow => $dow, > }; > my @irreg = (); >+my @permanent_irreg = (); > if(defined $subscriptionid) { >- @irreg = C4::Serials::GetSubscriptionIrregularities($subscriptionid); >+ my $subscription_o = Koha::Subscriptions->find($subscriptionid); >+ @irreg = $subscription_o->irregularities; >+ @permanent_irreg = $subscription_o->permanent_irregularities; > while(@irreg && $issuenumber > $irreg[0]) { > shift @irreg; > } >@@ -139,7 +143,7 @@ while( $i < 1000 ) { > } > if(defined $date){ > $line{'publicationdate'} = $date; >- $line{'dow'} = Day_of_Week(split /-/, $date); >+ $line{dow} = issue_number( dt_from_string($date), $frequency->{unit} ); > } > > # Check if we don't have exceed end date >@@ -175,8 +179,9 @@ $template->param( > > if ( $frequency->{unit} and not $custompattern ) { > $template->param( ask_for_irregularities => 1 ); >- if ( $frequency->{unit} eq 'day' and $frequency->{unitsperissue} == 1 ) { >- $template->param( daily_options => 1 ); >+ if ( $frequency->{unit} =~ /^(day|month|week)$/ and $frequency->{unitsperissue} == 1 ) { >+ $template->param( show_irregularity_options => $frequency->{unit} ); >+ $template->param( permanent_irreg => \@permanent_irreg ); > } > } > >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 16d397b..bb04ecd 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -294,6 +294,7 @@ sub redirect_add_subscription { > my $aqbudgetid = $query->param('aqbudgetid'); > my $periodicity = $query->param('frequency'); > my @irregularity = $query->multi_param('irregularity'); >+ my @permanent_irregularity = $query->multi_param('permanent_irregularity'); > my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $graceperiod = $query->param('graceperiod') || 0; >@@ -341,10 +342,10 @@ sub redirect_add_subscription { > $startdate, $periodicity, $numberlength, $weeklength, > $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, > $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, >- join(";",@irregularity), $numberpattern, $locale, $callnumber, >- $manualhistory, $internalnotes, $serialsadditems, >- $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >- $skip_serialseq >+ join(";",@irregularity), join(';', @permanent_irregularity), >+ $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >+ $location, $enddate, $skip_serialseq > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >@@ -357,6 +358,7 @@ sub redirect_add_subscription { > sub redirect_mod_subscription { > my $subscriptionid = $query->param('subscriptionid'); > my @irregularity = $query->multi_param('irregularity'); >+ my @permanent_irregularity = $query->multi_param('permanent_irregularity'); > my $auser = $query->param('user'); > my $librarian => scalar $query->param('librarian'), > my $branchcode = $query->param('branchcode'); >@@ -423,7 +425,8 @@ sub redirect_mod_subscription { > ModSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, > $periodicity, $firstacquidate, join(";",@irregularity), >- $numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, >+ join(';', @permanent_irregularity), $numberpattern, $locale, >+ $numberlength, $weeklength, $monthlength, $lastvalue1, > $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >diff --git a/t/Koha/DateUtils.t b/t/Koha/DateUtils.t >new file mode 100644 >index 0000000..f0af15c >--- /dev/null >+++ b/t/Koha/DateUtils.t >@@ -0,0 +1,46 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 9; >+use Test::Warn; >+ >+BEGIN { >+ use_ok('Koha::DateUtils'); >+} >+ >+my $dt = DateTime->new(year => 2017, month => 1, day => 1); >+ >+eval { issue_number('2017', 'day'); }; >+is($@, 'Date passed to issue_number is not a valid DateTime object'); >+ >+is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week'); >+ >+is(issue_number($dt, 'week'), 52, '2017-01-01 is the week #52 of the year'); >+ >+is(issue_number($dt, 'month'), 1, '2017-01-01 is the first month of the year'); >+ >+$dt = DateTime->new(year => 2022, month => 9, day => 17); >+ >+is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week'); >+ >+is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year'); >+ >+is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year'); >+ >+is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type'); >diff --git a/t/db_dependent/Serials/SubscriptionIrregularity.t b/t/db_dependent/Serials/SubscriptionIrregularity.t >new file mode 100644 >index 0000000..2e81d0f >--- /dev/null >+++ b/t/db_dependent/Serials/SubscriptionIrregularity.t >@@ -0,0 +1,35 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use t::lib::TestBuilder; >+use Test::More tests => 6; >+ >+use Koha::Database; >+ >+use_ok('Koha::Subscription'); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $subscription = $builder->build({ >+ source => 'Subscription', >+ value => { >+ irregularity => '2;4;7', >+ permanent_irregularity => '1;2' >+ }, >+}); >+ >+my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); >+my @irreg = $subscription_o->irregularities; >+is($irreg[0], 2, 'First element of irregularities is 2'); >+is($irreg[1], 4, 'Second element of irregularities is 4'); >+is($irreg[2], 7, 'Third element of irregularities is 7'); >+ >+my @permanent_irreg = $subscription_o->permanent_irregularities; >+is($permanent_irreg[0], 1, 'First element of permanent_irregularities is 1'); >+is($permanent_irreg[1], 2, 'Second element of permanent_irregularities is 2'); >+ >+$schema->storage->txn_rollback; >-- >2.7.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 17656
:
68259
|
68261
|
68607
|
68608
|
68665
|
69124
|
69207
|
69279
|
69553
|
69814
|
69820
|
69915
|
70335
|
70336
|
70430
|
70619
|
75403
|
75404
|
75405
|
75406
|
75407
|
75408
|
75721
|
75722
|
75723
|
75724
|
75725
|
75726
|
75953
|
102724
|
102725
|
102726
|
102727
|
102728
|
102729
|
102730
|
102860
|
102861
|
102862
|
102863
|
102864
|
102865
|
102866
|
102867
|
102960
|
102961
|
102962
|
102963
|
102964
|
102965
|
102966
|
102967
|
102968
|
103623
|
103624
|
103625
|
103626
|
103627
|
103628
|
103629
|
103630
|
103631
|
103657
|
103658
|
103659
|
103660
|
103661
|
103662
|
103663
|
103664
|
103665
|
103667
|
117789
|
117790
|
117791
|
117792
|
117846
|
117851
|
117852
|
118856
|
119106
|
120863
|
121082
|
121083
|
121084
|
121085
|
121086
|
121087
|
121088
|
121192
|
121193
|
121194
|
121195
|
121196
|
121197
|
121198
|
121296
|
121297
|
121298
|
121299
|
121300
|
121301
|
121302
|
128489
|
128491
|
128492
|
128493
|
128494
|
128495
|
128496
|
128498
|
128499
|
128500
|
128501
|
128502
|
128503
|
128504
|
132412
|
132413
|
132415
|
132416
|
132417
|
132418
|
132447
|
132448
|
132692
|
132779