View | Details | Raw Unified | Return to bug 21280
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/marc_editor.inc (+394 lines)
Line 0 Link Here
1
[% USE Koha %]
2
<script type="text/javascript">
3
//<![CDATA[
4
5
$(document).ready(function() {
6
    /* check cookie to hide/show marcdocs*/
7
    if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){
8
        toggleMARCdocLinks(false);
9
    } else {
10
        toggleMARCdocLinks(true);
11
    }
12
13
    $("#marcDocsSelect").click(function(){
14
        if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){
15
            toggleMARCdocLinks(true);
16
        } else {
17
            toggleMARCdocLinks(false);
18
        }
19
    });
20
21
    /* check cookie to hide/show marc tags*/
22
    var marctags_cookie = $.cookie("marctags_[% borrowernumber | html %]");
23
    if( marctags_cookie == 'hide'){
24
        toggleMARCTagLinks(false);
25
    } else if( marctags_cookie == 'show'){
26
        toggleMARCTagLinks(true)
27
    } else {
28
        [% UNLESS Koha.Preference("hide_marc") %]
29
            toggleMARCTagLinks(true)
30
        [% ELSE %]
31
            toggleMARCTagLinks(false);
32
        [% END %]
33
    }
34
35
    $("#marcTagsSelect").click(function(){
36
        if( $.cookie("marctags_[% borrowernumber | html %]") == 'hide'){
37
            toggleMARCTagLinks(true)
38
        } else {
39
            toggleMARCTagLinks(false);
40
        }
41
    });
42
});
43
44
function PopupMARCFieldDoc(field) {
45
    [% IF Koha.Preference('marcfielddocurl') %]
46
        var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','&quot;') | html %]";
47
        docurl = docurl.replace("{MARC}", "[% marcflavour | html %]");
48
        docurl = docurl.replace("{FIELD}", ""+field);
49
        docurl = docurl.replace("{LANG}", "[% lang | html %]");
50
        window.open(docurl);
51
    [% ELSIF ( marcflavour == 'MARC21' ) %]
52
        _MARC21FieldDoc(field);
53
    [% ELSIF ( marcflavour == 'UNIMARC' ) %]
54
        _UNIMARCFieldDoc(field);
55
    [% END %]
56
}
57
58
function _MARC21FieldDoc(field) {
59
    if(field == 0) {
60
        window.open("[%marc21_doc_base | html %]leader.html");
61
    } else if (field < 900) {
62
        window.open("[%marc21_doc_base | html %]" + ("000"+field).slice(-3) + ".html");
63
    } else {
64
        window.open("[%marc21_doc_base | html %]9xx.html");
65
    }
66
}
67
68
function _UNIMARCFieldDoc(field) {
69
    /* Outdated but linkable HTML documentation used to be available at
70
       http://archive.ifla.org/VI/3/p1996-1/, but that's no longer the case. More recent
71
       versions of the UNIMARC standard are available on the IFLA website only as
72
       PDFs (with non-predictable URLs), so just link to the front page.
73
    */
74
    window.open("[%unimarc_doc_base | html %]");
75
}
76
77
/*
78
 * Functions to hide/show marc docs and tags links
79
 */
