Bug 7688: Change subscription numbering pattern and frequencies
Serials numbering pattern and frequencies are no longer hard-coded. Now it's possible to create, edit and delete numbering patterns (and frequencies). This patch adds two new sql tables (subscription_numberpatterns and subscription_frequencies) Numbering patterns behave almost as before, there are still the same values to configure (addX, everyX, settoX, whenmorethanX). lastvalueX and innerloopX remain in subscription tables. There is a new value in numbering patterns: numberingX. For each "column" (X, Y or Z) you can tell how to format the number. Actually numberingX can be set to: - 'dayname' (name of the day) (0-6 or 1-7 depending on which day is the first of the week) - 'monthname' (name of the month) (0-11) - 'season' (name of the season) (0-3) (0 is Spring) These names are localized by using POSIX::setlocale and POSIX::strftime and setting a 'locale' value to the subscription. Locale have to be installed on the system. Note that season names are not localized using POSIX::strftime (it can't do this), so names are hardcoded into the code (available languages: en, fr). This could be fixed in the future by using a Perl localization framework. Frequencies can be configured using 3 parameters: - 'unit': one of 'day', 'week', 'month', 'year' - 'issuesperunit': integer >= 1, the number of received issues per 'unit' - 'unitsperissue': integer >= 1, the number of 'unit' between two issues One of 'issuesperunit' and 'unitsperissue' must be equal to 1. Examples: unit = 'day', issuesperunit=3, unitsperissue=1 => 3 issues per day unit = 'week', issuesperunit=1, unitsperissue=3 => 1 issue each 3 weeks Prediction pattern is now computed server-side and is more consistent with what Koha will do. The publication date is displayed alongside the serial number. Irregularities can now be checked one by one, in the prediction pattern table, or if frequency is 'day-based' (unit is 'day'), there is the possibility to check all issues for a week day at once. When an irregularity is found, there is the possibility to keep the serial number unchanged, or to skip it. It is configured at subscription creation or modification. For instance, with a daily subscription you can have: skip serial number | keep serial number ----------------------+---------------------- 2012-01-01 ¦ No 1 | 2012-01-01 ¦ No 1 2012-01-03 ¦ No 3 | 2012-01-03 ¦ No 2 To lighten the subscription modification page, manual history has been moved in its own page subscription-history.pl which is accessible on subscription-detail.pl, tab 'Planning'. Important note: updatedatabase.pl script takes into account existing subscriptions and create appropriate numbering patterns for them (it tries to create as few patterns as possible). Frequency is mapped to the correct entry in subscription_frequencies table. This patch includes kohastructure.sql and updatedatabase.pl changes + sample frequencies data and sample numberpatterns data for fresh installs (sample data is included in updatedatabase.pl) === TEST PLAN: === Create a new subscription: - Go to Serials module and click "New subscription" button - On the first page, choose a biblio and click next to go to the second page - Pick a first issue publication date - Choose frequency '1/day' - Choose a subscription length of 15 issues - Choose a subscription start date - Choose numbering pattern 'Volume, Number' - A table appears, fill 'Begins with' cells with '1' - Click on 'Test prediction pattern' button The prediction pattern is displayed at the right of the page. You can see in it the serial number, the publication date and a checkbox to allow you to choose which serials will not be received (irregularities). You can see that serial number start from "Vol 1, No 1" continue to "Vol 1, No 12" and then restart with "Vol 2, No 1". Frequency is '1/day' so you can see that publication date is incremented by one day line after line. - Now you can play a little with frequencies and numbering patterns, change one of them (or both) and click again on 'Test prediction pattern' - For example, choose frequency '3/weeks' and click on 'Test prediction pattern' button'. There is a little behaviour change compared with current master. Publication date will not be guessed within the week. Koha can't know when you will receive issues. So the publication date stay the same (monday of each week) for 3 consecutive issues and then jump to the next week. - Now choose frequency '1/3 months' and numbering pattern 'Seasonal' - Fill 'Begins with' cells with '2012' for Year and '0' for Season - Click on 'Test prediction pattern' - You should have something like 'Spring 2012', 'Summer 2012', ..., 'Winter 2012', 'Spring 2013' - Note that you can have seasons for south hemisphere by entering '2' in 'Year/Inner counter' - 2nd note: if you have some locales installed on your system, you can type its name in the 'Locale' field (actually it does not work for seasons name, only for month names and day names) If you want to modify the numbering pattern you can still do it here: - Click on 'Show/Hide advanced pattern' link. The advanced pattern table is shown but all fields are readonly - Click on 'Modify pattern' button. All readonly fields are now editable. Note that 'Begins with' and 'Inner counter' line are repeated here and any modifications in the small table will be replicated in the big table, and vice versa. - Pattern name is emptied, if you type a new name, a new pattern will be created, and if you type the same name as an existing numbering pattern, this one will be modified (with a confirmation message) - There is two new lines in this table: - Label: it's what is displayed in the smaller table headers above - Numbering: used to format numbers in different ways. can be 'seasons', 'monthname' or 'dayname'. Month name and day name can be localized using the 'Locale' field. Seasons can't (values for English and french are hard-coded in Serials.pm) - You can modify what you want in the table and click on 'Test prediction pattern' button each time you want to see your modifications. (Note that checkboxes for irregularities aren't displayed in this mode, and you can't save the subscription until you have saved or cancelled your changes). - To cancel your modifications, just click on 'Cancel modifications' button. - To save them, click on 'Save as new pattern'. If the pattern name is already existing, a confirmation box will ask you if you want to modify the existing numbering pattern. Otherwise a new pattern will be created and automatically selected. Once you have finished modifying numbering pattern, you can click again on 'Test prediction pattern' to define irregularities, and then click on 'Save subscription'. Now you can check the serials module still works correctly: - Check the subscription detail page to confirm that nothing is missing. Especially the 'Frequency' and 'Number pattern' information. - Try to receive some issues. Check that the serial number is correctly generated and if irregularities you have defined are taken into account (if you have defined some). - Check that receiving is blocked once you have reached the number of issues you have defined in subscription length (or once you have reached the subscription end date) In serials menu (to the left of almost each page of serials menu) you have two new links: 'Manage frequencies' and 'Manage numbering patterns'. 'Manage numbering patterns' lead to a page which list all numbering patterns and allow you to create, edit or delete them. The interface is almost the same as numbering pattern modification in subscription-add.pl 'Manage frequencies' lead to a page which list all frequencies and allow you to create, edit or delete them. Try to create a new frequency: - Click on 'Manage frequencies' link in the serials menu and then click on 'New frequency': - Fill in the description (mandatory). - Unit is one of 'day', 'week', 'month', year' or 'None' ('None' is for an irregular subscription) - If unit is different from 'None' you have to fill the two following fields (Issues per unit, and Units per issue) - Note that at least one of those must be equal to 1 - Issues per unit is the number of received issues by 'unit' and Units per issue is the number of 'unit' between two issues - Display order is used to build the drop-down list. Leave empty and it will be set to 0 (top of the list) - Then click on 'Save' - Check that this new frequency appears in the frequencies table and in the drop-down list in subscription-add.pl Subscription history has been moved in its own page. To test if it still works, choose a subscription with manual history enabled (or modify an existing subscription to turn on manual history). - On the detail page, tab 'Planning', you should have a link 'Edit history'. - Click on it - Modify history and click on Save - In tab 'Summary' you should have the infos you just entered And finally, you can check that old subscriptions (by old I mean subscriptions that existed before the update) are correctly linked to an existing numbering pattern and an existing frequency. Numbering patterns should be named 'Backup pattern X' where X is a number. Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Comment: Great development! Work as described. No koha-qa errors (with all patches applied). Please QA this fast. Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> Squashed commits: ----------------- Bug 7688 follow-up: Small fixes for QA - # Subroutines::ProhibitExplicitReturnUndef: Got 1 violation(s) in C4::Serials::GetSubscriptionIrregularities - Bad template constructions fixed in serials/subscription-add.tt Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> ---- Bug 7688 follow-up: Small fixes for QA #2 - "return undef" -> "return" - ":utf8" -> ":encoding(UTF-8)" - TAB -> SPACES Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> ---- Bug 7688: Translate sample frequencies for french Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> ---- Bug 7688: Fix generating next serial when there is no 'Expected' issue It can happen when the Expected issue is claimed. In this case the status of the last serial is 'Claimed' This patch change the API of GetNextSeq and GetSeq Test plan: - Create a subscription which starts a long time ago so that serials automatically appear in late issues - Receive the first serial - Go to claims page and claim the 2nd serial. - Go back to the subscription page and click on 'Serial collection' - You should have 2 serials, one 'Arrived' and one 'Claimed'. - Click on Generate Next. This should fail with a software error message ("can't call method output ...") - Apply this patch and click again on Generate Next. A new issue must be created with status 'Expected'. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> ---- Bug 7688: Followup FIX perldoc Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
ffa2fbc93d
commit
48b0472a63
60 changed files with 4187 additions and 2062 deletions
1002
C4/Serials.pm
1002
C4/Serials.pm
File diff suppressed because it is too large
Load diff
292
C4/Serials/Frequency.pm
Normal file
292
C4/Serials/Frequency.pm
Normal file
|
@ -0,0 +1,292 @@
|
|||
package C4::Serials::Frequency;
|
||||
|
||||
# Copyright 2000-2002 Biblibre SARL
|
||||
#
|
||||
# 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 2 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 strict;
|
||||
use warnings;
|
||||
|
||||
use C4::Context;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT);
|
||||
|
||||
BEGIN {
|
||||
# set the version for version checking
|
||||
$VERSION = 3.01;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&GetSubscriptionFrequencies
|
||||
&GetSubscriptionFrequency
|
||||
&AddSubscriptionFrequency
|
||||
&ModSubscriptionFrequency
|
||||
&DelSubscriptionFrequency
|
||||
|
||||
&GetSubscriptionsWithFrequency
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
C4::Serials::Frequency - Serials Frequency module
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 GetSubscriptionFrequencies
|
||||
|
||||
=over 4
|
||||
|
||||
=item C<@frequencies> = &GetSubscriptionFrequencies();
|
||||
|
||||
gets frequencies restricted on filters
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionFrequencies {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT *
|
||||
FROM subscription_frequencies
|
||||
ORDER BY displayorder
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute();
|
||||
|
||||
my $results = $sth->fetchall_arrayref( {} );
|
||||
return @$results;
|
||||
}
|
||||
|
||||
=head2 GetSubscriptionFrequency
|
||||
|
||||
=over 4
|
||||
|
||||
=item $frequency = &GetSubscriptionFrequency($frequencyid);
|
||||
|
||||
gets frequency where $frequencyid is the identifier
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionFrequency {
|
||||
my ($frequencyid) = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT *
|
||||
FROM subscription_frequencies
|
||||
WHERE id = ?
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($frequencyid);
|
||||
|
||||
return $sth->fetchrow_hashref;
|
||||
}
|
||||
|
||||
=head2 AddSubscriptionFrequency
|
||||
|
||||
=over 4
|
||||
|
||||
=item C<$frequencyid> = &AddSubscriptionFrequency($frequency);
|
||||
|
||||
Add a new frequency
|
||||
|
||||
=item C<$frequency> is a hashref that can contains the following keys
|
||||
|
||||
=over 2
|
||||
|
||||
=item * description
|
||||
|
||||
=item * unit
|
||||
|
||||
=item * issuesperunit
|
||||
|
||||
=item * unitsperissue
|
||||
|
||||
=item * expectedissuesayear
|
||||
|
||||
=item * displayorder
|
||||
|
||||
=back
|
||||
|
||||
Only description is mandatory.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub AddSubscriptionFrequency {
|
||||
my $frequency = shift;
|
||||
|
||||
unless(ref($frequency) eq 'HASH' && defined $frequency->{'description'} && $frequency->{'description'} ne '') {
|
||||
return;
|
||||
}
|
||||
|
||||
my @keys;
|
||||
my @values;
|
||||
foreach (qw/ description unit issuesperunit unitsperissue expectedissuesayear displayorder /) {
|
||||
if(exists $frequency->{$_}) {
|
||||
push @keys, $_;
|
||||
push @values, $frequency->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "INSERT INTO subscription_frequencies";
|
||||
$query .= '(' . join(',', @keys) . ')';
|
||||
$query .= ' VALUES (' . ('?,' x (scalar(@keys)-1)) . '?)';
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $rv = $sth->execute(@values);
|
||||
|
||||
if(defined $rv) {
|
||||
return $dbh->last_insert_id(undef, undef, "subscription_frequencies", undef);
|
||||
}
|
||||
|
||||
return $rv;
|
||||
}
|
||||
|
||||
=head2 ModSubscriptionFrequency
|
||||
|
||||
=over 4
|
||||
|
||||
=item &ModSubscriptionFrequency($frequency);
|
||||
|
||||
Modifies a frequency
|
||||
|
||||
=item C<$frequency> is a hashref that can contains the following keys
|
||||
|
||||
=over 2
|
||||
|
||||
=item * id
|
||||
|
||||
=item * description
|
||||
|
||||
=item * unit
|
||||
|
||||
=item * issuesperunit
|
||||
|
||||
=item * unitsperissue
|
||||
|
||||
=item * expectedissuesayear
|
||||
|
||||
=item * displayorder
|
||||
|
||||
=back
|
||||
|
||||
Only id is mandatory.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub ModSubscriptionFrequency {
|
||||
my $frequency = shift;
|
||||
|
||||
unless(
|
||||
ref($frequency) eq 'HASH'
|
||||
&& defined $frequency->{'id'} && $frequency->{'id'} > 0
|
||||
&& (
|
||||
(defined $frequency->{'description'}
|
||||
&& $frequency->{'description'} ne '')
|
||||
|| !defined $frequency->{'description'}
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
my @keys;
|
||||
my @values;
|
||||
foreach (qw/ description unit issuesperunit unitsperissue expectedissuesayear displayorder /) {
|
||||
if(exists $frequency->{$_}) {
|
||||
push @keys, $_;
|
||||
push @values, $frequency->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "UPDATE subscription_frequencies";
|
||||
$query .= ' SET ' . join(' = ?,', @keys) . ' = ?';
|
||||
$query .= ' WHERE id = ?';
|
||||
my $sth = $dbh->prepare($query);
|
||||
|
||||
return $sth->execute(@values, $frequency->{'id'});
|
||||
}
|
||||
|
||||
=head2 DelSubscriptionFrequency
|
||||
|
||||
=over 4
|
||||
|
||||
=item &DelSubscriptionFrequency($frequencyid);
|
||||
|
||||
Delete a frequency
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub DelSubscriptionFrequency {
|
||||
my $frequencyid = shift;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
DELETE FROM subscription_frequencies
|
||||
WHERE id = ?
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($frequencyid);
|
||||
}
|
||||
|
||||
=head2 GetSubscriptionsWithFrequency
|
||||
|
||||
my @subs = GetSubscriptionsWithFrequency($frequencyid);
|
||||
|
||||
Returns all subscriptions that are using a particular frequency
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionsWithFrequency {
|
||||
my ($frequencyid) = @_;
|
||||
|
||||
return unless $frequencyid;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT *
|
||||
FROM subscription
|
||||
LEFT JOIN biblio ON subscription.biblionumber = biblio.biblionumber
|
||||
WHERE periodicity = ?
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
my @results;
|
||||
if ($sth->execute($frequencyid)) {
|
||||
@results = @{ $sth->fetchall_arrayref({}) };
|
||||
}
|
||||
return @results;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Koha Developement team <info@koha.org>
|
||||
|
||||
=cut
|
289
C4/Serials/Numberpattern.pm
Normal file
289
C4/Serials/Numberpattern.pm
Normal file
|
@ -0,0 +1,289 @@
|
|||
package C4::Serials::Numberpattern;
|
||||
|
||||
# Copyright 2000-2002 Biblibre SARL
|
||||
#
|
||||
# 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 2 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 strict;
|
||||
use warnings;
|
||||
|
||||
use C4::Context;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT);
|
||||
|
||||
BEGIN {
|
||||
|
||||
# set the version for version checking
|
||||
$VERSION = 3.01;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&GetSubscriptionNumberpatterns
|
||||
&GetSubscriptionNumberpattern
|
||||
&GetSubscriptionNumberpatternByName
|
||||
&AddSubscriptionNumberpattern
|
||||
&ModSubscriptionNumberpattern
|
||||
&DelSubscriptionNumberpattern
|
||||
|
||||
&GetSubscriptionsWithNumberpattern
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
C4::Serials::Numberpattern - Serials numbering pattern module
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 GetSubscriptionNumberpatterns
|
||||
|
||||
@results = GetSubscriptionNumberpatterns;
|
||||
this function get all subscription number patterns entered in table
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionNumberpatterns {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT *
|
||||
FROM subscription_numberpatterns
|
||||
ORDER by displayorder
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute;
|
||||
my $results = $sth->fetchall_arrayref({});
|
||||
|
||||
return @$results;
|
||||
}
|
||||
|
||||
=head2 GetSubscriptionNumberpattern
|
||||
|
||||
$result = GetSubscriptionNumberpattern($numberpatternid);
|
||||
this function get the data of the subscription numberpatterns which id is $numberpatternid
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionNumberpattern {
|
||||
my $numberpatternid = shift;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq(
|
||||
SELECT *
|
||||
FROM subscription_numberpatterns
|
||||
WHERE id = ?
|
||||
);
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($numberpatternid);
|
||||
|
||||
return $sth->fetchrow_hashref;
|
||||
}
|
||||
|
||||
=head2 GetSubscriptionNumberpatternByName
|
||||
|
||||
$result = GetSubscriptionNumberpatternByName($name);
|
||||
this function get the data of the subscription numberpatterns which name is $name
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionNumberpatternByName {
|
||||
my $name = shift;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq(
|
||||
SELECT *
|
||||
FROM subscription_numberpatterns
|
||||
WHERE label = ?
|
||||
);
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $rv = $sth->execute($name);
|
||||
|
||||
return $sth->fetchrow_hashref;
|
||||
}
|
||||
|
||||
=head2 AddSubscriptionNumberpattern
|
||||
|
||||
=over 4
|
||||
|
||||
=item C<$numberpatternid> = &AddSubscriptionNumberpattern($numberpattern)
|
||||
|
||||
Add a new numberpattern
|
||||
|
||||
=item C<$frequency> is a hashref that contains values of the number pattern
|
||||
|
||||
=item Only label and numberingmethod are mandatory
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub AddSubscriptionNumberpattern {
|
||||
my $numberpattern = shift;
|
||||
|
||||
unless(
|
||||
ref($numberpattern) eq 'HASH'
|
||||
&& defined $numberpattern->{'label'}
|
||||
&& $numberpattern->{'label'} ne ''
|
||||
&& defined $numberpattern->{'numberingmethod'}
|
||||
&& $numberpattern->{'numberingmethod'} ne ''
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
my @keys;
|
||||
my @values;
|
||||
foreach (qw/ label description numberingmethod displayorder
|
||||
label1 label2 label3 add1 add2 add3 every1 every2 every3
|
||||
setto1 setto2 setto3 whenmorethan1 whenmorethan2 whenmorethan3
|
||||
numbering1 numbering2 numbering3 /) {
|
||||
if(exists $numberpattern->{$_}) {
|
||||
push @keys, $_;
|
||||
push @values, $numberpattern->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "INSERT INTO subscription_numberpatterns";
|
||||
$query .= '(' . join(',', @keys) . ')';
|
||||
$query .= ' VALUES (' . ('?,' x (scalar(@keys)-1)) . '?)';
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $rv = $sth->execute(@values);
|
||||
|
||||
if(defined $rv) {
|
||||
return $dbh->last_insert_id(undef, undef, "subscription_numberpatterns", undef);
|
||||
}
|
||||
|
||||
return $rv;
|
||||
}
|
||||
|
||||
=head2 ModSubscriptionNumberpattern
|
||||
|
||||
=over 4
|
||||
|
||||
=item &ModSubscriptionNumberpattern($numberpattern)
|
||||
|
||||
Modifies a numberpattern
|
||||
|
||||
=item C<$frequency> is a hashref that contains values of the number pattern
|
||||
|
||||
=item Only id is mandatory
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub ModSubscriptionNumberpattern {
|
||||
my $numberpattern = shift;
|
||||
|
||||
unless(
|
||||
ref($numberpattern) eq 'HASH'
|
||||
&& defined $numberpattern->{'id'}
|
||||
&& $numberpattern->{'id'} > 0
|
||||
&& (
|
||||
(defined $numberpattern->{'label'}
|
||||
&& $numberpattern->{'label'} ne '')
|
||||
|| !defined $numberpattern->{'label'}
|
||||
)
|
||||
&& (
|
||||
(defined $numberpattern->{'numberingmethod'}
|
||||
&& $numberpattern->{'numberingmethod'} ne '')
|
||||
|| !defined $numberpattern->{'numberingmethod'}
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
my @keys;
|
||||
my @values;
|
||||
foreach (qw/ label description numberingmethod displayorder
|
||||
label1 label2 label3 add1 add2 add3 every1 every2 every3
|
||||
setto1 setto2 setto3 whenmorethan1 whenmorethan2 whenmorethan3
|
||||
numbering1 numbering2 numbering3 /) {
|
||||
if(exists $numberpattern->{$_}) {
|
||||
push @keys, $_;
|
||||
push @values, $numberpattern->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "UPDATE subscription_numberpatterns";
|
||||
$query .= ' SET ' . join(' = ?,', @keys) . ' = ?';
|
||||
$query .= ' WHERE id = ?';
|
||||
my $sth = $dbh->prepare($query);
|
||||
|
||||
return $sth->execute(@values, $numberpattern->{'id'});
|
||||
}
|
||||
|
||||
=head2 DelSubscriptionNumberpattern
|
||||
|
||||
=over 4
|
||||
|
||||
=item &DelSubscriptionNumberpattern($numberpatternid)
|
||||
|
||||
Delete a number pattern
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub DelSubscriptionNumberpattern {
|
||||
my $numberpatternid = shift;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
DELETE FROM subscription_numberpatterns
|
||||
WHERE id = ?
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($numberpatternid);
|
||||
}
|
||||
|
||||
=head2 GetSubscriptionsWithNumberpattern
|
||||
|
||||
my @subs = GetSubscriptionsWithNumberpattern($numberpatternid);
|
||||
|
||||
Returns all subscriptions that are using a particular numbering pattern
|
||||
|
||||
=cut
|
||||
|
||||
sub GetSubscriptionsWithNumberpattern {
|
||||
my ($numberpatternid) = @_;
|
||||
|
||||
return unless $numberpatternid;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT *
|
||||
FROM subscription
|
||||
LEFT JOIN biblio ON subscription.biblionumber = biblio.biblionumber
|
||||
WHERE numberpattern = ?
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
my @results;
|
||||
if ($sth->execute($numberpatternid)) {
|
||||
@results = @{ $sth->fetchall_arrayref({}) };
|
||||
}
|
||||
return @results;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Koha Developement team <info@koha.org>
|
||||
|
||||
=cut
|
16
installer/data/mysql/de-DE/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/de-DE/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/en/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/en/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
1
installer/data/mysql/en/optional/sample_frequencies.txt
Normal file
1
installer/data/mysql/en/optional/sample_frequencies.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
25
installer/data/mysql/en/optional/sample_numberpatterns.sql
Normal file
25
installer/data/mysql/en/optional/sample_numberpatterns.sql
Normal file
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/es-ES/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/es-ES/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/fr-FR/2-Optionel/sample_frequencies.sql
Normal file
16
installer/data/mysql/fr-FR/2-Optionel/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/jour', 'day', 1, 2, 1),
|
||||
('1/jour', 'day', 1, 1, 2),
|
||||
('3/semaine', 'week', 1, 3, 3),
|
||||
('1/semaine', 'week', 1, 1, 4),
|
||||
('1/2 semaines', 'week', 2, 1, 5),
|
||||
('1/3 semaines', 'week', 3, 1, 6),
|
||||
('1/mois', 'month', 1, 1, 7),
|
||||
('1/2 mois', 'month', 2, 1, 8),
|
||||
('1/3 mois', 'month', 3, 1, 9),
|
||||
('2/an', 'month', 6, 1, 10),
|
||||
('1/an', 'year', 1, 1, 11),
|
||||
('1/2 ans', 'year', 2, 1, 12),
|
||||
('Irrégulier', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/it-IT/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/it-IT/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
|
@ -1977,6 +1977,53 @@ DROP TABLE IF EXISTS `stopwords`;
|
|||
`word` varchar(255) default NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table subscription_frequencies
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS subscription_frequencies;
|
||||
CREATE TABLE subscription_frequencies (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
description TEXT NOT NULL,
|
||||
displayorder INT DEFAULT NULL,
|
||||
unit ENUM('day','week','month','year') DEFAULT NULL,
|
||||
unitsperissue INTEGER NOT NULL DEFAULT '1',
|
||||
issuesperunit INTEGER NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table subscription_numberpatterns
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS subscription_numberpatterns;
|
||||
CREATE TABLE subscription_numberpatterns (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
label VARCHAR(255) NOT NULL,
|
||||
displayorder INTEGER DEFAULT NULL,
|
||||
description TEXT NOT NULL,
|
||||
numberingmethod VARCHAR(255) NOT NULL,
|
||||
label1 VARCHAR(255) DEFAULT NULL,
|
||||
add1 INTEGER DEFAULT NULL,
|
||||
every1 INTEGER DEFAULT NULL,
|
||||
whenmorethan1 INTEGER DEFAULT NULL,
|
||||
setto1 INTEGER DEFAULT NULL,
|
||||
numbering1 VARCHAR(255) DEFAULT NULL,
|
||||
label2 VARCHAR(255) DEFAULT NULL,
|
||||
add2 INTEGER DEFAULT NULL,
|
||||
every2 INTEGER DEFAULT NULL,
|
||||
whenmorethan2 INTEGER DEFAULT NULL,
|
||||
setto2 INTEGER DEFAULT NULL,
|
||||
numbering2 VARCHAR(255) DEFAULT NULL,
|
||||
label3 VARCHAR(255) DEFAULT NULL,
|
||||
add3 INTEGER DEFAULT NULL,
|
||||
every3 INTEGER DEFAULT NULL,
|
||||
whenmorethan3 INTEGER DEFAULT NULL,
|
||||
setto3 INTEGER DEFAULT NULL,
|
||||
numbering3 VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `subscription`
|
||||
--
|
||||
|
@ -1994,40 +2041,27 @@ CREATE TABLE `subscription` (
|
|||
`monthlength` int(11) default 0,
|
||||
`numberlength` int(11) default 0,
|
||||
`periodicity` tinyint(4) default 0,
|
||||
`dow` varchar(100) default '',
|
||||
`numberingmethod` varchar(100) default '',
|
||||
countissuesperunit INTEGER NOT NULL DEFAULT 1,
|
||||
`notes` mediumtext,
|
||||
`status` varchar(100) NOT NULL default '',
|
||||
`add1` int(11) default 0,
|
||||
`every1` int(11) default 0,
|
||||
`whenmorethan1` int(11) default 0,
|
||||
`setto1` int(11) default NULL,
|
||||
`lastvalue1` int(11) default NULL,
|
||||
`add2` int(11) default 0,
|
||||
`every2` int(11) default 0,
|
||||
`whenmorethan2` int(11) default 0,
|
||||
`setto2` int(11) default NULL,
|
||||
`lastvalue2` int(11) default NULL,
|
||||
`add3` int(11) default 0,
|
||||
`every3` int(11) default 0,
|
||||
`innerloop1` int(11) default 0,
|
||||
`lastvalue2` int(11) default NULL,
|
||||
`innerloop2` int(11) default 0,
|
||||
`innerloop3` int(11) default 0,
|
||||
`whenmorethan3` int(11) default 0,
|
||||
`setto3` int(11) default NULL,
|
||||
`lastvalue3` int(11) default NULL,
|
||||
`issuesatonce` tinyint(3) NOT NULL default 1,
|
||||
`innerloop3` int(11) default 0,
|
||||
`firstacquidate` date default NULL,
|
||||
`manualhistory` tinyint(1) NOT NULL default 0,
|
||||
`irregularity` text,
|
||||
skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
|
||||
`letter` varchar(20) default NULL,
|
||||
`numberpattern` tinyint(3) default 0,
|
||||
locale VARCHAR(80) DEFAULT NULL,
|
||||
`distributedto` text,
|
||||
`internalnotes` longtext,
|
||||
`callnumber` text,
|
||||
`location` varchar(80) NULL default '',
|
||||
`branchcode` varchar(10) NOT NULL default '',
|
||||
`hemisphere` tinyint(3) default 0,
|
||||
`lastbranch` varchar(10),
|
||||
`serialsadditems` tinyint(1) NOT NULL default '0',
|
||||
`staffdisplaycount` VARCHAR(10) NULL,
|
||||
|
@ -2036,7 +2070,9 @@ CREATE TABLE `subscription` (
|
|||
`enddate` date default NULL,
|
||||
`closed` INT(1) NOT NULL DEFAULT 0,
|
||||
`reneweddate` date default NULL,
|
||||
PRIMARY KEY (`subscriptionid`)
|
||||
PRIMARY KEY (`subscriptionid`),
|
||||
CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/pl-PL/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/pl-PL/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/ru-RU/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/ru-RU/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
16
installer/data/mysql/uk-UA/optional/sample_frequencies.sql
Normal file
16
installer/data/mysql/uk-UA/optional/sample_frequencies.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
INSERT INTO subscription_frequencies
|
||||
(description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13);
|
|
@ -0,0 +1 @@
|
|||
Sample frequencies for subscriptions
|
|
@ -0,0 +1,25 @@
|
|||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1 @@
|
|||
Sample numbering patterns for subscriptions
|
|
@ -7330,6 +7330,227 @@ if ( CheckVersion($DBversion) ) {
|
|||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "XXX";
|
||||
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
||||
$dbh->do(qq|
|
||||
DROP TABLE IF EXISTS subscription_frequencies
|
||||
|);
|
||||
$dbh->do(qq|
|
||||
CREATE TABLE subscription_frequencies (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
description TEXT NOT NULL,
|
||||
displayorder INT DEFAULT NULL,
|
||||
unit ENUM('day','week','month','year') DEFAULT NULL,
|
||||
unitsperissue INTEGER NOT NULL DEFAULT '1',
|
||||
issuesperunit INTEGER NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
||||
|);
|
||||
|
||||
$dbh->do(qq|
|
||||
DROP TABLE IF EXISTS subscription_numberpatterns
|
||||
|);
|
||||
$dbh->do(qq|
|
||||
CREATE TABLE subscription_numberpatterns (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
label VARCHAR(255) NOT NULL,
|
||||
displayorder INTEGER DEFAULT NULL,
|
||||
description TEXT NOT NULL,
|
||||
numberingmethod VARCHAR(255) NOT NULL,
|
||||
label1 VARCHAR(255) DEFAULT NULL,
|
||||
add1 INTEGER DEFAULT NULL,
|
||||
every1 INTEGER DEFAULT NULL,
|
||||
whenmorethan1 INTEGER DEFAULT NULL,
|
||||
setto1 INTEGER DEFAULT NULL,
|
||||
numbering1 VARCHAR(255) DEFAULT NULL,
|
||||
label2 VARCHAR(255) DEFAULT NULL,
|
||||
add2 INTEGER DEFAULT NULL,
|
||||
every2 INTEGER DEFAULT NULL,
|
||||
whenmorethan2 INTEGER DEFAULT NULL,
|
||||
setto2 INTEGER DEFAULT NULL,
|
||||
numbering2 VARCHAR(255) DEFAULT NULL,
|
||||
label3 VARCHAR(255) DEFAULT NULL,
|
||||
add3 INTEGER DEFAULT NULL,
|
||||
every3 INTEGER DEFAULT NULL,
|
||||
whenmorethan3 INTEGER DEFAULT NULL,
|
||||
setto3 INTEGER DEFAULT NULL,
|
||||
numbering3 VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
||||
|);
|
||||
|
||||
$dbh->do(qq|
|
||||
INSERT INTO subscription_frequencies (description, unit, unitsperissue, issuesperunit, displayorder)
|
||||
VALUES
|
||||
('2/day', 'day', 1, 2, 1),
|
||||
('1/day', 'day', 1, 1, 2),
|
||||
('3/week', 'week', 1, 3, 3),
|
||||
('1/week', 'week', 1, 1, 4),
|
||||
('1/2 weeks', 'week', 2, 1, 5),
|
||||
('1/3 weeks', 'week', 3, 1, 6),
|
||||
('1/month', 'month', 1, 1, 7),
|
||||
('1/2 months', 'month', 2, 1, 8),
|
||||
('1/3 months', 'month', 3, 1, 9),
|
||||
('2/year', 'month', 6, 1, 10),
|
||||
('1/year', 'year', 1, 1, 11),
|
||||
('1/2 year', 'year', 2, 1, 12),
|
||||
('Irregular', NULL, 1, 1, 13)
|
||||
|);
|
||||
|
||||
# Used to link existing subscription to newly created frequencies
|
||||
my $frequencies_mapping = { # keys are old frequency numbers, values are the new ones
|
||||
1 => 2, # daily (n/week)
|
||||
2 => 4, # 1/week
|
||||
3 => 5, # 1/2 weeks
|
||||
4 => 6, # 1/3 weeks
|
||||
5 => 7, # 1/month
|
||||
6 => 8, # 1/2 months (6/year)
|
||||
7 => 9, # 1/3 months (1/quarter)
|
||||
8 => 9, # 1/quarter (seasonal)
|
||||
9 => 10, # 2/year
|
||||
10 => 11, # 1/year
|
||||
11 => 12, # 1/2 years
|
||||
12 => 1, # 2/day
|
||||
16 => 13, # Without periodicity
|
||||
32 => 13, # Irregular
|
||||
48 => 13 # Unknown
|
||||
};
|
||||
|
||||
$dbh->do(qq|
|
||||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
('Number', 1, 'Simple Numbering method', 'No.{X}',
|
||||
'Number', 1, 1, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
|
||||
'Volume', 1, 48, 99999, 1, NULL,
|
||||
'Number', 1, 4, 12, 1, NULL,
|
||||
'Issue', 1, 1, 4, 1, NULL),
|
||||
|
||||
('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
|
||||
'Volume', 1, 12, 99999, 1, NULL,
|
||||
'Number', 1, 1, 12, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL),
|
||||
|
||||
('Seasonal', 4, 'Season Year', '{X} {Y}',
|
||||
'Season', 1, 1, 3, 0, 'season',
|
||||
'Year', 1, 4, 99999, 1, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL)
|
||||
|);
|
||||
|
||||
$dbh->do(qq|
|
||||
ALTER TABLE subscription
|
||||
MODIFY COLUMN numberpattern INTEGER DEFAULT NULL,
|
||||
MODIFY COLUMN periodicity INTEGER DEFAULT NULL
|
||||
|);
|
||||
|
||||
# Update existing subscriptions
|
||||
|
||||
my $query = qq|
|
||||
SELECT subscriptionid, periodicity, numberingmethod,
|
||||
add1, every1, whenmorethan1, setto1,
|
||||
add2, every2, whenmorethan2, setto2,
|
||||
add3, every3, whenmorethan3, setto3
|
||||
FROM subscription
|
||||
ORDER BY subscriptionid
|
||||
|;
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute;
|
||||
my $insert_numberpatterns_sth = $dbh->prepare(qq|
|
||||
INSERT INTO subscription_numberpatterns
|
||||
(label, displayorder, description, numberingmethod,
|
||||
label1, add1, every1, whenmorethan1, setto1, numbering1,
|
||||
label2, add2, every2, whenmorethan2, setto2, numbering2,
|
||||
label3, add3, every3, whenmorethan3, setto3, numbering3)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
|);
|
||||
my $check_numberpatterns_sth = $dbh->prepare(qq|
|
||||
SELECT * FROM subscription_numberpatterns
|
||||
WHERE add1 = ? AND add2 = ? AND add3 = ?
|
||||
AND every1 = ? AND every2 = ? AND every3 = ?
|
||||
AND whenmorethan1 = ? AND whenmorethan2 = ? AND whenmorethan3 = ?
|
||||
AND setto1 = ? AND setto2 = ? AND setto3 = ?
|
||||
AND numberingmethod = ?
|
||||
LIMIT 1
|
||||
|);
|
||||
my $update_subscription_sth = $dbh->prepare(qq|
|
||||
UPDATE subscription
|
||||
SET numberpattern = ?,
|
||||
periodicity = ?
|
||||
WHERE subscriptionid = ?
|
||||
|);
|
||||
|
||||
my $i = 1;
|
||||
while(my $sub = $sth->fetchrow_hashref) {
|
||||
$check_numberpatterns_sth->execute(
|
||||
$sub->{add1}, $sub->{add2}, $sub->{add3},
|
||||
$sub->{every1}, $sub->{every2}, $sub->{every3},
|
||||
$sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan3},
|
||||
$sub->{setto1}, $sub->{setto2}, $sub->{setto3},
|
||||
$sub->{numberingmethod}
|
||||
);
|
||||
my $p = $check_numberpatterns_sth->fetchrow_hashref;
|
||||
if (defined $p) {
|
||||
# Pattern already exists, link to it
|
||||
$update_subscription_sth->execute($p->{id},
|
||||
$frequencies_mapping->{$sub->{periodicity}},
|
||||
$sub->{subscriptionid});
|
||||
} else {
|
||||
# Create a new numbering pattern for this subscription
|
||||
my $ok = $insert_numberpatterns_sth->execute(
|
||||
"Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
|
||||
"X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
|
||||
"Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
|
||||
"Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
|
||||
);
|
||||
if($ok) {
|
||||
my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
|
||||
# Link to subscription_numberpatterns and subscription_frequencies
|
||||
$update_subscription_sth->execute($id,
|
||||
$frequencies_mapping->{$sub->{periodicity}},
|
||||
$sub->{subscriptionid});
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
# Remove now useless columns
|
||||
$dbh->do(qq|
|
||||
ALTER TABLE subscription
|
||||
DROP COLUMN numberingmethod,
|
||||
DROP COLUMN add1,
|
||||
DROP COLUMN every1,
|
||||
DROP COLUMN whenmorethan1,
|
||||
DROP COLUMN setto1,
|
||||
DROP COLUMN add2,
|
||||
DROP COLUMN every2,
|
||||
DROP COLUMN whenmorethan2,
|
||||
DROP COLUMN setto2,
|
||||
DROP COLUMN add3,
|
||||
DROP COLUMN every3,
|
||||
DROP COLUMN whenmorethan3,
|
||||
DROP COLUMN setto3,
|
||||
DROP COLUMN dow,
|
||||
DROP COLUMN issuesatonce,
|
||||
DROP COLUMN hemisphere,
|
||||
ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
|
||||
ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
|
||||
ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
|
||||
ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
|);
|
||||
|
||||
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 TableExists($table)
|
||||
|
|
|
@ -20,4 +20,14 @@
|
|||
[% IF ( CAN_user_serials_check_expiration ) %]
|
||||
<li><a href="/cgi-bin/koha/serials/checkexpiration.pl">Check expiration</a></li>
|
||||
[% END %]
|
||||
<li>
|
||||
<a href="/cgi-bin/koha/serials/subscription-frequencies.pl">
|
||||
Manage frequencies
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">
|
||||
Manage numbering patterns
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -123,64 +123,11 @@ $(document).ready(function() {
|
|||
</tr>
|
||||
[% FOREACH subscription IN subscriptions %]
|
||||
[% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
|
||||
<td><a href="subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]"># [% subscription.subscriptionid %]</a> </td>
|
||||
<td> [% IF ( subscription.periodicity1 ) %]
|
||||
1/day
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity2 ) %]
|
||||
1/week
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity3 ) %]
|
||||
1/2 weeks
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity4 ) %]
|
||||
1/3 weeks
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity5 ) %]
|
||||
1/Month
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity6 ) %]
|
||||
1/2 Months (6/year)
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity7 ) %]
|
||||
1/quarter
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity8 ) %]
|
||||
1/quarter
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity9 ) %]
|
||||
2/year
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity10 ) %]
|
||||
1/year
|
||||
[% END %]
|
||||
[% IF ( subscription.periodicity11 ) %]
|
||||
1/2 years
|
||||
[% END %]</td>
|
||||
<td>
|
||||
[% IF ( subscription.numberpattern1 ) %]
|
||||
Number
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern2 ) %]
|
||||
Volume, number, issue
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern3 ) %]
|
||||
Volume, number
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern4 ) %]
|
||||
Volume, issue
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern5 ) %]
|
||||
Number, issue
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern6 ) %]
|
||||
Seasonal only
|
||||
[% END %]
|
||||
[% IF ( subscription.numberpattern7 ) %]
|
||||
None of the above
|
||||
[% END %]</td>
|
||||
<td>[% Branches.GetName( subscription.branchcode ) %]</td>
|
||||
<td> [% subscription.callnumber %]</td>
|
||||
<td><a href="subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]"># [% subscription.subscriptionid %]</a> </td>
|
||||
<td>[% subscription.frequency.description %]</td>
|
||||
<td>[% subscription.numberpattern.label %]</td>
|
||||
<td> [% subscription.branchcode %]</td>
|
||||
<td> [% subscription.callnumber %]</td>
|
||||
<td> [% subscription.notes %]
|
||||
[% UNLESS subscription.closed %]
|
||||
[% IF ( subscription.subscriptionexpired ) %]
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
[% USE KohaDates %]
|
||||
|
||||
<h2>Prediction pattern</h1>
|
||||
[% IF (not_consistent_end_date) %]
|
||||
<p><em>End date is not consistent with subscription length.</em></p>
|
||||
[% END %]
|
||||
[% IF (ask_for_irregularities) %]
|
||||
<p><em>Please check issues that are NOT published (irregularities)</em></p>
|
||||
[% IF (daily_options) %]
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function Check_boxes(dow) {
|
||||
if($(":checkbox[data-dow='"+dow+"']:first").attr("checked") == 'checked') {
|
||||
$("#predictionst :checkbox[data-dow='"+dow+"']").each(function(){
|
||||
$(this).attr('checked', true);
|
||||
});
|
||||
} else {
|
||||
$("#predictionst :checkbox[data-dow='"+dow+"']").each(function(){
|
||||
$(this).attr('checked', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<p><em>
|
||||
If there is a day (or more) in the week where issues are never
|
||||
published, you can check corresponding boxes below.
|
||||
</em></p>
|
||||
<input type="checkbox" id="monday" data-dow="1" onchange="Check_boxes(1);" />
|
||||
<label for="monday">Monday</label>
|
||||
<input type="checkbox" id="tuesday" data-dow="2" onchange="Check_boxes(2);" />
|
||||
<label for="tuesday">Tuesday</label>
|
||||
<input type="checkbox" id="wednesday" data-dow="3" onchange="Check_boxes(3);" />
|
||||
<label for="wednesday">Wednesday</label>
|
||||
<input type="checkbox" id="thursday" data-dow="4" onchange="Check_boxes(4);" />
|
||||
<label for="thursday">Thursday</label>
|
||||
<input type="checkbox" id="friday" data-dow="5" onchange="Check_boxes(5);" />
|
||||
<label for="friday">Friday</label>
|
||||
<input type="checkbox" id="saturday" data-dow="6" onchange="Check_boxes(6);" />
|
||||
<label for="saturday">Saturday</label>
|
||||
<input type="checkbox" id="sunday" data-dow="7" onchange="Check_boxes(7);" />
|
||||
<label for="sunday">Sunday</label>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF (predictions_loop) %]
|
||||
<table id="predictionst">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Number</th>
|
||||
<th>Publication Date</th>
|
||||
[% IF (ask_for_irregularities) %]
|
||||
<th>Not published</th>
|
||||
[% END %]
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH prediction IN predictions_loop %]
|
||||
<tr>
|
||||
<td>[% prediction.number %]</td>
|
||||
<td>
|
||||
[% IF (prediction.publicationdate) %]
|
||||
[% prediction.publicationdate | $KohaDates %]
|
||||
[% ELSE %]
|
||||
unknown
|
||||
[% END %]
|
||||
</td>
|
||||
[% IF (ask_for_irregularities) %]
|
||||
<td style="text-align:center">
|
||||
[% UNLESS (loop.first) %]
|
||||
[% IF (prediction.not_published) %]
|
||||
<input type="checkbox" name="irregularity" value="[% prediction.issuenumber %]" data-dow="[% prediction.dow %]" checked="checked" />
|
||||
[% ELSE %]
|
||||
<input type="checkbox" name="irregularity" value="[% prediction.issuenumber %]" data-dow="[% prediction.dow %]" />
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
File diff suppressed because it is too large
Load diff
|
@ -9,21 +9,6 @@ var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("
|
|||
"Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
|
||||
|
||||
|
||||
// to display the options section
|
||||
function options(x,y,z){
|
||||
var textbox = '';
|
||||
// alert("X: "+x+"Y: "+y+"Z: "+z);
|
||||
if(x){
|
||||
document.f.xfield.value = x;
|
||||
if(y){
|
||||
document.f.yfield.value = y;
|
||||
if(z){
|
||||
document.f.zfield.value = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function confirm_deletion() {
|
||||
var is_confirmed = confirm(_("Are you sure you want to delete this subscription?"));
|
||||
if (is_confirmed) {
|
||||
|
@ -108,6 +93,14 @@ $(document).ready(function() {
|
|||
[% ELSE %]
|
||||
<li><span class="label">Items:</span> Serial receipt does not create an item record.</li>
|
||||
[% END %]
|
||||
<li>
|
||||
<span class="label">Serial number:</span>
|
||||
[% IF skip_serialseq %]
|
||||
Serial number is skipped when an irregularity is found.
|
||||
[% ELSE %]
|
||||
Serial number is kept when an irregularity is found.
|
||||
[% END %]
|
||||
</li>
|
||||
<li><span class="label">Grace period:</span> [% graceperiod %]</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -138,118 +131,44 @@ $(document).ready(function() {
|
|||
<ol>
|
||||
<li><span class="label">Beginning date:</span> [% startdate %]
|
||||
</li>
|
||||
<li><span class="label">Frequency (*):</span>
|
||||
[% IF ( periodicity16 ) %]
|
||||
Without regularity
|
||||
[% END %]
|
||||
[% IF ( periodicity32 ) %]
|
||||
Irregular
|
||||
[% END %]
|
||||
[% IF ( periodicity0 ) %]
|
||||
Unknown
|
||||
[% END %]
|
||||
[% IF ( periodicity12 ) %]
|
||||
2/day
|
||||
[% END %]
|
||||
[% IF ( periodicity1 ) %]
|
||||
1/day
|
||||
[% END %]
|
||||
[% IF ( periodicity13 ) %]
|
||||
1/4 months (3/year)
|
||||
[% END %]
|
||||
[% IF ( periodicity2 ) %]
|
||||
1/week
|
||||
[% END %]
|
||||
[% IF ( periodicity3 ) %]
|
||||
1/2 weeks
|
||||
[% END %]
|
||||
[% IF ( periodicity4 ) %]
|
||||
1/3 weeks
|
||||
[% END %]
|
||||
[% IF ( periodicity5 ) %]
|
||||
1/month
|
||||
[% END %]
|
||||
[% IF ( periodicity6 ) %]
|
||||
1/2 months (6/year)
|
||||
[% END %]
|
||||
[% IF ( periodicity7 ) %]
|
||||
1/quarter
|
||||
[% END %]
|
||||
[% IF ( periodicity8 ) %]
|
||||
1/quarter
|
||||
[% END %]
|
||||
[% IF ( periodicity9 ) %]
|
||||
2/year
|
||||
[% END %]
|
||||
[% IF ( periodicity10 ) %]
|
||||
1/year
|
||||
[% END %]
|
||||
[% IF ( periodicity11 ) %]
|
||||
1/2 years
|
||||
[% END %]
|
||||
<li><span class="label">Frequency:</span>
|
||||
[% frequency.description %]
|
||||
</li>
|
||||
<li>
|
||||
<span class="label">Manual history: </span>
|
||||
[% IF ( manualhistory ) %]
|
||||
Enabled
|
||||
Enabled <a href="/cgi-bin/koha/serials/subscription-history.pl?subscriptionid=[% subscriptionid %]">Edit history</a>
|
||||
[% ELSE %]
|
||||
Disabled
|
||||
[% END %]
|
||||
</li>
|
||||
<li><span class="label">Number pattern:</span>
|
||||
[% IF ( numberpattern1 ) %]
|
||||
Number only
|
||||
[% END %]
|
||||
[% IF ( numberpattern2 ) %]
|
||||
Volume, number, issue
|
||||
[% END %]
|
||||
[% IF ( numberpattern3 ) %]
|
||||
Volume, number
|
||||
[% END %]
|
||||
[% IF ( numberpattern4 ) %]
|
||||
Volume, issue
|
||||
[% END %]
|
||||
[% IF ( numberpattern5 ) %]
|
||||
Number, issue
|
||||
[% END %]
|
||||
[% IF ( numberpattern8 ) %]
|
||||
Year/Number
|
||||
[% END %]
|
||||
[% IF ( numberpattern6 ) %]
|
||||
Seasonal only
|
||||
[% END %]
|
||||
[% IF ( numberpattern7 ) %]
|
||||
None of the above
|
||||
[% END %]
|
||||
[% numberpattern.label %]
|
||||
</li>
|
||||
<li><table>
|
||||
<tr><td>Starting with:</td>
|
||||
<td align="center">[% lastvalue1 %]</td>
|
||||
[% IF ( lastvalue2 ) %]
|
||||
<td align="center">
|
||||
[% lastvalue2 %]
|
||||
</td>
|
||||
[% END %]
|
||||
[% IF ( lastvalue3 ) %]
|
||||
<td align="center">
|
||||
[% lastvalue3 %]
|
||||
</td>
|
||||
[% END %]
|
||||
<tr>
|
||||
<td>Starting with:</td>
|
||||
[% IF (has_X) %]
|
||||
<td align="center">[% lastvalue1 %]</td>
|
||||
[% END %]
|
||||
[% IF (has_Y) %]
|
||||
<td align="center">[% lastvalue2 %]</td>
|
||||
[% END %]
|
||||
[% IF (has_Z) %]
|
||||
<td align="center">[% lastvalue3 %]</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
<tr><td>Rollover:</td>
|
||||
<td align="center">
|
||||
[% IF ( whenmorethan1 < 9999999 ) %][% whenmorethan1 %][% ELSE %]Never[% END %]
|
||||
</td>
|
||||
[% IF ( whenmorethan2 ) %]
|
||||
<td align="center">
|
||||
[% IF ( whenmorethan2 < 9999999 ) %][% whenmorethan2 %][% ELSE %]Never[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
[% IF ( whenmorethan3 ) %]
|
||||
<td align="center">
|
||||
[% IF ( whenmorethan3 < 9999999 ) %][% whenmorethan3 %][% ELSE %]Never[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
<tr>
|
||||
<td>Rollover:</td>
|
||||
[% IF (has_X) %]
|
||||
<td align="center">[% numberpattern.whenmorethan1 %]</td>
|
||||
[% END %]
|
||||
[% IF (has_Y) %]
|
||||
<td align="center">[% numberpattern.whenmorethan2 %]</td>
|
||||
[% END %]
|
||||
[% IF (has_Z) %]
|
||||
<td align="center">[% numberpattern.whenmorethan3 %]</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
</table></li>
|
||||
[% IF ( irregular_issues ) %]
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Serials › Frequencies</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function confirmDelete() {
|
||||
return confirm(_("Are you sure you want to delete this subscription frequency?"));
|
||||
}
|
||||
|
||||
function check_form() {
|
||||
var description = $("#description").val();
|
||||
var unit = $("#unit").val();
|
||||
var issuesperunit = $("#issuesperunit").val();
|
||||
var unitsperissue = $("#unitsperissue").val();
|
||||
var alert_msg = _("Some fields are not valid:") + "\n";
|
||||
var errors = 0;
|
||||
|
||||
if(description.length == 0) {
|
||||
alert_msg += "\t - " + _("Description is required");
|
||||
errors ++;
|
||||
}
|
||||
if(unit.length > 0) {
|
||||
if(isNaN(issuesperunit) || issuesperunit == 0) {
|
||||
alert_msg += "\n\t - " + _("Issues per unit is required")
|
||||
+ " " + _("(must be a number greater than 0)");
|
||||
errors ++;
|
||||
}
|
||||
if(isNaN(unitsperissue) || unitsperissue == 0) {
|
||||
alert_msg += "\n\t - " + _("Units per issue is required")
|
||||
+ " " + _("(must be a number greater than 0)");
|
||||
errors ++;
|
||||
}
|
||||
if(issuesperunit > 1 && unitsperissue > 1) {
|
||||
alert_msg += "\n\t - " + _("One of 'issues per unit' and 'units per issue' must be equal to 1");
|
||||
errors ++;
|
||||
}
|
||||
}
|
||||
|
||||
if(errors == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
alert(alert_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
function show_blocking_subs() {
|
||||
$("#blocking_subs").show();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#issuesperunit").change(function() {
|
||||
var value = $(this).val();
|
||||
if(!isNaN(value) && value > 1) {
|
||||
$("#unitsperissue").val(1);
|
||||
}
|
||||
});
|
||||
$("#unitsperissue").change(function() {
|
||||
var value = $(this).val();
|
||||
if(!isNaN(value) && value > 1) {
|
||||
$("#issuesperunit").val(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'serials-search.inc' %]
|
||||
|
||||
<div id="breadcrumbs">
|
||||
<a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
|
||||
<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> ›
|
||||
<a href="/cgi-bin/koha/serials/subscription-frequencies.pl">Frequencies</a>
|
||||
</div>
|
||||
|
||||
<div id="doc3" class="yui-t2">
|
||||
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
[% IF (new or modify) %]
|
||||
[% IF (new) %]
|
||||
<h1>New frequency</h1>
|
||||
[% ELSE %]
|
||||
<h1>Modify frequency: [% description %]</h1>
|
||||
[% END %]
|
||||
<form action="/cgi-bin/koha/serials/subscription-frequencies.pl" method="post" onsubmit="return check_form();">
|
||||
[% IF (modify) %]
|
||||
<input type="hidden" name="id" value="[% id %]" />
|
||||
<input type="hidden" name="op" value="savemod" />
|
||||
[% ELSE %]
|
||||
<input type="hidden" name="op" value="savenew" />
|
||||
[% END %]
|
||||
<fieldset class="rows">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="description">Description:</label>
|
||||
<input type="text" id="description" name="description" value="[% description %]" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="unit">Unit</label>
|
||||
<select id="unit" name="unit">
|
||||
<option value="">None</option>
|
||||
[% FOREACH unit IN units_loop %]
|
||||
[% IF (unit.selected) %]
|
||||
<option selected="selected" value="[% unit.val %]">
|
||||
[% ELSE %]
|
||||
<option value="[% unit.val %]">
|
||||
[% END %]
|
||||
[% unit.val %]
|
||||
</option>
|
||||
[% END %]
|
||||
</select>
|
||||
</li>
|
||||
<li><span class="hint">Note: one of the two following fields must be equal to 1</span></li>
|
||||
<li>
|
||||
<label for="issuesperunit">Issues per unit</label>
|
||||
[% IF (new) %]
|
||||
<input type="text" id="issuesperunit" name="issuesperunit" value="1" size="3" />
|
||||
[% ELSE %]
|
||||
<input type="text" id="issuesperunit" name="issuesperunit" value="[% issuesperunit %]" size="3" />
|
||||
[% END %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="unitsperissue">Units per issue</label>
|
||||
[% IF (new) %]
|
||||
<input type="text" id="unitsperissue" name="unitsperissue" value="1" size="3" />
|
||||
[% ELSE %]
|
||||
<input type="text" id="unitsperissue" name="unitsperissue" value="[% unitsperissue %]" size="3" />
|
||||
[% END %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="displayorder">Display order</label>
|
||||
<input type="text" id="displayorder" name="displayorder" value="[% displayorder %]" size="3" />
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Save" />
|
||||
<input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/serials/subscription-frequencies.pl'" />
|
||||
</fieldset>
|
||||
</form>
|
||||
[% ELSE %]
|
||||
<h1>Frequencies</h1>
|
||||
[% IF still_used %]
|
||||
<div class="dialog">
|
||||
<p>
|
||||
This frequency is still used by [% subscriptions.size %]
|
||||
subscription(s). Do you still want to delete it?
|
||||
</p>
|
||||
<p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
|
||||
<ul id="blocking_subs" style="display:none">
|
||||
[% FOREACH sub IN subscriptions %]
|
||||
<li style="list-style-type:none">
|
||||
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
||||
<form action="" method="get">
|
||||
<input type="hidden" name="op" value="del" />
|
||||
<input type="hidden" name="confirm" value="1" />
|
||||
<input type="hidden" name="frequencyid" value="[% frequencyid %]" />
|
||||
<input type="submit" class="approve" value="Yes, delete" />
|
||||
</form>
|
||||
<form action="" method="get">
|
||||
<input type="submit" class="deny" value="No, don't delete" />
|
||||
</form>
|
||||
</div>
|
||||
[% END %]
|
||||
<a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=new">New frenquency</a>
|
||||
|
||||
[% IF (frequencies_loop.size) %]
|
||||
<table id="frequenciest">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<th>Unit</th>
|
||||
<th>Issues per unit</th>
|
||||
<th>Units per issue</th>
|
||||
<th>Display order</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH frequency IN frequencies_loop %]
|
||||
<tr>
|
||||
<td>[% frequency.description %]</td>
|
||||
<td>[% frequency.unit %]</td>
|
||||
<td>[% frequency.issuesperunit %]</td>
|
||||
<td>[% frequency.unitsperissue %]</td>
|
||||
<td>[% frequency.displayorder %]</td>
|
||||
<td>
|
||||
<a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=modify&frequencyid=[% frequency.id %]">Modify</a> |
|
||||
<a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=del&frequencyid=[% frequency.id %]">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% ELSE %]
|
||||
<p>There is no defined frequency.</p>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'serials-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
|
@ -0,0 +1,60 @@
|
|||
[% USE KohaDates %]
|
||||
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Serials › Subscription history</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
</head>
|
||||
|
||||
<body>
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'serials-search.inc' %]
|
||||
|
||||
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Subscription history</div>
|
||||
|
||||
<div id="doc3" class="yui-t2">
|
||||
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
<h1>Subscription history for [% title %]</h1>
|
||||
<div id="subscription_form_history">
|
||||
<form method="post" action="/cgi-bin/koha/serials/subscription-history.pl">
|
||||
<input type="hidden" name="op" value="mod" />
|
||||
<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
|
||||
<p>Hint : you can update the serial history manually. This can be useful for an old subscription or to clean the existing history. Modify those fields with care, as future serial recieve will continue to update them automatically.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Subscription start date</td>
|
||||
<td><input type="text" name="histstartdate" value="[% histstartdate | $KohaDates %]" /> (start date of the 1st subscription)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subscription end date</td>
|
||||
<td><input type="text" name="histenddate" value="[% histenddate | $KohaDates %]" />(if empty, subscription is still active)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Received issues</td>
|
||||
<td><textarea name="receivedlist" cols="60" rows="5">[% receivedlist %]</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Missing issues</td>
|
||||
<td><textarea name="missinglist" cols="60" rows="5">[% missinglist %]</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Note for OPAC</td>
|
||||
<td><textarea name="opacnote" cols="60" rows="5">[% opacnote %]</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Note for staff</td>
|
||||
<td><textarea name="librariannote" cols="60" rows="5">[% librariannote %]</textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" value="Save subscription history" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'serials-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
|
@ -0,0 +1,333 @@
|
|||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Serials › Number patterns</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
[% INCLUDE 'calendar.inc' %]
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
[% IF (new or modify) %]
|
||||
function testPattern() {
|
||||
var frequencyid = $("#frequency").val();
|
||||
var firstacquidate = $("#firstacquidate").val();
|
||||
var error = 0;
|
||||
var error_msg = "";
|
||||
if(frequencyid == undefined || frequencyid == "") {
|
||||
error_msg += _("- Frequency is not defined\n");
|
||||
error ++;
|
||||
}
|
||||
if(firstacquidate == undefined || firstacquidate == "") {
|
||||
error_msg += _("- First publication date is not defined\n");
|
||||
error ++;
|
||||
}
|
||||
|
||||
if(error){
|
||||
alert(_("Cannot test prediction pattern for the following reason(s):\n\n")
|
||||
+ error_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var ajaxData = {
|
||||
'custompattern': true,
|
||||
};
|
||||
var ajaxParams = [
|
||||
'firstacquidate', 'subtype', 'sublength', 'frequency', 'numberingmethod',
|
||||
'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
|
||||
'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
|
||||
'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
|
||||
'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
|
||||
];
|
||||
for(i in ajaxParams) {
|
||||
var param = ajaxParams[i];
|
||||
var value = $("#"+param).val();
|
||||
if(value.length > 0)
|
||||
ajaxData[param] = value;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/cgi-bin/koha/serials/showpredictionpattern.pl",
|
||||
data: ajaxData,
|
||||
async: false,
|
||||
dataType: "text",
|
||||
success: function(data) {
|
||||
$("#predictionpattern").html(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
[% END %]
|
||||
|
||||
function show_blocking_subs() {
|
||||
$("#blocking_subs").show();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'serials-search.inc' %]
|
||||
|
||||
<div id="breadcrumbs">
|
||||
<a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
|
||||
<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> ›
|
||||
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Numbering patterns</a>
|
||||
</div>
|
||||
|
||||
<div id="doc3" class="yui-t2">
|
||||
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
[% IF (new or modify) %]
|
||||
<div class="yui-g">
|
||||
[% IF (new) %]
|
||||
<h1>New number pattern</h1>
|
||||
[% IF (error_existing_numberpattern) %]
|
||||
<div class="dialog">
|
||||
<p>A pattern with this name already exists.</p>
|
||||
</div>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<h1>Modify pattern: [% label %]</h1>
|
||||
[% IF (error_existing_numberpattern) %]
|
||||
<div class="dialog">
|
||||
<p>Another pattern with this name already exists.</p>
|
||||
</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div>
|
||||
<div class="yui-g">
|
||||
<form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="post">
|
||||
[% IF (new) %]
|
||||
<input type="hidden" name="op" value="savenew" />
|
||||
[% ELSE %]
|
||||
<input type="hidden" name="op" value="savemod" />
|
||||
<input type="hidden" name="id" value="[% id %]" />
|
||||
[% END %]
|
||||
<fieldset class="rows">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="label">Name:</label>
|
||||
<input type="text" id="label" name="label" value="[% label %]" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="description">Description:</label>
|
||||
<input type="text" id="description" name="description" value="[% description %]" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="numberingmethod">Numbering formula:</label>
|
||||
<input type="text" id="numberingmethod" name="numberingmethod" value="[% numberingmethod %]" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="displayorder">Display order:</label>
|
||||
<input type="text" id="displayorder" name="displayorder" value="[% displayorder %]" />
|
||||
</li>
|
||||
</ol>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>X</th>
|
||||
<th>Y</th>
|
||||
<th>Z</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Label</td>
|
||||
<td><input type="text" id="label1" name="label1" value="[% label1 %]" /></td>
|
||||
<td><input type="text" id="label2" name="label2" value="[% label2 %]" /></td>
|
||||
<td><input type="text" id="label3" name="label3" value="[% label3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Add</td>
|
||||
<td><input type="text" id="add1" name="add1" value="[% add1 %]" /></td>
|
||||
<td><input type="text" id="add2" name="add2" value="[% add2 %]" /></td>
|
||||
<td><input type="text" id="add3" name="add3" value="[% add3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Every</td>
|
||||
<td><input type="text" id="every1" name="every1" value="[% every1 %]" /></td>
|
||||
<td><input type="text" id="every2" name="every2" value="[% every2 %]" /></td>
|
||||
<td><input type="text" id="every3" name="every3" value="[% every3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Set back to</td>
|
||||
<td><input type="text" id="setto1" name="setto1" value="[% setto1 %]" /></td>
|
||||
<td><input type="text" id="setto2" name="setto2" value="[% setto2 %]" /></td>
|
||||
<td><input type="text" id="setto3" name="setto3" value="[% setto3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>When more than</td>
|
||||
<td><input type="text" id="whenmorethan1" name="whenmorethan1" value="[% whenmorethan1 %]" /></td>
|
||||
<td><input type="text" id="whenmorethan2" name="whenmorethan2" value="[% whenmorethan2 %]" /></td>
|
||||
<td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
[% BLOCK numbering_select %]
|
||||
<select id="[% name %]" name="[% name %]" />
|
||||
<option value=""></option>
|
||||
[% IF (value == "dayname") %]
|
||||
<option selected="selected" value="dayname">Name of day</option>
|
||||
[% ELSE %]
|
||||
<option value="dayname">Name of day</option>
|
||||
[% END %]
|
||||
[% IF (value == "monthname") %]
|
||||
<option selected="selected" value="monthname">Name of month</option>
|
||||
[% ELSE %]
|
||||
<option value="monthname">Name of month</option>
|
||||
[% END %]
|
||||
[% IF (value == "season") %]
|
||||
<option selected="selected" value="season">Name of season</option>
|
||||
[% ELSE %]
|
||||
<option value="season">Name of season</option>
|
||||
[% END %]
|
||||
</select>
|
||||
[% END %]
|
||||
<td>Fromatting</td>
|
||||
<td>[% PROCESS numbering_select name="numbering1" value=numbering1 %]</td>
|
||||
<td>[% PROCESS numbering_select name="numbering2" value=numbering2 %]</td>
|
||||
<td>[% PROCESS numbering_select name="numbering3" value=numbering3 %]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Save" />
|
||||
<input type="reset" value="Reset" />
|
||||
<input type="button" value="Cancel" onclick="window.location = '/cgi-bin/koha/serials/subscription-numberpatterns.pl';" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="yui-g">
|
||||
<form>
|
||||
<fieldset class="rows">
|
||||
<legend>Test prediction pattern</legend>
|
||||
<ol>
|
||||
<li>
|
||||
<label for="frequency">Frequency:</label>
|
||||
<select id="frequency">
|
||||
[% FOREACH frequency IN frequencies_loop %]
|
||||
<option value="[% frequency.id %]">[% frequency.description %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label for="firstacquidate">First issue publication date</label>
|
||||
<input type="text" id="firstacquidate" class="datepicker" size="10" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="sublength">Subscription length:</label>
|
||||
<select id="subtype">
|
||||
[% FOREACH subtype IN subtypes_loop %]
|
||||
<option value="[% subtype.value %]">[% subtype.value %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
<input type="text" id="sublength" size="3" />
|
||||
</li>
|
||||
<li>
|
||||
<label for="locale">Locale:</label>
|
||||
<select id="locale" name="locale">
|
||||
<option value=""></option>
|
||||
[% FOREACH locale IN locales %]
|
||||
<option value="[% locale %]">[% locale %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
<span class="hint">If empty, system locale is used</span>
|
||||
</li>
|
||||
</ol>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>X</th>
|
||||
<th>Y</th>
|
||||
<th>Z</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Begins with</td>
|
||||
<td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 %]" /></td>
|
||||
<td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 %]" /></td>
|
||||
<td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 %]" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Inner counter</td>
|
||||
<td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 %]" /></td>
|
||||
<td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 %]" /></td>
|
||||
<td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 %]" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<fieldset class="action">
|
||||
<input type="button" value="Test pattern" onclick="testPattern();" />
|
||||
</fieldset>
|
||||
<div id="predictionpattern"></div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<h1>Number patterns</h1>
|
||||
[% IF still_used %]
|
||||
<div class="dialog">
|
||||
<p>
|
||||
This pattern is still used by [% subscriptions.size %]
|
||||
subscription(s). Do you still want to delete it?
|
||||
</p>
|
||||
<p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
|
||||
<ul id="blocking_subs" style="display:none">
|
||||
[% FOREACH sub IN subscriptions %]
|
||||
<li style="list-style-type:none">
|
||||
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
||||
<form action="" method="get">
|
||||
<input type="hidden" name="op" value="del" />
|
||||
<input type="hidden" name="confirm" value="1" />
|
||||
<input type="hidden" name="id" value="[% id %]" />
|
||||
<input type="submit" class="approve" value="Yes, delete" />
|
||||
</form>
|
||||
<form action="" method="get">
|
||||
<input type="submit" class="deny" value="No, don't delete" />
|
||||
</form>
|
||||
</div>
|
||||
[% END %]
|
||||
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=new">New numbering pattern</a>
|
||||
[% IF (numberpatterns_loop.size) %]
|
||||
<table id="numberpatternst">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Numbering formula</th>
|
||||
<th>Display order</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH numberpattern IN numberpatterns_loop %]
|
||||
<tr>
|
||||
<td>[% numberpattern.label %]</td>
|
||||
<td>[% numberpattern.description %]</td>
|
||||
<td>[% numberpattern.numberingmethod %]</td>
|
||||
<td>[% numberpattern.displayorder %]</td>
|
||||
<td>
|
||||
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=modify&id=[% numberpattern.id %]">Edit</a> |
|
||||
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=del&id=[% numberpattern.id %]">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% ELSE %]
|
||||
<p>There is no existing patterns.</p>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
[% INCLUDE 'serials-menu.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
42
serials/create-numberpattern.pl
Executable file
42
serials/create-numberpattern.pl
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use C4::Serials::Numberpattern;
|
||||
use URI::Escape;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $input = new CGI;
|
||||
|
||||
my $numberpattern;
|
||||
foreach (qw/ numberingmethod label1 label2 label3 add1 add2 add3
|
||||
every1 every2 every3 setto1 setto2 setto3 whenmorethan1 whenmorethan2
|
||||
whenmorethan3 numbering1 numbering2 numbering3 locale /) {
|
||||
$numberpattern->{$_} = $input->param($_);
|
||||
}
|
||||
# patternname is label in database
|
||||
$numberpattern->{'label'} = $input->param('patternname');
|
||||
|
||||
# Check if pattern already exist in database
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = qq{
|
||||
SELECT id
|
||||
FROM subscription_numberpatterns
|
||||
WHERE STRCMP(label, ?) = 0
|
||||
};
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $rv = $sth->execute($numberpattern->{'label'});
|
||||
my $numberpatternid;
|
||||
if($rv == 0) {
|
||||
# Pattern does not exists
|
||||
$numberpatternid = AddSubscriptionNumberpattern($numberpattern);
|
||||
} else {
|
||||
($numberpatternid) = $sth->fetchrow_array;
|
||||
$numberpattern->{'id'} = $numberpatternid;
|
||||
ModSubscriptionNumberpattern($numberpattern);
|
||||
}
|
||||
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
|
||||
print "{\"numberpatternid\":\"$numberpatternid\"}";
|
|
@ -61,38 +61,40 @@ if($op eq 'gennext' && @subscriptionid){
|
|||
my $status = defined( $nbissues ) ? 2 : 3;
|
||||
$nbissues ||= 1;
|
||||
for ( my $i = 0; $i < $nbissues; $i++ ){
|
||||
$sth->execute($subscriptionid);
|
||||
# modify actual expected issue, to generate the next
|
||||
if ( my $issue = $sth->fetchrow_hashref ) {
|
||||
ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
|
||||
$issue->{planneddate}, $issue->{publisheddate},
|
||||
$status, "" );
|
||||
}else{
|
||||
$sth->execute($subscriptionid);
|
||||
# modify actual expected issue, to generate the next
|
||||
if ( my $issue = $sth->fetchrow_hashref ) {
|
||||
ModSerialStatus( $issue->{serialid}, $issue->{serialseq},
|
||||
$issue->{planneddate}, $issue->{publisheddate},
|
||||
$status, "" );
|
||||
} else {
|
||||
require C4::Serials::Numberpattern;
|
||||
my $subscription = GetSubscription($subscriptionid);
|
||||
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
|
||||
my $expected = GetNextExpected($subscriptionid);
|
||||
my (
|
||||
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
) = GetNextSeq($subscription);
|
||||
my (
|
||||
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
|
||||
$newinnerloop1, $newinnerloop2, $newinnerloop3
|
||||
) = GetNextSeq($subscription, $pattern, $expected->{publisheddate});
|
||||
|
||||
## We generate the next publication date
|
||||
my $nextpublisheddate = GetNextDate( $expected->{planneddate}->output('iso'), $subscription );
|
||||
## Creating the new issue
|
||||
NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
|
||||
1, $nextpublisheddate, $nextpublisheddate );
|
||||
## We generate the next publication date
|
||||
my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1);
|
||||
## Creating the new issue
|
||||
NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'},
|
||||
1, $nextpublisheddate, $nextpublisheddate );
|
||||
|
||||
## Updating the subscription seq status
|
||||
my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
|
||||
WHERE subscriptionid = ?";
|
||||
my $seqsth = $dbh->prepare($squery);
|
||||
$seqsth->execute(
|
||||
$newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1,
|
||||
$newinnerloop2, $newinnerloop3, $subscriptionid
|
||||
);
|
||||
## Updating the subscription seq status
|
||||
my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
|
||||
WHERE subscriptionid = ?";
|
||||
my $seqsth = $dbh->prepare($squery);
|
||||
$seqsth->execute(
|
||||
$newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1,
|
||||
$newinnerloop2, $newinnerloop3, $subscriptionid
|
||||
);
|
||||
|
||||
}
|
||||
last if $nbissues == 1;
|
||||
last if HasSubscriptionExpired($subscriptionid) > 0;
|
||||
}
|
||||
last if $nbissues == 1;
|
||||
last if HasSubscriptionExpired($subscriptionid) > 0;
|
||||
}
|
||||
print $query->redirect('/cgi-bin/koha/serials/serials-collection.pl?subscriptionid='.$subscriptionid);
|
||||
}
|
||||
|
@ -109,9 +111,6 @@ if (@subscriptionid){
|
|||
$subs->{missinglist} =~ s/\n/\<br\/\>/g;
|
||||
$subs->{recievedlist} =~ s/\n/\<br\/\>/g;
|
||||
##these are display information
|
||||
$subs->{ "periodicity" . $subs->{periodicity} } = 1;
|
||||
$subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
|
||||
$subs->{ "status" . $subs->{'status'} } = 1;
|
||||
$subs->{startdate} = format_date( $subs->{startdate} );
|
||||
$subs->{histstartdate} = format_date( $subs->{histstartdate} );
|
||||
if ( !defined $subs->{enddate} || $subs->{enddate} eq '0000-00-00' ) {
|
||||
|
@ -125,6 +124,10 @@ if (@subscriptionid){
|
|||
$subs->{'subscriptionid'} = $subscriptionid; # FIXME - why was this lost ?
|
||||
$location = GetAuthorisedValues('LOC', $subs->{'location'});
|
||||
$callnumber = $subs->{callnumber};
|
||||
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
|
||||
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
|
||||
$subs->{frequency} = $frequency;
|
||||
$subs->{numberpattern} = $numberpattern;
|
||||
push @$subscriptiondescs,$subs;
|
||||
my $tmpsubscription= GetFullSubscription($subscriptionid);
|
||||
@subscriptioninformation=(@$tmpsubscription,@subscriptioninformation);
|
||||
|
@ -154,6 +157,7 @@ foreach (@$location) {
|
|||
$locationlib = $_->{'lib'} if $_->{'selected'};
|
||||
}
|
||||
|
||||
|
||||
chop $subscriptionidlist;
|
||||
$template->param(
|
||||
subscriptionidlist => $subscriptionidlist,
|
||||
|
|
|
@ -192,10 +192,7 @@ for(my $i=0;$i<$count;$i++){
|
|||
$serialslist[$i]->{'barcode'} = "TEMP" . sprintf("%.0f",$temp);
|
||||
}
|
||||
|
||||
my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
|
||||
|
||||
$sth->execute($subscriptionid);
|
||||
my $solhistory = $sth->fetchrow_hashref;
|
||||
my $solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
|
||||
|
||||
$subs = &GetSubscription($subscriptionid);
|
||||
($totalissues,@serialslist) = GetSerials($subscriptionid);
|
||||
|
@ -253,9 +250,7 @@ if (C4::Context->preference("serialsadditems")){
|
|||
$template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ;
|
||||
}
|
||||
|
||||
$sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
|
||||
$sth->execute($subscriptionid);
|
||||
$solhistory = $sth->fetchrow_hashref;
|
||||
$solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
|
||||
|
||||
$template->param(
|
||||
user => $auser,
|
||||
|
|
194
serials/showpredictionpattern.pl
Executable file
194
serials/showpredictionpattern.pl
Executable file
|
@ -0,0 +1,194 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2011 BibLibre SARL
|
||||
# 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 2 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.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
showpredictionpattern.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This script calculate numbering of serials based on numbering pattern, and
|
||||
publication date, based on frequency and first publication date.
|
||||
|
||||
=cut
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use CGI;
|
||||
use Date::Calc qw(Today Day_of_Year Week_of_Year Day_of_Week Days_in_Year Delta_Days Add_Delta_Days Add_Delta_YM);
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Serials;
|
||||
use C4::Serials::Frequency;
|
||||
|
||||
my $input = new CGI;
|
||||
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
|
||||
template_name => 'serials/showpredictionpattern.tt',
|
||||
query => $input,
|
||||
type => 'intranet',
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { 'serials' => '*' },
|
||||
} );
|
||||
|
||||
my $subscriptionid = $input->param('subscriptionid');
|
||||
my $frequencyid = $input->param('frequency');
|
||||
my $firstacquidate = $input->param('firstacquidate');
|
||||
my $nextacquidate = $input->param('nextacquidate');
|
||||
my $enddate = $input->param('enddate');
|
||||
my $subtype = $input->param('subtype');
|
||||
my $sublength = $input->param('sublength');
|
||||
my $custompattern = $input->param('custompattern');
|
||||
|
||||
|
||||
my %pattern = (
|
||||
numberingmethod => $input->param('numberingmethod') // '',
|
||||
numbering1 => $input->param('numbering1') // '',
|
||||
numbering2 => $input->param('numbering2') // '',
|
||||
numbering3 => $input->param('numbering3') // '',
|
||||
add1 => $input->param('add1') // '',
|
||||
add2 => $input->param('add2') // '',
|
||||
add3 => $input->param('add3') // '',
|
||||
whenmorethan1 => $input->param('whenmorethan1') // '',
|
||||
whenmorethan2 => $input->param('whenmorethan2') // '',
|
||||
whenmorethan3 => $input->param('whenmorethan3') // '',
|
||||
setto1 => $input->param('setto1') // '',
|
||||
setto2 => $input->param('setto2') // '',
|
||||
setto3 => $input->param('setto3') // '',
|
||||
every1 => $input->param('every1') // '',
|
||||
every2 => $input->param('every2') // '',
|
||||
every3 => $input->param('every3') // '',
|
||||
);
|
||||
|
||||
if(!defined $firstacquidate || $firstacquidate eq ''){
|
||||
my ($year, $month, $day) = Today();
|
||||
$firstacquidate = sprintf "%04d-%02d-%02d", $year, $month, $day;
|
||||
} else {
|
||||
$firstacquidate = C4::Dates->new($firstacquidate)->output('iso');
|
||||
}
|
||||
|
||||
if($enddate){
|
||||
$enddate = C4::Dates->new($enddate)->output('iso');
|
||||
}
|
||||
|
||||
if($nextacquidate) {
|
||||
$nextacquidate = C4::Dates->new($nextacquidate)->output('iso');
|
||||
} else {
|
||||
$nextacquidate = $firstacquidate;
|
||||
}
|
||||
my $date = $nextacquidate;
|
||||
|
||||
my %subscription = (
|
||||
locale => $input->param('locale') // '',
|
||||
lastvalue1 => $input->param('lastvalue1') // '',
|
||||
lastvalue2 => $input->param('lastvalue2') // '',
|
||||
lastvalue3 => $input->param('lastvalue3') // '',
|
||||
innerloop1 => $input->param('innerloop1') // '',
|
||||
innerloop2 => $input->param('innerloop2') // '',
|
||||
innerloop3 => $input->param('innerloop3') // '',
|
||||
irregularity => '',
|
||||
periodicity => $frequencyid,
|
||||
countissuesperunit => 1,
|
||||
firstacquidate => $firstacquidate,
|
||||
);
|
||||
|
||||
my $issuenumber;
|
||||
if(defined $subscriptionid) {
|
||||
($issuenumber) = C4::Serials::GetFictiveIssueNumber(\%subscription, $date);
|
||||
} else {
|
||||
$issuenumber = 1;
|
||||
}
|
||||
|
||||
my @predictions_loop;
|
||||
my ($calculated) = GetSeq(\%subscription, \%pattern);
|
||||
push @predictions_loop, {
|
||||
number => $calculated,
|
||||
publicationdate => $date,
|
||||
issuenumber => $issuenumber,
|
||||
dow => Day_of_Week(split /-/, $date),
|
||||
};
|
||||
my @irreg = ();
|
||||
if(defined $subscriptionid) {
|
||||
@irreg = C4::Serials::GetSubscriptionIrregularities($subscriptionid);
|
||||
while(@irreg && $issuenumber > $irreg[0]) {
|
||||
shift @irreg;
|
||||
}
|
||||
if(@irreg && $issuenumber == $irreg[0]){
|
||||
$predictions_loop[0]->{'not_published'} = 1;
|
||||
shift @irreg;
|
||||
}
|
||||
}
|
||||
|
||||
my $i = 1;
|
||||
while( $i < 1000 ) {
|
||||
my %line;
|
||||
|
||||
if(defined $date){
|
||||
$date = GetNextDate(\%subscription, $date);
|
||||
}
|
||||
if(defined $date){
|
||||
$line{'publicationdate'} = $date;
|
||||
$line{'dow'} = Day_of_Week(split /-/, $date);
|
||||
}
|
||||
|
||||
# Check if we don't have exceed end date
|
||||
if($sublength){
|
||||
if($subtype eq "issues" && $i >= $sublength){
|
||||
last;
|
||||
} elsif($subtype eq "weeks" && $date && Delta_Days( split(/-/, $date), Add_Delta_Days( split(/-/, $firstacquidate), 7*$sublength - 1 ) ) < 0) {
|
||||
last;
|
||||
} elsif($subtype eq "months" && $date && (Delta_Days( split(/-/, $date), Add_Delta_YM( split(/-/, $firstacquidate), 0, $sublength) ) - 1) < 0 ) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
if($enddate && $date && Delta_Days( split(/-/, $date), split(/-/, $enddate) ) <= 0 ) {
|
||||
last;
|
||||
}
|
||||
|
||||
($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern);
|
||||
$issuenumber++;
|
||||
$line{'number'} = $calculated;
|
||||
$line{'issuenumber'} = $issuenumber;
|
||||
if(@irreg && $issuenumber == $irreg[0]){
|
||||
$line{'not_published'} = 1;
|
||||
shift @irreg;
|
||||
}
|
||||
push @predictions_loop, \%line;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$template->param(
|
||||
predictions_loop => \@predictions_loop,
|
||||
);
|
||||
|
||||
my $frequency = GetSubscriptionFrequency($frequencyid);
|
||||
|
||||
if ( $frequency->{unit} and not $custompattern ) {
|
||||
$template->param( ask_for_irregularities => 1 );
|
||||
if ( $frequency->{unit} eq 'day' and $frequency->{unitsperissue} == 1 ) {
|
||||
$template->param( daily_options => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $date && $enddate && $date ne $enddate )
|
||||
or ( $subtype eq 'issues' && $i < $sublength ) )
|
||||
{
|
||||
$template->param( not_consistent_end_date => 1 );
|
||||
}
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
|
@ -19,7 +19,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use CGI;
|
||||
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days);
|
||||
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM);
|
||||
use C4::Koha;
|
||||
use C4::Biblio;
|
||||
use C4::Auth;
|
||||
|
@ -29,6 +29,8 @@ use C4::Output;
|
|||
use C4::Context;
|
||||
use C4::Branch; # GetBranches
|
||||
use C4::Serials;
|
||||
use C4::Serials::Frequency;
|
||||
use C4::Serials::Numberpattern;
|
||||
use C4::Letters;
|
||||
use Carp;
|
||||
|
||||
|
@ -46,7 +48,7 @@ my @budgets;
|
|||
my $permission = ($op eq "modify") ? "edit_subscription" : "create_subscription";
|
||||
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "serials/subscription-add.tmpl",
|
||||
= get_template_and_user({template_name => "serials/subscription-add.tt",
|
||||
query => $query,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
|
@ -57,9 +59,7 @@ my ($template, $loggedinuser, $cookie)
|
|||
|
||||
|
||||
my $sub_on;
|
||||
my @subscription_types = (
|
||||
'issues', 'weeks', 'months'
|
||||
);
|
||||
my @subscription_types = (qw(issues weeks months));
|
||||
my @sub_type_data;
|
||||
|
||||
my $subs;
|
||||
|
@ -81,7 +81,7 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
|
|||
if ($subs->{$_} eq '0000-00-00') {
|
||||
$subs->{$_} = ''
|
||||
} else {
|
||||
$subs->{$_} = format_date($subs->{$_});
|
||||
$subs->{$_} = $subs->{$_};
|
||||
}
|
||||
}
|
||||
if (!defined $subs->{letter}) {
|
||||
|
@ -89,28 +89,32 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
|
|||
}
|
||||
letter_loop($subs->{'letter'}, $template);
|
||||
my $nextexpected = GetNextExpected($subscriptionid);
|
||||
$nextexpected->{'isfirstissue'} = $nextexpected->{planneddate}->output('iso') eq $firstissuedate ;
|
||||
$subs->{nextacquidate} = $nextexpected->{planneddate}->output() if($op eq 'modify');
|
||||
$nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ;
|
||||
$subs->{nextacquidate} = $nextexpected->{planneddate} if($op eq 'modify');
|
||||
unless($op eq 'modsubscription') {
|
||||
foreach my $length_unit (qw(numberlength weeklength monthlength)) {
|
||||
if ($subs->{$length_unit}){
|
||||
$sub_length=$subs->{$length_unit};
|
||||
$sub_on=$length_unit;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if ($subs->{$length_unit}) {
|
||||
$sub_length=$subs->{$length_unit};
|
||||
$sub_on=$length_unit;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$template->param( %{$subs} );
|
||||
$template->param("dow".$subs->{'dow'} => 1) if defined $subs->{'dow'};
|
||||
$template->param(
|
||||
$op => 1,
|
||||
"subtype_$sub_on" => 1,
|
||||
sublength =>$sub_length,
|
||||
history => ($op eq 'modify'),
|
||||
"periodicity".$subs->{'periodicity'} => 1,
|
||||
"numberpattern".$subs->{'numberpattern'} => 1,
|
||||
firstacquiyear => substr($firstissuedate,0,4),
|
||||
);
|
||||
|
||||
if($op eq 'modify') {
|
||||
my ($serials_number) = GetSerials($subscriptionid);
|
||||
if($serials_number > 1) {
|
||||
$template->param(more_than_one_serial => 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $op eq 'dup' ) {
|
||||
|
@ -173,8 +177,48 @@ if ($op eq 'addsubscription') {
|
|||
$template->param(bibliotitle => $bib->{title});
|
||||
}
|
||||
}
|
||||
$template->param((uc(C4::Context->preference("marcflavour"))) => 1);
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
||||
$template->param((uc(C4::Context->preference("marcflavour"))) => 1);
|
||||
|
||||
my @frequencies = GetSubscriptionFrequencies;
|
||||
my @frqloop;
|
||||
foreach my $freq (@frequencies) {
|
||||
my $selected = 0;
|
||||
$selected = 1 if ($subs->{periodicity} and $freq->{id} eq $subs->{periodicity});
|
||||
my $row = {
|
||||
id => $freq->{'id'},
|
||||
selected => $selected,
|
||||
label => $freq->{'description'},
|
||||
};
|
||||
push @frqloop, $row;
|
||||
}
|
||||
$template->param(frequencies => \@frqloop);
|
||||
|
||||
my @numpatterns = GetSubscriptionNumberpatterns;
|
||||
my @numberpatternloop;
|
||||
foreach my $numpattern (@numpatterns) {
|
||||
my $selected = 0;
|
||||
$selected = 1 if($subs->{numberpattern} and $numpattern->{id} eq $subs->{numberpattern});
|
||||
my $row = {
|
||||
id => $numpattern->{'id'},
|
||||
selected => $selected,
|
||||
label => $numpattern->{'label'},
|
||||
};
|
||||
push @numberpatternloop, $row;
|
||||
}
|
||||
$template->param(numberpatterns => \@numberpatternloop);
|
||||
|
||||
# Get installed locales
|
||||
# FIXME this will not work with all environments.
|
||||
# If call to locale fails, @locales will be an empty array, which is fine.
|
||||
my @locales = map {
|
||||
chomp;
|
||||
# we don't want POSIX and C locales
|
||||
/^C|^POSIX$/ ? () : $_
|
||||
} `locale -a`;
|
||||
$template->param(locales => \@locales);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
}
|
||||
|
||||
sub letter_loop {
|
||||
|
@ -196,76 +240,96 @@ sub _get_sub_length {
|
|||
my ($type, $length) = @_;
|
||||
return
|
||||
(
|
||||
$type eq 'numberlength' ? $length : 0,
|
||||
$type eq 'weeklength' ? $length : 0,
|
||||
$type eq 'monthlength' ? $length : 0,
|
||||
$type eq 'issues' ? $length : 0,
|
||||
$type eq 'weeks' ? $length : 0,
|
||||
$type eq 'months' ? $length : 0,
|
||||
);
|
||||
}
|
||||
|
||||
sub _guess_enddate {
|
||||
my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
|
||||
my ($year, $month, $day);
|
||||
my $enddate;
|
||||
if($numberlength != 0) {
|
||||
my $frequency = GetSubscriptionFrequency($frequencyid);
|
||||
if($frequency->{'unit'} eq 'day') {
|
||||
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
|
||||
} elsif($frequency->{'unit'} eq 'week') {
|
||||
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
|
||||
} elsif($frequency->{'unit'} eq 'month') {
|
||||
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
|
||||
} elsif($frequency->{'unit'} eq 'year') {
|
||||
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0);
|
||||
}
|
||||
} elsif($weeklength != 0) {
|
||||
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7);
|
||||
} elsif($monthlength != 0) {
|
||||
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength);
|
||||
}
|
||||
if(defined $year) {
|
||||
$enddate = sprintf("%04d-%02d-%02d", $year, $month, $day);
|
||||
} else {
|
||||
undef $enddate;
|
||||
}
|
||||
return $enddate;
|
||||
}
|
||||
|
||||
sub redirect_add_subscription {
|
||||
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('periodicity');
|
||||
my $dow = $query->param('dow');
|
||||
my @irregularity = $query->param('irregularity_select');
|
||||
my $periodicity = $query->param('frequency');
|
||||
my @irregularity = $query->param('irregularity');
|
||||
my $numberpattern = $query->param('numbering_pattern');
|
||||
my $locale = $query->param('locale');
|
||||
my $graceperiod = $query->param('graceperiod') || 0;
|
||||
|
||||
my $subtype = $query->param('subtype');
|
||||
my $sublength = $query->param('sublength');
|
||||
my ( $numberlength, $weeklength, $monthlength )
|
||||
= _get_sub_length( $query->param('subtype'), $query->param('sublength') );
|
||||
= _get_sub_length( $subtype, $sublength );
|
||||
my $add1 = $query->param('add1');
|
||||
my $every1 = $query->param('every1');
|
||||
my $whenmorethan1 = $query->param('whenmorethan1');
|
||||
my $setto1 = $query->param('setto1');
|
||||
my $lastvalue1 = $query->param('lastvalue1');
|
||||
my $innerloop1 = $query->param('innerloop1');
|
||||
my $add2 = $query->param('add2');
|
||||
my $every2 = $query->param('every2');
|
||||
my $whenmorethan2 = $query->param('whenmorethan2');
|
||||
my $setto2 = $query->param('setto2');
|
||||
my $innerloop2 = $query->param('innerloop2');
|
||||
my $lastvalue2 = $query->param('lastvalue2');
|
||||
my $add3 = $query->param('add3');
|
||||
my $every3 = $query->param('every3');
|
||||
my $whenmorethan3 = $query->param('whenmorethan3');
|
||||
my $setto3 = $query->param('setto3');
|
||||
my $lastvalue3 = $query->param('lastvalue3');
|
||||
my $innerloop3 = $query->param('innerloop3');
|
||||
my $numberingmethod = $query->param('numberingmethod');
|
||||
my $status = 1;
|
||||
my $biblionumber = $query->param('biblionumber');
|
||||
my $callnumber = $query->param('callnumber');
|
||||
my $notes = $query->param('notes');
|
||||
my $internalnotes = $query->param('internalnotes');
|
||||
my $hemisphere = $query->param('hemisphere') || 1;
|
||||
my $letter = $query->param('letter');
|
||||
my $manualhistory = $query->param('manualhist');
|
||||
my $manualhistory = $query->param('manualhist') ? 1 : 0;
|
||||
my $serialsadditems = $query->param('serialsadditems');
|
||||
my $staffdisplaycount = $query->param('staffdisplaycount');
|
||||
my $opacdisplaycount = $query->param('opacdisplaycount');
|
||||
my $location = $query->param('location');
|
||||
my $skip_serialseq = $query->param('skip_serialseq');
|
||||
my $startdate = format_date_in_iso( $query->param('startdate') );
|
||||
my $enddate = format_date_in_iso( $query->param('enddate') );
|
||||
my $firstacquidate = format_date_in_iso($query->param('firstacquidate'));
|
||||
my $histenddate = format_date_in_iso($query->param('histenddate'));
|
||||
my $histstartdate = format_date_in_iso($query->param('histstartdate'));
|
||||
my $recievedlist = $query->param('recievedlist');
|
||||
my $missinglist = $query->param('missinglist');
|
||||
my $opacnote = $query->param('opacnote');
|
||||
my $librariannote = $query->param('librariannote');
|
||||
my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
|
||||
$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
|
||||
$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
|
||||
$add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
|
||||
$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
|
||||
$numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity),
|
||||
$numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes,
|
||||
$serialsadditems,$staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate
|
||||
);
|
||||
ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
|
||||
if(!defined $enddate || $enddate eq '') {
|
||||
if($subtype eq "issues") {
|
||||
$enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
|
||||
} else {
|
||||
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
|
||||
}
|
||||
}
|
||||
|
||||
my $subscriptionid = NewSubscription(
|
||||
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber,
|
||||
$startdate, $periodicity, $numberlength, $weeklength,
|
||||
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
|
||||
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate,
|
||||
join(";",@irregularity), $numberpattern, $locale, $callnumber,
|
||||
$manualhistory, $internalnotes, $serialsadditems,
|
||||
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
|
||||
$skip_serialseq
|
||||
);
|
||||
|
||||
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
|
||||
return;
|
||||
|
@ -273,7 +337,7 @@ sub redirect_add_subscription {
|
|||
|
||||
sub redirect_mod_subscription {
|
||||
my $subscriptionid = $query->param('subscriptionid');
|
||||
my @irregularity = $query->param('irregularity_select');
|
||||
my @irregularity = $query->param('irregularity');
|
||||
my $auser = $query->param('user');
|
||||
my $librarian => $query->param('librarian'),
|
||||
my $branchcode = $query->param('branchcode');
|
||||
|
@ -282,76 +346,66 @@ sub redirect_mod_subscription {
|
|||
my $biblionumber = $query->param('biblionumber');
|
||||
my $aqbudgetid = $query->param('aqbudgetid');
|
||||
my $startdate = format_date_in_iso($query->param('startdate'));
|
||||
my $firstacquidate = format_date_in_iso( $query->param('firstacquidate') );
|
||||
my $nextacquidate = $query->param('nextacquidate') ?
|
||||
format_date_in_iso($query->param('nextacquidate')):
|
||||
format_date_in_iso($query->param('startdate'));
|
||||
$firstacquidate;
|
||||
my $enddate = format_date_in_iso($query->param('enddate'));
|
||||
my $periodicity = $query->param('periodicity');
|
||||
my $dow = $query->param('dow');
|
||||
my $periodicity = $query->param('frequency');
|
||||
|
||||
my $subtype = $query->param('subtype');
|
||||
my $sublength = $query->param('sublength');
|
||||
my ($numberlength, $weeklength, $monthlength)
|
||||
= _get_sub_length( $query->param('subtype'), $query->param('sublength') );
|
||||
= _get_sub_length( $subtype, $sublength );
|
||||
my $numberpattern = $query->param('numbering_pattern');
|
||||
my $add1 = $query->param('add1');
|
||||
my $every1 = $query->param('every1');
|
||||
my $whenmorethan1 = $query->param('whenmorethan1');
|
||||
my $setto1 = $query->param('setto1');
|
||||
my $locale = $query->param('locale');
|
||||
my $lastvalue1 = $query->param('lastvalue1');
|
||||
my $innerloop1 = $query->param('innerloop1');
|
||||
my $add2 = $query->param('add2');
|
||||
my $every2 = $query->param('every2');
|
||||
my $whenmorethan2 = $query->param('whenmorethan2');
|
||||
my $setto2 = $query->param('setto2');
|
||||
my $lastvalue2 = $query->param('lastvalue2');
|
||||
my $innerloop2 = $query->param('innerloop2');
|
||||
my $add3 = $query->param('add3');
|
||||
my $every3 = $query->param('every3');
|
||||
my $whenmorethan3 = $query->param('whenmorethan3');
|
||||
my $setto3 = $query->param('setto3');
|
||||
my $lastvalue3 = $query->param('lastvalue3');
|
||||
my $innerloop3 = $query->param('innerloop3');
|
||||
my $numberingmethod = $query->param('numberingmethod');
|
||||
my $status = 1;
|
||||
my $callnumber = $query->param('callnumber');
|
||||
my $notes = $query->param('notes');
|
||||
my $internalnotes = $query->param('internalnotes');
|
||||
my $hemisphere = $query->param('hemisphere');
|
||||
my $letter = $query->param('letter');
|
||||
my $manualhistory = $query->param('manualhist');
|
||||
my $manualhistory = $query->param('manualhist') ? 1 : 0;
|
||||
my $serialsadditems = $query->param('serialsadditems');
|
||||
# subscription history
|
||||
my $histenddate = format_date_in_iso($query->param('histenddate'));
|
||||
my $histstartdate = format_date_in_iso($query->param('histstartdate'));
|
||||
my $recievedlist = $query->param('recievedlist');
|
||||
my $missinglist = $query->param('missinglist');
|
||||
my $opacnote = $query->param('opacnote');
|
||||
my $librariannote = $query->param('librariannote');
|
||||
my $staffdisplaycount = $query->param('staffdisplaycount');
|
||||
my $opacdisplaycount = $query->param('opacdisplaycount');
|
||||
my $graceperiod = $query->param('graceperiod') || 0;
|
||||
my $location = $query->param('location');
|
||||
my $skip_serialseq = $query->param('skip_serialseq');
|
||||
|
||||
# Guess end date
|
||||
if(!defined $enddate || $enddate eq '') {
|
||||
if($subtype eq "issues") {
|
||||
$enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
|
||||
} else {
|
||||
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
|
||||
}
|
||||
}
|
||||
|
||||
my $nextexpected = GetNextExpected($subscriptionid);
|
||||
# If it's a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary.
|
||||
if ( $nextacquidate ne $nextexpected->{planneddate}->output('iso') ) {
|
||||
ModNextExpected($subscriptionid,C4::Dates->new($nextacquidate,'iso'));
|
||||
# If it's a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary.
|
||||
if ( $nextexpected->{planneddate} && $nextacquidate ne $nextexpected->{planneddate} ) {
|
||||
ModNextExpected($subscriptionid, $nextacquidate);
|
||||
# if we have not received any issues yet, then we also must change the firstacquidate for the subs.
|
||||
$firstissuedate = $nextacquidate if($nextexpected->{isfirstissue});
|
||||
}
|
||||
|
||||
ModSubscription(
|
||||
$auser, $branchcode, $aqbooksellerid, $cost,
|
||||
$aqbudgetid, $startdate, $periodicity, $firstissuedate,
|
||||
$dow, join(q{,},@irregularity), $numberpattern, $numberlength,
|
||||
$weeklength, $monthlength, $add1, $every1,
|
||||
$whenmorethan1, $setto1, $lastvalue1, $innerloop1,
|
||||
$add2, $every2, $whenmorethan2, $setto2,
|
||||
$lastvalue2, $innerloop2, $add3, $every3,
|
||||
$whenmorethan3, $setto3, $lastvalue3, $innerloop3,
|
||||
$numberingmethod, $status, $biblionumber, $callnumber,
|
||||
$notes, $letter, $hemisphere, $manualhistory,$internalnotes,
|
||||
$serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid
|
||||
);
|
||||
ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
|
||||
ModSubscription(
|
||||
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
|
||||
$periodicity, $firstacquidate, join(";",@irregularity),
|
||||
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1,
|
||||
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3,
|
||||
$status, $biblionumber, $callnumber, $notes, $letter,
|
||||
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
|
||||
$opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
|
||||
$skip_serialseq
|
||||
);
|
||||
|
||||
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -118,15 +118,9 @@ $template->param(%{ $subs });
|
|||
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
|
||||
my @irregular_issues = split /,/, $subs->{irregularity};
|
||||
|
||||
if (! $subs->{numberpattern}) {
|
||||
$subs->{numberpattern} = q{};
|
||||
}
|
||||
if (! $subs->{dow}) {
|
||||
$subs->{dow} = q{};
|
||||
}
|
||||
if (! $subs->{periodicity}) {
|
||||
$subs->{periodicity} = '0';
|
||||
}
|
||||
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
|
||||
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
|
||||
|
||||
my $default_bib_view = get_default_view();
|
||||
|
||||
my ( $order, $bookseller, $tmpl_infos );
|
||||
|
@ -167,9 +161,11 @@ $template->param(
|
|||
C4::Context->userenv->{flags} % 2 !=1 &&
|
||||
C4::Context->userenv->{branch} && $subs->{branchcode} &&
|
||||
(C4::Context->userenv->{branch} ne $subs->{branchcode})),
|
||||
'periodicity' . $subs->{periodicity} => 1,
|
||||
'arrival' . $subs->{dow} => 1,
|
||||
'numberpattern' . $subs->{numberpattern} => 1,
|
||||
frequency => $frequency,
|
||||
numberpattern => $numberpattern,
|
||||
has_X => ($numberpattern->{'numberingmethod'} =~ /{X}/) ? 1 : 0,
|
||||
has_Y => ($numberpattern->{'numberingmethod'} =~ /{Y}/) ? 1 : 0,
|
||||
has_Z => ($numberpattern->{'numberingmethod'} =~ /{Z}/) ? 1 : 0,
|
||||
intranetstylesheet => C4::Context->preference('intranetstylesheet'),
|
||||
intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'),
|
||||
irregular_issues => scalar @irregular_issues,
|
||||
|
|
120
serials/subscription-frequencies.pl
Executable file
120
serials/subscription-frequencies.pl
Executable file
|
@ -0,0 +1,120 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2011 BibLibre SARL
|
||||
# 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 2 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.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
subscription-frequencies.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Manage subscription frequencies
|
||||
|
||||
=cut
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use CGI;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Serials;
|
||||
use C4::Serials::Frequency;
|
||||
|
||||
my $input = new CGI;
|
||||
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
|
||||
template_name => 'serials/subscription-frequencies.tt',
|
||||
query => $input,
|
||||
type => 'intranet',
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { 'parameters' => 1 },
|
||||
debug => 1,
|
||||
} );
|
||||
|
||||
my $op = $input->param('op');
|
||||
|
||||
if($op && ($op eq 'new' || $op eq 'modify')) {
|
||||
my @units_loop;
|
||||
push @units_loop, {val => $_} for (qw/ day week month year /);
|
||||
|
||||
if($op eq 'modify') {
|
||||
my $frequencyid = $input->param('frequencyid');
|
||||
my $frequency = GetSubscriptionFrequency($frequencyid);
|
||||
foreach (@units_loop) {
|
||||
if($frequency->{unit} and $_->{val} eq $frequency->{unit}) {
|
||||
$_->{selected} = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
$template->param( %$frequency );
|
||||
}
|
||||
|
||||
$template->param(
|
||||
units_loop => \@units_loop,
|
||||
$op => 1,
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
exit;
|
||||
}
|
||||
|
||||
if($op && ($op eq 'savenew' || $op eq 'savemod')) {
|
||||
my $frequency;
|
||||
foreach (qw/ description unit issuesperunit unitsperissue displayorder /) {
|
||||
$frequency->{$_} = $input->param($_);
|
||||
}
|
||||
$frequency->{unit} = undef if $frequency->{unit} eq '';
|
||||
foreach (qw/issuesperunit unitsperissue/) {
|
||||
$frequency->{$_} = 1 if $frequency->{$_} !~ /\d+/;
|
||||
}
|
||||
$frequency->{issuesperunit} = 1 if $frequency->{issuesperunit} < 1;
|
||||
$frequency->{unitsperissue} = 1 if $frequency->{issuesperunit} != 1;
|
||||
|
||||
if($op eq 'savemod') {
|
||||
$frequency->{id} = $input->param('id');
|
||||
ModSubscriptionFrequency($frequency);
|
||||
} else {
|
||||
AddSubscriptionFrequency($frequency);
|
||||
}
|
||||
} elsif($op && $op eq 'del') {
|
||||
my $frequencyid = $input->param('frequencyid');
|
||||
|
||||
if ($frequencyid) {
|
||||
my $confirm = $input->param('confirm');
|
||||
if ($confirm) {
|
||||
DelSubscriptionFrequency($frequencyid);
|
||||
} else {
|
||||
my @subs = GetSubscriptionsWithFrequency($frequencyid);
|
||||
if (@subs) {
|
||||
$template->param(
|
||||
frequencyid => $frequencyid,
|
||||
still_used => 1,
|
||||
subscriptions => \@subs
|
||||
);
|
||||
} else {
|
||||
DelSubscriptionFrequency($frequencyid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my @frequencies = GetSubscriptionFrequencies();
|
||||
|
||||
$template->param(frequencies_loop => \@frequencies);
|
||||
$template->param($op => 1) if $op;
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
19
serials/subscription-frequency.pl
Executable file
19
serials/subscription-frequency.pl
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use C4::Serials::Frequency;
|
||||
use C4::Auth qw/check_cookie_auth/;
|
||||
use URI::Escape;
|
||||
use strict;
|
||||
|
||||
my $input=new CGI;
|
||||
my $frqid=$input->param("frequency_id");
|
||||
my ($auth_status, $sessionID) = check_cookie_auth($input->cookie('CGISESSID'), { serials => '*' });
|
||||
if ($auth_status ne "ok") {
|
||||
exit 0;
|
||||
}
|
||||
my $frequencyrecord=GetSubscriptionFrequency($frqid);
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
|
||||
print "{".join (",",map { "\"$_\":\"".uri_escape($frequencyrecord->{$_})."\"" }sort keys %$frequencyrecord)."}";
|
87
serials/subscription-history.pl
Executable file
87
serials/subscription-history.pl
Executable file
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2011 BibLibre SARL
|
||||
# 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 2 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.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
subscription-history.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Modify subscription history
|
||||
|
||||
=cut
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use CGI;
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
|
||||
use C4::Biblio;
|
||||
use C4::Dates qw(format_date_in_iso);
|
||||
use C4::Serials;
|
||||
|
||||
my $input = new CGI;
|
||||
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
|
||||
template_name => 'serials/subscription-history.tt',
|
||||
query => $input,
|
||||
type => 'intranet',
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { 'serials' => 'edit_subscription' },
|
||||
debug => 1,
|
||||
} );
|
||||
|
||||
my $subscriptionid = $input->param('subscriptionid');
|
||||
my $op = $input->param('op');
|
||||
|
||||
if(!defined $subscriptionid || $subscriptionid eq '') {
|
||||
print $input->redirect('/cgi-bin/koha/serials/serials-home.pl');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($op && $op eq 'mod') {
|
||||
my $histstartdate = $input->param('histstartdate');
|
||||
my $histenddate = $input->param('histenddate');
|
||||
my $receivedlist = $input->param('receivedlist');
|
||||
my $missinglist = $input->param('missinglist');
|
||||
my $opacnote = $input->param('opacnote');
|
||||
my $librariannote = $input->param('librariannote');
|
||||
|
||||
ModSubscriptionHistory( $subscriptionid, format_date_in_iso($histstartdate),
|
||||
format_date_in_iso($histenddate), $receivedlist, $missinglist, $opacnote,
|
||||
$librariannote );
|
||||
|
||||
print $input->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
|
||||
exit;
|
||||
} else {
|
||||
my $history = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
|
||||
my (undef, $biblio) = GetBiblio($history->{'biblionumber'});
|
||||
|
||||
$template->param(
|
||||
subscriptionid => $subscriptionid,
|
||||
title => $biblio->{'title'},
|
||||
histstartdate => $history->{'histstartdate'},
|
||||
histenddate => $history->{'histenddate'},
|
||||
receivedlist => $history->{'recievedlist'},
|
||||
missinglist => $history->{'missinglist'},
|
||||
opacnote => $history->{'opacnote'},
|
||||
librariannote => $history->{'librariannote'},
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
}
|
15
serials/subscription-numberpattern.pl
Executable file
15
serials/subscription-numberpattern.pl
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use CGI;
|
||||
use C4::Serials::Numberpattern;
|
||||
use URI::Escape;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $input=new CGI;
|
||||
my $numpatternid=$input->param("numberpattern_id");
|
||||
|
||||
my $numberpatternrecord=GetSubscriptionNumberpattern($numpatternid);
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
|
||||
print "{",join (",",map {"\"$_\":\"".(uri_escape($numberpatternrecord->{$_}) // '')."\"" }sort keys %$numberpatternrecord),"}";
|
150
serials/subscription-numberpatterns.pl
Executable file
150
serials/subscription-numberpatterns.pl
Executable file
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2011 BibLibre SARL
|
||||
# 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 2 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.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
subscription-numberpatterns.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Manage numbering patterns
|
||||
|
||||
=cut
|
||||
|
||||
use Modern::Perl;
|
||||
use CGI;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Serials::Numberpattern;
|
||||
use C4::Serials::Frequency;
|
||||
|
||||
my $input = new CGI;
|
||||
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
|
||||
template_name => 'serials/subscription-numberpatterns.tt',
|
||||
query => $input,
|
||||
type => 'intranet',
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { 'parameters' => 1 }
|
||||
} );
|
||||
|
||||
my $op = $input->param('op');
|
||||
|
||||
if($op && $op eq 'savenew') {
|
||||
my $label = $input->param('label');
|
||||
my $numberpattern;
|
||||
foreach(qw/ label description numberingmethod displayorder
|
||||
label1 label2 label3 add1 add2 add3 every1 every2 every3
|
||||
setto1 setto2 setto3 whenmorethan1 whenmorethan2 whenmorethan3
|
||||
numbering1 numbering2 numbering3 /) {
|
||||
$numberpattern->{$_} = $input->param($_);
|
||||
if($numberpattern->{$_} and $numberpattern->{$_} eq '') {
|
||||
$numberpattern->{$_} = undef;
|
||||
}
|
||||
}
|
||||
my $numberpattern2 = GetSubscriptionNumberpatternByName($label);
|
||||
|
||||
if(!defined $numberpattern2) {
|
||||
AddSubscriptionNumberpattern($numberpattern);
|
||||
} else {
|
||||
$op = 'new';
|
||||
$template->param(error_existing_numberpattern => 1);
|
||||
$template->param(%$numberpattern);
|
||||
}
|
||||
} elsif ($op && $op eq 'savemod') {
|
||||
my $id = $input->param('id');
|
||||
my $label = $input->param('label');
|
||||
my $numberpattern = GetSubscriptionNumberpattern($id);
|
||||
my $mod_ok = 1;
|
||||
if($numberpattern->{'label'} ne $label) {
|
||||
my $numberpattern2 = GetSubscriptionNumberpatternByName($label);
|
||||
if(defined $numberpattern2 && $id != $numberpattern2->{'id'}) {
|
||||
$mod_ok = 0;
|
||||
}
|
||||
}
|
||||
if($mod_ok) {
|
||||
foreach(qw/ id label description numberingmethod displayorder
|
||||
label1 label2 label3 add1 add2 add3 every1 every2 every3
|
||||
setto1 setto2 setto3 whenmorethan1 whenmorethan2 whenmorethan3
|
||||
numbering1 numbering2 numbering3 /) {
|
||||
$numberpattern->{$_} = $input->param($_) || undef;
|
||||
}
|
||||
ModSubscriptionNumberpattern($numberpattern);
|
||||
} else {
|
||||
$op = 'modify';
|
||||
$template->param(error_existing_numberpattern => 1);
|
||||
}
|
||||
}
|
||||
|
||||
if($op && ($op eq 'new' || $op eq 'modify')) {
|
||||
if($op eq 'modify') {
|
||||
my $id = $input->param('id');
|
||||
if(defined $id) {
|
||||
my $numberpattern = GetSubscriptionNumberpattern($id);
|
||||
$template->param(%$numberpattern);
|
||||
} else {
|
||||
$op = 'new';
|
||||
}
|
||||
}
|
||||
my @frequencies = GetSubscriptionFrequencies();
|
||||
my @subtypes;
|
||||
push @subtypes, { value => $_ } for (qw/ issues weeks months /);
|
||||
my @locales = map {
|
||||
chomp;
|
||||
/^C|^POSIX$/ ? () : $_
|
||||
} `locale -a`;
|
||||
|
||||
$template->param(
|
||||
$op => 1,
|
||||
frequencies_loop => \@frequencies,
|
||||
subtypes_loop => \@subtypes,
|
||||
locales => \@locales,
|
||||
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
exit;
|
||||
}
|
||||
|
||||
if($op && $op eq 'del') {
|
||||
my $id = $input->param('id');
|
||||
if ($id) {
|
||||
my $confirm = $input->param('confirm');
|
||||
if ($confirm) {
|
||||
DelSubscriptionNumberpattern($id);
|
||||
} else {
|
||||
my @subs = GetSubscriptionsWithNumberpattern($id);
|
||||
if (@subs) {
|
||||
$template->param(
|
||||
id => $id,
|
||||
still_used => 1,
|
||||
subscriptions => \@subs
|
||||
);
|
||||
} else {
|
||||
DelSubscriptionNumberpattern($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my @numberpatterns_loop = GetSubscriptionNumberpatterns();
|
||||
|
||||
$template->param(
|
||||
numberpatterns_loop => \@numberpatterns_loop,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
Loading…
Reference in a new issue