baf8295acbd9bfc623ed7fcea887bc956a42e8c3
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / value_builder / marc21_field_008.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>008 builder &rsaquo; Cataloging &rsaquo; Koha</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="cat_marc21_field_008" class="cat" style="padding:1em;" onload="loadXmlValues()">
10 <h1> 008 Fixed-length data elements--Additional material characteristics--General information</h1>
11
12 <table>
13     <tr id="tr_result">
14     </tr>
15 </table>
16 <h4 id="h4_result">&quot;[% result | html %]&quot;</h4>
17
18 <form name="f_pop" id="f_pop" style="display:block" onsubmit="report()" action="">
19     <div id="toolbar">
20         <div class="btn-group">
21             <button type="submit" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
22         </div>
23         <div class="btn-group">
24             <button type="button" class="btn btn-default close_window"><i class="fa fa-remove"></i> Cancel</button>
25         </div>
26     </div>
27
28 <input type="hidden" name="plugin_name" value="marc21_field_008.pl" />
29 <input type="hidden" id="[% index | html %]" name="index" value="[% index | html %]" />
30 <input type="hidden" name="result" id="result" value="[% result | html %]" />
31 <table id="table_material_types">
32     <tr id="tr_material_types">
33         <td><label for="material_type" title="Select a type of material to specify the variable values">Type of Material</label></td>
34         <td>
35             <select name="material_type" id="material_type" title="Select a type of material to specify the variable values" onchange="changeTypeofMaterial(this.form)">
36                 <option value="">Select a type of material</option>
37             </select>
38         </td>
39     </tr>
40
41 </table>
42 </form>
43
44 [% MACRO jsinclude BLOCK %]
45     [% Asset.js("lib/hc-sticky.js") | $raw %]
46     [% Asset.js("js/xmlControlfield.js") | $raw %]
47     <script>
48         var Sticky;
49         $(document).ready(function(){
50             Sticky = $("#toolbar");
51             Sticky.hcSticky({
52                 stickTo: "#f_pop",
53                 stickyClass: "floating"
54             });
55             $(".close_window").on("click", function(e){
56                 e.preventDefault();
57                 window.close();
58             });
59         });
60         var objXmlControlField;
61         var tr_result;
62         var h4_result;
63
64         function loadXmlValues(){
65             $("#result").val( fix_field_008( $("#result").val() ) ); // fix field before loading elements
66
67             [% IF ( errorXml ) %]
68                 alert("[% errorXml | html %]");
69             [% ELSE %]
70                 var form = document.f_pop;
71                 h4_result = document.getElementById("h4_result");
72                 tr_result = document.getElementById("tr_result");
73                 objXmlControlField = new xmlControlField('[% tagfield | html %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang | html %]', '[% marcflavour | html %]');
74                 [%# If material type configuration is found using the leader, use that type when rendering. Otherwise, the default of BKS will be used %]
75                 [% IF ( material_configuration ) %]
76                     objXmlControlField.idMaterial = "[% material_configuration | html %]";
77                 [% END %]
78                 objXmlControlField.loadXmlValues();
79                 renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result"));
80             [% END %]
81         } // loadXmlValues
82
83         function changeTypeofMaterial(form){
84             if (form.material_type.options[form.material_type.selectedIndex].value != "" && confirm(_("Show values for '%s' material type?").format(form.material_type.options[form.material_type.selectedIndex].text))) {
85                 objXmlControlField.setIdMaterial(form.material_type.options[form.material_type.selectedIndex].value);
86                 objXmlControlField.renderTemplate();
87                 renderResult(tr_result, form.result.value, true);
88             }
89         } // changeTypeofMaterial
90
91         function report() {
92             var doc   = opener.document;
93             var field = doc.getElementById("[% index | html %]");
94             field.value = document.getElementById("result").value;
95             self.close();
96             return false;
97         }
98
99         function fix_field_008( myfield ) {
100             // If field length < 40, append from default008 starting at last complete data element
101
102             var j, position = [ 6, 7, 11, 15, 18, 35, 38, 39, 40 ], defaultvalue = '[% default008 | $raw %]';
103             for( j=0; j<position.length; j++ ) {
104                 if( myfield.length < position[j] ) break;
105             }
106             if( j == 0 ) {
107                 return defaultvalue;
108             } else if( j < position.length ) {
109                 return myfield.substring( 0, position[j-1] ) + defaultvalue.substring( position[j-1] );
110             }
111             return myfield;
112         }
113     </script>
114 [% END %]
115
116 [% INCLUDE 'intranet-bottom.inc' popup_window=1 %]