1 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Upload plugin</title>
6 <title>Koha › Tools › Upload</title>
8 [% INCLUDE 'doc-head-close.inc' %]
10 [% BLOCK plugin_pars %]
12 <input type="hidden" name="plugin" value="1" />
13 <input type="hidden" name="index" value="[% index %]" />
17 [% BLOCK breadcrumbs %]
18 <div id="breadcrumbs">
19 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
21 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23 <a href="/cgi-bin/koha/tools/upload.pl">Upload</a>
25 <span id="lastbreadcrumb">
26 [% IF mode=='new' || mode =='deleted'%]
27 Add new upload or search
36 <form method="post" action="[% SCRIPT_NAME %]" id="uploadfile" enctype="multipart/form-data">
37 [% PROCESS plugin_pars %]
38 <fieldset class="rows" id="uploadform">
39 <legend>Upload new files</legend>
42 <div id="fileuploadform">
43 <label for="fileToUpload">Select files: </label>
44 <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
47 [% IF uploadcategories %]
49 <label for="uploadcategory">Category: </label>
50 <select id="uploadcategory" name="uploadcategory">
52 <option value="" disabled hidden selected></option>
54 [% FOREACH cat IN uploadcategories %]
55 <option value="[% cat.code %]">[% cat.name %]</option>
62 [% IF uploadcategories %]
63 <div class="hint">Note: For temporary uploads do not select a category.</div>
65 <div class="hint">Note: No upload categories have been defined. All uploads will be marked as temporary.</div>
71 <input type="hidden" id="public" name="public" value="1"/>
73 <label id="public_cb">Allow public downloads:</label>
74 <input type="checkbox" id="public" name="public">
79 <fieldset class="action">
80 <button id="fileuploadbutton" onclick="StartUpload(); return false;">Upload</button>
81 <button id="fileuploadcancel" onclick="CancelUpload(); return false;">Cancel</button>
84 <div id="fileuploadpanel">
85 <div id="fileuploadstatus">Upload progress:
86 <progress id="fileuploadprogress" min="0" 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="[% SCRIPT_NAME %]" 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="searchupload">Search term: </label>
104 <input type="text" id="term" name="term" value=""/>
107 <fieldset class="action">
108 <button id="searchbutton" onclick="return CheckSearch();" 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="" />
128 <fieldset class="action">
129 <button onclick="window.close();return false;">Close</button>
138 <fieldset class="action">
139 <button class="submit">Back</button>
145 [% BLOCK newsearch %]
146 <form id="newsearch">
147 <fieldset class="action">
148 <button onclick="SubmitMe('new'); return false;">New search</button>
150 <button onclick="window.close();return false;">Close</button>
156 [% BLOCK table_results %]
164 [% IF !plugin %]<th>Public</td>[% END %]
165 [% IF !plugin %]<th>Temporary</td>[% END %]
170 [% FOREACH record IN uploads %]
172 <td>[% record.name %]</td>
173 <td>[% record.filesize %]</td>
174 <td>[% record.hashvalue %]</td>
175 <td>[% record.uploadcategorycode %]</td>
177 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
178 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
182 <a href="" onclick="Choose('[% record.hashvalue %]'); return false;">Choose</a>
184 <a href="" onclick="SubmitMe( 'download', [% record.id %] ); return false;">Download</a>
185 <a href="" onclick="DeleteEntry( [% record.id %] ); return false;">Delete</a>
193 <style type="text/css">
194 #fileuploadstatus,#fileuploadfailed { display : none; }
195 #fileuploadstatus { margin:.4em; }
196 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
199 <script type="text/javascript">
202 "Error 0: Not in use",
203 _("This file already exists (in this category)."),
204 _("File could not be created. Check permissions."),
205 _("Your koha-conf.xml does not contain a valid upload_path."),
206 _("No temporary directory found."),
207 _("File could not be read."),
208 _("File has been deleted."),
209 _("File could not be deleted."),
213 <script type="text/javascript" src="[% themelang %]/js/file-upload.js"></script>
214 <script type="text/javascript">
216 function StartUpload() {
217 if( $('#fileToUpload').prop('files').length == 0 ) return;
218 $('#fileToUpload').prop('disabled',true);
219 $('#fileuploadbutton').hide();
220 $("#fileuploadcancel").show();
221 $("#fileuploadfailed").html('');
222 $("#myalerts").hide('');
223 $("#myalerts").html('');
224 $("#fileuploadstatus").show();
225 $("#uploadedfileid").val('');
226 $("#searchfile").hide();
227 $("#lastbreadcrumb").text( _("Add a new upload") );
230 if( $("#uploadcategory").val() )
231 cat = encodeURIComponent( $("#uploadcategory").val() );
232 if( cat ) xtra= 'category=' + cat + '&';
234 xtra = xtra + 'public=1&temp=0';
236 if( !cat ) xtra = 'temp=1&';
237 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
239 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
241 function CancelUpload() {
242 if( xhr ) xhr.abort();
243 $("#fileuploadstatus").hide();
244 $('#fileToUpload').prop('disabled', false);
245 $('#fileuploadbutton').show();
246 $("#fileuploadcancel").hide();
247 $("#fileuploadfailed").show();
248 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
250 function cbUpload( status, fileid, err ) {
251 $('#fileToUpload').prop('disabled', false);
252 if( status=='done' ) {
253 var e = err? JSON.stringify(err): '';
254 SubmitMe( 'search', fileid, e );
256 $('#fileuploadbutton').show();
257 $("#fileuploadcancel").hide();
258 $("#fileuploadstatus").hide();
259 $("#fileuploadfailed").show();
260 $("#fileuploadfailed").html( _("Upload status: ") +
261 ( status=='failed'? _("Failed"):
262 ( status=='denied'? _("Denied"): status ))
267 function ShowAlerts(err) {
269 for( var file in err ) {
270 str= str + '<p>' + file + ': ' +
271 errMESSAGES[ err[file] ] + '</p>';
274 $('#myalerts').html(str);
275 $('#myalerts').show();
278 function CheckSearch() {
279 if( $("#term").val()=="" ) {
280 alert( _("Please enter a search term.") );
285 function SubmitMe(op, id, msg ) {
286 $("#submitter #op").val( op );
287 $("#submitter #id").val( id );
288 $("#submitter #msg").val( msg );
289 $("#submitter").submit();
291 function DeleteEntry(id) {
292 if( !confirm( _("Do you really want to delete this upload?") ))
295 SubmitMe( 'delete', id );
297 function ClearField() {
299 $(window.opener.document).find('#[% index %]').val( '' );
302 function Choose(hashval) {
303 var res = '[% Koha.Preference('OPACBaseURL') %]';
304 res = res.replace( /\/$/, '');
305 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
307 $(window.opener.document).find('#[% index %]').val( res );
311 $(document).ready(function() {
313 ShowAlerts( [% msg %] );
315 $("#fileuploadcancel").hide();
316 $("#public_cb").click(function() {
317 $("#public").click();
324 <body id="tools_upload" class="tools">
326 [% INCLUDE 'header.inc' %]
327 [% INCLUDE 'cat-search.inc' %]
328 [% PROCESS breadcrumbs %]
331 <div id="doc3" class="yui-t2">
338 <div class="dialog alert" id="myalerts" style="display:none;"></div>
340 [% PROCESS submitter %]
341 [% IF mode == 'new' || mode == 'deleted' %]
342 [% PROCESS form_new %]
343 [% PROCESS form_search %]
345 [% ELSIF mode == 'report' %]
347 <h3>Your request gave the following results:</h3>
348 [% PROCESS table_results %]
352 <h4>Sorry, your request had no results.</h4>
353 [% PROCESS newsearch %]
361 [% INCLUDE 'intranet-bottom.inc' %]