4 [% USE TablesSettings %]
6 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Upload plugin</title>
10 <title>Upload › Tools › Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
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 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
25 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
28 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
31 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
34 <a href="#" aria-current="page">
35 [% IF mode=='new' || mode =='deleted'%]
36 Add new upload or search
47 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
48 [% PROCESS plugin_pars %]
49 <fieldset class="rows" id="uploadform">
50 <legend>Upload new files</legend>
53 <div id="fileuploadform">
54 <label for="fileToUpload">Select files: </label>
55 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
58 [% IF uploadcategories %]
60 <label for="uploadcategory">Category: </label>
61 <select id="uploadcategory" name="uploadcategory">
63 <option value=""></option>
65 [% FOREACH cat IN uploadcategories %]
66 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
73 [% IF uploadcategories %]
74 <div class="hint">Note: For temporary uploads do not select a category.</div>
77 Note: No upload categories are defined.
78 [% IF ( CAN_user_parameters_manage_auth_values ) -%]
79 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.
81 An administrator must add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.
89 <input type="hidden" id="public" name="public" value="1"/>
91 <label id="public_cb">Allow public downloads:</label>
92 <input type="checkbox" id="public" name="public" />
96 <fieldset class="action">
97 <button id="fileuploadbutton">Upload</button>
98 <button id="fileuploadcancel">Cancel</button>
101 <div id="fileuploadpanel">
102 <div id="fileuploadstatus" class="progress_panel">Upload progress:
103 <progress id="fileuploadprogress" max="100" value="0">
105 <span class="fileuploadpercent">0</span>%
107 <div id="fileuploadfailed"></div>
112 [% BLOCK form_browse %]
113 [% IF uploadcategories %]
114 <form method="post" id="browsefile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
115 [% PROCESS plugin_pars %]
116 <input type="hidden" name="op" value="browse"/>
117 <fieldset class="rows">
118 <legend>Search uploads by category</legend>
121 <label for="browsecategory">Category: </label>
122 <select id="browsecategory" name="browsecategory">
123 [% FOREACH cat IN uploadcategories %]
124 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
129 <fieldset class="action">
130 <button id="browsebutton" class="submit">Search</button>
137 [% BLOCK form_search %]
138 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
139 [% PROCESS plugin_pars %]
140 <input type="hidden" name="op" value="search"/>
141 <fieldset class="rows">
142 <legend>Search uploads by name or hashvalue</legend>
145 <label for="term">Search term: </label>
146 <input type="text" id="term" name="term" value=""/>
149 <fieldset class="action">
150 <button id="searchbutton" class="submit">Search</button>
156 [% BLOCK submitter %]
157 <form id="submitter" style="display:none;" method="post">
158 [% PROCESS plugin_pars %]
159 <input type="hidden" name="op" id="op" value=""/>
160 <input type="hidden" name="id" id="id" value="" />
161 <input type="hidden" name="msg" id="msg" value="" />
167 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
174 <fieldset class="action">
175 <button class="submit">Back</button>
181 [% BLOCK newsearch %]
182 <form id="newsearch">
183 <fieldset class="action">
184 <button id="new_search">New search</button>
188 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
192 [% BLOCK table_results %]
193 <table id="uploadresults">
200 [% IF !plugin %]<th>Public</th>[% END %]
201 [% IF !plugin %]<th>Temporary</th>[% END %]
202 <th class="NoSort noExport">Actions</th>
206 [% FOREACH record IN uploads %]
208 <td>[% record.filename | html %]</td>
209 <td>[% record.filesize | html %]</td>
210 <td>[% record.hashvalue | html %]</td>
211 <td>[% record.uploadcategorycode | html %]</td>
213 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
214 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
218 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
220 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
221 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
222 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
232 #fileuploadstatus,#fileuploadfailed { display : none; }
233 #fileuploadstatus { margin:.4em; }
234 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
241 <body id="tools_upload" class="tools">
242 <div class="main container-fluid">
244 <div class="col-sm-12">
247 <body id="tools_upload" class="tools">
248 [% INCLUDE 'header.inc' %]
249 [% INCLUDE 'cat-search.inc' %]
250 [% PROCESS breadcrumbs %]
252 <div class="main container-fluid">
254 <div class="col-sm-10 col-sm-push-2">
259 <div class="dialog alert" id="myalerts" style="display:none;"></div>
261 [% PROCESS submitter %]
262 [% IF mode == 'new' || mode == 'deleted' %]
263 [% PROCESS form_new %]
264 [% PROCESS form_browse %]
265 [% PROCESS form_search %]
267 [% ELSIF mode == 'report' %]
269 <h3>Your request gave the following results:</h3>
270 [% PROCESS table_results %]
274 <h4>Sorry, your request had no results.</h4>
275 [% PROCESS newsearch %]
281 </div> <!-- /.col-sm-10.col-sm-push-2 -->
283 <div class="col-sm-2 col-sm-pull-10">
285 [% INCLUDE 'tools-menu.inc' %]
287 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
288 </div> <!-- /.row -->
291 </div> <!-- .col-sm-12 -->
292 </div> <!-- /.row -->
296 [% MACRO jsinclude BLOCK %]
297 [% Asset.js("js/tools-menu.js") | $raw %]
298 [% INCLUDE 'datatables.inc' %]
299 [% Asset.js("js/file-upload.js") | $raw %]
300 [% INCLUDE 'columns_settings.inc' %]
302 function StartUpload() {
303 if( $('#fileToUpload').prop('files').length == 0 ) return;
304 $('#fileToUpload').prop('disabled',true);
305 $('#fileuploadbutton').hide();
306 $("#fileuploadcancel").show();
307 $("#fileuploadfailed").html('');
308 $("#myalerts").hide('');
309 $("#myalerts").html('');
310 $("#fileuploadstatus").show();
311 $("#uploadedfileid").val('');
312 $("#searchfile").hide();
313 $("#lastbreadcrumb").text( _("Add a new upload") );
316 if( $("#uploadcategory").val() )
317 cat = encodeURIComponent( $("#uploadcategory").val() );
318 if( cat ) xtra= 'category=' + cat + '&';
320 xtra = xtra + 'public=1&temp=0';
322 if( !cat ) xtra = 'temp=1&';
323 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
325 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
327 function CancelUpload() {
328 if( xhr ) xhr.abort();
329 $("#fileuploadstatus").hide();
330 $('#fileToUpload').prop('disabled', false);
331 $('#fileuploadbutton').show();
332 $("#fileuploadcancel").hide();
333 $("#fileuploadfailed").show();
334 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
336 function cbUpload( status, fileid, err ) {
337 $('#fileToUpload').prop('disabled', false);
338 if( status=='done' ) {
339 var e = err? JSON.stringify(err): '';
340 SubmitMe( 'search', fileid, e );
342 $('#fileuploadbutton').show();
343 $("#fileuploadcancel").hide();
344 $("#fileuploadstatus").hide();
345 $("#fileuploadfailed").show();
346 $("#fileuploadfailed").html( _("Upload status: ") +
347 ( status=='failed'? _("Failed"):
348 ( status=='denied'? _("Denied"): status ))
353 function ShowAlerts(err) {
355 for( var file in err ) {
356 str= str + '<p>' + file + ': ' +
357 errMESSAGES( err[file].code ) + '</p>';
360 $('#myalerts').html(str);
361 $('#myalerts').show();
364 function errMESSAGES(code) {
367 case 'UPLERR_ALREADY_EXISTS':
368 rv = _("This file already exists (in this category).");
370 case 'UPLERR_CANNOT_WRITE':
371 rv = _("File could not be created. Check permissions.");
373 case 'UPLERR_NO_ROOT_DIR':
374 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
376 case 'UPLERR_NO_TEMP_DIR':
377 rv = _("No temporary directory found.");
379 case 'UPLERR_FILE_NOT_READ':
380 rv = _("File could not be read.");
382 case 'UPL_FILE_DELETED': // An alert, no error
383 rv = _("File has been deleted.");
385 case 'UPLERR_FILE_NOT_DELETED':
386 rv = _("File or upload record could not be deleted.");
393 function CheckSearch() {
394 if( $("#term").val()=="" ) {
395 alert( _("Please enter a search term.") );
400 function SubmitMe(op, id, msg ) {
401 $("#submitter #op").val( op );
402 $("#submitter #id").val( id );
403 $("#submitter #msg").val( msg );
404 $("#submitter").submit();
406 function DeleteEntry(id) {
407 if( !confirm( _("Do you really want to delete this upload?") ))
410 SubmitMe( 'delete', id );
412 function ClearField() {
414 $(window.opener.document).find('#[% index | html %]').val( '' );
417 function Choose(hashval) {
418 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
419 res = res.replace( /\/$/, '');
420 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
422 $(window.opener.document).find('#[% index | html %]').val( res );
426 $(document).ready(function() {
427 KohaTable("uploadresults",{});
429 ShowAlerts( [% msg | html %] );
431 $("#fileuploadcancel").hide();
432 $("#public_cb").click(function() {
433 $("#public").click();
435 $("#fileuploadbutton").on("click",function(e){
439 $("#fileuploadcancel").on("click",function(e){
443 $("#searchbutton").on("click",function(){
444 return CheckSearch();
446 $(".choose_entry").on("click",function(e){
448 var record_hashvalue = $(this).data("record-hashvalue");
449 Choose( record_hashvalue );
451 $(".download_entry").on("click",function(e){
453 var record_id = $(this).data("record-id");
454 SubmitMe( 'download', record_id );
456 $(".delete_entry").on("click",function(e){
458 var record_id = $(this).data("record-id");
459 DeleteEntry( record_id );
461 $("#new_search").on("click",function(e){
469 [% INCLUDE 'intranet-bottom.inc' %]