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