@@ -, +, @@ suggestions ----------- - Set SupportsAuthorizedValues with itemtypes or loc or ccode - Get to suggestion form (OPAC or intranet) - Look at "Document type" combobox, it must contains descriptions of selected authorized values - Save the suggestion - Get to intranet suggestions management - Organize suggestions by document type --- C4/Koha.pm | 83 +++++++++----------- .../prog/en/modules/suggestion/suggestion.tt | 10 +-- .../bootstrap/en/modules/opac-suggestions.tt | 12 +-- opac/opac-suggestions.pl | 2 +- suggestion/suggestion.pl | 8 +- 5 files changed, 55 insertions(+), 60 deletions(-) --- a/C4/Koha.pm +++ a/C4/Koha.pm @@ -27,6 +27,7 @@ use C4::Context; use C4::Branch qw(GetBranchesCount); use Koha::Cache; use Koha::DateUtils qw(dt_from_string); +use C4::ItemType; use DateTime::Format::MySQL; use Business::ISBN; use autouse 'Data::cselectall_arrayref' => qw(Dumper); @@ -130,77 +131,71 @@ sub subfield_is_koha_internal_p { =head2 GetSupportName - $itemtypename = &GetSupportName($codestring); + $lib = &GetSupportName($authorised_value); -Returns a string with the name of the itemtype. +Returns the name of the support corresponding to specified authorised value. =cut -sub GetSupportName{ - my ($codestring)=@_; - return if (! $codestring); - my $resultstring; - my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); - if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { - my $query = qq| - SELECT description - FROM itemtypes - WHERE itemtype=? - order by description - |; - my $sth = C4::Context->dbh->prepare($query); - $sth->execute($codestring); - ($resultstring)=$sth->fetchrow; - return $resultstring; - } else { - my $sth = - C4::Context->dbh->prepare( - "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?" - ); - $sth->execute( $advanced_search_types, $codestring ); - my $data = $sth->fetchrow_hashref; - return $$data{'lib'}; - } - +sub GetSupportName { + my $authorised_value = shift; + return '' unless $authorised_value; + my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; + if ( $supports_av eq 'itemtypes' ) { + my $itemtype = getitemtypeinfo($authorised_value); + return $itemtype->{'description'} if $itemtype; + } + else { + my $lib = GetKohaAuthorisedValueLib( $supports_av, $authorised_value ); + return $lib if $lib; + } + return ''; } + =head2 GetSupportList - $itemtypes = &GetSupportList(); + $supports = &GetSupportList(); -Returns an array ref containing informations about Support (since itemtype is rather a circulation code when item-level-itypes is used). +Returns an array ref containing informations about support : authorised_value, lib, imageurl build a HTML select with the following code : =head3 in PERL SCRIPT - my $itemtypes = GetSupportList(); - $template->param(itemtypeloop => $itemtypes); + my $supports = GetSupportList(); + $template->param(supportsloop => $supports); =head3 in TEMPLATE =cut -sub GetSupportList{ - my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); - if (!$advanced_search_types or $advanced_search_types =~ /itemtypes/) { - return GetItemTypes( style => 'array' ); - } else { - my $advsearchtypes = GetAuthorisedValues($advanced_search_types); - my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes; - return \@results; - } +sub GetSupportList { + my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; + if ( $supports_av eq 'itemtypes' ) { + my @supports = map { + { + authorised_value => $_->{'itemtype'}, + lib => $_->{'description'}, + imageurl => $_->{'imageurl'} + } + } C4::ItemType->all; + return \@supports; + } + else { + return GetAuthorisedValues($supports_av); + } } + =head2 GetItemTypes $itemtypes = &GetItemTypes( style => $style ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -213,8 +213,8 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
  • Publication place:[% place |html %]
  • Collection title:[% collectiontitle |html %]
  • Document type: - [% FOREACH itemtypeloo IN itemtypeloop %] - [% IF ( itemtypeloo.selected ) %][% itemtypeloo.translated_description %][% END %] + [% FOREACH supports_loo IN supports_loop %] + [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %] [% END %]
  • [% IF ( patron_reason_loop ) %] @@ -337,9 +337,9 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
  • --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -42,16 +42,16 @@
  • -
  • +
  • --- a/opac/opac-suggestions.pl +++ a/opac/opac-suggestions.pl @@ -189,7 +189,7 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { $template->param( %$suggestion, - itemtypeloop=> $supportlist, + supports_loop => $supportlist, suggestions_loop => $suggestions_loop, patron_reason_loop => $patron_reason_loop, "op_$op" => 1, --- a/suggestion/suggestion.pl +++ a/suggestion/suggestion.pl @@ -328,16 +328,16 @@ $template->param( branchloop => \@branchloop, my $supportlist = GetSupportList(); foreach my $support (@$supportlist) { - $$support{'selected'} = (defined $$suggestion_ref{'itemtype'}) - ? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'} - : 0; + if ( defined $$suggestion_ref{'itemtype'} && $support->{'authorised_value'} eq $$suggestion_ref{'itemtype'}) { + $$support{'selected'} = 1; + } if ( $$support{'imageurl'} ) { $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} ); } else { delete $$support{'imageurl'}; } } -$template->param(itemtypeloop=>$supportlist); +$template->param( supports_loop => $supportlist); $template->param( returnsuggestedby => $returnsuggestedby ); my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'}); --