Bug 15295! Koha::Libraries - Remove ModBranchCategoryInfo
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 3 Dec 2015 15:02:35 +0000 (15:02 +0000)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Thu, 14 Jan 2016 15:45:31 +0000 (15:45 +0000)
This has been replaced with Koha::Library->update_categories and
Koha::Library->add_to_categories

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
http://bugs.koha-community.org/show_bug.cgi?id=15294

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
C4/Branch.pm
t/db_dependent/Branch.t

index c4e4cc1..7e8b187 100644 (file)
@@ -38,7 +38,6 @@ BEGIN {
                &ModBranch
                &GetBranchInfo
                &GetBranchesInCategory
-               &ModBranchCategoryInfo
                &mybranch
        );
     @EXPORT_OK = qw( &onlymine &mybranch );
@@ -381,27 +380,6 @@ sub GetBranchInfo {
     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__
 
index 791f545..9076a2d 100644 (file)
@@ -43,7 +43,6 @@ can_ok(
       ModBranch
       GetBranchInfo
       GetBranchesInCategory
-      ModBranchCategoryInfo
       mybranch
       )
 );
@@ -166,7 +165,6 @@ is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA");
 my $count_cat  = Koha::LibraryCategories->search->count;
 
 my $cat1 = {
-    add              => 1,
     categorycode     => 'CAT1',
     categoryname     => 'catname1',
     codedescription  => 'catdesc1',
@@ -174,7 +172,6 @@ my $cat1 = {
     show_in_pulldown => 1
 };
 my $cat2 = {
-    add              => 1,
     categorycode     => 'CAT2',
     categoryname     => 'catname2',
     categorytype     => 'catype2',
@@ -190,19 +187,12 @@ my %new_category = (
     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' );
@@ -226,8 +216,8 @@ $b2->{issuing}    = undef;
 $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',