Bug 32254: (follow-up) Add page section to Cashup history
[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     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
16         <ol>
17             <li>
18                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19             </li>
20             <li>
21                 <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
22             </li>
23
24             [% IF ( op == 'edit_form' ) %]
25                 <li>
26                     <a href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Automatic item modifications by age</a>
27                 </li>
28                 <li>
29                     <a href="#" aria-current="page">
30                         Rules
31                     </a>
32                 </li>
33             [% ELSE %]
34                 <li>
35                     <a href="#" aria-current="page">
36                         Automatic item modifications by age
37                     </a>
38                 </li>
39             [% END %]
40         </ol>
41     </nav>
42     [% END %]
43
44
45 <div class="main container-fluid">
46     <div class="row">
47         <div class="col-sm-10 col-sm-push-2">
48             <main>
49
50         [% IF ( op == 'edit_form' ) %]
51           <form method="post" id="rules_form" action="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">
52             <h1>Rules for automatic item modifications by age</h1>
53             <div id="toolbar" class="btn-toolbar">
54                 <div class="btn-group">
55                     <button class="btn btn-default add_rule"><i class="fa fa-plus"></i> Add rule</button>
56                 </div>
57                 <div class="btn-group">
58                     <button type="submit" id="save_rules" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
59                 </div>
60                 <div class="btn-group">
61                     <a class="btn btn-default" href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl"><i class="fa fa-remove"></i> Cancel</a>
62                 </div>
63             </div>
64         [% ELSE %]
65             <h1>Automatic item modifications by age</h1>
66             [% IF ( rules ) %]
67                 <div id="toolbar" class="btn-toolbar">
68                     <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>
69                 </div>
70             [% ELSE %]
71                 <div id="toolbar" class="btn-toolbar">
72                     <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>
73                 </div>
74             [% END %]
75         [% END %]
76
77         [% FOR message IN messages %]
78           [% IF message.type == "error" %]
79             <div class="dialog alert">
80           [% END %]
81           [% IF message.code == "unable_to_load_configuration" %]
82             An error occurs: Unable to load the configuration.
83           [% END %]
84           </div>
85         [% END %]
86
87         [% IF op == 'edit_form' %]
88             <div id="edit_rules">
89                 <div id="rules">
90                 [% FOR rule IN rules %]
91                   [% SET id = loop.count %]
92                   <fieldset class="rule">
93                     <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>
94                     <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled -->
95                     <div class="age">
96                       <h5>Age in days</h5>
97                       <input class="age" type="text" inputmode="numeric" pattern="[0-9]*"  value="[% rule.age | html %]" name="age_[% id | html %]" />
98                       <h5>Age field</h5>
99                           <div class="blocks">
100                               <select name="agefield_[% id | html %]">
101                                   <option value="">Choose an age field</option>
102                                   [% FOR field IN agefields %]
103                                     [% IF rule.agefield == field %]
104                                      <option value="[% field | html %]" selected="selected">[% field | html %]</option>
105                                     [% ELSE %]
106                                      <option value="[% field | html %]">[% field | html %]</option>
107                                     [% END %]
108                                   [% END %]
109                               </select>
110                               <span class="hint">If not set then items.dateaccessioned will be used</span>
111                           </div>
112                     </div>
113                     <div class="blocks">
114                       <h5>Conditions</h5>
115                       [% FOR condition IN rule.conditions %]
116                         <div class="block">
117                           <select name="condition_field_[% id | html %]">
118                             <option value="">Choose a field name</option>
119                             [% FOR field IN condition_fields %]
120                               [% IF condition.field == field %]
121                                 <option value="[% field | html %]" selected="selected">[% field | html %]</option>
122                               [% ELSE %]
123                                 <option value="[% field | html %]">[% field | html %]</option>
124                               [% END %]
125                             [% END %]
126                           </select>
127                           =
128                           <input type="text" value="[% condition.value | html %]" name="condition_value_[% id | html %]" />
129                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
130                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
131                         </div>
132                       [% END %]
133                     </div>
134                     <div class="blocks">
135                       <h5>Substitutions</h5>
136                       [% FOR substitution IN rule.substitutions %]
137                         <div class="block">
138                           <select class="required" required="required" name="substitution_field_[% id | html %]">
139                             <option value="">Choose a field name</option>
140                             [% FOR field IN substitution_fields %]
141                               [% IF substitution.field == field %]
142                                 <option value="[% field | html %]" selected="selected">[% field | html %]</option>
143                               [% ELSE %]
144                                 <option value="[% field | html %]">[% field | html %]</option>
145                               [% END %]
146                             [% END %]
147                           </select>
148                           =
149                           <input type="text" value="[% substitution.value | html %]" name="substitution_value_[% id | html %]" />
150                           <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
151                           <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
152                           <span class="required">A field name is required</span>
153                         </div>
154                       [% END %]
155                     </div>
156                   </fieldset>
157                 [% END %]
158                 </div>
159                 <input type="hidden" name="op" value="update" />
160             </div>
161           </form>
162
163         <div id="norules" class="dialog message">
164           There are no rules defined.
165         </div>
166
167           <fieldset id="new_rule">
168             <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash"></i> Remove this rule</a></legend>
169             <input type="hidden" name="unique_id" />
170             <div class="age">
171               <h5>Age in days</h5>
172               <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" />
173               <h5>Age field</h5>
174               <div class="block">
175                   <select name="agefield">
176                       <option value="">Choose an age field</option>
177                       [% FOR field IN agefields %]
178                            <option value="[% field | html %]">[% field | html %]</option>
179                       [% END %]
180                   </select>
181                   <span class="hint">If not set then items.dateaccessioned will be used</span>
182               </div>
183             </div>
184             <div class="blocks">
185               <h5>Conditions</h5>
186               <div class="block">
187                 <select name="condition_field">
188                   <option value="">Choose a field name</option>
189                   [% FOR field IN condition_fields %]
190                     <option value="[% field | html %]">[% field | html %]</option>
191                   [% END %]
192                 </select>
193                 =
194                 <input type="text" value="" name="condition_value" />
195                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a>
196                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a>
197               </div>
198             </div>
199             <div class="blocks">
200               <h5>Substitutions</h5>
201               <div class="block">
202                 <select required="required" class="required" name="substitution_field">
203                   <option value="">Choose a field name</option>
204                   [% FOR field IN substitution_fields %]
205                     <option value="[% field | html %]">[% field | html %]</option>
206                   [% END %]
207                 </select>
208                 =
209                 <input type="text" value="" name="substitution_value" />
210                 <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a>
211                 <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a>
212                 <span class="required">A field name is required</span>
213               </div>
214             </div>
215           </fieldset>
216         [% ELSIF rules %]
217             <div>
218                 <h4>List of rules</h4>
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>
269         [% ELSE %]
270             <div class="dialog message">
271                 There are no rules defined.
272             </div>
273         [% END %]
274
275             </main>
276         </div> <!-- /.col-sm-10.col-sm-push-2 -->
277
278         <div class="col-sm-2 col-sm-pull-10">
279             <aside>
280                 [% INCLUDE 'cat-menu.inc' %]
281             </aside>
282         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
283      </div> <!-- /.row -->
284
285 [% MACRO jsinclude BLOCK %]
286     [% Asset.js("lib/hc-sticky.js") | $raw %]
287     [% Asset.js("js/automatic_item_modification_by_age.js") | $raw %]
288     [% IF op == 'edit_form' %]
289         <script>
290             var Sticky;
291             $(document).ready(function() {
292                   [% IF ( op == 'edit_form' ) %]
293                 Sticky = $("#toolbar");
294                 Sticky.hcSticky({
295                     stickTo: "main",
296                     stickyClass: "floating"
297                 });
298                   [% END %]
299                   [% IF rules.size > 0 %]
300                       $("#norules").hide();
301                   [% ELSE %]
302                       $("#rules").show();
303                   [% END %]
304             });
305         </script>
306     [% END %]
307 [% END %]
308
309 [% INCLUDE 'intranet-bottom.inc' %]