@@ -, +, @@ GetAuthorisedValues to the templates # 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. - Edit an itemtype and check the value of the "Search category" dropdown list - Edit a patron attribute type and check the value of the "Class" dropdown list - Detail for a catalogue record, the Status column should be correctly populated if items are damaged and/or lost - Item details for a catalogue record, the lost, damaged and withdrawn value should be correctly displayed - Edit a patron, the "street type" should be correctly selected - Create a patron attribute type linked to an authorised value list. - Edit a patron, set a value for this attribute, edit it again. The correct value should be selected. - Search for subscriptions. The 'Location' dropdown list should behave correctly (select the entry you have choosen before, etc.) - Edit a subscription, the location dropdown list should select the correct value. - Edit and view a suggestion with a 'reason for suggestion' set (you should have at least 1 OPAC_SUG AV defined) --- C4/Koha.pm | 26 ++------------- Koha/Template/Plugin/AuthorisedValues.pm | 4 +-- admin/itemtypes.pl | 2 +- admin/patron-attr-types.pl | 18 ++++------ catalogue/detail.pl | 4 +-- catalogue/moredetail.pl | 6 ++-- .../prog/en/includes/av-build-dropbox.inc | 2 ++ .../en/includes/member-main-address-style-de.inc | 2 +- .../en/includes/member-main-address-style-us.inc | 2 +- .../prog/en/modules/admin/itemtypes.tt | 6 ++-- .../prog/en/modules/admin/patron-attr-types.tt | 2 +- .../prog/en/modules/catalogue/detail.tt | 4 +-- .../prog/en/modules/catalogue/moredetail.tt | 8 ++--- .../prog/en/modules/members/memberentrygen.tt | 2 +- .../prog/en/modules/serials/serials-collection.tt | 3 +- .../prog/en/modules/serials/serials-edit.tt | 3 +- .../prog/en/modules/serials/serials-search.tt | 38 +++++----------------- .../prog/en/modules/serials/subscription-add.tt | 2 +- .../prog/en/modules/suggestion/suggestion.tt | 20 +++++++++--- .../bootstrap/en/includes/opac-topissues.inc | 4 +-- members/memberentry.pl | 2 +- opac/opac-search.pl | 2 +- serials/serials-collection.pl | 12 ++----- serials/serials-edit.pl | 8 ++--- serials/serials-search.pl | 2 +- serials/subscription-add.pl | 2 +- suggestion/suggestion.pl | 2 +- t/db_dependent/Koha.t | 8 +---- 28 files changed, 74 insertions(+), 122 deletions(-) --- a/C4/Koha.pm +++ a/C4/Koha.pm @@ -998,35 +998,25 @@ sub GetAuthValCodeFromField { =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 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; @@ -1063,13 +1053,6 @@ sub GetAuthorisedValues { $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}; } @@ -1077,9 +1060,6 @@ sub GetAuthorisedValues { } $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; } --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ a/Koha/Template/Plugin/AuthorisedValues.pm @@ -29,8 +29,8 @@ sub GetByCode { } sub Get { - my ( $self, $category, $selected, $opac ) = @_; - return GetAuthorisedValues( $category, $selected, $opac ); + my ( $self, $category, $opac ) = @_; + return GetAuthorisedValues( $category, $opac ); } sub GetAuthValueDropbox { --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -59,7 +59,7 @@ undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$ 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, --- a/admin/patron-attr-types.pl +++ a/admin/patron-attr-types.pl @@ -99,7 +99,7 @@ sub add_attribute_type_form { 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 { @@ -255,7 +255,7 @@ sub edit_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; @@ -271,8 +271,11 @@ sub edit_attribute_type_form { } $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, @@ -325,10 +328,3 @@ sub authorised_value_category_list { } $template->param(authorised_value_categories => \@list); } - -sub pa_classes { - my $template = shift; - my $selected = @_ ? shift : ''; - - $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS', $selected ) ); -} --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -218,9 +218,9 @@ foreach my $item (@items) { $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 --- a/catalogue/moredetail.pl +++ a/catalogue/moredetail.pl @@ -137,9 +137,9 @@ foreach ( keys %{$data} ) { ($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'} ); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc @@ -6,6 +6,7 @@ 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 ) %] @@ -16,6 +17,7 @@ [% IF avs %] [% FOR roadtype IN roadtypes %] - [% IF roadtype.selected %] + [% IF roadtype.authorised_value == streettype %] [% ELSE %] --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc @@ -24,7 +24,7 @@ [% FOREACH cat IN searchcategory %] - [% IF cat.selected %] + [% IF cat.authorised_value == itemtype.searchcategory %] @@ -278,8 +278,8 @@ Item types administration --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -650,7 +650,7 @@ function verify_images() { [% IF ( item.itemlost ) %] [% IF ( item.itemlostloop ) %] [% FOREACH itemlostloo IN item.itemlostloop %] - [% IF ( itemlostloo.selected ) %] + [% IF itemlostloo.authorised_value == item.itemlost %] [% itemlostloo.lib %] [% END %] [% END %] @@ -666,7 +666,7 @@ function verify_images() { [% IF ( item.damaged ) %] [% IF ( item.itemdamagedloop ) %] [% FOREACH itemdamagedloo IN item.itemdamagedloop %] - [% IF ( itemdamagedloo.selected ) %] + [% IF itemdamagedloo.authorised_value == item.damaged %] [% itemdamagedloo.lib %] [% END %] [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -109,7 +109,7 @@ [% FOREACH itemdamagedloo IN ITEM_DAT.itemdamagedloop %] - [% IF ( itemdamagedloo.selected ) %] + [% IF itemdamagedloo.authorised_value == ITEM_DAT.damaged %] [% ELSE %] @@ -173,7 +173,7 @@ [% ELSE %] [% FOREACH itemwithdrawn IN ITEM_DAT.itemwithdrawnloop %] - [% IF ( itemwithdrawn.selected ) %] + [% IF itemwithdrawn.authorised_value == ITEM_DAT.withdrawn %] [% itemwithdrawn.lib %] [% END %] [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1046,7 +1046,7 @@ function select_user(borrowernumber, borrower) { - [% IF locations %] -
  • - - -
  • - [% END %] +
  • + + [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %] +
  • @@ -418,21 +407,10 @@ [% END %]
  • - [% IF locations %] -
  • - - -
  • - [% END %] +
  • + + [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %] +
  • --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -600,7 +600,7 @@ $(document).ready(function() { [% FOREACH patron_reason_loo IN patron_reason_loop %] - [% IF ( patron_reason_loo.selected ) %][% ELSE %][% END %] - [% END %]
  • [% END %] + [% IF patron_reason_loop %] +
  • + + +
  • + [% END %]
  • --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-topissues.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-topissues.inc @@ -53,8 +53,8 @@