1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha › Authorities › <!-- TMPL_IF name="authid" -->Modify authority #<!-- TMPL_VAR NAME="authid" --> (<!-- TMPL_VAR name="authtypetext" -->)<!-- TMPL_ELSE -->Adding authority (<!-- TMPL_VAR name="authtypetext" -->)<!-- /TMPL_IF --></title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
5 <script type="text/javascript">
8 $(document).ready(function() {
9 $('#authoritytabs').tabs();
13 * check if mandatory subfields are writed
15 function AreMandatoriesNotOk(){
16 var mandatories = new Array();
17 var tab = new Array();
18 var label = new Array();
20 <!-- TMPL_LOOP NAME='BIG_LOOP' --><!-- TMPL_LOOP NAME='innerloop' --><!-- TMPL_LOOP NAME='subfield_loop'--><!-- TMPL_IF NAME='mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
21 tab.push("<!-- TMPL_VAR NAME='number' -->");
22 label.push("<!-- TMPL_VAR NAME='marc_lib' ESCAPE=JS-->");<!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
23 var StrAlert = _("Can't save this record because the following field aren't filled :\n\n");
24 for(var i=0,len=mandatories.length; i<len ; i++){
25 //alert ( mandatories[i]);
26 if( ! document.getElementById(mandatories[i]).value){
28 document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
29 document.getElementById(mandatories[i]).focus();
30 StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
45 var StrAlert = AreMandatoriesNotOk();
58 function AddField(field,cntrepeatfield) {
59 document.forms['f'].op.value = "addfield";
60 document.forms['f'].addfield_field.value=field;
61 document.forms['f'].repeat_field.value=cntrepeatfield;
65 function Dopop(link,i) {
66 defaultvalue = document.getElementById(i).value;
67 window.open(link+"&result="+defaultvalue,"value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
70 function ExpandField(index) {
71 var original = document.getElementById(index); //original <div>
72 var divs = original.getElementsByTagName('div');
73 for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div
74 if(divs[i].getAttribute("name") == 'line'){ // if it s a subfield
75 if (divs[i].style.display == 'block') {
76 divs[i].style.display = 'none';
78 divs[i].style.display = 'block';
85 * To clone a field or a subfield by clickink on '+' button
87 function CloneField(index) {
88 var original = document.getElementById(index); //original <div>
89 var clone = original.cloneNode(true);
90 var new_key = CreateKey();
91 var new_id = original.getAttribute('id')+new_key;
93 clone.setAttribute('id',new_id); // setting a new id for the parent div
95 var divs = clone.getElementsByTagName('div');
97 <!-- TMPL_UNLESS NAME='hide_marc'--> // No indicator if hide_marc
98 // setting a new name for the new indicator
99 var indicator = clone.getElementsByTagName('input')[0];
100 indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
101 <!-- /TMPL_UNLESS -->
103 // settings all subfields
104 for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div
105 if(divs[i].getAttribute("name") == 'line'){ // if it s a subfield
107 // set the attribute for the new 'div' subfields
108 divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key);
110 var inputs = divs[i].getElementsByTagName('input');
113 inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
114 inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key);
117 id_input = inputs[1].getAttribute('id')+new_key;
118 inputs[1].setAttribute('id',id_input);
119 inputs[1].setAttribute('name',inputs[1].getAttribute('name')+new_key);
121 try{ // it s a select if it is not an input
122 var selects = divs[i].getElementsByTagName('select');
123 id_input = selects[0].getAttribute('id')+new_key;
124 selects[0].setAttribute('id',id_input);
125 selects[0].setAttribute('name',selects[0].getAttribute('name')+new_key);
126 }catch(e2){ // it is a textarea if it s not a select or an input
127 var textaeras = divs[i].getElementsByTagName('textarea');
128 id_input = textaeras[0].getAttribute('id')+new_key;
129 textaeras[0].setAttribute('id',id_input);
130 textaeras[0].setAttribute('name',textaeras[0].getAttribute('name')+new_key);
134 <!-- TMPL_UNLESS NAME='advancedMARCEditor'-->
135 // when cloning a subfield, re set its label too.
136 var labels = divs[i].getElementsByTagName('label');
137 labels[0].setAttribute('for',id_input);
138 <!-- /TMPL_UNLESS -->
140 <!-- TMPL_UNLESS NAME='hide_marc'-->
141 // updating javascript parameters on button up
142 var imgs = divs[i].getElementsByTagName('img');
143 imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');");
144 <!-- /TMPL_UNLESS -->
146 // setting its '+' button
147 var CloneButtonPlus=0;
149 CloneButtonPlus = divs[i].getElementsByTagName('span')[0];
150 if(CloneButtonPlus.getAttribute('class') == 'buttonPlus'){
151 CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')");
157 // do nothig if ButtonPlus & CloneButtonPlus don t exist.
163 spans = divs[i].getElementsByTagName('span');
169 if(!CloneButtonPlus){ // it s impossible to have + ... (buttonDot AND buttonPlus)
170 buttonDot = spans[0];
174 var buttonDotOnClick = buttonDot.getAttribute('onclick');
175 if(buttonDotOnClick.match('Clictag')){ // -1- It s a plugin
176 var re = /\('.*'\)/i;
177 buttonDotOnClick = buttonDotOnClick.replace(re,"('"+inputs[1].getAttribute('id')+"')");
178 if(buttonDotOnClick){
179 buttonDot.setAttribute('onclick',buttonDotOnClick);
182 if(buttonDotOnClick.match('Dopop')) { // -2- It's a auth value
184 var re1 = /&index=.*',/;
187 buttonDotOnClick = buttonDotOnClick.replace(re1,"&index="+inputs[1].getAttribute('id')+"',");
188 buttonDotOnClick = buttonDotOnClick.replace(re2,",'"+inputs[1].getAttribute('id')+"')");
190 if(buttonDotOnClick){
191 buttonDot.setAttribute('onclick',buttonDotOnClick);
196 // do not copy the script section.
197 var script = spans[0].getElementsByTagName('script')[0];
198 spans[0].removeChild(script);
200 // do nothing if there is no script
206 <!-- TMPL_UNLESS NAME='hide_marc'-->
207 var buttonUp = divs[i].getElementsByTagName('img')[0];
208 buttonUp.setAttribute('onclick',"upSubfield('" + divs[i].getAttribute('id') + "')");
209 <!-- /TMPL_UNLESS -->
211 } else { // it's a indicator div
212 if(divs[i].getAttribute('name') == 'div_indicator'){
213 var inputs = divs[i].getElementsByTagName('input');
214 inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
218 CloneButtonPlus = divs[i].getElementsByTagName('span')[1]; // 0 is the title
219 CloneButtonPlus.setAttribute('onclick',"CloneField('" + divs[i].parentNode.getAttribute('id') + "')");
222 // do nothig CloneButtonPlus doesn't exist.
225 // setting its 'Expand' property
228 ExpandFieldA = divs[i].getElementsByTagName('a')[0];
229 ExpandFieldA.setAttribute('onclick',"ExpandField('" + divs[i].parentNode.getAttribute('id') + "')");
232 // do nothig if ButtonPlus & CloneButtonPlus don t exist.
239 // insert this line on the page
240 original.parentNode.insertBefore(clone,original.nextSibling);
243 function CloneSubfield(index){
244 var original = document.getElementById(index); //original <div>
245 var clone = original.cloneNode(true);
246 var new_key = CreateKey();
247 var new_id = original.getAttribute('id')+new_key;
249 // set the attribute for the new 'div' subfields
250 var inputs = clone.getElementsByTagName('input');
251 var selects = clone.getElementsByTagName('select');
252 var textareas = clone.getElementsByTagName('textarea');
256 for(var i=0,len=inputs.length; i<len ; i++ ){
257 id_input = inputs[i].getAttribute('id')+new_key;
258 inputs[i].setAttribute('id',id_input);
259 inputs[i].setAttribute('name',inputs[i].getAttribute('name')+new_key);
263 for(var i=0,len=selects.length; i<len ; i++ ){
264 id_input = selects[i].getAttribute('id')+new_key;
265 selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
266 selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key);
270 for(var i=0,len=textareas.length; i<len ; i++ ){
271 id_input = textareas[i].getAttribute('id')+new_key;
272 textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
273 textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key);
276 <!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
277 // when cloning a subfield, reset its label too.
278 var label = clone.getElementsByTagName('label')[0];
279 label.setAttribute('for',id_input);
280 <!-- /TMPL_UNLESS -->
282 // setting a new if for the parent div
283 clone.setAttribute('id',new_id);
287 var spans = clone.getElementsByTagName('span');
289 for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
290 if(spans[i].getAttribute('class') == 'buttonPlus'){
291 CloneButtonPlus = spans[i];
292 CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
293 var buttonUp = clone.getElementsByTagName('img')[0];
294 buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
300 // do nothig if ButtonPlus & CloneButtonPlus don't exist.
302 // insert this line on the page
303 original.parentNode.insertBefore(clone,original.nextSibling);
307 * This function create a random number
309 function CreateKey(){
310 return parseInt(Math.random() * 100000);
314 * This function allows to move a subfield up by clickink on the 'up' button .
316 function upSubfield(index) {
318 var line = document.getElementById(index); // get the line where the user has clicked.
320 return; // this line doesn't exist...
322 var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>")
324 // getting all subfields for this tag
325 var subfields = tag.getElementsByTagName('div');
326 var subfieldsLength = subfields.length;
328 if(subfieldsLength<=1) return; // nothing to do if there is just one subfield.
330 // among all subfields
331 for(var i=0;i<subfieldsLength;i++){
332 if(subfields[i].getAttribute('id') == index){ //looking for the subfield which is clicked :
333 if(i==1){ // if the clicked subfield is on the top
334 tag.appendChild(subfields[1]);
337 var lineAbove = subfields[i-1];
338 tag.insertBefore(line,lineAbove);
345 function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
346 subfield = document.getElementById(index);
347 subfield.style.display = 'block';
348 label = document.getElementById(labelindex);
349 label.style.display='none';
352 function addauthority() {
353 X = document.forms[0].authtype.value;
354 window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
356 function searchauthority() {
357 X = document.forms[0].authtype2.value;
358 Y = document.forms[0].value.value;
359 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";
363 <style type="text/css">
371 <!-- TMPL_INCLUDE NAME="header.inc" -->
373 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a> › <!-- TMPL_IF name="authid" -->Modify authority #<!-- TMPL_VAR NAME="authid" --> (<!-- TMPL_VAR name="authtypetext" -->)<!-- TMPL_ELSE -->Adding authority (<!-- TMPL_VAR name="authtypetext" -->)<!-- /TMPL_IF --> </div>
375 <div id="doc" class="yui-t7">
381 <!-- TMPL_IF name="authid" -->
382 <h1>Modify authority #<!-- TMPL_VAR NAME="authid" --> (<!-- TMPL_VAR name="authtypetext" -->)</h1>
384 <h1>Adding authority (<!-- TMPL_VAR name="authtypetext" -->)</h1>
386 <form method="post" name="f" action="/cgi-bin/koha/authorities/authorities.pl">
387 <input type="hidden" name="op" value="add" />
388 <input type="hidden" name="addfield_field" value="" />
389 <input type="hidden" name="repeat_field" value="" />
390 <input type="hidden" name="authtypecode" value="<!-- TMPL_VAR NAME="authtypecode" -->" />
391 <input type="hidden" name="authid" value="<!-- TMPL_VAR NAME="authid" -->" />
394 <!-- TMPL_IF name="authid" -->
395 <input type="button" value="Save" onclick="Check(this.form)" accesskey="w" />
397 <input type="button" value="Add" onclick="Check(this.form)" accesskey="w" />
401 <!-- TMPL_IF name="duplicateauthid" -->
402 <div class="problem">
403 <p>Duplicate suspected with <a href="javascript:openWindow("detail.pl?authid=<!-- TMPL_VAR name="duplicateauthid" -->&popup=1", "Duplicate Authority");" class="button"><!-- TMPL_VAR name="duplicateauthvalue" --></a></p>
404 <p>You must either :</p>
406 <p><input type="checkbox" value="1" name="confirm_not_duplicate" />confirm it's not a duplicate (and click on <input type="button" value="Add authority" onclick="Check(this.form)" accesskey="w" class="button" /> again)</p>
407 <p>Go to <a href="authorities.pl?authid=<!-- TMPL_VAR name="duplicateauthid" -->" >original authority</a></p>
412 <div id="authoritytabs" class="toptabs numbered">
413 <ul> <!-- TMPL_LOOP name="BIG_LOOP" -->
414 <li><!-- TMPL_IF name="number" -->
415 <a href="/cgi-bin/authorities/authorties.pl#tab<!-- TMPL_VAR name="number" -->XX"><!-- TMPL_VAR name="number"--></a>
417 <a href="/cgi-bin/authorities/authorties.pl#tab<!-- TMPL_VAR name="number" -->XX"><!-- TMPL_VAR name="number"--></a>
418 <!-- /TMPL_IF --></li>
419 <!-- /TMPL_LOOP --></ul>
421 <!-- TMPL_LOOP name="BIG_LOOP" -->
422 <!-- hide every tab except the 1st -->
423 <!-- TMPL_IF name="number" -->
424 <div id="tab<!-- TMPL_VAR name="number" -->XX">
426 <div id="tab<!-- TMPL_VAR name="number" -->XX">
429 <!-- TMPL_LOOP NAME="innerloop" -->
430 <!-- TMPL_IF NAME="tag" -->
431 <div class="tag" id="tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->">
432 <div class="tag_title" name="div_indicator">
433 <!-- TMPL_UNLESS name="hide_marc" -->
434 <span title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --></span>
435 <!-- TMPL_IF NAME="fixedfield" -->
437 class="indicator flat"
439 style="display:none;"
440 name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->"
443 value="<!-- TMPL_VAR NAME="indicator" -->" />
446 class="indicator flat"
448 name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->"
451 value="<!-- TMPL_VAR NAME="indicator" -->" />
454 <!-- TMPL_IF NAME="fixedfield" -->
457 name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
458 value="<!-- TMPL_VAR NAME="indicator" --><!-- TMPL_VAR name="random" -->" />
462 name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
463 value="<!-- TMPL_VAR NAME="indicator" --><!-- TMPL_VAR name="random" -->" />
465 <!-- /TMPL_UNLESS -->
467 <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
468 <a onclick="ExpandField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->')"><!-- TMPL_VAR NAME="tag_lib" --></a>
469 <!-- /TMPL_UNLESS -->
470 <!-- TMPL_IF name="repeatable" -->
471 <span class="buttonPlus" onclick="CloneField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->')">+</span>
476 <!-- TMPL_LOOP NAME="subfield_loop" -->
477 <!-- One line on the marc editor -->
478 <div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->">
480 <!--TMPL_UNLESS NAME="advancedMARCEditor" -->
481 <label for="tag_<!-- TMPL_VAR NAME='tag'-->_subfield_<!-- TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
482 <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF --> class="labelsubfield" >
483 <!-- /TMPL_UNLESS -->
485 <!-- TMPL_UNLESS name="hide_marc" -->
486 <img class="buttonUp" <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF --> src="<!-- TMPL_VAR NAME="themelang" -->/../img/up.png" onclick="upSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->')" alt="Move Up" title="Move Up" />
487 <input title="<!-- TMPL_VAR NAME='marc_lib_plain' -->"
488 style=" <!-- TMPL_IF NAME="fixedfield" -->display:none; <!-- /TMPL_IF -->border:0;" type="text"
489 name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!-- TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
490 value="<!-- TMPL_VAR NAME="subfield" -->"
497 name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!-- TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
498 value="<!-- TMPL_VAR NAME="subfield" -->"/>
499 <!-- /TMPL_UNLESS -->
501 <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
502 <!-- TMPL_IF name="mandatory" --><span class="subfield_mandatory"><!-- /TMPL_IF -->
503 <!-- TMPL_VAR NAME="marc_lib" -->
504 <!-- TMPL_IF name="mandatory" --></span><!-- /TMPL_IF -->
506 <!-- /TMPL_UNLESS -->
508 <!-- TMPL_VAR NAME="marc_value" -->
510 <!-- TMPL_IF NAME="repeatable" -->
511 <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->')">+</span>
515 <!-- End of the line -->
519 <!-- /TMPL_IF --><!-- tag -->
524 <!-- TMPL_UNLESS Name="singletab" -->
529 <div name="hidden" id="hidden" class="tab">
530 <!-- TMPL_LOOP NAME="hidden_loop" -->
531 <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
532 <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
533 <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
534 <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
535 <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR NAME="tag_mandatory" -->" />
538 <!-- TMPL_IF name="oldauthnumtagfield" -->
539 <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="oldauthnumtagfield" -->" />
540 <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="oldauthnumtagsubfield" -->" />
541 <input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="authid" -->" />
542 <input type="hidden" name="mandatory" value="0" />
543 <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
544 <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR NAME="tag_mandatory" -->" />
545 <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="oldauthtypetagfield" -->" />
546 <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="oldauthtypetagsubfield" -->" />
547 <input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="authtypecode" -->" />
550 <!-- TMPL_IF name="authid" -->
551 <input type="button" value="Save" onclick="Check(this.form)" accesskey="w" />
553 <input type="button" value="Add" onclick="Check(this.form)" accesskey="w" />
561 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->