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