MT 1717 : Opac descriptions for authorised values
This commit is contained in:
parent
88bb1b635b
commit
96fc46e2e1
11
C4/Biblio.pm
11
C4/Biblio.pm
|
|
@ -1272,19 +1272,22 @@ sub GetCOinSBiblio {
|
|||
=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) {
|
||||
|
|
@ -1308,11 +1311,11 @@ sub GetAuthorisedValueDesc {
|
|||
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
|
||||
|
|
|
|||
29
C4/Koha.pm
29
C4/Koha.pm
|
|
@ -1068,27 +1068,31 @@ sub GetAuthValCode {
|
|||
|
||||
$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;
|
||||
|
|
@ -1117,6 +1121,7 @@ sub GetAuthorisedValueCategories {
|
|||
=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.
|
||||
|
|
@ -1124,16 +1129,16 @@ sub GetAuthorisedValueCategories {
|
|||
=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 {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ sub AuthorizedValuesForCategory ($) {
|
|||
$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
|
||||
|
|
@ -73,7 +73,7 @@ $template->param( script_name => $script_name,
|
|||
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 {
|
||||
|
|
@ -93,6 +93,7 @@ if ($op eq 'add_form') {
|
|||
$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,
|
||||
|
|
@ -123,11 +124,14 @@ if ($op eq 'add_form') {
|
|||
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;
|
||||
}
|
||||
|
|
@ -139,11 +143,13 @@ if ($op eq 'add_form') {
|
|||
($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;
|
||||
}
|
||||
|
|
@ -158,12 +164,13 @@ if ($op eq 'add_form') {
|
|||
################## 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,
|
||||
);
|
||||
|
|
@ -219,12 +226,13 @@ sub default_form {
|
|||
# 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#! /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";
|
||||
|
|
@ -413,6 +413,7 @@ CREATE TABLE `authorised_values` (
|
|||
`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`),
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@
|
|||
<li>
|
||||
<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">
|
||||
|
|
@ -109,13 +113,16 @@
|
|||
<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" />
|
||||
|
|
@ -189,10 +196,11 @@ the subfield is not entered through a free field, but though a list of authorize
|
|||
<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>
|
||||
|
|
@ -203,9 +211,9 @@ the subfield is not entered through a free field, but though a list of authorize
|
|||
<!-- 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>
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) {
|
|||
}
|
||||
$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();
|
||||
|
|
@ -241,7 +241,7 @@ foreach my $field (@fields) {
|
|||
else {
|
||||
$this_row{ $subf[$i][0] } =
|
||||
GetAuthorisedValueDesc( $field->tag(), $subf[$i][0],
|
||||
$subf[$i][1], '', $tagslib );
|
||||
$subf[$i][1], '', $tagslib, '', 'opac' );
|
||||
}
|
||||
}
|
||||
if (%this_row) {
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ foreach my $biblionumber ( @bibs ) {
|
|||
$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'}){
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ if ( $itemtype ) {
|
|||
$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);
|
||||
|
|
@ -422,7 +422,7 @@ if (C4::Context->preference("OPACShelfBrowser")) {
|
|||
$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');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
|
|||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue