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

(-)a/Koha/Object/Mixin/AdditionalFields.pm (+43 lines)
Lines 91-96 sub set_additional_fields { Link Here
91
    }
91
    }
92
}
92
}
93
93
94
=head3 get_additional_field_values_for_template
95
96
Returns additional field values in the format expected by the .tt file
97
98
    my $fields =  Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template;
99
100
Expected format is a hash of arrays, where the hash key is the field id and its respective array contains
101
the field values 'value' for that field. Example where field_id = 2 is the only repeatable field:
102
103
{
104
    '3' => ['first value for field 3'],
105
    '1' => ['first value for field 1'],
106
    '4' => ['first value for field 4'],
107
    '2' => [
108
        'first value for field 2',
109
        'second value for field 2',
110
        'third value for field 2'
111
    ]
112
};
113
114
=cut
115
116
sub get_additional_field_values_for_template {
117
    my ($self) = @_;
118
119
    my $additional_field_ids = $self->additional_field_values->search(
120
        {},
121
        {
122
            columns  => ['field_id'],
123
            distinct => 1,
124
        }
125
    );
126
127
    my %fields;
128
    while ( my $additional_field_value = $additional_field_ids->next ) {
129
        my @values = map ( $_->value,
130
            $self->additional_field_values->search( { field_id => $additional_field_value->field_id } )->as_list );
131
        $fields{ $additional_field_value->field_id } = \@values;
132
    }
133
134
    return \%fields;
135
}
136
94
=head3 additional_field_values
137
=head3 additional_field_values
95
138
96
Returns additional field values
139
Returns additional field values
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-display.inc (-8 / +22 lines)
Lines 1-11 Link Here
1
[% USE AuthorisedValues %]
1
[% USE AuthorisedValues %]
2
[% FOR field IN available %]
2
[% FOR field IN available %]
3
    <li>
3
        [% IF is_table_cell %]
4
        <span class="label"> [% field.name | html %]: </span>
4
            <td>
5
        [% IF field.authorised_value_category %]
5
        [% END %]
6
            [% AuthorisedValues.GetByCode( field.authorised_value_category, values.${field.name} ) | html %]
6
        [% SET values_list = [] %]
7
        [% ELSE %]
7
        [% FOR value IN values.${field.id} %]
8
            [% values.${field.name} | html %]
8
            [% IF field.authorised_value_category %]
9
        [% END %]
9
                [% values_list.push(AuthorisedValues.GetByCode( field.authorised_value_category, value )) %]
10
    </li>
10
            [% ELSE %]
11
                [% values_list.push(value) %]
12
            [% END %]
13
        [% END %]
14
        [% IF value_only %]
15
           [% values_list.join(', ') | html %]
16
        [% ELSIF !values_list.empty %]
17
            <li>
18
                <span class="label"> [% field.name | html %]: </span>
19
                [% values_list.join(', ') | html %]
20
            </li>
21
        [% END %]
22
        [% IF is_table_cell %]
23
            </td>
24
        [% END %]
11
[% END %]
25
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc (-38 / +95 lines)
Lines 3-69 Link Here
3
[% USE ClassSources %]
3
[% USE ClassSources %]
4
[% USE ItemTypes %]
4
[% USE ItemTypes %]
5
[% IF wrap_fieldset != 0 %]
5
[% IF wrap_fieldset != 0 %]
6
<fieldset class="rows">
6
<fieldset class="rows" id="additional_fields_form_section">
7
    <legend>Additional fields</legend>
7
    <legend>Additional fields</legend>
8
    <ol>
8
    <ol>
9
[% END %]
9
[% END %]
10
        [% FOR field IN available %]
10
        [% FOR field IN available %]
11
        [% authorised_value_category = field.effective_authorised_value_category %]
11
        [% authorised_value_category = field.effective_authorised_value_category %]
12
            <li>
12
            [% IF authorised_value_category %]
13
                <li>
13
                <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
14
                <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
14
                [% IF authorised_value_category %]
15
                [% IF field.marcfield && field.marcfield_mode == 'get' %]
15
                    [% IF field.marcfield && field.marcfield_mode == 'get' %]
16
                    <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]" class="marcfieldget" disabled>
16
                        <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]" disabled>
17
                [% ELSE %]
17
                    [% ELSE %]
18
                    [% IF !field.repeatable %]
18
                        <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]">
19
                        <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]">
19
                    [% END %]
20
                    [% END %]
21
                [% END %]
22
                    [% IF !field.repeatable %]
20
                        <option value=""></option>
23
                        <option value=""></option>
21
                        [% IF authorised_value_category == 'branches' %]
24
                    [% END %]
22
                            [% FOREACH branch IN Branches.all() %]
25
                    [% IF authorised_value_category == 'branches' %]