80
81
function toggleMARCdocLinks(flag){
82
    if( flag === true ){
83
        $(".marcdocs").show();
84
        $.cookie("marcdocs_[% borrowernumber | html %]",'show', { path: "/", expires: 365 });
85
        $("#marcDocsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
86
    } else {
87
        $(".marcdocs").hide();
88
        $.cookie("marcdocs_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 });
89
        $("#marcDocsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
90
    }
91
}
92
93
function toggleMARCTagLinks(flag){
94
    if( flag === true ){
95
        $(".tagnum").show();
96
        $(".subfieldcode").show();
97
        $.cookie("marctags_[% borrowernumber | html %]",'show', { path: "/", expires: 365 });
98
        $("#marcTagsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
99
    } else {
100
        $(".tagnum").hide();
101
        $(".subfieldcode").hide();
102
        $.cookie("marctags_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 });
103
        $("#marcTagsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
104
    }
105
}
106
107
/**
108
 * check if mandatory subfields are written
109
 */
110
function AreMandatoriesNotOk(){
111
    var mandatories = new Array();
112
    var mandatoriesfields = new Array();
113
    var tab = new Array();
114
    var label = new Array();
115
    var flag=0;
116
    var tabflag= new Array();
117
    [% FOREACH BIG_LOO IN BIG_LOOP %]
118
        [% FOREACH innerloo IN BIG_LOO.innerloop %]
119
            [% IF ( innerloo.mandatory ) %]
120
                mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]"));
121
            [% END %]
122
            [% FOREACH subfield_loo IN innerloo.subfield_loop %]
123
                [% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
124
                       tab.push("[% BIG_LOO.number | html %]");
125
                    label.push("[% subfield_loo.marc_lib | $raw %]");
126
                [% END %]
127
            [% END %]
128
        [% END %]
129
    [% END %]
130
    var StrAlert = _("Can't save this record because the following field aren't filled:");
131
    StrAlert += "\n\n";
132
    for(var i=0,len=mandatories.length; i<len ; i++){
133
        var tag=mandatories[i].substr(4,3);
134
        var subfield=mandatories[i].substr(17,1);
135
        var tagnumber=mandatories[i].substr(19,mandatories[i].lastIndexOf("_")-19);
136
        if (tabflag[tag+subfield+tagnumber] ==  null) {
137
            tabflag[tag+subfield+tagnumber]=new Array();
138
            tabflag[tag+subfield+tagnumber][0]=0;
139
        }
140
        if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(mandatories[i]) != null && ! document.getElementById(mandatories[i]).value || document.getElementById(mandatories[i]) == null)){
141
            tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
142
            document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
143
            $('#' + mandatories[i]).focus();
144
            tabflag[tag+subfield+tagnumber][1]=label[i];
145
            tabflag[tag+subfield+tagnumber][2]=tab[i];
146
        } else {
147
            tabflag[tag+subfield+tagnumber][0] = 1;
148
        }
149
    }
150
    for (var tagsubfieldid in tabflag){
151
      if (tabflag[tagsubfieldid][0]==0){
152
        var tag=tagsubfieldid.substr(0,3);
153
        var subfield=tagsubfieldid.substr(3,1);
154
        StrAlert += "\t* "+_("tag %s subfield %s %s in tab %s").format(tag, subfield, tabflag[tagsubfieldid][1], tabflag[tagsubfieldid][2]) + "\n";
155
        //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
156
        flag=1;
157
      }
158
    }
159
160
    /* Check for mandatories field(not subfields) */
161
    for(var i=0,len=mandatoriesfields.length; i<len; i++){
162
        isempty  = true;
163
        arr      = mandatoriesfields[i];
164
        divid    = "tag_" + arr[0] + "_" + arr[1];
165
        varegexp = new RegExp("^tag_" + arr[0] + "_code_");
166
167
        if(parseInt(arr[0]) >= 10){
168
            elem = document.getElementById(divid);
169
            eleminputs = elem.getElementsByTagName('input');
170
171
            for(var j=0,len2=eleminputs.length; j<len2; j++){
172
173
                if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
174
                    inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
175
176
                    for( var k=0; k<len2; k++){
177
                        if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
178
                            isempty = false
179
                        }
180
                    }
181
182
                    elemselect = elem.getElementsByTagName('select');
183
                    for( var k=0; k<elemselect.length; k++){
184
                        if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
185
                            isempty = false
186
                        }
187
                    }
188
                }
189
            }
190
191
            elemtextareas = elem.getElementsByTagName('textarea');
192
            for(var j=0,len2=elemtextareas.length; j<len2; j++){
193
                // this bit assumes that the only textareas in this context would be for subfields
194
                if (elemtextareas[j].value) {
195
                    isempty = false;
196
                }
197
            }
198
        }else{
199
            isempty = false;
200
        }
201
202
        if(isempty){
203
            flag = 1;
204
                StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
205
        }
206
207
    }
208
209
    if(flag){
210
        return StrAlert;
211
    } else {
212
        return flag;
213
    }
214
}
215
216
/**
217
 * Check that the record is ok
218
 */
219
function Check(){
220
    var StrAlert = AreMandatoriesNotOk();
221
    if( ! StrAlert ){
222
        document.f.submit();
223
        return true;
224
    } else {
225
        alert(StrAlert);
226
        return false;
227
    }
228
}
229
//]]>
230
</script>
231
232
<div id="[% maindiv | html %]" class="toptabs numbered">
233
    <ul>
234
        [% FOREACH BIG_LOO IN BIG_LOOP %]
235
        <li><a href="#tab[% BIG_LOO.number | uri %]XX">[% BIG_LOO.number | html %]</a></li>
236
        [% END %]
237
    </ul>
238
239
[% FOREACH BIG_LOO IN BIG_LOOP %]
240
    <div id="tab[% BIG_LOO.number | html %]XX">
241
242
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
243
    [% IF ( innerloo.tag ) %]
244
    <div class="tag" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
245
        <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
246
            [% IF advancedMARCEditor %]
247
                <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to Expand this Tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a>
248
            [% ELSE %]
249
                <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
250
                [% IF marcflavour != 'NORMARC' %]<a href="#" class="marcdocs" onclick="PopupMARCFieldDoc('[% innerloo.tag | html %]'); return false;">&nbsp;?</a>[% END %]
251
            [% END %]
252
                [% IF ( innerloo.fixedfield ) %]
253
                    <input type="text"
254
                        tabindex="1"
255
                        class="indicator flat"
256
                        style="display:none;"
257
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
258
                        size="1"
259
                        maxlength="1"
260
                        value="[% innerloo.indicator1 | html %]" />
261
                    <input type="text"
262
                        tabindex="1"
263
                        class="indicator flat"
264
                        style="display:none;"
265
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
266
                        size="1"
267
                        maxlength="1"
268
                        value="[% innerloo.indicator2 | html %]" />
269
                [% ELSE %]
270
                    <input type="text"
271
                        tabindex="1"
272
                        class="indicator flat"
273
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
274
                        size="1"
275
                        maxlength="1"
276
                        value="[% innerloo.indicator1 | html %]" />
277
                    <input type="text"
278
                        tabindex="1"
279
                        class="indicator flat"
280
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
281
                        size="1"
282
                        maxlength="1"
283
                        value="[% innerloo.indicator2 | html %]" />
284
                [% END %] -
285
286
            [% UNLESS advancedMARCEditor %]
287
                <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to Expand this Tag">[% innerloo.tag_lib | html %]</a>
288
            [% END %]
289
                <span class="field_controls">
290
                [% IF ( innerloo.repeatable ) %]
291
                    <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','0','[% advancedMARCEditor | html %]'); return false;" title="Repeat this Tag">
292
                        <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this Tag" />
293
                    </a>
294
                [% END %]
295
                    <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this Tag">
296
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this Tag" />
297
                    </a>
298
                </span>
299
300
        </div>
301
302
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
303
            <!--  One line on the marc editor -->
304
            <div class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
305
306
                [% UNLESS advancedMARCEditor %]
307
                    [% 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">
308
                    [% ELSE %]<label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
309
                    [% END %]
310
                [% END %]
311
312
                <span class="subfieldcode">
313
                    [% IF ( subfield_loo.fixedfield ) %]
314
                        <img class="buttonUp" style="display:none;" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
315
                    [% ELSE %]
316
                        <img class="buttonUp" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
317
                    [% END %]
318
                        <input type="text"
319
                            title="[% subfield_loo.marc_lib | $raw %]"
320
                            style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
321
                            name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
322
                            value="[% subfield_loo.subfield | html %]"
323
                            size="1"
324
                            maxlength="1"
325
                            class="flat"
326
                            tabindex="0" />
327
                </span>
328
329
                [% UNLESS advancedMARCEditor %]
330
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
331
                        [% subfield_loo.marc_lib | $raw %]
332
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
333
                    </span>
334
                    </label>
335
                [% END %]
336
337
                [% SET mv = subfield_loo.marc_value %]
338
                [% IF ( mv.type == 'text' or mv.type == 'text1' ) %]
339
                    [% IF ( mv.readonly == 1 ) %]
340
                    <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" />
341
                    [% ELSE %]
342
                    <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 -%]" />
343
                    [% END %]
344
                    [% IF ( mv.authtype ) %]
345
                    <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>
346
                    [% END %]
347
                [% ELSIF ( mv.type == 'text_complex' or mv.type == 'text2' ) %]
348
                    <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 -%]" />
