Bug 11764 - Move repeatedly redefined function toUC() into staff-global.js
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / biblio_framework.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; MARC frameworks
3 [% IF ( add_form ) %]
4 &rsaquo; [% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]
5 [% ELSIF ( delete_confirm ) %]
6 &rsaquo; Delete framework for [% frameworktext %] ([% frameworkcode %])?
7 [% END %]
8 </title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 <script type="text/javascript">
11 //<![CDATA[
12
13 function isNotNull(f,noalert) {
14     if (f.value.length ==0) {
15         return false;
16     }
17     return true;
18 }
19 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20 function Check(f) {
21     var ok=1;
22     var _alertString="";
23     var alertString2;
24     if (f.frameworkcode.value.length==0) {
25         _alertString += "\n- " + _("Framework code missing");
26     }
27     if (!(isNotNull(window.document.Aform.frameworktext))) {
28         _alertString += "\n- " + _("Description missing");
29     }
30     if (_alertString.length==0) {
31         document.Aform.submit();
32     } else {
33         alertString2  = _("Form not submitted because of the following problem(s)");
34         alertString2 += "\n------------------------------------------------------------------------------------\n";
35         alertString2 += _alertString;
36         alert(alertString2);
37         return false;
38     }
39     return true;
40 }
41
42 //]]>
43 </script>
44 <script type="text/javascript">
45 /* Import/Export from/to spreadsheet */
46
47     var importing = false;
48
49     $(document).ready(function() {
50         $("body").css("cursor", "auto");
51         $('.import_export_options').hide();
52         $('a.import_export_fw').click(function() {
53             if (!importing) {
54                 $('.import_export_options').hide();
55                 $(this).next().show('slide');
56             }
57             return false;
58         });
59         $('.import_export_close').click(function() {
60             if (!importing) {
61                 $('.import_export_options').fadeOut('fast');
62                 $("body").css("cursor", "auto");
63                 return false;
64             }
65         });
66         $('.input_import').val("");
67
68         var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
69         if (matches && matches.length > 1) {
70             alert(_("Error importing the framework ") + decodeURIComponent(matches[1]));
71         }
72
73         $('input.input_import').change( function() {
74             var filename = $(this).val();
75             if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
76                 $(this).css("background-color","yellow");
77                 alert(_("Please select an ods or xml file"));
78                 $(this).val("");
79                 $(this).css("background-color","white");
80             }
81         });
82         $('form.form_export').submit(function() {
83             $('.modal').modal("hide");
84             return true;
85         });
86         $('form.form_import').submit(function() {
87             var id = $(this).attr('id');
88             var obj = $('#' + id + ' input:file');
89             if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
90                 if (confirm(_("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) {
91                     var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
92                     $('#importing_' + frameworkcode).find("span").html(_("Importing to framework:")+"<strong>" + frameworkcode + "</strong>. " +_("Importing from file:")+"<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>");
93                     if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
94                         var timestamp = new Date().getTime();
95                         $('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp);
96                     }
97                     $('#importing_' + frameworkcode).css('display', 'block');
98                     if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
99                     importing = true;
100                     $(".modal-footer,.closebtn").hide();
101                     return true;
102                 } else
103                     return false;
104             }
105             obj.css("background-color","yellow");
106             alert(_("Please select an spreadsheet (csv, ods, xml) file"));
107             obj.val("");
108             obj.css("background-color","white");
109             return false;
110         });
111     });
112
113 </script>
114
115 </head>
116 <body id="admin_biblio_framework" class="admin">
117 [% INCLUDE 'header.inc' %]
118 [% INCLUDE 'cat-search.inc' %]
119
120 <div id="breadcrumbs">
121         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
122 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
123 &rsaquo; <a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC frameworks</a>
124 [% IF ( add_form ) %]
125 &rsaquo; [% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]
126 [% ELSIF ( delete_confirm ) %]
127 &rsaquo; Delete framework for [% frameworktext %] ([% frameworkcode %])?
128 [% END %]
129 </div>
130
131 <div id="doc3" class="yui-t2">
132   <div id="bd">
133     <div id="yui-main">
134       <div class="yui-b">
135
136 [% IF ( else ) %]
137 <div id="toolbar" class="btn-toolbar">
138     <a class="btn btn-small" id="newframework" href="/cgi-bin/koha/admin/biblio_framework.pl?op=add_form"><i class="icon-plus"></i> New framework</a>
139 </div>
140 [% END %]
141
142 [% IF ( add_form ) %]
143     <h1>[% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]</h1>
144     <form action="[% script_name %]" name="Aform" method="post" onsubmit="return Check(this);">
145         <input type="hidden" name="op" value="add_validate" />
146     <fieldset class="rows">
147     <ol>
148         [% IF ( frameworkcode ) %]
149         <li><span class="label">Framework code: </span><input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode %]" />[% frameworkcode %]
150             <input type="hidden" name="modif" value="1" />
151         </li>
152         [% ELSE %]
153         <li><label for="frameworkcode">Framework code: </label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" /></li>
154         [% END %]
155         <li><label for="description">Description: </label>
156         <input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" /></li></ol></fieldset>
157         <fieldset class="action">       <input type="submit" value="Submit" class="submit" /></fieldset>
158     </form>
159 [% END %]
160
161 [% IF ( delete_confirm ) %]
162 <div class="dialog alert">
163     <h3>Delete framework for [% frameworktext %] ([% frameworkcode %])?</h3>
164     [% IF ( total ) %]
165        <p><strong>This framework is used [% total %] times</strong>.</p>
166     [% END %]
167     <form class="inline" action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="frameworkcode" value="[% frameworkcode %]" /><input type="submit" class="approve" value="Yes, delete this framework!" />
168     </form>
169     <form class="inline" action="[% script_name %]" method="get"><input type="submit" class="deny" value="No, do not delete!" /></form>
170 </div>
171 [% END %]
172
173 [% IF ( else ) %]
174 <h1>MARC frameworks</h1>
175 <p>Framework name, then go to MARC biblio to set MARC editor parameters</p>
176 <table>
177     <tr>
178         <th>Code</th>
179         <th>Description</th>
180         <th>&nbsp;</th>
181         <th>Edit</th>
182         <th>Delete</th>
183         <th title="Export framework structure (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)">Export</th>
184         <th title="Import framework structure (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)">Import</th>
185     </tr>
186     <tr>
187         <td>&nbsp;</td>
188         <td>Default framework</td>
189         <td><a href="marctagstructure.pl?frameworkcode=[% frameworkcode %]">MARC structure</a></td>
190         <td>&nbsp;</td>
191         <td>&nbsp;</td>
192         <td>
193
194             <!-- Button to trigger modal -->
195             <a href="#" data-toggle="modal" data-target="#exportModal_[% frameworkcode %]">Export</a>
196             <!-- Modal -->
197             <div class="modal hide" id="exportModal_[% frameworkcode %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% frameworkcode %]" aria-hidden="true">
198                 <div class="modal-header">
199                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
200                     <h3 id="exportLabelexportModal_[% frameworkcode %]">Export default framework</h3>
201                 </div>
202                 <form action="import_export_framework.pl" name="form_[% frameworkcode %]" method="get" target="_blank"  class="form_export">
203                     <div class="modal-body">
204                         <fieldset>
205                             <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" />
206                             <p><label for="csv_type_export_[% frameworkcode %]"><input type="radio" name="type_export_[% frameworkcode %]" value="csv" id="csv_type_export_[% frameworkcode %]" checked="checked" /> Export to CSV spreadsheet</label></p>
207                             <p><label for="xml_type_export_[% frameworkcode %]"><input type="radio" name="type_export_[% frameworkcode %]" value="excel" id="xml_type_export_[% frameworkcode %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
208                             <p><label for="ods_type_export_[% frameworkcode %]"><input type="radio" name="type_export_[% frameworkcode %]" value="ods" id="ods_type_export_[% frameworkcode %]" /> Export to OpenDocument spreadsheet format</label></p>
209
210                         </fieldset>
211                     </div>
212                     <div class="modal-footer">
213                         <button type="submit" class="btn">Export</button>
214                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
215                     </div>
216                 </form>
217             </div>
218
219         </td>
220         <td>
221
222             <!-- Button to trigger modal -->
223             <a href="#" data-toggle="modal" data-target="#importModal_[% frameworkcode %][% loop.count %]">Import</a>
224             <!-- Modal -->
225             <div class="modal hide" id="importModal_[% frameworkcode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% frameworkcode %][% loop.count %]" aria-hidden="true">
226                 <div class="modal-header">
227                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
228                     <h3 id="importLabelexportModal_[% frameworkcode %][% loop.count %]">Import default framework structure (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
229                 </div>
230                 <form action="/cgi-bin/koha/admin/import_export_framework.pl" name="form_i_[% frameworkcode %]" id="form_i_[% frameworkcode %]" method="post" enctype="multipart/form-data" class="form_import">
231                     <div class="modal-body">
232                             <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" />
233                             <input type="hidden" name="action" value="import" />
234                             <p><label for="file_import_[% frameworkcode %]">Upload file:</label> <input type="file" name="file_import_[% frameworkcode %]" id="file_import_[% frameworkcode %]" class="input_import" /></p>
235                             <div id="importing_[% frameworkcode %]" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
236                     </div>
237                     <div class="modal-footer">
238                         <button type="submit" class="btn">Import</button>
239                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
240                     </div>
241                 </form>
242             </div>
243
244         </td>
245     </tr>
246     <!-- note highlight assignment appears backwards because we already have a normal row for Default -->
247     [% FOREACH loo IN loop %]
248         [% IF ( loop.odd ) %]<tr class="highlight">
249         [% ELSE %]<tr>
250         [% END %]
251             <td>[% loo.frameworkcode %]</td>
252             <td>[% loo.frameworktext %]</td>
253             <td><a href="marctagstructure.pl?frameworkcode=[% loo.frameworkcode %]" >MARC structure</a></td>
254             <td><a href="[% loo.script_name %]?op=add_form&amp;frameworkcode=[% loo.frameworkcode |html %]">Edit</a></td>
255             <td><a href="[% loo.script_name %]?op=delete_confirm&amp;frameworkcode=[% loo.frameworkcode |html %]">Delete</a></td>
256             <td>
257
258                 <!-- Button to trigger modal -->
259                 <a href="#" data-toggle="modal" data-target="#exportModal_[% loo.frameworkcode %][% loop.count %]">Export</a>
260                 <!-- Modal -->
261                 <div class="modal hide" id="exportModal_[% loo.frameworkcode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% loo.frameworkcode %][% loop.count %]" aria-hidden="true">
262                     <div class="modal-header">
263                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
264                         <h3 id="exportLabelexportModal_[% loo.frameworkcode %][% loop.count %]">Export [% loo.frameworktext %] framework</h3>
265                     </div>
266                     <form action="import_export_framework.pl" name="form_[% loo.frameworkcode %]" method="get" target="_blank"  class="form_export">
267                         <div class="modal-body">
268                             <fieldset>
269                                 <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
270                                 <p><label for="csv_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="csv" id="csv_type_export_[% loo.frameworkcode %][% loop.count %]" checked="checked" /> Export to CSV spreadsheet</label></p>
271                                 <p><label for="xml_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="excel" id="xml_type_export_[% loo.frameworkcode %][% loop.count %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
272                                 <p><label for="ods_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="ods" id="ods_type_export_[% loo.frameworkcode %][% loop.count %]" /> Export to OpenDocument spreadsheet format</label></p>
273
274                             </fieldset>
275                         </div>
276                         <div class="modal-footer">
277                             <button type="submit" class="btn">Export</button>
278                             <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
279                         </div>
280                     </form>
281                 </div>
282             </td>
283             <td>
284
285                 <!-- Button to trigger modal -->
286                 <a href="#" data-toggle="modal" data-target="#importModal_[% loo.frameworkcode %][% loop.count %]">Import</a>
287                 <!-- Modal -->
288                 <div class="modal hide" id="importModal_[% loo.frameworkcode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% loo.frameworkcode %][% loop.count %]" aria-hidden="true">
289                     <div class="modal-header">
290                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
291                         <h3 id="importLabelexportModal_[% loo.frameworkcode %][% loop.count %]">Import [% loo.frameworkcode %] framework structure (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
292                     </div>
293                     <form action="/cgi-bin/koha/admin/import_export_framework.pl" name="form_i_[% loo.frameworkcode %]" id="form_i_[% loo.frameworkcode %]" method="post" enctype="multipart/form-data" class="form_import">
294                         <div class="modal-body">
295                                 <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
296                                 <input type="hidden" name="action" value="import" />
297                                 <p><label for="file_import_[% loo.frameworkcode %]">Upload file:</label> <input type="file" name="file_import_[% loo.frameworkcode %]" id="file_import_[% loo.frameworkcode %]" class="input_import" /></p>
298                                 <div id="importing_[% loo.frameworkcode %]" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
299                         </div>
300                         <div class="modal-footer">
301                             <button type="submit" class="btn">Import</button>
302                             <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
303                         </div>
304                     </form>
305                 </div>
306         </td>
307         </tr>
308     [% END %]
309 </table>
310     [% IF ( previous ) %]<a href="[% previous %]">&lt;&lt; Previous</a>[% END %]
311     [% IF ( next ) %]<a href="[% next %]">Next &gt;&gt;</a>[% END %]
312
313 [% END %]
314     </div>
315   </div>
316 <div class="yui-b">
317 [% INCLUDE 'admin-menu.inc' %]
318   </div>
319 </div>
320 [% INCLUDE 'intranet-bottom.inc' %]