Merge remote-tracking branch 'origin/new/bug_8062'
[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 $(document).ready(function() {
47     new YAHOO.widget.Button("newframework");
48 });
49 //]]>
50 </script>
51 <script type="text/javascript">
52 /* Import/Export from/to spreadsheet */
53
54     var importing = false;
55
56     $(document).ready(function() {
57         $("body").css("cursor", "auto");
58         $('.import_export_options').hide();
59         $('a.import_export_fw').click(function() {
60             if (!importing) {
61                 $('.import_export_options').hide();
62                 $(this).next().show('slide');
63             }
64             return false;
65         });
66         $('.import_export_close').click(function() {
67             if (!importing) {
68                 $('.import_export_options').fadeOut('fast');
69                 $("body").css("cursor", "auto");
70             }
71         });
72         $('.input_import').val("");
73
74         var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
75         if (matches && matches.length > 1) {
76             alert(_("Error importing the framework ") + decodeURIComponent(matches[1]));
77         }
78     });
79     
80     $(function() {
81         $('input.input_import').change( function() {
82             var filename = $(this).val();
83             if ( ! /(?:\.csv|\.sql|\.ods|\.xml)$/.test(filename)) {
84                 $(this).css("background-color","yellow");
85                 alert(_('Please select an ods or xml file'));
86                 $(this).val("");
87                 $(this).css("background-color","white");
88             }
89         });
90         $('form.form_export').submit(function() {
91             $('.import_export_options').hide();
92             return true;
93         });
94         $('form.form_import').submit(function() {
95             var id = $(this).attr('id');
96             var obj = $('#' + id + ' input:file');
97             if (/(?:\.csv|\.sql|\.ods|\.xml)$/.test(obj.val())) {
98                 if (confirm('Do you really want to import the framework fields/subfields (will overwrite current configuration, for safety reasons please make before an export to have a backup file)?')) {
99                     var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
100                     $('#importing_' + frameworkcode).find("span").html("Importing <strong>" + frameworkcode + "</strong> from <i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>");
101                     if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
102                         var timestamp = new Date().getTime();
103                         $('#importing_' + frameworkcode).find("img").attr('src', '/intranet-tmpl/prog/img/loading.gif' + '?' +timestamp);
104                     }
105                     $('#importing_' + frameworkcode).css('display', 'block');
106                     if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
107                     importing = true;
108                     return true;
109                 } else
110                     return false;
111             }
112             obj.css("background-color","yellow");
113             alert(_('Please select an spreadsheet (csv, ods, xml) or sql file'));
114             obj.val("");
115             obj.css("background-color","white");
116             return false;
117         });
118     });
119     
120     
121
122 </script>
123
124 </head>
125 <body id="admin_biblio_framework" class="admin">
126 [% INCLUDE 'header.inc' %]
127 [% INCLUDE 'cat-search.inc' %]
128
129 <div id="breadcrumbs">
130         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
131 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
132 &rsaquo; <a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC frameworks</a>
133 [% IF ( add_form ) %]
134 &rsaquo; [% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]
135 [% ELSIF ( delete_confirm ) %]
136 &rsaquo; Delete framework for [% frameworktext %] ([% frameworkcode %])?
137 [% END %]
138 </div>
139
140 <div id="doc3" class="yui-t2">
141   <div id="bd">
142     <div id="yui-main">
143       <div class="yui-b">
144         
145 [% IF ( else ) %]<div id="toolbar">
146         <ul class="toolbar">
147     <li><a id="newframework" href="/cgi-bin/koha/admin/biblio_framework.pl?op=add_form">New framework</a></li>
148 </ul></div>[% END %]
149
150 [% IF ( add_form ) %]
151     <h1>[% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]</h1>
152     <form action="[% script_name %]" name="Aform" method="post" onsubmit="return Check(this);">
153         <input type="hidden" name="op" value="add_validate" />
154     <fieldset class="rows">
155     <ol>
156         [% IF ( frameworkcode ) %]
157         <li><span class="label">Framework code</span><input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode %]" />[% frameworkcode %]
158             <input type="hidden" name="modif" value="1" />
159         </li>
160         [% ELSE %]
161         <li><label for="frameworkcode">Framework code</label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" /></li>
162         [% END %]
163         <li><label for="description">Description</label>
164         <input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" /></li></ol></fieldset>
165         <fieldset class="action">       <input type="submit" value="Submit" class="submit" /></fieldset>
166     </form>
167 [% END %]
168
169 [% IF ( delete_confirm ) %]
170 <div class="dialog alert">
171     <h3>Delete framework for [% frameworktext %] ([% frameworkcode %])?</h3>
172     [% IF ( total ) %]
173        <p><strong>This framework is used [% total %] times</strong>.</p>
174     [% END %]
175     <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!" />
176     </form>
177     <form class="inline" action="[% script_name %]" method="get"><input type="submit" class="deny" value="No, do not delete!" /></form>
178 </div>
179 [% END %]
180
181 [% IF ( else ) %]
182 <h1>MARC frameworks</h1>
183 <p>Framework name, then go to MARC biblio to set MARC editor parameters</p>
184 <table>
185     <tr>
186         <th>Code</th>
187         <th>Description</th>
188         <th>&nbsp;</th>
189         <th>Edit</th>
190         <th>Delete</th>
191         <th title="Export framework structure (fields, subfields) to a spreadsheet file (.csv, .xml, .ods) or SQL file">Export</th>
192         <th title="Import framework structure (fields, subfields) from a spreadsheet file (.csv, .xml, .ods) or SQL file">Import</th>
193     </tr>
194     <tr>
195         <td>&nbsp;</td>
196         <td>Default framework</td>
197         <td><a href="marctagstructure.pl?frameworkcode=[% frameworkcode %]">MARC structure</a></td>
198         <td>&nbsp;</td>
199         <td>&nbsp;</td>
200         <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>
201             <div class="import_export_options">
202                 <form action="import_export_framework.pl" name="form_[% frameworkcode %]" method="get" target="_blank"  class="form_export">
203                     <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" />
204                     <ul>
205                         <li class="li_close_import_export"><span class="import_export_close" title="Close popup">Close</span></li>
206                         <li><input type="radio" name="type_export_[% frameworkcode %]" value="csv" id="type_export_[% frameworkcode %]" checked="checked" /><label for="type_export_[% frameworkcode %]" title="Export to CSV spreadsheet">Export to CSV spreadsheet</label></li>
207                         <li><input type="radio" name="type_export_[% frameworkcode %]" value="excel" id="type_export_[% frameworkcode %]" /><label for="type_export_[% frameworkcode %]" title="Export to Excel as XML format, compatible with OpenOffice/LibreOffice as well">Export to Excel with XML format</label></li>
208                         <li><input type="radio" name="type_export_[% frameworkcode %]" value="ods" id="type_export_[% frameworkcode %]" /><label for="type_export_[% frameworkcode %]">Export to OpenDocument spreadsheet format</label></li>
209                         <li><input type="radio" name="type_export_[% frameworkcode %]" value="sql" id="type_export_[% frameworkcode %]" /><label for="type_export_[% frameworkcode %]" title="Export to SQL">Export to SQL</label></li>
210                         <li><input type="submit" class="export_ok" href="#" value="Export" title="Export to a spreadsheet" /></li>
211                     </ul>
212                 </form>
213             </div>
214             </div>
215         </td>
216         <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>
217             <div class="import_export_options">
218                 <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">
219                     <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" />
220                     <input type="hidden" name="action" value="import" />
221                     <ul>
222                         <li class="li_close_import_export"><span class="import_export_close" title="Close popup">Close</span></li>
223                         <li><label for="file_import_[% frameworkcode %]" title="Import from a spreadsheet, formats available: ods, xml (formatted from excel)">Spreadsheet file</label><input type="file" name="file_import_[% frameworkcode %]" id="file_import_[% frameworkcode %]" class="input_import" value="" autocomplete="off" /></li>
224                         <li><input type="submit" class="import_ok" value="Import" title="Import from a spreadsheet" /><div id="importing_[% frameworkcode %]" style="display:none" class="importing"><img src="/intranet-tmpl/prog/img/loading.gif" /><span class="importing_msg"></span></div></li>
225                     </ul>
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, 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                         <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
246                         <ul>
247                             <li class="li_close_import_export"><span class="import_export_close" title="Close popup">Close</span></li>
248                             <li><input type="radio" name="type_export_[% loo.frameworkcode %]" value="csv" id="type_export_[% loo.frameworkcode %]" checked="checked" /><label for="type_export_[% loo.frameworkcode %]" title="Export to CSV spreadsheet">Export to CSV spreadsheet</label></li>
249                             <li><input type="radio" name="type_export_[% loo.frameworkcode %]" value="excel" id="type_export_[% loo.frameworkcode %]" /><label for="type_export_[% loo.frameworkcode %]" title="Export to Excel as XML format, compatible with OpenOffice/LibreOffice as well">Export to Excel as XML format</label></li>
250                             <li><input type="radio" name="type_export_[% loo.frameworkcode %]" value="ods" id="type_export_[% loo.frameworkcode %]" /><label for="type_export_[% loo.frameworkcode %]">Export to OpenDocument spreadsheet format</label></li>
251                             <li><input type="radio" name="type_export_[% loo.frameworkcode %]" value="sql" id="type_export_[% loo.frameworkcode %]" /><label for="type_export_[% loo.frameworkcode %]" title="Export to SQL">Export to SQL</label></li>
252                             <li><input type="submit" class="export_ok" href="#" value="Export" title="Export to a spreadsheet" /></li>
253                         </ul>
254                     </form>
255                 </div>
256                 </div>
257             </td>
258             <td><div class="import_export"><a class="import_export_fw" href="#" title="Import [% loo.frameworkcode %] framework structure (fields, subfields) from a spreadsheet file (.csv, .xml, .ods) or SQL file">Import</a>
259             <div class="import_export_options">
260                 <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">
261                     <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
262                     <input type="hidden" name="action" value="import" />
263                     <ul>
264                         <li class="li_close_import_export"><span class="import_export_close" title="Close popup">Close</span></li>
265                         <li><label for="file_import_[% loo.frameworkcode %]" title="Import from a spreadsheet, formats available: ods, xml (formatted from excel)">Spreadsheet file</label><input type="file" name="file_import_[% loo.frameworkcode %]" id="file_import_[% loo.frameworkcode %]" class="input_import" value="" autocomplete="off" /></li>
266                         <li><input type="submit" class="import_ok" value="Import" title="Import from a spreadsheet" /><div id="importing_[% loo.frameworkcode %]" style="display:none" class="importing"><img src="/intranet-tmpl/prog/img/loading.gif" /><span class="importing_msg"></span></div></li>
267                     </ul>
268                 </form>
269             </div>
270             </div>
271         </td>
272         </tr>
273     [% END %]
274 </table>
275     [% IF ( previous ) %]<a href="[% previous %]">&lt;&lt; Previous</a>[% END %]
276     [% IF ( next ) %]<a href="[% next %]">Next &gt;&gt;</a>[% END %]
277
278 [% END %]
279     </div>
280   </div>
281 <div class="yui-b">
282 [% INCLUDE 'admin-menu.inc' %]
283   </div>
284 </div>
285 [% INCLUDE 'intranet-bottom.inc' %]