View | Details | Raw Unified | Return to bug 766
Collapse All | Expand All

(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-22 / +3 lines)
Lines 44-71 sub GetByCode { Link Here
44
    return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
44
    return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
45
}
45
}
46
46
47
sub BuildDropbox {
47
sub GetAuthValueDropbox {
48
    my ( $self, $name, $category, $default, $params ) = @_;
48
    my ( $self, $category, $default ) = @_;
49
    my $class = $params->{class};
49
    return C4::Koha::GetAuthvalueDropbox($category, $default);
50
    my $avs = C4::Koha::GetAuthvalueDropbox($category, $default);
51
    my $size = $params->{size} || 20;
52
    my $html;
53
    if ( @$avs ) {
54
        $html = qq|<select id="$name" name="$name" class="$class" >|;
55
        for my $av ( @$avs ) {
56
            if ( $av->{default} ) {
57
                $html .= qq|<option value="$av->{value}" selected="selected">$av->{label}</option>|;
58
            } else {
59
                $html .= qq|<option value="$av->{value}">$av->{label}</option>|;
60
            }
61
        }
62
        $html .= q|</select>|;
63
    } else {
64
        $html .= qq|<input type="text" id="$name" name="$name" size="$size" value="$default" class="$class" />|;
65
66
    }
67
68
    return encode( 'UTF-8', $html );
69
}
50
}
70
51
71
1;
52
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc (+29 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[%#
3
    Parameters:
4
    name: tthe name of the select element
5
    category: the authorised value category
6
    default: the default authorised value to select
7
    class: the css class of the select element
8
    size: the size to use for the input (generated if not authorised value category exist).
9
%]
10
11
[% SET avs = AuthorisedValues.GetAuthValueDropbox( category, default ) %]
12
[% DEFAULT
13
    class = ''
14
    size = 20
15
%]
16
17
[% IF avs %]
18
  <select id="[% name %]" name="[% name %]" class="[% class %]" >
19
  [% FOR av IN avs %]
20
    [% IF av.default %]
21
      <option value="[% av.value %]" selected="selected">[% av.label %]</option>
22
    [% ELSE %]
23
      <option value="[% av.value %]">[% av.label %]</option>
24
    [% END %]
25
  [% END %]
26
  </select>
27
[% ELSE %]
28
  <input type="text" id="[% name %]" name="[% name %]" size="[% size %]" value="[% default %]" class="[% class %]" />
29
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-4 / +2 lines)
Lines 1-4 Link Here
1
[% USE AuthorisedValues %]
2
[% IF ( opduplicate ) %][% SET focusAction = "clearDupe" %][% END %]
1
[% IF ( opduplicate ) %][% SET focusAction = "clearDupe" %][% END %]
3
[% USE KohaDates %]
2
[% USE KohaDates %]
4
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
Lines 959-965 Link Here
959
        <label for="sort1">
958
        <label for="sort1">
960
      [% END %]
959
      [% END %]
961
      Sort 1: </label>
960
      Sort 1: </label>
962
      [% AuthorisedValues.BuildDropbox("sort1", "Bsort1", sort1, { class => focusAction, size => 20 } ) %]
961
      [% PROCESS 'av-build-dropbox.inc' name="sort1", category="Bsort1", default=sort1, class=focusAction, size = 20 %]
963
      [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %]
962
      [% IF ( mandatorysort1 ) %]<span class="required">Required</span>[% END %]
964
    </li>
963
    </li>
965
        [% END %]
964
        [% END %]
Lines 971-977 Link Here
971
    <label for="sort2">
970
    <label for="sort2">
972
    [% END %]
971
    [% END %]
973
    Sort 2: </label>
972
    Sort 2: </label>
974
    [% AuthorisedValues.BuildDropbox("sort2", "Bsort2", sort2, { class => focusAction, size => 20 } ) %]
973
    [% PROCESS 'av-build-dropbox.inc' name="sort2", category="Bsort2", default=sort2, class=focusAction, size = 20 %]
975
    [% IF ( mandatorysort2 ) %]<span class="required">Required</span>[% END %]
974
    [% IF ( mandatorysort2 ) %]<span class="required">Required</span>[% END %]
976
    </li>
975
    </li>
977
        [% END %]
976
        [% END %]
978
- 

Return to bug 766