=head2 GetAuthorisedValues
- $authvalues = GetAuthorisedValues([$category], [$selected]);
+ $authvalues = GetAuthorisedValues([$category]);
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<$selected> adds a "selected => 1" entry to the hash if the
-authorised_value matches it. B<NOTE:> this feature should be considered
-deprecated as it may be removed in the future.
-
C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist.
=cut
sub GetAuthorisedValues {
- my ( $category, $selected, $opac ) = @_;
-
- # TODO: the "selected" feature should be replaced by a utility function
- # somewhere else, it doesn't belong in here. For starters it makes
- # caching much more complicated. Or just let the UI logic handle it, it's
- # what it's for.
+ my ( $category, $opac ) = @_;
# Is this cached already?
$opac = $opac ? 1 : 0; # normalise to be safe
my $branch_limit =
C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
- my $selected_key = defined($selected) ? $selected : '';
my $cache_key =
- "AuthorisedValues-$category-$selected_key-$opac-$branch_limit";
+ "AuthorisedValues-$category-$opac-$branch_limit";
my $cache = Koha::Cache->get_instance();
my $result = $cache->get_from_cache($cache_key);
return $result if $result;
$sth->execute( @where_args );
while (my $data=$sth->fetchrow_hashref) {
- if ( defined $selected and $selected eq $data->{authorised_value} ) {
- $data->{selected} = 1;
- }
- else {
- $data->{selected} = 0;
- }
-
if ($opac && $data->{lib_opac}) {
$data->{lib} = $data->{lib_opac};
}
}
$sth->finish;
- # We can't cache for long because of that "selected" thing which
- # makes it impossible to clear the cache without iterating through every
- # value, which sucks. This'll cover this request, and not a whole lot more.
$cache->set_in_cache( $cache_key, \@results, { deepcopy => 1, expiry => 5 } );
return \@results;
}
}
sub Get {
- my ( $self, $category, $selected, $opac ) = @_;
- return GetAuthorisedValues( $category, $selected, $opac );
+ my ( $self, $category, $opac ) = @_;
+ return GetAuthorisedValues( $category, $opac );
}
sub GetAuthValueDropbox {
if ( $op eq 'add_form' ) {
my $itemtype = Koha::ItemTypes->find($itemtype_code);
my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
- my $searchcategory = GetAuthorisedValues("ITEMTYPECAT", ( $itemtype ? $itemtype->searchcategory : '' ) );
+ my $searchcategory = GetAuthorisedValues("ITEMTYPECAT");
my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') );
$template->param(
itemtype => $itemtype,
branches_loop => \@branches_loop,
);
authorised_value_category_list($template);
- pa_classes($template);
+ $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS'));
}
sub error_add_attribute_type_form {
$template->param(display_checkout_checked => 'checked="checked"');
}
authorised_value_category_list($template, $attr_type->authorised_value_category());
- pa_classes( $template, $attr_type->class );
+ $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS' ));
my $branches = GetBranches;
}
$template->param( branches_loop => \@branches_loop );
- $template->param ( category_code => $attr_type->category_code );
- $template->param ( category_description => $attr_type->category_description );
+ $template->param(
+ category_code => $attr_type->category_code,
+ category_class => $attr_type->class,
+ category_description => $attr_type->category_description,
+ );
$template->param(
attribute_type_form => 1,
}
$template->param(authorised_value_categories => \@list);
}
-
-sub pa_classes {
- my $template = shift;
- my $selected = @_ ? shift : '';
-
- $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) );
-}
$item->{datedue} = format_sqldatetime($item->{datedue});
# item damaged, lost, withdrawn loops
- $item->{itemlostloop} = GetAuthorisedValues($authvalcode_items_itemlost, $item->{itemlost}) if $authvalcode_items_itemlost;
+ $item->{itemlostloop} = GetAuthorisedValues($authvalcode_items_itemlost) if $authvalcode_items_itemlost;
if ($item->{damaged}) {
- $item->{itemdamagedloop} = GetAuthorisedValues($authvalcode_items_damaged, $item->{damaged}) if $authvalcode_items_damaged;
+ $item->{itemdamagedloop} = GetAuthorisedValues($authvalcode_items_damaged) if $authvalcode_items_damaged;
}
#get shelf location and collection code description if they are authorised value.
# same thing for copy number
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
foreach my $item (@items){
$item->{object} = Koha::Items->find( $item->{itemnumber} );
- $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
- $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
- $item->{itemwithdrawnloop}= GetAuthorisedValues(GetAuthValCode('items.withdrawn',$fw),$item->{withdrawn}) if GetAuthValCode('items.withdrawn',$fw);
+ $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw)) if GetAuthValCode('items.itemlost',$fw);
+ $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw)) if GetAuthValCode('items.damaged',$fw);
+ $item->{itemwithdrawnloop}= GetAuthorisedValues(GetAuthValCode('items.withdrawn',$fw)) if GetAuthValCode('items.withdrawn',$fw);
$item->{'collection'} = $ccodes->{ $item->{ccode} } if ($ccodes);
$item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'};
$item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
default: the default authorised value to select
class: the CSS class of the select element
size: the size to use for the input (generated if the authorised value category does not exist).
+ all: add a "All" entry
%]
[% SET avs = AuthorisedValues.GetAuthValueDropbox( category, default ) %]
[% IF avs %]
<select id="[% name %]" name="[% name %]" class="[% class %]" >
+ [% IF all %]<option value="All">All</option>[% END %]
[% FOR av IN avs %]
[% IF av.default %]
<option value="[% av.value %]" selected="selected">[% av.label | html_entity %]</option>
<select name="streettype">
<option value=""></option>
[% FOR roadtype IN roadtypes %]
- [% IF roadtype.selected %]
+ [% IF roadtype.authorised_value == streettype %]
<option value="[% roadtype.authorised_value %]" selected="selected">[% roadtype.lib %]</option>
[% ELSE %]
<option value="[% roadtype.authorised_value %]">[% roadtype.lib %]</option>
<select name="streettype">
<option value=""></option>
[% FOR roadtype IN roadtypes %]
- [% IF roadtype.selected %]
+ [% IF roadtype.authorised_value == streettype%]
<option value="[% roadtype.authorised_value %]" selected="selected">[% roadtype.lib %]</option>
[% ELSE %]
<option value="[% roadtype.authorised_value %]">[% roadtype.lib %]</option>
<select id="searchcategory" name="searchcategory">
<option value="">None</option>
[% FOREACH cat IN searchcategory %]
- [% IF cat.selected %]
+ [% IF cat.authorised_value == itemtype.searchcategory %]
<option value="[% cat.authorised_value %]" selected="selected">
[% cat.lib %]
</option>
<label for="sip_media_type">SIP media type: </label>
<select id="sip_media_type" name="sip_media_type">
<option value=""></option>
- [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE', itemtype.sip_media_type ) %]
- [% IF a.selected %]
+ [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE') %]
+ [% IF a.authorised_value == itemtype.sip_media_type %]
<option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
[% ELSE %]
<option value="[% a.authorised_value %]">[% a.lib %]</option>
<select name="class">
<option value="" />
[% FOREACH class IN classes_val_loop %]
- [% IF ( class.selected ) %]
+ [% IF class.authorised_value == category_class %]
<option value="[% class.authorised_value %]" selected="selected">
[% class.lib %]
</option>
[% IF ( item.itemlost ) %]
[% IF ( item.itemlostloop ) %]
[% FOREACH itemlostloo IN item.itemlostloop %]
- [% IF ( itemlostloo.selected ) %]
+ [% IF itemlostloo.authorised_value == item.itemlost %]
<span class="lost">[% itemlostloo.lib %]</span>
[% END %]
[% END %]
[% IF ( item.damaged ) %]
[% IF ( item.itemdamagedloop ) %]
[% FOREACH itemdamagedloo IN item.itemdamagedloop %]
- [% IF ( itemdamagedloo.selected ) %]
+ [% IF itemdamagedloo.authorised_value == item.damaged %]
<span class="dmg">[% itemdamagedloo.lib %]</span>
[% END %]
[% END %]
<select name="itemlost" >
<option value="">Choose</option>
[% FOREACH itemlostloo IN ITEM_DAT.itemlostloop %]
- [% IF ( itemlostloo.selected ) %]
+ [% IF itemlostloo.authorised_value == ITEM_DAT.itemlost %]
<option value="[% itemlostloo.authorised_value %]" selected="selected">[% itemlostloo.lib %]</option>
[% ELSE %]
<option value="[% itemlostloo.authorised_value %]">[% itemlostloo.lib %]</option>
<select name="damaged" >
<option value="">Choose</option>
[% FOREACH itemdamagedloo IN ITEM_DAT.itemdamagedloop %]
- [% IF ( itemdamagedloo.selected ) %]
+ [% IF itemdamagedloo.authorised_value == ITEM_DAT.damaged %]
<option value="[% itemdamagedloo.authorised_value %]" selected="selected">[% itemdamagedloo.lib %]</option>
[% ELSE %]
<option value="[% itemdamagedloo.authorised_value %]">[% itemdamagedloo.lib %]</option>
<select name="withdrawn" >
<option value="">Choose</option>
[% FOREACH itemwithdrawn IN ITEM_DAT.itemwithdrawnloop %]
- [% IF ( itemwithdrawn.selected ) %]
+ [% IF itemwithdrawn.authorised_value == ITEM_DAT.withdrawn %]
<option value="[% itemwithdrawn.authorised_value %]" selected="selected">[% itemwithdrawn.lib %]</option>
[% ELSE %]
<option value="[% itemwithdrawn.authorised_value %]">[% itemwithdrawn.lib %]</option>
<input type="submit" name="submit" class="submit" value="Set status" /></form>
[% ELSE %]
[% FOREACH itemwithdrawn IN ITEM_DAT.itemwithdrawnloop %]
- [% IF ( itemwithdrawn.selected ) %]
+ [% IF itemwithdrawn.authorised_value == ITEM_DAT.withdrawn %]
[% itemwithdrawn.lib %]
[% END %]
[% END %]
<select id="[% patron_attribute.form_id %]" name="[% patron_attribute.form_id %]">
<option value=""></option>
[% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %]
- [% IF ( auth_val_loo.selected ) %]
+ [% IF auth_val_loo.authorised_value == patron_attribute.value %]
<option value="[% auth_val_loo.authorised_value %]" selected="selected">
[% auth_val_loo.lib %]
</option>
+[% USE AuthorisedValues %]
[% USE Branches %]
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
[% INCLUDE 'serials-toolbar.inc' %]
<h1>Serial collection information for <i>[% bibliotitle %]</i>
- [% IF location %] ([% location %] ) [% END %]
+ [% IF location %] ([% AuthorisedValues.GetByCode( 'LOC', location ) %]) [% END %]
[% IF ( callnumber ) %]callnumber: [% callnumber %][% END %]</h1>
[% END %]
+[% USE AuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Serials › Serial edition [% bibliotitle %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<div class="yui-b">
<h1>Serial edition <i>[% bibliotitle %]</i>
- [% IF location %] ( [% location %] ) [% END %]
+ [% IF location %] ([% AuthorisedValues.GetByCode('LOC', location) %])[% END %]
[% IF ( callnumber ) %] callnumber: [% callnumber %][% END %]</h1>
[% IF internalnotes %]<p>Nonpublic note: [% internalnotes %]</p>[% END %]
<form method="post" name="f" action="serials-edit.pl" id="serials_edit">
[% END %]
</select>
</li>
- [% IF locations %]
- <li>
- <label for="location">Location:</label>
- <select name="location_filter">
- <option value="">All</option>
- [% FOR loc IN locations %]
- [% IF loc.selected %]
- <option value="[% loc.authorised_value %]" selected="selected">[% loc.lib %]</option>
- [% ELSE %]
- <option value="[% loc.authorised_value %]">[% loc.lib %]</option>
- [% END %]
- [% END %]
- </select>
- </li>
- [% END %]
+ <li>
+ <label for="location">Location:</label>
+ [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
+ </li>
<li>
<label for="to">Expires before:</label>
<input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
[% END %]
</select>
</li>
- [% IF locations %]
- <li>
- <label for="location">Location:</label>
- <select name="location_filter">
- <option value="">All</option>
- [% FOR loc IN locations %]
- [% IF loc.selected %]
- <option value="[% loc.authorised_value %]" selected="selected">[% loc.lib %]</option>
- [% ELSE %]
- <option value="[% loc.authorised_value %]">[% loc.lib %]</option>
- [% END %]
- [% END %]
- </select>
- </li>
- [% END %]
+ <li>
+ <label for="location">Location:</label>
+ [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
+ </li>
<li>
<label for="to">Expires before:</label>
<input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
<select name="location" id="location">
<option value="">None</option>
[% FOREACH locations_loo IN locations_loop %]
- [% IF ( locations_loo.selected ) %]
+ [% IF locations_loo.authorised_value == location %]
<option value="[% locations_loo.authorised_value %]" selected="selected">[% locations_loo.lib %]</option>
[% ELSE %]
<option value="[% locations_loo.authorised_value %]">[% locations_loo.lib %]</option>
[% IF ( patron_reason_loop ) %]
<li><span class="label">Reason for suggestion: </span>
[% FOREACH patron_reason_loo IN patron_reason_loop %]
- [% IF ( patron_reason_loo.selected ) %][% patron_reason_loo.lib %][% END %]
+ [% IF patron_reason_loo.authorised_value == patronreason %][% patron_reason_loo.lib %][% END %]
[% END %]
</li>
[% END %]
<li><label for="itemtype">Document type:</label>
[% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, default=itemtype %]
</li>
- [% IF ( patron_reason_loop ) %]<li><label for="patronreason">Reason for suggestion: </label><select name="patronreason" id="patronreason"><option value=""> -- Choose -- </option>[% FOREACH patron_reason_loo IN patron_reason_loop %]
- [% IF ( patron_reason_loo.selected ) %]<option value="[% patron_reason_loo.authorised_value %]" selected="selected">[% patron_reason_loo.lib %]</option>[% ELSE %]<option value="[% patron_reason_loo.authorised_value %]">[% patron_reason_loo.lib %]</option>[% END %]
- [% END %]</select></li>[% END %]
+ [% IF patron_reason_loop %]
+ <li>
+ <label for="patronreason">Reason for suggestion: </label>
+ <select name="patronreason" id="patronreason">
+ <option value=""> -- Choose -- </option>
+ [% FOREACH patron_reason_loo IN patron_reason_loop %]
+ [% IF patron_reason_loo.authorised_value == patronreason %]
+ <option value="[% patron_reason_loo.authorised_value %]" selected="selected">[% patron_reason_loo.lib %]</option>
+ [% ELSE %]
+ <option value="[% patron_reason_loo.authorised_value %]">[% patron_reason_loo.lib %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </li>
+ [% END %]
<li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40">[% note %]</textarea></li>
</ol>
</fieldset>
<label for="ccode">Limit to:</label>
<select name="ccode" id="ccode">
<option value="">All collections</option>
- [% FOREACH ccode IN AuthorisedValues.Get('CCODE', selected_ccode, 1) %]
- [% IF ccode.selected %]
+ [% FOREACH ccode IN AuthorisedValues.Get('CCODE', 1) %]
+ [% IF ccode.authorised_value == selected_ccode %]
<option value="[% ccode.authorised_value %]" selected="selected">
[% ELSE %]
<option value="[% ccode.authorised_value %]">
my $cities = Koha::Cities->search( {}, { order_by => 'city_name' } );
-my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE', $data{streettype} );
+my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE' );
$template->param(
roadtypes => $roadtypes,
cities => $cities,
push @advancedsearchesloop, \%search_code;
} else {
# covers all the other cases: non-itemtype authorized values
- my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
+ my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, 'opac');
my @authvalueloop;
for my $thisitemtype (@$advsearchtypes) {
my $hiding_key = lc $thisitemtype->{category};
$subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
$subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
$subs->{'subscriptionid'} = $subscriptionid; # FIXME - why was this lost ?
- $location = GetAuthorisedValues('LOC', $subs->{'location'});
+ $location = $subs->{'location'};
$callnumber = $subs->{callnumber};
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity});
my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern});
$biblionumber = $subscription->{'bibnum'} unless ($biblionumber);
}
-# warn "title : $title yearmax : $yearmax nombre d'elements dans le tableau :".scalar(@$subscriptions);
-# use Data::Dumper; warn Dumper($subscriptions);
-my $locationlib;
-foreach (@$location) {
- $locationlib = $_->{'lib'} if $_->{'selected'};
-}
-
-
chop $subscriptionidlist;
$template->param(
subscriptionidlist => $subscriptionidlist,
routing => C4::Context->preference("RoutingSerials"),
subscr=>$query->param('subscriptionid'),
subscriptioncount => $subscriptioncount,
- location => $locationlib,
+ location => $location,
callnumber => $callnumber,
uc(C4::Context->preference("marcflavour")) => 1,
serialsadditems => $subscriptiondescs->[0]{'serialsadditems'},
print $query->redirect($redirect);
}
}
-my $location = GetAuthorisedValues('LOC', $serialdatalist[0]->{'location'});
-my $locationlib;
-foreach (@$location) {
- $locationlib = $_->{'lib'} if $_->{'selected'};
-}
+my $location = $serialdatalist[0]->{'location'};
my $default_bib_view = get_default_view();
$template->param(
biblionumber => $serialdatalist[0]->{'biblionumber'},
serialslist => \@serialdatalist,
default_bib_view => $default_bib_view,
- location => $locationlib,
+ location => $location,
(uc(C4::Context->preference("marcflavour"))) => 1
);
publisher_filter => $publisher,
bookseller_filter => $bookseller,
branch_filter => $branch,
- locations => C4::Koha::GetAuthorisedValues('LOC', $location),
+ location_filter => $location,
expiration_date_filter => $expiration_date_dt,
branches_loop => \@branches_loop,
done_searched => $searched,
};
}
-my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
+my $locations_loop = GetAuthorisedValues("LOC");
$template->param(branchloop => $branchloop,
locations_loop=>$locations_loop,
$template->param( returnsuggestedby => $returnsuggestedby );
-my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'});
+my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG");
$template->param(patron_reason_loop=>$patron_reason_loop);
#Budgets management
id => ignore(),
category => 'BUG10656',
authorised_value => 'AAA',
- selected => 0,
lib => 'A_STAFF',
lib_opac => 'Z_PUBLIC',
imageurl => '',
id => ignore(),
category => 'BUG10656',
authorised_value => 'DDD',
- selected => 0,
lib => 'D_STAFF',
lib_opac => undef,
imageurl => '',
id => ignore(),
category => 'BUG10656',
authorised_value => 'ZZZ',
- selected => 0,
lib => 'Z_STAFF',
lib_opac => 'A_PUBLIC',
imageurl => '',
],
'list of authorised values in staff mode sorted by staff label (bug 10656)'
);
- $authvals = GetAuthorisedValues('BUG10656', '', 1);
+ $authvals = GetAuthorisedValues('BUG10656', 1);
cmp_deeply(
$authvals,
[
id => ignore(),
category => 'BUG10656',
authorised_value => 'ZZZ',
- selected => 0,
lib => 'A_PUBLIC',
lib_opac => 'A_PUBLIC',
imageurl => '',
id => ignore(),
category => 'BUG10656',
authorised_value => 'DDD',
- selected => 0,
lib => 'D_STAFF',
lib_opac => undef,
imageurl => '',
id => ignore(),
category => 'BUG10656',
authorised_value => 'AAA',
- selected => 0,
lib => 'Z_PUBLIC',
lib_opac => 'Z_PUBLIC',
imageurl => '',