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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt (-5 / +39 lines)
Lines 89-99 Link Here
89
                    <legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
89
                    <legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
90
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
90
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
91
                    <div class="age">
91
                    <div class="age">
92
                      <h5>Age in days</h5>
92
                      <h5>Age</h5>
93
                      <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
93
                      <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
94
                      <h5>Age unit</h5>
95
                      <div class="block">
96
                          <select name="ageunit_[% id | html %]">
97
                              <option value="">Choose an age unit</option>
98
                              [% FOR unit IN ageunits %]
99
                                  [% IF rule.ageunit == unit %]
100
                                      <option value="[% unit | html %]" selected="selected">[% unit | html %]</option>
101
                                  [% ELSE %]
102
                                      <option value="[% unit | html %]">[% unit | html %]</option>
103
                                  [% END %]
104
                              [% END %]
105
                          </select>
106
                          <span class="hint">Only the items.damaged_on, items.itemlost_on and items.withdrawn_on age fields can use the 'Hours unit. If not set then days will be used.</span>
107
                      </div>
108
94
                      <h5>Age field</h5>
109
                      <h5>Age field</h5>
95
                          <div class="blocks">
110
                          <div class="blocks">
96
                              <select name="agefield_[% id | html %]">
111
                              <select name="agefield_[% id | html %]" onchange="unit_display()">
97
                                  <option value="">Choose an age field</option>
112
                                  <option value="">Choose an age field</option>
98
                                  [% FOR field IN agefields %]
113
                                  [% FOR field IN agefields %]
99
                                    [% IF rule.agefield == field %]
114
                                    [% IF rule.agefield == field %]
Lines 164-174 Link Here
164
            <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
179
            <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
165
            <input type="hidden" name="unique_id" />
180
            <input type="hidden" name="unique_id" />
166
            <div class="age">
181
            <div class="age">
167
              <h5>Age in days</h5>
182
              <h5>Age</h5>
168
              <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
183
              <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
184
              <h5>Age unit</h5>
185
              <div class="block">
186
                  <select name="ageunit">
187
                      <option value="">Choose an age unit</option>
188
                      [% FOR unit IN ageunits %]
189
                          <option value="[% unit | html %]">[% unit | html %]</option>
190
                      [% END %]
191
                  </select>
192
                  <span class="hint">Only items.damaged_on, items.itemlost_on and items.withdrawn_on age fields can use the 'Hours' unit. If not set then days will be used.</span>
193
              </div>
169
              <h5>Age field</h5>
194
              <h5>Age field</h5>
170
              <div class="block">
195
              <div class="block">
171
                  <select name="agefield">
196
                  <select name="agefield" onchange="unit_display()">
172
                      <option value="">Choose an age field</option>
197
                      <option value="">Choose an age field</option>
173
                      [% FOR field IN agefields %]
198
                      [% FOR field IN agefields %]
174
                           <option value="[% field | html %]">[% field | html %]</option>
199
                           <option value="[% field | html %]">[% field | html %]</option>
Lines 216-221 Link Here
216
                        <thead>
241
                        <thead>
217
                          <tr>
242
                          <tr>
218
                               <th>Age</th>
243
                               <th>Age</th>
244
                                <th>Age unit</th>
219
                                <th>Age field</th>
245
                                <th>Age field</th>
220
                                <th>Conditions</th>
246
                                <th>Conditions</th>
221
                                <th>Substitutions</th>
247
                                <th>Substitutions</th>
Lines 226-236 Link Here
226
                                <tr>
252
                                <tr>
227
                                    <td>
253
                                    <td>
228
                                        [% IF rule.age.defined and rule.age.length > 0 %]
254
                                        [% IF rule.age.defined and rule.age.length > 0 %]
229
                                            <span>[% rule.age | html %] days</span>
255
                                            <span>[% rule.age | html %]</span>
230
                                        [% ELSE %]
256
                                        [% ELSE %]
231
                                            <span>There is no age for this rule.</span>
257
                                            <span>There is no age for this rule.</span>
232
                                        [% END %]
258
                                        [% END %]
