Repository navigation
Expand file tree
/
Copy pathjCustom.js
More file actions
109 lines (98 loc) · 3.82 KB
/
Copy pathjCustom.js
File metadata and controls
109 lines (98 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$(document).ready(function () {
var urlJsonP = $('span.url_act').text()+'/GetJsonMyDonasi';
$('table.donasi-program-table').DataTable({
"oLanguage": {
"sEmptyTable": "Belum ada data. <a href='#' class='btn btn-primary add-from-tb'><i class='glyphicon glyphicon-plus'></i> Tambahkan data</a>"
},
"iDisplayLength": 5,
"processing": true, //Feature control the processing indicator.
"serverSide": true, //Feature control DataTables' server-side processing mode.
// Load data for the table's content from an Ajax source
"ajax": {
"url": urlJsonP,
"type": "POST"
},
//Set column definition initialisation properties.
"columnDefs": [
{
"targets": [ -1 ], //last column
"orderable": false, //set not orderable
}
]
});
$('input[name="donatur_nama"]').focus();
$("input[name=filektp]").change(function () {
readURL(this);
});
$(document).on('click','.btn-donate',function(){
//alert('wew');
var id = $(this).attr('id');
$('input.jml-'+id).css('display','block');
$(this).addClass('btn-donate-submit');
$(this).text('submit');
});
$(document).on('click','a.item-upload',function(){
var id = $(this).attr('id');
var judul = $('h4.heading-'+id).text();
var urlJson = $('span.url_act').text()+'/RequestGetSrcDokumen';
var baseurl = $('span.base-url-upload').text();
var kirim = {'dokid':id};
if ($('p.uid').length == 1) {
kirim['uid'] = $('p.uid').text();
};
$.ajax({
url: urlJson,
data: kirim,
type:"POST",
dataType:"json",
success: function(data){
if (data.length > 0) {
$.each( data, function( key, val ) {
if (val.sb_dok_src == null) {
$('form.upload-submit').after('mohon maaf anda harus upload ulang, karena dokumen <b>'+judul+'</b> tidak ditemukan dalam server');
}else{
$('div.modal-body').html('<img src="'+baseurl+val.sb_dok_src+'" class="img-responsive" alt="'+judul+'"/>');
if (val.sb_verify == 1) {
$('.modal-footer').html('<span style="font-size:14px;" class="label label-success">sudah terverifikasi</span>');
};
}
});
}
$('h4.modal-title').text(judul);
$('input[name="sb_dok_id"]').val(id);
$('#modalupload').modal('show');
}
});
});
//urladmAct
$(document).on('click','a.btn-donate-submit',function(){
var id = $(this).attr('id');
var jml = $('input.jml-'+id).val().trim();
var url_act = $('span.url_act').text()+'/DonateSubmit';
if (jml.length > 0) {
$.ajax({
url: url_act,
type:"POST",
data: {'donasi_program_id':id,'donasi_jumlah':jml},
success :function(data){
if (data == '0') {
alert('gagal memberi donasi');
}
location.reload();
}
});
}else{
alert('angka tidak boleh kosong');
location.reload();
}
});
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#image_upload_preview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}