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 [% IF record.owner == owner || CAN_user_tools_upload_manage %]
186 <a href="" onclick="DeleteEntry( [% record.id %] ); return false;">Delete</a>
195 <style type="text/css">
196 #fileuploadstatus,#fileuploadfailed { display : none; }
197 #fileuploadstatus { margin:.4em; }
198 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
201 <script type="text/javascript">
204 "Error 0: Not in use",
205 _("This file already exists (in this category)."),
206 _("File could not be created. Check permissions."),
207 _("Your koha-conf.xml does not contain a valid upload_path."),
208 _("No temporary directory found."),
209 _("File could not be read."),
210 _("File has been deleted."),
211 _("File could not be deleted."),
215 <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
216 <script type="text/javascript">
218 function StartUpload() {
219 if( $('#fileToUpload').prop('files').length == 0 ) return;
220 $('#fileToUpload').prop('disabled',true);
221 $('#fileuploadbutton').hide();
222 $("#fileuploadcancel").show();
223 $("#fileuploadfailed").html('');
224 $("#myalerts").hide('');
225 $("#myalerts").html('');
226 $("#fileuploadstatus").show();
227 $("#uploadedfileid").val('');
228 $("#searchfile").hide();
229 $("#lastbreadcrumb").text( _("Add a new upload") );
232 if( $("#uploadcategory").val() )
233 cat = encodeURIComponent( $("#uploadcategory").val() );
234 if( cat ) xtra= 'category=' + cat + '&';
236 xtra = xtra + 'public=1&temp=0';
238 if( !cat ) xtra = 'temp=1&';
239 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
241 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
243 function CancelUpload() {
244 if( xhr ) xhr.abort();
245 $("#fileuploadstatus").hide();
246 $('#fileToUpload').prop('disabled', false);
247 $('#fileuploadbutton').show();
248 $("#fileuploadcancel").hide();
249 $("#fileuploadfailed").show();
250 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
252 function cbUpload( status, fileid, err ) {
253 $('#fileToUpload').prop('disabled', false);
254 if( status=='done' ) {
255 var e = err? JSON.stringify(err): '';
256 SubmitMe( 'search', fileid, e );
258 $('#fileuploadbutton').show();
259 $("#fileuploadcancel").hide();
260 $("#fileuploadstatus").hide();
261 $("#fileuploadfailed").show();
262 $("#fileuploadfailed").html( _("Upload status: ") +
263 ( status=='failed'? _("Failed"):
264 ( status=='denied'? _("Denied"): status ))
269 function ShowAlerts(err) {
271 for( var file in err ) {
272 str= str + '<p>' + file + ': ' +
273 errMESSAGES[ err[file] ] + '</p>';
276 $('#myalerts').html(str);
277 $('#myalerts').show();
280 function CheckSearch() {
281 if( $("#term").val()=="" ) {
282 alert( _("Please enter a search term.") );
287 function SubmitMe(op, id, msg ) {
288 $("#submitter #op").val( op );
289 $("#submitter #id").val( id );
290 $("#submitter #msg").val( msg );
291 $("#submitter").submit();
293 function DeleteEntry(id) {
294 if( !confirm( _("Do you really want to delete this upload?") ))
297 SubmitMe( 'delete', id );
299 function ClearField() {
301 $(window.opener.document).find('#[% index %]').val( '' );
304 function Choose(hashval) {
305 var res = '[% Koha.Preference('OPACBaseURL') %]';
306 res = res.replace( /\/$/, '');
307 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
309 $(window.opener.document).find('#[% index %]').val( res );
313 $(document).ready(function() {
315 ShowAlerts( [% msg %] );
317 $("#fileuploadcancel").hide();
318 $("#public_cb").click(function() {
319 $("#public").click();
326 <body id="tools_upload" class="tools">
328 [% INCLUDE 'header.inc' %]
329 [% INCLUDE 'cat-search.inc' %]
330 [% PROCESS breadcrumbs %]
333 <div id="doc3" class="yui-t2">
339 <div class="dialog alert" id="myalerts" style="display:none;"></div>
341 [% PROCESS submitter %]
342 [% IF mode == 'new' || mode == 'deleted' %]
343 [% PROCESS form_new %]
344 [% PROCESS form_search %]
346 [% ELSIF mode == 'report' %]
348 <h3>Your request gave the following results:</h3>
349 [% PROCESS table_results %]
353 <h4>Sorry, your request had no results.</h4>
354 [% PROCESS newsearch %]
362 <div class="yui-b noprint">
363 [% INCLUDE 'tools-menu.inc' %]
368 [% INCLUDE 'intranet-bottom.inc' %]