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>
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">
203 <div class="main container-fluid">
205 <div class="col-sm-12">
208 <body id="tools_upload" class="tools">
209 [% INCLUDE 'header.inc' %]
210 [% INCLUDE 'cat-search.inc' %]
211 [% PROCESS breadcrumbs %]
213 <div class="main container-fluid">
215 <div class="col-sm-10 col-sm-push-2">
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 %]
241 </div> <!-- /.col-sm-10.col-sm-push-2 -->
243 <div class="col-sm-2 col-sm-pull-10">
245 [% INCLUDE 'tools-menu.inc' %]
247 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
248 </div> <!-- /.row -->
251 </div> <!-- .col-sm-12 -->
252 </div> <!-- /.row -->
256 [% MACRO jsinclude BLOCK %]
257 [% Asset.js("js/tools-menu.js") | $raw %]
258 [% INCLUDE 'datatables.inc' %]
259 [% Asset.js("js/file-upload.js") | $raw %]
261 function StartUpload() {
262 if( $('#fileToUpload').prop('files').length == 0 ) return;
263 $('#fileToUpload').prop('disabled',true);
264 $('#fileuploadbutton').hide();
265 $("#fileuploadcancel").show();
266 $("#fileuploadfailed").html('');
267 $("#myalerts").hide('');
268 $("#myalerts").html('');
269 $("#fileuploadstatus").show();
270 $("#uploadedfileid").val('');
271 $("#searchfile").hide();
272 $("#lastbreadcrumb").text( _("Add a new upload") );
275 if( $("#uploadcategory").val() )
276 cat = encodeURIComponent( $("#uploadcategory").val() );
277 if( cat ) xtra= 'category=' + cat + '&';
279 xtra = xtra + 'public=1&temp=0';
281 if( !cat ) xtra = 'temp=1&';
282 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
284 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
286 function CancelUpload() {
287 if( xhr ) xhr.abort();
288 $("#fileuploadstatus").hide();
289 $('#fileToUpload').prop('disabled', false);
290 $('#fileuploadbutton').show();
291 $("#fileuploadcancel").hide();
292 $("#fileuploadfailed").show();
293 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
295 function cbUpload( status, fileid, err ) {
296 $('#fileToUpload').prop('disabled', false);
297 if( status=='done' ) {
298 var e = err? JSON.stringify(err): '';
299 SubmitMe( 'search', fileid, e );
301 $('#fileuploadbutton').show();
302 $("#fileuploadcancel").hide();
303 $("#fileuploadstatus").hide();
304 $("#fileuploadfailed").show();
305 $("#fileuploadfailed").html( _("Upload status: ") +
306 ( status=='failed'? _("Failed"):
307 ( status=='denied'? _("Denied"): status ))
312 function ShowAlerts(err) {
314 for( var file in err ) {
315 str= str + '<p>' + file + ': ' +
316 errMESSAGES( err[file].code ) + '</p>';
319 $('#myalerts').html(str);
320 $('#myalerts').show();
323 function errMESSAGES(code) {
326 case 'UPLERR_ALREADY_EXISTS':
327 rv = _("This file already exists (in this category).");
329 case 'UPLERR_CANNOT_WRITE':
330 rv = _("File could not be created. Check permissions.");
332 case 'UPLERR_NO_ROOT_DIR':
333 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
335 case 'UPLERR_NO_TEMP_DIR':
336 rv = _("No temporary directory found.");
338 case 'UPLERR_FILE_NOT_READ':
339 rv = _("File could not be read.");
341 case 'UPL_FILE_DELETED': // An alert, no error
342 rv = _("File has been deleted.");
344 case 'UPLERR_FILE_NOT_DELETED':
345 rv = _("File or upload record could not be deleted.");
352 function CheckSearch() {
353 if( $("#term").val()=="" ) {
354 alert( _("Please enter a search term.") );
359 function SubmitMe(op, id, msg ) {
360 $("#submitter #op").val( op );
361 $("#submitter #id").val( id );
362 $("#submitter #msg").val( msg );
363 $("#submitter").submit();
365 function DeleteEntry(id) {
366 if( !confirm( _("Do you really want to delete this upload?") ))
369 SubmitMe( 'delete', id );
371 function ClearField() {
373 $(window.opener.document).find('#[% index | html %]').val( '' );
376 function Choose(hashval) {
377 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
378 res = res.replace( /\/$/, '');
379 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
381 $(window.opener.document).find('#[% index | html %]').val( res );
385 $(document).ready(function() {
386 $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
388 { 'bSortable': false, 'aTargets': [ 'nosort' ] }
390 "sPaginationType": "four_button"
393 ShowAlerts( [% msg | html %] );
395 $("#fileuploadcancel").hide();
396 $("#public_cb").click(function() {
397 $("#public").click();
399 $("#fileuploadbutton").on("click",function(e){
403 $("#fileuploadcancel").on("click",function(e){
407 $("#searchbutton").on("click",function(){
408 return CheckSearch();
410 $(".choose_entry").on("click",function(e){
412 var record_hashvalue = $(this).data("record-hashvalue");
413 Choose( record_hashvalue );
415 $(".download_entry").on("click",function(e){
417 var record_id = $(this).data("record-id");
418 SubmitMe( 'download', record_id );
420 $(".delete_entry").on("click",function(e){
422 var record_id = $(this).data("record-id");
423 DeleteEntry( record_id );
425 $("#new_search").on("click",function(e){
433 [% INCLUDE 'intranet-bottom.inc' %]