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 <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>
70 Note: No upload categories are defined.
71 [% IF ( CAN_user_parameters_manage_auth_values ) -%]
72 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.
74 An administrator must add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.
82 <input type="hidden" id="public" name="public" value="1"/>
84 <label id="public_cb">Allow public downloads:</label>
85 <input type="checkbox" id="public" name="public" />
89 <fieldset class="action">
90 <button id="fileuploadbutton">Upload</button>
91 <button id="fileuploadcancel">Cancel</button>
94 <div id="fileuploadpanel">
95 <div id="fileuploadstatus" class="progress_panel">Upload progress:
96 <progress id="fileuploadprogress" max="100" value="0">
98 <span class="fileuploadpercent">0</span>%
100 <div id="fileuploadfailed"></div>
105 [% BLOCK form_search %]
106 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
107 [% PROCESS plugin_pars %]
108 <input type="hidden" name="op" value="search"/>
109 <fieldset class="rows">
110 <legend>Search uploads by name or hashvalue</legend>
113 <label for="term">Search term: </label>
114 <input type="text" id="term" name="term" value=""/>
117 <fieldset class="action">
118 <button id="searchbutton" class="submit">Search</button>
124 [% BLOCK submitter %]
125 <form id="submitter" style="display:none;" method="post">
126 [% PROCESS plugin_pars %]
127 <input type="hidden" name="op" id="op" value=""/>
128 <input type="hidden" name="id" id="id" value="" />
129 <input type="hidden" name="msg" id="msg" value="" />
135 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
142 <fieldset class="action">
143 <button class="submit">Back</button>
149 [% BLOCK newsearch %]
150 <form id="newsearch">
151 <fieldset class="action">
152 <button id="new_search">New search</button>
156 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
160 [% BLOCK table_results %]
161 <table id="uploadresults">
168 [% IF !plugin %]<th>Public</th>[% END %]
169 [% IF !plugin %]<th>Temporary</th>[% END %]
170 <th class="NoSort noExport">Actions</th>
174 [% FOREACH record IN uploads %]
176 <td>[% record.filename | html %]</td>
177 <td>[% record.filesize | html %]</td>
178 <td>[% record.hashvalue | html %]</td>
179 <td>[% record.uploadcategorycode | html %]</td>
181 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
182 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
186 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
188 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
189 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
190 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
200 #fileuploadstatus,#fileuploadfailed { display : none; }
201 #fileuploadstatus { margin:.4em; }
202 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
209 <body id="tools_upload" class="tools">
210 <div class="main container-fluid">
212 <div class="col-sm-12">
215 <body id="tools_upload" class="tools">
216 [% INCLUDE 'header.inc' %]
217 [% INCLUDE 'cat-search.inc' %]
218 [% PROCESS breadcrumbs %]
220 <div class="main container-fluid">
222 <div class="col-sm-10 col-sm-push-2">
227 <div class="dialog alert" id="myalerts" style="display:none;"></div>
229 [% PROCESS submitter %]
230 [% IF mode == 'new' || mode == 'deleted' %]
231 [% PROCESS form_new %]
232 [% PROCESS form_search %]
234 [% ELSIF mode == 'report' %]
236 <h3>Your request gave the following results:</h3>
237 [% PROCESS table_results %]
241 <h4>Sorry, your request had no results.</h4>
242 [% PROCESS newsearch %]
248 </div> <!-- /.col-sm-10.col-sm-push-2 -->
250 <div class="col-sm-2 col-sm-pull-10">
252 [% INCLUDE 'tools-menu.inc' %]
254 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
255 </div> <!-- /.row -->
258 </div> <!-- .col-sm-12 -->
259 </div> <!-- /.row -->
263 [% MACRO jsinclude BLOCK %]
264 [% Asset.js("js/tools-menu.js") | $raw %]
265 [% INCLUDE 'datatables.inc' %]
266 [% Asset.js("js/file-upload.js") | $raw %]
267 [% INCLUDE 'columns_settings.inc' %]
269 function StartUpload() {
270 if( $('#fileToUpload').prop('files').length == 0 ) return;
271 $('#fileToUpload').prop('disabled',true);
272 $('#fileuploadbutton').hide();
273 $("#fileuploadcancel").show();
274 $("#fileuploadfailed").html('');
275 $("#myalerts").hide('');
276 $("#myalerts").html('');
277 $("#fileuploadstatus").show();
278 $("#uploadedfileid").val('');
279 $("#searchfile").hide();
280 $("#lastbreadcrumb").text( _("Add a new upload") );
283 if( $("#uploadcategory").val() )
284 cat = encodeURIComponent( $("#uploadcategory").val() );
285 if( cat ) xtra= 'category=' + cat + '&';
287 xtra = xtra + 'public=1&temp=0';
289 if( !cat ) xtra = 'temp=1&';
290 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
292 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
294 function CancelUpload() {
295 if( xhr ) xhr.abort();
296 $("#fileuploadstatus").hide();
297 $('#fileToUpload').prop('disabled', false);
298 $('#fileuploadbutton').show();
299 $("#fileuploadcancel").hide();
300 $("#fileuploadfailed").show();
301 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
303 function cbUpload( status, fileid, err ) {
304 $('#fileToUpload').prop('disabled', false);
305 if( status=='done' ) {
306 var e = err? JSON.stringify(err): '';
307 SubmitMe( 'search', fileid, e );
309 $('#fileuploadbutton').show();
310 $("#fileuploadcancel").hide();
311 $("#fileuploadstatus").hide();
312 $("#fileuploadfailed").show();
313 $("#fileuploadfailed").html( _("Upload status: ") +
314 ( status=='failed'? _("Failed"):
315 ( status=='denied'? _("Denied"): status ))
320 function ShowAlerts(err) {
322 for( var file in err ) {
323 str= str + '<p>' + file + ': ' +
324 errMESSAGES( err[file].code ) + '</p>';
327 $('#myalerts').html(str);
328 $('#myalerts').show();
331 function errMESSAGES(code) {
334 case 'UPLERR_ALREADY_EXISTS':
335 rv = _("This file already exists (in this category).");
337 case 'UPLERR_CANNOT_WRITE':
338 rv = _("File could not be created. Check permissions.");
340 case 'UPLERR_NO_ROOT_DIR':
341 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
343 case 'UPLERR_NO_TEMP_DIR':
344 rv = _("No temporary directory found.");
346 case 'UPLERR_FILE_NOT_READ':
347 rv = _("File could not be read.");
349 case 'UPL_FILE_DELETED': // An alert, no error
350 rv = _("File has been deleted.");
352 case 'UPLERR_FILE_NOT_DELETED':
353 rv = _("File or upload record could not be deleted.");
360 function CheckSearch() {
361 if( $("#term").val()=="" ) {
362 alert( _("Please enter a search term.") );
367 function SubmitMe(op, id, msg ) {
368 $("#submitter #op").val( op );
369 $("#submitter #id").val( id );
370 $("#submitter #msg").val( msg );
371 $("#submitter").submit();
373 function DeleteEntry(id) {
374 if( !confirm( _("Do you really want to delete this upload?") ))
377 SubmitMe( 'delete', id );
379 function ClearField() {
381 $(window.opener.document).find('#[% index | html %]').val( '' );
384 function Choose(hashval) {
385 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
386 res = res.replace( /\/$/, '');
387 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
389 $(window.opener.document).find('#[% index | html %]').val( res );
393 $(document).ready(function() {
394 KohaTable("uploadresults",{});
396 ShowAlerts( [% msg | html %] );
398 $("#fileuploadcancel").hide();
399 $("#public_cb").click(function() {
400 $("#public").click();
402 $("#fileuploadbutton").on("click",function(e){
406 $("#fileuploadcancel").on("click",function(e){
410 $("#searchbutton").on("click",function(){
411 return CheckSearch();
413 $(".choose_entry").on("click",function(e){
415 var record_hashvalue = $(this).data("record-hashvalue");
416 Choose( record_hashvalue );
418 $(".download_entry").on("click",function(e){
420 var record_id = $(this).data("record-id");
421 SubmitMe( 'download', record_id );
423 $(".delete_entry").on("click",function(e){
425 var record_id = $(this).data("record-id");
426 DeleteEntry( record_id );
428 $("#new_search").on("click",function(e){
436 [% INCLUDE 'intranet-bottom.inc' %]