5 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Upload plugin</title>
9 <title>Koha › Tools › Upload</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/datatables.css") | $raw %]
14 [% BLOCK plugin_pars %]
16 <input type="hidden" name="plugin" value="1" />
17 <input type="hidden" name="index" value="[% index | html %]" />
21 [% BLOCK breadcrumbs %]
22 <div id="breadcrumbs">
23 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
25 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
27 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
29 <span id="lastbreadcrumb">
30 [% IF mode=='new' || mode =='deleted'%]
31 Add new upload or search
40 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
41 [% PROCESS plugin_pars %]
42 <fieldset class="rows" id="uploadform">
43 <legend>Upload new files</legend>
46 <div id="fileuploadform">
47 <label for="fileToUpload">Select files: </label>
48 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
51 [% IF uploadcategories %]
53 <label for="uploadcategory">Category: </label>
54 <select id="uploadcategory" name="uploadcategory">
56 <option value=""></option>
58 [% FOREACH cat IN uploadcategories %]
59 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
66 [% IF uploadcategories %]
67 <div class="hint">Note: For temporary uploads do not select a category.</div>
69 <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>
75 <input type="hidden" id="public" name="public" value="1"/>
77 <label id="public_cb">Allow public downloads:</label>
78 <input type="checkbox" id="public" name="public" />
82 <fieldset class="action">
83 <button id="fileuploadbutton">Upload</button>
84 <button id="fileuploadcancel">Cancel</button>
87 <div id="fileuploadpanel">
88 <div id="fileuploadstatus" class="progress_panel">Upload progress:
89 <progress id="fileuploadprogress" max="100" value="0">
91 <span class="fileuploadpercent">0</span>%
93 <div id="fileuploadfailed"></div>
98 [% BLOCK form_search %]
99 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
100 [% PROCESS plugin_pars %]
101 <input type="hidden" name="op" value="search"/>
102 <fieldset class="rows">
103 <legend>Search uploads by name or hashvalue</legend>
106 <label for="term">Search term: </label>
107 <input type="text" id="term" name="term" value=""/>
110 <fieldset class="action">
111 <button id="searchbutton" class="submit">Search</button>
117 [% BLOCK submitter %]
118 <form id="submitter" style="display:none;" method="post">
119 [% PROCESS plugin_pars %]
120 <input type="hidden" name="op" id="op" value=""/>
121 <input type="hidden" name="id" id="id" value="" />
122 <input type="hidden" name="msg" id="msg" value="" />
128 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
135 <fieldset class="action">
136 <button class="submit">Back</button>
142 [% BLOCK newsearch %]
143 <form id="newsearch">
144 <fieldset class="action">
145 <button id="new_search">New search</button>
149 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
153 [% BLOCK table_results %]
154 <table id="uploadresults">
161 [% IF !plugin %]<th>Public</th>[% END %]
162 [% IF !plugin %]<th>Temporary</th>[% END %]
163 <th class="nosort">Actions</th>
167 [% FOREACH record IN uploads %]
169 <td>[% record.filename | html %]</td>
170 <td>[% record.filesize | html %]</td>
171 <td>[% record.hashvalue | html %]</td>
172 <td>[% record.uploadcategorycode | html %]</td>
174 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
175 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
179 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
181 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
182 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
183 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
192 <style type="text/css">
193 #fileuploadstatus,#fileuploadfailed { display : none; }
194 #fileuploadstatus { margin:.4em; }
195 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
202 <body id="tools_upload" class="tools">
207 <body id="tools_upload" class="tools">
208 [% INCLUDE 'header.inc' %]
209 [% INCLUDE 'cat-search.inc' %]
210 [% PROCESS breadcrumbs %]
211 <div id="doc3" class="yui-t2">
220 <div class="dialog alert" id="myalerts" style="display:none;"></div>
222 [% PROCESS submitter %]
223 [% IF mode == 'new' || mode == 'deleted' %]
224 [% PROCESS form_new %]
225 [% PROCESS form_search %]
227 [% ELSIF mode == 'report' %]
229 <h3>Your request gave the following results:</h3>
230 [% PROCESS table_results %]
234 <h4>Sorry, your request had no results.</h4>
235 [% PROCESS newsearch %]
243 <div class="yui-b noprint">
244 [% INCLUDE 'tools-menu.inc' %]
250 [% MACRO jsinclude BLOCK %]
251 [% Asset.js("js/tools-menu.js") | $raw %]
252 [% INCLUDE 'datatables.inc' %]
253 [% Asset.js("js/file-upload.js") | $raw %]
254 <script type="text/javascript">
255 function StartUpload() {
256 if( $('#fileToUpload').prop('files').length == 0 ) return;
257 $('#fileToUpload').prop('disabled',true);
258 $('#fileuploadbutton').hide();
259 $("#fileuploadcancel").show();
260 $("#fileuploadfailed").html('');
261 $("#myalerts").hide('');
262 $("#myalerts").html('');
263 $("#fileuploadstatus").show();
264 $("#uploadedfileid").val('');
265 $("#searchfile").hide();
266 $("#lastbreadcrumb").text( _("Add a new upload") );
269 if( $("#uploadcategory").val() )
270 cat = encodeURIComponent( $("#uploadcategory").val() );
271 if( cat ) xtra= 'category=' + cat + '&';
273 xtra = xtra + 'public=1&temp=0';
275 if( !cat ) xtra = 'temp=1&';
276 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
278 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
280 function CancelUpload() {
281 if( xhr ) xhr.abort();
282 $("#fileuploadstatus").hide();
283 $('#fileToUpload').prop('disabled', false);
284 $('#fileuploadbutton').show();
285 $("#fileuploadcancel").hide();
286 $("#fileuploadfailed").show();
287 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
289 function cbUpload( status, fileid, err ) {
290 $('#fileToUpload').prop('disabled', false);
291 if( status=='done' ) {
292 var e = err? JSON.stringify(err): '';
293 SubmitMe( 'search', fileid, e );
295 $('#fileuploadbutton').show();
296 $("#fileuploadcancel").hide();
297 $("#fileuploadstatus").hide();
298 $("#fileuploadfailed").show();
299 $("#fileuploadfailed").html( _("Upload status: ") +
300 ( status=='failed'? _("Failed"):
301 ( status=='denied'? _("Denied"): status ))
306 function ShowAlerts(err) {
308 for( var file in err ) {
309 str= str + '<p>' + file + ': ' +
310 errMESSAGES( err[file].code ) + '</p>';
313 $('#myalerts').html(str);
314 $('#myalerts').show();
317 function errMESSAGES(code) {
320 case 'UPLERR_ALREADY_EXISTS':
321 rv = _("This file already exists (in this category).");
323 case 'UPLERR_CANNOT_WRITE':
324 rv = _("File could not be created. Check permissions.");
326 case 'UPLERR_NO_ROOT_DIR':
327 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
329 case 'UPLERR_NO_TEMP_DIR':
330 rv = _("No temporary directory found.");
332 case 'UPLERR_FILE_NOT_READ':
333 rv = _("File could not be read.");
335 case 'UPL_FILE_DELETED': // An alert, no error
336 rv = _("File has been deleted.");
338 case 'UPLERR_FILE_NOT_DELETED':
339 rv = _("File or upload record could not be deleted.");
346 function CheckSearch() {
347 if( $("#term").val()=="" ) {
348 alert( _("Please enter a search term.") );
353 function SubmitMe(op, id, msg ) {
354 $("#submitter #op").val( op );
355 $("#submitter #id").val( id );
356 $("#submitter #msg").val( msg );
357 $("#submitter").submit();
359 function DeleteEntry(id) {
360 if( !confirm( _("Do you really want to delete this upload?") ))
363 SubmitMe( 'delete', id );
365 function ClearField() {
367 $(window.opener.document).find('#[% index | html %]').val( '' );
370 function Choose(hashval) {
371 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
372 res = res.replace( /\/$/, '');
373 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
375 $(window.opener.document).find('#[% index | html %]').val( res );
379 $(document).ready(function() {
380 $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
382 { 'bSortable': false, 'aTargets': [ 'nosort' ] }
384 "sPaginationType": "four_button"
387 ShowAlerts( [% msg | html %] );
389 $("#fileuploadcancel").hide();
390 $("#public_cb").click(function() {
391 $("#public").click();
393 $("#fileuploadbutton").on("click",function(e){
397 $("#fileuploadcancel").on("click",function(e){
401 $("#searchbutton").on("click",function(){
402 return CheckSearch();
404 $(".choose_entry").on("click",function(e){
406 var record_hashvalue = $(this).data("record-hashvalue");
407 Choose( record_hashvalue );
409 $(".download_entry").on("click",function(e){
411 var record_id = $(this).data("record-id");
412 SubmitMe( 'download', record_id );
414 $(".delete_entry").on("click",function(e){
416 var record_id = $(this).data("record-id");
417 DeleteEntry( record_id );
419 $("#new_search").on("click",function(e){
427 [% INCLUDE 'intranet-bottom.inc' %]