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