1 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Upload plugin</title>
6 <title>Koha › Tools › Upload</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
11 [% BLOCK plugin_pars %]
13 <input type="hidden" name="plugin" value="1" />
14 <input type="hidden" name="index" value="[% index %]" />
18 [% BLOCK breadcrumbs %]
19 <div id="breadcrumbs">
20 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
22 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
24 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
26 <span id="lastbreadcrumb">
27 [% IF mode=='new' || mode =='deleted'%]
28 Add new upload or search
37 <form method="post" action="/cgi-bin/koha/tools/upload.pl" id="uploadfile" enctype="multipart/form-data">
38 [% PROCESS plugin_pars %]
39 <fieldset class="rows" id="uploadform">
40 <legend>Upload new files</legend>
43 <div id="fileuploadform">
44 <label for="fileToUpload">Select files: </label>
45 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
48 [% IF uploadcategories %]
50 <label for="uploadcategory">Category: </label>
51 <select id="uploadcategory" name="uploadcategory">
53 <option value=""></option>
55 [% FOREACH cat IN uploadcategories %]
56 <option value="[% cat.code %]">[% cat.name %]</option>
63 [% IF uploadcategories %]
64 <div class="hint">Note: For temporary uploads do not select a category.</div>
66 <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>
72 <input type="hidden" id="public" name="public" value="1"/>
74 <label id="public_cb">Allow public downloads:</label>
75 <input type="checkbox" id="public" name="public" />
79 <fieldset class="action">
80 <button id="fileuploadbutton">Upload</button>
81 <button id="fileuploadcancel">Cancel</button>
84 <div id="fileuploadpanel">
85 <div id="fileuploadstatus" class="progress_panel">Upload progress:
86 <progress id="fileuploadprogress" max="100" value="0">
88 <span class="fileuploadpercent">0</span>%
90 <div id="fileuploadfailed"></div>
95 [% BLOCK form_search %]
96 <form method="post" id="searchfile" action="/cgi-bin/koha/tools/upload.pl" enctype="multipart/form-data">
97 [% PROCESS plugin_pars %]
98 <input type="hidden" name="op" value="search"/>
99 <fieldset class="rows">
100 <legend>Search uploads by name or hashvalue</legend>
103 <label for="term">Search term: </label>
104 <input type="text" id="term" name="term" value=""/>
107 <fieldset class="action">
108 <button id="searchbutton" class="submit">Search</button>
114 [% BLOCK submitter %]
115 <form id="submitter" style="display:none;" method="post">
116 [% PROCESS plugin_pars %]
117 <input type="hidden" name="op" id="op" value=""/>
118 <input type="hidden" name="id" id="id" value="" />
119 <input type="hidden" name="msg" id="msg" value="" />
125 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
132 <fieldset class="action">
133 <button class="submit">Back</button>
139 [% BLOCK newsearch %]
140 <form id="newsearch">
141 <fieldset class="action">
142 <button id="new_search">New search</button>
146 <div id="closewindow"><a class="btn btn-default btn-default close" href="#">Close</a></div>
150 [% BLOCK table_results %]
151 <table id="uploadresults">
158 [% IF !plugin %]<th>Public</th>[% END %]
159 [% IF !plugin %]<th>Temporary</th>[% END %]
160 <th class="nosort">Actions</th>
164 [% FOREACH record IN uploads %]
166 <td>[% record.filename %]</td>
167 <td>[% record.filesize %]</td>
168 <td>[% record.hashvalue %]</td>
169 <td>[% record.uploadcategorycode %]</td>
171 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
172 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
176 <button class="btn btn-default btn-xs choose_entry" data-record-hashvalue="[% record.hashvalue %]"><i class="fa fa-plus"></i> Choose</button>
178 <button class="btn btn-default btn-xs download_entry" data-record-id="[% record.id %]"><i class="fa fa-download"></i> Download</button>
179 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
180 <button class="btn btn-default btn-xs delete_entry" data-record-id="[% record.id %]"><i class="fa fa-trash"></i> Delete</button>
189 [% INCLUDE 'datatables.inc' %]
190 <style type="text/css">
191 #fileuploadstatus,#fileuploadfailed { display : none; }
192 #fileuploadstatus { margin:.4em; }
193 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
196 <script type="text/javascript">
199 "Error 0: Not in use",
200 _("This file already exists (in this category)."),
201 _("File could not be created. Check permissions."),
202 _("Your koha-conf.xml does not contain a valid upload_path."),
203 _("No temporary directory found."),
204 _("File could not be read."),
205 _("File has been deleted."),
206 _("File or upload record could not be deleted."),
210 <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
211 <script type="text/javascript">
213 function StartUpload() {
214 if( $('#fileToUpload').prop('files').length == 0 ) return;
215 $('#fileToUpload').prop('disabled',true);
216 $('#fileuploadbutton').hide();
217 $("#fileuploadcancel").show();
218 $("#fileuploadfailed").html('');
219 $("#myalerts").hide('');
220 $("#myalerts").html('');
221 $("#fileuploadstatus").show();
222 $("#uploadedfileid").val('');
223 $("#searchfile").hide();
224 $("#lastbreadcrumb").text( _("Add a new upload") );
227 if( $("#uploadcategory").val() )
228 cat = encodeURIComponent( $("#uploadcategory").val() );
229 if( cat ) xtra= 'category=' + cat + '&';
231 xtra = xtra + 'public=1&temp=0';
233 if( !cat ) xtra = 'temp=1&';
234 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
236 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
238 function CancelUpload() {
239 if( xhr ) xhr.abort();
240 $("#fileuploadstatus").hide();
241 $('#fileToUpload').prop('disabled', false);
242 $('#fileuploadbutton').show();
243 $("#fileuploadcancel").hide();
244 $("#fileuploadfailed").show();
245 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
247 function cbUpload( status, fileid, err ) {
248 $('#fileToUpload').prop('disabled', false);
249 if( status=='done' ) {
250 var e = err? JSON.stringify(err): '';
251 SubmitMe( 'search', fileid, e );
253 $('#fileuploadbutton').show();
254 $("#fileuploadcancel").hide();
255 $("#fileuploadstatus").hide();
256 $("#fileuploadfailed").show();
257 $("#fileuploadfailed").html( _("Upload status: ") +
258 ( status=='failed'? _("Failed"):
259 ( status=='denied'? _("Denied"): status ))
264 function ShowAlerts(err) {
266 for( var file in err ) {
267 str= str + '<p>' + file + ': ' +
268 errMESSAGES[ err[file].code ] + '</p>';
271 $('#myalerts').html(str);
272 $('#myalerts').show();
275 function CheckSearch() {
276 if( $("#term").val()=="" ) {
277 alert( _("Please enter a search term.") );
282 function SubmitMe(op, id, msg ) {
283 $("#submitter #op").val( op );
284 $("#submitter #id").val( id );
285 $("#submitter #msg").val( msg );
286 $("#submitter").submit();
288 function DeleteEntry(id) {
289 if( !confirm( _("Do you really want to delete this upload?") ))
292 SubmitMe( 'delete', id );
294 function ClearField() {
296 $(window.opener.document).find('#[% index %]').val( '' );
299 function Choose(hashval) {
300 var res = '[% Koha.Preference('OPACBaseURL') %]';
301 res = res.replace( /\/$/, '');
302 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
304 $(window.opener.document).find('#[% index %]').val( res );
308 $(document).ready(function() {
309 $("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, {
311 { 'bSortable': false, 'aTargets': [ 'nosort' ] }
313 "sPaginationType": "four_button"
316 ShowAlerts( [% msg %] );
318 $("#fileuploadcancel").hide();
319 $("#public_cb").click(function() {
320 $("#public").click();
322 $("#fileuploadbutton").on("click",function(e){
326 $("#fileuploadcancel").on("click",function(e){
330 $("#searchbutton").on("click",function(){
331 return CheckSearch();
333 $(".choose_entry").on("click",function(e){
335 var record_hashvalue = $(this).data("record-hashvalue");
336 Choose( record_hashvalue );
338 $(".download_entry").on("click",function(e){
340 var record_id = $(this).data("record-id");
341 SubmitMe( 'download', record_id );
343 $(".delete_entry").on("click",function(e){
345 var record_id = $(this).data("record-id");
346 DeleteEntry( record_id );
348 $("#new_search").on("click",function(e){
358 <body id="tools_upload" class="tools">
363 <body id="tools_upload" class="tools">
364 [% INCLUDE 'header.inc' %]
365 [% INCLUDE 'cat-search.inc' %]
366 [% PROCESS breadcrumbs %]
367 <div id="doc3" class="yui-t2">
376 <div class="dialog alert" id="myalerts" style="display:none;"></div>
378 [% PROCESS submitter %]
379 [% IF mode == 'new' || mode == 'deleted' %]
380 [% PROCESS form_new %]
381 [% PROCESS form_search %]
383 [% ELSIF mode == 'report' %]
385 <h3>Your request gave the following results:</h3>
386 [% PROCESS table_results %]
390 <h4>Sorry, your request had no results.</h4>
391 [% PROCESS newsearch %]
399 <div class="yui-b noprint">
400 [% INCLUDE 'tools-menu.inc' %]
405 [% INCLUDE 'intranet-bottom.inc' %]