fix POD errors reported by xt/author/podcorrectness.t
[koha.git] / C4 / Serials / Frequency.pm
1 package C4::Frequency;
2
3 # Copyright 2000-2002 Biblibre SARL
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 use C4::Context;
22 use C4::SQLHelper qw<:all>;
23 use C4::Debug;
24
25 use vars qw($VERSION @ISA @EXPORT);
26
27 BEGIN {
28         # set the version for version checking
29         $VERSION = 3.01;
30         require Exporter;
31         @ISA    = qw(Exporter);
32         @EXPORT = qw(
33
34         &GetFrequencies
35         &GetFrequency
36                 &new
37                 &all
38             &AddFrequency
39         &ModFrequency
40         &DelFrequency
41
42         );
43 }
44
45 # -------------------------------------------------------------------
46 my %count_issues_a_year=(
47         day=>365,
48         week=>52,
49         month=>12,
50         quarter=>4,
51         year=>1
52 );
53
54 sub new {
55     my ($class, $opts) = @_;
56     bless $opts => $class;
57 }
58
59
60 sub AddFrequency {
61     my ($class,$frequency) = @_;
62         return InsertInTable("subscription_frequency",$frequency);
63 }
64
65 sub GetExpectedissuesayear {
66     my ($class,$unit,$issuesperunit,$unitperissues) = @_;
67         return Int($count_issues_a_year{$unit}/$issuesperunit)*$unitperissues;
68 }
69
70 # -------------------------------------------------------------------
71 sub ModFrequency {
72     my ($class,$frequency) = @_;
73         return UpdateInTable("subscription_frequency",$frequency);
74 }
75
76 # -------------------------------------------------------------------
77 sub DelFrequency {
78         my ($class,$frequency) = @_;
79         return DeleteInTable("subscription_frequency",$frequency);
80 }
81
82 sub all {
83     my ($class) = @_;
84     my $dbh = C4::Context->dbh;
85     return    map { $class->new($_) }    @{$dbh->selectall_arrayref(
86         # The subscription_frequency table is small enough for
87         # `SELECT *` to be harmless.
88         "SELECT * FROM subscription_frequency ORDER BY description",
89         { Slice => {} },
90     )};
91 }
92
93 =head3 GetFrequency
94
95 =over 4
96
97 &GetFrequency($freq_id);
98
99 gets frequency where $freq_id is the identifier
100
101 =back
102
103 =cut
104
105 # -------------------------------------------------------------------
106 sub GetFrequency {
107     my ($freq_id) = @_;
108         return undef unless $freq_id;
109     my $results= SearchInTable("subscription_frequency",{frequency_id=>$freq_id}, undef, undef,undef, undef, "wide");
110         return undef unless ($results);
111         return $$results[0];
112 }
113
114 =head3 GetFrequencies
115
116 =over 4
117
118 &GetFrequencies($filter, $order_by);
119
120 gets frequencies restricted on filters
121
122 =back
123
124 =cut
125
126 # -------------------------------------------------------------------
127 sub GetFrequencies {
128     my ($filters,$orderby) = @_;
129     return SearchInTable("subscription_frequency",$filters, $orderby, undef,undef, undef, "wide");
130 }
131
132 END { }    # module clean-up code here (global destructor)
133
134 1;
135 __END__
136
137 =head1 AUTHOR
138
139 Koha Developement team <info@koha.org>
140
141 =cut