4 [% USE TablesSettings %]
5 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Upload plugin</title>
11 <title>Upload › Tools › Koha</title>
13 [% INCLUDE 'doc-head-close.inc' %]
15 [% BLOCK plugin_pars %]
17 <input type="hidden" name="plugin" value="1" />
18 <input type="hidden" name="index" value="[% index | html %]" />
22 [% BLOCK breadcrumbs %]
23 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
26 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
29 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
32 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
35 <a href="#" aria-current="page">
36 [% IF mode=='new' || mode =='deleted'%]
37 Add new upload or search
48 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
49 [% PROCESS plugin_pars %]
50 <fieldset class="rows" id="uploadform">
51 <legend>Upload new files</legend>
54 <div id="fileuploadform">
55 <label for="fileToUpload">Select files: </label>
56 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
59 [% IF uploadcategories %]
61 <label for="uploadcategory">Category: </label>
62 <select id="uploadcategory" name="uploadcategory">
64 <option value=""></option>
66 [% FOREACH cat IN uploadcategories %]
67 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
74 [% IF uploadcategories %]
75 <div class="hint">Note: For temporary uploads do not select a category.</div>
78 Note: No upload categories are defined.
79 [% IF ( CAN_user_parameters_manage_auth_values ) -%]
80 Add values to the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=UPLOAD">UPLOAD authorized value category</a> otherwise all uploads will be marked as temporary.
82 An administrator must add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.
90 <input type="hidden" id="public" name="public" value="1"/>
92 <label id="public_cb">Allow public downloads:</label>
93 <input type="checkbox" id="public" name="public" />
97 <fieldset class="action">
98 <button id="fileuploadbutton">Upload</button>
99 <button id="fileuploadcancel">Cancel</button>
102 <div id="fileuploadpanel">
103 <div id="fileuploadstatus" class="progress_panel">Upload progress:
104 <progress id="fileuploadprogress" max="100" value="0">
106 <span class="fileuploadpercent">0</span>%
108 <div id="fileuploadfailed"></div>
113 [% BLOCK form_browse %]
114 [% IF uploadcategories %]
115 <form method="post" id="browsefile" action="/cgi-bin/koha/tools/upload.pl">
116 [% PROCESS plugin_pars %]
117 <input type="hidden" name="op" value="browse"/>
118 <fieldset class="brief">
119 <h4>Search uploads by category</h4>
122 <label for="browsecategory">Category: </label>
123 <select id="browsecategory" name="browsecategory">
124 [% FOREACH cat IN uploadcategories %]
125 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
130 <fieldset class="action">
131 <button id="browsebutton" class="submit">Search</button>
138 [% BLOCK form_search %]
139 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl">
140 [% PROCESS plugin_pars %]
141 <input type="hidden" name="op" value="search"/>
142 <fieldset class="brief">
143 <h4>Search uploads by name or hashvalue</h4>
146 <label for="term">Search term: </label>
147 <input type="text" id="term" name="term" value=""/>
150 <fieldset class="action">
151 <button id="searchbutton" class="submit">Search</button>
157 [% BLOCK submitter %]
158 <form id="submitter" style="display:none;" method="post">
159 [% PROCESS plugin_pars %]
160 <input type="hidden" name="op" id="op" value=""/>
161 <input type="hidden" name="id" id="id" value="" />
162 <input type="hidden" name="msg" id="msg" value="" />
168 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
175 <fieldset class="action">
176 <button class="submit">Back</button>
182 [% BLOCK newsearch %]
183 <form id="newsearch">
184 <fieldset class="action">
185 <button id="new_search">New search</button>
189 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
193 [% BLOCK table_results %]
194 <table id="uploadresults">
201 [% IF !plugin %]<th>Public</th>[% END %]
202 [% IF !plugin %]<th>Temporary</th>[% END %]
203 <th class="NoSort noExport">Actions</th>
207 [% FOREACH record IN uploads %]
209 <td>[% record.filename | html %]</td>
210 <td>[% record.filesize | html %]</td>
211 <td>[% record.hashvalue | html %]</td>
213 <a href="/cgi-bin/koha/tools/upload.pl?op=browse&browsecategory=[% record.uploadcategorycode | uri %]">[% AuthorisedValues.GetByCode( 'UPLOAD', record.uploadcategorycode ) | html %]</a>
217 [% IF record.public %]
218 <a href="[% Koha.Preference('OPACBaseURL') | url %]/cgi-bin/koha/opac-retrieve-file.pl?id=[% record.hashvalue | uri %]" class="get-file" data-toggle="tooltip"><i class="fa fa-link" aria-hidden="true"></i> Yes</a>
223 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
227 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
229 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
230 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
231 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
241 #fileuploadstatus,#fileuploadfailed { display : none; }
242 #fileuploadstatus { margin:.4em; }
243 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
250 <body id="tools_upload" class="tools">
251 <div class="main container-fluid">
253 <div class="col-sm-12">
256 <body id="tools_upload" class="tools">
257 [% INCLUDE 'header.inc' %]
258 [% INCLUDE 'cat-search.inc' %]
259 [% PROCESS breadcrumbs %]
261 <div class="main container-fluid">
263 <div class="col-sm-10 col-sm-push-2">
268 <div class="dialog alert" id="myalerts" style="display:none;"></div>
270 [% PROCESS submitter %]
271 [% IF mode == 'new' || mode == 'deleted' %]
272 [% PROCESS form_new %]
274 [% IF uploadcategories %]
275 <div class="col-sm-6">
276 [% PROCESS form_browse %]
278 <div class="col-sm-6">
280 <div class="col-sm-12">
282 [% PROCESS form_search %]
286 [% ELSIF mode == 'report' %]
287 <div id="toolbar" class="btn-toolbar">
288 <a href="/cgi-bin/koha/tools/upload.pl" class="btn btn-default">Upload file</a>
291 <h3>Your request gave the following results:</h3>
292 [% PROCESS table_results %]
296 <h4>Sorry, your request had no results.</h4>
297 [% PROCESS newsearch %]
303 </div> <!-- /.col-sm-10.col-sm-push-2 -->
305 <div class="col-sm-2 col-sm-pull-10">
307 [% IF mode == 'report' %]
308 [% PROCESS form_browse %]
309 [% PROCESS form_search %]
313 [% INCLUDE 'tools-menu.inc' %]
315 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
316 </div> <!-- /.row -->
319 </div> <!-- .col-sm-12 -->
320 </div> <!-- /.row -->
324 [% MACRO jsinclude BLOCK %]
325 [% Asset.js("js/tools-menu.js") | $raw %]
326 [% INCLUDE 'datatables.inc' %]
327 [% Asset.js("js/file-upload.js") | $raw %]
328 [% INCLUDE 'columns_settings.inc' %]
330 function StartUpload() {
331 if( $('#fileToUpload').prop('files').length == 0 ) return;
332 $('#fileToUpload').prop('disabled',true);
333 $('#fileuploadbutton').hide();
334 $("#fileuploadcancel").show();
335 $("#fileuploadfailed").html('');
336 $("#myalerts").hide('');
337 $("#myalerts").html('');
338 $("#fileuploadstatus").show();
339 $("#uploadedfileid").val('');
340 $("#searchfile").hide();
341 $("#lastbreadcrumb").text( _("Add a new upload") );
344 if( $("#uploadcategory").val() )
345 cat = encodeURIComponent( $("#uploadcategory").val() );
346 if( cat ) xtra= 'category=' + cat + '&';
348 xtra = xtra + 'public=1&temp=0';
350 if( !cat ) xtra = 'temp=1&';
351 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
353 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
355 function CancelUpload() {
356 if( xhr ) xhr.abort();
357 $("#fileuploadstatus").hide();
358 $('#fileToUpload').prop('disabled', false);
359 $('#fileuploadbutton').show();
360 $("#fileuploadcancel").hide();
361 $("#fileuploadfailed").show();
362 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
364 function cbUpload( status, fileid, err ) {
365 $('#fileToUpload').prop('disabled', false);
366 if( status=='done' ) {
367 var e = err? JSON.stringify(err): '';
368 SubmitMe( 'search', fileid, e );
370 $('#fileuploadbutton').show();
371 $("#fileuploadcancel").hide();
372 $("#fileuploadstatus").hide();
373 $("#fileuploadfailed").show();
374 $("#fileuploadfailed").html( _("Upload status: ") +
375 ( status=='failed'? _("Failed"):
376 ( status=='denied'? _("Denied"): status ))
381 function ShowAlerts(err) {
383 for( var file in err ) {
384 str= str + '<p>' + file + ': ' +
385 errMESSAGES( err[file].code ) + '</p>';
388 $('#myalerts').html(str);
389 $('#myalerts').show();
392 function errMESSAGES(code) {
395 case 'UPLERR_ALREADY_EXISTS':
396 rv = _("This file already exists (in this category).");
398 case 'UPLERR_CANNOT_WRITE':
399 rv = _("File could not be created. Check permissions.");
401 case 'UPLERR_NO_ROOT_DIR':
402 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
404 case 'UPLERR_NO_TEMP_DIR':
405 rv = _("No temporary directory found.");
407 case 'UPLERR_FILE_NOT_READ':
408 rv = _("File could not be read.");
410 case 'UPL_FILE_DELETED': // An alert, no error
411 rv = _("File has been deleted.");
413 case 'UPLERR_FILE_NOT_DELETED':
414 rv = _("File or upload record could not be deleted.");
421 function CheckSearch() {
422 if( $("#term").val()=="" ) {
423 alert( _("Please enter a search term.") );
428 function SubmitMe(op, id, msg ) {
429 $("#submitter #op").val( op );
430 $("#submitter #id").val( id );
431 $("#submitter #msg").val( msg );
432 $("#submitter").submit();
434 function DeleteEntry(id) {
435 if( !confirm( _("Do you really want to delete this upload?") ))
438 SubmitMe( 'delete', id );
440 function ClearField() {
442 $(window.opener.document).find('#[% index | html %]').val( '' );
445 function Choose(hashval) {
446 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
447 res = res.replace( /\/$/, '');
448 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
450 $(window.opener.document).find('#[% index | html %]').val( res );
454 $(document).ready(function() {
455 KohaTable("uploadresults",{});
457 ShowAlerts( [% msg | html %] );
459 $("#fileuploadcancel").hide();
460 $("#public_cb").click(function() {
461 $("#public").click();
463 $("#fileuploadbutton").on("click",function(e){
467 $("#fileuploadcancel").on("click",function(e){
471 $("#searchbutton").on("click",function(){
472 return CheckSearch();
474 $("#uploadresults tbody").on("click",".choose_entry",function(e){
476 var record_hashvalue = $(this).data("record-hashvalue");
477 Choose( record_hashvalue );
479 $("#uploadresults tbody").on("click",".download_entry",function(e){
481 var record_id = $(this).data("record-id");
482 SubmitMe( 'download', record_id );
484 $("#uploadresults tbody").on("click",".delete_entry",function(e){
486 var record_id = $(this).data("record-id");
487 DeleteEntry( record_id );
489 $("#new_search").on("click",function(e){
494 if ( window.isSecureContext ) {
495 $(".get-file").on("click", function(e){
497 if( navigator.clipboard && navigator.clipboard.writeText){
498 navigator.clipboard.writeText( $(this).attr("href") );
499 $(this).attr("data-original-title", _( "Link copied to the clipboard" ) )
503 $(".get-file").tooltip({
504 delay: { "show": 100, "hide": 500 }
505 }).on("hidden.bs.tooltip", function(){
506 $(this).attr("data-original-title", _( "Copy link to this file" ) );
513 [% INCLUDE 'intranet-bottom.inc' %]