5 [% USE TablesSettings %]
6 [% USE AuthorisedValues %]
8 [% PROCESS 'i18n.inc' %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>[% FILTER collapse %]
12 [% IF mode == 'new' || mode == 'deleted' %]
13 [% t("Uploads") | html %] ›
16 [% IF mode == 'report' %]
17 [% t("Results") | html %] ›
18 [% t("Uploads") | html %] ›
20 [% t("Tools") | html %] ›
21 [% t("Koha") | html %]
23 [% INCLUDE 'doc-head-close.inc' %]
25 [% BLOCK plugin_pars %]
27 <input type="hidden" name="plugin" value="1" />
28 <input type="hidden" name="index" value="[% index | html %]" />
33 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
34 [% PROCESS plugin_pars %]
35 <fieldset class="rows" id="uploadform">
36 <legend>Upload new files</legend>
39 <div id="fileuploadform">
40 <label for="fileToUpload">Select files: </label>
41 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
44 [% IF uploadcategories %]
46 <label for="uploadcategory">Category: </label>
47 <select id="uploadcategory" name="uploadcategory">
49 <option value=""></option>
51 [% FOREACH cat IN uploadcategories %]
52 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
59 [% IF uploadcategories %]
60 <div class="hint">Note: For temporary uploads do not select a category.</div>
63 Note: No upload categories are defined.
64 [% IF ( CAN_user_parameters_manage_auth_values ) -%]
65 [% av_UPLOAD_link = BLOCK %]<a href='/cgi-bin/koha/admin/authorised_values.pl?searchfield=UPLOAD'>UPLOAD</a>[% END %]
66 <span>Add values to the [% av_UPLOAD_link | $raw | $KohaSpan %] authorized value category otherwise all uploads will be marked as temporary.</span>
68 <span>An administrator must add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.</span>
76 <input type="hidden" id="public" name="public" value="1"/>
78 <label id="public_cb">Allow public downloads:</label>
79 <input type="checkbox" id="public" name="public" />
84 <fieldset class="action">
85 <button id="fileuploadbutton" class="btn btn-primary">Upload</button>
86 <button id="fileuploadcancel" class="btn btn-link">Cancel</button>
88 <div id="fileuploadpanel">
89 <div id="fileuploadstatus" class="progress_panel">Upload progress:
90 <progress id="fileuploadprogress" max="100" value="0">
92 <span class="fileuploadpercent">0</span>%
94 <div id="fileuploadfailed"></div>
99 [% BLOCK form_browse %]
100 [% IF uploadcategories %]
101 <form method="post" id="browsefile" action="/cgi-bin/koha/tools/upload.pl">
102 [% PROCESS plugin_pars %]
103 <input type="hidden" name="op" value="browse"/>
104 <fieldset class="brief">
105 <h4>Search uploads by category</h4>
108 <label for="browsecategory">Category: </label>
109 <select id="browsecategory" name="browsecategory" required="required">
110 <option value="">Choose</option>
111 [% FOREACH cat IN uploadcategories %]
112 [% IF cat.code == browsecategory %]
113 <option value="[% cat.code | html %]" selected="selected">[% cat.name | html %]</option>
115 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
122 <fieldset class="action">
123 <button id="browsebutton" class="btn btn-primary">Search</button>
129 [% BLOCK form_search %]
130 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl">
131 [% PROCESS plugin_pars %]
132 <input type="hidden" name="op" value="search"/>
133 <fieldset class="brief">
134 <h4>Search uploads by name or hashvalue</h4>
137 <label for="term">Search term: </label>
138 <input type="text" id="term" name="term" value=""/>
142 <fieldset class="action">
143 <button id="searchbutton" class="btn btn-primary">Search</button>
148 [% BLOCK submitter %]
149 <form id="submitter" style="display:none;" method="post">
150 [% PROCESS plugin_pars %]
151 <input type="hidden" name="op" id="op" value=""/>
152 <input type="hidden" name="id" id="id" value="" />
153 <input type="hidden" name="msg" id="msg" value="" />
159 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
166 <fieldset class="action">
167 <button class="btn btn-default">Back</button>
173 [% BLOCK newsearch %]
174 <form id="newsearch">
175 <fieldset class="action">
176 <button id="new_search" class="btn btn-default">New search</button>
180 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
184 [% BLOCK table_results %]
185 <div class="page-section">
186 <table id="uploadresults">
194 [% IF !plugin %]<th>Public</th>[% END %]
195 [% IF !plugin %]<th>Temporary</th>[% END %]
196 <th class="NoSort noExport">Actions</th>
200 [% FOREACH record IN uploads %]
202 <td>[% record.filename | html %]</td>
203 <td>[% record.filesize | html %]</td>
204 <td>[% record.hashvalue | html %]</td>
205 <td data-order="[% record.dtcreated | html %]">[% record.dtcreated | $KohaDates with_hours = 1 %]</td>
207 <a href="/cgi-bin/koha/tools/upload.pl?op=browse&browsecategory=[% record.uploadcategorycode | uri %]">[% AuthorisedValues.GetByCode( 'UPLOAD', record.uploadcategorycode ) | html %]</a>
211 [% IF record.public %]
212 <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>
217 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
221 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
223 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
224 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
225 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash-can"></i> Delete</button>
232 </div> <!-- /.page-section -->
236 #fileuploadstatus,#fileuploadfailed { display : none; }
237 #fileuploadstatus { margin:.4em; }
238 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
245 <body id="tools_upload" class="tools">
246 <div class="main container-fluid">
248 <div class="col-sm-12">
251 <body id="tools_upload" class="tools">
252 [% WRAPPER 'header.inc' %]
253 [% INCLUDE 'cat-search.inc' %]
255 [% WRAPPER 'sub-header.inc' %]
256 [% WRAPPER breadcrumbs %]
257 [% WRAPPER breadcrumb_item %]
258 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
260 [% IF mode == 'new' || mode == 'deleted' %]
261 [% WRAPPER breadcrumb_item bc_active= 1 %]
265 [% WRAPPER breadcrumb_item %]
266 <a href="/cgi-bin/koha/tools/upload.pl">Uploads</a>
269 [% IF mode == 'report' %]
270 [% WRAPPER breadcrumb_item bc_active= 1 %]
274 [% END #/ WRAPPER breadcrumbs %]
275 [% END #/ WRAPPER sub-header.inc %]
277 <div class="main container-fluid">
279 <div class="col-sm-10 col-sm-push-2">
284 <div class="dialog alert" id="myalerts" style="display:none;"></div>
286 [% PROCESS submitter %]
287 [% IF mode == 'new' || mode == 'deleted' %]
288 [% PROCESS form_new %]
290 [% IF uploadcategories %]
291 <div class="col-xs-6">
292 [% PROCESS form_browse %]
294 <div class="col-xs-6">
296 <div class="col-xs-12">
298 [% PROCESS form_search %]
302 [% ELSIF mode == 'report' %]
303 <div id="toolbar" class="btn-toolbar">
304 <a href="/cgi-bin/koha/tools/upload.pl" class="btn btn-default">Upload file</a>
307 <h3>Your request gave the following results:</h3>
308 [% PROCESS table_results %]
312 <h4>Sorry, your request had no results.</h4>
313 [% PROCESS newsearch %]
319 </div> <!-- /.col-sm-10.col-sm-push-2 -->
321 <div class="col-sm-2 col-sm-pull-10">
323 [% IF mode == 'report' %]
324 [% PROCESS form_browse %]
325 [% PROCESS form_search %]
329 [% INCLUDE 'tools-menu.inc' %]
331 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
332 </div> <!-- /.row -->
335 </div> <!-- .col-sm-12 -->
336 </div> <!-- /.row -->
340 [% MACRO jsinclude BLOCK %]
341 [% Asset.js("js/tools-menu.js") | $raw %]
342 [% INCLUDE 'datatables.inc' %]
343 [% Asset.js("js/file-upload.js") | $raw %]
344 [% INCLUDE 'columns_settings.inc' %]
346 function StartUpload() {
347 if( $('#fileToUpload').prop('files').length == 0 ) return;
348 $('#fileToUpload').prop('disabled',true);
349 $('#fileuploadbutton').hide();
350 $("#fileuploadcancel").show();
351 $("#fileuploadfailed").html('');
352 $("#myalerts").hide('');
353 $("#myalerts").html('');
354 $("#fileuploadstatus").show();
355 $("#uploadedfileid").val('');
356 $("#searchfile").hide();
357 $("#lastbreadcrumb").text( _("Add a new upload") );
360 if( $("#uploadcategory").val() )
361 cat = encodeURIComponent( $("#uploadcategory").val() );
362 if( cat ) xtra= 'category=' + cat + '&';
364 xtra = xtra + 'public=1&temp=0';
366 if( !cat ) xtra = 'temp=1&';
367 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
369 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
371 function CancelUpload() {
372 if( xhr ) xhr.abort();
373 $("#fileuploadstatus").hide();
374 $('#fileToUpload').prop('disabled', false);
375 $('#fileuploadbutton').show();
376 $("#fileuploadcancel").hide();
377 $("#fileuploadfailed").show();
378 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
380 function cbUpload( status, fileid, err ) {
381 $('#fileToUpload').prop('disabled', false);
382 if( status=='done' ) {
383 var e = err? JSON.stringify(err): '';
384 SubmitMe( 'search', fileid, e );
386 $('#fileuploadbutton').show();
387 $("#fileuploadcancel").hide();
388 $("#fileuploadstatus").hide();
389 $("#fileuploadfailed").show();
390 $("#fileuploadfailed").html( _("Upload status: ") +
391 ( status=='failed'? _("Failed"):
392 ( status=='denied'? _("Denied"): status ))
397 function ShowAlerts(err) {
399 for( var file in err ) {
400 str= str + '<p>' + file + ': ' +
401 errMESSAGES( err[file].code ) + '</p>';
404 $('#myalerts').html(str);
405 $('#myalerts').show();
408 function errMESSAGES(code) {
411 case 'UPLERR_ALREADY_EXISTS':
412 rv = _("This file already exists (in this category).");
414 case 'UPLERR_CANNOT_WRITE':
415 rv = _("File could not be created. Check permissions.");
417 case 'UPLERR_NO_ROOT_DIR':
418 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
420 case 'UPLERR_NO_TEMP_DIR':
421 rv = _("No temporary directory found.");
423 case 'UPLERR_FILE_NOT_READ':
424 rv = _("File could not be read.");
426 case 'UPL_FILE_DELETED': // An alert, no error
427 rv = _("File has been deleted.");
429 case 'UPLERR_FILE_NOT_DELETED':
430 rv = _("File or upload record could not be deleted.");
437 function CheckSearch() {
438 if( $("#term").val()=="" ) {
439 alert( _("Please enter a search term.") );
444 function SubmitMe(op, id, msg ) {
445 $("#submitter #op").val( op );
446 $("#submitter #id").val( id );
447 $("#submitter #msg").val( msg );
448 $("#submitter").submit();
450 function DeleteEntry(id) {
451 if( !confirm( _("Do you really want to delete this upload?") ))
454 SubmitMe( 'delete', id );
456 function ClearField() {
458 $(window.opener.document).find('#[% index | html %]').val( '' );
461 function Choose(hashval) {
462 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
463 res = res.replace( /\/$/, '');
464 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
466 $(window.opener.document).find('#[% index | html %]').val( res );
470 var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'upload', 'uploadresults', 'json' ) | $raw %];
472 table_settings['columns'].splice(6, 1);
473 table_settings['columns'].splice(5, 1);
475 $(document).ready(function() {
476 KohaTable("uploadresults",{
480 ShowAlerts( [% msg | html %] );
482 $("#fileuploadcancel").hide();
483 $("#public_cb").click(function() {
484 $("#public").click();
486 $("#fileuploadbutton").on("click",function(e){
490 $("#fileuploadcancel").on("click",function(e){
494 $("#searchbutton").on("click",function(){
495 return CheckSearch();
497 $("#uploadresults tbody").on("click",".choose_entry",function(e){
499 var record_hashvalue = $(this).data("record-hashvalue");
500 Choose( record_hashvalue );
502 $("#uploadresults tbody").on("click",".download_entry",function(e){
504 var record_id = $(this).data("record-id");
505 SubmitMe( 'download', record_id );
507 $("#uploadresults tbody").on("click",".delete_entry",function(e){
509 var record_id = $(this).data("record-id");
510 DeleteEntry( record_id );
512 $("#new_search").on("click",function(e){
517 if ( window.isSecureContext ) {
518 $(".get-file").on("click", function(e){
520 if( navigator.clipboard && navigator.clipboard.writeText){
521 navigator.clipboard.writeText( $(this).attr("href") );
522 $(this).attr("data-original-title", _( "Link copied to the clipboard" ) )
526 $(".get-file").tooltip({
527 delay: { "show": 100, "hide": 500 }
528 }).on("hidden.bs.tooltip", function(){
529 $(this).attr("data-original-title", _( "Copy link to this file" ) );
536 [% INCLUDE 'intranet-bottom.inc' %]