Bug 29648: Fix occurrences of GetColumns
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / marc_modification_templates.tt
1 [% USE raw %]
2 [% USE JSON.Escape %]
3 [% USE Asset %]
4 [% USE TablesSettings %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>MARC modification templates &rsaquo; Tools &rsaquo; Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% FILTER collapse %]
10     <style>
11         #add_action {
12             display: none;
13         }
14
15         .action_line {
16             margin-bottom: 1em;
17         }
18     </style>
19 [% END %]
20 </head>
21
22 <body id="tools_marc_modification_templates" class="tools">
23 [% INCLUDE 'header.inc' %]
24 [% INCLUDE 'cat-search.inc' %]
25
26 [% IF ( TemplatesLoop ) %]
27     [% FOREACH TemplatesLoo IN TemplatesLoop %]
28         [% IF ( TemplatesLoo.selected ) %]
29             [% SET template_name = TemplatesLoo.name %]
30         [% END %]
31     [% END %]
32 [% END %]
33
34 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
35     <ol>
36         <li>
37             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
38         </li>
39         <li>
40             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
41         </li>
42
43         [% IF ( template_name ) %]
44             <li>
45                 <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
46             </li>
47             <li>
48                 <a href="#" aria-current="page">
49                     [% template_name | html %]
50                 </a>
51             </li>
52         [% ELSE %]
53             <li>
54                 <a href="#" aria-current="page">
55                     MARC modification templates
56                 </a>
57             </li>
58         [% END %]
59     </ol>
60 </nav>
61
62 <div class="main container-fluid">
63     <div class="row">
64         <div class="col-sm-10 col-sm-push-2">
65             <main>
66
67             <div id="toolbar" class="btn-toolbar">
68                 <a href="#" data-toggle="modal" data-template_id="" data-target="#createTemplate" id="new_template" class="btn btn-default duplicate_template"><i class="fa fa-plus"></i> New template</a>
69                 [% IF ( template_id != '' ) %]
70                     <a href="#" id="new_action" class="btn btn-default"><i class="fa fa-plus"></i> New action</a>
71                     <a class="btn btn-default delete_template" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% template_id | html %]&amp;op=delete_template"><i class="fa fa-fw fa-trash"></i> Delete template</a>
72                 [% END %]
73             </div>
74
75             [% IF error %]
76                 [% IF error == 'no_from_field' %]
77                     <div class="dialog message">Error: no field value specified.</div>
78                 [% END %]
79             [% END %]
80
81             [% IF ( TemplatesLoop ) %]
82
83                 [% IF ( template_id == '' ) %]
84
85                     <h1>MARC modification templates [% template_id | html %]</h1>
86
87                     <table id="templatest">
88                         <thead>
89                             <tr>
90                                 <th>Id</th>
91                                 <th>Template</th>
92                                 <th class="NoSort noExport">Actions</th>
93                             </tr>
94                         </thead>
95                         <tbody>
96                             [% FOREACH TemplatesLoo IN TemplatesLoop %]
97                                 <tr>
98                                     <td>[% TemplatesLoo.template_id | html %]</td>
99                                     <td>[% TemplatesLoo.name | html %]</td>
100                                     <td class="actions">
101                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id | html %]&amp;op=select_template" ><i class="fa fa-fw fa-pencil"></i> Edit actions</a>
102                                         <a class="btn btn-default btn-xs duplicate_template" href="#" data-toggle="modal" data-template_id="[% TemplatesLoo.template_id | html %]" data-target="#createTemplate"><i class="fa fa-fw fa-copy"></i> Duplicate</a>
103                                         <a class="btn btn-default btn-xs delete_template" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id | html %]&amp;op=delete_template"><i class="fa fa-fw fa-trash"></i> Delete</a>
104                                     </td>
105                                 </tr>
106                             [% END %]
107                         </tbody>
108                     </table>
109
110                 [% ELSE %]
111
112                     <h1>Actions for <em>[% template_name | html %]</em></h1>
113
114                     [% IF ( ActionsLoop ) %]
115
116                         <table id="template_actions" class="template_actions">
117                             <thead>
118                                 <tr>
119                                     <th>Change order</th>
120                                     <th>Rank</th>
121                                     <th>Action</th>
122                                     <th>Description</th>
123                                     <th>&nbsp;</th>
124                                     <th>&nbsp;</th>
125                                 </tr>
126                             </thead>
127                             <tbody>
128                                 [% FOREACH ActionsLoo IN ActionsLoop %]
129                                     <tr>
130                                         <td class="actions">
131                                             <a title="Move action up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
132                                                 <i class="fa fa-arrow-up fa-lg order-control"></i>
133                                             </a>
134
135                                             <a title="Move action to top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
136                                                 <i class="fa fa-arrow-up fa-lg overline order-control"></i>
137                                             </a>
138
139                                             <a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
140                                                 <i class="fa fa-arrow-down fa-lg underline order-control"></i>
141                                             </a>
142
143                                             <a title="Move action down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id | html %]&amp;mmta_id=[% ActionsLoo.mmta_id | html %]">
144                                                 <i class="fa fa-arrow-down fa-lg order-control"></i>
145                                             </a>
146                                         </td>
147
148                                         <td>[% ActionsLoo.ordering | html %]</td>
149                                         <td>
150                                             [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
151                                             [% IF ( ActionsLoo.action_add_field ) %] Add new [% END %]
152                                             [% IF ( ActionsLoo.action_update_field ) %] Update existing or add new [% END %]
153                                             [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
154                                             [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
155                                             [% IF ( ActionsLoo.action_copy_and_replace_field ) %] Copy and replace [% END %]
156
157                                             [% UNLESS ( ActionsLoo.action_update_field ) %]
158                                                 [% IF ( ActionsLoo.field_number ) %]
159                                                     1st
160                                                 [% END %]
161                                             [% END %]
162
163                                             field
164
165                                             [% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield.length ) %]$[% ActionsLoo.from_subfield | html %][% END %]
166
167                                             [% IF ( ActionsLoo.field_value ) %]
168                                                 with value <em>[% ActionsLoo.field_value | html %]</em>
169                                             [% END %]
170
171                                             [% IF ( ActionsLoo.to_field ) %]
172                                                 to [% ActionsLoo.to_field | html %][% IF ( ActionsLoo.to_subfield.length ) %]$[% ActionsLoo.to_subfield | html %][% END %]
173
174                                                 [% IF ( ActionsLoo.to_regex_search ) %]
175                                                      using RegEx s<strong>/[% ActionsLoo.to_regex_search | html %]/[% ActionsLoo.to_regex_replace | html %]/[% ActionsLoo.to_regex_modifiers | html %]</strong>
176                                                 [% END %]
177                                             [% END %]
178
179                                             [% IF ( ActionsLoo.conditional ) %]
180                                                 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
181                                                 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
182
183                                                 [% ActionsLoo.conditional_field | html %][% IF ( ActionsLoo.conditional_subfield.length ) %]$[% ActionsLoo.conditional_subfield | html %][% END %]
184
185                                                 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
186                                                 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
187                                                 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
188                                                 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
189
190                                                 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]<strong>[% ActionsLoo.conditional_value | html %]</strong>[% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
191                                             [% END %]
192                                         </td>
193                                         <td>[% ActionsLoo.description | html %]</td>
194                                         <td>
195                                             <a class="btn btn-default btn-xs edit_action" href="#modaction" data-mmta_id="[% ActionsLoo.mmta_id | html %]"><i class="fa fa-pencil"></i> Edit</a>
196                                         </td>
197                                         <td>
198                                             <a class="btn btn-default btn-xs" href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id | html %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id | html %]" onclick="return confirmDeleteAction();"><i class="fa fa-trash"></i> Delete</a>
199                                         </td>
200                                     </tr>
201                                 [% END # /FOREACH ActionsLoo %]
202                             </tbody>
203                         </table>
204                     [% ELSE %]
205                         <div class="dialog message template_actions"><p>There are no defined actions for this template.</p></div>
206                     [% END # /IF ActionsLoop %]
207
208                     <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
209                         <a name="modaction"></a>
210                         <fieldset>
211                             <legend id="modaction_legend">Add a new action</legend>
212                             <div id="warning_multivalued" style="color:red; display:none;">You have chosen a condition on the same field as the original field. If your records contain multivalued fields it is highly recommended not to do that.</div>
213
214                             <div class="action_line">
215                                 <select name="action" id="action" onchange="onActionChange(this);">
216                                     <option value="delete_field">Delete</option>
217                                     <option value="add_field">Add new</option>
218                                     <option value="update_field">Update existing or add new</option>
219                                     <option value="move_field">Move</option>
220                                     <option value="copy_field">Copy</option>
221                                     <option value="copy_and_replace_field">Copy and replace</option>
222                                 </select>
223
224                                 <span id="field_number_block">
225                                     <select name="field_number" id="field_number">
226                                         <option value="0">All</option>
227                                         <option value="1">1st</option>
228                                     </select>
229                                 </span>
230
231                                 field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
232
233                                 <span name="with_value_block" id="with_value_block" style="display:none;">
234                                     with value <input type="text" name="field_value" id="field_value" />
235                                 </span>
236
237                                 <span name="to_field_block" id="to_field_block" style="display:none;">
238                                     to field <input type="text" name="to_field" id="to_field" size="3" maxlength="3" /> <input type="text" name="to_subfield" id="to_subfield" size="1" maxlength="1" title="let blank for the entire field" />
239
240                                     <span name="to_field_regex_block" id="to_field_regex_block">
241                                         <sup>
242                                             <label for="to_field_regex">RegEx</label>
243                                             <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
244
245                                             <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
246                                                 s/<input type="text" name="to_regex_search" id="to_regex_search" placeholder="regex pattern" />/<input type="text" name="to_regex_replace" id="to_regex_replace" placeholder="regex replacement" />/<input type="text" name="to_regex_modifiers" id="to_regex_modifiers" placeholder="ig" size="3" />
247                                             </span>
248                                         </sup>
249                                     </span>
250                                 </span>
251                             </div>
252
253                             <div class="action_line">
254                                 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
255                                     <option value="" selected="selected" />
256                                     <option value="if">if</option>
257                                     <option value="unless">unless</option>
258                                 </select>
259
260                                 <span name="conditional_block" id="conditional_block" style="display:none;">
261                                     field <input type="text" name="conditional_field" id="conditional_field" size="3" maxlength="3" /> <input type="text" name="conditional_subfield" id="conditional_subfield" size="1" maxlength="1" />
262
263                                     <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
264                                         <option value="" />
265                                         <option value="exists">exists</option>
266                                         <option value="not_exists">doesn't exist</option>
267                                         <option value="equals">matches</option>
268                                         <option value="not_equals">doesn't match</option>
269                                     </select>
270
271                                     <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
272
273                                         <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
274
275                                         <sup>
276                                             <label for="conditional_regex">RegEx</label>
277                                             <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
278                                         </sup>
279
280                                     </span>
281                                 </span>
282                             </div>
283
284                             <div class="action_line">
285                                 <label for="description">Description:</label>
286                                 <input type="text" name="description" id="description" size="60" />
287                             </div>
288
289                             <fieldset class="action">
290                                 <input type="hidden" name="template_id" value="[% template_id | html %]" />
291                                 <input type="hidden" name="mmta_id" id="mmta_id" />
292                                 <input type="hidden" name="op" value="add_action" />
293                                 <input id="action_submit" type="submit" value="Add action" />
294                                 <a href="#modaction" class="cancel" id="cancel_edit" onclick="cancelEditAction();">Cancel</a>
295                             </fieldset>
296
297                         </fieldset>
298                     </form>
299
300                 [% END %]
301
302             [% ELSE %]
303                 <h1>MARC modification templates</h1>
304                 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
305             [% END # /IF TemplatesLoop %]
306
307             <!-- Modal to create new template -->
308             <div class="modal" id="createTemplate" tabindex="-1" role="dialog" aria-labelledby="LabelcreateTemplate" aria-hidden="true">
309                 <div class="modal-dialog">
310                 <div class="modal-content">
311                 <div class="modal-header">
312                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
313                     <h2 id="LabelcreateTemplate">Create a new template</h2>
314                 </div>
315                 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
316                     <div class="modal-body">
317                         <fieldset>
318                             <p>
319                                 <label for="template_name" class="required">Name: </label>
320                                 <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
321                                 <span class="required">Required</span>
322                             </p>
323
324                             <input type="hidden" name="op" value="create_template" />
325
326                             <p>
327                                 <label for="duplicate_a_template">Duplicate a template:</label>
328                                 <select name="template_id" id="duplicate_a_template">
329                                     <option value=""> -- None --</option>
330                                     [% FOREACH TemplatesLoo IN TemplatesLoop %]
331                                         <option value="[% TemplatesLoo.template_id | html %]"> [% TemplatesLoo.name | html %]</option>
332                                     [% END %]
333                                 </select>
334                                 <input type="hidden" name="duplicate_current_template" id="duplicate_current_template" />
335                             </p>
336                         </fieldset>
337                     </div>
338                     <div class="modal-footer">
339                         <button type="submit" class="btn btn-default">Submit</button>
340                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
341                     </div>
342                 </form>
343                 </div>
344                 </div>
345             </div>
346
347             </main>
348         </div> <!-- /.col-sm-10.col-sm-push-2 -->
349
350         <div class="col-sm-2 col-sm-pull-10">
351             <aside>
352                 [% INCLUDE 'tools-menu.inc' %]
353             </aside>
354         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
355      </div> <!-- /.row -->
356
357 [% MACRO jsinclude BLOCK %]
358     [% Asset.js("js/tools-menu.js") | $raw %]
359     [% INCLUDE 'datatables.inc' %]
360     [% INCLUDE 'columns_settings.inc' %]
361     <script>
362         table_settings = [% TablesSettings.GetTableSettings('tools', 'marc-modification-templates', 'templatest', 'json') | $raw %];
363         [% IF ActionsLoop %]
364             var mmtas = [% ActionsLoop.json | $raw %]
365         [% END %]
366     </script>
367     [% Asset.js("js/marc_modification_templates.js") | $raw %]
368 [% END %]
369
370 [% INCLUDE 'intranet-bottom.inc' %]