=over 4
my $subfieldvalue =get_authorised_value_desc(
- $tag, $subf[$i][0],$subf[$i][1], '', $taglib, $category);
+ $tag, $subf[$i][0],$subf[$i][1], '', $taglib, $category, $opac);
Retrieve the complete description for a given authorised value.
Now takes $category and $value pair too.
my $auth_value_desc =GetAuthorisedValueDesc(
'','', 'DVD' ,'','','CCODE');
+If the optional $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
+
+
=back
=cut
sub GetAuthorisedValueDesc {
- my ( $tag, $subfield, $value, $framework, $tagslib, $category ) = @_;
+ my ( $tag, $subfield, $value, $framework, $tagslib, $category, $opac ) = @_;
my $dbh = C4::Context->dbh;
if (!$category) {
if ( $category ne "" ) {
my $sth =
$dbh->prepare(
- "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?"
+ "SELECT lib, lib_opac FROM authorised_values WHERE category = ? AND authorised_value = ?"
);
$sth->execute( $category, $value );
my $data = $sth->fetchrow_hashref;
- return $data->{'lib'};
+ return ($opac && $data->{'lib_opac'}) ? $data->{'lib_opac'} : $data->{'lib'};
}
else {
return $value; # if nothing is found return the original value
$authvalues = GetAuthorisedValues([$category], [$selected]);
-This function returns all authorised values from the'authosied_value' table in a reference to array of hashrefs.
+This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs.
C<$category> returns authorised values for just one category (optional).
+C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist.
+
=cut
sub GetAuthorisedValues {
- my ($category,$selected) = @_;
+ my ($category,$selected,$opac) = @_;
my @results;
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM authorised_values";
$query .= " WHERE category = '" . $category . "'" if $category;
- $query .= " ORDER BY category, lib";
-
+ $query .= " ORDER BY category, lib, lib_opac";
my $sth = $dbh->prepare($query);
$sth->execute;
while (my $data=$sth->fetchrow_hashref) {
- if ($selected eq $data->{'authorised_value'} ) {
- $data->{'selected'} = 1;
- }
- push @results, $data;
+ if ($selected eq $data->{'authorised_value'} ) {
+ $data->{'selected'} = 1;
+ }
+ if ($opac && $data->{'lib_opac'}) {
+ $data->{'lib'} = $data->{'lib_opac'};
+ }
+ push @results, $data;
}
#my $data = $sth->fetchall_arrayref({});
return \@results; #$data;
=head2 GetKohaAuthorisedValues
Takes $kohafield, $fwcode as parameters.
+ If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
Returns hashref of Code => description
Returns undef
if no authorised value category is defined for the kohafield.
=cut
sub GetKohaAuthorisedValues {
- my ($kohafield,$fwcode,$codedvalue) = @_;
+ my ($kohafield,$fwcode,$opac) = @_;
$fwcode='' unless $fwcode;
my %values;
my $dbh = C4::Context->dbh;
my $avcode = GetAuthValCode($kohafield,$fwcode);
if ($avcode) {
- my $sth = $dbh->prepare("select authorised_value, lib from authorised_values where category=? ");
+ my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? ");
$sth->execute($avcode);
- while ( my ($val, $lib) = $sth->fetchrow_array ) {
- $values{$val}= $lib;
+ while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) {
+ $values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib;
}
return \%values;
} else {
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $sth=$dbh->prepare('
- SELECT id, category, authorised_value, lib, imageurl
+ SELECT id, category, authorised_value, lib, lib_opac, imageurl
FROM authorised_values
WHERE (category = ?)
ORDER BY category, authorised_value
if ($op eq 'add_form') {
my $data;
if ($id) {
- my $sth=$dbh->prepare("select id, category, authorised_value, lib, imageurl from authorised_values where id=?");
+ my $sth=$dbh->prepare("select id, category, authorised_value, lib, lib_opac, imageurl from authorised_values where id=?");
$sth->execute($id);
$data=$sth->fetchrow_hashref;
} else {
$template->param( category => $data->{'category'},
authorised_value => $data->{'authorised_value'},
lib => $data->{'lib'},
+ lib_opac => $data->{'lib_opac'},
id => $data->{'id'},
imagesets => C4::Koha::getImageSets( checked => $data->{'imageurl'} ),
offset => $offset,
SET category = ?,
authorised_value = ?,
lib = ?,
+ lib_opac = ?,
imageurl = ?
WHERE id=?' );
my $lib = $input->param('lib');
+ my $lib_opac = $input->param('lib_opac');
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
- $sth->execute($new_category, $new_authorised_value, $lib, $imageurl, $id);
+ undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
+ $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$new_category."&offset=$offset\"></html>";
exit;
}
($duplicate_entry) = $sth->fetchrow_array();
unless ( $duplicate_entry ) {
my $sth=$dbh->prepare( 'INSERT INTO authorised_values
- ( id, category, authorised_value, lib, imageurl )
- values (?, ?, ?, ?, ?)' );
+ ( id, category, authorised_value, lib, lib_opac, imageurl )
+ values (?, ?, ?, ?, ?, ?)' );
my $lib = $input->param('lib');
+ my $lib_opac = $input->param('lib_opac');
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
- $sth->execute($id, $new_category, $new_authorised_value, $lib, $imageurl );
+ undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
+ $sth->execute($id, $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$input->param('category')."&offset=$offset\"></html>";
exit;
}
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
- my $sth=$dbh->prepare("select category,authorised_value,lib from authorised_values where id=?");
+ my $sth=$dbh->prepare("select category,authorised_value,lib,lib_opac from authorised_values where id=?");
$sth->execute($id);
my $data=$sth->fetchrow_hashref;
$id = $input->param('id') unless $id;
$template->param(searchfield => $searchfield,
Tlib => $data->{'lib'},
+ Tlib_opac => $data->{'lib_opac'},
Tvalue => $data->{'authorised_value'},
id =>$id,
);
# builds value list
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
my %row_data; # get a fresh hash for the row data
- $row_data{category} = $results->[$i]{'category'};
- $row_data{authorised_value} = $results->[$i]{'authorised_value'};
- $row_data{lib} = $results->[$i]{'lib'};
- $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
- $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
- $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset";
+ $row_data{category} = $results->[$i]{'category'};
+ $row_data{authorised_value} = $results->[$i]{'authorised_value'};
+ $row_data{lib} = $results->[$i]{'lib'};
+ $row_data{lib_opac} = $results->[$i]{'lib_opac'};
+ $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
+ $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset";
+ $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset";
push(@loop_data, \%row_data);
}
--- /dev/null
+#! /usr/bin/perl
+use strict;
+use warnings;
+use C4::Context;
+my $dbh=C4::Context->dbh;
+$dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
+print "Upgrade done (Added a lib_opac field in authorised_values table)\n";
`category` varchar(10) NOT NULL default '',
`authorised_value` varchar(80) NOT NULL default '',
`lib` varchar(80) default NULL,
+ `lib_opac` varchar(80) default NULL,
`imageurl` varchar(200) default NULL,
PRIMARY KEY (`id`),
KEY `name` (`category`),
<label for="lib">Description</label>
<input type="text" name="lib" id="lib" value="<!-- TMPL_VAR name="lib" -->" />
</li>
+ <li>
+ <label for="lib_opac">Description (OPAC)</label>
+ <input type="text" name="lib_opac" id="lib_opac" value="<!-- TMPL_VAR name="lib_opac" -->" />
+ </li>
</ol>
<div id="icons" class="toptabs">
<h5 style="margin-left:10px;">Choose an Icon:</h5>
<table>
<tr>
<th>Category</th>
- <th>Variable</th>
<th>Value</th>
+ <th>Description</th>
+ <th>Description (OPAC)</th>
</tr>
<tr>
- <td><!-- TMPL_VAR name="searchfield" --></td>
- <td><!-- TMPL_VAR name="Tvalue" --></td>
- <td><!-- TMPL_VAR name="Tlib" --></td></tr>
+ <td><!-- TMPL_VAR name="searchfield" --></td>
+ <td><!-- TMPL_VAR name="Tvalue" --></td>
+ <td><!-- TMPL_VAR name="Tlib" --></td>
+ <td><!-- TMPL_VAR name="Tlib_opac" --></td>
+ </tr>
</table>
<form action="<!-- TMPL_VAR name=" script_name " -->" method="post">
<input type="hidden" name="op" value="delete_confirmed" />
<p>The list of status to describe a lost item</p>
<!-- /TMPL_IF -->
<table>
+<caption>Authorised values for category <!-- TMPL_VAR name="category" --> :</caption>
<tr>
- <th>Category</th>
<th>Authorized value</th>
<th>Description</th>
+ <th>Description (OPAC)</th>
<th>Icon</th>
<th>Edit</th>
<th>Delete</th>
<!-- TMPL_ELSE -->
<tr>
<!-- /TMPL_UNLESS -->
- <td><!-- TMPL_VAR name="category" --></td>
<td><!-- TMPL_VAR name="authorised_value" --></td>
<td><!-- TMPL_VAR name="lib" --></td>
+ <td><!-- TMPL_VAR name="lib_opac" --></td>
<td><!-- TMPL_IF NAME="imageurl" --><img src="<!-- TMPL_VAR name="imageurl" -->" alt=""/><!-- TMPL_ELSE --> <!-- /TMPL_IF --></td>
<td><a href="<!-- TMPL_VAR name="edit" -->">Edit</a></td>
<td><a href="<!-- TMPL_VAR name="delete" -->">Delete</a></td>
}
$subfield_data{marc_value} =
GetAuthorisedValueDesc( $fields[$x_i]->tag(),
- $subf[$i][0], $subf[$i][1], '', $tagslib );
+ $subf[$i][0], $subf[$i][1], '', $tagslib, '', 'opac' );
}
$subfield_data{marc_subfield} = $subf[$i][0];
$subfield_data{marc_tag} = $fields[$x_i]->tag();
else {
$this_row{ $subf[$i][0] } =
GetAuthorisedValueDesc( $field->tag(), $subf[$i][0],
- $subf[$i][1], '', $tagslib );
+ $subf[$i][1], '', $tagslib, '', 'opac' );
}
}
if (%this_row) {
$hasauthors = 1;
}
- my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
- my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} );
+ my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
+ my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
for my $itm (@items) {
if ($itm->{'location'}){
$dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
$dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
}
-my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
-my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} );
+my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
+my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
#coping with subscriptions
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
$starting_homebranch->{code} = $result->{'homebranch'};
$starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
$starting_location->{code} = $result->{'location'};
- $starting_location->{description} = GetAuthorisedValueDesc('','', $result->{'location'} ,'','','LOC');
+ $starting_location->{description} = GetAuthorisedValueDesc('','', $result->{'location'} ,'','','LOC', 'opac');
}
push @itemtypesloop, \%row;
}
} else {
- my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
- for my $thisitemtype (sort {$a->{'lib'} cmp $b->{'lib'}} @$advsearchtypes) {
+ my $advsearchtypes = GetAuthorisedValues($advanced_search_types, '', 'opac');
+ for my $thisitemtype (@$advsearchtypes) {
my %row =(
number=>$cnt++,
ccl => $advanced_search_types,