23
                                [% IF branch.branchcode == values.${field.id} %]
26
                        [% FOREACH branch IN Branches.all() %]
24
                                    <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option>
27
                            [% IF branch.branchcode == values.${field.id}.0 %]
25
                                [% ELSE %]
28
                                <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option>
26
                                    <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
29
                            [% ELSE %]
27
                                [% END %]
30
                                <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
28
                            [% END %]
31
                            [% END %]
29
                        [% ELSIF authorised_value_category == 'cn_source' %]
32
                        [% END %]
30
                            [% FOREACH class_source IN ClassSources.all({ selected => values.${field.id} }) %]
33
                    [% ELSIF authorised_value_category == 'cn_source' %]
31
                                [% IF class_source.cn_source == values.${field.id} %]
34
                        [% FOREACH class_source IN ClassSources.all({ selected => values.${field.id} }) %]
32
                                    <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %]</option>
35
                            [% IF class_source.cn_source == values.${field.id}.0 %]
33
                                [% ELSE %]
36
                                <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %]</option>
34
                                    <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option>
37
                            [% ELSE %]
35
                                [% END %]
38
                                <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option>
36
                            [% END %]
39
                            [% END %]
37
                        [% ELSIF authorised_value_category == 'itemtypes' %]
40
                        [% END %]
38
                            [% FOREACH itemtype IN ItemTypes.Get() %]
41
                    [% ELSIF authorised_value_category == 'itemtypes' %]
39
                                [% IF itemtype.itemtype == values.${field.id} %]
42
                        [% FOREACH itemtype IN ItemTypes.Get() %]
40
                                    <option value="[% itemtype.itemtype | html %]" selected="selected">[% itemtype.description | html %]</option>
43
                            [% IF itemtype.itemtype == values.${field.id}.0 %]
41
                                [% ELSE %]
44
                                <option value="[% itemtype.itemtype | html %]" selected="selected">[% itemtype.description | html %]</option>
42
                                    <option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option>
45
                            [% ELSE %]
43
                                [% END %]
46
                                <option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option>
44
                            [% END %]
47
                            [% END %]
45
                        [% ELSE %]
48
                        [% END %]
46
                            [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( authorised_value_category ) %]
49
                    [% ELSE %]
47
                                [% IF av.authorised_value == values.${field.id} %]
50
                        [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( authorised_value_category ) %]
51
                            [% IF !field.repeatable %]
52
                                [% IF av.authorised_value == values.${field.id}.0 %]
48
                                    <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
53
                                    <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
49
                                [% ELSE %]
54
                                [% ELSE %]
50
                                    <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
55
                                    <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
51
                                [% END %]
56
                                [% END %]
57
                            [% ELSE %]
58
                                [% SET av_field_value_rendered = 0 %]
59
                                [% FOR value IN values.${field.id} %]
60
                                    [% IF av.authorised_value == value %]
61
                                        <label class="radio">
62
                                            <input type="checkbox" id="additional_field_[% field.id | html %]" checked name="additional_field_[% field.id | html %]" value="[% av.authorised_value | html %]">[% av.lib | html %]
63
                                        </label>
64
                                        [% SET av_field_value_rendered = 1 %]
65
                                    [% END %]
66
                                [% END %]
67
                                [% IF !av_field_value_rendered %]
68
                                    <label class="radio">
69
                                        <input type="checkbox" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" value="[% av.authorised_value | html %]">[% av.lib | html %]
70
                                    </label>
71
                                [% END %]
52
                            [% END %]
72
                            [% END %]
53
                        [% END %]
73
                        [% END %]
54
                    </select> <span>(Authorised values for [% authorised_value_category | html %])</span>
74
                    [% END %]
55
                [% ELSIF field.marcfield && field.marcfield_mode == 'get' %]
75
                </select>
56
                    <input type="text" value="[% values.${field.id} | html %]" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" readonly="readonly" />
76
                [% IF !search_form %]
57
                [% ELSE %]
77
                    <span>(Authorised values for [% authorised_value_category | html %])</span>
58
                    <input type="text" value="[% values.${field.id} | html %]" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" />
78
                    [% IF field.marcfield && field.marcfield_mode == 'get' %]
79
                        This value will be filled with the [% field.marcfield | html %] subfield of the selected bibliographic record.
80
                    [% ELSIF field.marcfield && field.marcfield_mode == 'set' %]
81
                        This value will be saved to the [% field.marcfield | html %] subfield of the selected bibliographic record.
82
                    [% END %]
59
                [% END %]
83
                [% END %]
84
            </li>
60
85
61
                [% IF field.marcfield && field.marcfield_mode == 'get' %]
86
            [% ELSIF field.marcfield && field.marcfield_mode == 'get' %]
87
                <li>
88
                <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
89
                <input type="text" value="[% values.${field.id}.0 | html %]" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" readonly="readonly" />
