1 package Koha::Item::Search::Field;
5 our (@ISA, @EXPORT_OK);
20 sub AddItemSearchField {
23 my ( $name, $label, $tagfield, $tagsubfield, $av_category ) =
24 @$field{qw(name label tagfield tagsubfield authorised_values_category)};
26 return unless ($name and $label and $tagfield);
28 my $dbh = C4::Context->dbh;
30 INSERT INTO items_search_fields (name, label, tagfield, tagsubfield, authorised_values_category)
31 VALUES (?, ?, ?, ?, ?)
33 my $sth = $dbh->prepare($query);
34 my $rv = $sth->execute($name, $label, $tagfield, $tagsubfield, $av_category);
36 return ($rv) ? $field : undef;
39 sub ModItemSearchField {
42 my ( $name, $label, $tagfield, $tagsubfield, $av_category ) =
43 @$field{qw(name label tagfield tagsubfield authorised_values_category)};
45 return unless ($name and $label and $tagfield);
47 my $dbh = C4::Context->dbh;
49 UPDATE items_search_fields
53 authorised_values_category = ?
56 my $sth = $dbh->prepare($query);
57 my $rv = $sth->execute($label, $tagfield, $tagsubfield, $av_category, $name);
59 return ($rv) ? $field : undef;
62 sub DelItemSearchField {
65 my $dbh = C4::Context->dbh;
67 DELETE FROM items_search_fields
70 my $sth = $dbh->prepare($query);
71 my $rv = $sth->execute($name);
73 my $is_deleted = $rv ? int($rv) : 0;
75 warn "DelItemSearchField: Field '$name' doesn't exist";
81 sub GetItemSearchField {
84 my $dbh = C4::Context->dbh;
86 SELECT * FROM items_search_fields
89 my $sth = $dbh->prepare($query);
90 my $rv = $sth->execute($name);
94 $field = $sth->fetchrow_hashref;
100 sub GetItemSearchFields {
101 my $dbh = C4::Context->dbh;
103 SELECT * FROM items_search_fields
105 my $sth = $dbh->prepare($query);
106 my $rv = $sth->execute();
110 my $fields = $sth->fetchall_arrayref( {} );