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