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"/>
74 <input type="checkbox" id="public" name="public">
75 Allow public downloads
80 <fieldset class="action">
81 <button id="fileuploadbutton" onclick="StartUpload(); return false;">Upload</button>
82 <button id="fileuploadcancel" onclick="CancelUpload(); return false;">Cancel</button>
85 <div id="fileuploadpanel">
86 <div id="fileuploadstatus">Upload progress:
87 <progress id="fileuploadprogress" min="0" max="100" value="0">
89 <span class="fileuploadpercent">0</span>%
91 <div id="fileuploadfailed"></div>
96 [% BLOCK form_search %]
97 <form method="post" id="searchfile" action="[% SCRIPT_NAME %]" enctype="multipart/form-data">
98 [% PROCESS plugin_pars %]
99 <input type="hidden" name="op" value="search"/>
100 <fieldset class="rows">
101 <legend>Search uploads by name or hashvalue</legend>
104 <label for="searchupload">Search term: </label>
105 <input type="text" id="term" name="term" value=""/>
108 <fieldset class="action">
109 <button id="searchbutton" onclick="return CheckSearch();" class="submit">Search</button>
117 [% BLOCK submitter %]
118 <form id="submitter" style="display:none;" method="post">
119 [% PROCESS plugin_pars %]
120 <input type="hidden" name="op" id="op" value=""/>
121 <input type="hidden" name="id" id="id" value="" />
122 <input type="hidden" name="msg" id="msg" value="" />
129 <fieldset class="action">
130 <button onclick="window.close();return false;">Close</button>
136 [% BLOCK newsearch %]
137 <form id="newsearch">
138 <fieldset class="action">
139 <button onclick="SubmitMe('new'); return false;">New search</button>
141 <button onclick="window.close();return false;">Close</button>
147 [% BLOCK table_results %]
155 [% IF !plugin %]<th>Public</td>[% END %]
156 [% IF !plugin %]<th>Temporary</td>[% END %]
161 [% FOREACH record IN uploads %]
163 <td>[% record.name %]</td>
164 <td>[% record.filesize %]</td>
165 <td>[% record.hashvalue %]</td>
166 <td>[% record.categorycode %]</td>
168 <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
169 <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td>
173 <a href="" onclick="Choose('[% record.hashvalue %]'); return false;">Choose</a>
175 <a href="" onclick="SubmitMe( 'download', [% record.id %] ); return false;">Download</a>
176 <a href="" onclick="ClearField(); SubmitMe( 'delete', [% record.id %] ); return false;">Delete</a>
184 <style type="text/css">
185 #fileuploadstatus,#fileuploadfailed { display : none; }
186 #fileuploadstatus { margin:.4em; }
187 #fileuploadprogress { width:150px;height:10px;border:1px solid #666;background:url('[% interface %]/[% theme %]/img/progress.png') -300px 0px no-repeat; }
190 <script type="text/javascript">
193 "Error 0: Not in use",
194 _("This file already exists (in this category)."),
195 _("File could not be created. Check permissions."),
196 _("Your koha-conf.xml does not contain a valid upload_path."),
197 _("No temporary directory found."),
198 _("File could not be read."),
199 _("File has been deleted."),
200 _("File could not be deleted."),
204 <script type="text/javascript" src="[% themelang %]/js/file-upload.js"></script>
205 <script type="text/javascript">
207 function StartUpload() {
208 if( $('#fileToUpload').prop('files').length == 0 ) return;
209 $('#fileToUpload').prop('disabled',true);
210 $('#fileuploadbutton').hide();
211 $("#fileuploadcancel").show();
212 $("#fileuploadfailed").html('');
213 $("#myalerts").hide('');
214 $("#myalerts").html('');
215 $("#fileuploadstatus").show();
216 $("#uploadedfileid").val('');
217 $("#searchfile").hide();
218 $("#lastbreadcrumb").text( _("Add a new upload") );
221 if( $("#uploadcategory").val() )
222 cat = encodeURIComponent( $("#uploadcategory").val() );
223 if( cat ) xtra= 'category=' + cat + '&';
225 xtra = xtra + 'public=1&temp=0';
227 if( !cat ) xtra = 'temp=1&';
228 if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
230 xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
232 function CancelUpload() {
233 if( xhr ) xhr.abort();
234 $("#fileuploadstatus").hide();
235 $('#fileToUpload').prop('disabled', false);
236 $('#fileuploadbutton').show();
237 $("#fileuploadcancel").hide();
238 $("#fileuploadfailed").show();
239 $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
241 function cbUpload( status, fileid, err ) {
242 $('#fileToUpload').prop('disabled', false);
243 if( status=='done' ) {
244 var e = err? JSON.stringify(err): '';
245 SubmitMe( 'search', fileid, e );
247 $('#fileuploadbutton').show();
248 $("#fileuploadcancel").hide();
249 $("#fileuploadstatus").hide();
250 $("#fileuploadfailed").show();
251 $("#fileuploadfailed").html( _("Upload status: ") +
252 ( status=='failed'? _("Failed"):
253 ( status=='denied'? _("Denied"): status ))
258 function ShowAlerts(err) {
260 for( var file in err ) {
261 str= str + '<p>' + file + ': ' +
262 errMESSAGES[ err[file] ] + '</p>';
265 $('#myalerts').html(str);
266 $('#myalerts').show();
269 function CheckSearch() {
270 if( $("#term").val()=="" ) {
271 alert( _("Please enter a search term.") );
276 function SubmitMe(op, id, msg ) {
277 $("#submitter #op").val( op );
278 $("#submitter #id").val( id );
279 $("#submitter #msg").val( msg );
280 $("#submitter").submit();
282 function ClearField() {
284 $(window.opener.document).find('#[% index %]').val( '' );
287 function Choose(hashval) {
288 var res = '[% Koha.Preference('OPACBaseURL') %]';
289 res = res.replace( /\/$/, '');
290 res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
292 $(window.opener.document).find('#[% index %]').val( res );
296 $(document).ready(function() {
298 ShowAlerts( [% msg %] );
300 $("#fileuploadcancel").hide();
306 <body id="tools_upload" class="tools">
308 [% INCLUDE 'header.inc' %]
309 [% INCLUDE 'cat-search.inc' %]
310 [% PROCESS breadcrumbs %]
313 <div id="doc3" class="yui-t2">
320 <div class="dialog alert" id="myalerts" style="display:none;"></div>
322 [% PROCESS submitter %]
323 [% IF mode == 'new' || mode == 'deleted' %]
324 [% PROCESS form_new %]
325 [% PROCESS form_search %]
327 [% ELSIF mode == 'report' %]
329 <h3>Your request gave the following results:</h3>
330 [% PROCESS table_results %]
333 <h4>Sorry, your request had no results.</h4>
334 [% PROCESS newsearch %]
342 [% INCLUDE 'intranet-bottom.inc' %]