DB rev 134: DisplayMultiPlaceHold syspref
[koha.git] / C4 / Serials / Frequency.pm
blobe41db5e0cfa1e8353c5ce6654afe03c0fd00173a
1 package C4::Frequency;
3 # Copyright 2000-2002 Biblibre SARL
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 #use warnings; FIXME - Bug 2505
22 use C4::Context;
23 use C4::SQLHelper qw<:all>;
24 use C4::Debug;
26 use vars qw($VERSION @ISA @EXPORT);
28 BEGIN {
29 # set the version for version checking
30 $VERSION = 3.01;
31 require Exporter;
32 @ISA = qw(Exporter);
33 @EXPORT = qw(
35 &GetFrequencies
36 &GetFrequency
37 &new
38 &all
39 &AddFrequency
40 &ModFrequency
41 &DelFrequency
46 # -------------------------------------------------------------------
47 my %count_issues_a_year=(
48 day=>365,
49 week=>52,
50 month=>12,
51 quarter=>4,
52 year=>1
55 sub new {
56 my ($class, $opts) = @_;
57 bless $opts => $class;
61 sub AddFrequency {
62 my ($class,$frequency) = @_;
63 return InsertInTable("subscription_frequency",$frequency);
66 sub GetExpectedissuesayear {
67 my ($class,$unit,$issuesperunit,$unitperissues) = @_;
68 return Int($count_issues_a_year{$unit}/$issuesperunit)*$unitperissues;
71 # -------------------------------------------------------------------
72 sub ModFrequency {
73 my ($class,$frequency) = @_;
74 return UpdateInTable("subscription_frequency",$frequency);
77 # -------------------------------------------------------------------
78 sub DelFrequency {
79 my ($class,$frequency) = @_;
80 return DeleteInTable("subscription_frequency",$frequency);
83 sub all {
84 my ($class) = @_;
85 my $dbh = C4::Context->dbh;
86 return map { $class->new($_) } @{$dbh->selectall_arrayref(
87 # The subscription_frequency table is small enough for
88 # `SELECT *` to be harmless.
89 "SELECT * FROM subscription_frequency ORDER BY description",
90 { Slice => {} },
91 )};
94 =head3 GetFrequency
96 =over 4
98 &GetFrequency($freq_id);
100 gets frequency where $freq_id is the identifier
102 =back
104 =cut
106 # -------------------------------------------------------------------
107 sub GetFrequency {
108 my ($freq_id) = @_;
109 return undef unless $freq_id;
110 my $results= SearchInTable("subscription_frequency",{frequency_id=>$freq_id}, undef, undef,undef, undef, "wide");
111 return undef unless ($results);
112 return $$results[0];
115 =head3 GetFrequencies
117 =over 4
119 &GetFrequencies($filter, $order_by);
121 gets frequencies restricted on filters
123 =back
125 =cut
127 # -------------------------------------------------------------------
128 sub GetFrequencies {
129 my ($filters,$orderby) = @_;
130 return SearchInTable("subscription_frequency",$filters, $orderby, undef,undef, undef, "wide");
133 END { } # module clean-up code here (global destructor)
136 __END__
138 =head1 AUTHOR
140 Koha Developement team <info@koha.org>
142 =cut