| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/wamp/www/SIPBOS_2020/application/modules/import_xml/views/ |
Upload File : |
<fieldset>
<legend id="bc" data-bind="text: title"></legend>
</fieldset>
<form id="frm" method="post" action="<?php echo base_url(); ?>import_xml/proses" enctype="multipart/form-data">
<div class="controls-row">
<div class="control-group pull-left" data-bind="validationElement: id_skpd" >
<label class="control-label" for="kode_skpd">SKPD</label>
<input type="text" class="span2" id="kode_skpd" readonly="1" data-bind="value: kd_skpd, executeOnEnter: pilih_skpd" />
<div class="controls span5 input-append">
<input type="text" class="span6" id="nama_skpd" readonly="1" data-bind="value: nm_skpd, executeOnEnter: pilih_skpd" />
<span class="add-on" data-bind="visible: !isSKPD && canSave(), click: pilih_skpd"><i class="icon-folder-open"></i></span>
</div>
</div>
<div class="control-group pull-right">
<label class="control-label" for="jurnal" >Template Jurnal</label>
<select id="jurnal" class="span3" data-bind="options: jurnal_array, optionsText:'kode', optionsValue:'id', optionsCaption:'Pilih Template Jurnal ...', value: jurnal"></select>
</div>
</div>
<div class="controls-row">
<div class="control-group pull-left" data-bind="validationElement: file_xml">
<label class="control-label" for="file_xml">Upload</label>
<div class="add-on" id="fileuploader"><i class="icon-folder-open"></i> ...</div>
</div>
</div>
<h4>File XML</h4>
<ul data-bind="foreach: file_xml">
<li>
<a href="#" data-bind="visible: $parent.canSave && !$parent.processing(), click: $parent.removeFileXML" title="Hapus"><i class="icon-trash"></i></a>
<span data-bind="text: realname"> </span>
<img data-bind="visible: loading" src="<?php echo base_url()?>assets/img/select2-spinner.gif">
<img data-bind="visible: success" src="<?php echo base_url()?>assets/img/validYes.png">
<img data-bind="visible: failed" src="<?php echo base_url()?>assets/img/validNo.png">
</li>
</ul>
<div class="bottom-bar">
<button type="button" class="btn btn-primary" data-bind="enable: canSave && !processing(), click: function(data, event){save(false, data, event) }" />Import</button>
</div>
</form>
<div class="control-group well alert-info" style="margin-top: 70px;" data-bind="visible: showMessage">
<h4>Import SKP sudah selesai, dengan rincian sebagai berikut:</h4>
<ul>
<li><span data-bind="text: skp_success"></span> SKP berhasil disimpan</li>
<li><span data-bind="text: skp_failed"></span> SKP tidak bisa disimpan, karena <span data-bind="text: skp_failed"></span> no skp sudah ada</li>
<li><span data-bind="text: rek_failed"></span> SKP kode rekeningnya tidak ditemukan</li>
</ul>
</div>
<script>
var fileCounter = 0, fileIndeks = 0;
var skp_success = 0, skp_failed = 0, rek_failed = 0;
$(document).ready(function() {
inisialisasi();
$("#fileuploader").uploadFile({
url:"<?php echo base_url()?>import_xml/do_upload",
fileName:"file",
uploadButtonClass:"btn",
doneButtonClass:"btn",
dragDropStr:"",
multiple:true,
returnType:"json",
maxFileSize:"8388608",
allowedTypes:"xml",
showFileCounter:false,
showDone:false,
showStatusAfterSuccess: false,
abortStr:"Batal",
extErrorStr:"tidak diizinkan. Extensions yang diizinkan: ",
sizeErrorStr:"tidak diizinkan. Max size: ",
onSuccess:function(files,data,xhr) {
if (data.isSuccess) {
fileCounter++;
App.file_xml.push( new file(data.realname, data.name, false, false, false) );
}
else {
show_error(data.message, 'Gagal');
}
}
});
});
function proses_import(file){
var $frm = $('#frm'),
data = JSON.parse(ko.toJSON(App));
data['file_xml'] = file;
// loading: true
App.file_xml.replace( App.file_xml()[fileIndeks],
{ realname: App.file_xml()[fileIndeks]['realname'], name: file, loading: true, success: false, failed: false }
);
$.ajax({
url: $frm.attr('action'),
type: 'post',
dataType: 'json',
data: data,
success: function(res, xhr){
if (res.isSuccess) {
skp_success = skp_success + parseInt(res.skp_success); // skp yang berhasil diimport
skp_failed = skp_failed + parseInt(res.skp_failed); // skp gagal import
rek_failed = rek_failed + parseInt(res.rek_failed); // rekening tidak ditemukan
App.skp_success(skp_success);
App.skp_failed(skp_failed);
App.rek_failed(rek_failed);
// success: true
App.file_xml.replace( App.file_xml()[fileIndeks],
{ realname: App.file_xml()[fileIndeks]['realname'], name: file, loading: false, success: true, failed: false }
);
}
else {
// failed: true
App.file_xml.replace( App.file_xml()[fileIndeks],
{ realname: App.file_xml()[fileIndeks]['realname'], name: file, loading: false, success: false, failed: true }
);
}
},
complete: function(){
fileIndeks++;
if (fileIndeks < fileCounter) {
proses_import(App.file_xml()[fileIndeks]['name']);
}
else {
App.showMessage(true);
}
}
});
}
ko.validation.init({
insertMessages: false,
decorateElement: true,
errorElementClass: 'error',
});
var file = function(realname, name, loading, success, failed) {
this.realname = realname;
this.name = name;
this.loading = loading;
this.success = success;
this.failed = failed;
}
var ModelImportXML = function (){
var self = this;
self.modul_display = '<?php echo $modul_display ?>';
self.processing = ko.observable(false);
self.isSKPD = <?php echo $id_skpd == 0 ? 'false' : 'true'; ?>;
self.akses_level = ko.observable(<?php echo isset($akses) ? $akses : 0 ?>);
self.id_skpd = ko.observable(<?php echo isset($data['ID_SKPD']) ? $data['ID_SKPD'] : '' ?>)
.extend({
required: {params: true, message: 'SKPD belum dipilih'}
});
self.kd_skpd = ko.observable(<?php echo isset($data['KODE_SKPD_LKP']) ? json_encode($data['KODE_SKPD_LKP']) : '' ?>);
self.nm_skpd = ko.observable(<?php echo isset($data['NAMA_SKPD']) ? json_encode($data['NAMA_SKPD']) : '' ?>);
self.jurnal_array = ko.observableArray(<?php echo json_encode($setup_jurnal) ?>);
self.jurnal = ko.observable(<?php echo isset($data['ID_SETUP_JURNAL']) ? $data['ID_SETUP_JURNAL'] : '' ?>)
.extend({
required: {params: true, message: 'Template jurnal belum dipilih'}
});
self.file_xml = ko.observableArray([])
.extend({
required: {params: true, message: 'File xml belum diupload'}
});
self.removeFileXML = function() {
self.file_xml.remove(this);
}
self.showMessage = ko.observable(false);
self.skp_success = ko.observable(0);
self.skp_failed = ko.observable(0);
self.rek_failed = ko.observable(0);
self.title = ko.computed(function(){
return self.modul_display;
});
self.canSave = ko.computed(function(){
return self.akses_level() >= 3;
});
self.errors = ko.validation.group(self);
}
var App = new ModelImportXML();
App.formValidation = function(){
var errmsg = [];
if (!App.isValid()){
errmsg.push('Ada kolom yang belum diisi dengan benar. Silakan diperbaiki.');
App.errors.showAllMessages();
}
if (errmsg.length > 0) {
message = errmsg.join('</br>');
show_warning(message);
return false;
}
return true;
}
App.save = function(){
if (!App.formValidation()){ return }
App.processing(true);
proses_import(App.file_xml()[fileIndeks]['name']);
}
App.pilih_skpd = function(){
if (!App.canSave() || App.isSKPD) { return; }
var option = {multi:0};
Dialog.pilihSKPD(option, function(obj, select){
var rs = $(obj).jqGrid('getRowData', select[0].id);
App.id_skpd(rs.id);
App.kd_skpd(rs.kode);
App.nm_skpd(rs.nama);
});
}
ko.applyBindings(App);
setTimeout(function(){
<?php
if ($id_skpd !== 0){
?>
App.id_skpd(<?php echo $id_skpd; ?>);
App.kd_skpd('<?php echo $kode_skpd; ?>');
App.nm_skpd('<?php echo $nama_skpd; ?>');
<?php
}
?>
}, 500)
</script>