Bug 20731: Move template JavaScript to the footer: Call number browser MARC plugin
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / value_builder / marc21_field_008.tt
1 [% USE Asset %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Cataloging &rsaquo; 008 builder</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 </head>
7
8 <body id="cat_marc21_field_008" class="cat" style="padding:1em;" onload="loadXmlValues()">
9 <h3> 008 Fixed-length data elements--Additional material characteristics--General information</h3>
10
11 <table>
12     <tr id="tr_result">
13     </tr>
14 </table>
15 <h4 id="h4_result">&quot;[% result %]&quot;</h4>
16
17 <form name="f_pop" id="f_pop" onsubmit="report()" action="">
18     <div id="toolbar">
19         <div class="btn-group">
20             <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-save"></i> Save</button>
21         </div>
22         <div class="btn-group">
23             <button type="button" class="btn btn-default btn-sm close_window"><i class="fa fa-remove"></i> Cancel</button>
24         </div>
25     </div>
26
27 <input type="hidden" name="plugin_name" value="marc21_field_008.pl" />
28 <input type="hidden" id="[% index %]" name="index" value="[% index %]" />
29 <input type="hidden" name="result" id="result" value="[% result %]" />
30 <table id="table_material_types">
31     <tr id="tr_material_types">
32         <td><label for="material_type" title="Select a type of material to specify the variable values">Type of Material</label></td>
33         <td>
34             <select name="material_type" id="material_type" title="Select a type of material to specify the variable values" onchange="changeTypeofMaterial(this.form)">
35                 <option value="">Select a type of material</option>
36             </select>
37         </td>
38     </tr>
39
40 </table>
41 </form>
42
43 [% MACRO jsinclude BLOCK %]
44     [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") %]
45     [% Asset.js("js/xmlControlfield.js") %]
46     <script>
47         $(document).ready(function(){
48             $('#toolbar').fixFloat();
49             $(".close_window").on("click", function(e){
50                 e.preventDefault();
51                 window.close();
52             });
53         });
54         var objXmlControlField;
55         var tr_result;
56         var h4_result;
57
58         function loadXmlValues(){
59             [% IF ( errorXml ) %]
60                 alert("[% errorXml %]");
61             [% ELSE %]
62                 var form = document.f_pop;
63                 h4_result = document.getElementById("h4_result");
64                 tr_result = document.getElementById("tr_result");
65                 objXmlControlField = new xmlControlField('[% tagfield %]', 'f_pop', document.getElementById('material_type'), document.getElementById('table_material_types'), 'h4_result', 'tr_result', '', '[% themelang %]', '[% marcflavour %]');
66                 [%# If material type configuration is found using the leader, use that type when rendering. Otherwise, the default of BKS will be used %]
67                 [% IF ( material_configuration ) %]
68                     objXmlControlField.idMaterial = "[% material_configuration %]";
69                 [% END %]
70                 objXmlControlField.loadXmlValues();
71                 renderResult(tr_result, (form.result.value != "")?form.result.value:returnValueParam("result"));
72             [% END %]
73         } // loadXmlValues
74
75         function changeTypeofMaterial(form){
76             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))) {
77                 objXmlControlField.setIdMaterial(form.material_type.options[form.material_type.selectedIndex].value);
78                 objXmlControlField.renderTemplate();
79                 renderResult(tr_result, form.result.value, true);
80             }
81         } // changeTypeofMaterial
82
83         function report() {
84             var doc   = opener.document;
85             var field = doc.getElementById("[% index %]");
86             field.value = document.getElementById("result").value;
87             self.close();
88             return false;
89         }
90
91     </script>
92 [% END %]
93
94 [% INCLUDE 'intranet-bottom.inc' popup_window=1 %]