/
col_json.php
365 lines (279 loc) · 11.1 KB
/
col_json.php
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
include 'collateral_script/session_head.php';
include 'collateral_script/db_function.php';
include 'collateral_script/function.php';
$mod = $_GET["mod"];
switch ($mod) {
case "json_list_program":
$ListProgram = getlistProgram($_GET["produk"]);
echo json_encode($ListProgram);
exit;
break;
case "json_nomor_aplikasi":
json_nomor_aplikasi();
break;
case "json_sumDet":
json_sumDet();
break;
case "json_sumDetCair":
json_sumDetCair();
break;
case "json_produktifitasDet":
json_produktifitasDet();
break;
}
function json_produktifitasDet(){
$npp = $_GET['npp'];
$tgl1 = $_GET['tgl1'];
$tgl2 = $_GET['tgl2'];
$submn = $_GET['submn'];
$lnc = $_GET['lnc'];
$dataArray = array();
$db_function = new db_function();
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
if (!$sidx)
$sidx = 1;
if($limit==""){
$limit=10;
}
$sql = "select noaplikasi,namadebitur,no_rekg_pinjaman,produk,tgl_pk,no_bpkb,
no_pengikatan,no_polis_ass_jiwa,no_polis_ass_kerugian,tgl_update,no_trail
from debitur_trail where :whereInput: and userupdate='$npp' and lnc='$lnc' and
tgl_update>'" . balikTgl($tgl1) . "' and tgl_update<'" . balikTgl($tgl2) . " 23:59:59'
";
if ($submn == "input") {
$sql = str_replace(":whereInput:", "no_trail=1", $sql);
} else {
$sql = str_replace(":whereInput:", "no_trail<>1", $sql);
}
if(isset($_GET['searchValue']) && trim($_GET['searchValue'])!="" ){
$sql.=" and ".$_GET['searchBy']." like '%".$_GET['searchValue']."%' ";
}
$sqlCount = "select count(*) from ($sql) test";
$count = $db_function->selectOnefield($sqlCount);
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page = $total_pages;
$start = $limit * $page - $limit;
if ($start < 0)
$start = 0;
$sqlDt = $sql . " LIMIT $start , $limit";
$query = $db_function->selectAllRows($sqlDt);
$responce['page'] = $page;
$responce['total'] = $total_pages;
$responce['records']= $count;
$i=0;
foreach($query as $row){
$responce['rows'][$i]['id']=$i;
$responce['rows'][$i]['cell']=array(
'noaplikasi'=>$row['noaplikasi'],
'namadebitur'=>$row['namadebitur'],
'no_rekg_pinjaman'=>$row['no_rekg_pinjaman'],
'produk'=>$row['produk'],
'tgl_pk'=>$row['tgl_pk'],
'no_bpkb'=>$row['no_bpkb'],
'no_pengikatan'=>$row['no_pengikatan'],
'no_polis_ass_jiwa'=>$row['no_polis_ass_jiwa'],
'no_polis_ass_kerugian'=>$row['no_polis_ass_kerugian'],
'tgl_update'=>balikTglDate($row['tgl_update']),
'no_trail'=>$row['no_trail']
);
$i++;
}
echo json_encode($responce);
exit;
}
function getlistProgram($produk) {
$db_function = new db_function();
$ListProgram = array();
$buf = $db_function->selectAllRows(
"select b.program_nm from master_produk a join master_program b on a.produk_kd=b.produk_kd
where a.produk_nm='" . $produk . "' order by b.program_nm");
foreach ($buf as $row) {
$ListProgram[] = $row['program_nm'];
}
return $ListProgram;
}
function json_nomor_aplikasi() {
$db_function = new db_function();
$dataprint = array('status' => 'gagal');
$noaplikasi = $_GET['noaplikasi'];
if (strlen($noaplikasi) == 20) {
$buf['tgl'] = substr($noaplikasi, 0, 8);
$buf['program_kd'] = substr($noaplikasi, 8, 2);
$buf['cab_kd'] = substr($noaplikasi, 10, 5);
$program_kd = $buf['program_kd'];
$cab_kd = $buf['cab_kd'];
$inputdate = substr($buf['tgl'], 0, 2) . "-" . substr($buf['tgl'], 2, 2) . "-" . substr($buf['tgl'], 4, 4);
$lnc = cleanstr($db_function->selectOnefield("select singkatan from master_cab where cab_kd='" . $buf['cab_kd'] . "'"));
$buf = $db_function->selectOneRows(
"select prog.program_nm,prod.produk_kd,prod.produk_nm from master_program prog
left join master_produk prod on prog.produk_kd=prod.produk_kd
where prog.program_kd='" . $buf['program_kd'] . "'
");
$produk_kd = "";
$program = "";
$produk = "";
if (!empty($buf)) {
$produk = $buf['produk_nm'];
$program = $buf['program_nm'];
$produk_kd = $buf['produk_kd'];
}
$ListProgram = getlistProgram($produk);
if ($produk != "") {
$dataprint = array(
'status' => 'sukses',
'listProgram' => $ListProgram,
'field' => array(
'produk' => $produk,
'program' => $program,
'inputdate' => $inputdate,
'lnc' => $lnc
)
);
}
}
echo json_encode($dataprint);
exit;
}
function json_sumDet() {
$db_function = new db_function();
$tgl = $_GET['tgl'];
$lnc = $_GET['lnc'];
$jns = $_GET['jns'];
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
if($limit==""){
$limit=10;
}
$tgl_update = $tgl . " 23:59:59";
$sql = "select trail.noaplikasi,trail.namadebitur,trail.no_rekg_pinjaman,trail.produk,trail.tgl_pk,trail.no_bpkb,
trail.no_pengikatan,trail.no_polis_ass_jiwa,trail.no_polis_ass_kerugian,trail.tgl_update,trail.no_trail
from debitur_trail trail
join (select max(tgl_update) tgl_update,no_rekg_pinjaman from debitur_trail where tgl_update <= '$tgl_update' group by no_rekg_pinjaman) bb
on trail.no_rekg_pinjaman=bb.no_rekg_pinjaman and trail.tgl_update=bb.tgl_update
where lnc='$lnc' and :paramwhere: ";
if ($jns == "status_rekg") {
$sql = str_replace(":paramwhere:", "trail.status_rekg='AKTIF' ", $sql);
}
else if ($jns == "total") {
$sql = str_replace(":paramwhere:", "(no_bpkb='PENDING' or no_ajb='PENDING' or no_pengikatan='PENDING' or no_polis_ass_jiwa='PENDING' or no_polis_ass_kerugian='PENDING') ", $sql);
}
else{
$sql = str_replace(":paramwhere:", "trail.$jns='PENDING' ", $sql);
}
if(isset($_GET['searchValue']) && trim($_GET['searchValue'])!="" ){
$sql.=" and trail.".$_GET['searchBy']." like '%".$_GET['searchValue']."%' ";
}
$sqlCount = "select count(*) from ($sql) test";
$count = $db_function->selectOnefield($sqlCount);
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page = $total_pages;
$start = $limit * $page - $limit;
if ($start < 0)
$start = 0;
$sqlDt = "select * from ($sql)temp LIMIT $start , $limit";
$query = $db_function->selectAllRows($sqlDt);
$responce['page'] = $page;
$responce['total'] = $total_pages;
$responce['records']= $count;
$i=0;
foreach($query as $row){
$responce['rows'][$i]['id']=$i;
$responce['rows'][$i]['cell']=$row;
$i++;
}
echo json_encode($responce);
exit;
}
function json_sumDetCair() {
$db_function = new db_function();
$lnc = $_GET['lnc'];
$jns = $_GET['jns'];
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$tgl = $_GET['tgl'];
if($limit==""){
$limit=10;
}
$tgl_update = $tgl . " 23:59:59";
$sql = "select trail.noaplikasi,trail.namadebitur,trail.no_rekg_pinjaman,trail.tgl_pk ,trail.tgl_cair_tahap_fondasi,trail.tgl_cair_tahap_topping,trail.tgl_cair_tahap_bast,trail.tgl_cair_tahap_dok
from debitur join debitur_trail trail on debitur.no_rekg_pinjaman=trail.no_rekg_pinjaman
join (
select max(tgl_update) tgl_update,no_rekg_pinjaman from debitur_trail where tgl_update <= '$tgl_update' group by no_rekg_pinjaman) bb
on trail.no_rekg_pinjaman=bb.no_rekg_pinjaman and trail.tgl_update=bb.tgl_update
where 1=1 and trail.skim_pencairan='PARTIAL DROW DOWN' and trail.skim_pks in('KAVLING BANGUN','INDENT') :paramwhere: group by trail.lnc";
if(isset($_GET['searchValue']) && trim($_GET['searchValue'])!="" ){
$sql.=" and ".$_GET['searchBy']." like '%".$_GET['searchValue']."%' ";
}
switch ($jns){
case "debitur";
$sql = str_replace(":paramwhere:", "and trail.progress <>'' ", $sql);
break;
case "pondasi";
$sql = str_replace(":paramwhere:", "and trail.progress='BELUM SELESAI' and trail.tgl_cair_tahap_fondasi in(null,'','0000-00-00') ", $sql);
break;
case "topping";
$sql = str_replace(":paramwhere:", "and trail.progress='BELUM SELESAI' and trail.tgl_cair_tahap_fondasi >'0000-00-00' and trail.tgl_cair_tahap_topping in(null,'','0000-00-00') ", $sql);
break;
case "bast";
$sql = str_replace(":paramwhere:", "and trail.progress='BELUM SELESAI' and trail.tgl_cair_tahap_topping >'0000-00-00' and trail.tgl_cair_tahap_bast in(null,'','0000-00-00') ", $sql);
break;
case "dokumen";
$sql = str_replace(":paramwhere:", "and trail.progress='BELUM SELESAI' and trail.tgl_cair_tahap_bast >'0000-00-00' and trail.tgl_cair_tahap_dok in(null,'','0000-00-00') ", $sql);
break;
case "inprogress";
$sql = str_replace(":paramwhere:", "and trail.progress='SELESAI' ", $sql);
break;
case "selesai";
$sql.="AND progress='SELESAI'";
break;
}
$sqlCount = "select count(*) from ($sql) test";
$count = $db_function->selectOnefield($sqlCount);
if ($count > 0 && $limit > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page = $total_pages;
$start = $limit * $page - $limit;
if ($start < 0)
$start = 0;
$sqlDt = "select * from ($sql)temp LIMIT $start , $limit";
$query = $db_function->selectAllRows($sqlDt);
$responce['page'] = $page;
$responce['total'] = $total_pages;
$responce['records']= $count;
$i=0;
foreach($query as $row){
$row['tgl_pk']= balikTgl($row['tgl_pk']);
$row['tgl_cair_tahap_fondasi']= cleanDate(balikTgl($row['tgl_cair_tahap_fondasi']));
$row['tgl_cair_tahap_topping']= cleanDate(balikTgl($row['tgl_cair_tahap_topping']));
$row['tgl_cair_tahap_bast']= cleanDate(balikTgl($row['tgl_cair_tahap_bast']));
$row['tgl_cair_tahap_dok']= cleanDate(balikTgl($row['tgl_cair_tahap_dok']));
$responce['rows'][$i]['id']=$i;
$responce['rows'][$i]['cell']=$row;
$i++;
}
echo json_encode($responce);
exit;
}
?>