oups, sorry, fixing mistake in previous patch
[koha.git] / C4 / Serials / NumberPattern.pm
1 package C4::Numberpattern;
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         &GetNumberpatterns
35         &GetNumberpattern
36                 &new
37                 &all
38             &AddNumberpattern
39         &ModNumberpattern
40         &DelNumberpattern
41
42         );
43 }
44
45 # -------------------------------------------------------------------
46 sub new {
47     my ($class, $opts) = @_;
48     bless $opts => $class;
49 }
50
51
52 sub AddNumberpattern {
53     my ($class,$numberpattern) = @_;
54         return InsertInTable("subscription_numberpattern",$numberpattern);
55 }
56
57 # -------------------------------------------------------------------
58 sub ModNumberpattern {
59     my ($class,$numberpattern) = @_;
60         return UpdateInTable("subscription_numberpattern",$numberpattern);
61 }
62
63 # -------------------------------------------------------------------
64 sub DelNumberpattern {
65         my ($class,$numberpattern) = @_;
66         return DeleteInTable("subscription_numberpattern",$numberpattern);
67 }
68
69 sub all {
70     my ($class) = @_;
71     my $dbh = C4::Context->dbh;
72     return    map { $class->new($_) }    @{$dbh->selectall_arrayref(
73         # The subscription_numberpattern table is small enough for
74         # `SELECT *` to be harmless.
75         "SELECT * FROM subscription_numberpattern ORDER BY description",
76         { Slice => {} },
77     )};
78 }
79
80 =head3 GetNumberpattern
81
82 =over 4
83
84 &GetNumberpattern($freq_id);
85
86 gets numberpattern where $freq_id is the identifier
87
88 =back
89
90 =cut
91
92 # -------------------------------------------------------------------
93 sub GetNumberpattern {
94     my ($numpattern_id) = @_;
95         return undef unless $num_patternid;
96     my $results= SearchInTable("subscription_numberpattern",{numberpattern_id=>$freq_id}, undef, undef,undef, undef, "wide");
97         return undef unless ($results);
98         return $$results[0];
99 }
100
101 =head3 GetFrequencies
102
103 =over 4
104
105 &GetFrequencies($filter, $order_by);
106
107 gets frequencies restricted on filters
108
109 =back
110
111 =cut
112
113 # -------------------------------------------------------------------
114 sub GetNumberPatterns {
115     my ($filters,$orderby) = @_;
116     return SearchInTable("subscription_numberpattern",$filters, $orderby, undef,undef, undef, "wide");
117 }
118
119 END { }    # module clean-up code here (global destructor)
120
121 1;
122 __END__
123
124 =back
125
126 =head1 AUTHOR
127
128 Koha Developement team <info@koha.org>
129
130 =cut