MARC authority management (1st draft. works really poorly)
[koha.git] / koha-tmpl / intranet-tmpl / default / en / authorities / authorities.tmpl
1 <!-- TMPL_INCLUDE NAME="auth-top.inc" -->
2 <link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/includes/marc-editor.css">
3
4 <div class="tabbed">
5         <form method="post" name="f">
6         <h1 class="authority">Authority number <!-- TMPL_VAR name="authid" --></h1>
7         <p>
8                 <input type="hidden" name="op" value="add">
9                 <input type="hidden" name="addfield_field">
10                 <input type="hidden" name="authtypecode" value="<!-- TMPL_VAR name="authtypecode" -->">
11                 <!-- TMPL_IF name="authid" -->
12                         <input type="button" value="Save" onClick='Check(this.form)' accesskey="w" class="button authority">
13                 <!-- TMPL_ELSE -->
14                         <input type="button" value="Add biblio" onClick='Check(this.form)' accesskey="w" class="button authority">
15                 <!-- /TMPL_IF -->
16 <!--            <a href="javascript:PopupZ3950()" class="button authority">z3950 search</a> -->
17         </p>
18 </div>
19
20 <!-- TMPL_LOOP name="0XX" -->
21         <!-- TMPL_IF name="tag" -->
22                 <p class="MARCtag">
23                 <!-- TMPL_VAR name="tag" -->
24                 <input type="hidden" name="ind_tag" value="<!-- TMPL_VAR name="tag" -->">
25                 <input type="text" name="indicator" size=3 maxlength=2 value="<!-- TMPL_VAR name="indicator" -->"> - <tmpl_var name="tag_lib">
26                 <!-- TMPL_IF name="repeatable" -->
27                         <a href="javascript:AddField(<!-- TMPL_VAR name="tag" -->)">+</a>
28                 <!-- /TMPL_IF -->
29                 </p>
30         <!-- /TMPL_IF -->
31         <!-- TMPL_LOOP name="subfield_loop" -->
32                 <p>
33                         <label class="labelsubfield">
34                                 <b><!-- TMPL_VAR name="subfield" --></b>
35                                 <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF -->
36                                 <!-- TMPL_VAR name="marc_lib" -->
37                                 <!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF -->
38                         </label>
39                         <!-- TMPL_VAR name="marc_value" -->
40                         <input type="hidden" name="tag" value="<!-- TMPL_VAR name="tag" -->">
41                         <input type="hidden" name="subfield" value="<!-- TMPL_VAR name="subfield" -->">
42                         <input type="hidden" name="mandatory" value="<!-- TMPL_VAR name="mandatory" -->">
43                         <input type="hidden" name="kohafield" value="<!-- TMPL_VAR name="kohafield" -->">
44                         <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR name="tag_mandatory" -->">
45                 </p>
46         <!-- /tmpl_loop -->
47 <!-- /tmpl_loop -->
48                 
49                 <div name="hidden" id="hidden" class="tab">
50                 <!-- TMPL_LOOP name="hidden_loop" -->
51                                 <input type="hidden" name="tag" value="<!-- TMPL_VAR name="tag" -->">
52                                 <input type="hidden" name="subfield" value="<!-- TMPL_VAR name="subfield" -->">
53                                 <input type="hidden" name="mandatory" value="<!-- TMPL_VAR name="mandatory" -->">
54                                 <input type="hidden" name="kohafield" value="<!-- TMPL_VAR name="kohafield" -->">
55                                 <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR name="tag_mandatory" -->">
56                 <!-- /TMPL_LOOP -->
57                 </div>
58                 <!-- TMPL_IF name="oldbiblionumtagfield" -->
59                         <input type="hidden" name="tag" value="<!-- TMPL_VAR name="oldbiblionumtagfield" -->">
60                         <input type="hidden" name="subfield" value="<!-- TMPL_VAR name="oldbiblionumtagsubfield" -->">
61                         <input type="hidden" name="field_value" value="<!-- TMPL_VAR name="oldbiblionumber" -->">
62                         <input type="hidden" name="mandatory" value="0">
63                         <input type="hidden" name="kohafield" value="<!-- TMPL_VAR name="kohafield" -->">
64                         <input type="hidden" name="tag" value="<!-- TMPL_VAR name="oldbiblioitemnumtagfield" -->">
65                         <input type="hidden" name="subfield" value="<!-- TMPL_VAR name="oldbiblioitemnumtagsubfield" -->">
66                         <input type="hidden" name="field_value" value="<!-- TMPL_VAR name="oldbiblioitemnumber" -->">
67                         <input type="hidden" name="mandatory" value="0">
68                         <input type="hidden" name="kohafield" value="<!-- TMPL_VAR name="kohafield" -->">
69                         <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR name="tag_mandatory" -->">
70                 <!-- /TMPL_IF -->
71         </form>
72 <script LANGUAGE="JavaScript">
73 function _(s) { return s } // dummy function for gettext
74 function active(numlayer)
75 {
76         for (i=0; i < 10 ; i++ ) {
77                 ong = i+"XX";
78                 link = "link"+i;
79                 if (numlayer==i) {
80                         document.getElementById(ong).style.visibility="visible";
81                 } else {
82                         document.getElementById(ong).style.visibility="hidden";
83                 }
84         }
85 }
86 function Check(f) {
87         // Scan for nonempty fields
88         var field_is_nonempty_p = new Array();
89         for (i=0 ; i<f.field_value.length ; i++) {
90             field_is_nonempty_p[f.tag[i].value] = 0;
91         }
92         for (i=0 ; i<f.field_value.length ; i++) {
93             if (f.field_value[i].value.length != 0) {
94                 field_is_nonempty_p[f.tag[i].value] += 1;
95             }
96         }
97
98         // Scan for missing mandatory subfields
99         var total_missing_mandatory_subfields = 0;
100         for (i=0 ; i<f.field_value.length-2 ; i++) {
101                 if (f.field_value[i].value.length==0 && f.mandatory[i].value==1) {
102                     // We should not flag an error unless the tag is also
103                     // mandatory, or if something else in the tag is entered
104
105                     if (f.tag_mandatory[i].value == 1 || field_is_nonempty_p[f.tag[i].value]) {
106                         document.getElementById("error"+i).style.backgroundColor="#FF0000";
107                         total_missing_mandatory_subfields++;
108                     }
109                 } else {
110                         document.getElementById("error"+i).style.backgroundColor="#FFFFFF";
111                 }
112         }
113
114         // Scan for missing mandatory tags
115         var total_missing_mandatory_tags = 0;
116         var seen_mandatory_tag_p = new Array();
117         for (i=0 ; i<f.field_value.length ; i++) {
118             var j = f.tag[i].value;
119             if (!field_is_nonempty_p[j] && f.tag_mandatory[i].value == 1) {
120                 if (seen_mandatory_tag_p[j] != 1) {
121                     seen_mandatory_tag_p[j] = 1;
122                     total_missing_mandatory_tags++;
123                 }
124                 document.getElementById("error"+i).style.backgroundColor="#ffff00";
125             }
126         }
127
128         var total_errors = total_missing_mandatory_tags + total_missing_mandatory_subfields;
129         var alertString2;
130         if (total_errors!=0) {
131                 alertString2  = _("Form not submitted because of the following problem(s)");
132                 alertString2 += "\n------------------------------------------------------------------------------------\n";
133                 alertString2 += "\n- "+ total_missing_mandatory_tags +_(" mandatory tags empty");
134                 alertString2 += "\n- "+ total_missing_mandatory_subfields +_(" mandatory fields empty (see bold subfields)");
135                 alert(alertString2);
136         } else {
137                 document.forms[0].submit();
138         }
139 }
140 function Dopop(link,i) {
141         defaultvalue=document.forms[0].field_value[i].value;
142         newin=window.open(link+"&result="+defaultvalue,"value builder",'width=550,height=550,toolbar=false,scrollbars=yes');
143 }
144
145 function PopupZ3950() {
146     var strQuery="";
147         for (i=0 ; i<document.forms[0].field_value.length ; i++) {
148                 if (document.forms[0].kohafield[i].value == "biblioitems.isbn" && document.forms[0].field_value[i].value.length>0) {
149                     strQuery += "&isbn="+document.forms[0].field_value[i].value;
150                 }
151                 if (document.forms[0].kohafield[i].value == "biblio.title" && document.forms[0].field_value[i].value.length>0) {
152                     strQuery += "&title="+document.forms[0].field_value[i].value;
153                 }
154                 if (document.forms[0].kohafield[i].value == "biblio.author" &&document.forms[0].field_value[i].value.length>0) {
155                     strQuery += "&author="+document.forms[0].field_value[i].value;
156                 }
157                 if (document.forms[0].kohafield[i].value == "biblioitems.issn" && document.forms[0].field_value[i].value.length>0) {
158                     strQuery += "&issn="+document.forms[0].field_value[i].value;
159                 }
160         }
161         newin=window.open("../z3950/search.pl?bibid=<!-- TMPL_VAR name="bibid" -->"+strQuery,"z3950search",'width=500,height=400,toolbar=false,scrollbars=yes');
162 }
163
164 function AddField(field) {
165         document.forms[0].op.value = "addfield";
166         document.forms[0].addfield_field.value=field;
167         document.f.submit();
168 }
169 </script>
170 </body>
171 </html>