<title>Koha › Cataloging › [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.js("lib/hc-sticky.js") | $raw %]
+[% INCLUDE 'select2.inc' %]
<script>
var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]";
+ $.fn.select2.defaults.set("width", "100%" );
</script>
-[% INCLUDE 'select2.inc' %]
[% Asset.js("js/cataloging.js") | $raw %]
-[% INCLUDE 'strings.inc' %]
[% Asset.js("js/browser.js") | $raw %]
<script>
var browser = KOHA.browser('[% searchid | html %]', parseInt('[% biblionumber | html %]', 10));
PopupZ3950();
});
+ $("#linkerbutton").click(function(){
+ AutomaticLinker();
+ });
+
$("#saverecord").click(function(){
$(".btn-group").removeClass("open");
onOption();
var onOption = function () {
return Check();
}
- [% END %]
+[% END %]
+
+/**
+* this function append button for create new authority if not found
+*/
+
+function addCreateAuthorityButton(tag_subfield_line, heading, tag_index) {
+ var title = _("Create authority");
+ var elem = $('<a href="#" title="' + title + '"><i class="fa fa-plus-circle"></i></a>');
+ tag_subfield_line.append(elem);
+ var tag_subfield_line_a = $('.subfield_line[id^=subfield' + heading.tag + 'a]').eq(tag_index);
+ var subfield_a = tag_subfield_line_a.children('.input_marceditor').eq(0);
+ var index = subfield_a.attr('id');
+ elem.click(function() {
+ var popup = window.open("", "new_auth_popup",'fullscreen,toolbar=false,scrollbars=yes');
+ if(popup !== null) {
+ // Create a new form that will be POSTed in the new window
+ var form = $('<form>').attr({
+ method: 'post',
+ action: "/cgi-bin/koha/authorities/authorities.pl",
+ target: "new_auth_popup"
+ });
+ //add the authtypecode
+ form.append($('<input>').attr({
+ type: 'hidden',
+ name: 'authtypecode',
+ value: heading.auth_type
+ }));
+ form.append($('<input>').attr({
+ type: 'hidden',
+ name: 'tagreport',
+ value: heading.tag_to_report
+ }));
+ form.append($('<input>').attr({
+ type: 'hidden',
+ name: 'tagbiblio',
+ value: heading.tag
+ }));
+ form.append($('<input>').attr({
+ type: 'hidden',
+ name: 'index',
+ value: index
+ }));
+ $('.tag[id^=tag_' + heading.tag + '_]').eq(tag_index).find(':input').each(function(){
+ form.append($('<input>').attr({
+ type: 'hidden',
+ name: this.name.split('_',4).join(''),
+ value: $(this).val()
+ }));
+ });
+ $('body').append(form);
+ form.submit();
+ form.remove();
+ }
+ return false;
+ });
+
+}
+
+/**
+ * Updates the authid for every heading field
+ * Adds visual feedback for the changes made on the form.
+ */
+function updateHeadingLinks(links) {
+ var current_tag = '';
+ var tag_index = 0;
+
+ // Delete the old message dialog and create a new one
+ $('#autolinker_dialog').remove();
+ var message_dialog = $('<div id="autolinker_dialog" class="dialog message"><strong>' + _("Automatic authority link results:") + '</strong><ul></ul></div>');
+ var message_dialog_ul = message_dialog.find('ul');
+
+ $.each(links, function(index, heading) {
+ if(current_tag == heading.tag) {
+ tag_index++;
+ }
+ else {
+ current_tag = heading.tag;
+ tag_index = 0;
+ }
+
+ // Find the $9 field to update
+ var tag_subfield_line = $('.subfield_line[id^=subfield' + heading.tag + '9]').eq(tag_index);
+ if( tag_subfield_line.length < 1 ){ return; }
+
+ var subfield = tag_subfield_line.find('.input_marceditor').eq(0);
+
+ // Delete the old status if one exists
+ tag_subfield_line.children('.subfield_status').remove();
+ // If the field wasn't modified. Skip it.
+ if(heading.status == 'UNCHANGED') {
+ return;
+ }
+
+
+ // Make the subfield line visible and update its value
+ tag_subfield_line.show();
+ subfield.val(heading.authid);
+
+ // Add the new status
+ var image = '<i class="fa fa-close no_matching_authority" </i> ';
+ var message = '';
+ var field_class = 'no_matching_authority_field';
+ switch(heading.status) {
+ case 'LOCAL_FOUND':
+ image = '<i class="fa fa-check matching_authority"</i> ';
+ message = _("A matching authority was found in the local database.");
+ field_class = 'matching_authority_field';
+ break;
+ case 'CREATED':
+ image = '<i class="fa fa-check matching_authority"></i> ';
+ message = _("No matching authority found. A new authority was created automatically.");
+ field_class = 'matching_authority_field';
+ break;
+ case 'MULTIPLE_MATCH':
+ message = _("More than one local match found. Possibly a duplicate authority!");
+ break;
+ case 'NONE_FOUND':
+ message = _("No matching authority found.");
+ break;
+ default:
+ message = heading.status;
+ break;
+ }
+
+ subfield[0].classList.add(field_class);
+ tag_subfield_line.find('i').each(function() {
+ this.remove();
+ });
+ tag_subfield_line.append(image);
+
+ // Add the message to the dialog
+ message_dialog_ul.append('<li><strong>' + heading.tag + '</strong> - ' + message + '</li>');
+
+ // Add a link to create a new authority if none was found
+ if(heading.status == 'NONE_FOUND' && tag_subfield_line.find('i').length == 1) {
+ addCreateAuthorityButton(tag_subfield_line, heading , tag_index);
+ }
+ });
+
+ if(message_dialog.find('li').length == 0) {
+ message_dialog_ul.append("<li>" + _("No authority link was changed.") + "</li>");
+ }
+ $('#addbibliotabs').before(message_dialog);
+}
+
+/**
+ * Use an ajax request to automatically find authority links for the current record
+ */
+function AutomaticLinker() {
+ // Show the Loading overlay
+ $("#loading").show();
+
+ // Remove fields that are completely empty
+ $('#f').find('.tag').each(function() {
+ var empty = true;
+ $(this).find('.input_marceditor').each(function() {
+ if($(this).val() != '') {
+ empty = false;
+ return false;
+ }
+ });
+ if(empty) {
+ UnCloneField($(this).attr('id'));
+ }
+ });
+
+ // Get all the form values to post via AJAX
+ var form_data = {};
+ $('#f').find(':input').each(function(){
+ form_data[this.name] = $(this).val();
+ });
+ delete form_data[''];
+
+ // Send the data to automatic_linker.pl
+ $.ajax({
+ url:'/cgi-bin/koha/svc/cataloguing/automatic_linker.pl',
+ type:'post',
+ data: form_data,
+ dataType: 'json',
+ error: function(xhr) {
+ alert("Error : \n" + xhr.responseText);
+ },
+ success: function(json) {
+ switch(json.status) {
+ case 'UNAUTHORIZED':
+ alert(_("Error : You do not have the permissions necessary to use this functionality."));
+ break;
+ case 'OK':
+ updateHeadingLinks(json.links);
+ break;
+ }
+ },
+ complete: function() {
+ $("#loading").hide();
+ }
+ });
+}
+
+
+function PopupMARCFieldDoc(field) {
+ [% IF Koha.Preference('marcfielddocurl') %]
+ var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]";
+ docurl = docurl.replace("{MARC}", "[% marcflavour | html %]");
+ docurl = docurl.replace("{FIELD}", ""+field);
+ docurl = docurl.replace("{LANG}", "[% lang | html %]");
+ window.open(docurl);
+ [% ELSIF ( marcflavour == 'MARC21' ) %]
+ _MARC21FieldDoc(field);
+ [% ELSIF ( marcflavour == 'UNIMARC' ) %]
+ _UNIMARCFieldDoc(field);
+ [% END %]
+}
function confirmnotdup(redirect){
$("#confirm_not_duplicate").attr("value","1");
$("#redirect").attr("value",redirect);
</script>
[% Asset.css("css/addbiblio.css") | $raw %]
-
</head>
<body id="cat_addbiblio" class="cat">
[% ELSE %]
<div class="btn-group"><a class="btn btn-default" href="#" id="z3950search"><i class="fa fa-search"></i> Z39.50/SRU search</a></div>
[% END %]
+ [% IF ( CAN_user_editauthorities ) %]
+ <div class="btn-group"><a class="btn btn-default" href="#" id="linkerbutton"><i class="fa fa-refresh"></i> Link authorities automatically</a></div>
+ [% END %]
[% END %]
<div class="btn-group">
[% FOREACH subfield_loo IN innerloo.subfield_loop %]
<!-- One line on the marc editor -->
<li class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
+ <div class="subfieldcode">
+ <input type="text"
+ title="[% subfield_loo.marc_lib | $raw %]"
+ style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
+ name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
+ value="[% subfield_loo.subfield | html %]"
+ size="1"
+ maxlength="1"
+ class="flat"
+ tabindex="0" />
+ </div>
[% UNLESS advancedMARCEditor %]
- [% IF ( subfield_loo.fixedfield ) %]
- <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" style="display:none;" class="labelsubfield">
+ [% IF ( subfield_loo.mandatory ) %]
+ <div class="subfield subfield_mandatory">
+ [% ELSIF ( subfield_loo.important ) %]
+ <div class="subfield subfield_important">
[% ELSE %]
- <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
+ <div class="subfield">
[% END %]
- [% END %]
-
- <span class="subfieldcode">
- <input type="text"
- title="[% subfield_loo.marc_lib | $raw %]"
- style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
- name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
- value="[% subfield_loo.subfield | html %]"
- size="1"
- maxlength="1"
- class="flat"
- tabindex="0" />
- </span>
-
- [% UNLESS advancedMARCEditor %]
- [% IF ( subfield_loo.mandatory ) %]
- <span class="subfield subfield_mandatory">
- [% ELSIF ( subfield_loo.important ) %]
- <span class="subfield subfield_important">
+ [% IF ( subfield_loo.fixedfield ) %]
+ <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" style="display:none;" class="labelsubfield">
[% ELSE %]
- <span class="subfield">
+ <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
[% END %]
[% subfield_loo.marc_lib | $raw %]
- </span>
- </label>
+ </label>
+ </div>
[% END %]
[% SET mv = subfield_loo.marc_value %]
- [% IF ( mv.type == 'text' ) %]
- [% IF ( mv.readonly == 1 ) %]
- <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor readonly" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" readonly="readonly" />
- [% ELSE %]
- <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
- [% END %]
-
- [% IF ( mv.authtype ) %]
- <span class="subfield_controls"><a href="#" class="buttonDot tag_editor" onclick="openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtype | html -%]','biblio'); return false;" tabindex="1" title="Tag editor">Tag editor</a></span>
- [% END %]
- [% ELSIF ( mv.type == 'text_complex' ) %]
- <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor framework_plugin" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
- <span class="subfield_controls">
- [% IF mv.noclick %]
- <span class="buttonDot tag_editor disabled" tabindex="-1" title="Field autofilled by plugin"></span>
+ <div id="field_marceditor[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]" class="field_marceditor">
+ [% IF ( mv.type == 'text' ) %]
+ [% IF ( mv.readonly == 1 ) %]
+ <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor readonly" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" readonly="readonly" />
[% ELSE %]
- [% IF mv.plugin == "upload.pl" %]
- <a href="#" id="buttonDot_[% mv.id | html %]" class="tag_editor upload framework_plugin" tabindex="1"><i class="fa fa-upload" aria-hidden="true"></i> Upload</a>
- [% ELSE %]
- <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor framework_plugin" tabindex="1" title="Tag editor">Tag editor</a>
- [% END %]
+ <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
[% END %]
- </span>
- [% mv.javascript | $raw %]
- [% ELSIF ( mv.type == 'hidden' ) %]
- <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
- [% ELSIF ( mv.type == 'textarea' ) %]
- <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
- [% ELSIF ( mv.type == 'select' ) %]
+
+ [% ELSIF ( mv.type == 'text_complex' ) %]
+ <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor framework_plugin" tabindex="1" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" />
+ [% mv.javascript | $raw %]
+ [% ELSIF ( mv.type == 'hidden' ) %]
+ <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="[%- mv.size | html -%]" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
+ [% ELSIF ( mv.type == 'textarea' ) %]
+ <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
+ [% ELSIF ( mv.type == 'select' ) %]
[% IF mv.category AND CAN_user_parameters_manage_auth_values %]
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]">
[% ELSE %]
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
[% END %]
- [% FOREACH aval IN mv.values %]
- [% IF aval == mv.default %]
- <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
- [% ELSE %]
- <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
+ [% FOREACH aval IN mv.values %]
+ [% IF aval == mv.default %]
+ <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
+ [% ELSE %]
+ <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
+ [% END %]
[% END %]
- [% END %]
- </select>
- [% END # /IF (mv.type...) %]
+ </select>
+ [% END # /IF (mv.type...) %]
+ </div>
[% IF ( subfield_loo.mandatory ) %]
- <span class="required">Required</span>
+ <div class="subfield_loop_mandatory">
+ <span class="required">Required</span>
+ </div>
[% ELSIF ( subfield_loo.important ) %]
- <span class="important">Important</span>
+ <div class="subfield_loop_mandatory">
+ <span class="important">Important</span>
+ </div>
[% END %]
- <span class="subfield_controls">
+ <div class="subfield_controls">
+ [% IF ( mv.type == 'text' ) %]
+ [% IF ( mv.authtype ) %]
+ <a href="#" class="buttonDot tag_editor" onclick="openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtype | html -%]','biblio'); return false;" tabindex="1" title="Tag editor">Tag editor</a>
+ [% END %]
+ [% ELSIF ( mv.type == 'text_complex' ) %]
+ [% IF mv.noclick %]
+ <span class="buttonDot tag_editor disabled" tabindex="-1" title="Field autofilled by plugin"></span>
+ [% ELSE %]
+ [% IF mv.plugin == "upload.pl" %]
+ <a href="#" id="buttonDot_[% mv.id | html %]" class="tag_editor upload framework_plugin" tabindex="1"><i class="fa fa-upload" aria-hidden="true"></i> Upload</a>
+ [% ELSE %]
+ <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor framework_plugin" tabindex="1" title="Tag editor">Tag editor</a>
+ [% END %]
+ [% END %]
+ </span>
+ [% END %]
[% IF ( subfield_loo.repeatable ) %]
<a href="#" class="buttonPlus" tabindex="1" onclick="CloneSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]','[% advancedMARCEditor | html %]'); return false;">
<img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
<img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
</a>
[% END %]
- </span>
+ </div>
</li> <!-- /.subfield_line -->
<!-- End of the line -->
[% END # /FOREACH subfield_loop %]