90 lines
3.0 KiB
PHTML
90 lines
3.0 KiB
PHTML
<?php
|
|
$this->headTitle($this->config->title->site);
|
|
$this->headTitle('后台管理');
|
|
$this->headTitle()->setSeparator(' - ');
|
|
$theme = new Theme;
|
|
$theme->AppendPlus($this,"jquery-fileupload");
|
|
?>
|
|
<div class="row-fluid">
|
|
<div class="span2">
|
|
<?= $this->partial('data/left.phtml'); ?>
|
|
</div>
|
|
|
|
<div class="span10">
|
|
<h3>數據導入</h3>
|
|
<hr />
|
|
|
|
<label>上傳文件,請選擇Excel文件進行上傳</label>
|
|
|
|
<span class="btn btn-success fileinput-button file-upload-ctls">上傳文件<input id="fileupload" type="file" name="FileData"></span>
|
|
<div class="progress" id="pdf-upload-progress" style="display: none;">
|
|
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
|
</div>
|
|
</div>
|
|
<div id="uploadedFile"></div>
|
|
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(function () {
|
|
'use strict';
|
|
|
|
var jqXHR = $('#fileupload').fileupload({
|
|
url: '/admin/data/dataimport/ac/upload',
|
|
dataType: 'json',
|
|
done: function (e, data) {
|
|
|
|
if(typeof(data.result.error) != 'undefined' && data.result.error != 0)
|
|
{
|
|
alert(data.result.error);
|
|
return false;
|
|
}
|
|
|
|
if($('#uploadedFile').html() == "")
|
|
$('#uploadedFile').html(upload.makeFileHtml(data.result));
|
|
else
|
|
$('#uploadedFile').append(upload.makeFileHtml(data.result));
|
|
|
|
return true;
|
|
|
|
},
|
|
stop : function (e) {
|
|
$('#pdf-upload-progress').hide();
|
|
$('.file-upload-ctls').show();
|
|
},//stop
|
|
start : function (e) {
|
|
$('.file-upload-ctls').hide();
|
|
$('#pdf-upload-progress .progress-bar').css('width', 0 + '%');
|
|
$('#pdf-upload-progress').show();
|
|
},//start
|
|
progressall: function (e, data) {
|
|
var progress = parseInt(data.loaded / data.total * 100, 10);
|
|
$('#pdf-upload-progress .progress-bar').css(
|
|
'width',
|
|
progress + '%'
|
|
);
|
|
},//progressall
|
|
add: function (e, data) {
|
|
if($('input[name=attid]').length >= 1)
|
|
{
|
|
upload.deleteFile($('input[name=attid]').val());
|
|
$('file-alert').alert('close')
|
|
}
|
|
|
|
data.process().done(function () {
|
|
data.submit();
|
|
});
|
|
}//add
|
|
}).prop('disabled', !$.support.fileInput)
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled');
|
|
});
|
|
|
|
var upload = {
|
|
makeFileHtml : function(data){
|
|
return '<div class="alert alert-success">'
|
|
+ data.file
|
|
+ ' <a href="/admin/data/dataimport/ac/preprocess/?file='+ encodeURI(data.file) +'">導入數據</a>'
|
|
+ "</div>";
|
|
}
|
|
};
|
|
</script>
|