5 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Upload plugin</title>
9 <title>Koha › Tools › Upload</title>
11 [% INCLUDE 'doc-head-close.inc' %]
13 [% BLOCK plugin_pars %]
15 <input type="hidden" name="plugin" value="1" />
16 <input type="hidden" name="index" value="[% index | html %]" />
20 [% BLOCK breadcrumbs %]
21 <div id="breadcrumbs">
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
26 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
28 <span id="lastbreadcrumb">
29 [% IF mode=='new' || mode =='deleted'%]
30 Add new upload or search
39 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
40 [% PROCESS plugin_pars %]
41 <fieldset class="rows" id="uploadform">
42 <legend>Upload new files</legend>
45 <div id="fileuploadform">
46 <label for="fileToUpload">Select files: </label>
47 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
50 [% IF uploadcategories %]
52 <label for="uploadcategory">Category: </label>
53 <select id="uploadcategory" name="uploadcategory">
55 <option value=""></option>
57 [% FOREACH cat IN uploadcategories %]
58 <option value="[% cat.code | html %]">[% cat.name | html %]</option>
65 [% IF uploadcategories %]
66 <div class="hint">Note: For temporary uploads do not select a category.</div>
68 <div class="hint">Note: No upload categories are defined. Add values to the UPLOAD authorized value category otherwise all uploads will be marked as temporary.</div>
74 <input type="hidden" id="public" name="public" value="1"/>
76 <label id="public_cb">Allow public downloads:</label>
77 <input type="checkbox" id="public" name="public" />
81 <fieldset class="action">
82 <button id="fileuploadbutton">Upload</button>
83 <button id="fileuploadcancel">Cancel</button>
86 <div id="fileuploadpanel">
87 <div id="fileuploadstatus" class="progress_panel">Upload progress:
88 <progress id="fileuploadprogress" max="100" value="0">
90 <span class="fileuploadpercent">0</span>%
92 <div id="fileuploadfailed"></div>
97 [% BLOCK form_search %]
98 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
99 [% PROCESS plugin_pars %]
100 <input type="hidden" name="op" value="search"/>
101 <fieldset class="rows">
102 <legend>Search uploads by name or hashvalue</legend>
105 <label for="term">Search term: </label>
106 <input type="text" id="term" name="term" value=""/>
109 <fieldset class="action">
110 <button id="searchbutton" class="submit">Search</button>
116 [% BLOCK submitter %]
117 <form id="submitter" style="display:none;" method="post">
118 [% PROCESS plugin_pars %]
119 <input type="hidden" name="op" id="op" value=""/>
120 <input type="hidden" name="id" id="id" value="" />
121 <input type="hidden" name="msg" id="msg" value="" />
127 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
134 <fieldset class="action">
135 <button class="submit">Back</button>
141 [% BLOCK newsearch %]
142 <form id="newsearch">
143 <fieldset class="action">
144 <button id="new_search">New search</button>
148 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
152 [% BLOCK table_results %]
153 <table id="uploadresults">
160 [% IF !plugin %]<th>Public</th>[% END %]
161 [% IF !plugin %]<th>Temporary</th>[% END %]
162 <th class="nosort">Actions</th>
166 [% FOREACH record IN uploads %]
168 <td>[% record.filename | html %]</td>
169 <td>[% record.filesize | html %]</td>
170 <td>[% record.hashvalue | html %]</td>
171 <td>[% record.uploadcategorycode | html %]</td>
173 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
174 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
178 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue | html %]"><i class="fa fa-plus"></i> Choose</button>
180 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id | html %]"><i class="fa fa-download"></i> Download</button>
181 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
182 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id | html %]"><i class="fa fa-trash"></i> Delete</button>
192 #fileuploadstatus,#fileuploadfailed { display : none; }
193 #fileuploadstatus { margin:.4em; }
194 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface | html %]/[% theme | html %]/img/progress.png') -300px 0px no-repeat; }
201 <body id="tools_upload" class="tools">
202 <div class="main container-fluid">
204 <div class="col-sm-12">
207 <body id="tools_upload" class="tools">
208 [% INCLUDE 'header.inc' %]
209 [% INCLUDE 'cat-search.inc' %]
210 [% PROCESS breadcrumbs %]
212 <div class="main container-fluid">
214 <div class="col-sm-10 col-sm-push-2">
219 <div class="dialog alert" id="myalerts" style="display:none;"></div>
221 [% PROCESS submitter %]
222 [% IF mode == 'new' || mode == 'deleted' %]
223 [% PROCESS form_new %]
224 [% PROCESS form_search %]
226 [% ELSIF mode == 'report' %]
228 <h3>Your request gave the following results:</h3>
229 [% PROCESS table_results %]
233 <h4>Sorry, your request had no results.</h4>
234 [% PROCESS newsearch %]
240 </div> <!-- /.col-sm-10.col-sm-push-2 -->
242 <div class="col-sm-2 col-sm-pull-10">
244 [% INCLUDE 'tools-menu.inc' %]
246 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
247 </div> <!-- /.row -->
250 </div> <!-- .col-sm-12 -->
251 </div> <!-- /.row -->
255 [% MACRO jsinclude BLOCK %]
256 [% Asset.js("js/tools-menu.js") | $raw %]
257 [% INCLUDE 'datatables.inc' %]
258 [% Asset.js("js/file-upload.js") | $raw %]
260 function StartUpload() {
261 if( $('#fileToUpload').prop('files').length == 0 ) return;
262 $('#fileToUpload').prop('disabled',true);
263 $('#fileuploadbutton').hide();
264 $("#fileuploadcancel").show();
265 $("#fileuploadfailed").html('');
266 $("#myalerts").hide('');
267 $("#myalerts").html('');
268 $("#fileuploadstatus").show();
269 $("#uploadedfileid").val('');
270 $("#searchfile").hide();
271 $("#lastbreadcrumb").text( _("Add a new upload") );
274 if( $("#uploadcategory").val() )
275 cat = encodeURIComponent( $("#uploadcategory").val() );
276 if( cat ) xtra= 'category=' + cat + '&';
278 xtra = xtra + 'public=1&temp=0';
280 if( !cat ) xtra = 'temp=1&';
281 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
283 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
285 function CancelUpload() {
286 if( xhr ) xhr.abort();
287 $("#fileuploadstatus").hide();
288 $('#fileToUpload').prop('disabled', false);
289 $('#fileuploadbutton').show();
290 $("#fileuploadcancel").hide();
291 $("#fileuploadfailed").show();
292 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
294 function cbUpload( status, fileid, err ) {
295 $('#fileToUpload').prop('disabled', false);
296 if( status=='done' ) {
297 var e = err? JSON.stringify(err): '';
298 SubmitMe( 'search', fileid, e );
300 $('#fileuploadbutton').show();
301 $("#fileuploadcancel").hide();
302 $("#fileuploadstatus").hide();
303 $("#fileuploadfailed").show();
304 $("#fileuploadfailed").html( _("Upload status: ") +
305 ( status=='failed'? _("Failed"):
306 ( status=='denied'? _("Denied"): status ))
311 function ShowAlerts(err) {
313 for( var file in err ) {
314 str= str + '<p>' + file + ': ' +
315 errMESSAGES( err[file].code ) + '</p>';
318 $('#myalerts').html(str);
319 $('#myalerts').show();
322 function errMESSAGES(code) {
325 case 'UPLERR_ALREADY_EXISTS':
326 rv = _("This file already exists (in this category).");
328 case 'UPLERR_CANNOT_WRITE':
329 rv = _("File could not be created. Check permissions.");
331 case 'UPLERR_NO_ROOT_DIR':
332 rv = _("Your koha-conf.xml does not contain a valid upload_path.");
334 case 'UPLERR_NO_TEMP_DIR':
335 rv = _("No temporary directory found.");
337 case 'UPLERR_FILE_NOT_READ':
338 rv = _("File could not be read.");
340 case 'UPL_FILE_DELETED': // An alert, no error
341 rv = _("File has been deleted.");
343 case 'UPLERR_FILE_NOT_DELETED':
344 rv = _("File or upload record could not be deleted.");
351 function CheckSearch() {
352 if( $("#term").val()=="" ) {
353 alert( _("Please enter a search term.") );
358 function SubmitMe(op, id, msg ) {
359 $("#submitter #op").val( op );
360 $("#submitter #id").val( id );
361 $("#submitter #msg").val( msg );
362 $("#submitter").submit();
364 function DeleteEntry(id) {
365 if( !confirm( _("Do you really want to delete this upload?") ))
368 SubmitMe( 'delete', id );
370 function ClearField() {
372 $(window.opener.document).find('#[% index | html %]').val( '' );
375 function Choose(hashval) {
376 var res = '[% Koha.Preference('OPACBaseURL') | html %]';
377 res = res.replace( /\/$/, '');
378 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
380 $(window.opener.document).find('#[% index | html %]').val( res );
384 $(document).ready(function() {
385 $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
387 { 'bSortable': false, 'aTargets': [ 'nosort' ] }
389 "sPaginationType": "four_button"
392 ShowAlerts( [% msg | html %] );
394 $("#fileuploadcancel").hide();
395 $("#public_cb").click(function() {
396 $("#public").click();
398 $("#fileuploadbutton").on("click",function(e){
402 $("#fileuploadcancel").on("click",function(e){
406 $("#searchbutton").on("click",function(){
407 return CheckSearch();
409 $(".choose_entry").on("click",function(e){
411 var record_hashvalue = $(this).data("record-hashvalue");
412 Choose( record_hashvalue );
414 $(".download_entry").on("click",function(e){
416 var record_id = $(this).data("record-id");
417 SubmitMe( 'download', record_id );
419 $(".delete_entry").on("click",function(e){
421 var record_id = $(this).data("record-id");
422 DeleteEntry( record_id );
424 $("#new_search").on("click",function(e){
432 [% INCLUDE 'intranet-bottom.inc' %]