Bug 11961 - Add a "Z39.50 search" button to the authority creation and modification...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / authorities / authorities.tt
index 4df6746..693b61e 100644 (file)
@@ -1,20 +1,52 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Authorities &rsaquo; [% IF ( authid ) %]Modify authority #[% authid %] ([% authtypetext %])[% ELSE %]Adding authority ([% authtypetext %])[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/yui/plugins/bubbling-min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
 <script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script>
 
 <script type="text/javascript">
 //<![CDATA[
-
+    $(window).load(function(){
+        $("#loading").hide();
+    });
         $(document).ready(function() {
         $('#authoritytabs').tabs();
-
-               $("#f").submit(function(){
-                       return $(this).Check();
+        $('#toolbar').fixFloat();
+        $("#addauth").click(function(){
+            if(Check()){
+                $("#f").submit();
+            }
                });
+        $("#z3950submit").click(function(){
+            if (confirm(_("Please note that this Z39.50 search could replace the current record."))){
+                var strQuery = GetZ3950Terms();
+                if(strQuery){
+                    window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
+                }
+            }
+            return false;
+        });
         });
 
+/**
+ * check if z3950 mandatories are set or not
+ */
+function GetZ3950Terms(){
+ var strQuery="&authtypecode="+document.forms['f'].authtypecode.value;
+    var mandatories = new Array();
+    var mandatories_label = new Array();
+    [% FOREACH BIG_LOO IN BIG_LOOP %][% FOREACH innerloo IN BIG_LOO.innerloop %][% FOREACH subfield_loo IN innerloo.subfield_loop %][% IF ( subfield_loo.z3950_mandatory ) %]mandatories.push("[% subfield_loo.id %]");
+        mandatories_label.push("[% subfield_loo.z3950_mandatory %]");[% END %][% END %][% END %][% END %]
+
+    for(var i=0,len=mandatories.length; i<len ; i++){
+        var field_value = document.getElementById(mandatories[i]).value;
+        if( field_value ){
+            strQuery += "&"+mandatories_label[i]+"="+field_value;
+        }
+    }
+    return strQuery;
+}
+
 /**
  * check if mandatory subfields are written
  */
@@ -42,7 +74,7 @@ function AreMandatoriesNotOk(){
         // alert (id_string);
         if( ! $("#" + id_string).val() ){
             $("#" + id_string).attr('class','subfield_not_filled').focus();
-            StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
+            StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n";
         }
     }
     
@@ -75,7 +107,7 @@ function AreMandatoriesNotOk(){
        
        if(isempty){
                flag = 1;
-                       StrAlert += "\t* Field " + arr[0] + _(" is mandatory, at least one of its subfields must be filled") + "\n";
+                StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
        }
        
     }
@@ -87,10 +119,6 @@ function AreMandatoriesNotOk(){
     return false;
 }
 
-/**
- * 
- * 
- */
 function Check(){
     var StrAlert = AreMandatoriesNotOk();
     if( ! StrAlert ){
@@ -102,44 +130,6 @@ function Check(){
     }
 }
 
-
-// returns the subfieldcode based upon subfieldid writing
-function getSubfieldcode(tagsubfieldid){
-    // 3 : tag +3 : tagnumber +4 : number of _ +8 subfield -1 begins at 0  
-    return tagsubfieldid.substr(3+3+4+8-1,1);
-}
-
-// Take the base of tagsubfield information (removing the subfieldcodes and subfieldindexes)
-// returns the filter
-function getTagInputnameFilter(tagsubfieldid){
-    var tagsubfield=tagsubfieldid.substr(0,tagsubfieldid.lastIndexOf("_"));  
-    var tagcode=tagsubfield.substr(tagsubfield.lastIndexOf("_"));
-    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
-    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
-    tagsubfield=tagsubfield+"_."+tagcode;
-    return tagsubfield;  
-}
-
-function openAuth(tagsubfieldid,authtype) {
-    // let's take the base of tagsubfield information (removing the indexes and the codes
-    var element=document.getElementById(tagsubfieldid);
-    var tagsubfield=getTagInputnameFilter(tagsubfieldid);
-    var elementsubfcode=getSubfieldcode(element.name);
-    var mainmainstring=element.value;
-    var mainstring="";  
-    var inputs = element.parentNode.parentNode.getElementsByTagName("input");
-
-    for (var myindex =0; myindex<inputs.length;myindex++){
-        if (inputs[myindex].name && inputs[myindex].name.match(tagsubfield)){
-            var subfieldcode=getSubfieldcode(inputs[myindex].name);
-            if (isNaN(parseInt(subfieldcode)) && inputs[myindex].value != "" && subfieldcode!=elementsubfcode){
-                mainstring=inputs[myindex].value+" "+mainstring;
-            }      
-        }
-    }           
-    newin=window.open("../authorities/auth_finder.pl?source=auth&authtypecode="+  authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
-}
-
 function AddField(field,cntrepeatfield) {
     document.forms['f'].op.value = "addfield";
     document.forms['f'].addfield_field.value=field;
@@ -156,52 +146,23 @@ function searchauthority() {
     Y = document.forms[0].value.value;
     window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
 }
+function confirmnotdup(redirect){
+    $("#confirm_not_duplicate").attr("value","1");
+    Check();
+}
 //]]>
 </script>
 <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
+[% IF ( bidi ) %]
+   <link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />
+[% END %]
 </head>
 <body id="auth_authorities" class="auth">
-<div id="yui-cms-loading">
-      <div id="yui-cms-float">
-          Loading, please wait...
-      </div>
-  </div>
-<script type="text/javascript" src="[% themelang %]/lib/yui/plugins/loading-min.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-(function() {
-       // configuring the loading mask
-       YAHOO.widget.Loading.config({
-               opacity: 0.8
-       });
-})();
-     $(document).ready(function() {
-        yuiToolbar();
-        $("#addauthc,#action").empty();
-     });
-    // YUI Toolbar Functions
-    function yuiToolbar() {
-    var addauthButton = new YAHOO.widget.Button({
-                                            id: "addauth",
-                                            type: "button",
-                                            label: _("Save"),
-                                            container: "addauthc",
-                                            onclick: {fn: Check }
-                                        });
-    var addauthButton2 = new YAHOO.widget.Button({
-                                            id: "addauth2",
-                                            type: "button",
-                                            label: _("Save"),
-                                            container: "action",
-                                            onclick: {fn: Check }
-                                        });
-    }
-    function confirmnotdup(redirect){
-        $("#confirm_not_duplicate").attr("value","1");
-        Check();
-    }
-//]]>
-</script>
+
+<div id="loading">
+   <div>Loading, please wait...</div>
+</div>
+
 [% INCLUDE 'header.inc' %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a> &rsaquo; [% IF ( authid ) %]Modify authority #[% authid %] ([% authtypetext %])[% ELSE %]Adding authority [% authtypetext %][% END %]  </div>
@@ -221,11 +182,11 @@ function searchauthority() {
 [% IF ( duplicateauthid ) %]
         <div class="dialog alert">
                 <h4>Duplicate record suspected</h4>
-                <p>Is this a duplicate of <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]" onclick="openWindow('/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]&amp;popup=1', 'Duplicate authority','800','600'); return false;" class="button">[% duplicateauthvalue %]</a>?</p>
+                <p>Is this a duplicate of <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]" onclick="openWindow('/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]&amp;popup=1', 'DuplicateAuthority','800','600'); return false;" class="button">[% duplicateauthvalue %]</a>?</p>
 
                 <form action="authorities.pl" method="get">
                     <input type="hidden" name="authid" value="[% duplicateauthid %]" />
-                    <input type="submit" class="edit" value="Yes: Edit exisiting authority" />
+                    <input type="submit" class="edit" value="Yes: Edit existing authority" />
                 </form>
                 <form action="authorities.pl" method="get">
                     <input type="button" value="No: Save as new authority" class="save" accesskey="w" onclick="confirmnotdup('items'); return false;" />
@@ -242,8 +203,12 @@ function searchauthority() {
     <input type="hidden" name="index" value="[% index %]" />
     <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
 
-       <div id="toolbar">
-       <ul class="toolbar"><li id="addauthc"><input id="addauth" type="submit" value="Save" accesskey="w" /></li></ul></div>
+    <div id="toolbar" class="btn-toolbar">
+        <div class="btn-group"><a href="#" id="addauth" class="btn btn-small" accesskey="w"><i class="icon-hdd"></i> Save</a></div>
+        <div class="btn-group">
+            <a class="btn btn-small" id="z3950submit" href="#"><i class="icon-search"></i> Z39.50 search</a>
+        </div>
+    </div>
 
 <div id="authoritytabs" class="toptabs numbered">
     <ul>
@@ -257,7 +222,7 @@ function searchauthority() {
 
     [% FOREACH innerloo IN BIG_LOO.innerloop %]
     [% IF ( innerloo.tag ) %]
-    <div class="tag" id="tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
+    <div class="tag clearfix" id="tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
         <div class="tag_title" id="div_indicator_tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
         [% UNLESS hide_marc %]
             [% IF advancedMARCEditor %]
@@ -326,11 +291,11 @@ function searchauthority() {
                 <span class="field_controls">
                 [% IF ( innerloo.repeatable ) %]
                     <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]','[% hide_marc %]','[% advancedMARCEditor %]'); return false;" title="Repeat this Tag">
-                        <img src="/intranet-tmpl/prog/img/repeat-tag.png" alt="Repeat this Tag" />
+                        <img src="[% interface %]/[% theme %]/img/repeat-tag.png" alt="Repeat this Tag" />
                     </a>
                 [% END %]
                     <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]'); return false;" title="Delete this Tag">
-                        <img src="/intranet-tmpl/prog/img/delete-tag.png" alt="Delete this Tag" />
+                        <img src="[% interface %]/[% theme %]/img/delete-tag.png" alt="Delete this Tag" />
                     </a>
                 </span>
 
@@ -349,9 +314,9 @@ function searchauthority() {
                 [% UNLESS hide_marc %]
                 <span class="subfieldcode">
                     [% IF ( subfield_loo.fixedfield ) %]
-                        <img class="buttonUp" style="display:none;" src="/intranet-tmpl/prog/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
+                        <img class="buttonUp" style="display:none;" src="[% interface %]/[% theme %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
                     [% ELSE %]
-                        <img class="buttonUp" src="/intranet-tmpl/prog/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
+                        <img class="buttonUp" src="[% interface %]/[% theme %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
                     [% END %]
                         <input type="text"
                             title="[% subfield_loo.marc_lib_plain %]"
@@ -377,15 +342,41 @@ function searchauthority() {
                     </label>
                 [% END %]
                 
-                [% subfield_loo.marc_value %]
+                [% SET mv = subfield_loo.marc_value %]
+                [% IF ( mv.type == 'select' ) %]
+                     <select name="[%- mv.name -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id -%]">
+                     [% FOREACH aval IN mv.values %]
+                         [% IF aval == mv.default %]
+                         <option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
+                         [% ELSE %]
+                         <option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
+                         [% END %]
+                     [% END %]
+                     </select>
+                [% ELSIF ( mv.type == 'text1' ) %]
+                    <input type="text" id="[%- mv.id -%]" name="[%- mv.id -%]" value="[%- mv.value -%]" class="input_marceditor" tabindex="1" />
+                    <a href="#" class="buttonDot" onclick="openAuth(this.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtypecode -%]','auth'); return false;" tabindex="1" title="Tag editor">...</a>
+                [% ELSIF ( mv.type == 'text2' ) %]
+                    <input tabindex="1" type="text" id="[%- mv.id -%]" size="67" maxlength="[%- mv.maxlength -%]" name="[%- mv.id -%]" value="[%- mv.value -%]" class="input_marceditor" onfocus="Focus[%- mv.function -%]([%- mv.index_tag -%])" onblur="Blur[%- mv.function -%]([%- mv.index_tag -%]);" />
+                    <a href="#" class="buttonDot" onclick="Clic[%- mv.function -%]('[%- mv.id -%]'); return false;" title="Tag editor">...</a>
+                    [% mv.javascript %]
+                [% ELSIF ( mv.type == 'text' ) %]
+                    <input type="text" id="[%- mv.id -%]" name="[%- mv.name -%]" value="[%- mv.value -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength -%]" />
+                [% ELSIF ( mv.type == 'textarea' ) %]
+                    <textarea cols="70" rows="4" id="[%- mv.id -%]" name="[%- mv.name -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength -%]">[%- mv.value -%]</textarea>
+                [% ELSIF ( mv.type == 'hidden' ) %]
+                    <input tabindex="1" type="hidden" id="[%- mv.id -%]" name="[%- mv.name -%]" size="67" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
+                [% ELSIF ( mv.type == 'hidden_simple' ) %]
+                    <input type="hidden" name="[%- mv.name -%]" />
+                [% END %]
 
                 <span class="subfield_controls">
                 [% IF ( subfield_loo.repeatable ) %]
                     <a href="#" class="buttonPlus" tabindex="1" onclick="CloneSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]','[% advancedMARCEditor %]'); return false;">
-                        <img src="/intranet-tmpl/prog/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
+                        <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
                     </a>
                     <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]'); return false;">
-                        <img src="/intranet-tmpl/prog/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
+                        <img src="[% interface %]/[% theme %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
                     </a>
                 [% END %]
                 </span>