add.pt
8.9 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
222
223
224
225
226
227
228
229
230
231
232
233
234
<html metal:use-macro="load: ../base.pt">
<div metal:fill-slot="content">
<link href="/static/datatables/extensions/TableTools/css/dataTables.tableTools.min.css" rel="stylesheet">
<link href="/static/datatables/media/css/dataTables.bootstrap.css" rel="stylesheet">
<h4>Tambah/Edit STS</h4>
<hr>
<form id="deform" method="POST" enctype="multipart/form-data" accept-charset="utf-8"
class="form-horizontal">
<fieldset class="deformFormFieldset">
<input type="hidden" name="_charset_" />
<input type="hidden" name="__formid__" value="deform"/>
<div tal:condition="'id' in form">
<div tal:define="field form['id']">
${structure:field.serialize()}
</div>
</div>
<!--unit_id ------------------------------->
<div class="form-group">
<!--unit_id ------------------------------->
<div tal:define="field form['unit_id']">
${structure:field.serialize()}
</div>
</div>
<div class="form-group" tal:define="field form['unit_nm']" id="item-${field.oid}">
<label for="${field.oid}" class="control-label col-md-1" id="req-${field.oid}">
${field.title}<span id="error-${field.oid}" class="text text-danger"
tal:condition="field.required"> *</span></label>
<div class="col-md-11">
${structure:field.serialize()}
</div>
</div>
<script>
//Untuk headof OPD
$('#unit_nm').typeahead({
"hint" : true,
"highlight": true,
"minLength": 1,
"remote" : "/skpd/hon_wp/act?term=%QUERY",
},{
"name" : 'unit_nm',
"displayKey": 'value',
});
$('#unit_nm').bind('typeahead:selected', function(obj, datum, name) {
$('#unit_id').val(datum.id);
});
</script>
<!--kode ------------------------------->
<div class="form-group" tal:define="field form['kode']" id="item-${field.oid}">
<label for="${field.oid}" class="control-label col-md-1" id="req-${field.oid}">
${field.title}<span id="error-${field.oid}" class="text text-danger"
tal:condition="field.required"> *</span></label>
<div class="col-md-5">
${structure:field.serialize()}
<script>
$("#${field.oid}").attr("readonly", true);
</script>
</div>
<!--tgl_sts ------------------------------->
<div tal:define="field form['tgl_sts']" id="item-${field.oid}">
<label for="${field.oid}" class="control-label col-md-3" id="req-${field.oid}">
${field.title}<span id="error-${field.oid}" class="text text-danger"
tal:condition="field.required"> *</span></label>
<div class="col-md-3">
${structure:field.serialize()}
</div>
</div>
</div>
<!--nama ------------------------------->
<div class="form-group" tal:define="field form['nama']" id="item-${field.oid}">
<label for="${field.oid}" class="control-label col-md-1" id="req-${field.oid}">
${field.title}<span id="error-${field.oid}" class="text text-danger"
tal:condition="field.required"> *</span></label>
<div class="col-md-11">
${structure:field.serialize()}
</div>
</div>
<!--jumlah ------------------------------->
<div class="form-group" tal:define="field form['jumlah']" id="item-${field.oid}">
<label for="${field.oid}" class="control-label col-md-1" id="req-${field.oid}">
${field.title}<span id="error-${field.oid}" class="text text-danger"
tal:condition="field.required"> *</span></label>
<div class="col-md-4">
${structure:field.serialize()}
<script>
$("#${field.oid}").attr("readonly", true);
</script>
</div>
<!--Button ------------------------------->
<div class="col-md-4">
<button id="deformsave" name="simpan" type="submit" class="btn btn-primary "
value="simpan">Simpan</button>
<button id="deformcancel" name="batal" type="submit" class="btn btn-default "
value="batal">Batal</button>
</div>
</div>
</fieldset>
</form>
<table id="table1" name="table1" class="table table-bordered table-hover table-condensed" >
<thead>
<tr>
<th>ID</th>
<th>SSPDID</th>
<th>RekID</th>
<th>Kode</th>
<th>Rekening</th>
<th>Jumlah</th>
</tr>
</thead>
<tbody>
</tbody>
</table><br><br><br>
<!--Form Detail------------------------------->
<form id="detail" method="POST" enctype="multipart/form-data" accept-charset="utf-8"
class="form-horizontal">
<fieldset class="deformFormFieldset">
<!--Belum Tau Isiannya apa :) -->
</fieldset>
</form>
<script src="/static/datatables/media/js/jquery.dataTables.min.js"></script>
<!--script src="/static/datatables/media/js/jquery.jeditable.js')}"></script-->
<script src="/static/datatables/media/js/jquery.dataTables.ext.js"></script>
<script src="/static/datatables/extensions/TableTools/media/js/ZeroClipboard.js"></script>
<script src="/static/datatables/media/js/dataTables.bootstrap.js"></script>
<script>
var mID;
var oTable;
var iPos;
var oFormUrl = "/arstsitem/";
var sts_id = $('#id').val();
//Nambahin variable sts_id & kondisi untuk pemanggilan grid
if (!sts_id){
kosong = '0';
var oTableUrl = oFormUrl+"grid/act?sts_id="+kosong;
}else{
var oTableUrl = oFormUrl+"grid/act?sts_id="+sts_id;
}
$(document).ready(function () {
oTable = $('#table1').dataTable({
"sAjaxSource" : oTableUrl,
"bStateSave" : true,
"bServerSide" : true,
"bProcessing" : true,
"sDom" : '<"toolbar">lfrtip',
"bScrollCollapse" : true,
"bSort" : true,
"bSearch" : false,
"bInfo" : false,
"bFilter" : true,
"bAutoWidth" : false,
"bPaginate" : true,
"sPaginationType" : "full_numbers",
"lengthMenu": [
[10, 25, 50, 100],
[10, 25, 50, 100]
],
"aoColumnDefs": [
{"bSearchable": false, "bVisible": false, "aTargets": [0,1,2]}
],
"aoColumns": [
null,
null,
null,
{"sWidth": "75px", "sClass": "right"},
null,
{"sWidth": "75px", "sClass": "right"},
],
});
var tb_array = [
'<div class="btn-group pull-left">',
'<button id="btn_tambah" class="btn btn btn-primary pull-left" type="button">Pilih</button>',
'<button id="btn_delete" class="btn btn btn-danger pull-left" type="button">Hapus</button>',
//'<button id="btn_print" class="btn btn btn-primary pull-left" type="button">Cetak</button>',
//' <button id="btn_close" class="btn btn btn-warning" type="button">Tutup</button>',
' ',
'</div>',
];
var tb = tb_array.join(' ');
$("div.toolbar").html(tb);
$('#table1 tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
mID = '';
$(this).removeClass('selected');
} else {
iPos = oTable.fnGetPosition(this);
var aData = oTable.fnGetData(iPos);
mID = aData[0];
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
$('#btn_tambah').click(function () {
var sts_id = $('#id').val();
if(!sts_id){
alert('Simpan Dulu Headernya');
}
else{
window.location = oFormUrl+$("#id").val()+'/list';
}
});
$('#btn_edit').click(function () {
if (mID) {
window.location = oFormUrl+mID+'/edit';
} else {
alert('Silahkan pilih data yang akan diedit');
}
});
$('#btn_delete').click(function () {
if (mID) {
var hapus = confirm('Hapus data ini?');
if (hapus == true) {
window.location = oFormUrl+mID+'/delete';
};
} else {
alert('Silahkan pilih data yang akan dihapus');
}
});
});
</script>
</div>
</html>