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