list.pt
8.17 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<html metal:use-macro="load: ../base.pt">
<div metal:fill-slot="content">
<div class="jarviswidget jarviswidget-color-blueLight"> <!-- jarviswidget -->
<header role="heading">
<h2>
<i class="fa fa-fw fa-table"></i>
${request.title}
</h2>
</header>
<div role="content">
<div class="widget-body"><!-- widget-body -->
<div class="dataTables_wrapper form-inline no-footer">
<div class="dt-toolbar" style="padding: 0; margin-bottom: 20px; background: #fff; border-bottom: none;"> <!-- dt-toolbar -->
<form id="form" method="POST" enctype="multipart/form-data" accept-charset="utf-8"
class="form-horizontal">
<fieldset class="deformFormFieldset">
<!--Tanggal-->
<div id="item-tanggal_fltr">
<div class="col-md-5">
<div class="input-group">
<span class="input-group-addon">Tanggal</span>
<input id="awal" class="form-control date-control" type="text"
value="${request.session['awal']}" name="awal">
<span class="input-group-addon">s.d</span>
<input id="akhir" class="form-control date-control" type="text"
value="${request.session['akhir']}" name="akhir">
</div>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="posted"
value = "1"
checked = "${request.session['posted'] and 'checked' or None}" name="posted">
</span>
<label class="form-control">Posted</label>
<span class="input-group-btn">
<button id="btn-filter" name="btn-filter" class="btn btn btn-primary" type="submit">Filter</button>
</span>
</div>
</div>
</div>
</fieldset>
</form>
</div>
<table id="table1" class="table table-bordered table-hover table-condensed dt-responsive">
<thead>
<tr>
<th>Nomor</th>
<th>Penyetor</th>
<th>Uraian</th>
<th>Tanggal.</th>
<th>Nilai</th>
<!-- <th>Bunga</th> -->
<!-- <th>Valid.</th> -->
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div metal:fill-slot="scripts">
<script>
$( document ).ready(function() {
var sUrl = "/sipkd/tbp";
var mID;
var mThn;
var oTable;
var iPos;
var oTableUrl = sUrl+"/grid/act";
var rows_selected = [];
var oTable = $('#table1').DataTable({
dom : '<"col-md-8"<"toolbar">l><"col-md-4"f>rtip',
processing : true,
serverSide : true,
ajax : oTableUrl,
//stateSave : true,
scrollCollapse: true,
sort : true,
info : false,
filter : true,
autoWidth : false,
paginate : true,
paginationType: "full_numbers",
displayLength : 25,
order : [[ 1, "asc" ],[ 2, "asc" ]],
lengthMenu: [
[10, 25, 50, 100],
[10, 25, 50, 100]
],
columns: [
{"data": "nomor", "width": "50px"},
{"data": "penyetor","width": "80px"},
{"data": "uraian"},
{"data": "tanggal", "width": "80px","className":"dt-center"},
//{"data": "nilai", "width": "80px", "className":"dt-right",
// "render": $.fn.dataTable.render.number( '.', ',', 0, '' )},
//{"data": "bunga", "width": "70px", "className":"dt-right",
// "render": $.fn.dataTable.render.number( '.', ',', 0, '' )},
{"data": "valid", "width": "80px", "className":"dt-center",}
],
"language": {
"search" : "Cari: ",
"paginate":{
"first" : "Pertama ",
"last" : "Akhir ",
"previous": "",
"next" : "",
},
"lengthMenu": "Tampil _MENU_ baris "
},
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
var rowId = aData[0];
if($.inArray(rowId, rows_selected) !== -1){
$(nRow).find('input[type="checkbox"]').prop('checked', true);
$(nRow).addClass('selected');
}
},
}); //end of oTable
var style_posted = "";
var style_unposted = "";
var tb_array = [
'<div class="btn-group pull-left">',
//' <button id="btn_add" class="btn btn btn-primary" type="button">Tambah</button>',
//' <button id="btn_edit" class="btn btn btn-primary" type="button">Edit</button>',
//' <button id="btn_delete" class="btn btn btn-danger" type="button">Hapus</button>',
//' <button id="btn_posting" class="btn btn btn-success" type="button">Proses</button>',
//' <!--<button id="btn_unposting" class="btn btn btn-info" type="button">Un-Posting</button>-->',
//' <button id="btn_close" class="btn btn-warning" type="button">Tutup</button>',
//' <button id="btn_csv" class="btn btn-primary" type="button">CSV</button>',
//' <button id="btn_pdf" class="btn btn-primary" type="button">PDF</button>',
' ',
'</div>',
];
var tb = tb_array.join(' ');
$("div.toolbar").html(tb);
$("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;');
/***********************************************************************
BUTTON
***********************************************************************/
$('#btn_add').click(function () {
window.location = sUrl+'/add';
});
$('#btn_edit').click(function () {
if (mID) window.location = sUrl+'/'+mID+'/edit';
else alert('Pilih Baris yang akan di edit');
});
$('#btn_delete').click(function () {
if (mID) window.location = sUrl+'/'+mID+'/delete';
else alert('Pilih Baris yang akan di hapus');
});
$("#btn_close").click(function () {
window.location = '/skpd';
return false;
});
$('#btn_posting').click(function () {
if (rows_selected.length>0) {
$.ajax({
type: "POST",
url: sUrl+"/post",
data : { id : rows_selected.join(",") },
success: function (html) {
if (html.success == true) {
$("#success").css('display', 'inline', 'important');
$("#success").html("<span class='glyphicon glyphicon-ok'></span> " + html.msg);
rows_selected = [];
oTable.ajax.reload();}
else {
$("#errors").css('display', 'inline', 'important');
$("#errors").html("<span class='glyphicon glyphicon-remove'></span> " + html.msg);
}
} //end if
}); //end ajax*/
} //end if
else {
alert('Silahkan pilih data yang akan diposting');
}
});
$('#btn_csv').click(function () {
window.location = sUrl+ "/csv";
});
$('.date-control').datepicker({
format:'dd-mm-yyyy'
});
//Handle click on row data
$('#table1 tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
} else {
var aData = oTable.row( this ).data();
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
mID = aData.id;
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});
}); //end of document
</script>
</div>
</html>