Bug 16021 - Use Font Awesome icons on automatic item modifications by age page
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / automatic_item_modification_by_age.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Tools &rsaquo; Automatic item modifications by age</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript">//<![CDATA[
5   function clear_inputs(node, new_node) {
6     var selects = $(node).find("select");
7     $(selects).each(function(i) {
8       var select = this;
9       $(new_node).find("select").eq(i).val($(select).val());
10     });
11     var inputs = $(node).find("input");
12     $(inputs).each(function(i) {
13       var input = this;
14       $(new_node).find("input").eq(i).val($(input).val());
15     });
16   }
17
18   function remove_block_action( link ) {
19     var blocks = $(link).parent().parent();
20     if( $(blocks).find(".block").length > 2 ) {
21       $(blocks).find("a.remove_block").show();
22     } else {
23       $(blocks).find("a.remove_block").hide();
24     }
25     $(link).parent().remove();
26   }
27
28   function remove_rule_action( link ) {
29     if( $("#rules").find("div.rule").length < 2 ) {
30         $("#rules").hide();
31         $("#norules").show();
32     }
33     $(link).parent().remove();
34   }
35
36   function clone_block(block) {
37     var new_block = $(block).clone(1);
38     clear_inputs(block, new_block);
39     $(new_block).find('a.remove_block').show();
40     var blocks = $(block).parent();
41     $(blocks).append(new_block);
42     $(blocks).find('a.remove_block').click(function(){
43       remove_block_action($(this));
44     }).show();
45   }
46
47   $(document).ready(function() {
48     $("#new_rule a.remove_rule").hide();
49     $("#new_rule a.remove_block").hide();
50     $("#rules a.remove_block").click(function(){
51       remove_block_action($(this));
52     });
53     $("#rules a.remove_rule").click(function(){
54       remove_rule_action($(this));
55     });
56
57     var unique_id = $("div.rule").length + 1;
58     $("a.add_rule").click(function(){
59       var rule = $("#new_rule");
60       var new_rule = $(rule).clone(1);
61       $(new_rule).removeAttr('id');
62       $(new_rule).attr('class', 'rule');
63       clear_inputs(rule, new_rule);
64       $(new_rule).find("select[name='condition_field']").attr('name', 'condition_field_' + unique_id);
65       $(new_rule).find("select[name='substitution_field']").attr('name', 'substitution_field_' + unique_id);
66       $(new_rule).find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id);
67       $(new_rule).find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id);
68       $(new_rule).find("input[name='age']").attr('name', 'age_' + unique_id);
69       $(new_rule).find("input[name='unique_id']").val(unique_id);
70
71       $("#rules").append(new_rule);
72
73       if( $("#rules").find("div.rule").length > 0 ) {
74           $("#rules").show();
75           $("#norules").hide();
76       }
77       if( $("#rules").find(".conditions > .condition").length > 1 ) {
78
79       }
80       if( $("#rules").find(".conditions > .condition").length > 1 ) {
81
82       }
83       $(new_rule).find('a.remove_rule').click(function(){
84         remove_rule_action( $(this) );
85       }).show();
86       $(new_rule).find('a.add_rule').remove();
87       unique_id++;
88     });
89
90     $("a.add_block").click(function(){
91       clone_block( $(this).parent() );
92     });
93
94     if( $("#rules").find("div.rule").length < 1 ) {
95         $("#rules").hide();
96         $("#norules").show();
97     }
98
99     $("#rules .rule .blocks").each(function(){
100       if ( $(this).find(".block").length == 1 ) {
101         $(this).find("a.remove_block").hide();
102       }
103     });
104
105     [% IF op == 'edit_form' %]
106       [% IF rules.size > 0 %]
107         $("#norules").hide();
108       [% ELSE %]
109         $("#rules").show();
110       [% END %]
111     [% END %]
112   });
113 //]]>
114 </script>
115 </head>
116 <body id="tools_automatic_item_modification_by_age" class="tools">
117 [% INCLUDE 'header.inc' %]
118 [% INCLUDE 'cat-search.inc' %]
119 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Automatic item modifications by age</a></div>
120
121 <div id="doc3" class="yui-t2">
122   <div id="bd">
123     <div id="yui-main">
124       <div class="yui-b">
125         <h3>Automatic item modifications by age</h3>
126         <div id="toolbar" class="btn-toolbar">
127           <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl?op=edit_form"><i class="fa fa-pencil"></i> Edit</a>
128         </div>
129         [% FOR message IN messages %]
130           [% IF message.type == "error" %]
131             <div class="dialog error">
132           [% END %]
133           [% IF message.code == "unable_to_load_configuration" %]
134             An error occurs: Unable to load the configuration.
135           [% END %]
136           </div>
137         [% END %]
138
139         [% IF op == 'edit_form' %]
140           <form method="post" action="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">
141             <div id="edit_rules">
142               <h4>List of rules</h4>
143                 <div id="rules">
144                 [% FOR rule IN rules %]
145                   [% SET id = loop.count %]
146                   <div class="rule">
147                     <input type="hidden" name="unique_id" value="[% loop.count %]" /> <!-- FIXME on update, the unique_id should be filled -->
148                     <div class="age">
149                       <h5>Age</h5>
150                       <input type="number" value="[% rule.age %]" name="age_[% id %]" /> days
151                     </div>
152                     <div class="blocks">
153                       <h5>Conditions</h5>
154                       [% FOR condition IN rule.conditions %]
155                         <div class="block">
156                           <select name="condition_field_[% id %]">
157                             <option value="">Choose a field name</option>
158                             [% FOR field IN condition_fields %]
159                               [% IF condition.field == field %]
160                                 <option value="[% field %]" selected="selected">[% field %]</option>
161                               [% ELSE %]
162                                 <option value="[% field %]">[% field %]</option>
163                               [% END %]
164                             [% END %]
165                           </select>
166                           =
167                           <input type="text" value="[% condition.value %]" name="condition_value_[% id%]" />
168                           <a class="add_block" style="cursor:pointer"><i class="fa fa-plus"></i></a>
169                           <a class="remove_block" style="cursor:pointer"><i class="fa fa-trash"></i></a>
170                         </div>
171                       [% END %]
172                     </div>
173                     <div class="blocks">
174                       <h5>Substitutions</h5>
175                       [% FOR substitution IN rule.substitutions %]
176                         <div class="block">
177                           <select name="substitution_field_[% id %]">
178                             <option value="">Choose a field name</option>
179                             [% FOR field IN substitution_fields %]
180                               [% IF substitution.field == field %]
181                                 <option value="[% field %]" selected="selected">[% field %]</option>
182                               [% ELSE %]
183                                 <option value="[% field %]">[% field %]</option>
184                               [% END %]
185                             [% END %]
186                           </select>
187                           =
188                           <input type="text" value="[% substitution.value %]" name="substitution_value_[% id %]" />
189                           <a class="add_block" style="cursor:pointer"><i class="fa fa-plus"></i></a>
190                           <a class="remove_block" style="cursor:pointer"><i class="fa fa-trash"></i></a>
191                         </div>
192                       [% END %]
193                     </div>
194                     <a class="remove_rule" style="cursor:pointer">Remove this rule</a>
195                   </div>
196                 [% END %]
197                 </div>
198                 <div id="norules">
199                   There is no rule defined.
200                 </div>
201               <fieldset class="action">
202                 <input type="hidden" name="op" value="update" />
203                 <a class="cancel" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Cancel</a>
204                 <input type="submit" value="Submit theses rules" />
205               </fieldset>
206             </div>
207           </form>
208           <h4>Add a new rule</h4>
209           <div id="new_rule">
210             <input type="hidden" name="unique_id" />
211             <div class="age">
212               <h5>Age</h5>
213               <input type="number" value="" name="age" /> days
214             </div>
215             <div class="blocks">
216               <h5>Conditions</h5>
217               <div class="block">
218                 <select name="condition_field">
219                   <option value="">Choose a field name</option>
220                   [% FOR field IN condition_fields %]
221                     <option value="[% field %]">[% field %]</option>
222                   [% END %]
223                 </select>
224                 =
225                 <input type="text" value="" name="condition_value" />
226                 <a class="add_block" style="cursor:pointer"><i class="fa fa-plus"></i></a>
227                 <a class="remove_block" style="cursor:pointer"><i class="fa fa-trash"></i></a>
228               </div>
229             </div>
230             <div class="blocks">
231               <h5>Substitutions</h5>
232               <div class="block">
233                 <select name="substitution_field">
234                   <option value="">Choose a field name</option>
235                   [% FOR field IN substitution_fields %]
236                     <option value="[% field %]">[% field %]</option>
237                   [% END %]
238                 </select>
239                 =
240                 <input type="text" value="" name="substitution_value" />
241                 <a class="add_block" style="cursor:pointer"><i class="fa fa-plus"></i></a>
242                 <a class="remove_block" style="cursor:pointer"><i class="fa fa-trash"></i></a>
243               </div>
244             </div>
245           <a class="add_rule" style="cursor:pointer">Add this rule</a>
246           <a class="remove_rule" style="cursor:pointer">Remove this rule</a>
247           </div>
248         [% ELSIF rules and op == 'show' %]
249           <div id="rules">
250             <h4>List of rules</h4>
251             [% FOR rule IN rules %]
252               <div class="rule">
253                 <div class="age">
254                   <h5>Age</h5>
255                   [% IF rule.age.defined and rule.age.length > 0 %]
256                     [% rule.age %] days
257                   [% ELSE %]
258                     There is no age for this rule.
259                   [% END %]
260                 </div>
261                 <div class="blocks">
262                   <h5>Conditions</h5>
263                   [% FOR condition IN rule.conditions %]
264                     [% IF condition.field %]
265                       <div class="block">
266                         [% condition.field %] = [% condition.value %]
267                       </div>
268                     [% ELSE %]
269                       There is no condition for this rule.
270                     [% END %]
271                   [% END %]
272                 </div>
273                 <div class="blocks">
274                   <h5>Substitutions</h5>
275                   [% FOR substitution IN rule.substitutions %]
276                     <div class="block">
277                       [% substitution.field %] = [% substitution.value %]
278                     </div>
279                   [% END %]
280                 </div>
281               </div>
282             [% END %]
283           </div>
284         [% ELSE %]
285           There is no rule defined. Please click on the edit button.
286         [% END %]
287
288       </div>
289     </div>
290   <div class="yui-b noprint">
291     [% INCLUDE 'tools-menu.inc' %]
292   </div>
293 </div>
294 [% INCLUDE 'intranet-bottom.inc' %]