349
                    <span class="subfield_controls">
350
                        [% IF mv.noclick %]
351
                            <a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup"></a>
352
                        [% ELSE %]
353
                            <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor framework_plugin" tabindex="1" title="Tag editor">Tag editor</a>
354
                        [% END %]
355
                    </span>
356
                    [% mv.javascript | $raw %]
357
                [% ELSIF ( mv.type == 'hidden' ) %]
358
                    <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 -%]" />
359
                [% ELSIF ( mv.type == 'textarea' ) %]
360
                    <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
361
                [% ELSIF ( mv.type == 'select' ) %]
362
                    <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
363
                    [% FOREACH aval IN mv.values %]
364
                        [% IF aval == mv.default %]
365
                        <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
366
                        [% ELSE %]
367
                        <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
368
                        [% END %]
369
                    [% END %]
370
                    </select>
371
                [% END %]
372
373
                <span class="subfield_controls">
374
                [% IF ( subfield_loo.repeatable ) %]
375
                    <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;">
376
                        <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
377
                    </a>
378
                    <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
379
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
380
                    </a>
381
                [% END %]
382
                </span>
383
384
            </div>
385
            <!-- End of the line -->
386
        [% END %]
387
388
    </div>
389
    [% END %]<!-- if innerloo.tag -->
390
    [% END %]<!-- BIG_LOO.innerloop -->
391
    </div>
392
[% END %]<!-- BIG_LOOP -->
393
394
</div><!-- tabs -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt (-278 / +13 lines)
Lines 54-142 function GetZ3950Terms(){ Link Here
54
    return strQuery;
54
    return strQuery;
55
}
55
}
56
56
57
/**
58
 * check if mandatory subfields are written
59
 */
60
function AreMandatoriesNotOk(){
61
    var mandatories = new Array();
62
    var mandatoriesfields = new Array();
63
    var   tab = new Array();
64
    var label = new Array();
65
    [% FOREACH BIG_LOO IN BIG_LOOP %]
66
    	[% FOREACH innerloo IN BIG_LOO.innerloop %]
67
			[% IF ( innerloo.mandatory ) %]
68
        		mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]"));
69
            [% END %]
70
    		[% FOREACH subfield_loo IN innerloo.subfield_loop %]
71
    			[% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
72
                    tab.push("[% BIG_LOO.number | html %]");
73
                    label.push("[% subfield_loo.marc_lib | $raw |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]");
74
    			[% END %]
75
			[% END %]
76
		[% END %]
77
	[% END %]
78
    var StrAlert = "";
79
    for(var i=0,len=mandatories.length; i<len ; i++){
80
        var id_string = mandatories[i];
81
        // alert (id_string);
82
        if( ! $("#" + id_string).val() ){
83
            $("#" + id_string).attr('class','subfield_not_filled').focus();
84
            StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n";
85
        }
86
    }
87
    
88
    /* Check for mandatories field(not subfields) */
89
    for(var i=0,len=mandatoriesfields.length; i<len; i++){
90
    	isempty  = true;
91
    	arr      = mandatoriesfields[i];
92
    	divid    = "tag_" + arr[0] + "_" + arr[1];
93
    	varegexp = new RegExp("^tag_" + arr[0] + "_code_");
94
95
		if(parseInt(arr[0]) >= 10){
96
	    	elem = document.getElementById(divid);
97
	    	eleminputs = elem.getElementsByTagName('input');
98
	    	
99
	    	for(var j=0,len2=eleminputs.length; j<len2; j++){
100
	
101
	    		if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
102
					inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
103
					
104
					for( var k=0; k<len2; k++){
105
						if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
106
							isempty = false
107
						}
108
					}
109
	    		}
110
	    	}
111
    	}else{
112
    		isempty = false;
113
    	}