233
                                    </td>
259
                                    </td>
260
                                    <td>
261
                                        [% IF rule.ageunit %]
262
                                            [% rule.ageunit | html %]
263
                                        [% ELSE %]
264
                                            <!-- In case old rules do not contain an ageunit value display that 'Days' will be used -->
265
                                            Days
266
                                        [% END %]
267
                                    </td>
234
                                    <td>
268
                                    <td>
235
                                        [% IF rule.agefield %]
269
                                        [% IF rule.agefield %]
236
                                            [% rule.agefield | html %]
270
                                            [% rule.agefield | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js (-1 / +26 lines)
Lines 49-57 function update_rule_count(){ Link Here
49
    });
49
    });
50
}
50
}
51
51
52
function unit_display(){
53
    var rules = document.querySelectorAll("input[name='unique_id'");
54
    for (var i = 0; i < rules.length; i++) {
55
        var rule_id = rules[i].value;
56
        if (rule_id) {
57
            var age_field = $("select[name='agefield_" + rule_id + "']").val();
58
            if ( age_field == 'items.damaged_on'
59
                || age_field == 'items.itemlost_on'
60
                || age_field == 'items.withdrawn_on' )
61
            {
62
                $("select[name='ageunit_" + rule_id + "'] option[value='Days']").removeAttr('selected');
63
64
                $("select[name='ageunit_" + rule_id + "']").attr("disabled", false);
65
            } else {
66
                $("select[name='ageunit_" + rule_id + "'] option[value='Days']").attr('selected','selected');
67
                $("select[name='ageunit_" + rule_id + "']").attr("disabled", true);
68
            }
69
        }
70
    }
71
}
72
73
52
$(document).ready(function() {
74
$(document).ready(function() {
53
    $("#new_rule .remove_rule").hide();
75
    $("#new_rule .remove_rule").hide();
54
    $("#new_rule a.remove_block").hide();
76
    $("#new_rule a.remove_block").hide();
77
    unit_display();
55
    $("#rules a.remove_block").click(function(e){
78
    $("#rules a.remove_block").click(function(e){
56
        e.preventDefault();
79
        e.preventDefault();
57
        remove_block_action($(this));
80
        remove_block_action($(this));
Lines 62-67 $(document).ready(function() { Link Here
62
    });
85
    });
63
86
64
    var unique_id = $(".rule").length + 1;
87
    var unique_id = $(".rule").length + 1;
88
    var previous_id = unique_id - 1;
65
    $(".add_rule").click(function(e){
89
    $(".add_rule").click(function(e){
66
        e.preventDefault();
90
        e.preventDefault();
67
        var rule = $("#new_rule");
91
        var rule = $("#new_rule");
Lines 75-86 $(document).ready(function() { Link Here
75
        new_rule.find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id);
99
        new_rule.find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id);
76
        new_rule.find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id);
100
        new_rule.find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id);
77
        new_rule.find("input[name='age']").attr('name', 'age_' + unique_id);
101
        new_rule.find("input[name='age']").attr('name', 'age_' + unique_id);
102
        new_rule.find("select[name='ageunit']").attr('name', 'ageunit_' + unique_id);
78
        new_rule.find("select[name='agefield']").attr('name', 'agefield_' + unique_id);
103
        new_rule.find("select[name='agefield']").attr('name', 'agefield_' + unique_id);
79
        new_rule.find("input[name='unique_id']").val(unique_id);
104
        new_rule.find("input[name='unique_id']").val(unique_id);
80
105
81
        $("#rules").append(new_rule);
106
        $("#rules").append(new_rule);
82
        update_rule_count();
107
        update_rule_count();
83
        var scrollToPoint = new_rule.position();
108
        var scrollToPoint = new_rule.position();
109
        unit_display();
84
        window.scroll(0, scrollToPoint.top - $("#toolbar").height() );
110
        window.scroll(0, scrollToPoint.top - $("#toolbar").height() );
85
111
86
        if( $("#rules").find(".rule").length > 0 ) {
112
        if( $("#rules").find(".rule").length > 0 ) {
87
- 

Return to bug 21173