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."));
26 if ( ( $("#to_field").val() <= 10 && $("#to_subfield").val().length > 0 ) ||
27 ( $("#from_field").val() <= 10 && $("#from_subfield").val().length > 0 ) ) {
28 alert(_("If the field is a control field, the subfield should be empty"));
31 if ( ( $("#from_field").val() <= 10 && $("#to_subfield").val().length == 0 ) ||
32 ( $("#to_field").val() <= 10 && $("#from_subfield").val().length == 0 ) ) {
33 alert(_("A control field cannot be used with a regular field."));
37 if ( action == 'update_field' ) {
38 if ( $("#from_subfield").val().length <= 0 ) {
39 alert(_("The source subfield should be filled for update."));
43 if ( $("#from_field").val().length <= 0 ) {
44 alert(_("The source field should be filled."));
49 $("#conditional_field,#from_field").change(function(){
57 function updateAllEvery(){
58 if ( $("#conditional_field").is(":visible") ) {
59 if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) {
60 $("#field_number option[value='0']").html(_("Every"));
62 $("#field_number option[value='0']").html(_("All"));
67 function onActionChange(selectObj) {
68 // get the index of the selected option
69 var idx = selectObj.selectedIndex;
71 // get the value of the selected option
72 var action = selectObj.options[idx].value;
76 show('field_number_block');
77 hide('with_value_block');
78 hide('to_field_block');
82 hide('field_number_block');
83 show('with_value_block');
84 hide('to_field_block');
88 show('field_number_block');
89 hide('with_value_block');
90 show('to_field_block');
94 show('field_number_block');
95 hide('with_value_block');
96 show('to_field_block');
102 function onConditionalChange(selectObj) {
103 // get the index of the selected option
104 var idx = selectObj.selectedIndex;
106 // get the value of the selected option
107 var action = selectObj.options[idx].value;
111 hide('conditional_block');
116 show('conditional_block');
121 function onConditionalComparisonChange(selectObj) {
122 // get the index of the selected option
123 var idx = selectObj.selectedIndex;
125 // get the value of the selected option
126 var action = selectObj.options[idx].value;
131 show('conditional_comparison_block');
135 hide('conditional_comparison_block');
140 function onToFieldRegexChange( checkboxObj ) {
141 if ( checkboxObj.checked ) {
142 show('to_field_regex_value_block');
144 hide('to_field_regex_value_block');
148 function onConditionalRegexChange( checkboxObj ) {
149 if ( checkboxObj.checked ) {
150 $("span.match_regex_prefix" ).show();
151 $("span.match_regex_suffix" ).show();
153 $("span.match_regex_prefix" ).hide();
154 $("span.match_regex_suffix" ).hide();
158 function show(eltId) {
159 elt = document.getElementById( eltId );
160 elt.style.display='inline';
163 function hide(eltId) {
164 clearFormElements( eltId );
165 elt = document.getElementById( eltId );
166 elt.style.display='none';
169 function clearFormElements(divId) {
170 myBlock = document.getElementById( divId );
172 var inputElements = myBlock.getElementsByTagName( "input" );
173 for (var i = 0; i < inputElements.length; i++) {
174 switch( inputElements[i].type ) {
176 inputElements[i].value = '';
179 inputElements[i].checked = false;
184 var selectElements = myBlock.getElementsByTagName( "select" );
185 for (var i = 0; i < selectElements.length; i++) {
186 selectElements[i].selectedIndex = 0;
191 function confirmDelete() {
192 var agree = confirm(_("Are you sure you wish to delete this template?"));
196 var modaction_legend_innerhtml;
197 var action_submit_value;
199 function editAction( mmta_id, ordering, action, field_number, from_field, from_subfield, field_value, to_field,
200 to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
201 conditional_comparison, conditional_value, conditional_regex, description
203 document.getElementById('mmta_id').value = mmta_id;
205 setSelectByValue( 'action', action );
206 document.getElementById('action').onchange();
208 setSelectByValue( 'field_number', field_number );
210 document.getElementById('from_field').value = from_field;
211 document.getElementById('from_subfield').value = from_subfield;
212 document.getElementById('field_value').value = field_value;
213 document.getElementById('to_field').value = to_field;
214 document.getElementById('to_subfield').value = to_subfield;
215 $("#to_regex_search").val(to_regex_search);
216 $("#to_regex_replace").val(to_regex_replace);
217 $("#to_regex_modifiers").val(to_regex_modifiers);
219 document.getElementById('to_field_regex').checked = conditional_regex.length;
220 document.getElementById('to_field_regex').onchange();
222 setSelectByValue( 'conditional', conditional );
223 document.getElementById('conditional').onchange();
225 document.getElementById('conditional_field').value = conditional_field;
226 document.getElementById('conditional_subfield').value = conditional_subfield;
228 setSelectByValue( 'conditional_comparison', conditional_comparison );
229 document.getElementById('conditional_comparison').onchange();
231 document.getElementById('conditional_value').value = conditional_value;
233 document.getElementById('conditional_regex').checked = parseInt( conditional_regex );
235 document.getElementById('description').value = description;
237 window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
238 document.getElementById('modaction_legend').innerHTML = _("Edit action %s").format(ordering);
240 window.action_submit_value = document.getElementById('action_submit').value;
241 document.getElementById('action_submit').value = _("Update action");
246 function cancelEditAction() {
247 document.getElementById('mmta_id').value = '';
249 setSelectByValue( 'action', 'delete_field' );
250 document.getElementById('action').onchange();
252 document.getElementById('from_field').value = '';
253 document.getElementById('from_subfield').value = '';
254 document.getElementById('field_value').value = '';
255 document.getElementById('to_field').value = '';
256 document.getElementById('to_subfield').value = '';
257 $("#to_regex_search").val("");
258 $("#to_regex_replace").val("");
259 $("#to_regex_modifiers").val("");
261 document.getElementById('to_field_regex').checked = false;
262 document.getElementById('to_field_regex').onchange();
264 setSelectByValue( 'conditional', '' );
265 document.getElementById('conditional').onchange();
267 document.getElementById('conditional_field').value = '';
268 document.getElementById('conditional_subfield').value = '';
270 setSelectByValue( 'conditional_comparison', '' );
271 document.getElementById('conditional_comparison').onchange();
273 document.getElementById('conditional_value').value = '';
275 document.getElementById('conditional_regex').checked = false;
277 document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
278 document.getElementById('action_submit').value = window.action_submit_value;
283 function setSelectByValue( selectId, value ) {
284 s = document.getElementById( selectId );
286 for ( i = 0; i < s.options.length; i++ ) {
287 if ( s.options[i].value == value ) {
298 [% INCLUDE 'header.inc' %]
299 [% INCLUDE 'cat-search.inc' %]
301 <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>
303 <div id="doc3" class="yui-t2">
307 <h2>MARC modification templates</h2>
310 [% IF error == 'no_from_field' %]
311 <div class="dialog message">Error: no field value specified.</div>
315 [% IF ( TemplatesLoop ) %]
317 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
318 <label for="select_template">Template: </label>
319 <select name="template_id" id="select_template" style="width:20em;">
320 [% FOREACH TemplatesLoo IN TemplatesLoop %]
321 [% IF ( TemplatesLoo.selected ) %]
322 <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
324 <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
328 <input type="hidden" name="op" value="select_template">
329 <input type="submit" value="Go" />
332 <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
333 <input type="hidden" name="template_id" value="[% template_id %]" />
334 <input type="hidden" name="op" value="delete_template">
335 <input type="submit" value="Delete template" onClick="return confirmDelete()" />
339 [% IF ( ActionsLoop ) %]
341 <caption>Actions for this template</caption>
344 <th>Change order</th>
352 [% FOREACH ActionsLoo IN ActionsLoop %]
354 <td style="white-space:nowrap;">
355 <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 %]">
356 <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
359 <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 %]">
360 <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
363 <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 %]">
364 <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
367 <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 %]">
368 <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
372 <td>[% ActionsLoo.ordering %]</td>
374 [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
375 [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
376 [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
377 [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
379 [% UNLESS ( ActionsLoo.action_update_field ) %]
380 [% IF ( ActionsLoo.field_number ) %]
387 [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
389 [% IF ( ActionsLoo.field_value ) %]
390 with value <i>[% ActionsLoo.field_value %]</i>
393 [% IF ( ActionsLoo.to_field ) %]
394 to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
396 [% IF ( ActionsLoo.to_regex_search ) %]
397 using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
401 [% IF ( ActionsLoo.conditional ) %]
402 [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
403 [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
405 [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
407 [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
408 [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
409 [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
410 [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
412 [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
413 <strong>[% ActionsLoo.conditional_value %]</strong>
414 [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
417 <td>[% ActionsLoo.description %]</td>
418 <td><a href="#modaction" onclick='editAction(
419 "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
420 "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
421 "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
422 "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
423 "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
424 "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
425 "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
426 "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
427 "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
428 "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
429 "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
430 "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
431 "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
432 "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
433 "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
434 "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
435 "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
436 "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
437 "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
439 <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]">Delete</a></td>
444 <div class="dialog message"><p>There are no defined actions for this template.</p></div>
447 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
448 <a name="modaction"></a>
450 <legend id="modaction_legend">Add a new action</legend>
451 <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>
453 <select name="action" id="action" onchange="onActionChange(this);">
454 <option value="delete_field">Delete</option>
455 <option value="update_field">Add/Update</option>
456 <option value="move_field">Move</option>
457 <option value="copy_field">Copy</option>
460 <span id="field_number_block">
461 <select name="field_number" id="field_number">
462 <option value="0">All</option>
463 <option value="1">1st</option>
467 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" />
469 <span name="with_value_block" id="with_value_block" style="display:none;">
470 with value <input type="text" name="field_value" id="field_value" />
473 <span name="to_field_block" id="to_field_block" style="display:none;">
474 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" />
476 <span name="to_field_regex_block" id="to_field_regex_block">
478 <label for="to_field_regex">RegEx</label>
479 <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
481 <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
482 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" />
490 <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
491 <option value="" selected="selected" />
492 <option value="if">if</option>
493 <option value="unless">unless</option>
496 <span name="conditional_block" id="conditional_block" style="display:none;">
497 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" />
499 <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
501 <option value="exists">exists</option>
502 <option value="not_exists">doesn't exist</option>
503 <option value="equals">matches</option>
504 <option value="not_equals">doesn't match</option>
507 <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
509 <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
512 <label for="conditional_regex">RegEx</label>
513 <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
519 <input type="hidden" name="template_id" value="[% template_id %]" />
520 <input type="hidden" name="mmta_id" id="mmta_id" />
521 <input type="hidden" name="op" value="add_action" />
524 <label for="description">Description:</label>
525 <input type="text" name="description" id="description" size="60" />
528 <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
534 <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
537 <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
539 <legend>Create a new template</legend>
541 <label for="template_name" class="required">Name: </label>
542 <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
543 <span class="required">Required</span>
545 <input type="hidden" name="op" value="create_template" />
546 <input type="submit" value="Create template" />
548 [% IF ( template_id ) %]
549 <input type="hidden" name="template_id" value="[% template_id %]" />
550 <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
551 <label for="duplicate_current_template">Duplicate current template</label>
559 [% INCLUDE 'tools-menu.inc' %]
563 [% INCLUDE 'intranet-bottom.inc' %]