114
    	
115
    	if(isempty){
116
    		flag = 1;
117
                StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
118
    	}
119
    	
120
    }
121
    
122
    
123
    if(StrAlert){
124
        return _("Can't save this record because the following field aren't filled :") + "\n\n" + StrAlert;
125
    }
126
    return false;
127
}
128
129
function Check(){
130
    var StrAlert = AreMandatoriesNotOk();
131
    if( ! StrAlert ){
132
        document.f.submit();
133
        return true;
134
    } else {
135
        alert(StrAlert);
136
        return false;
137
    }
138
}
139
140
function AddField(field,cntrepeatfield) {
57
function AddField(field,cntrepeatfield) {
141
    document.forms['f'].op.value = "addfield";
58
    document.forms['f'].op.value = "addfield";
142
    document.forms['f'].addfield_field.value=field;
59
    document.forms['f'].addfield_field.value=field;
Lines 221-226 function confirmnotdup(redirect){ Link Here
221
        <div class="btn-group">
138
        <div class="btn-group">
222
            <a class="btn btn-default btn-sm" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50 search</a>
139
            <a class="btn btn-default btn-sm" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50 search</a>
223
        </div>
140
        </div>
141
142
        <div class="btn-group">
143
            <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"></i> Settings <span class="caret"></span></button>
144
            <ul id="settings-menu" class="dropdown-menu">
145
                <li>
146
                    <a href="#" id="marcDocsSelect"><i class="fa fa-check-square-o"></i> Show MARC tag documentation links</a>
147
                <li>
148
                    <a href="#" id="marcTagsSelect"><i class="fa fa-check-square-o"></i> Show tags</a>
149
                </li>
150
            </ul>
151
        </div>
152
224
        <div class="btn-group">
153
        <div class="btn-group">
225
            [% IF ( authid ) %]
154
            [% IF ( authid ) %]
226
                <a class="btn btn-default btn-sm" id="cancel" href="/cgi-bin/koha/authorities/detail.pl?authid=[% authid | url %]">Cancel</a>
155
                <a class="btn btn-default btn-sm" id="cancel" href="/cgi-bin/koha/authorities/detail.pl?authid=[% authid | url %]">Cancel</a>
Lines 230-431 function confirmnotdup(redirect){ Link Here
230
        </div>
159
        </div>
231
    </div>
160
    </div>
232
161
233
<div id="authoritytabs" class="toptabs numbered">
162
    [% INCLUDE 'marc_editor.inc' maindiv='authoritytabs' marc21_doc_base='http://www.loc.gov/marc/authority/ad' unimarc_doc_base='https://www.ifla.org/publications/unimarc-authorities--3rd-edition--updates' %]
234
    <ul>
235
        [% FOREACH BIG_LOO IN BIG_LOOP %]
236
        <li><a href="#tab[% BIG_LOO.number | uri %]XX">[% BIG_LOO.number | html %]</a></li>
237
        [% END %]
238
    </ul>
239
163
240
[% FOREACH BIG_LOO IN BIG_LOOP %]
241
    <div id="tab[% BIG_LOO.number | html %]XX">
242
243
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
244
    [% IF ( innerloo.tag ) %]
245
    <div class="tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
246
        <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
247
        [% UNLESS hide_marc %]
248
            [% IF advancedMARCEditor %]
249
                <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to Expand this Tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a>
250
            [% ELSE %]
251
                <span title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
252
            [% END %]
253
                [% IF ( innerloo.fixedfield ) %]
254
                    <input type="text"
255
                        tabindex="1"
256
                        class="indicator flat"
257
                        style="display:none;"
258
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
259
                        size="1"
260
                        maxlength="1"
261
                        value="[% innerloo.indicator1 | html %]" />
262
                    <input type="text"
263
                        tabindex="1"
264
                        class="indicator flat"
265
                        style="display:none;"
266
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
267
                        size="1"
268
                        maxlength="1"
269
                        value="[% innerloo.indicator2 | html %]" />
270
                [% ELSE %]
271
                    <input type="text"
272
                        tabindex="1"
273
                        class="indicator flat"
274
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
275
                        size="1"
276
                        maxlength="1"
277
                        value="[% innerloo.indicator1 | html %]" />
278
                    <input type="text"
279
                        tabindex="1"
280
                        class="indicator flat"
281
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
282
                        size="1"
283
                        maxlength="1"
284
                        value="[% innerloo.indicator2 | html %]" />
285
                [% END %] -
286
        [% ELSE %]
287
                [% IF ( innerloo.fixedfield ) %]
288
                    <input type="hidden"
289
                        tabindex="1"
290
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
291
                        value="[% innerloo.indicator1 | html %]" />
292
                    <input type="hidden"
293
                        tabindex="1"
294
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
295
                        value="[% innerloo.indicator2 | html %]" />
296
                [% ELSE %]
297
                    <input type="hidden"
298
                        tabindex="1"
299
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
300
                        value="[% innerloo.indicator1 | html %]" />
301
                    <input type="hidden"
302
                        tabindex="1"
303
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
304
                        value="[% innerloo.indicator2 | html %]" />
305
                [% END %]
306
        [% END %]
307
308
            [% UNLESS advancedMARCEditor %]
309
                <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to Expand this Tag">[% innerloo.tag_lib | html %]</a>
310
            [% END %]
311
                <span class="field_controls">
312
                [% IF ( innerloo.repeatable ) %]
313
                    <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','[% hide_marc | html %]','[% advancedMARCEditor | html %]'); return false;" title="Repeat this Tag">
314
                        <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this Tag" />
315
                    </a>
316
                [% END %]
317
                    <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this Tag">
318
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this Tag" />
319
                    </a>
320
                </span>
321
322
        </div>
323
324
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
325
            <!--  One line on the marc editor -->
326
            <div class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
327
328
                [% UNLESS advancedMARCEditor %]
329
                    [% 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">
330
                    [% ELSE %]<label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
331
                    [% END %]
332
                [% END %]
333
                
334
                [% UNLESS hide_marc %]
335
                <span class="subfieldcode">
336
                    [% IF ( subfield_loo.fixedfield ) %]
337
                        <img class="buttonUp" style="display:none;" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
338
                    [% ELSE %]
339
                        <img class="buttonUp" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
340
                    [% END %]
341
                        <input type="text"
342
                            title="[% subfield_loo.marc_lib | $raw %]"
343
                            style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
344
                            name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
345
                            value="[% subfield_loo.subfield | html %]"
346
                            size="1"
347
                            maxlength="1"
348
                            class="flat"
349
                            tabindex="0" />
350
                </span>
351
                [% ELSE %]
352
                    <input type="hidden"
353
                        name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
354
                        value="[% subfield_loo.subfield | html %]" />
355
                [% END %]
356
357
                [% UNLESS advancedMARCEditor %]
358
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
359
                        [% subfield_loo.marc_lib | $raw %]
360
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
361
                    </span>
362
                    </label>
363
                [% END %]
364
                
365
                [% SET mv = subfield_loo.marc_value %]
366
                [% IF ( mv.type == 'select' ) %]
367
                     <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
368
                     [% FOREACH aval IN mv.values %]
369
                         [% IF aval == mv.default %]
370
                         <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
371
                         [% ELSE %]
372
                         <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
373
                         [% END %]
374
                     [% END %]
375
                     </select>
376
                [% ELSIF ( mv.type == 'text1' ) %]
377
                    <input type="text" id="[%- mv.id | html -%]" name="[%- mv.id | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" />
378
                    <a href="#" class="buttonDot" onclick="openAuth(this.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtypecode | html -%]','auth'); return false;" tabindex="1" title="Tag editor">...</a>
379
                [% ELSIF ( mv.type == 'text2' ) %]
380
                    <input type="text" id="[%- mv.id | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" />
381
                    [% IF mv.noclick %]
382
                        <a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup">...</a>
383
                    [% ELSE %]
384
                        <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor" title="Tag editor">...</a>
385
                    [% END %]
386
                    [% mv.javascript | $raw %]
387
                [% ELSIF ( mv.type == 'text' ) %]
388
                    <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]" />
389
                [% ELSIF ( mv.type == 'textarea' ) %]
390
                    <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]">[%- mv.value | html -%]</textarea>
391
                [% ELSIF ( mv.type == 'hidden' ) %]
392
                    <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
393
                [% ELSIF ( mv.type == 'hidden_simple' ) %]
394
                    <input type="hidden" name="[%- mv.name | html -%]" />
395
                [% END %]
396
397
                <span class="subfield_controls">
398
                [% IF ( subfield_loo.repeatable ) %]
399
                    <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;">
400
                        <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
401
                    </a>
402
                    <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
403
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
404
                    </a>
405
                [% END %]
406
                </span>
407
                
408
            </div>
409
            <!-- End of the line -->
410
        [% END %]
411
412
    </div>
413
    [% END %]<!-- if innerloo.tag -->
414
    [% END %]<!-- BIG_LOO.innerloop -->
415
    </div>
416
[% END %]<!-- BIG_LOOP -->
417
418
</div><!-- tabs -->
419
420
<div name="hidden" id="hidden" class="tab">
421
[% FOREACH hidden_loo IN hidden_loop %]
422
    <input type="hidden" name="tag" value="[% hidden_loo.tag | html %]" />
423
    <input type="hidden" name="subfield" value="[% hidden_loo.subfield | html %]" />
424
    <input type="hidden" name="mandatory" value="[% hidden_loo.mandatory | html %]" />
425
    <input type="hidden" name="kohafield" value="[% hidden_loo.kohafield | html %]" />
426
    <input type="hidden" name="tag_mandatory" value="[% hidden_loo.tag_mandatory | html %]" />
427
[% END %]
428
</div>
429
[% IF ( oldauthnumtagfield ) %]
164
[% IF ( oldauthnumtagfield ) %]
430
    <input type="hidden" name="tag" value="[% oldauthnumtagfield | html %]" />
165
    <input type="hidden" name="tag" value="[% oldauthnumtagfield | html %]" />
431
    <input type="hidden" name="subfield" value="[% oldauthnumtagsubfield | html %]" />
166
    <input type="hidden" name="subfield" value="[% oldauthnumtagsubfield | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-398 / +1 lines)
Lines 38-80 Link Here
38
            stickyClass: "floating"
38
            stickyClass: "floating"
39
        });
39
        });
