Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / automatic_item_modification_by_age.tt
blob7e1d5a38513b4c010b229ffb45f5ee408c34781b
1 [% USE Asset %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Tools &rsaquo; Automatic item modifications by age</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 </head>
8 <body id="tools_automatic_item_modification_by_age" class="tools">
9 [% INCLUDE 'header.inc' %]
10 [% INCLUDE 'cat-search.inc' %]
11     <div id="breadcrumbs">
12         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
13         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
14         [% IF ( op == 'edit_form' ) %]
15             <a href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Automatic item modifications by age</a> &rsaquo;
16             Rules
17         [% ELSE %]
18             Automatic item modifications by age
19         [% END %]
20     </div>
22 <div id="doc3" class="yui-t2">
23   <div id="bd">
24     <div id="yui-main">
25       <div class="yui-b">
27         [% IF ( op == 'edit_form' ) %]
28           <form method="post" id="rules_form" action="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">
29             <h3>Rules for automatic item modifications by age</h3>
30             <div id="toolbar" class="btn-toolbar">
31                 <div class="btn-group">
32                     <button class="btn btn-default btn-sm add_rule"><i class="fa fa-plus"></i> Add rule</button>
33                 </div>
34                 <div class="btn-group">
35                     <button type="submit" id="save_rules" class="btn btn-default btn-sm"><i class="fa fa-save"></i> Save</button>
36                 </div>
37                 <div class="btn-group">
38                     <a class="btn btn-default btn-sm" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl"><i class="fa fa-remove"></i> Cancel</a>
39                 </div>
40             </div>
41         [% ELSE %]
42             <h3>Automatic item modifications by age</h3>
43             [% IF ( rules ) %]
44                 <div id="toolbar" class="btn-toolbar">
45                     <a class="btn btn-default btn-sm" id="newentry" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl?op=edit_form"><i class="fa fa-pencil"></i> Edit rules</a>
46                 </div>
47             [% ELSE %]
48                 <div id="toolbar" class="btn-toolbar">
49                     <a class="btn btn-default btn-sm" id="newentry" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl?op=edit_form"><i class="fa fa-plus"></i> Add rules</a>
50                 </div>
51             [% END %]
52         [% END %]
54         [% FOR message IN messages %]
55           [% IF message.type == "error" %]
56             <div class="dialog alert">
57           [% END %]
58           [% IF message.code == "unable_to_load_configuration" %]
59             An error occurs: Unable to load the configuration.
60           [% END %]
61           </div>
62         [% END %]
64         [% IF op == 'edit_form' %]
65             <div id="edit_rules">
66                 <div id="rules">
67                 [% FOR rule IN rules %]
68                   [% SET id = loop.count %]
69                   <fieldset class="rule">
70                     <legend>Rule <span class="rulecount">[% loop.count %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
71                     <input type="hidden" name="unique_id" value="[% loop.count %]" /> <!-- FIXME on update, the unique_id should be filled -->
72                     <div class="age">
73                       <h5>Age in days</h5>
74                       <input class="age" type="number" value="[% rule.age %]" name="age_[% id %]" />
75                     </div>
76                     <div class="blocks">
77                       <h5>Conditions</h5>
78                       [% FOR condition IN rule.conditions %]
79                         <div class="block">
80                           <select name="condition_field_[% id %]">
81                             <option value="">Choose a field name</option>
82                             [% FOR field IN condition_fields %]
83                               [% IF condition.field == field %]
84                                 <option value="[% field %]" selected="selected">[% field %]</option>
85                               [% ELSE %]
86                                 <option value="[% field %]">[% field %]</option>
87                               [% END %]
88                             [% END %]
89                           </select>
90                           =
91                           <input type="text" value="[% condition.value %]" name="condition_value_[% id%]" />
92                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
93                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
94                         </div>
95                       [% END %]
96                     </div>
97                     <div class="blocks">
98                       <h5>Substitutions</h5>
99                       [% FOR substitution IN rule.substitutions %]
100                         <div class="block">
101                           <select class="required" required="required" name="substitution_field_[% id %]">
102                             <option value="">Choose a field name</option>
103                             [% FOR field IN substitution_fields %]
104                               [% IF substitution.field == field %]
105                                 <option value="[% field %]" selected="selected">[% field %]</option>
106                               [% ELSE %]
107                                 <option value="[% field %]">[% field %]</option>
108                               [% END %]
109                             [% END %]
110                           </select>
111                           =
112                           <input type="text" value="[% substitution.value %]" name="substitution_value_[% id %]" />
113                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
114                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
115                           <span class="required">A field name is required</span>
116                         </div>
117                       [% END %]
118                     </div>
119                   </fieldset>
120                 [% END %]
121                 </div>
122                 <input type="hidden" name="op" value="update" />
123             </div>
124           </form>
126         <div id="norules" class="dialog message">
127           There are no rules defined.
128         </div>
130           <fieldset id="new_rule">
131             <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
132             <input type="hidden" name="unique_id" />
133             <div class="age">
134               <h5>Age in days</h5>
135               <input class="age" type="number" value="" name="age" />
136             </div>
137             <div class="blocks">
138               <h5>Conditions</h5>
139               <div class="block">
140                 <select name="condition_field">
141                   <option value="">Choose a field name</option>
142                   [% FOR field IN condition_fields %]
143                     <option value="[% field %]">[% field %]</option>
144                   [% END %]
145                 </select>
146                 =
147                 <input type="text" value="" name="condition_value" />
148                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
149                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
150               </div>
151             </div>
152             <div class="blocks">
153               <h5>Substitutions</h5>
154               <div class="block">
155                 <select required="required" class="required" name="substitution_field">
156                   <option value="">Choose a field name</option>
157                   [% FOR field IN substitution_fields %]
158                     <option value="[% field %]">[% field %]</option>
159                   [% END %]
160                 </select>
161                 =
162                 <input type="text" value="" name="substitution_value" />
163                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
164                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
165                 <span class="required">A field name is required</span>
166               </div>
167             </div>
168           </fieldset>
169         [% ELSIF rules %]
170             <div>
171                 <h4>List of rules</h4>
172                     <table id="rulest">
173                         <thead>
174                           <tr>
175                                <th>Age</th>
176                                 <th>Conditions</th>
177                                 <th>Substitutions</th>
178                             </tr>
179                         </thead>
180                         <tbody>
181                             [% FOR rule IN rules %]
182                                 <tr>
183                                     <td>
184                                         [% IF rule.age.defined and rule.age.length > 0 %]
185                                             [% rule.age %] days
186                                         [% ELSE %]
187                                             There is no age for this rule.
188                                         [% END %]
189                                     </td>
190                                     <td>
191                                         [% FOR condition IN rule.conditions %]
192                                             [% IF condition.field %]
193                                                 <div class="block">
194                                                 [% condition.field %] = [% condition.value %]
195                                                 </div>
196                                             [% ELSE %]
197                                                 There is no condition for this rule.
198                                             [% END %]
199                                         [% END %]
200                                     </td>
201                                     <td>
202                                         [% FOR substitution IN rule.substitutions %]
203                                             <div class="block">
204                                                 [% substitution.field %] = [% substitution.value %]
205                                             </div>
206                                         [% END %]
207                                     </td>
208                                 </tr>
209                             [% END %]
210                         </tbody>
211                     </table>
212             </div>
213         [% ELSE %]
214             <div class="dialog message">
215                 There are no rules defined.
216             </div>
217         [% END %]
219       </div>
220     </div>
221   <div class="yui-b noprint">
222     [% INCLUDE 'tools-menu.inc' %]
223   </div>
224 </div>
226 [% MACRO jsinclude BLOCK %]
227     [% Asset.js("js/tools-menu.js") %]
228     [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") %]
229     [% Asset.js("js/automatic_item_modification_by_age.js") %]
230     [% IF op == 'edit_form' %]
231         <script type="text/javascript">
232             $(document).ready(function() {
233                   [% IF ( op == 'edit_form' ) %]
234                       $('#toolbar').fixFloat();
235                   [% END %]
236                   [% IF rules.size > 0 %]
237                       $("#norules").hide();
238                   [% ELSE %]
239                       $("#rules").show();
240                   [% END %]
241             });
242         </script>
243     [% END %]
244 [% END %]
246 [% INCLUDE 'intranet-bottom.inc' %]