4 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Upload plugin</title>
8 <title>Koha › Tools › Upload</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("css/datatables.css") %]
13 [% BLOCK plugin_pars %]
15 <input type="hidden" name="plugin" value="1" />
16 <input type="hidden" name="index" value="[% index %]" />
20 [% BLOCK breadcrumbs %]
21 <div id="breadcrumbs">
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
26 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
28 <span id="lastbreadcrumb">
29 [% IF mode=='new' || mode =='deleted'%]
30 Add new upload or search
39 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
40 [% PROCESS plugin_pars %]
41 <fieldset class="rows" id="uploadform">
42 <legend>Upload new files</legend>
45 <div id="fileuploadform">
46 <label for="fileToUpload">Select files: </label>
47 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
50 [% IF uploadcategories %]
52 <label for="uploadcategory">Category: </label>
53 <select id="uploadcategory" name="uploadcategory">
55 <option value=""></option>
57 [% FOREACH cat IN uploadcategories %]
58 <option value="[% cat.code %]">[% cat.name %]</option>
65 [% IF uploadcategories %]
66 <div class="hint">Note: For temporary uploads do not select a category.</div>
68 <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>
74 <input type="hidden" id="public" name="public" value="1"/>
76 <label id="public_cb">Allow public downloads:</label>
77 <input type="checkbox" id="public" name="public" />
81 <fieldset class="action">
82 <button id="fileuploadbutton">Upload</button>
83 <button id="fileuploadcancel">Cancel</button>
86 <div id="fileuploadpanel">
87 <div id="fileuploadstatus" class="progress_panel">Upload progress:
88 <progress id="fileuploadprogress" max="100" value="0">
90 <span class="fileuploadpercent">0</span>%
92 <div id="fileuploadfailed"></div>
97 [% BLOCK form_search %]
98 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
99 [% PROCESS plugin_pars %]
100 <input type="hidden" name="op" value="search"/>
101 <fieldset class="rows">
102 <legend>Search uploads by name or hashvalue</legend>
105 <label for="term">Search term: </label>
106 <input type="text" id="term" name="term" value=""/>
109 <fieldset class="action">
110 <button id="searchbutton" class="submit">Search</button>
116 [% BLOCK submitter %]
117 <form id="submitter" style="display:none;" method="post">
118 [% PROCESS plugin_pars %]
119 <input type="hidden" name="op" id="op" value=""/>
120 <input type="hidden" name="id" id="id" value="" />
121 <input type="hidden" name="msg" id="msg" value="" />
127 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
134 <fieldset class="action">
135 <button class="submit">Back</button>
141 [% BLOCK newsearch %]
142 <form id="newsearch">
143 <fieldset class="action">
144 <button id="new_search">New search</button>
148 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
152 [% BLOCK table_results %]
153 <table id="uploadresults">
160 [% IF !plugin %]<th>Public</th>[% END %]
161 [% IF !plugin %]<th>Temporary</th>[% END %]
162 <th class="nosort">Actions</th>
166 [% FOREACH record IN uploads %]
168 <td>[% record.filename %]</td>
169 <td>[% record.filesize %]</td>
170 <td>[% record.hashvalue %]</td>
171 <td>[% record.uploadcategorycode %]</td>
173 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
174 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
178 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue %]"><i class="fa fa-plus"></i> Choose</button>
180 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id %]"><i class="fa fa-download"></i> Download</button>
181 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
182 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id %]"><i class="fa fa-trash"></i> Delete</button>
191 <style type="text/css">
192 #fileuploadstatus,#fileuploadfailed { display : none; }
193 #fileuploadstatus { margin:.4em; }
194 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
201 <body id="tools_upload" class="tools">
206 <body id="tools_upload" class="tools">
207 [% INCLUDE 'header.inc' %]
208 [% INCLUDE 'cat-search.inc' %]
209 [% PROCESS breadcrumbs %]
210 <div id="doc3" class="yui-t2">
219 <div class="dialog alert" id="myalerts" style="display:none;"></div>
221 [% PROCESS submitter %]
222 [% IF mode == 'new' || mode == 'deleted' %]
223 [% PROCESS form_new %]
224 [% PROCESS form_search %]
226 [% ELSIF mode == 'report' %]
228 <h3>Your request gave the following results:</h3>
229 [% PROCESS table_results %]
233 <h4>Sorry, your request had no results.</h4>
234 [% PROCESS newsearch %]
242 <div class="yui-b noprint">
243 [% INCLUDE 'tools-menu.inc' %]
249 [% MACRO jsinclude BLOCK %]
250 [% Asset.js("js/tools-menu.js") %]
251 [% INCLUDE 'datatables.inc' %]
252 <script type="text/javascript">
254 "Error 0: Not in use",
255 _("This file already exists (in this category)."),
256 _("File could not be created. Check permissions."),
257 _("Your koha-conf.xml does not contain a valid upload_path."),
258 _("No temporary directory found."),
259 _("File could not be read."),
260 _("File has been deleted."),
261 _("File or upload record could not be deleted."),
264 [% Asset.js("js/file-upload.js") %]
265 <script type="text/javascript">
266 function StartUpload() {
267 if( $('#fileToUpload').prop('files').length == 0 ) return;
268 $('#fileToUpload').prop('disabled',true);
269 $('#fileuploadbutton').hide();
270 $("#fileuploadcancel").show();
271 $("#fileuploadfailed").html('');
272 $("#myalerts").hide('');
273 $("#myalerts").html('');
274 $("#fileuploadstatus").show();
275 $("#uploadedfileid").val('');
276 $("#searchfile").hide();
277 $("#lastbreadcrumb").text( _("Add a new upload") );
280 if( $("#uploadcategory").val() )
281 cat = encodeURIComponent( $("#uploadcategory").val() );
282 if( cat ) xtra= 'category=' + cat + '&';
284 xtra = xtra + 'public=1&temp=0';
286 if( !cat ) xtra = 'temp=1&';
287 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
289 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
291 function CancelUpload() {
292 if( xhr ) xhr.abort();
293 $("#fileuploadstatus").hide();
294 $('#fileToUpload').prop('disabled', false);
295 $('#fileuploadbutton').show();
296 $("#fileuploadcancel").hide();
297 $("#fileuploadfailed").show();
298 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
300 function cbUpload( status, fileid, err ) {
301 $('#fileToUpload').prop('disabled', false);
302 if( status=='done' ) {
303 var e = err? JSON.stringify(err): '';
304 SubmitMe( 'search', fileid, e );
306 $('#fileuploadbutton').show();
307 $("#fileuploadcancel").hide();
308 $("#fileuploadstatus").hide();
309 $("#fileuploadfailed").show();
310 $("#fileuploadfailed").html( _("Upload status: ") +
311 ( status=='failed'? _("Failed"):
312 ( status=='denied'? _("Denied"): status ))
317 function ShowAlerts(err) {
319 for( var file in err ) {
320 str= str + '<p>' + file + ': ' +
321 errMESSAGES[ err[file].code ] + '</p>';
324 $('#myalerts').html(str);
325 $('#myalerts').show();
328 function CheckSearch() {
329 if( $("#term").val()=="" ) {
330 alert( _("Please enter a search term.") );
335 function SubmitMe(op, id, msg ) {
336 $("#submitter #op").val( op );
337 $("#submitter #id").val( id );
338 $("#submitter #msg").val( msg );
339 $("#submitter").submit();
341 function DeleteEntry(id) {
342 if( !confirm( _("Do you really want to delete this upload?") ))
345 SubmitMe( 'delete', id );
347 function ClearField() {
349 $(window.opener.document).find('#[% index %]').val( '' );
352 function Choose(hashval) {
353 var res = '[% Koha.Preference('OPACBaseURL') %]';
354 res = res.replace( /\/$/, '');
355 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
357 $(window.opener.document).find('#[% index %]').val( res );
361 $(document).ready(function() {
362 $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
364 { 'bSortable': false, 'aTargets': [ 'nosort' ] }
366 "sPaginationType": "four_button"
369 ShowAlerts( [% msg %] );
371 $("#fileuploadcancel").hide();
372 $("#public_cb").click(function() {
373 $("#public").click();
375 $("#fileuploadbutton").on("click",function(e){
379 $("#fileuploadcancel").on("click",function(e){
383 $("#searchbutton").on("click",function(){
384 return CheckSearch();
386 $(".choose_entry").on("click",function(e){
388 var record_hashvalue = $(this).data("record-hashvalue");
389 Choose( record_hashvalue );
391 $(".download_entry").on("click",function(e){
393 var record_id = $(this).data("record-id");
394 SubmitMe( 'download', record_id );
396 $(".delete_entry").on("click",function(e){
398 var record_id = $(this).data("record-id");
399 DeleteEntry( record_id );
401 $("#new_search").on("click",function(e){
409 [% INCLUDE 'intranet-bottom.inc' %]