Bugzilla – Attachment 83893 Details for
Bug 17047
Mana Knowledge Base : Data sharing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17047 subscriptions management with Mana-KB
Bug-17047-subscriptions-management-with-Mana-KB.patch (text/plain), 132.55 KB, created by
Kyle M Hall (khall)
on 2019-01-14 18:47:21 UTC
(
hide
)
Description:
Bug 17047 subscriptions management with Mana-KB
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2019-01-14 18:47:21 UTC
Size:
132.55 KB
patch
obsolete
>From 23bcf19c3861304df72957fa038465049094b448 Mon Sep 17 00:00:00 2001 >From: morgane alonso <morgane.alonso@biblibre.com> >Date: Thu, 25 Aug 2016 08:22:50 +0000 >Subject: [PATCH] Bug 17047 subscriptions management with Mana-KB > >- add a class SharedContent.pm to communicate with Mana-KB server >- add a link in serials-menu.inc to serials_search.pl to open >a mana-subscription research form >- modify the research form in serials-search.tt to show the right fields >for Mana-KB >- create datatable in mana-subscription-search-result.inc to show >results from a research on Mana-KB >- modify serials-search.pl to manage research on Mana-KB > >- add a mana_id to subscription table >- add a share button on serials-toolbar.inc and a modal to ask >the language of the share and to alert if the subscription is >already link to a Mana-KB subscription model >- add function in C4/Serials to get all the info for a subscription >sharing >- modify subscription-detail.pl to manage sharing to Mana-KB > >- modify subscription-add.tt and subscription.pl to manage a >import from Mana-KB during a subscription creation >- add 2 script in svc for ajax calling from subscription-add.tt >to communicate with Mana-KB server during a asubscription creation >- add a function in Subscription.pm to have all the info for a Mana-KB research >from a biblionumber >- modify functions used by subscription-add.pl in C4/Serials to manage a >frequency which came from Mana-KB server and not already created on the >koha database, and modify the tests of the said functions > >Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Rebased-by: Alex Arnaud <alex.arnaud@biblibre.com> (2018-07-04) >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Serials.pm | 39 +-- > Koha/SharedContent.pm | 90 +++++ > Koha/Subscription.pm | 64 ++++ > Koha/Subscription/Frequencies.pm | 4 + > Koha/Subscription/Frequency.pm | 4 + > Koha/Subscription/Numberpattern.pm | 48 +++ > Koha/Subscription/Numberpatterns.pm | 77 +++++ > .../mana_01-add_mana_id_in_subscription.sql | 1 + > .../mana-subscription-search-result.inc | 46 +++ > .../prog/en/includes/serials-menu.inc | 3 + > .../prog/en/includes/serials-toolbar.inc | 105 ++++++ > .../mana-subscription-search-result.tt | 1 + > .../prog/en/modules/serials/serials-home.tt | 1 + > .../prog/en/modules/serials/serials-search.tt | 42 ++- > .../en/modules/serials/subscription-add.tt | 26 +- > .../en/modules/serials/subscription-detail.tt | 15 +- > .../intranet-tmpl/prog/js/subscription-add.js | 184 ++++++++-- > misc/cronjobs/serialsUpdate.pl | 4 +- > serials/serials-collection.pl | 6 +- > serials/serials-search.pl | 122 +++++-- > serials/showpredictionpattern.pl | 23 +- > serials/subscription-add.pl | 81 ++++- > serials/subscription-detail.pl | 71 +++- > svc/mana/search | 62 ++++ > svc/mana/use | 48 +++ > t/db_dependent/Koha/SharedContent.t | 29 ++ > t/db_dependent/Koha/Subscription.t | 82 ++++- > t/db_dependent/Serials.t | 3 +- > .../Serials/GetFictiveIssueNumber.t | 320 +++++++----------- > t/db_dependent/Serials/GetNextDate.t | 307 ++++++++--------- > t/db_dependent/Serials/GetNextSeq.t | 124 +++---- > 31 files changed, 1482 insertions(+), 550 deletions(-) > create mode 100644 Koha/SharedContent.pm > create mode 100644 Koha/Subscription/Numberpattern.pm > create mode 100644 Koha/Subscription/Numberpatterns.pm > create mode 100644 installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt > create mode 100755 svc/mana/search > create mode 100755 svc/mana/use > create mode 100644 t/db_dependent/Koha/SharedContent.t > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 91498ee262..f300c126d2 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -829,19 +829,20 @@ sub GetPreviousSerialid { > my ( > $nextseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) = GetNextSeq( $subscription, $pattern, $planneddate ); >+ ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate ); > > $subscription is a hashref containing all the attributes of the table > 'subscription'. > $pattern is a hashref containing all the attributes of the table > 'subscription_numberpatterns'. >+$frequency is a hashref containing all the attributes of the table 'subscription_frequencies' > $planneddate is a date string in iso format. > This function get the next issue for the subscription given on input arg > > =cut > > sub GetNextSeq { >- my ($subscription, $pattern, $planneddate) = @_; >+ my ($subscription, $pattern, $frequency, $planneddate) = @_; > > return unless ($subscription and $pattern); > >@@ -854,7 +855,7 @@ sub GetNextSeq { > if(@irreg > 0) { > my $irregularities = {}; > $irregularities->{$_} = 1 foreach(@irreg); >- my $issueno = GetFictiveIssueNumber($subscription, $planneddate) + 1; >+ my $issueno = GetFictiveIssueNumber($subscription, $planneddate, $frequency) + 1; > while($irregularities->{$issueno}) { > $count++; > $issueno++; >@@ -997,7 +998,7 @@ sub GetExpirationDate { > > #calculate the date of the last issue. > for ( my $i = 1 ; $i <= $length ; $i++ ) { >- $enddate = GetNextDate( $subscription, $enddate ); >+ $enddate = GetNextDate( $subscription, $enddate, $frequency ); > } > } elsif ( $subscription->{monthlength} ) { > if ( $$subscription{startdate} ) { >@@ -1149,16 +1150,17 @@ sub ModSerialStatus { > if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) { > my $subscription = GetSubscription($subscriptionid); > my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); > > # next issue number > my ( > $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 > ) >- = GetNextSeq( $subscription, $pattern, $publisheddate ); >+ = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate ); > > # next date (calculated from actual date & frequency parameters) >- my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1); >+ my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1); > my $nextpubdate = $nextpublisheddate; > $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? > WHERE subscriptionid = ?"; >@@ -1367,7 +1369,7 @@ sub NewSubscription { > $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, > $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, > $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype >+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ) = @_; > my $dbh = C4::Context->dbh; > >@@ -1381,8 +1383,8 @@ sub NewSubscription { > irregularity, numberpattern, locale, callnumber, > manualhistory, internalnotes, serialsadditems, staffdisplaycount, > opacdisplaycount, graceperiod, location, enddate, skip_serialseq, >- itemtype, previousitemtype) >- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) >+ itemtype, previousitemtype, mana_id) >+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?) > |; > my $sth = $dbh->prepare($query); > $sth->execute( >@@ -1393,7 +1395,7 @@ sub NewSubscription { > $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, > $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, >- $itemtype, $previousitemtype >+ $itemtype, $previousitemtype, $mana_id > ); > > my $subscriptionid = $dbh->{'mysql_insertid'}; >@@ -2107,7 +2109,7 @@ sub abouttoexpire { > my $expirationdate = GetExpirationDate($subscriptionid); > > my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid); >- my $nextdate = GetNextDate($subscription, $res); >+ my $nextdate = GetNextDate($subscription, $res, $frequency); > > # only compare dates if both dates exist. > if ($nextdate and $expirationdate) { >@@ -2128,7 +2130,7 @@ sub abouttoexpire { > > =head2 GetFictiveIssueNumber > >-$issueno = GetFictiveIssueNumber($subscription, $publishedate); >+$issueno = GetFictiveIssueNumber($subscription, $publishedate, $frequency); > > Get the position of the issue published at $publisheddate, considering the > first issue (at firstacquidate) is at position 1, the next is at position 2, etc... >@@ -2147,9 +2149,8 @@ date (in GetNextDate) or the next issue number (in GetNextSeq). > =cut > > sub GetFictiveIssueNumber { >- my ($subscription, $publisheddate) = @_; >+ my ($subscription, $publisheddate, $frequency) = @_; > >- my $frequency = GetSubscriptionFrequency($subscription->{'periodicity'}); > my $unit = $frequency->{unit} ? lc $frequency->{'unit'} : undef; > return if !$unit; > my $issueno; >@@ -2293,12 +2294,13 @@ sub _get_next_date_year { > > =head2 GetNextDate > >-$resultdate = GetNextDate($publisheddate,$subscription) >+$resultdate = GetNextDate($publisheddate,$subscription,$freqdata,$updatecount) > > this function it takes the publisheddate and will return the next issue's date > and will skip dates if there exists an irregularity. > $publisheddate has to be an ISO date >-$subscription is a hashref containing at least 'periodicity', 'firstacquidate', 'irregularity', and 'countissuesperunit' >+$subscription is a hashref containing at least 'firstacquidate', 'irregularity', and 'countissuesperunit' >+$frequency is a hashref containing frequency informations > $updatecount is a boolean value which, when set to true, update the 'countissuesperunit' in database > - eg if periodicity is monthly and $publisheddate is 2007-02-10 but if March and April is to be > skipped then the returned date will be 2007-05-10 >@@ -2311,11 +2313,10 @@ Return undef if subscription is irregular > =cut > > sub GetNextDate { >- my ( $subscription, $publisheddate, $updatecount ) = @_; >+ my ( $subscription, $publisheddate, $freqdata, $updatecount ) = @_; > > return unless $subscription and $publisheddate; > >- my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); > > if ($freqdata->{'unit'}) { > my ( $year, $month, $day ) = split /-/, $publisheddate; >@@ -2335,7 +2336,7 @@ sub GetNextDate { > > # Get the 'fictive' next issue number > # It is used to check if next issue is an irregular issue. >- my $issueno = GetFictiveIssueNumber($subscription, $publisheddate) + 1; >+ my $issueno = GetFictiveIssueNumber($subscription, $publisheddate, $freqdata) + 1; > > # Then get the next date > my $unit = lc $freqdata->{'unit'}; >diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm >new file mode 100644 >index 0000000000..e0c512bcd4 >--- /dev/null >+++ b/Koha/SharedContent.pm >@@ -0,0 +1,90 @@ >+package Koha::SharedContent; >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use JSON; >+use HTTP::Request; >+use LWP::UserAgent; >+ >+our $MANA_IP = "http://10.25.159.107:5000"; >+ >+sub manaRequest { >+ my $mana_request = shift; >+ my $result; >+ >+ $mana_request->content_type('application/json'); >+ my $userAgent = LWP::UserAgent->new; >+ my $response = $userAgent->request($mana_request); >+ >+ if ( $response->code ne "204" ) { >+ $result = from_json( $response->decoded_content ); >+ } >+ $result->{code} = $response->code; >+ >+ return $result if ( $response->code =~ /^2..$/ ); >+} >+ >+sub manaNewUserPatchRequest { >+ my $resource = shift; >+ my $id = shift; >+ >+ my $url = "$MANA_IP/$resource/$id.json/newUser"; >+ my $request = HTTP::Request->new( PATCH => $url ); >+ >+ return manaRequest($request); >+} >+ >+sub manaPostRequest { >+ my $resource = shift; >+ my $content = shift; >+ >+ my $url = "$MANA_IP/$resource.json"; >+ my $request = HTTP::Request->new( POST => $url ); >+ >+ $content->{bulk_import} = 0; >+ my $json = to_json( $content, { utf8 => 1 } ); >+ $request->content($json); >+ >+ return manaRequest($request); >+} >+ >+sub manaGetRequestWithId { >+ my $resource = shift; >+ my $id = shift; >+ >+ my $url = "$MANA_IP/$resource/$id.json"; >+ my $request = HTTP::Request->new( GET => $url ); >+ >+ return manaRequest($request); >+} >+ >+sub manaGetRequest { >+ my $resource = shift; >+ my $parameters = shift; >+ >+ $parameters = join '&', >+ map { defined $parameters->{$_} ? $_ . "=" . $parameters->{$_} : () } >+ keys %$parameters; >+ my $url = "$MANA_IP/$resource.json?$parameters"; >+ my $request = HTTP::Request->new( GET => $url ); >+ >+ return manaRequest($request); >+} >+ >+1; >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index 27d926dcb8..4991eb4ec9 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -24,7 +24,11 @@ use Carp; > use Koha::Database; > use Koha::Biblios; > use Koha::Acquisition::Booksellers; >+use Koha::Biblioitems; >+use Koha::Subscriptions; > use Koha::Subscription::Frequencies; >+use Koha::Subscription::Numberpatterns; >+use JSON; > > use base qw(Koha::Object); > >@@ -125,6 +129,66 @@ sub frequency { > > =cut > >+sub get_search_info { >+ my $searched_sub_id = shift; >+ my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } ); >+ my $biblioitem = >+ Koha::Biblioitems->find( { 'biblionumber' => $searched_sub_id } ); >+ >+ my $sub_mana_info = { >+ 'title' => $biblio->title, >+ 'issn' => $biblioitem->issn, >+ 'ean' => $biblioitem->ean, >+ 'publishercode' => $biblioitem->publishercode >+ }; >+ return $sub_mana_info; >+} >+ >+sub get_sharable_info { >+ my $shared_sub_id = shift; >+ my $subscription = Koha::Subscriptions->find($shared_sub_id); >+ my $biblio = Koha::Biblios->find( $subscription->biblionumber ); >+ my $biblioitem = Koha::Biblioitems->find( >+ { 'biblionumber' => $subscription->biblionumber } ); >+ my $sub_frequency = >+ Koha::Subscription::Frequencies->find( $subscription->periodicity ); >+ my $sub_numberpatteern = >+ Koha::Subscription::Numberpatterns->find( $subscription->numberpattern ); >+ >+ my $sub_mana_info = { >+ 'title' => $biblio->title, >+ 'sfdescription' => $sub_frequency->description, >+ 'unit' => $sub_frequency->unit, >+ 'unitsperissue' => $sub_frequency->unitsperissue, >+ 'issuesperunit' => $sub_frequency->issuesperunit, >+ 'label' => $sub_numberpatteern->label, >+ 'sndescription' => $sub_numberpatteern->description, >+ 'numberingmethod' => $sub_numberpatteern->numberingmethod, >+ 'label1' => $sub_numberpatteern->label1, >+ 'add1' => $sub_numberpatteern->add1, >+ 'every1' => $sub_numberpatteern->every1, >+ 'whenmorethan1' => $sub_numberpatteern->whenmorethan1, >+ 'setto1' => $sub_numberpatteern->setto1, >+ 'numbering1' => $sub_numberpatteern->numbering1, >+ 'label2' => $sub_numberpatteern->label2, >+ 'add2' => $sub_numberpatteern->add2, >+ 'every2' => $sub_numberpatteern->every2, >+ 'whenmorethan2' => $sub_numberpatteern->whenmorethan2, >+ 'setto2' => $sub_numberpatteern->setto2, >+ 'numbering2' => $sub_numberpatteern->numbering2, >+ 'label3' => $sub_numberpatteern->label3, >+ 'add3' => $sub_numberpatteern->add3, >+ 'every3' => $sub_numberpatteern->every3, >+ 'whenmorethan3' => $sub_numberpatteern->whenmorethan3, >+ 'setto3' => $sub_numberpatteern->setto3, >+ 'numbering3' => $sub_numberpatteern->numbering3, >+ 'issn' => $biblioitem->issn, >+ 'ean' => $biblioitem->ean, >+ 'publishercode' => $biblioitem->publishercode >+ }; >+ return $sub_mana_info; >+} >+ > sub _type { > return 'Subscription'; > } >diff --git a/Koha/Subscription/Frequencies.pm b/Koha/Subscription/Frequencies.pm >index 27489a6030..4d5b8d924d 100644 >--- a/Koha/Subscription/Frequencies.pm >+++ b/Koha/Subscription/Frequencies.pm >@@ -43,6 +43,10 @@ sub _type { > return 'SubscriptionFrequency'; > } > >+=head3 object_class >+ >+=cut >+ > sub object_class { > return 'Koha::Subscription::Frequency'; > } >diff --git a/Koha/Subscription/Frequency.pm b/Koha/Subscription/Frequency.pm >index 4450715487..d7d06dc3c0 100644 >--- a/Koha/Subscription/Frequency.pm >+++ b/Koha/Subscription/Frequency.pm >@@ -25,7 +25,11 @@ use base qw(Koha::Object); > > =head1 NAME > >+<<<<<<< b4c9007cc708d995838eae801a5a24b47435095e > Koha::Subscription::Frequency - Koha Subscription Frequency Object class >+======= >+Koha::Subscription::Frequency - Koha Subscription::Frequency Object class >+>>>>>>> Bug 17047 subscriptions management with Mana-KB > > =head1 API > >diff --git a/Koha/Subscription/Numberpattern.pm b/Koha/Subscription/Numberpattern.pm >new file mode 100644 >index 0000000000..049fbfebc4 >--- /dev/null >+++ b/Koha/Subscription/Numberpattern.pm >@@ -0,0 +1,48 @@ >+package Koha::Subscription::Numberpattern; >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use Koha::Database; >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::SubscriptionNumberpattern - Koha SubscriptionNumberpattern Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SubscriptionNumberpattern'; >+} >+ >+=head1 AUTHOR >+ >+Morgane Alonso <morgane.alonso@biblibre.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Subscription/Numberpatterns.pm b/Koha/Subscription/Numberpatterns.pm >new file mode 100644 >index 0000000000..638e0280cb >--- /dev/null >+++ b/Koha/Subscription/Numberpatterns.pm >@@ -0,0 +1,77 @@ >+package Koha::Subscription::Numberpatterns; >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use Koha::Database; >+use Koha::Subscription::Numberpattern; >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::SubscriptionNumberpatterns - Koha SubscriptionNumberpattern object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 uniqeLabel >+ >+=cut >+ >+sub uniqueLabel { >+ my ($self, $label) = @_; >+ >+ my $samelabel = Koha::Subscription::Numberpatterns->search({label => $label})->next(); >+ if ($samelabel) { >+ my $i = 2; >+ my $newlabel = $samelabel->label . " ($i)"; >+ while (my $othersamelabel = $self->search({label => $newlabel})->next()) { >+ $i++; >+ $newlabel = $samelabel->label . " ($i)"; >+ } >+ $label = $newlabel; >+ } >+ return $label; >+} >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SubscriptionNumberpattern'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Subscription::Numberpattern'; >+} >+ >+=head1 AUTHOR >+ >+Morgane Alonso <morgane.alonso@biblibre.com> >+ >+=cut >+ >+1; >diff --git a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql b/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql >new file mode 100644 >index 0000000000..5c590d1c66 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql >@@ -0,0 +1 @@ >+ALTER TABLE subscription ADD mana_id int(11); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc >new file mode 100644 >index 0000000000..4ce9b9b9cf >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc >@@ -0,0 +1,46 @@ >+[% USE KohaDates %] >+<table id="mana_results_datatable"> >+ <thead> >+ <tr> >+ <th>ISSN</th> >+ <th class="anti-the">Title</th> >+ <th>Frequency</th> >+ <th>Numbering pattern</th> >+ <th class="NoSort">Number of users</th> >+ <th class="title-string">Last Import</th> >+ [% UNLESS search_only %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ <tfoot> >+ <tr> >+ <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search frequency" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search numbering pattern" /></td> >+ <td></td> >+ <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search last import" /></td> >+ [% UNLESS search_only %] >+ <td></td> >+ [% END %] >+ </tr> >+ </tfoot> >+ <tbody> >+ [% FOREACH subscription IN subscriptions %] >+ [% UNLESS subscription.cannotdisplay %] >+ <tr id="row[% subscription.subscriptionid %]"> >+ <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td> >+ <td>[% subscription.title %]</a></td> >+ <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td> >+ <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td> >+ <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td> >+ <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td> >+ [% UNLESS search_only %] >+ <td><a style="cursor:pointer" onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</a></td> >+ [% END %] >+ </tr> >+ [% END %] >+ [% END %] >+ </tbody> >+</table> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >index d2dc4c8a7c..257c429c26 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >@@ -31,4 +31,7 @@ > </a> > </li> > <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li> >+ [% IF Koha.Preference('Mana') %] >+ <li><a href="/cgi-bin/koha/serials/serials-search.pl?mana=1">Search on Mana</a></li> >+ [% END %] > </ul> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >index e889278d9e..484a988ab2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >@@ -7,6 +7,13 @@ > [% ELSE %] > <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div> > [% END %] >+ [% IF Koha.Preference('Mana') %] >+ [% IF one_language_enabled==0 or mana_id %] >+ <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-small"><i class="fa fa-share-alt"></i> Share</a></div> >+ [% ELSE %] >+ <div class="btn-group" data-toggle="tooltip" title="Your email address will be associated to your sharing."><a class="btn btn-small" onclick="share()"><i class="fa fa-share-alt"></i> Share</a></div> >+ [% END %] >+ [% END %] > [% END %] > > [% IF ( CAN_user_serials_edit_subscription || CAN_user_serials_create_subscription || CAN_user_serials_delete_subscription ) %] >@@ -63,3 +70,101 @@ > [% END %] > </div> > [% END %] >+ >+<div id="mana_share_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_share_modal_label" style="display: none;"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h3 id="mana_share_modal_label">Share [% bibliotitle %] to Mana</h3> >+ </div> >+ <div class="modal-body"> >+ [% IF (mana_id) %] >+ <div class="alert"> >+ <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwide it will do nothing.</p> >+ </div> >+ [% END %] >+ [% IF ( languages_loop ) %] >+ [% UNLESS ( one_language_enabled ) %] >+ <div class="rows"> >+ <p>The frequency and the numberpattern of [% bibliotitle %] are :</p> >+ <ol> >+ <li><span class="label">Frequency : </span> >+ [% frequency.description %] >+ </li> >+ <li><span class="label">Number pattern : </span> >+ [% numberpattern.label %] >+ </li> >+ </ol> >+ </div> >+ <div class="rows"> >+ <form method="get" id="mana_share_form" action="/cgi-bin/koha/serials/subscription-detail.pl" class="validated" > >+ <fieldset> >+ <label for="mana_language">Language of your sharing :</label> >+ <select id="mana_language" name="mana_language"> >+ [% FOREACH languages_loo IN languages_loop %] >+ [% IF ( languages_loo.group_enabled ) %] >+ [% IF ( languages_loo.plural ) %] >+ [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %] >+ [% IF ( sublanguages_loo.enabled ) %] >+ [% IF ( sublanguages_loo.sublanguage_current ) %] >+ <option value="[% languages_loo.rfc4646_subtag %]" selected> >+ [% sublanguages_loo.native_description %] >+ [% sublanguages_loo.script_description %] >+ [% sublanguages_loo.region_description %] >+ [% sublanguages_loo.variant_description %] >+ ([% sublanguages_loo.rfc4646_subtag %]) >+ </option> >+ [% ELSE %] >+ <option value="[% languages_loo.rfc4646_subtag %]"> >+ [% sublanguages_loo.native_description %] >+ [% sublanguages_loo.script_description %] >+ [% sublanguages_loo.region_description %] >+ [% sublanguages_loo.variant_description %] >+ ([% sublanguages_loo.rfc4646_subtag %]) >+ </option> >+ [% END %] >+ [% END %] >+ [% END %] >+ [% ELSE %] >+ [% IF ( languages_loo.group_enabled ) %] >+ [% IF ( languages_loo.current ) %] >+ <option value="[% languages_loo.rfc4646_subtag %]" selected> >+ [% IF ( languages_loo.native_description ) %] >+ [% languages_loo.native_description %] >+ [% ELSE %] >+ [% languages_loo.rfc4646_subtag %] >+ [% END %] >+ </option> >+ [% ELSE %] >+ <option value="[% languages_loo.rfc4646_subtag %]"> >+ [% IF ( languages_loo.native_description ) %] >+ [% languages_loo.native_description %] >+ [% ELSE %] >+ [% languages_loo.rfc4646_subtag %] >+ [% END %] >+ </option> >+ [% END %] >+ [% END %] >+ [% END %] >+ [% END %] >+ [% END %] >+ </select> >+ <input type="hidden" id="op" name="op" value="share"/> >+ <input type="hidden" id="subscriptionid" name="subscriptionid" value="[% subscriptionid %]"/> >+ </fieldset> >+ </form> >+ </div> >+ [% END %] >+ [% END %] >+ </div> >+ <div class="modal-footer"> >+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> >+ [% IF one_language_enabled==0 %] >+ <button type="submit" form="mana_share_form" class="btn btn-primary">Share</button> >+ [% ELSE %] >+ <div class="btn-group"><a class="btn btn-primary" onclick="share()">Share</a></div> >+ [% END %] >+ </div> >+ </div> >+ </div> >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt >new file mode 100644 >index 0000000000..0afe02c890 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt >@@ -0,0 +1 @@ >+[% INCLUDE 'mana-subscription-search-result.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >index d9630b0130..ff401ed4cb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE Asset %] > [% USE KohaDates %] >+[% USE Koha %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials [% biblionumber | html %]</title> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >index b6c718366d..1886094a02 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >@@ -4,6 +4,7 @@ > [% USE Branches %] > [% USE CGI %] > [% USE KohaDates %] >+[% USE Koha %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials [% biblionumber | html %]</title> >@@ -275,6 +276,7 @@ > [% END %] > </ol> > <input type="hidden" name="searched" value="1" /> >+ [% IF ( mana ) %]<input type="hidden" name="mana" value="1" />[% END %] > <fieldset class="action"> > <input type="submit" value="Search" /> > </fieldset> >@@ -286,9 +288,18 @@ > [% IF ( total ) %] > <div id="serialstabs" class="toptabs" style="clear:both;"> > <ul class="ui-tabs-nav"> >- <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li> >- <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li> >+ [% IF mana %] >+ <li><a href="#mana">Mana ([% total || 0 | html %])</a></li> >+ [% ELSE %] >+ <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li> >+ <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li> >+ [% END %] > </ul> >+ [% IF mana %] >+ <div id="mana"> >+ [% INCLUDE 'mana-subscription-search-result.inc' %] >+ </div> >+ [% ELSE %] > <div id="opened"> > [% IF openedsubscriptions %] > [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %] >@@ -307,6 +318,7 @@ > </div> > [% END %] > </div> >+ [% END %] > </div> > [% ELSE %] > <div class="dialog message"> >@@ -323,6 +335,7 @@ > > [% INCLUDE 'serials-menu.inc' %] > [% IF ( done_searched ) %] >+ [% UNLESS ( mana ) %] > <div id="advsearch"> > <form action="/cgi-bin/koha/serials/serials-search.pl" method="get"> > <fieldset class="brief"> >@@ -395,16 +408,16 @@ > <fieldset class="action"> > <input type="submit" value="Search" /> > </fieldset> >+ > </div> > </fieldset> > </form> > [% END %] >- >+ [% END %] > </aside> > </div> <!-- /.col-sm-2.col-sm-pull-10 --> > </div> <!-- /.row --> > >- > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'datatables.inc' %] >@@ -461,8 +474,18 @@ > ] > })); > >+ var manarlt = $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ "aoColumnDefs": [ >+ { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >+ { "sType": "title-string", "aTargets" : [ "title-string" ] }, >+ { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } >+ ] >+ })); >+ > osrlt.fnAddFilters("dt-filter", 750); > csrlt.fnAddFilters("dt-filter", 750); >+ manarlt.fnAddFilters("dt-filter", 750); > > $('#serialstabs').tabs(); > $("#reopensub").click(function(){ >@@ -484,6 +507,17 @@ > itemSelectionBuildActionLinks(div); > }); > >+ [% IF ( mana ) %] >+ $("label[for=callnumber], input#callnumber").hide(); >+ $("label[for=bookseller], input#bookseller").hide(); >+ $("label[for=branch], select#branch").hide(); >+ $("label[for=to], input#to").hide(); >+ $(".ui-datepicker-trigger").hide(); >+ $("label[for=location], select#location_filter").hide(); >+ [% FOR field IN additional_fields_for_subscription %] >+ $("label[for=additional_field_[% field.id %]], input#additional_field_[% field.id %]").hide(); >+ [% END %] >+ [% END %] > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index edab9b3f0d..3b3a32c569 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -2,6 +2,7 @@ > [% USE Asset %] > [% USE KohaDates %] > [% USE Branches %] >+[% USE Koha %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials › [% IF ( modify ) %][% bibliotitle | html %] › Modify subscription[% ELSE %]New subscription[% END %]</title> >@@ -213,6 +214,9 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ > > <div id="page_2"> > <div class="col-md-6"> >+ <div id="mana_search" class="dialog message"> >+ <p>Frequency and Numbering pattern have been already proposed for this subscription on Mana. To show results, click <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Here</a></p> >+ </div> > <div id="subscription_form_planning"> > <fieldset class="rows"> > <legend>Serials planning</legend> >@@ -477,10 +481,16 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ > </div> > [% END %] > >+ <input type="hidden" id="mana_id" name="mana_id" value=""/> >+ <input type="hidden" id="sndescription" name="sndescription" value=""/> >+ <input type="hidden" id="sfdescription" name="sfdescription" value=""/> >+ <input type="hidden" id="unit" name="unit" value=""/> >+ <input type="hidden" id="unitsperissue" name="unitsperissue" value=""/> >+ <input type="hidden" id="issuesperunit" name="issuesperunit" value=""/> > <fieldset class="action"> > <input type="button" id="subscription_add_previous" value="<< Previous" style="float:left;"/> > <input id="testpatternbutton" type="button" value="Test prediction pattern" /> >- <input type="submit" value="Save subscription" style="float:right;" accesskey="w" /> >+ <input type="submit" onclick="removeDisabledAttr()" value="Save subscription" style="float:right;" accesskey="w"/> > </fieldset> > </div> > </div> >@@ -490,6 +500,20 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ > </div> > </form> > </div> >+ <div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h3 id="mana_search_result_label"></h3> >+ </div> >+ <div class="modal-body"> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> >+ </div> >+ </div> > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'calendar.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index 9f14fbbfb4..fd50f2fa7b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -29,7 +29,7 @@ > <div class="col-sm-10 col-sm-push-2"> > <main> > >- [% INCLUDE 'serials-toolbar.inc' %] >+ [% INCLUDE 'serials-toolbar.inc' mana_id = mana_id %] > > <h1>Subscription for [% bibliotitle | html %] [% IF closed %](closed)[% END %]</h1> > [% IF ( abouttoexpire ) %] >@@ -58,7 +58,18 @@ > </form> > > </div> >- [% END %] <!-- NEEDSCONFIRMATION --> >+ [% END %] <!-- NEEDSCONFIRMATION --> >+ [% IF mana_code.defined %] >+ <div id="alert-community" class="dialog message"> >+ <p> >+ [% IF (mana_code == 201) %] >+ The export is done, thank you for your contribution. >+ [% ELSIF (mana_code == 200) %] >+ The model already exists on Mana, thank you for your contribution. >+ [% END %] >+ </p> >+ </div> >+ [% END %] > > <div id="subscription_description" class="toptabs"> > <ul class="ui-tabs-nav"> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >index c995751431..df26753c5c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -2,6 +2,9 @@ > > var globalnumpatterndata; > var globalfreqdata; >+var mananumpatterndata; >+var manafreqdata; >+var manaid; > var advancedpatternlocked; > var patternneedtobetested = 0; > if ( irregularity !== "" ){ >@@ -85,31 +88,57 @@ function Check_page2(){ > } > > function frequencyload(){ >- $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, >- function(freqdata){ >- globalfreqdata=freqdata; >- if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) { >- var option = $("#subtype option[value='issues']"); >- $(option).attr('selected', 'selected'); >- $("#subtype option[value!='issues']").prop('disabled', true) >- } else { >- $("#subtype option").prop('disabled', false) >- } >+ if ($("#frequency option:selected").val() === "mana"){ >+ globalfreqdata=manafreqdata; >+ $("input[name='sfdescription']").val(manafreqdata.description); >+ $("input[name='unit']").val(manafreqdata.unit); >+ $("input[name='unitsperissue']").val(manafreqdata.unitsperissue); >+ $("input[name='issuesperunit']").val(manafreqdata.issuesperunit); >+ if ($( "#numberpattern option:selected" ).val() === "mana" ) { >+ $("input[name='mana_id']").val(manaid); > } >- ) >+ } else { >+ $.getJSON("subscription-frequency.pl",{"frequency_id":document.f.frequency.value,ajax:'true'}, >+ function(freqdata){ >+ globalfreqdata=freqdata; >+ if ( globalfreqdata.unit && globalfreqdata.unit.length == 0 ) { >+ var option = $("#subtype option[value='issues']"); >+ $(option).attr('selected', 'selected'); >+ $("#subtype option[value!='issues']").prop('disabled', true); >+ } else { >+ $("#subtype option").prop('disabled', false); >+ } >+ } >+ ); >+ $("input[name='mana_id']").val(""); >+ } > } > > function numberpatternload(){ >- $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'}, >- function(numpatterndata){ >- globalnumpatterndata=numpatterndata; >- if (globalnumpatterndata==undefined){ >- return false; >- } >- displaymoreoptions(); >- restoreAdvancedPattern(); >+ if($("#numberpattern option:selected" ).val() === "mana"){ >+ globalnumpatterndata=mananumpatterndata; >+ $("input[name='sndescription']").val(mananumpatterndata.description); >+ if($("#frequency option:selected" ).val() === "mana"){ >+ $("input[name='mana_id']").val(manaid); > } >- ); >+ if (globalnumpatterndata==undefined){ >+ return false; >+ } >+ displaymoreoptions(); >+ restoreAdvancedPattern(); >+ } else { >+ $.getJSON("subscription-numberpattern.pl",{"numberpattern_id":document.f.numbering_pattern.value,ajax:'true'}, >+ function(numpatterndata){ >+ globalnumpatterndata=numpatterndata; >+ if (globalnumpatterndata==undefined){ >+ return false; >+ } >+ displaymoreoptions(); >+ restoreAdvancedPattern(); >+ } >+ ); >+ $("input[name='mana_id']").val(""); >+ } > } > > function displaymoreoptions() { >@@ -275,7 +304,8 @@ function testPredictionPattern() { > 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', > 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', > 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >- 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale' >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', >+ 'sfdescription', 'unitsperissue', 'issuesperunit', 'unit' > ]; > for(i in ajaxParams) { > var param = ajaxParams[i]; >@@ -288,7 +318,7 @@ function testPredictionPattern() { > url:"/cgi-bin/koha/serials/showpredictionpattern.pl", > data: ajaxData, > success: function(data) { >- $("#displayexample").html(data); >+ $("#displayexample").html(data).show(); > patternneedtobetested = 0; > } > }); >@@ -362,8 +392,113 @@ function show_page_2() { > displaymoreoptions(); > } > >+function mana_search() { >+ $.ajax({ >+ type: "POST", >+ url: "/cgi-bin/koha/svc/mana/search", >+ data: {biblionumber : $("#biblionumber").val()}, >+ dataType: "html", >+ }) >+ .done( function( result ) { >+ $("#mana_search_result .modal-body").html(result); >+ $("#mana_search_result_label").text("Results from Mana"); >+ $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ "aoColumnDefs": [ >+ { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >+ { "sType": "title-string", "aTargets" : [ "title-string" ] }, >+ { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } >+ ] >+ })); >+ if($("td.dataTables_empty").length == 0){ >+ $("#mana_search").show(); >+ } >+ }).fail(function(result){ >+ }); >+} >+ >+function mana_use(mana_id){ >+ $("tr").removeClass("selected"); >+ $("#row"+mana_id).addClass("selected"); >+ $.ajax( { >+ type: "POST", >+ url: "/cgi-bin/koha/svc/mana/use", >+ data: {id : mana_id}, >+ dataType: "json", >+ }) >+ .done(function(result){ >+ var select = document.getElementById('numberpattern'); >+ for(i = 0; i < select.length; i++){ >+ if(select[i].value === "mana"){ >+ select.remove(i); >+ } >+ } >+ var optionnumpattern = document.createElement("option"); >+ optionnumpattern.text = result.label + " (mana)"; >+ optionnumpattern.selected = true; >+ optionnumpattern.value="mana"; >+ select.add(optionnumpattern); >+ >+ mananumpatterndata = { >+ id:"mana", >+ add1:result.add1, >+ add2:result.add2, >+ add3:result.add3, >+ description:result.sndescription, >+ displayorder:result.displayorder, >+ every1:result.every1, >+ every2:result.every2, >+ every3:result.every3, >+ label:result.label, >+ label1:result.label1, >+ label2:result.label2, >+ label3:result.label3, >+ numbering1:result.numbering1, >+ numbering2:result.numbering2, >+ numbering3:result.numbering3, >+ numberingmethod:result.numberingmethod, >+ setto1:result.setto1, >+ setto2:result.setto2, >+ setto3:result.setto3, >+ whenmorethan1:result.whenmorethan1, >+ whenmorethan2:result.whenmorethan2, >+ whenmorethan3:result.whenmorethan3, >+ }; >+ select = document.getElementById("frequency"); >+ for(i = 0; i < select.length; i++){ >+ if(select[i].value === "mana"){ >+ select.remove(i); >+ } >+ } >+ var optionfreq = document.createElement("option"); >+ optionfreq.text = result.sfdescription + " (mana)"; >+ optionfreq.selected = true; >+ optionfreq.value="mana"; >+ select.add(optionfreq); >+ manafreqdata = { >+ id:"mana", >+ description:result.sfdescription, >+ displayorder:result.displayorder, >+ issuesperunit:result.issuesperunit, >+ unit:result.unit, >+ unitsperissue:result.unitsperissue, >+ }; >+ manaid = result.id; >+ $("input[name='mana_id']").val(manaid); >+ $("#mana_search_result").modal("hide"); >+ frequencyload(); >+ numberpatternload(); >+ }).fail( function( result ){ >+ }); >+} >+ >+function removeDisabledAttr() { >+ $('select:disabled').removeAttr('disabled'); >+} > > $(document).ready(function() { >+ $("#displayexample").hide(); >+ $("#mana_search_result").modal("hide"); > $("#aqbooksellerid").on('keypress', function(e) { > if (e.keyCode == 13) { > e.preventDefault(); >@@ -447,6 +582,8 @@ $(document).ready(function() { > }); > } > >+ $("#mana_search").hide(); >+ > show_page_1(); > $("#subscription_add_form").on("submit",function(){ > return Check_page2(); >@@ -469,6 +606,9 @@ $(document).ready(function() { > }); > $("#subscription_add_next").on("click",function(){ > if ( Check_page1() ){ >+ [% IF Koha.Preference('Mana') %] >+ mana_search(); >+ [% END %] > show_page_2(); > } > }); >diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl >index aae1e5656a..a478476981 100755 >--- a/misc/cronjobs/serialsUpdate.pl >+++ b/misc/cronjobs/serialsUpdate.pl >@@ -33,6 +33,7 @@ use C4::Debug; > use C4::Serials; > use C4::Log; > use Koha::DateUtils; >+use C4::Serials::Frequency; > > use Date::Calc qw/Date_to_Days check_date/; > use Getopt::Long; >@@ -118,7 +119,8 @@ while ( my $issue = $sth->fetchrow_hashref ) { > my $publisheddate = $issue->{publisheddate}; > > if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) { >- my $nextpublisheddate = GetNextDate( $subscription, $publisheddate ); >+ my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'}); >+ my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata ); > my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > > if ( $nextpublisheddate && $today ) { >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index e8735b319d..7622e7ed9a 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -77,14 +77,16 @@ if($op eq 'gennext' && @subscriptionid){ > require C4::Serials::Numberpattern; > my $subscription = GetSubscription($subscriptionid); > my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequencies($subscription->{periodicity}); > my $expected = GetNextExpected($subscriptionid); > my ( > $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, > $newinnerloop1, $newinnerloop2, $newinnerloop3 >- ) = GetNextSeq($subscription, $pattern, $expected->{publisheddate}); >+ ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}); > > ## We generate the next publication date >- my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); >+ my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); >+ my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1); > my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate; > ## Creating the new issue > NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index 30bf7db87c..d6cb85cece 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -38,6 +38,7 @@ use C4::Serials; > use Koha::AdditionalField; > > use Koha::DateUtils; >+use Koha::SharedContent; > > my $query = new CGI; > my $title = $query->param('title_filter') || ''; >@@ -52,6 +53,7 @@ my $location = $query->param('location_filter') || ''; > my $expiration_date = $query->param('expiration_date_filter') || ''; > my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); > my $searched = $query->param('searched') || 0; >+my $mana = $query->param('mana') || 0; > my @subscriptionids = $query->multi_param('subscriptionid'); > my $op = $query->param('op'); > >@@ -95,7 +97,17 @@ for my $field ( @$additional_fields ) { > my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef; > my @subscriptions; > if ($searched){ >- @subscriptions = SearchSubscriptions( >+ if ($mana) { >+ my $result = Koha::SharedContent::manaGetRequest("subscription",{ >+ title => $title, >+ issn => $ISSN, >+ ean => $EAN, >+ publisher => $publisher >+ }); >+ @subscriptions = @{ $result->{data} }; >+ } >+ else { >+ @subscriptions = SearchSubscriptions( > { > biblionumber => $biblionumber, > title => $title, >@@ -108,46 +120,84 @@ if ($searched){ > additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}{value}, authorised_value_category => $additional_field_filters->{$_}{authorised_value_category} } } keys %$additional_field_filters ], > location => $location, > expiration_date => $expiration_date_dt, >- } >- ); >+ }); >+ } > } > >-# to toggle between create or edit routing list options >-if ($routing) { >- for my $subscription ( @subscriptions) { >- $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); >- } >+if ($mana) { >+ $template->param( >+ subscriptions => \@subscriptions, >+ total => scalar @subscriptions, >+ title_filter => $title, >+ ISSN_filter => $ISSN, >+ EAN_filter => $EAN, >+ callnumber_filter => $callnumber, >+ publisher_filter => $publisher, >+ bookseller_filter => $bookseller, >+ branch_filter => $branch, >+ location_filter => $location, >+ expiration_date_filter => $expiration_date_dt, >+ done_searched => $searched, >+ routing => $routing, >+ additional_field_filters => $additional_field_filters, >+ additional_fields_for_subscription => $additional_fields, >+ marcflavour => (uc(C4::Context->preference("marcflavour"))), >+ mana => $mana, >+ search_only => 1 >+ ); > } >+else >+{ >+ # to toggle between create or edit routing list options >+ if ($routing) { >+ for my $subscription ( @subscriptions) { >+ $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); >+ } >+ } > >-my (@openedsubscriptions, @closedsubscriptions); >-for my $sub ( @subscriptions ) { >- unless ( $sub->{closed} ) { >- push @openedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >- } else { >- push @closedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >+ my (@openedsubscriptions, @closedsubscriptions); >+ for my $sub ( @subscriptions ) { >+ unless ( $sub->{closed} ) { >+ push @openedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } else { >+ push @closedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } > } >-} > >-$template->param( >- openedsubscriptions => \@openedsubscriptions, >- closedsubscriptions => \@closedsubscriptions, >- total => @openedsubscriptions + @closedsubscriptions, >- title_filter => $title, >- ISSN_filter => $ISSN, >- EAN_filter => $EAN, >- callnumber_filter => $callnumber, >- publisher_filter => $publisher, >- bookseller_filter => $bookseller, >- branch_filter => $branch, >- location_filter => $location, >- expiration_date_filter => $expiration_date_dt, >- done_searched => $searched, >- routing => $routing, >- additional_field_filters => $additional_field_filters, >- additional_fields_for_subscription => $additional_fields, >- marcflavour => (uc(C4::Context->preference("marcflavour"))) >-); >+ my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } ); >+ my @branches_loop; >+ foreach my $b ( @branches ) { >+ my $selected = 0; >+ $selected = 1 if( defined $branch and $branch eq $b->branchcode ); >+ push @branches_loop, { >+ branchcode => $b->branchcode, >+ branchname => $b->branchname, >+ selected => $selected, >+ }; >+ } > >+ $template->param( >+ openedsubscriptions => \@openedsubscriptions, >+ closedsubscriptions => \@closedsubscriptions, >+ total => @openedsubscriptions + @closedsubscriptions, >+ title_filter => $title, >+ ISSN_filter => $ISSN, >+ EAN_filter => $EAN, >+ callnumber_filter => $callnumber, >+ publisher_filter => $publisher, >+ bookseller_filter => $bookseller, >+ branch_filter => $branch, >+ location_filter => $location, >+ expiration_date_filter => $expiration_date_dt, >+ branches_loop => \@branches_loop, >+ done_searched => $searched, >+ routing => $routing, >+ additional_field_filters => $additional_field_filters, >+ additional_fields_for_subscription => $additional_fields, >+ marcflavour => (uc(C4::Context->preference("marcflavour"))), >+ mana => $mana >+ ); >+} > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 6986b5efad..ec55f0e079 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -56,7 +56,21 @@ my $subtype = $input->param('subtype'); > my $sublength = $input->param('sublength'); > my $custompattern = $input->param('custompattern'); > >-my $frequency = GetSubscriptionFrequency($frequencyid); >+ >+my $frequency; >+if ( $frequencyid eq 'mana' ) { >+ $frequency = { >+ 'id' => undef, >+ 'displayorder' => undef, >+ 'description' => scalar $input->param('sfdescription') // '', >+ 'unitsperissue' => scalar $input->param('unitsperissue') // '', >+ 'issuesperunit' => scalar $input->param('issuesperunit') // '', >+ 'unit' => scalar $input->param('unit') // '' >+ }; >+} >+else { >+ $frequency = GetSubscriptionFrequency($frequencyid); >+} > > my %pattern = ( > numberingmethod => scalar $input->param('numberingmethod') // '', >@@ -98,14 +112,13 @@ my %subscription = ( > innerloop2 => scalar $input->param('innerloop2') // '', > innerloop3 => scalar $input->param('innerloop3') // '', > irregularity => '', >- periodicity => $frequencyid, > countissuesperunit => 1, > firstacquidate => $firstacquidate, > ); > > my $issuenumber; > if(defined $subscriptionid) { >- ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date); >+ ($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date, $frequency); > } else { > $issuenumber = 1; > } >@@ -135,7 +148,7 @@ while( $i < 1000 ) { > my %line; > > if(defined $date){ >- $date = GetNextDate(\%subscription, $date); >+ $date = GetNextDate(\%subscription, $date, $frequency); > } > if(defined $date){ > $line{'publicationdate'} = $date; >@@ -156,7 +169,7 @@ while( $i < 1000 ) { > last; > } > >- ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern); >+ ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern, $frequency); > $issuenumber++; > $line{'number'} = $calculated; > $line{'issuenumber'} = $issuenumber; >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index fb7e797762..71166b8105 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -35,6 +35,10 @@ use Koha::DateUtils; > use Koha::ItemTypes; > use Carp; > >+use Koha::Subscription::Numberpattern; >+use Koha::Subscription::Frequency; >+use Koha::SharedContent; >+ > #use Smart::Comments; > > our $query = CGI->new; >@@ -288,15 +292,61 @@ sub _guess_enddate { > return $enddate; > } > >+sub manage_subscription_numbering_pattern_id { >+ my $params; >+ if ( $query->param('numbering_pattern') eq 'mana' ) { >+ foreach (qw/numberingmethod label1 add1 every1 whenmorethan1 setto1 >+ numbering1 label2 add2 every2 whenmorethan2 setto2 numbering2 >+ label3 add3 every3 whenmorethan3 setto3 numbering3/) { >+ $params->{$_} = $query->param($_) if $query->param($_); >+ } >+ >+ my $existing = Koha::Subscription::Numberpatterns->search($params)->next(); >+ >+ if ($existing) { >+ return $existing->id; >+ } >+ >+ $params->{label} = Koha::Subscription::Numberpattern->uniqueLabel($query->param('patternname')); >+ $params->{description} = $query->param('sndescription'); >+ >+ >+ my $subscription_np = Koha::Subscription::Numberpattern->new()->set($params)->store(); >+ return $subscription_np->id; >+ } >+ >+ return $query->param('numbering_pattern'); >+} >+ >+sub manage_subscription_frequencies_id { >+ my $periodicity; >+ if ( $query->param('frequency') eq 'mana' ) { >+ my $subscription_freq = Koha::Subscription::Frequency->new()->set( >+ { >+ description => $query->param('sfdescription'), >+ unit => $query->param('unit'), >+ unitsperissue => $query->param('unitsperissue'), >+ issuesperunit => $query->param('issuesperunit'), >+ } >+ )->store(); >+ $periodicity = $subscription_freq->id; >+ } >+ else { >+ $periodicity = $query->param('frequency'); >+ } >+ return $periodicity; >+} >+ > sub redirect_add_subscription { >+ my $periodicity = manage_subscription_frequencies_id(); >+ my $numberpattern = manage_subscription_numbering_pattern_id(); >+ > my $auser = $query->param('user'); > my $branchcode = $query->param('branchcode'); > my $aqbooksellerid = $query->param('aqbooksellerid'); > my $cost = $query->param('cost'); > my $aqbudgetid = $query->param('aqbudgetid'); >- my $periodicity = $query->param('frequency'); > my @irregularity = $query->multi_param('irregularity'); >- my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $graceperiod = $query->param('graceperiod') || 0; > >@@ -326,6 +376,15 @@ sub redirect_add_subscription { > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); > >+ my $mana_id; >+ if ( $query->param('mana_id') ne "" ) { >+ $mana_id = $query->param('mana_id'); >+ Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id); >+ } >+ else { >+ $mana_id = undef; >+ } >+ > my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); > my $enddate = output_pref( { str => scalar $query->param('enddate'), dateonly => 1, dateformat => 'iso' } ); > my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); >@@ -337,7 +396,6 @@ sub redirect_add_subscription { > $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) > } > } >- > my $subscriptionid = NewSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, > $startdate, $periodicity, $numberlength, $weeklength, >@@ -346,7 +404,7 @@ sub redirect_add_subscription { > join(";",@irregularity), $numberpattern, $locale, $callnumber, > $manualhistory, $internalnotes, $serialsadditems, > $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >- $skip_serialseq, $itemtype, $previousitemtype >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >@@ -376,13 +434,13 @@ sub redirect_mod_subscription { > ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } ) > : $firstacquidate; > >- my $periodicity = $query->param('frequency'); >+ my $periodicity = manage_subscription_frequencies_id(); >+ my $numberpattern = manage_subscription_numbering_pattern_id(); > > my $subtype = $query->param('subtype'); > my $sublength = $query->param('sublength'); > my ($numberlength, $weeklength, $monthlength) > = _get_sub_length( $subtype, $sublength ); >- my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $lastvalue1 = $query->param('lastvalue1'); > my $innerloop1 = $query->param('innerloop1'); >@@ -405,6 +463,15 @@ sub redirect_mod_subscription { > my $previousitemtype = $query->param('previousitemtype'); > my $skip_serialseq = $query->param('skip_serialseq'); > >+ my $mana_id; >+ if ( defined( $query->param('mana_id') ) ) { >+ $mana_id = $query->param('mana_id'); >+ Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id); >+ } >+ else { >+ $mana_id = undef; >+ } >+ > # Guess end date > if(!defined $enddate || $enddate eq '') { > if($subtype eq "issues") { >@@ -430,7 +497,7 @@ sub redirect_mod_subscription { > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, > $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >- $skip_serialseq, $itemtype, $previousitemtype >+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index fb8721cf8e..7f6f0264be 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -33,6 +33,12 @@ use Koha::Acquisition::Bookseller; > use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/; > use Carp; > >+use LWP::UserAgent; >+use Koha::SharedContent; >+use Koha::Patrons; >+use Koha::Subscriptions; >+use Koha::Libraries; >+ > my $query = new CGI; > my $op = $query->param('op') || q{}; > my $issueconfirmed = $query->param('issueconfirmed'); >@@ -72,31 +78,72 @@ my ($totalissues,@serialslist) = GetSerials($subscriptionid); > $totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue) > > if ($op eq 'del') { >- if ($$subs{'cannotedit'}){ >- carp "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; >- print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); >- exit; >- } >- >+ if ($$subs{'cannotedit'}){ >+ carp "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; >+ print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); >+ exit; >+ } >+ > # Asking for confirmation if the subscription has not strictly expired yet or if it has linked issues > my $strictlyexpired = HasSubscriptionStrictlyExpired($subscriptionid); > my $linkedissues = CountIssues($subscriptionid); > my $countitems = HasItems($subscriptionid); > if ($strictlyexpired == 0 || $linkedissues > 0 || $countitems>0) { >- $template->param(NEEDSCONFIRMATION => 1); >- if ($strictlyexpired == 0) { $template->param("NOTEXPIRED" => 1); } >- if ($linkedissues > 0) { $template->param("LINKEDISSUES" => 1); } >- if ($countitems > 0) { $template->param("LINKEDITEMS" => 1); } >+ $template->param(NEEDSCONFIRMATION => 1); >+ if ($strictlyexpired == 0) { $template->param("NOTEXPIRED" => 1); } >+ if ($linkedissues > 0) { $template->param("LINKEDISSUES" => 1); } >+ if ($countitems > 0) { $template->param("LINKEDITEMS" => 1); } > } else { >- $issueconfirmed = "1"; >+ $issueconfirmed = "1"; > } > # If it's ok to delete the subscription, we do so > if ($issueconfirmed eq "1") { >- &DelSubscription($subscriptionid); >+ &DelSubscription($subscriptionid); > print $query->redirect("/cgi-bin/koha/serials/serials-home.pl"); > exit; > } > } >+elsif ( $op and $op eq "share" ) { >+ my $mana_language; >+ if ( $query->param('mana_language') ) { >+ $mana_language = $query->param('mana_language'); >+ } >+ else { >+ $mana_language = C4::Context->preference('language'); >+ } >+ >+ my $mana_email; >+ if ( $loggedinuser ne 0 ) { >+ my $borrower = Koha::Patrons->find($loggedinuser); >+ $mana_email = $borrower->email >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ $mana_email = $borrower->emailpro >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ $mana_email = >+ Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ } >+ $mana_email = C4::Context->preference('KohaAdminEmailAddress') >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ my %versions = C4::Context::get_versions(); >+ >+ my $mana_info = { >+ language => $mana_language, >+ kohaversion => $versions{'kohaVersion'}, >+ exportemail => $mana_email >+ }; >+ my $sub_mana_info = Koha::Subscription::get_sharable_info($subscriptionid); >+ $sub_mana_info = { %$sub_mana_info, %$mana_info }; >+ my $result = Koha::SharedContent::manaPostRequest( "subscription", >+ $sub_mana_info ); >+ if ( $result->{code} eq "200" and $result->{code} eq "201" ) { >+ my $subscription = Koha::Subscriptions->find($subscriptionid); >+ $subscription->set( { mana_id => $result->{id} } )->store; >+ $subs->{mana_id} = $result->{id}; >+ } >+ $template->param( mana_code => $result->{code} ); >+} >+ > my $hasRouting = check_routing($subscriptionid); > > (undef, $cookie, undef, undef) >diff --git a/svc/mana/search b/svc/mana/search >new file mode 100755 >index 0000000000..0f58c84009 >--- /dev/null >+++ b/svc/mana/search >@@ -0,0 +1,62 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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 strict; >+use warnings; >+ >+use Koha::SharedContent; >+use Koha::Subscription; >+use C4::Auth qw(check_cookie_auth), qw(get_template_and_user); >+use C4::Output qw( output_with_http_headers ); >+ >+use CGI; >+use JSON; >+ >+my $input = new CGI; >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $input->cookie('CGISESSID'), >+ { serials => 'create_subscription' } ); >+ >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "serials/mana-subscription-search-result.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ >+ # flagsrequired => { serials => $permission }, >+ flagsrequired => { serials => 'create_subscription' }, >+ debug => 1, >+ } >+); >+ >+my $biblionumber = $input->param('biblionumber'); >+ >+my $sub_mana_info = Koha::Subscription::get_search_info($biblionumber); >+my $result = >+ Koha::SharedContent::manaGetRequest( "subscription", $sub_mana_info ); >+$template->param( subscriptions => $result->{data} ); >+ >+output_with_http_headers $input, $cookie, $template->output, 'json'; >diff --git a/svc/mana/use b/svc/mana/use >new file mode 100755 >index 0000000000..a2f2e440e6 >--- /dev/null >+++ b/svc/mana/use >@@ -0,0 +1,48 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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 strict; >+use warnings; >+ >+use Koha::SharedContent; >+use C4::Auth qw(check_cookie_auth); >+ >+use CGI; >+use JSON; >+ >+ >+my $input = new CGI; >+binmode STDOUT, ":encoding(UTF-8)"; >+print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+ >+my ( $auth_status, $sessionID ) = >+ check_cookie_auth( $input->cookie('CGISESSID'), >+ { serials => 'create_subscription' } ); >+ >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $result = Koha::SharedContent::manaGetRequestWithId("subscription", $input->param('id') ); >+ >+my $subscription; >+$subscription = $result->{data}; >+ >+print(to_json($subscription)); >diff --git a/t/db_dependent/Koha/SharedContent.t b/t/db_dependent/Koha/SharedContent.t >new file mode 100644 >index 0000000000..3784028f3b >--- /dev/null >+++ b/t/db_dependent/Koha/SharedContent.t >@@ -0,0 +1,29 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# 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 t::lib::TestBuilder; >+use Test::More tests => 1; >+use Koha::Database; >+ >+use_ok('Koha::SharedContent'); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; # mode insertion >diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t >index 1218e05619..c3789179cd 100644 >--- a/t/db_dependent/Koha/Subscription.t >+++ b/t/db_dependent/Koha/Subscription.t >@@ -19,18 +19,22 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 10; > >+use Koha::Database; >+use Koha::Subscription; > use Koha::Subscriptions; > use Koha::Biblio; >+use Koha::Biblios; > > use t::lib::TestBuilder; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >- > my $builder = t::lib::TestBuilder->new; > >+use_ok('Koha::Subscription'); >+ > subtest 'Koha::Subscription->biblio' => sub { > plan tests => 1; > >@@ -101,6 +105,80 @@ subtest 'Koha::Subscription->frequency' => sub { > is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' ); > }; > >+my $nb_of_subs = Koha::Subscriptions->search->count; >+my $biblio_1 = $builder->build( { source => 'Biblio' } ); >+my $bi_1 = $builder->build( >+ { >+ source => 'Biblioitem', >+ value => { >+ biblionumber => $biblio_1->{biblionumber} >+ } >+ } >+); >+my $sub_freq_1 = $builder->build( { source => 'SubscriptionFrequency' } ); >+my $sub_np_1 = $builder->build( { source => 'SubscriptionNumberpattern' } ); >+my $sub_1 = $builder->build( >+ { >+ source => 'Subscription', >+ value => { >+ biblionumber => $biblio_1->{biblionumber}, >+ periodicity => $sub_freq_1->{id}, >+ numberpattern => $sub_np_1->{id} >+ } >+ } >+); >+ >+is( >+ Koha::Subscriptions->search->count, >+ $nb_of_subs + 1, >+ 'The subscription should have been added' >+); >+is( >+ $sub_1->{biblionumber}, >+ $biblio_1->{biblionumber}, >+ 'The link between sub and biblio is well done' >+); >+is( $sub_1->{periodicity}, $sub_freq_1->{id}, >+ 'The link between sub and sub_freq is well done' ); >+is( $sub_1->{numberpattern}, >+ $sub_np_1->{id}, >+ 'The link between sub and sub_numberpattern is well done' ); >+ >+my $ref = { >+ 'title' => $biblio_1->{title}, >+ 'sfdescription' => $sub_freq_1->{description}, >+ 'unit' => $sub_freq_1->{unit}, >+ 'unitsperissue' => $sub_freq_1->{unitsperissue}, >+ 'issuesperunit' => $sub_freq_1->{issuesperunit}, >+ 'sndescription' => $sub_np_1->{description}, >+ 'numberingmethod' => $sub_np_1->{numberingmethod}, >+ 'label' => $sub_np_1->{label}, >+ 'label1' => $sub_np_1->{label1}, >+ 'add1' => $sub_np_1->{add1}, >+ 'every1' => $sub_np_1->{every1}, >+ 'whenmorethan1' => $sub_np_1->{whenmorethan1}, >+ 'setto1' => $sub_np_1->{setto1}, >+ 'numbering1' => $sub_np_1->{numbering1}, >+ 'label2' => $sub_np_1->{label2}, >+ 'add2' => $sub_np_1->{add2}, >+ 'every2' => $sub_np_1->{every2}, >+ 'whenmorethan2' => $sub_np_1->{whenmorethan2}, >+ 'setto2' => $sub_np_1->{setto2}, >+ 'numbering2' => $sub_np_1->{numbering2}, >+ 'label3' => $sub_np_1->{label3}, >+ 'add3' => $sub_np_1->{add3}, >+ 'every3' => $sub_np_1->{every3}, >+ 'whenmorethan3' => $sub_np_1->{whenmorethan3}, >+ 'setto3' => $sub_np_1->{setto3}, >+ 'numbering3' => $sub_np_1->{numbering3}, >+ 'issn' => $bi_1->{issn}, >+ 'ean' => $bi_1->{ean}, >+ 'publishercode' => $bi_1->{publishercode} >+}; >+ >+is_deeply( Koha::Subscription::get_sharable_info( $sub_1->{subscriptionid} ), >+ $ref, "get_sharable_info function is ok" ); >+ > $schema->storage->txn_rollback; > > 1; >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 323e821f6e..35e5a6493a 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -283,7 +283,8 @@ my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscrip > ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); > my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); > ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); >-my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, 1); >+my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); >+my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, $frequency, 1); > my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 ); > # Add 14 serials > my $counter = 0; >diff --git a/t/db_dependent/Serials/GetFictiveIssueNumber.t b/t/db_dependent/Serials/GetFictiveIssueNumber.t >index 993baf4cfb..e944de982a 100644 >--- a/t/db_dependent/Serials/GetFictiveIssueNumber.t >+++ b/t/db_dependent/Serials/GetFictiveIssueNumber.t >@@ -1,220 +1,126 @@ > #!/usr/bin/perl > >-# This test deals with GetFictiveIssueNumber (from C4::Serials) >- >+use C4::Context; >+use Test::More tests => 18; > use Modern::Perl; >-use Test::More tests => 5; >- >-use Koha::Database; >-use C4::Serials; >-use C4::Serials::Frequency; > >-my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; > my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; > >-subtest 'Tests for irregular frequency' => sub { >- plan tests => 2; >- >- # Add a frequency >- my $freq_irr = AddSubscriptionFrequency({ >- description => "Irregular", >- unit => undef, >- }); >+use C4::Serials::Frequency; >+use C4::Serials; > >- # Test it >- my $subscription = { >- periodicity => $freq_irr, >- firstacquidate => '1972-02-07', >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-12-31'), undef, 'Irregular: should be undef' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-12-31'), undef, 'Irregular: still undef' ); >+# TEST CASE - 1 issue per day, no irregularities >+my $frequency = { >+ description => "One issue per day", >+ unit => 'day', >+ issuesperunit => 1, >+ unitsperissue => 1, > }; > >-subtest 'Tests for yearly frequencies' => sub { >- plan tests => 10; >- >- # First add a few frequencies >- my $freq_1i_1y = AddSubscriptionFrequency({ >- description => "1 issue per year", >- unit => 'year', >- issuesperunit => 1, >- unitsperissue => 1, >- }); >- my $freq_1i_3y = AddSubscriptionFrequency({ >- description => "1 issue per 3 years", >- unit => 'year', >- issuesperunit => 1, >- unitsperissue => 3, >- }); >- my $freq_5i_1y = AddSubscriptionFrequency({ >- description => "5 issues per year", >- unit => 'year', >- issuesperunit => 5, >- unitsperissue => 1, >- }); >- my $freq_366i_1y = AddSubscriptionFrequency({ >- description => "366 issue per year", >- unit => 'year', >- issuesperunit => 366, >- unitsperissue => 1, >- }); >- >- # TEST CASE - 1 issue per year >- my $subscription = { >- periodicity => $freq_1i_1y, >- firstacquidate => '1972-02-10', >- countissuesperunit => 1, >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-09'), 1, 'Feb 9 still 1' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-10'), 2, 'Feb 10 goes to 2' ); >- >- # TEST CASE - 1 issue per 3 years >- $subscription->{periodicity} = $freq_1i_3y; >- $subscription->{firstacquidate} = '1972-02-20'; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1975-02-19'), 1, 'Feb 19, 1975 still 1' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1975-02-20'), 2, 'Feb 20, 1975 goes to 2' ); >- >- # TEST CASE - 5 issues per year >- $subscription->{periodicity} = $freq_5i_1y; >- $subscription->{firstacquidate} = '1972-02-29'; #leap year >- $subscription->{countissuesperunit} = 1; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-11'), 1, 'May 11 still 1' ); >- $subscription->{countissuesperunit} = 2; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-12'), 2, 'May 12 goes to 2' ); >- $subscription->{countissuesperunit} = 5; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-27'), 5, 'Feb 27 should still be 5' ); >- $subscription->{countissuesperunit} = 1; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-28'), 6, 'Feb 28 goes to 6' ); >- >- # TEST CASE - 366 issues per year (hypothetical example) >- # Testing prevention of divide by zero >- $subscription->{periodicity} = $freq_366i_1y; >- $subscription->{firstacquidate} = '1972-02-29'; #leap year >- $subscription->{countissuesperunit} = 366; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-27'), 366, 'Feb 27 still at 366' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-02-28'), 732, 'Feb 28 goes to 732' ); >- >+my $subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, > }; >- >-subtest 'Tests for monthly frequencies' => sub { >- plan tests => 8; >- >- # First add a few frequencies >- my $freq_1i_5m = AddSubscriptionFrequency({ >- description => "1 issue per 5 months", >- unit => 'month', >- issuesperunit => 1, >- unitsperissue => 5, >- }); >- my $freq_4i_1m = AddSubscriptionFrequency({ >- description => "4 issue per month", >- unit => 'month', >- issuesperunit => 4, >- unitsperissue => 1, >- }); >- >- # TEST CASE - 1 issue per 5 months >- my $subscription = { >- periodicity => $freq_1i_5m, >- firstacquidate => '1972-02-10', >- countissuesperunit => 1, >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-09'), 1, 'Jul 9 still 1' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-10'), 2, 'Jul 10 goes to 2' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-09'), 3, 'May 9 still 3' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-10'), 4, 'May 10 goes to 4' ); >- >- # TEST CASE - 4 issue per 1 months >- $subscription = { >- periodicity => $freq_4i_1m, >- firstacquidate => '1972-02-22', >- countissuesperunit => 1, >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-28'), 1, 'Feb 28 still 1' ); >- $subscription->{countissuesperunit} = 2; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-29'), 2, 'Feb 29 goes to 2' ); >- $subscription->{countissuesperunit} = 4; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-21'), 4, 'Mar 21 still 4' ); >- $subscription->{countissuesperunit} = 1; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-22'), 5, 'Mar 22 goes to 5' ); >- >+my $issueNumber; >+ >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '1' ); >+ >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '2' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '3' ); >+ >+# TEST CASE - 2 issues per day, no irregularity >+$frequency = { >+ description => "Two issues per day", >+ unit => 'day', >+ issuesperunit => 2, >+ unitsperissue => 1, > }; >- >-subtest 'Tests for weekly frequencies' => sub { >- plan tests => 4; >- >- # First add a few frequencies >- my $freq_1i_7w = AddSubscriptionFrequency({ >- description => "1 issue per 7 weeks", >- unit => 'week', >- issuesperunit => 1, >- unitsperissue => 7, >- }); >- my $freq_3i_1w = AddSubscriptionFrequency({ >- description => "3 issues per week", >- unit => 'week', >- issuesperunit => 3, >- unitsperissue => 1, >- }); >- >- # TEST CASE - 1 issue per 7 weeks >- my $subscription = { >- periodicity => $freq_1i_7w, >- firstacquidate => '1972-02-10', >- countissuesperunit => 1, >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-29'), 1, 'Mar 29 still 1' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-30'), 2, 'Mar 30 goes to 2' ); >- >- # TEST CASE - 3 issue per 1 week >- $subscription = { >- periodicity => $freq_3i_1w, >- firstacquidate => '1972-02-03', >- countissuesperunit => 1, >- }; >- $subscription->{countissuesperunit} = 3; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-09'), 3, 'Feb 9 still 3' ); >- $subscription->{countissuesperunit} = 1; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-10'), 4, 'Feb 10 goes to 4' ); >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, > }; >- >-subtest 'Tests for dayly frequencies' => sub { >- plan tests => 4; >- >- # First add a few frequencies >- my $freq_1i_12d = AddSubscriptionFrequency({ >- description => "1 issue per 12 days", >- unit => 'day', >- issuesperunit => 1, >- unitsperissue => 12, >- }); >- my $freq_3i_1d = AddSubscriptionFrequency({ >- description => "3 issues per day", >- unit => 'day', >- issuesperunit => 3, >- unitsperissue => 1, >- }); >- >- # TEST CASE - 1 issue per 12 days >- my $subscription = { >- periodicity => $freq_1i_12d, >- firstacquidate => '1972-03-16', >- countissuesperunit => 1, >- }; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-27'), 1, 'Mar 27 still 1' ); >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-28'), 2, 'Mar 28 goes to 2' ); >- >- # TEST CASE - 3 issue per day >- $subscription = { >- periodicity => $freq_3i_1d, >- firstacquidate => '1972-04-23', >- countissuesperunit => 1, >- }; >- $subscription->{countissuesperunit} = 3; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-01'), 27, 'May 1 still 27' ); >- $subscription->{countissuesperunit} = 1; >- is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-05-02'), 28, 'May 2 goes to 28' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '1' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '3' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '5' ); >+ >+$subscription->{countissuesperunit} = 2; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, '2' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, '4' ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, '6' ); >+ >+# TEST CASE - 1 issue every 2 days, no irregularity >+$frequency = { >+ description => "one issue every two days", >+ unit => 'day', >+ issuesperunit => 1, >+ unitsperissue => 2, > }; >- >-$schema->storage->txn_rollback; >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-03', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-04', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-05', $frequency ); >+is( $issueNumber, 3 ); >+ >+# TEST CASE - 1 issue per week, no irregularity >+$frequency = { >+ description => "one issue per week", >+ unit => 'week', >+ issuesperunit => 1, >+ unitsperissue => 1, >+}; >+$subscription = { >+ firstacquidate => '1970-01-01', >+ irregularity => '', >+ countissuesperunit => 1, >+}; >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-01', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-02', $frequency ); >+is( $issueNumber, 1 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-08', $frequency ); >+is( $issueNumber, 2 ); >+$issueNumber = >+ C4::Serials::GetFictiveIssueNumber( $subscription, '1970-01-15', $frequency ); >+is( $issueNumber, 3 ); >+ >+$dbh->rollback; >diff --git a/t/db_dependent/Serials/GetNextDate.t b/t/db_dependent/Serials/GetNextDate.t >index a0422d7ce4..bcbb76c1ad 100644 >--- a/t/db_dependent/Serials/GetNextDate.t >+++ b/t/db_dependent/Serials/GetNextDate.t >@@ -19,552 +19,525 @@ my $frequency = { > issuesperunit => 1, > unitsperissue => 1, > }; >-my $id = AddSubscriptionFrequency($frequency); > > my $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > my $publisheddate = $subscription->{firstacquidate}; > >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); > > # TEST CASE - 1 issue per day, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', # Skip the second and fourth issues > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-06'); > > # TEST CASE - 2 issues per day, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "Two issues per day", > unit => 'day', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); > > # TEST CASE - 2 issues per day, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); > > # TEST CASE - 1 issue every 2 days, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue every two days", > unit => 'day', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-05'); > > # TEST CASE - 1 issue every 2 days, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-03'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); > > # TEST CASE - 1 issue per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue per week", > unit => 'week', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); > > # TEST CASE - 1 issue per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-22'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); > > # TEST CASE - 1 issue every 2 weeks, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "one issue every 2 weeks", > unit => 'week', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-12'); > > # TEST CASE - 1 issue every 2 weeks, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-12'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-26'); > > # TEST CASE - 2 issues per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "two issues per week", > unit => 'week', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+# when more than 1 issue per week, date is automatically set to the same day of >+# week as firstacquidate >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-11'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-15'); > > # TEST CASE - 2 issues per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-04'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-11'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-22'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-25'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-29'); > > # TEST CASE - 6 issues per week, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "six issues per week", > unit => 'week', > issuesperunit => 6, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-06', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-08'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-10'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-11'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-13'); > > # TEST CASE - 6 issues per week, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-06', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-07'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-09'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-13'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-01-14'); > > # TEST CASE - 1 issue per month, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue per month", > unit => 'month', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-02-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-04-01'); > > # TEST CASE - 1 issue per month, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-05-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-06-01'); > > # TEST CASE - 1 issue every 2 months, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue every 2 months", > unit => 'month', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-03-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-05-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-01'); > > # TEST CASE - 1 issue every 2 months, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;3', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-09-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-11-01'); > > # TEST CASE - 2 issues per month, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "2 issues per month", > unit => 'month', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-16', 'Jan 16'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-01', 'Feb 1'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-16', 'Feb 16'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-03-01', 'Mar 1' ); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-01-16', 'January has 31 days'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-02-01'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-02-16', 'February has only 28 days'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-03-01'); > > # TEST CASE - 2 issues per month, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-16', 'Jan 16' ); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-16', 'Feb 16 (skipping Feb 1)' ); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-04-01', 'Apr 1 (skipping Mar 1 and 16)' ); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-04-16', 'Apr 16' ); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-05-01', 'May 1' ); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-01-16', 'January has 31 days'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-02-16', 'February has only 28 days'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-04-01'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-04-16', 'April has 30 days'); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+is($publisheddate, '1970-05-01'); > > # TEST CASE - 1 issue per year, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue per year", > unit => 'year', > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-01-01'); > > # TEST CASE - 1 issue per year, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1975-01-01'); > > # TEST CASE - 1 issue every 2 years, no irregularity >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "1 issue every 2 years", > unit => 'year', > issuesperunit => 1, > unitsperissue => 2, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1976-01-01'); > > # TEST CASE - 1 issue every 2 years, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '2;4', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1978-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1980-01-01'); > # Move publisheddate to Feb 29 (leap year 1980) > $publisheddate = '1980-02-29'; >-$publisheddate = GetNextDate( $subscription, $publisheddate ); >+$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency ); > is( $publisheddate, '1982-02-28', 'Test +2 year from Feb 29' ); > > # TEST CASE - 2 issues per year, no irregularity >-$id = AddSubscriptionFrequency({ >- description => "2 issues per year", >+$frequency = { >+ description => "1 issue every 2 years", > unit => 'year', > issuesperunit => 2, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1972-01-01'); > > # TEST CASE - 2 issues per year, irregularities > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '3;5;6', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1970-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1971-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-01-01'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1973-07-02'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, '1974-01-01'); > > # TEST CASE - 9 issues per year, dates spread throughout month >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "9 issues per year", > unit => 'year', > issuesperunit => 9, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-08-10', > irregularity => '', > countissuesperunit => 1, > }; > my @dates = ( $subscription->{firstacquidate} ); > foreach(1..27) { >- push @dates, GetNextDate( $subscription, $dates[-1] ); >+ push @dates, GetNextDate( $subscription, $dates[-1], $frequency ); > } > is( $dates[9], '1971-08-10', 'Freq 9/yr, 1 year passed' ); > is( $dates[18], '1972-08-10', 'Freq 9/yr, 2 years passed (leap year)' ); > is( $dates[27], '1973-08-10', 'Freq 9/yr, 3 years passed' ); > # Keep (first) position in cycle, but shift back 9 days >-is( GetNextDate( $subscription, '1973-08-01' ), '1973-09-10', 'Back 9 days, without annual correction' ); >+is( GetNextDate( $subscription, '1973-08-01', $frequency ), '1973-09-10', 'Back 9 days, without annual correction' ); > # Set position to last in cycle, and shift back 9 days; annual correction > $subscription->{countissuesperunit} = 9; >-is( GetNextDate( $subscription, '1973-08-01' ), '1973-09-15', 'Last in cycle, back 9 days, expect annual correction' ); >+is( GetNextDate( $subscription, '1973-08-01', $frequency ), '1973-09-15', 'Last in cycle, back 9 days, expect annual correction' ); > > # TEST CASE - Irregular >-$id = AddSubscriptionFrequency({ >+$frequency = { > description => "Irregular", > unit => undef, > issuesperunit => 1, > unitsperissue => 1, >-}); >+}; > $subscription = { >- periodicity => $id, > firstacquidate => '1970-01-01', > irregularity => '', > countissuesperunit => 1, > }; > $publisheddate = $subscription->{firstacquidate}; > # GetNextDate always return undef if subscription is irregular >-$publisheddate = GetNextDate($subscription, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); > is($publisheddate, undef); > > # GetNextDate returns undef if one of two first parameters is undef >-$publisheddate = GetNextDate($subscription, undef); >+$publisheddate = GetNextDate($subscription, undef, $frequency); > is($publisheddate, undef); >-$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}); >+$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}, $frequency); > is($publisheddate, undef); >-$publisheddate = GetNextDate(undef, undef); >+$publisheddate = GetNextDate(undef, undef, $frequency); > is($publisheddate, undef); > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Serials/GetNextSeq.t b/t/db_dependent/Serials/GetNextSeq.t >index 4b277d00ed..53fbbe1a88 100644 >--- a/t/db_dependent/Serials/GetNextSeq.t >+++ b/t/db_dependent/Serials/GetNextSeq.t >@@ -44,16 +44,16 @@ my $subscription = { > }; > my $publisheddate = $subscription->{firstacquidate}; > >-my $seq = _next_seq($subscription, $pattern, $publisheddate); >+my $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: 3'); > > # TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7 >@@ -80,19 +80,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Tuesday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Friday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Sunday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Monday'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Tuesday'); > > # TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2 >@@ -119,19 +119,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: March'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: September'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: January'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: March'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: May'); > > # TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3 >@@ -158,19 +158,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Summer'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Spring'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Fall'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Winter'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'X: Spring'); > > # TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4 >@@ -197,19 +197,19 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 1, X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 1'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 2, X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Y: 3, X: 1'); > > # TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4 >@@ -236,41 +236,41 @@ $pattern = { > > $publisheddate = $subscription->{firstacquidate}; > >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 1, X: 2'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 1'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 1, Y: 2, X: 4'); > for (1..100) { >- $publisheddate = GetNextDate($subscription, $publisheddate); >- $seq = _next_seq($subscription, $pattern, $publisheddate); >+ $publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+ $seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > } >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 1'); > # 110th is here >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 3'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 4, X: 4'); >-$publisheddate = GetNextDate($subscription, $publisheddate); >-$seq = _next_seq($subscription, $pattern, $publisheddate); >+$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); >+$seq = _next_seq($subscription, $pattern, $frequency, $publisheddate); > is($seq, 'Z: 4, Y: 5, X: 1'); > > sub _next_seq { >- my ($subscription, $pattern, $publisheddate) = @_; >+ my ($subscription, $pattern, $frequency, $publisheddate) = @_; > my $seq; > ($seq, $subscription->{lastvalue1}, $subscription->{lastvalue2}, > $subscription->{lastvalue3}, $subscription->{innerloop1}, > $subscription->{innerloop2}, $subscription->{innerloop3}) = >- GetNextSeq($subscription, $pattern, $publisheddate); >+ GetNextSeq($subscription, $pattern, $frequency, $publisheddate); > return $seq; > } >-- >2.17.2 (Apple Git-113)
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 17047
:
56175
|
56176
|
56177
|
56178
|
56179
|
56180
|
56181
|
59728
|
59729
|
59931
|
61905
|
62045
|
62046
|
62047
|
62048
|
62049
|
62050
|
62051
|
62052
|
62053
|
62054
|
62075
|
62465
|
62475
|
62485
|
62540
|
62542
|
62543
|
62544
|
62545
|
62546
|
62547
|
62548
|
62549
|
62550
|
62551
|
62552
|
62553
|
62589
|
62591
|
62592
|
62593
|
62594
|
62595
|
62596
|
62597
|
62598
|
62599
|
62603
|
62604
|
62605
|
62606
|
62607
|
62768
|
63476
|
63601
|
63618
|
63619
|
63620
|
63621
|
63622
|
63623
|
64484
|
64530
|
64618
|
64619
|
64620
|
64621
|
64622
|
64623
|
64624
|
64625
|
64626
|
64627
|
64628
|
64629
|
64630
|
64631
|
64632
|
64633
|
64634
|
64635
|
64636
|
64637
|
64638
|
64639
|
64640
|
64641
|
64642
|
64643
|
64648
|
64649
|
64650
|
64651
|
64652
|
64653
|
64654
|
64706
|
64962
|
65058
|
65059
|
65060
|
65061
|
65062
|
65063
|
65064
|
65065
|
65773
|
66667
|
66668
|
66987
|
67003
|
67004
|
67005
|
67006
|
67009
|
67010
|
67011
|
67012
|
67013
|
67014
|
67015
|
67016
|
67017
|
67018
|
67019
|
67020
|
67021
|
67022
|
67023
|
69034
|
69035
|
69036
|
69037
|
69038
|
69039
|
69040
|
69041
|
69091
|
70203
|
70204
|
70205
|
70206
|
70208
|
70209
|
70210
|
70211
|
70561
|
70874
|
72660
|
72661
|
72662
|
72663
|
72664
|
72665
|
72666
|
72667
|
72668
|
72669
|
72670
|
73699
|
73737
|
73738
|
73739
|
73740
|
73741
|
73742
|
73743
|
73744
|
73745
|
73746
|
73747
|
73748
|
73975
|
73976
|
73977
|
73978
|
73979
|
73980
|
73981
|
73982
|
73983
|
73984
|
73985
|
73986
|
76673
|
76674
|
76675
|
76676
|
76677
|
76678
|
76679
|
76680
|
76681
|
76682
|
76683
|
76684
|
78215
|
78216
|
78217
|
78218
|
78219
|
78220
|
78221
|
78222
|
78223
|
78224
|
78225
|
78226
|
78227
|
78228
|
78229
|
79868
|
79869
|
79870
|
79871
|
79872
|
79874
|
79877
|
79878
|
79879
|
79880
|
79881
|
79882
|
79883
|
79884
|
79885
|
79886
|
79887
|
79888
|
79922
|
79923
|
79924
|
79925
|
79926
|
79927
|
79928
|
79929
|
79930
|
79931
|
79932
|
79933
|
79934
|
79935
|
79936
|
79937
|
79938
|
79939
|
80183
|
80184
|
80185
|
80186
|
80187
|
80188
|
80189
|
80190
|
80191
|
80192
|
80193
|
80194
|
80195
|
80196
|
80197
|
80198
|
80199
|
80200
|
80471
|
80472
|
80473
|
80907
|
80908
|
80909
|
80910
|
80911
|
80912
|
80913
|
80914
|
80915
|
80916
|
80917
|
80918
|
80919
|
80920
|
80921
|
80922
|
80923
|
80924
|
81935
|
81936
|
81937
|
81938
|
81939
|
81940
|
81941
|
81942
|
81943
|
81944
|
81945
|
81946
|
81947
|
81948
|
81949
|
81950
|
81951
|
81952
|
81968
|
83863
|
83864
|
83865
|
83866
|
83867
|
83868
|
83869
|
83870
|
83871
|
83872
|
83873
|
83874
|
83875
|
83876
|
83877
|
83878
|
83879
|
83880
|
83881
|
83892
|
83893
|
83894
|
83895
|
83896
|
83897
|
83898
|
83899
|
83900
|
83901
|
83902
|
83903
|
83904
|
83905
|
83906
|
83907
|
83908
|
83909
|
83910
|
83911
|
83912
|
84142
|
84145
|
84210
|
84260
|
84261
|
84262
|
84263
|
84264
|
84265
|
84323
|
84324
|
84325
|
84326
|
84327
|
84328
|
84329
|
84332