40
40
41
        /* check cookie to hide/show marcdocs*/
42
        if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){
43
            toggleMARCdocLinks(false);
44
        } else {
45
            toggleMARCdocLinks(true);
46
        }
47
48
        $("#marcDocsSelect").click(function(){
49
            if($.cookie("marcdocs_[% borrowernumber | html %]") == 'hide'){
50
                toggleMARCdocLinks(true);
51
            } else {
52
                toggleMARCdocLinks(false);
53
            }
54
        });
55
56
        /* check cookie to hide/show marc tags*/
57
        var marctags_cookie = $.cookie("marctags_[% borrowernumber | html %]");
58
        if( marctags_cookie == 'hide'){
59
            toggleMARCTagLinks(false);
60
        } else if( marctags_cookie == 'show'){
61
            toggleMARCTagLinks(true)
62
        } else {
63
            [% UNLESS Koha.Preference("hide_marc") %]
64
                toggleMARCTagLinks(true)
65
            [% ELSE %]
66
                toggleMARCTagLinks(false);
67
            [% END %]
68
        }
69
70
        $("#marcTagsSelect").click(function(){
71
            if( $.cookie("marctags_[% borrowernumber | html %]") == 'hide'){
72
                toggleMARCTagLinks(true)
73
            } else {
74
                toggleMARCTagLinks(false);
75
            }
76
        });
