Line 0
Link Here
|
|
|
1 |
package Koha::DB::Branch; |
2 |
|
3 |
use Modern::Perl; |
4 |
use C4::Context; #FIXME = create a Koha package for KOHA_CONF reading |
5 |
|
6 |
use Koha::Database; |
7 |
use Class::Accessor "antlers"; |
8 |
|
9 |
has 'branchcode' => (is => 'rw', required => 1, isa => 'Str'); |
10 |
has 'branchname' => (is => 'rw', required => 1, isa => 'Str'); |
11 |
has 'branchaddress1' => (is => 'rw', required => 0, isa => 'Str'); |
12 |
has 'branchaddress2' => (is => 'rw', required => 0, isa => 'Str'); |
13 |
has 'branchaddress3' => (is => 'rw', required => 0, isa => 'Str'); |
14 |
has 'branchzip' => (is => 'rw', required => 0, isa => 'Str'); |
15 |
has 'branchcity' => (is => 'rw', required => 0, isa => 'Str'); |
16 |
has 'branchstate' => (is => 'rw', required => 0, isa => 'Str'); |
17 |
has 'branchcountry' => (is => 'rw', required => 0, isa => 'Str'); |
18 |
has 'branchphone' => (is => 'rw', required => 0, isa => 'Str'); |
19 |
has 'branchfax' => (is => 'rw', required => 0, isa => 'Str'); |
20 |
has 'branchemail' => (is => 'rw', required => 0, isa => 'Str'); |
21 |
has 'branchurl' => (is => 'rw', required => 0, isa => 'Str'); |
22 |
has 'issuing' => (is => 'rw', required => 0, isa => 'Int'); |
23 |
has 'branchip' => (is => 'rw', required => 0, isa => 'Str'); |
24 |
has 'branchprinter' => (is => 'rw', required => 0, isa => 'Str'); |
25 |
has 'branchnotes' => (is => 'rw', required => 0, isa => 'Str'); |
26 |
has 'opac_info' => (is => 'rw', required => 0, isa => 'Str'); |
27 |
|
28 |
my $database = Koha::Database->new(); |
29 |
my $schema = $database->schema(); |
30 |
|
31 |
sub create { |
32 |
my ($self) = @_; |
33 |
$schema->resultset('Branch')->create({ map { $_ => $self->$_ } $schema->source('Branch')->columns }); |
34 |
} |
35 |
|
36 |
sub read { |
37 |
my ($self, $branch) = @_; |
38 |
return $schema->resultset('Branch')->search($branch); |
39 |
} |
40 |
|
41 |
sub update { |
42 |
my ($self, $branch) = @_; |
43 |
return $schema->resultset('Branch')->search({branchcode => $branch->{branchcode}})->update($branch); |
44 |
} |
45 |
|
46 |
sub delete { |
47 |
my ($self,$branch) = @_; |
48 |
$schema->resultset('Branch')->search($branch)->delete; |
49 |
} |