Bug 35198: Sort database column names alphabetically on automatic item modification...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / automatic_item_modification_by_age.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Automatic item modifications by age &rsaquo; Cataloging &rsaquo; Koha</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="tools_automatic_item_modification_by_age" class="tools">
10 [% WRAPPER 'header.inc' %]
11     [% INCLUDE 'cat-search.inc' %]
12 [% END %]
13
14 [% WRAPPER 'sub-header.inc' %]
15     [% WRAPPER breadcrumbs %]
16             [% WRAPPER breadcrumb_item %]
17                 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
18             [% END %]
19
20             [% IF ( op == 'edit_form' ) %]
21                 [% WRAPPER breadcrumb_item %]
22                     <a href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Automatic item modifications by age</a>
23                 [% END %]
24                 [% WRAPPER breadcrumb_item bc_active= 1 %]
25                     <span>Rules</span>
26                 [% END %]
27             [% ELSE %]
28                 [% WRAPPER breadcrumb_item bc_active= 1 %]
29                     <span>Automatic item modifications by age</span>
30                 [% END %]
31             [% END %]
32     [% END #/ WRAPPER breadcrumbs %]
33 [% END #/ WRAPPER sub-header.inc %]
34
35 <div class="main container-fluid">
36     <div class="row">
37         <div class="col-sm-10 col-sm-push-2">
38             <main>
39
40         [% IF ( op == 'edit_form' ) %]
41           <form method="post" id="rules_form" action="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">
42             <h1>Rules for automatic item modifications by age</h1>
43             <div id="toolbar" class="btn-toolbar">
44                 <div class="btn-group">
45                     <button class="btn btn-default add_rule"><i class="fa fa-plus"></i> Add rule</button>
46                 </div>
47                 <div class="btn-group">
48                     <button type="submit" id="save_rules" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
49                 </div>
50                 <div class="btn-group">
51                     <a class="btn btn-default" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl"><i class="fa fa-remove"></i> Cancel</a>
52                 </div>
53             </div>
54         [% ELSE %]
55             <h1>Automatic item modifications by age</h1>
56             [% IF ( rules ) %]
57                 <div id="toolbar" class="btn-toolbar">
58                     <a class="btn btn-default" 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>
59                 </div>
60             [% ELSE %]
61                 <div id="toolbar" class="btn-toolbar">
62                     <a class="btn btn-default" 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>
63                 </div>
64             [% END %]
65         [% END %]
66
67         [% FOR message IN messages %]
68           [% IF message.type == "error" %]
69             <div class="dialog alert">
70           [% END %]
71           [% IF message.code == "unable_to_load_configuration" %]
72             An error occurs: Unable to load the configuration.
73           [% END %]
74           </div>
75         [% END %]
76
77         [% IF op == 'edit_form' %]
78             <div id="edit_rules">
79                 <div id="rules">
80                 [% FOR rule IN rules %]
81                   [% SET id = loop.count %]
82                   <fieldset class="rule">
83                     <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>
84                     <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
85                     <div class="age">
86                       <h5>Age in days</h5>
87                       <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
88                       <h5>Age field</h5>
89                           <div class="blocks">
90                               <select name="agefield_[% id | html %]">
91                                   <option value="">Choose an age field</option>
92                                   [% FOR field IN agefields.sort %]
93                                     [% IF rule.agefield == field %]
94                                      <option value="[% field | html %]" selected="selected">[% field | html %]</option>
95                                     [% ELSE %]
96                                      <option value="[% field | html %]">[% field | html %]</option>
97                                     [% END %]
98                                   [% END %]
99                               </select>
100                               <span class="hint">If not set then items.dateaccessioned will be used</span>
101                           </div>
102                     </div>
103                     <div class="blocks">
104                       <h5>Conditions</h5>
105                       [% FOR condition IN rule.conditions %]
106                         <div class="block">
107                           <select name="condition_field_[% id | html %]">
108                             <option value="">Choose a field name</option>
109                             [% FOR field IN condition_fields.sort %]
110                               [% IF condition.field == field %]
111                                 <option value="[% field | html %]" selected="selected">[% field | html %]</option>
112                               [% ELSE %]
113                                 <option value="[% field | html %]">[% field | html %]</option>
114                               [% END %]
115                             [% END %]
116                           </select>
117                           =
118                           <input type="text" value="[% condition.value | html %]" name="condition_value_[% id | html %]" />
119                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
120                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
121                         </div>
122                       [% END %]
123                     </div>
124                     <div class="blocks">
125                       <h5>Substitutions</h5>
126                       [% FOR substitution IN rule.substitutions %]
127                         <div class="block">
128                           <select class="required" required="required" name="substitution_field_[% id | html %]">
129                             <option value="">Choose a field name</option>
130                             [% FOR field IN substitution_fields.sort %]
131                               [% IF substitution.field == field %]
132                                 <option value="[% field | html %]" selected="selected">[% field | html %]</option>
133                               [% ELSE %]
134                                 <option value="[% field | html %]">[% field | html %]</option>
135                               [% END %]
136                             [% END %]
137                           </select>
138                           =
139                           <input type="text" value="[% substitution.value | html %]" name="substitution_value_[% id | html %]" />
140                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
141                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
142                           <span class="required">A field name is required</span>
143                         </div>
144                       [% END %]
145                     </div>
146                   </fieldset>
147                 [% END %]
148                 </div>
149                 <input type="hidden" name="op" value="update" />
150             </div>
151           </form>
152
153         <div id="norules" class="dialog message">
154           There are no rules defined.
155         </div>
156
157           <fieldset id="new_rule">
158             <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
159             <input type="hidden" name="unique_id" />
160             <div class="age">
161               <h5>Age in days</h5>
162               <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
163               <h5>Age field</h5>
164               <div class="block">
165                   <select name="agefield">
166                       <option value="">Choose an age field</option>
167                       [% FOR field IN agefields.sort %]
168                            <option value="[% field | html %]">[% field | html %]</option>
169                       [% END %]
170                   </select>
171                   <span class="hint">If not set then items.dateaccessioned will be used</span>
172               </div>
173             </div>
174             <div class="blocks">
175               <h5>Conditions</h5>
176               <div class="block">
177                 <select name="condition_field">
178                   <option value="">Choose a field name</option>
179                   [% FOR field IN condition_fields.sort %]
180                     <option value="[% field | html %]">[% field | html %]</option>
181                   [% END %]
182                 </select>
183                 =
184                 <input type="text" value="" name="condition_value" />
185                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
186                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
187               </div>
188             </div>
189             <div class="blocks">
190               <h5>Substitutions</h5>
191               <div class="block">
192                 <select required="required" class="required" name="substitution_field">
193                   <option value="">Choose a field name</option>
194                   [% FOR field IN substitution_fields.sort %]
195                     <option value="[% field | html %]">[% field | html %]</option>
196                   [% END %]
197                 </select>
198                 =
199                 <input type="text" value="" name="substitution_value" />
200                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
201                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
202                 <span class="required">A field name is required</span>
203               </div>
204             </div>
205           </fieldset>
206         [% ELSIF rules %]
207             <div>
208                 <h4>List of rules</h4>
209
210                 <div class="page-section">
211                     <table id="rulest">
212                         <thead>
213                           <tr>
214                                <th>Age</th>
215                                 <th>Age field</th>
216                                 <th>Conditions</th>
217                                 <th>Substitutions</th>
218                             </tr>
219                         </thead>
220                         <tbody>
221                             [% FOR rule IN rules %]
222                                 <tr>
223                                     <td>
224                                         [% IF rule.age.defined and rule.age.length > 0 %]
225                                             <span>[% rule.age | html %] days</span>
226                                         [% ELSE %]
227                                             <span>There is no age for this rule.</span>
228                                         [% END %]
229                                     </td>
230                                     <td>
231                                         [% IF rule.agefield %]
232                                             [% rule.agefield | html %]
233                                         [% ELSE %]
234                                             <!-- In case old rules do not contain an agefield value display that items.dateaccessioned will be used -->
235                                             items.dateaccessioned
236                                         [% END %]
237                                     </td>
238                                     <td>
239                                         [% FOR condition IN rule.conditions %]
240                                             [% IF condition.field %]
241                                                 <div class="block">
242                                                 [% condition.field | html %] = [% condition.value | html %]
243                                                 </div>
244                                             [% ELSE %]
245                                                 There is no condition for this rule.
246                                             [% END %]
247                                         [% END %]
248                                     </td>
249                                     <td>
250                                         [% FOR substitution IN rule.substitutions %]
251                                             <div class="block">
252                                                 [% substitution.field | html %] = [% substitution.value | html %]
253                                             </div>
254                                         [% END %]
255                                     </td>
256                                 </tr>
257                             [% END %]
258                         </tbody>
259                     </table>
260                 </div> <!-- /.page-section -->
261             </div>
262         [% ELSE %]
263             <div class="dialog message">
264                 There are no rules defined.
265             </div>
266         [% END %]
267
268             </main>
269         </div> <!-- /.col-sm-10.col-sm-push-2 -->
270
271         <div class="col-sm-2 col-sm-pull-10">
272             <aside>
273                 [% INCLUDE 'cat-menu.inc' %]
274             </aside>
275         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
276      </div> <!-- /.row -->
277
278 [% MACRO jsinclude BLOCK %]
279     [% Asset.js("lib/hc-sticky.js") | $raw %]
280     [% Asset.js("js/automatic_item_modification_by_age.js") | $raw %]
281     [% IF op == 'edit_form' %]
282         <script>
283             var Sticky;
284             $(document).ready(function() {
285                   [% IF ( op == 'edit_form' ) %]
286                 Sticky = $("#toolbar");
287                 Sticky.hcSticky({
288                     stickTo: "main",
289                     stickyClass: "floating"
290                 });
291                   [% END %]
292                   [% IF rules.size > 0 %]
293                       $("#norules").hide();
294                   [% ELSE %]
295                       $("#rules").show();
296                   [% END %]
297             });
298         </script>
299     [% END %]
300 [% END %]
301
302 [% INCLUDE 'intranet-bottom.inc' %]