1 package Koha
::Item
::Search
::Field
;
4 use base
qw( Exporter );
16 sub AddItemSearchField
{
19 my ( $name, $label, $tagfield, $tagsubfield, $av_category ) =
20 @
$field{qw(name label tagfield tagsubfield authorised_values_category)};
22 return unless ($name and $label and $tagfield);
24 my $dbh = C4
::Context
->dbh;
26 INSERT INTO items_search_fields (name, label, tagfield, tagsubfield, authorised_values_category)
27 VALUES (?, ?, ?, ?, ?)
29 my $sth = $dbh->prepare($query);
30 my $rv = $sth->execute($name, $label, $tagfield, $tagsubfield, $av_category);
32 return ($rv) ?
$field : undef;
35 sub ModItemSearchField
{
38 my ( $name, $label, $tagfield, $tagsubfield, $av_category ) =
39 @
$field{qw(name label tagfield tagsubfield authorised_values_category)};
41 return unless ($name and $label and $tagfield);
43 my $dbh = C4
::Context
->dbh;
45 UPDATE items_search_fields
49 authorised_values_category = ?
52 my $sth = $dbh->prepare($query);
53 my $rv = $sth->execute($label, $tagfield, $tagsubfield, $av_category, $name);
55 return ($rv) ?
$field : undef;
58 sub DelItemSearchField
{
61 my $dbh = C4
::Context
->dbh;
63 DELETE FROM items_search_fields
66 my $sth = $dbh->prepare($query);
67 my $rv = $sth->execute($name);
69 my $is_deleted = $rv ?
int($rv) : 0;
71 warn "DelItemSearchField: Field '$name' doesn't exist";
77 sub GetItemSearchField
{
80 my $dbh = C4
::Context
->dbh;
82 SELECT * FROM items_search_fields
85 my $sth = $dbh->prepare($query);
86 my $rv = $sth->execute($name);
90 $field = $sth->fetchrow_hashref;
96 sub GetItemSearchFields
{
97 my $dbh = C4
::Context
->dbh;
99 SELECT * FROM items_search_fields
101 my $sth = $dbh->prepare($query);
102 my $rv = $sth->execute();
106 my $fields = $sth->fetchall_arrayref( {} );