Bug 15867: Move MARC modification templates JavaScript into separate file
[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_EDIT_ACTION = _("Edit action %s");
16     var MSG_MMT_UPDATE_ACTION = _("Update action");
17     //]]>
18 </script>
19 <script type="text/javascript" src="[% themelang %]/js/marc_modification_templates.js"></script>
20 </head>
21
22 <body id="tools_marc_modification_templates" class="tools">
23 [% INCLUDE 'header.inc' %]
24 [% INCLUDE 'cat-search.inc' %]
25
26 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC modification templates</div>
27
28 <div id="doc3" class="yui-t2">
29   <div id="bd">
30     <div id="yui-main">
31         <div class="yui-b">
32             <h2>MARC modification templates</h2>
33
34             [% IF error %]
35                 [% IF error == 'no_from_field' %]
36                     <div class="dialog message">Error: no field value specified.</div>
37                 [% END %]
38             [% END %]
39
40             [% IF ( TemplatesLoop ) %]
41
42                 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
43                     <label for="select_template">Template: </label>
44                     <select name="template_id" id="select_template" style="width:20em;">
45                         [% FOREACH TemplatesLoo IN TemplatesLoop %]
46                                                     [% IF ( TemplatesLoo.selected ) %]
47                             <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
48                                                     [% ELSE %]
49                             <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
50                                                     [% END %]
51                         [% END %]
52                     </select>
53                     <input type="hidden" name="op" value="select_template">
54                     <input type="submit" value="Go" />
55                 </form>
56
57                 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
58                     <input type="hidden" name="template_id" value="[% template_id %]" />
59                     <input type="hidden" name="op" value="delete_template">
60                     <input type="submit" value="Delete template" onClick="return confirmDelete()" />
61                 </form>
62
63
64                 [% IF ( ActionsLoop ) %]
65                     <table>
66                         <caption>Actions for this template</caption>
67
68                         <tr>
69                             <th>Change order</th>
70                             <th>Order</th>
71                             <th>Action</th>
72                             <th>Description</th>
73                             <th>&nbsp;</th>
74                             <th>&nbsp;</th>
75                         </tr>
76
77                         [% FOREACH ActionsLoo IN ActionsLoop %]
78                             <tr>
79                                 <td style="white-space:nowrap;">
80                                     <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 %]">
81                                     <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
82                                         </a>
83
84                                 <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 %]">
85                                     <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
86                                         </a>
87
88                                         <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 %]">
89                                     <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
90                                         </a>
91
92                                         <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 %]">
93                                     <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
94                                         </a>
95                                 </td>
96
97                                 <td>[% ActionsLoo.ordering %]</td>
98                                 <td>
99                                     [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
100                                     [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
101                                     [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
102                                     [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
103                                     [% IF ( ActionsLoo.action_copy_and_replace_field ) %] Copy and replace [% END %]
104
105                                     [% UNLESS ( ActionsLoo.action_update_field ) %]
106                                         [% IF ( ActionsLoo.field_number ) %]
107                                             1st
108                                         [% END %]
109                                     [% END %]
110
111                                     field
112
113                                     [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
114
115                                     [% IF ( ActionsLoo.field_value ) %]
116                                         with value <i>[% ActionsLoo.field_value %]</i>
117                                     [% END %]
118
119                                     [% IF ( ActionsLoo.to_field ) %]
120                                         to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
121
122                                         [% IF ( ActionsLoo.to_regex_search ) %]
123                                              using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
124                                         [% END %]
125                                     [% END %]
126
127                                     [% IF ( ActionsLoo.conditional ) %]
128                                         [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
129                                         [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
130
131                                         [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
132
133                                         [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
134                                         [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
135                                         [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
136                                         [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
137
138                                         [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
139                                         <strong>[% ActionsLoo.conditional_value %]</strong>
140                                         [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
141                                     [% END %]
142                                 </td>
143                                 <td>[% ActionsLoo.description %]</td>
144                                 <td><a href="#modaction" onclick='editAction(
145                                                     "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
146                                                     "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
147                                                     "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
148                                                     "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
149                                                     "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
150                                                     "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
151                                                     "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
152                                                     "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
153                                                     "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
154                                                     "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
155                                                     "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
156                                                     "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
157                                                     "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
158                                                     "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
159                                                     "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
160                                                     "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
161                                                     "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
162                                                     "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
163                                                     "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
164                                                 );updateAllEvery();'>Edit</a></td>
165                                 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
166                             </tr>
167                         [% END %]
168                     </table>
169                 [% ELSE %]
170                     <div class="dialog message"><p>There are no defined actions for this template.</p></div>
171                 [% END %]
172
173                 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
174                     <a name="modaction"></a>
175                     <fieldset>
176                         <legend id="modaction_legend">Add a new action</legend>
177                         <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>
178
179                         <select name="action" id="action" onchange="onActionChange(this);">
180                             <option value="delete_field">Delete</option>
181                             <option value="update_field">Add/Update</option>
182                             <option value="move_field">Move</option>
183                             <option value="copy_field">Copy</option>
184                             <option value="copy_and_replace_field">Copy and replace</option>
185                         </select>
186
187                         <span id="field_number_block">
188                             <select name="field_number" id="field_number">
189                                 <option value="0">All</option>
190                                 <option value="1">1st</option>
191                             </select>
192                         </span>
193
194                         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" />
195
196                         <span name="with_value_block" id="with_value_block" style="display:none;">
197                             with value <input type="text" name="field_value" id="field_value" />
198                         </span>
199
200                         <span name="to_field_block" id="to_field_block" style="display:none;">
201                             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" />
202
203                             <span name="to_field_regex_block" id="to_field_regex_block">
204                                 <sup>
205                                     <label for="to_field_regex">RegEx</label>
206                                     <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
207
208                                     <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
209                                         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" />
210                                     </span>
211                                 </sup>
212                             </span>
213                         </span>
214
215                         <p/>
216
217                         <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
218                             <option value="" selected="selected" />
219                             <option value="if">if</option>
220                             <option value="unless">unless</option>
221                         </select>
222
223                         <span name="conditional_block" id="conditional_block" style="display:none;">
224                             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" />
225
226                             <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
227                                 <option value="" />
228                                 <option value="exists">exists</option>
229                                 <option value="not_exists">doesn't exist</option>
230                                 <option value="equals">matches</option>
231                                 <option value="not_equals">doesn't match</option>
232                             </select>
233
234                             <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
235
236                                 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
237
238                                 <sup>
239                                     <label for="conditional_regex">RegEx</label>
240                                     <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
241                                 </sup>
242
243                             </span>
244                         </span>
245
246                         <input type="hidden" name="template_id" value="[% template_id %]" />
247                         <input type="hidden" name="mmta_id" id="mmta_id" />
248                         <input type="hidden" name="op" value="add_action" />
249
250                         <br/><br/>
251                         <label for="description">Description:</label>
252                         <input type="text" name="description" id="description" size="60" />
253
254                         <br/><br/>
255                         <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
256
257                     </fieldset>
258                 </form>
259
260             [% ELSE %]
261                 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
262             [% END %]
263
264             <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
265                 <fieldset>
266                     <legend>Create a new template</legend>
267
268                     <label for="template_name" class="required">Name: </label>
269                     <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
270                     <span class="required">Required</span>
271
272                     <input type="hidden" name="op" value="create_template" />
273                     <input type="submit" value="Create template" />
274
275                     [% IF ( template_id ) %]
276                         <input type="hidden" name="template_id" value="[% template_id %]" />
277                         <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
278                         <label for="duplicate_current_template">Duplicate current template</label>
279                     [% END %]
280                 </fieldset>
281             </form>
282         </div>
283     </div>
284
285     <div class="yui-b">
286         [% INCLUDE 'tools-menu.inc' %]
287     </div>
288   </div>
289 </div>
290 [% INCLUDE 'intranet-bottom.inc' %]