90
                [% IF !search_form %]
62
                    This value will be filled with the [% field.marcfield | html %] subfield of the selected bibliographic record.
91
                    This value will be filled with the [% field.marcfield | html %] subfield of the selected bibliographic record.
63
                [% ELSIF field.marcfield && field.marcfield_mode == 'set' %]
92
                [% END %]
93
                </li>
94
            [% ELSE %]
95
                [% SET text_field_value_rendered = 0 %]
96
                [% FOR value IN values.${field.id} %]
97
                    <li>
98
                    <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
99
                    <input type="text" value="[% value | html %]" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" />
100
                    [% UNLESS search_form == 1 %]
101
                        <a href="#" class="clear_attribute"><i class="fa fa-fw fa-trash-can"></i> Clear</a>
102
                    [% END %]
103
                    [% IF field.repeatable && !search_form %]
104
                        <a href="#" class="clone_attribute"><i class="fa fa-fw fa-plus"></i> New</a>
105
                    [% END %]
106
                    [% SET text_field_value_rendered = 1 %]
107
                [% END %]
108
                [% IF !text_field_value_rendered %]
109
                    <li>
110
                    <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
111
                    <input type="text" id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]" />
112
                    [% UNLESS search_form == 1 %]
113
                        <a href="#" class="clear_attribute"><i class="fa fa-fw fa-trash-can"></i> Clear</a>
114
                    [% END %]
115
                    [% IF field.repeatable && !search_form %]
116
                        <a href="#" class="clone_attribute"><i class="fa fa-fw fa-plus"></i> New</a>
117
                    [% END %]
118
                [% END %]
119
                [% IF field.marcfield && field.marcfield_mode == 'set' && !search_form %]
64
                    This value will be saved to the [% field.marcfield | html %] subfield of the selected bibliographic record.
120
                    This value will be saved to the [% field.marcfield | html %] subfield of the selected bibliographic record.
65
                [% END %]
121
                [% END %]
66
            </li>
122
                </li>
123
            [% END %]
67
        [% END %]
124
        [% END %]
68
[% IF wrap_fieldset != 0 %]
125
[% IF wrap_fieldset != 0 %]
69
    </ol>
126
    </ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc (-1 / +1 lines)
Lines 31-37 Link Here
31
        <label for="basketgroupname">Basket group:</label>
31
        <label for="basketgroupname">Basket group:</label>
32
        <input type="text" name="basketgroupname" id="basketgroupname" value="[% filters.basketgroupname | html %]" />
32
        <input type="text" name="basketgroupname" id="basketgroupname" value="[% filters.basketgroupname | html %]" />
33
    </li>
33
    </li>
34
        [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_filters wrap_fieldset=0 %]
34
        [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_filters wrap_fieldset=0 search_form=1 %]
35
    <li>
35
    <li>
36
      <label for="ordernumber">Order line:</label>
36
      <label for="ordernumber">Order line:</label>
37
      <input type="text" name="ordernumber" id="ordernumber" value="[% filters.ordernumber | html %]" />
37
      <input type="text" name="ordernumber" id="ordernumber" value="[% filters.ordernumber | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-1 / +1 lines)
Lines 210-216 Link Here
210
            <fieldset class="rows">
210
            <fieldset class="rows">
211
                <legend>Search orders</legend>
211
                <legend>Search orders</legend>
212
        [% END %]
212
        [% END %]
213
            [% INCLUDE 'filter-orders.inc' %]
213
            [% INCLUDE 'filter-orders.inc' search_form=1 %]
214
            <input type="hidden" name="do_search" value="1" />
214
            <input type="hidden" name="do_search" value="1" />
215
        </fieldset>
215
        </fieldset>
216
        <fieldset class="action">
216
        <fieldset class="action">
(-)a/koha-tmpl/intranet-tmpl/prog/js/additional-fields-entry.js (-1 / +28 lines)
Line 0 Link Here
0
- 
1
$(document).ready(function() {
2
    $("#additional_fields_form_section").on("click", ".clone_attribute", function(e){
3
        e.preventDefault();
4
        clone_entry( this );
5
    });
6
7
    $("#additional_fields_form_section").on("click", ".clear_attribute", function(e){
8
        e.preventDefault();
9
        clear_entry( this );
10
    });
11
12
    $('#additional_fields_form_section').parents('form ').submit(function() {
13
        $('.marcfieldget').prop("disabled", false);
14
        return true;
15
    });
16
});
17
18
function clone_entry(node) {
19
    var original = $(node).parent();
20
    var clone = $(node).parent().clone();
21
    $(original).after(clone);
22
    return false;
23
}
24
25
function clear_entry(node) {
26
    var original = $(node).parent();
27
    $("input", original).val('');
28
}

Return to bug 35044