1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha › Tools › MARC modification templates</title>
3 [% INCLUDE 'doc-head-close.inc' %]
5 <script type="text/javascript">
7 $(document).ready(function() {
8 $('#select_template').find("input:submit").hide();
9 $('#select_template').change(function() {
10 $('#select_template').submit();
17 function onActionChange(selectObj) {
18 // get the index of the selected option
19 var idx = selectObj.selectedIndex;
21 // get the value of the selected option
22 var action = selectObj.options[idx].value;
26 show('field_number_block');
27 hide('with_value_block');
28 hide('to_field_block');
32 hide('field_number_block');
33 show('with_value_block');
34 hide('to_field_block');
38 show('field_number_block');
39 hide('with_value_block');
40 show('to_field_block');
44 show('field_number_block');
45 hide('with_value_block');
46 show('to_field_block');
52 function onConditionalChange(selectObj) {
53 // get the index of the selected option
54 var idx = selectObj.selectedIndex;
56 // get the value of the selected option
57 var action = selectObj.options[idx].value;
61 hide('conditional_block');
66 show('conditional_block');
71 function onConditionalComparisonChange(selectObj) {
72 // get the index of the selected option
73 var idx = selectObj.selectedIndex;
75 // get the value of the selected option
76 var action = selectObj.options[idx].value;
81 show('conditional_comparison_block');
85 hide('conditional_comparison_block');
90 function onToFieldRegexChange( checkboxObj ) {
91 if ( checkboxObj.checked ) {
92 show('to_field_regex_value_block');
94 hide('to_field_regex_value_block');
98 function onConditionalRegexChange( checkboxObj ) {
99 if ( checkboxObj.checked ) {
100 document.getElementById( 'match_regex_prefix' ).style.visibility='visible';
102 document.getElementById( 'match_regex_prefix' ).style.visibility='hidden';
106 function show(eltId) {
107 elt = document.getElementById( eltId );
108 elt.style.display='inline';
111 function hide(eltId) {
112 clearFormElements( eltId );
113 elt = document.getElementById( eltId );
114 elt.style.display='none';
117 function clearFormElements(divId) {
118 myBlock = document.getElementById( divId );
120 var inputElements = myBlock.getElementsByTagName( "input" );
121 for (var i = 0; i < inputElements.length; i++) {
122 switch( inputElements[i].type ) {
124 inputElements[i].value = '';
127 inputElements[i].checked = false;
132 var selectElements = myBlock.getElementsByTagName( "select" );
133 for (var i = 0; i < selectElements.length; i++) {
134 selectElements[i].selectedIndex = 0;
139 function confirmDelete() {
140 var agree = confirm("Are you sure you wish to delete this template?");
144 var modaction_legend_innerhtml;
145 var action_submit_value;
147 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
148 to_subfield, to_regex, conditional, conditional_field, conditional_subfield,
149 conditional_comparison, conditional_value, conditional_regex, description
151 document.getElementById('mmta_id').value = mmta_id;
153 setSelectByValue( 'action', action );
154 document.getElementById('action').onchange();
156 setSelectByValue( 'field_number', field_number );
158 document.getElementById('from_field').value = from_field;
159 document.getElementById('from_subfield').value = from_subfield;
160 document.getElementById('field_value').value = field_value;
161 document.getElementById('to_field').value = to_field;
162 document.getElementById('to_subfield').value = to_subfield;
163 document.getElementById('to_regex').value = to_regex;
165 document.getElementById('to_field_regex').checked = to_regex.length;
166 document.getElementById('to_field_regex').onchange();
168 setSelectByValue( 'conditional', conditional );
169 document.getElementById('conditional').onchange();
171 document.getElementById('conditional_field').value = conditional_field;
172 document.getElementById('conditional_subfield').value = conditional_subfield;
174 setSelectByValue( 'conditional_comparison', conditional_comparison );
175 document.getElementById('conditional_comparison').onchange();
177 document.getElementById('conditional_value').value = conditional_value;
179 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
181 document.getElementById('description').value = description;
183 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerhtml;
184 document.getElementById('modaction_legend').innerhtml = "Edit Action " + ordering;
186 window.action_submit_value = document.getElementById('action_submit').value;
187 document.getElementById('action_submit').value = "Update Action";
192 function cancelEditAction() {
193 document.getElementById('mmta_id').value = '';
195 setSelectByValue( 'action', 'delete_field' );
196 document.getElementById('action').onchange();
198 document.getElementById('from_field').value = '';
199 document.getElementById('from_subfield').value = '';
200 document.getElementById('field_value').value = '';
201 document.getElementById('to_field').value = '';
202 document.getElementById('to_subfield').value = '';
203 document.getElementById('to_regex').value = '';
205 document.getElementById('to_field_regex').checked = false;
206 document.getElementById('to_field_regex').onchange();
208 setSelectByValue( 'conditional', '' );
209 document.getElementById('conditional').onchange();
211 document.getElementById('conditional_field').value = '';
212 document.getElementById('conditional_subfield').value = '';
214 setSelectByValue( 'conditional_comparison', '' );
215 document.getElementById('conditional_comparison').onchange();
217 document.getElementById('conditional_value').value = '';
219 document.getElementById('conditional_regex').checked = false;
221 document.getElementById('modaction_legend').innerhtml = window.modaction_legend_innerhtml;
222 document.getElementById('action_submit').value = window.action_submit_value;
227 function setSelectByValue( selectId, value ) {
228 s = document.getElementById( selectId );
230 for ( i = 0; i < s.options.length; i++ ) {
231 if ( s.options[i].value == value ) {
242 [% INCLUDE 'header.inc' %]
243 [% INCLUDE 'cat-search.inc' %]
245 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › MARC modification templates</div>
247 <div id="doc3" class="yui-t2">
250 <h2>MARC modification templates</h2>
252 [% IF ( TemplatesLoop ) %]
254 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
255 <label for="select_template">Template: </label>
256 <select name="template_id" id="select_template" style="width:20em;">
257 [% FOREACH TemplatesLoo IN TemplatesLoop %]
258 [% IF ( TemplatesLoo.selected ) %]
259 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
261 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
265 <input type="hidden" name="op" value="select_template">
266 <input type="submit" value="Go" />
269 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
270 <input type="hidden" name="template_id" value="[% template_id %]" />
271 <input type="hidden" name="op" value="delete_template">
272 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
276 [% IF ( ActionsLoop ) %]
278 <caption>Actions for this template</caption>
281 <th>Change Order</th>
289 [% FOREACH ActionsLoo IN ActionsLoop %]
291 <td style="white-space:nowrap;">
292 <a title="Move Action Up" href="marc_modification_templates.pl?op=move_action&where=up&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
293 <img src="/intranet-tmpl/[% theme %]/img/go-up.png" border="0" alt="Go up" />
296 <a title="Move Action To Top" href="marc_modification_templates.pl?op=move_action&where=top&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
297 <img src="/intranet-tmpl/[% theme %]/img/go-top.png" border="0" alt="Go top" />
300 <a title="Move Action To Bottom" href="marc_modification_templates.pl?op=move_action&where=bottom&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
301 <img src="/intranet-tmpl/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
304 <a title="Move Action Down" href="marc_modification_templates.pl?op=move_action&where=down&template_id=[% ActionsLoo.template_id %]&mmta_id=[% ActionsLoo.mmta_id %]">
305 <img src="/intranet-tmpl/[% theme %]/img/go-down.png" border="0" alt="Go down" />
309 <td>[% ActionsLoo.ordering %]</td>
311 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
312 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
313 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
314 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
316 [% UNLESS ( ActionsLoo.action_update_field ) %]
317 [% IF ( ActionsLoo.field_number ) %]
324 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
326 [% IF ( ActionsLoo.field_value ) %]
327 with value <i>[% ActionsLoo.field_value %]</i>
330 [% IF ( ActionsLoo.to_field ) %]
331 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
333 [% IF ( ActionsLoo.to_regex ) %]
334 using RegEx s<strong>[% ActionsLoo.to_regex %]</strong>
338 [% IF ( ActionsLoo.conditional ) %]
339 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
340 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
342 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
344 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
345 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
346 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
347 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
349 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %]<strong>[% ActionsLoo.conditional_value %]</strong>
352 <td>[% ActionsLoo.description %]</td>
353 <td><a href="#modaction" onclick='editAction(
354 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
355 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
356 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
357 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
358 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
359 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
360 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
361 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
362 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
363 "[% ActionsLoo.to_regex |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
364 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
365 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
366 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
367 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
368 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
369 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
370 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
372 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
377 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
380 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
381 <a name="modaction"></a>
383 <legend id="modaction_legend">Add A New Action</legend>
385 <select name="action" id="action" onchange="onActionChange(this);">
386 <option value="delete_field">Delete</option>
387 <option value="update_field">Add/Update</option>
388 <option value="move_field">Move</option>
389 <option value="copy_field">Copy</option>
392 <span id="field_number_block">
393 <select name="field_number" id="field_number">
394 <option value="0">All</option>
395 <option value="1">1st</option>
399 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" />
401 <span name="with_value_block" id="with_value_block" style="display:none;">
402 with value <input type="text" name="field_value" id="field_value" />
405 <span name="to_field_block" id="to_field_block" style="display:none;">
406 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" />
408 <span name="to_field_regex_block" id="to_field_regex_block">
410 <label for="to_field_regex">RegEx</label>
411 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
413 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
414 s<input type="text" name="to_regex" id="to_regex" />
422 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
423 <option value="" selected />
424 <option value="if">if</option>
425 <option value="unless">unless</option>
428 <span name="conditional_block" id="conditional_block" style="display:none;">
429 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" />
431 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
433 <option value="exists">exists</option>
434 <option value="not_exists">doesn't exist</option>
435 <option value="equals">matches</option>
436 <option value="not_equals">doesn't match</option>
439 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
441 <span id="match_regex_prefix" style="visibility:hidden;">m</span><input type="text" id="conditional_value" name="conditional_value" />
444 <label for="conditional_regex">RegEx</label>
445 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
451 <input type="hidden" name="template_id" value="[% template_id %]" />
452 <input type="hidden" name="mmta_id" id="mmta_id" />
453 <input type="hidden" name="op" value="add_action" />
456 <label for="description">Description:</label>
457 <input type="text" name="description" id="description" size="60" />
460 <input id="action_submit" type="submit" value="Add Action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
466 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
469 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" >
471 <legend>Create a new template</legend>
473 <label for="template_name">Name: </label>
474 <input name="template_name" id="template_name" type="text" size="30" />
476 <input type="hidden" name="op" value="create_template" />
477 <input type="submit" value="Create template" />
479 [% IF ( template_id ) %]
480 <input type="hidden" name="template_id" value="[% template_id %]" />
481 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
482 <label for="duplicate_current_template">Duplicate current template</label>
490 [% INCLUDE 'tools-menu.inc' %]
493 [% INCLUDE 'intranet-bottom.inc' %]