4 [% USE TablesSettings %]
6 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Upload plugin</title>
10 <title>Koha › Tools › Upload</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_search %]
113 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
114 [% PROCESS plugin_pars %]
115 <input type="hidden" name="op" value="search"/>
116 <fieldset class="rows">
117 <legend>Search uploads by name or hashvalue</legend>
120 <label for="term">Search term: </label>
121 <input type="text" id="term" name="term" value=""/>
124 <fieldset class="action">
125 <button id="searchbutton" class="submit">Search</button>
131 [% BLOCK submitter %]
132 <form id="submitter" style="display:none;" method="post">
133 [% PROCESS plugin_pars %]
134 <input type="hidden" name="op" id="op" value=""/>
135 <input type="hidden" name="id" id="id" value="" />
136 <input type="hidden" name="msg" id="msg" value="" />
142 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
149 <fieldset class="action">
150 <button class="submit">Back</button>
156 [% BLOCK newsearch %]
157 <form id="newsearch">
158 <fieldset class="action">
159 <button id="new_search">New search</button>
163 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
167 [% BLOCK table_results %]
168 <table id="uploadresults">
175 [% IF !plugin %]<th>Public</th>[% END %]
176 [% IF !plugin %]<th>Temporary</th>[% END %]
177 <th class="NoSort noExport">Actions</th>
181 [% FOREACH record IN uploads %]
183 <td>[% record.filename | html %]</td>
184 <td>[% record.filesize | html %]</td>
185 <td>[% record.hashvalue | html %]</td>
186 <td>[% record.uploadcategorycode | html %]</td>
188 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
189 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
193 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
195 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
196 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
197 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
207 #fileuploadstatus,#fileuploadfailed { display : none; }
208 #fileuploadstatus { margin:.4em; }
209 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
216 <body id="tools_upload" class="tools">
217 <div class="main container-fluid">
219 <div class="col-sm-12">
222 <body id="tools_upload" class="tools">
223 [% INCLUDE 'header.inc' %]
224 [% INCLUDE 'cat-search.inc' %]
225 [% PROCESS breadcrumbs %]
227 <div class="main container-fluid">
229 <div class="col-sm-10 col-sm-push-2">
234 <div class="dialog alert" id="myalerts" style="display:none;"></div>
236 [% PROCESS submitter %]
237 [% IF mode == 'new' || mode == 'deleted' %]
238 [% PROCESS form_new %]
239 [% PROCESS form_search %]
241 [% ELSIF mode == 'report' %]
243 <h3>Your request gave the following results:</h3>
244 [% PROCESS table_results %]
248 <h4>Sorry, your request had no results.</h4>
249 [% PROCESS newsearch %]
255 </div> <!-- /.col-sm-10.col-sm-push-2 -->
257 <div class="col-sm-2 col-sm-pull-10">
259 [% INCLUDE 'tools-menu.inc' %]
261 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
262 </div> <!-- /.row -->
265 </div> <!-- .col-sm-12 -->
266 </div> <!-- /.row -->
270 [% MACRO jsinclude BLOCK %]
271 [% Asset.js("js/tools-menu.js") | $raw %]
272 [% INCLUDE 'datatables.inc' %]
273 [% Asset.js("js/file-upload.js") | $raw %]
274 [% INCLUDE 'columns_settings.inc' %]
276 function StartUpload() {
277 if( $('#fileToUpload').prop('files').length == 0 ) return;
278 $('#fileToUpload').prop('disabled',true);
279 $('#fileuploadbutton').hide();
280 $("#fileuploadcancel").show();
281 $("#fileuploadfailed").html('');
282 $("#myalerts").hide('');
283 $("#myalerts").html('');
284 $("#fileuploadstatus").show();
285 $("#uploadedfileid").val('');
286 $("#searchfile").hide();
287 $("#lastbreadcrumb").text( _("Add a new upload") );
290 if( $("#uploadcategory").val() )
291 cat = encodeURIComponent( $("#uploadcategory").val() );
292 if( cat ) xtra= 'category=' + cat + '&';
294 xtra = xtra + 'public=1&temp=0';
296 if( !cat ) xtra = 'temp=1&';
297 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
299 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
301 function CancelUpload() {
302 if( xhr ) xhr.abort();
303 $("#fileuploadstatus").hide();
304 $('#fileToUpload').prop('disabled', false);
305 $('#fileuploadbutton').show();
306 $("#fileuploadcancel").hide();
307 $("#fileuploadfailed").show();
308 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
310 function cbUpload( status, fileid, err ) {
311 $('#fileToUpload').prop('disabled', false);
312 if( status=='done' ) {
313 var e = err? JSON.stringify(err): '';
314 SubmitMe( 'search', fileid, e );
316 $('#fileuploadbutton').show();
317 $("#fileuploadcancel").hide();
318 $("#fileuploadstatus").hide();
319 $("#fileuploadfailed").show();
320 $("#fileuploadfailed").html( _("Upload status: ") +
321 ( status=='failed'? _("Failed"):
322 ( status=='denied'? _("Denied"): status ))
327 function ShowAlerts(err) {
329 for( var file in err ) {
330 str= str + '<p>' + file + ': ' +
331 errMESSAGES( err[file].code ) + '</p>';
334 $('#myalerts').html(str);
335 $('#myalerts').show();
338 function errMESSAGES(code) {
341 case 'UPLERR_ALREADY_EXISTS':
342 rv = _("This file already exists (in this category).");
344 case 'UPLERR_CANNOT_WRITE':
345 rv = _("File could not be created. Check permissions.");
347 case 'UPLERR_NO_ROOT_DIR':
348 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
350 case 'UPLERR_NO_TEMP_DIR':
351 rv = _("No temporary directory found.");
353 case 'UPLERR_FILE_NOT_READ':
354 rv = _("File could not be read.");
356 case 'UPL_FILE_DELETED': // An alert, no error
357 rv = _("File has been deleted.");
359 case 'UPLERR_FILE_NOT_DELETED':
360 rv = _("File or upload record could not be deleted.");
367 function CheckSearch() {
368 if( $("#term").val()=="" ) {
369 alert( _("Please enter a search term.") );
374 function SubmitMe(op, id, msg ) {
375 $("#submitter #op").val( op );
376 $("#submitter #id").val( id );
377 $("#submitter #msg").val( msg );
378 $("#submitter").submit();
380 function DeleteEntry(id) {
381 if( !confirm( _("Do you really want to delete this upload?") ))
384 SubmitMe( 'delete', id );
386 function ClearField() {
388 $(window.opener.document).find('#[% index | html %]').val( '' );
391 function Choose(hashval) {
392 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
393 res = res.replace( /\/$/, '');
394 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
396 $(window.opener.document).find('#[% index | html %]').val( res );
400 $(document).ready(function() {
401 KohaTable("uploadresults",{});
403 ShowAlerts( [% msg | html %] );
405 $("#fileuploadcancel").hide();
406 $("#public_cb").click(function() {
407 $("#public").click();
409 $("#fileuploadbutton").on("click",function(e){
413 $("#fileuploadcancel").on("click",function(e){
417 $("#searchbutton").on("click",function(){
418 return CheckSearch();
420 $(".choose_entry").on("click",function(e){
422 var record_hashvalue = $(this).data("record-hashvalue");
423 Choose( record_hashvalue );
425 $(".download_entry").on("click",function(e){
427 var record_id = $(this).data("record-id");
428 SubmitMe( 'download', record_id );
430 $(".delete_entry").on("click",function(e){
432 var record_id = $(this).data("record-id");
433 DeleteEntry( record_id );
435 $("#new_search").on("click",function(e){
443 [% INCLUDE 'intranet-bottom.inc' %]