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