&ModBranch
&GetBranchInfo
&GetBranchesInCategory
- &ModBranchCategoryInfo
&mybranch
);
@EXPORT_OK = qw( &onlymine &mybranch );
return \@results;
}
-=head2 ModBranchCategoryInfo
-
-&ModBranchCategoryInfo($data);
-sets the data from the editbranch form, and writes to the database...
-
-=cut
-
-sub ModBranchCategoryInfo {
- my ($data) = @_;
- my $dbh = C4::Context->dbh;
- if ($data->{'add'}){
- # we are doing an insert
- my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)");
- $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} );
- }
- else {
- # modifying
- my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?");
- $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) );
- }
-}
1;
__END__
ModBranch
GetBranchInfo
GetBranchesInCategory
- ModBranchCategoryInfo
mybranch
)
);
my $count_cat = Koha::LibraryCategories->search->count;
my $cat1 = {
- add => 1,
categorycode => 'CAT1',
categoryname => 'catname1',
codedescription => 'catdesc1',
show_in_pulldown => 1
};
my $cat2 = {
- add => 1,
categorycode => 'CAT2',
categoryname => 'catname2',
categorytype => 'catype2',
show_in_pulldown => 1,
);
-ModBranchCategoryInfo({
- add => 1,
- %new_category,
-});
-
-ModBranchCategoryInfo($cat1);
-ModBranchCategoryInfo($cat2);
+Koha::LibraryCategory->new(\%new_category)->store;
+Koha::LibraryCategory->new($cat1)->store;
+Koha::LibraryCategory->new($cat2)->store;
my $categories = Koha::LibraryCategories->search;
is( $categories->count, $count_cat + 3, "Two categories added" );
-delete $cat1->{add};
-delete $cat2->{add};
-delete $new_category{add};
my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete;
is( $del, 1, 'One row affected' );
$b2->{categories} = \@cat;
is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' );
-ModBranchCategoryInfo({add => 1,%$cat2});
-is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two catgories added" );
+Koha::LibraryCategory->new($cat2)->store;
+is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" );
$b2 = {
branchcode => 'BRB',
branchname => 'BranchB',