77
78
        [%# Only ask for a confirmation if it is an edit %]
41
        [%# Only ask for a confirmation if it is an edit %]
79
        $("#z3950search").click(function(){
42
        $("#z3950search").click(function(){
80
            [% IF biblionumber %]
43
            [% IF biblionumber %]
Lines 168-370 function PopupZ3950() { Link Here
168
    } 
131
    } 
169
}
132
}
170
133
171
function PopupMARCFieldDoc(field) {
172
    [% IF Koha.Preference('marcfielddocurl') %]
173
        var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','&quot;') | html %]";
174
        docurl = docurl.replace("{MARC}", "[% marcflavour | html %]");
175
        docurl = docurl.replace("{FIELD}", ""+field);
176
        docurl = docurl.replace("{LANG}", "[% lang | html %]");
177
        window.open(docurl);
178
    [% ELSIF ( marcflavour == 'MARC21' ) %]
179
        _MARC21FieldDoc(field);
180
    [% ELSIF ( marcflavour == 'UNIMARC' ) %]
181
        _UNIMARCFieldDoc(field);
182
    [% END %]
183
}
184
185
function _MARC21FieldDoc(field) {
186
    if(field == 0) {
187
        window.open("http://www.loc.gov/marc/bibliographic/bdleader.html");
188
    } else if (field < 900) {
189
        window.open("http://www.loc.gov/marc/bibliographic/bd" + ("000"+field).slice(-3) + ".html");
190
    } else {
191
        window.open("http://www.loc.gov/marc/bibliographic/bd9xx.html");
192
    }
193
}
194
195
function _UNIMARCFieldDoc(field) {
196
    /* http://archive.ifla.org/VI/3/p1996-1/ is an outdated version of UNIMARC, but
197
       seems to be the only version available that can be linked to per tag.  More recent
198
       versions of the UNIMARC standard are available on the IFLA website only as
199
       PDFs!
200
    */
201
    var url;
202
    if (field == 0) {
203
        url = "http://archive.ifla.org/VI/3/p1996-1/uni.htm";
204
    } else {
205
        var first = field.substring(0,1);
206
        url = "http://archive.ifla.org/VI/3/p1996-1/uni" + first + ".htm#";
207
        if (first == 0) url = url + "b";
208
        url = first == 9
209
              ? "http://archive.ifla.org/VI/3/p1996-1/uni9.htm"
210
              : url + field;
211
    }
212
    window.open(url);
213
}
214
215
/*
216
 * Functions to hide/show marc docs and tags links
217
 */
218
219
function toggleMARCdocLinks(flag){
220
    if( flag === true ){
221
        $(".marcdocs").show();
222
        $.cookie("marcdocs_[% borrowernumber | html %]",'show', { path: "/", expires: 365 });
223
        $("#marcDocsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
224
    } else {
225
        $(".marcdocs").hide();
226
        $.cookie("marcdocs_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 });
227
        $("#marcDocsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
228
    }
229
}
230
231
function toggleMARCTagLinks(flag){
232
    if( flag === true ){
233
        $(".tagnum").show();
234
        $(".subfieldcode").show();
235
        $.cookie("marctags_[% borrowernumber | html %]",'show', { path: "/", expires: 365 });
236
        $("#marcTagsSelect i").addClass('fa-check-square-o').removeClass('fa-square-o');
237
    } else {
238
        $(".tagnum").hide();
239
        $(".subfieldcode").hide();
240
        $.cookie("marctags_[% borrowernumber | html %]",'hide', { path: "/", expires: 365 });
241
        $("#marcTagsSelect i").removeClass('fa-check-square-o').addClass('fa-square-o');
242
    }
243
}
244
245
/**
246
 * check if mandatory subfields are written
247
 */
248
function AreMandatoriesNotOk(){
249
    var mandatories = new Array();
250
    var mandatoriesfields = new Array();
251
    var tab = new Array();
252
    var label = new Array();
253
    var flag=0;
254
    var tabflag= new Array();  
255
    [% FOREACH BIG_LOO IN BIG_LOOP %]
256
    	[% FOREACH innerloo IN BIG_LOO.innerloop %]
257
	        [% IF ( innerloo.mandatory ) %]
258
    	    	mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]"));
259
        	[% END %]
260
    		[% FOREACH subfield_loo IN innerloo.subfield_loop %]
261
    			[% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
262
                   	tab.push("[% BIG_LOO.number | html %]");
263
                    label.push("[% subfield_loo.marc_lib | $raw %]");
264
                [% END %]
265
            [% END %]
266
        [% END %]
267
    [% END %]
268
    var StrAlert = _("Can't save this record because the following field aren't filled:");
269
    StrAlert += "\n\n";
270
    for(var i=0,len=mandatories.length; i<len ; i++){
271
        var tag=mandatories[i].substr(4,3);
272
        var subfield=mandatories[i].substr(17,1);
273
        var tagnumber=mandatories[i].substr(19,mandatories[i].lastIndexOf("_")-19);
274
        if (tabflag[tag+subfield+tagnumber] ==  null) { 
275
	    tabflag[tag+subfield+tagnumber]=new Array();
276
            tabflag[tag+subfield+tagnumber][0]=0; 
277
	}
278
        if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(mandatories[i]) != null && ! document.getElementById(mandatories[i]).value || document.getElementById(mandatories[i]) == null)){
279
            tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
280
            document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
281
            $('#' + mandatories[i]).focus();
282
            tabflag[tag+subfield+tagnumber][1]=label[i];
283
            tabflag[tag+subfield+tagnumber][2]=tab[i];
284
        } else {
285
            tabflag[tag+subfield+tagnumber][0] = 1;
286
        }    
287
    }
288
    for (var tagsubfieldid in tabflag){
289
      if (tabflag[tagsubfieldid][0]==0){
290
        var tag=tagsubfieldid.substr(0,3);
291
        var subfield=tagsubfieldid.substr(3,1);    
292
        StrAlert += "\t* "+_("tag %s subfield %s %s in tab %s").format(tag, subfield, tabflag[tagsubfieldid][1], tabflag[tagsubfieldid][2]) + "\n";
293
        //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; 
294
        flag=1;    
295
      }   
296
    }   
297
    
298
    /* Check for mandatories field(not subfields) */
299
    for(var i=0,len=mandatoriesfields.length; i<len; i++){
300
	    isempty  = true;
301
		arr      = mandatoriesfields[i];
302
    	divid    = "tag_" + arr[0] + "_" + arr[1];
303
    	varegexp = new RegExp("^tag_" + arr[0] + "_code_");
304
    	
305
		if(parseInt(arr[0]) >= 10){
306
	    	elem = document.getElementById(divid);
307
	    	eleminputs = elem.getElementsByTagName('input');
308
	    	
309
	    	for(var j=0,len2=eleminputs.length; j<len2; j++){
310
	
311
	    		if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
312
					inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
313
					
314
					for( var k=0; k<len2; k++){
315
						if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
316
							isempty = false
317
						}
318
					}
319
					
320
					elemselect = elem.getElementsByTagName('select');
321
					for( var k=0; k<elemselect.length; k++){
322
						if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
323
							isempty = false
324
						}
325
					}
326
	    		}
327
	    	}
328
329
	    	elemtextareas = elem.getElementsByTagName('textarea');
330
	    	for(var j=0,len2=elemtextareas.length; j<len2; j++){
331
                // this bit assumes that the only textareas in this context would be for subfields
332
                if (elemtextareas[j].value) {
333
                    isempty = false;
334
                }
335
            }
336
    	}else{
337
    		isempty = false;
338
    	}
339
    	
340
    	if(isempty){
341
    		flag = 1;
342
                StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
343
    	}
344
    	
345
    }
346
    
347
    if(flag){
348
	    return StrAlert;
349
	} else {
350
		return flag;
351
	}
352
}
353
354
/**
355
 *
356
 *
357
 */
358
function Check(){
359
    var StrAlert = AreMandatoriesNotOk();
360
    if( ! StrAlert ){
361
        document.f.submit();
362
        return true;
363
    } else {
364
        alert(StrAlert);
365
        return false;
366
    }
367
}
368
134
369
/** 
135
/** 
370
 * check if z3950 mandatories are set or not
136
 * check if z3950 mandatories are set or not
Lines 570-738 function Changefwk() { Link Here
570
        <input type="hidden" name="breedingid" value="[% breedingid | html %]" />
336
        <input type="hidden" name="breedingid" value="[% breedingid | html %]" />
571
        <input type="hidden" name="changed_framework" value="" />
337
        <input type="hidden" name="changed_framework" value="" />
572
338
573
<div id="addbibliotabs" class="toptabs numbered">
339
    [% INCLUDE 'marc_editor.inc' maindiv='addbibliotabs' marc21_doc_base='http://www.loc.gov/marc/bibliographic/bd' unimarc_doc_base='https://www.ifla.org/publications/unimarc-bibliographic--3rd-edition--updates-2012-and-updates-2016' %]
574
    <ul>
575
        [% FOREACH BIG_LOO IN BIG_LOOP %]
576
        <li><a href="#tab[% BIG_LOO.number | uri %]XX">[% BIG_LOO.number | html %]</a></li>
577
        [% END %]
578
    </ul>
579
580
[% FOREACH BIG_LOO IN BIG_LOOP %]
581
    <div id="tab[% BIG_LOO.number | html %]XX">
582
    
583
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
584
    [% IF ( innerloo.tag ) %]
585
    <div class="tag" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
586
        <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
587
            [% IF advancedMARCEditor %]
588
                <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to Expand this Tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a>
589
            [% ELSE %]
590
                <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
591
                [% IF marcflavour != 'NORMARC' %]<a href="#" class="marcdocs" onclick="PopupMARCFieldDoc('[% innerloo.tag | html %]'); return false;">&nbsp;?</a>[% END %]
592
            [% END %]
593
                [% IF ( innerloo.fixedfield ) %]
594
                    <input type="text"
595
                        tabindex="1"
596
                        class="indicator flat"
597
                        style="display:none;"
598
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
599
                        size="1"
600
                        maxlength="1"
601
                        value="[% innerloo.indicator1 | html %]" />
602
                    <input type="text"
603
                        tabindex="1"
604
                        class="indicator flat"
605
                        style="display:none;"
606
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
607
                        size="1"
608
                        maxlength="1"
609
                        value="[% innerloo.indicator2 | html %]" />
610
                [% ELSE %]
611
                    <input type="text"
612
                        tabindex="1"
613
                        class="indicator flat"
614
                        name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
615
                        size="1"
616
                        maxlength="1"
617
                        value="[% innerloo.indicator1 | html %]" />
618
                    <input type="text"
619
                        tabindex="1"
620
                        class="indicator flat"
621
                        name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
622
                        size="1"
623
                        maxlength="1"
624
                        value="[% innerloo.indicator2 | html %]" />
625
                [% END %] -
626
627
            [% UNLESS advancedMARCEditor %]
628
                <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to Expand this Tag">[% innerloo.tag_lib | html %]</a>
629
            [% END %]
630
                <span class="field_controls">
631
                [% IF ( innerloo.repeatable ) %]
632
                    <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','0','[% advancedMARCEditor | html %]'); return false;" title="Repeat this Tag">
633
                        <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this Tag" />
634
                    </a>
635
                [% END %]
636
                    <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this Tag">
637
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this Tag" />
638
                    </a>
639
                </span>
640
641
        </div>
642
643
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
644
            <!--  One line on the marc editor -->
645
            <div class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
646
647
                [% UNLESS advancedMARCEditor %]
648
                    [% 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">
649
                    [% ELSE %]<label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
650
                    [% END %]
651
                [% END %]
652
653
                <span class="subfieldcode">
654
                    [% IF ( subfield_loo.fixedfield ) %]
655
                        <img class="buttonUp" style="display:none;" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
656
                    [% ELSE %]
657
                        <img class="buttonUp" src="[% interface | html %]/[% theme | html %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]')" alt="Move Up" title="Move Up" />
658
                    [% END %]
659
                        <input type="text"
660
                            title="[% subfield_loo.marc_lib | $raw %]"
661
                            style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
662
                            name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
663
                            value="[% subfield_loo.subfield | html %]"
664
                            size="1"
665
                            maxlength="1"
666
                            class="flat"
667
                            tabindex="0" />
668
                </span>
669
670
                [% UNLESS advancedMARCEditor %]
671
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
672
                        [% subfield_loo.marc_lib | $raw %]
673
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
674
                    </span>
675
                    </label>
676
                [% END %]
677
                
678
                [% SET mv = subfield_loo.marc_value %]
679
                [% IF ( mv.type == 'text' ) %]
680
                    [% IF ( mv.readonly == 1 ) %]
681
                    <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" />
682
                    [% ELSE %]
683
                    <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 -%]" />
684
                    [% END %]
685
                    [% IF ( mv.authtype ) %]
686
                    <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>
687
                    [% END %]
688
                [% ELSIF ( mv.type == 'text_complex' ) %]
689
                    <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 -%]" />
690
                    <span class="subfield_controls">
691
                        [% IF mv.noclick %]
692
                            <a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup"></a>
693
                        [% ELSE %]
694
                            <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor framework_plugin" tabindex="1" title="Tag editor">Tag editor</a>
695
                        [% END %]
696
                    </span>
697
                    [% mv.javascript | $raw %]
698
                [% ELSIF ( mv.type == 'hidden' ) %]
699
                    <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 -%]" />
700
                [% ELSIF ( mv.type == 'textarea' ) %]
701
                    <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
702
                [% ELSIF ( mv.type == 'select' ) %]
703
                    <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
704
                    [% FOREACH aval IN mv.values %]
705
                        [% IF aval == mv.default %]
706
                        <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
707
                        [% ELSE %]
708
                        <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
709
                        [% END %]
710
                    [% END %]
711
                    </select>
712
                [% END %]
713
                
714
                <span class="subfield_controls">
715
                [% IF ( subfield_loo.repeatable ) %]
716
                    <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;">
717
                        <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
718
                    </a>
719
                    <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
720
                        <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
721
                    </a>
722
                [% END %]
723
                </span>
724
                
725
            </div>
726
            <!-- End of the line -->
727
        [% END %]
728
729
    </div>
730
    [% END %]<!-- if innerloo.tag -->
731
    [% END %]<!-- BIG_LOO.innerloop -->
732
    </div>
733
[% END %]<!-- BIG_LOOP -->
734
735
</div><!-- tabs -->
736
340
737
[%# Fields for fast cataloging %]
341
[%# Fields for fast cataloging %]
738
<input type="hidden" name="barcode" value="[% barcode | html %]" />
342
<input type="hidden" name="barcode" value="[% barcode | html %]" />
739
- 

Return to bug 21280