1 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Upload plugin</title>
6 <title>Koha › Tools › Upload</title>
8 [% INCLUDE 'doc-head-close.inc' %]
10 [% BLOCK plugin_pars %]
12 <input type="hidden" name="plugin" value="1" />
13 <input type="hidden" name="index" value="[% index %]" />
17 [% BLOCK breadcrumbs %]
18 <div id="breadcrumbs">
19 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
21 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
25 <span id="lastbreadcrumb">
26 [% IF mode=='new' || mode =='deleted'%]
27 Add new upload or search
36 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
37 [% PROCESS plugin_pars %]
38 <fieldset class="rows" id="uploadform">
39 <legend>Upload new files</legend>
42 <div id="fileuploadform">
43 <label for="fileToUpload">Select files: </label>
44 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
47 [% IF uploadcategories %]
49 <label for="uploadcategory">Category: </label>
50 <select id="uploadcategory" name="uploadcategory">
52 <option value=""></option>
54 [% FOREACH cat IN uploadcategories %]
55 <option value="[% cat.code %]">[% cat.name %]</option>
62 [% IF uploadcategories %]
63 <div class="hint">Note: For temporary uploads do not select a category.</div>
65 <div class="hint">Note: No upload categories are defined. Add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.</div>
71 <input type="hidden" id="public" name="public" value="1"/>
73 <label id="public_cb">Allow public downloads:</label>
74 <input type="checkbox" id="public" name="public" />
78 <fieldset class="action">
79 <button id="fileuploadbutton">Upload</button>
80 <button id="fileuploadcancel">Cancel</button>
83 <div id="fileuploadpanel">
84 <div id="fileuploadstatus" class="progress_panel">Upload progress:
85 <progress id="fileuploadprogress" max="100" value="0">
87 <span class="fileuploadpercent">0</span>%
89 <div id="fileuploadfailed"></div>
94 [% BLOCK form_search %]
95 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
96 [% PROCESS plugin_pars %]
97 <input type="hidden" name="op" value="search"/>
98 <fieldset class="rows">
99 <legend>Search uploads by name or hashvalue</legend>
102 <label for="term">Search term: </label>
103 <input type="text" id="term" name="term" value=""/>
106 <fieldset class="action">
107 <button id="searchbutton" class="submit">Search</button>
113 [% BLOCK submitter %]
114 <form id="submitter" style="display:none;" method="post">
115 [% PROCESS plugin_pars %]
116 <input type="hidden" name="op" id="op" value=""/>
117 <input type="hidden" name="id" id="id" value="" />
118 <input type="hidden" name="msg" id="msg" value="" />
124 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
131 <fieldset class="action">
132 <button class="submit">Back</button>
138 [% BLOCK newsearch %]
139 <form id="newsearch">
140 <fieldset class="action">
141 <button id="new_search">New search</button>
145 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
149 [% BLOCK table_results %]
157 [% IF !plugin %]<th>Public</th>[% END %]
158 [% IF !plugin %]<th>Temporary</th>[% END %]
163 [% FOREACH record IN uploads %]
165 <td>[% record.filename %]</td>
166 <td>[% record.filesize %]</td>
167 <td>[% record.hashvalue %]</td>
168 <td>[% record.uploadcategorycode %]</td>
170 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
171 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
175 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue %]"><i class="fa fa-plus"></i> Choose</button>
177 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id %]"><i class="fa fa-download"></i> Download</button>
178 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
179 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id %]"><i class="fa fa-trash"></i> Delete</button>
188 <style type="text/css">
189 #fileuploadstatus,#fileuploadfailed { display : none; }
190 #fileuploadstatus { margin:.4em; }
191 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
194 <script type="text/javascript">
197 "Error 0: Not in use",
198 _("This file already exists (in this category)."),
199 _("File could not be created. Check permissions."),
200 _("Your koha-conf.xml does not contain a valid upload_path."),
201 _("No temporary directory found."),
202 _("File could not be read."),
203 _("File has been deleted."),
204 _("File or upload record could not be deleted."),
208 <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
209 <script type="text/javascript">
211 function StartUpload() {
212 if( $('#fileToUpload').prop('files').length == 0 ) return;
213 $('#fileToUpload').prop('disabled',true);
214 $('#fileuploadbutton').hide();
215 $("#fileuploadcancel").show();
216 $("#fileuploadfailed").html('');
217 $("#myalerts").hide('');
218 $("#myalerts").html('');
219 $("#fileuploadstatus").show();
220 $("#uploadedfileid").val('');
221 $("#searchfile").hide();
222 $("#lastbreadcrumb").text( _("Add a new upload") );
225 if( $("#uploadcategory").val() )
226 cat = encodeURIComponent( $("#uploadcategory").val() );
227 if( cat ) xtra= 'category=' + cat + '&';
229 xtra = xtra + 'public=1&temp=0';
231 if( !cat ) xtra = 'temp=1&';
232 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
234 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
236 function CancelUpload() {
237 if( xhr ) xhr.abort();
238 $("#fileuploadstatus").hide();
239 $('#fileToUpload').prop('disabled', false);
240 $('#fileuploadbutton').show();
241 $("#fileuploadcancel").hide();
242 $("#fileuploadfailed").show();
243 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
245 function cbUpload( status, fileid, err ) {
246 $('#fileToUpload').prop('disabled', false);
247 if( status=='done' ) {
248 var e = err? JSON.stringify(err): '';
249 SubmitMe( 'search', fileid, e );
251 $('#fileuploadbutton').show();
252 $("#fileuploadcancel").hide();
253 $("#fileuploadstatus").hide();
254 $("#fileuploadfailed").show();
255 $("#fileuploadfailed").html( _("Upload status: ") +
256 ( status=='failed'? _("Failed"):
257 ( status=='denied'? _("Denied"): status ))
262 function ShowAlerts(err) {
264 for( var file in err ) {
265 str= str + '<p>' + file + ': ' +
266 errMESSAGES[ err[file] ] + '</p>';
269 $('#myalerts').html(str);
270 $('#myalerts').show();
273 function CheckSearch() {
274 if( $("#term").val()=="" ) {
275 alert( _("Please enter a search term.") );
280 function SubmitMe(op, id, msg ) {
281 $("#submitter #op").val( op );
282 $("#submitter #id").val( id );
283 $("#submitter #msg").val( msg );
284 $("#submitter").submit();
286 function DeleteEntry(id) {
287 if( !confirm( _("Do you really want to delete this upload?") ))
290 SubmitMe( 'delete', id );
292 function ClearField() {
294 $(window.opener.document).find('#[% index %]').val( '' );
297 function Choose(hashval) {
298 var res = '[% Koha.Preference('OPACBaseURL') %]';
299 res = res.replace( /\/$/, '');
300 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
302 $(window.opener.document).find('#[% index %]').val( res );
306 $(document).ready(function() {
308 ShowAlerts( [% msg %] );
310 $("#fileuploadcancel").hide();
311 $("#public_cb").click(function() {
312 $("#public").click();
314 $("#fileuploadbutton").on("click",function(e){
318 $("#fileuploadcancel").on("click",function(e){
322 $("#searchbutton").on("click",function(){
323 return CheckSearch();
325 $(".choose_entry").on("click",function(e){
327 var record_hashvalue = $(this).data("record-hashvalue");
328 Choose( record_hashvalue );
330 $(".download_entry").on("click",function(e){
332 var record_id = $(this).data("record-id");
333 SubmitMe( 'download', record_id );
335 $(".delete_entry").on("click",function(e){
337 var record_id = $(this).data("record-id");
338 DeleteEntry( record_id );
340 $("#new_search").on("click",function(e){
350 <body id="tools_upload" class="tools">
355 <body id="tools_upload" class="tools">
356 [% INCLUDE 'header.inc' %]
357 [% INCLUDE 'cat-search.inc' %]
358 [% PROCESS breadcrumbs %]
359 <div id="doc3" class="yui-t2">
368 <div class="dialog alert" id="myalerts" style="display:none;"></div>
370 [% PROCESS submitter %]
371 [% IF mode == 'new' || mode == 'deleted' %]
372 [% PROCESS form_new %]
373 [% PROCESS form_search %]
375 [% ELSIF mode == 'report' %]
377 <h3>Your request gave the following results:</h3>
378 [% PROCESS table_results %]
382 <h4>Sorry, your request had no results.</h4>
383 [% PROCESS newsearch %]
391 <div class="yui-b noprint">
392 [% INCLUDE 'tools-menu.inc' %]
397 [% INCLUDE 'intranet-bottom.inc' %]