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();
12 $("span.match_regex_prefix" ).hide();
13 $("span.match_regex_suffix" ).hide();
15 $("#add_action").submit(function(){
16 var action = $("#action").val();
17 if ( action == 'move_field' || action == 'copy_field' ) {
18 if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) {
19 alert(_("Both subfield values should be filled or empty."));
22 if ( $("#to_field").val().length <= 0 ) {
23 alert(_("The destination should be filled."));
27 if ( action == 'update_field' ) {
28 if ( $("#from_subfield").val().length <= 0 ) {
29 alert(_("The source subfield should be filled for update."));
33 if ( $("#from_field").val().length <= 0 ) {
34 alert(_("The source field should be filled."));
44 function updateWarnings(){
45 if ( $("#conditional_field").is(":visible") ) {
46 if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
47 $("#warning_multivalued").show();
49 $("#warning_multivalued").hide();
54 function onActionChange(selectObj) {
55 // get the index of the selected option
56 var idx = selectObj.selectedIndex;
58 // get the value of the selected option
59 var action = selectObj.options[idx].value;
63 show('field_number_block');
64 hide('with_value_block');
65 hide('to_field_block');
69 hide('field_number_block');
70 show('with_value_block');
71 hide('to_field_block');
75 show('field_number_block');
76 hide('with_value_block');
77 show('to_field_block');
81 show('field_number_block');
82 hide('with_value_block');
83 show('to_field_block');
89 function onConditionalChange(selectObj) {
90 // get the index of the selected option
91 var idx = selectObj.selectedIndex;
93 // get the value of the selected option
94 var action = selectObj.options[idx].value;
98 hide('conditional_block');
103 show('conditional_block');
108 function onConditionalComparisonChange(selectObj) {
109 // get the index of the selected option
110 var idx = selectObj.selectedIndex;
112 // get the value of the selected option
113 var action = selectObj.options[idx].value;
118 show('conditional_comparison_block');
122 hide('conditional_comparison_block');
127 function onToFieldRegexChange( checkboxObj ) {
128 if ( checkboxObj.checked ) {
129 show('to_field_regex_value_block');
131 hide('to_field_regex_value_block');
135 function onConditionalRegexChange( checkboxObj ) {
136 if ( checkboxObj.checked ) {
137 $("span.match_regex_prefix" ).show();
138 $("span.match_regex_suffix" ).show();
140 $("span.match_regex_prefix" ).hide();
141 $("span.match_regex_suffix" ).hide();
145 function show(eltId) {
146 elt = document.getElementById( eltId );
147 elt.style.display='inline';
150 function hide(eltId) {
151 clearFormElements( eltId );
152 elt = document.getElementById( eltId );
153 elt.style.display='none';
156 function clearFormElements(divId) {
157 myBlock = document.getElementById( divId );
159 var inputElements = myBlock.getElementsByTagName( "input" );
160 for (var i = 0; i < inputElements.length; i++) {
161 switch( inputElements[i].type ) {
163 inputElements[i].value = '';
166 inputElements[i].checked = false;
171 var selectElements = myBlock.getElementsByTagName( "select" );
172 for (var i = 0; i < selectElements.length; i++) {
173 selectElements[i].selectedIndex = 0;
178 function confirmDelete() {
179 var agree = confirm(_("Are you sure you wish to delete this template?"));
183 var modaction_legend_innerhtml;
184 var action_submit_value;
186 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
187 to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
188 conditional_comparison, conditional_value, conditional_regex, description
190 document.getElementById('mmta_id').value = mmta_id;
192 setSelectByValue( 'action', action );
193 document.getElementById('action').onchange();
195 setSelectByValue( 'field_number', field_number );
197 document.getElementById('from_field').value = from_field;
198 document.getElementById('from_subfield').value = from_subfield;
199 document.getElementById('field_value').value = field_value;
200 document.getElementById('to_field').value = to_field;
201 document.getElementById('to_subfield').value = to_subfield;
202 $("#to_regex_search").val(to_regex_search);
203 $("#to_regex_replace").val(to_regex_replace);
204 $("#to_regex_modifiers").val(to_regex_modifiers);
206 document.getElementById('to_field_regex').checked = conditional_regex.length;
207 document.getElementById('to_field_regex').onchange();
209 setSelectByValue( 'conditional', conditional );
210 document.getElementById('conditional').onchange();
212 document.getElementById('conditional_field').value = conditional_field;
213 document.getElementById('conditional_subfield').value = conditional_subfield;
215 setSelectByValue( 'conditional_comparison', conditional_comparison );
216 document.getElementById('conditional_comparison').onchange();
218 document.getElementById('conditional_value').value = conditional_value;
220 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
222 document.getElementById('description').value = description;
224 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
225 document.getElementById('modaction_legend').innerHTML = _("Edit action %s").format(ordering);
227 window.action_submit_value = document.getElementById('action_submit').value;
228 document.getElementById('action_submit').value = _("Update action");
233 function cancelEditAction() {
234 document.getElementById('mmta_id').value = '';
236 setSelectByValue( 'action', 'delete_field' );
237 document.getElementById('action').onchange();
239 document.getElementById('from_field').value = '';
240 document.getElementById('from_subfield').value = '';
241 document.getElementById('field_value').value = '';
242 document.getElementById('to_field').value = '';
243 document.getElementById('to_subfield').value = '';
244 $("#to_regex_search").val("");
245 $("#to_regex_replace").val("");
246 $("#to_regex_modifiers").val("");
248 document.getElementById('to_field_regex').checked = false;
249 document.getElementById('to_field_regex').onchange();
251 setSelectByValue( 'conditional', '' );
252 document.getElementById('conditional').onchange();
254 document.getElementById('conditional_field').value = '';
255 document.getElementById('conditional_subfield').value = '';
257 setSelectByValue( 'conditional_comparison', '' );
258 document.getElementById('conditional_comparison').onchange();
260 document.getElementById('conditional_value').value = '';
262 document.getElementById('conditional_regex').checked = false;
264 document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
265 document.getElementById('action_submit').value = window.action_submit_value;
270 function setSelectByValue( selectId, value ) {
271 s = document.getElementById( selectId );
273 for ( i = 0; i < s.options.length; i++ ) {
274 if ( s.options[i].value == value ) {
285 [% INCLUDE 'header.inc' %]
286 [% INCLUDE 'cat-search.inc' %]
288 <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>
290 <div id="doc3" class="yui-t2">
294 <h2>MARC modification templates</h2>
297 [% IF error == 'no_from_field' %]
298 <div class="dialog message">Error: no field value specified.</div>
302 [% IF ( TemplatesLoop ) %]
304 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
305 <label for="select_template">Template: </label>
306 <select name="template_id" id="select_template" style="width:20em;">
307 [% FOREACH TemplatesLoo IN TemplatesLoop %]
308 [% IF ( TemplatesLoo.selected ) %]
309 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
311 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
315 <input type="hidden" name="op" value="select_template">
316 <input type="submit" value="Go" />
319 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
320 <input type="hidden" name="template_id" value="[% template_id %]" />
321 <input type="hidden" name="op" value="delete_template">
322 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
326 [% IF ( ActionsLoop ) %]
328 <caption>Actions for this template</caption>
331 <th>Change order</th>
339 [% FOREACH ActionsLoo IN ActionsLoop %]
341 <td style="white-space:nowrap;">
342 <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 %]">
343 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
346 <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 %]">
347 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
350 <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 %]">
351 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
354 <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 %]">
355 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
359 <td>[% ActionsLoo.ordering %]</td>
361 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
362 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
363 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
364 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
366 [% UNLESS ( ActionsLoo.action_update_field ) %]
367 [% IF ( ActionsLoo.field_number ) %]
374 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
376 [% IF ( ActionsLoo.field_value ) %]
377 with value <i>[% ActionsLoo.field_value %]</i>
380 [% IF ( ActionsLoo.to_field ) %]
381 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
383 [% IF ( ActionsLoo.to_regex_search ) %]
384 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
388 [% IF ( ActionsLoo.conditional ) %]
389 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
390 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
392 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
394 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
395 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
396 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
397 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
399 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
400 <strong>[% ActionsLoo.conditional_value %]</strong>
401 [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
404 <td>[% ActionsLoo.description %]</td>
405 <td><a href="#modaction" onclick='editAction(
406 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
407 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
408 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
409 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
410 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
411 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
412 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
413 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
414 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
415 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
416 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
417 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
418 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
419 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
420 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
421 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
422 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
423 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
424 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
426 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
431 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
434 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
435 <a name="modaction"></a>
437 <legend id="modaction_legend">Add a new action</legend>
438 <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>
440 <select name="action" id="action" onchange="onActionChange(this);">
441 <option value="delete_field">Delete</option>
442 <option value="update_field">Add/Update</option>
443 <option value="move_field">Move</option>
444 <option value="copy_field">Copy</option>
447 <span id="field_number_block">
448 <select name="field_number" id="field_number">
449 <option value="0">All</option>
450 <option value="1">1st</option>
454 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" />
456 <span name="with_value_block" id="with_value_block" style="display:none;">
457 with value <input type="text" name="field_value" id="field_value" />
460 <span name="to_field_block" id="to_field_block" style="display:none;">
461 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" />
463 <span name="to_field_regex_block" id="to_field_regex_block">
465 <label for="to_field_regex">RegEx</label>
466 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
468 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
469 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" />
477 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
478 <option value="" selected="selected" />
479 <option value="if">if</option>
480 <option value="unless">unless</option>
483 <span name="conditional_block" id="conditional_block" style="display:none;">
484 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" />
486 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
488 <option value="exists">exists</option>
489 <option value="not_exists">doesn't exist</option>
490 <option value="equals">matches</option>
491 <option value="not_equals">doesn't match</option>
494 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
496 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
499 <label for="conditional_regex">RegEx</label>
500 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
506 <input type="hidden" name="template_id" value="[% template_id %]" />
507 <input type="hidden" name="mmta_id" id="mmta_id" />
508 <input type="hidden" name="op" value="add_action" />
511 <label for="description">Description:</label>
512 <input type="text" name="description" id="description" size="60" />
515 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
521 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
524 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
526 <legend>Create a new template</legend>
528 <label for="template_name" class="required">Name: </label>
529 <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
530 <span class="required">Required</span>
532 <input type="hidden" name="op" value="create_template" />
533 <input type="submit" value="Create template" />
535 [% IF ( template_id ) %]
536 <input type="hidden" name="template_id" value="[% template_id %]" />
537 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
538 <label for="duplicate_current_template">Duplicate current template</label>
546 [% INCLUDE 'tools-menu.inc' %]
550 [% INCLUDE 'intranet-bottom.inc' %]