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 83-93 Link Here
83
                    <legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend>
83
                    <legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend>
84
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
84
                    <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
85
                    <div class="age">
85
                    <div class="age">
86
                      <h5>Age in days</h5>
86
                      <h5>Age</h5>
87
                      <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
87
                      <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
88
                      <h5>Age unit</h5>
89
                      <div class="block">
90
                          <select name="ageunit_[% id | html %]">
91
                              <option value="">Choose an age unit</option>
92
                              [% FOR unit IN ageunits %]
93
                                  [% IF rule.ageunit == unit %]
94
                                      <option value="[% unit | html %]" selected="selected">[% unit | html %]</option>
95
                                  [% ELSE %]
96
                                      <option value="[% unit | html %]">[% unit | html %]</option>
97
                                  [% END %]
98
                              [% END %]
99
                          </select>
100
                          <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>
101
                      </div>
102
88
                      <h5>Age field</h5>
103
                      <h5>Age field</h5>
89
                          <div class="blocks">
104
                          <div class="blocks">
90
                              <select name="agefield_[% id | html %]">
105
                              <select name="agefield_[% id | html %]" onchange="unit_display()">
91
                                  <option value="">Choose an age field</option>
106
                                  <option value="">Choose an age field</option>
92
                                  [% FOR field IN agefields %]
107
                                  [% FOR field IN agefields %]
93
                                    [% IF rule.agefield == field %]
108
                                    [% IF rule.agefield == field %]
Lines 158-168 Link Here
158
            <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend>
173
            <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend>
159
            <input type="hidden" name="unique_id" />
174
            <input type="hidden" name="unique_id" />
160
            <div class="age">
175
            <div class="age">
161
              <h5>Age in days</h5>
176
              <h5>Age</h5>
162
              <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
177
              <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
178
              <h5>Age unit</h5>
179
              <div class="block">
180
                  <select name="ageunit">
181
                      <option value="">Choose an age unit</option>
182
                      [% FOR unit IN ageunits %]
183
                          <option value="[% unit | html %]">[% unit | html %]</option>
184
                      [% END %]
185
                  </select>
186
                  <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>
187
              </div>
163
              <h5>Age field</h5>
188
              <h5>Age field</h5>
164
              <div class="block">
189
              <div class="block">
165
                  <select name="agefield">
190
                  <select name="agefield" onchange="unit_display()">
166
                      <option value="">Choose an age field</option>
191
                      <option value="">Choose an age field</option>
167
                      [% FOR field IN agefields %]
192
                      [% FOR field IN agefields %]
168
                           <option value="[% field | html %]">[% field | html %]</option>
193
                           <option value="[% field | html %]">[% field | html %]</option>
Lines 212-217 Link Here
212
                        <thead>
237
                        <thead>
213
                          <tr>
238
                          <tr>
214
                               <th>Age</th>
239
                               <th>Age</th>
240
                                <th>Age unit</th>
215
                                <th>Age field</th>
241
                                <th>Age field</th>
216
                                <th>Conditions</th>
242
                                <th>Conditions</th>
217
                                <th>Substitutions</th>
243
                                <th>Substitutions</th>
Lines 222-232 Link Here
222
                                <tr>
248
                                <tr>
223
                                    <td>
249
                                    <td>
224
                                        [% IF rule.age.defined and rule.age.length > 0 %]
250
                                        [% IF rule.age.defined and rule.age.length > 0 %]
225
                                            <span>[% rule.age | html %] days</span>
251
                                            <span>[% rule.age | html %]</span>
226
                                        [% ELSE %]
252
                                        [% ELSE %]
227
                                            <span>There is no age for this rule.</span>
253
                                            <span>There is no age for this rule.</span>
228
                                        [% END %]
254
                                        [% END %]
229
                                    </td>
255
                                    </td>
256
                                    <td>
257
                                        [% IF rule.ageunit %]
258
                                            [% rule.ageunit | html %]
259
                                        [% ELSE %]
260
                                            <!-- In case old rules do not contain an ageunit value display that 'Days' will be used -->
261
                                            Days
262
                                        [% END %]
263
                                    </td>
230
                                    <td>
264
                                    <td>
231
                                        [% IF rule.agefield %]
265
                                        [% IF rule.agefield %]
232
                                            [% rule.agefield | html %]
266
                                            [% rule.agefield | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js (-1 / +25 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 75-86 $(document).ready(function() { Link Here
75
        new_rule.find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id);
98
        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);
99
        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);
100
        new_rule.find("input[name='age']").attr('name', 'age_' + unique_id);
101
        new_rule.find("select[name='ageunit']").attr('name', 'ageunit_' + unique_id);
78
        new_rule.find("select[name='agefield']").attr('name', 'agefield_' + unique_id);
102
        new_rule.find("select[name='agefield']").attr('name', 'agefield_' + unique_id);
79
        new_rule.find("input[name='unique_id']").val(unique_id);
103
        new_rule.find("input[name='unique_id']").val(unique_id);
80
104
81
        $("#rules").append(new_rule);
105
        $("#rules").append(new_rule);
82
        update_rule_count();
106
        update_rule_count();
83
        var scrollToPoint = new_rule.position();
107
        var scrollToPoint = new_rule.position();
108
        unit_display();
84
        window.scroll(0, scrollToPoint.top - $("#toolbar").height() );
109
        window.scroll(0, scrollToPoint.top - $("#toolbar").height() );
85
110
86
        if( $("#rules").find(".rule").length > 0 ) {
111
        if( $("#rules").find(".rule").length > 0 ) {
87
- 

Return to bug 21173