Project

General

Profile

Bug #1299 » MinovaUtil.FieldGenerator.js

Tri Rizqiaty, 06/30/2022 03:40 PM

 
1
Ext.define('MinovaUtil.FieldGenerator', {});
2
MinovaUtil.FieldGenerator.Form = function (formname, rec, null_, viewOnly, tbl, isLookup) {
3
	var lw=150;
4
	if(isDesk== false){
5
		lw=100;
6
	}
7
    var formfield = undefined;
8
    var ReadOnly_ = false;
9
    var Hidden_ = false;
10
    var start_ = null;
11
    var end_ = null;
12
    var defaultValue = rec.DefaultValue;
13

    
14
    if (defaultValue.substring(0, 2).toLowerCase() == 'fn') {
15
        Ext.Ajax.request({
16
            async: false,
17
            method: 'POST',
18
            url: '/UserControl/GetStore',
19
            params: {
20
                tableName: 'PCMFUNC',
21
                param: 'FuncName[equal]' + rec.DefaultValue
22
            },
23
            success: function (response) {
24
                var results = Ext.decode(response.responseText);
25
                data_ = results.data;
26
                if (data_.length > 0) {
27
                    defaultValue = eval(data_[0].FunctionCode);
28
                }
29
            }
30
        });
31

    
32
    }
33

    
34
    if (rec.FieldName == 'StartDate' || rec.FieldName == 'EndDate') {
35
        start_ = 'StartDate';
36
        end_ = 'EndDate';
37
    }
38
    if (rec.FieldName == 'ValidFrom' || rec.FieldName == 'ValidThrough') {
39
        start_ = 'ValidFrom';
40
        end_ = 'ValidThrough';
41
    }
42
	/*BEGIN YN 220512*/
43
	if (rec.FieldName == 'SDate' || rec.FieldName == 'EDate') {
44
        start_ = 'SDate';
45
        end_ = 'EDate';
46
    }
47
	/*END YN 220512*/
48
    if (rec.ReadOnly == '1') {
49
        ReadOnly_ = true;
50
    }
51

    
52
    if (rec.IsHidden == '1' || rec.Sequence == '' || rec.Sequence == '0' || rec.ColumnNo == '' || rec.GridView == '') {
53
        Hidden_ = true;
54
        null_ = true;
55
    }
56
    if (viewOnly == true) {
57
        if (rec.TableRef != '' && rec.SearchType == "2") {
58
            formfield = new Ext.form.Display({
59
                fieldBodyCls: 'x-form-trigger-wrap-minova',
60
                fieldLabel: rec.ScreenCaption,
61
                readOnly: ReadOnly_,
62
                hidden: Hidden_,
63
                name: rec.FieldName,
64
                value: defaultValue,
65
                padding: 0,
66
                anchor: '100%',
67
                IsPrimaryKey: rec.IsPrimaryKey,
68
                labelCls: 'label-minova',
69
                labelWidth: lw,
70
                tableRef: rec.TableRef,
71
                listeners: {
72
                    change: function () {
73
                        var me = this;
74
                        data_ = undefined;
75
                        Ext.Ajax.request({
76
                            async: false,
77
                            method: 'POST',
78
                            url: '/UserControl/GetStore',
79
                            params: {
80
                                tableName: 'PDSCMTABLE',
81
                                param: me.tableRef + ',' + me.getValue() + ',hasil'
82
                            },
83
                            success: function (response) {
84
                                var results = Ext.decode(response.responseText);
85
                                data_ = results.data;
86
                                if (data_ != null) {
87
                                    if (data_.length > 0) {
88
                                        value = value + '-' + data_[0].hasil;
89
                                        me.setRawValue(value);
90
                                    }
91
                                }
92
                            }
93
                        });
94
                    }
95
                }
96
            });
97
        }
98
        if (rec.TableRef != '' && rec.SearchType != "" && rec.SearchType != "2") {
99

    
100
            valueField = null;
101
            displayValue = null;
102
            Ext.Ajax.request({
103
                async: false,
104
                method: 'POST',
105
                url: '/UserControl/GetStore',
106
                params: {
107
                    tableName: 'SDATATABLEFIELD',
108
                    param: 'TableName[equal]' + rec.TableRef
109
                },
110
                success: function (response) {
111
                    var results = Ext.decode(response.responseText);
112
                    data_ = results.data;
113
                    if (data_ != undefined) {
114
                        valueField_ = $.grep(data_, function (r) {
115
                            return r.ValueField == '1'
116
                        });
117
                        valueField = valueField_[0].FieldName
118
                        displayValue_ = $.grep(data_, function (r) {
119
                            return r.DisplayValue == '1'
120
                        });
121
                        displayValue = displayValue_[0].FieldName
122

    
123
                    }
124
                }
125
            });
126
            var objClass = '';
127
            var comboParam = ''
128
            if (rec.TableRef.toLowerCase() == 'phrom0001') {
129
                var splitParam = rec.ParamCombo.split(']');
130
                if (splitParam.length == 1) {
131
                    objClass = ',ObjectClass[=]' + splitParam[0]
132
                } else {
133
                    objClass = rec.ParamCombo
134
                }
135
                comboParam = objClass;
136
                var sdate = Ext.ComponentQuery.query('displayfield[name=StartDate]')[0];
137
                var date = MinovaUtil.GetNowDate();
138
                var sdateVal = '';
139
                var edateVal = '';
140
                if (sdate) {
141
                    sdateVal = sdate.getValue();
142
                } else {
143
                    sdateVal = date;
144
                }
145
                if (sdateVal == '') {
146
                    sdateVal = date
147
                }
148
                objClass = objClass + ',StartDate[<=]' + sdateVal + ',EndDate[>=]' + sdateVal
149
            } else {
150
                objClass = rec.ParamCombo
151
            }
152
            formfield = new Ext.form.Display({
153
                fieldBodyCls: 'x-form-trigger-wrap-minova',
154
                fieldLabel: rec.ScreenCaption,
155
                readOnly: ReadOnly_,
156
                hidden: Hidden_,
157
                name: rec.FieldName,
158
                //value: defaultValue, //Untuk Display jangan diisi default, karena event change ga akan tereksekusi jika value = defaultvalue
159
                padding: 0,
160
                anchor: '100%',
161
                IsPrimaryKey: rec.IsPrimaryKey,
162
                labelCls: 'label-minova',
163
                labelWidth: lw,
164
                objClass: objClass,
165
                comboParam: comboParam,
166
                //store : Ext.create('Ext.data.Store', {
167
                //	storeId : 'storeDisplay' + rec.FieldName,
168
                //	autoLoad : false,
169

    
170
                //}),
171
				store: Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName),
172
				/*
173
                store: Ext.create('Ext.data.Store', {
174
                    storeId: 'storeDisplay' + rec.FieldName,
175
                    autoLoad: true,
176
                    //fields: ['MenuType', 'MenuDesc'],
177
                    proxy: {
178
                        method: 'POST',
179
                        async: false,
180
                        type: 'ajax',
181
                        url: '/UserControl/GetStore?tableName=' + rec.TableRef + '&param=' + objClass,
182

    
183
                        reader: {
184
                            type: 'json',
185
                            root: 'data'
186
                        }
187
                    }
188
                }),*/
189
                listeners: {
190

    
191
                    //	var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
192
                    //	Ext.Ajax.request({
193
                    //		method : 'POST',
194
                    //		async : true,
195
                    //		url : '/UserControl/GetStore',
196
                    //		params : {
197
                    //			tableName : rec.TableRef,
198
                    //			param : ''
199
                    //		},
200
                    //		success : function (response) {
201
                    //			var results = Ext.decode(response.responseText);
202
                    //			store.loadData(results.data);
203

    
204
                    //		}
205
                    //	});
206
                    //},
207
                    afterrenderer: function (f) {
208
                        var display = this.displayField;
209
                        var value = this.getValue();
210
                        var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
211
                        //store.load();
212
                        var r = store.findRecord(f.valueField, f.value)
213
                        if (r != null) {
214
                            f.setRawValue(r.get(f.displayField))
215
                        }
216
                    },
217

    
218
                    change: function (f) {
219
                        //alert(this.valueField, value);
220
                        var display = this.displayField;
221
                        var objClass = this.objClass;
222
                        //var field_ = Ext.ComponentQuery.query('[name=' + rec.FieldName + ']')[0];
223
                        var field_ = this;
224
                        var sdateVal = MinovaUtil.GetNowDate();
225
                        if (Ext.ComponentQuery.query('displayfield[name=StartDate]')[0]) {
226
                            sdateVal = Ext.ComponentQuery.query('displayfield[name=StartDate]')[0].getValue();
227
							sdateVal_=sdateVal.substring(6,10)+sdateVal.substring(3,5)+sdateVal.substring(0,2);
228
							sdateVal=sdateVal_;
229
                        }
230
                        var comboParam = field_.comboParam;
231
                        comboParam = comboParam + ',StartDate[<=]' + sdateVal + ',EndDate[>=]' + sdateVal
232
                        var value = this.getValue();
233
						storeName = 'storeDisplay' + rec.FieldName;
234
						var store = Ext.StoreMgr.lookup(storeName);
235
						if (store == undefined) {
236
							var storeRef = Ext.create('Ext.data.Store', {
237
								storeId: storeName,
238
								autoLoad: true,
239
								f: f,
240
								proxy: {
241
									method: 'POST',
242
									type: 'ajax',
243
									url: '/UserControl/GetStore',
244
									extraParams: {
245
										tableName: rec.TableRef,
246
										param: rec.ParamCombo
247
									},
248
									reader: {
249
										type: 'json',
250
										root: 'data',
251
										totalProperty: 'data[0].TotalCount'
252
									},
253
									//autoLoad: {
254
									//    callback: function (f, storeName){
255
									//        console.log(f);
256
									//    }
257
									//}
258
								}
259
							});
260
							storeRef.on("load", function (me) {
261
								f = me.f;
262
								var r = me.findRecord(f.valueField, f.value);
263
								if (r != null) {
264
									f.setRawValue(r.get(f.displayField));
265
								}
266
							});
267
							//storeRef.load();
268
							//store = storeRef;
269
						}
270
						else {
271
							if (store.data.length == 0) {
272
								Ext.Ajax.request({
273
									method: 'POST',
274
									async: false,
275
									url: '/UserControl/GetStore',
276
									params: {
277
										tableName: rec.TableRef,
278
										param: f.valueField + '[=]' + field_.getValue() + ',' + comboParam
279
									},
280
									success: function (response) {
281
										var results = Ext.decode(response.responseText);
282
										var data_ = results.data;
283
										if (data_.length > 0) {
284
											var dt = eval('data_[0].' + field_.displayField);
285
											field_.setRawValue(dt);
286
										}
287
									}
288
								});
289
							} else {
290
								var r = store.findRecord(f.valueField, f.value)
291
								if (r != null) {
292
									f.setRawValue(r.get(f.displayField))
293
								}
294
							}
295
						}
296
						/*
297
                        var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
298
                        if (store.data.length == 0) {
299
                            Ext.Ajax.request({
300
                                method: 'POST',
301
                                async: false,
302
                                url: '/UserControl/GetStore',
303
                                params: {
304
                                    tableName: rec.TableRef,
305
                                    param: f.valueField + '[=]' + field_.getValue() + ',' + comboParam
306
                                },
307
                                success: function (response) {
308
                                    var results = Ext.decode(response.responseText);
309
                                    var data_ = results.data;
310
                                    if (data_.length > 0) {
311
                                        var dt = eval('data_[0].' + field_.displayField);
312
                                        field_.setRawValue(dt);
313

    
314
                                    }
315

    
316
                                }
317
                            });
318

    
319
                        } else {
320
                            var r = store.findRecord(f.valueField, f.value)
321
                            if (r != null) {
322
                                f.setRawValue(r.get(f.displayField))
323
                            }
324

    
325
                        }*/
326

    
327
                    }
328

    
329
                },
330
                queryMode: 'local',
331
                displayField: displayValue,
332
                valueField: valueField,
333
            });
334
        } else {
335
            switch (rec.FormatRef) {
336
                //case 'date':
337
                //    formfield = new Ext.form.Display({
338
                //        ieldBodyCls: 'x-form-trigger-wrap-minova',
339
                //        labelCls: 'label-minova',
340
                //        labelWidth: lw,
341
                //        hidden: Hidden_,
342
                //        fieldLabel: rec.ScreenCaption,
343
                //        name: rec.FieldName,
344
                //        value: rec.DefaultValue,
345
                //        IsPrimaryKey: rec.IsPrimaryKey,
346
                //        padding: 0,
347
                //        anchor: '100%',
348
                //        listeners: {
349
                //            change: function (f) {
350
                //                var value_ = f.getValue();
351
                //                if (value_ != '' && value_ != undefined && value_.length == 8) {
352
                //                    f.setValue(value_.substring(6, 8) + '/' + value_.substring(4, 6) + '/' + value_.substring(0, 4))
353
                //                }
354
                //            }
355
                //        }
356
                //    });
357
                //    break;
358
                case 'date':
359
                    formfield = new Ext.form.Display({
360
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
361
                        labelCls: 'label-minova',
362
                        labelWidth: lw,
363
                        hidden: Hidden_,
364
                        fieldLabel: rec.ScreenCaption,
365
                        name: rec.FieldName,
366
                        value: defaultValue,
367
                        IsPrimaryKey: rec.IsPrimaryKey,
368
                        padding: 0,
369
                        anchor: '100%',
370
                        readOnly: ReadOnly_,
371
                        listeners: {
372
                            change: function (f) {
373
                                var value_ = f.getValue();
374
                                if (value_ != '' && value_ != undefined && value_.length == 8) {
375
                                    f.setValue(value_.substring(6, 8) + '/' + value_.substring(4, 6) + '/' + value_.substring(0, 4))
376
                                }
377
                            }
378
                        }
379
                    });
380
                    break;
381
                case 'datetime':
382
                    formfield = new Ext.form.Display({
383
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
384
                        labelCls: 'label-minova',
385
                        labelWidth: lw,
386
                        hidden: Hidden_,
387
                        fieldLabel: rec.ScreenCaption,
388
                        name: rec.FieldName,
389
                        value: defaultValue,
390
                        IsPrimaryKey: rec.IsPrimaryKey,
391
                        padding: 0,
392
                        readOnly: ReadOnly_,
393
                        anchor: '100%',
394
                        listeners: {
395
                            change: function (f) {
396
                                var value_ = f.getValue();
397
                                if (value_ != '' && value_ != undefined && value_.length == 14) {
398
                                    f.setValue(value_.substring(6, 8) + '/' + value_.substring(4, 6) + '/' + value_.substring(0, 4) + ' ' + value_.substring(8, 10) + ':' + value_.substring(10, 12) + ':' + value_.substring(12, 14))
399
                                }
400
                            }
401
                        }
402
                    });
403
                    break
404
                case "amountencrypt":
405
                    formfield = new Ext.form.Display({
406
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
407
                        labelCls: 'label-minova',
408
                        labelWidth: lw,
409
                        hidden: Hidden_,
410
                        fieldLabel: rec.ScreenCaption,
411
                        name: rec.FieldName,
412
                        value: defaultValue,
413
                        fieldStyle: 'text-align:right;',
414
                        IsPrimaryKey: rec.IsPrimaryKey,
415
                        padding: 0,
416
                        readOnly: ReadOnly_,
417
                        anchor: '100%',
418
                        isEncryptDisplay: true,
419
                        nameTable: tbl
420
                    });
421
                    break
422
                default:
423
                    if (rec.FixedValue == '') {
424
                        formfield = new Ext.form.Display({
425
                            fieldBodyCls: 'x-form-trigger-wrap-minova',
426
                            labelCls: 'label-minova',
427
                            labelWidth: lw,
428
                            hidden: Hidden_,
429
                            readOnly: ReadOnly_,
430
                            fieldLabel: rec.ScreenCaption,
431
                            name: rec.FieldName,
432
                            value: defaultValue,
433
                            IsPrimaryKey: rec.IsPrimaryKey,
434
                            padding: 0,
435
                            anchor: '100%',
436

    
437
                        });
438
                    } else {
439
                        formfield = new Ext.form.Display({
440
                            fieldBodyCls: 'x-form-trigger-wrap-minova',
441
                            labelCls: 'label-minova',
442
                            labelWidth: lw,
443
                            hidden: Hidden_,
444
                            readOnly: ReadOnly_,
445
                            fieldLabel: rec.ScreenCaption,
446
                            name: rec.FieldName,
447
                            value: defaultValue,
448
                            IsPrimaryKey: rec.IsPrimaryKey,
449
                            padding: 0,
450
                            anchor: '100%',
451
                            fixedValue: rec.FixedValue,
452
                            cek: true,
453
                            listeners: {
454

    
455
                                change: function (val) {
456
                                    if (val.cek) {
457
                                        var valueField = val.getValue();
458
                                        var fixed = val.fixedValue;
459
                                        var hasil = fixed.split('||');
460
                                        var code = '';
461
                                        hasil.forEach(function (h) {
462
                                            store_ = h.split('=')
463
                                            //storeData.push({
464
                                            //    code: store_[0],
465
                                            //    desc: store_[1],
466

    
467
                                            //});
468
                                            code = store_[0]
469
                                            if (code == valueField) {
470
                                                val.setValue(store_[1]);
471
                                                val.cek = false;
472
                                            }
473
                                        });
474
                                    }
475
                                }
476
                            }
477
                        });
478
                    }
479
                    break;
480
            }
481
        }
482

    
483
    } else {
484
        switch (rec.FormatRef) {
485
			case "area":
486
			    formfield = new Ext.form.TextArea({
487
                            allowBlank: null_,
488
                            fieldLabel: rec.ScreenCaption,
489
                            readOnly: ReadOnly_,
490
                            readOnlyCls: 'minova-readonly',
491
                            labelCls: 'label-minova',
492
                            labelWidth: lw,
493
                            hidden: Hidden_,
494
                            name: rec.FieldName,
495
                            msgTarget: 'side',
496
                            value: defaultValue,
497
                            IsPrimaryKey: rec.IsPrimaryKey,
498
                            maxLength: rec.Length,
499
                            anchor: '100%',
500
                            formname: formname,
501
                            vtype: 'validateMinovaXss',
502
                            nameTable: tbl,
503
                            listeners: {
504

    
505
                                change: function (val) {
506
                                    var _label = val.name;
507
                                    var _form = val.formname;
508
                                    var _Value = val.getValue();
509
                                    var target = rec.TriggerCombo;
510
                                    var custumFunc = rec.SelectFunction;
511
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
512
                                        Ext.Ajax.request({
513
                                            async: false,
514
                                            method: 'POST',
515
                                            url: '/UserControl/GetStore',
516
                                            params: {
517
                                                tableName: 'PCMFUNC',
518
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
519
                                            },
520
                                            success: function (response) {
521
                                                var results = Ext.decode(response.responseText);
522
                                                data_ = results.data[0];
523
                                                if (data_ != undefined) {
524
                                                    custumFunc = data_.FunctionCode;
525
                                                }
526
                                            }
527
                                        });
528
                                    }
529
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
530
                                    if (frm) {
531

    
532
                                        if (target) {
533
                                            var f = frm.getForm().findField(target)
534
                                            _store = f.getStore();
535
                                            var _tbl = _store.proxy.extraParams.tableName;
536
                                            var oldParam = _store.proxy.extraParams.param;
537
                                            _store.proxy.extraParams = {
538
                                                tableName: _tbl,
539
                                                param: _label + '[=]' + _Value
540
                                            };
541
                                            _store.load();
542
                                        }
543

    
544
                                        if (custumFunc) {
545
                                            eval(custumFunc)
546
                                        }
547

    
548
                                    }
549

    
550
                                },
551

    
552
                            },
553
                        });
554
                    break
555
            case "date":				
556
				/*YN 220512*/
557
                if (rec.FieldName == 'StartDate' || rec.FieldName == 'EndDate' || rec.FieldName == 'ValidFrom' || rec.FieldName == 'ValidThrough' || rec.FieldName == 'SDate' || rec.FieldName == 'EDate' ) {
558
                    formfield = new Ext.form.DateField({
559
                        allowBlank: null_,
560
                        readOnlyCls: 'minova-readonly',
561
                        fieldLabel: rec.ScreenCaption,
562
                        readOnly: ReadOnly_,
563
                        msgTarget: 'side',
564
                        hidden: Hidden_,
565
                        labelCls: 'label-minova',
566
                        labelWidth: lw,
567
                        name: rec.FieldName,
568
                        format: 'd/m/Y',
569
                        submitFormat: 'Ymd',
570
                        IsPrimaryKey: rec.IsPrimaryKey,
571
                        value: defaultValue,
572
                        anchor: '100%',
573
                        vtype: 'daterange',
574
                        start: start_,
575
                        end: end_,
576
                        pnl: formname,
577
                        formname: formname,
578
                        nameTable: tbl,
579
                        hideMode: 'visibility',
580
                        listeners: {
581

    
582
                            change: function (val) {
583
                                var _label = val.name;
584
                                var _form = val.formname;
585
                                var _Value = val.getValue();
586
                                var target = rec.TriggerCombo;
587
                                var custumFunc = rec.SelectFunction;
588
                                if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
589
                                    Ext.Ajax.request({
590
                                        async: false,
591
                                        method: 'POST',
592
                                        url: '/UserControl/GetStore',
593
                                        params: {
594
                                            tableName: 'PCMFUNC',
595
                                            param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
596
                                        },
597
                                        success: function (response) {
598
                                            var results = Ext.decode(response.responseText);
599
                                            data_ = results.data[0];
600
                                            if (data_ != undefined) {
601
                                                custumFunc = data_.FunctionCode;
602
                                            }
603
                                        }
604
                                    });
605
                                }
606
                                var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
607
                                if (frm) {
608

    
609
                                    if (target) {
610
                                        var f = frm.getForm().findField(target)
611
                                        _store = f.getStore();
612
                                        var _tbl = _store.proxy.extraParams.tableName;
613
                                        var oldParam = _store.proxy.extraParams.param;
614
                                        _store.proxy.extraParams = {
615
                                            tableName: _tbl,
616
                                            param: _label + '[=]' + _Value
617
                                        };
618
                                        _store.load();
619
                                    }
620

    
621
                                    if (custumFunc) {
622
                                        eval(custumFunc)
623
                                    }
624

    
625
                                }
626

    
627
                            },
628

    
629
                        },
630
                    });
631
                } else {
632
                    formfield = new Ext.form.DateField({
633
                        allowBlank: null_,
634
                        fieldLabel: rec.ScreenCaption,
635
                        readOnlyCls: 'minova-readonly',						
636
                        readOnly: ReadOnly_,
637
                        msgTarget: 'side',
638
                        labelCls: 'label-minova',
639
                        labelWidth: lw,
640
                        hidden: Hidden_,
641
                        name: rec.FieldName,
642
						format: 'd/m/Y',
643
                        submitFormat: 'Ymd',
644
                        value: defaultValue,
645
                        IsPrimaryKey: rec.IsPrimaryKey,
646
                        anchor: '100%',
647
                        formname: formname,
648
                        nameTable: tbl,
649
                        hideMode: 'visibility',
650
                        listeners: {
651

    
652
                            change: function (val) {
653
                                var _label = val.name;
654
                                var _form = val.formname;
655
                                var _Value = val.getValue();
656
                                var target = rec.TriggerCombo;
657
                                var custumFunc = rec.SelectFunction;
658
                                if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
659
                                    Ext.Ajax.request({
660
                                        async: false,
661
                                        method: 'POST',
662
                                        url: '/UserControl/GetStore',
663
                                        params: {
664
                                            tableName: 'PCMFUNC',
665
                                            param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
666
                                        },
667
                                        success: function (response) {
668
                                            var results = Ext.decode(response.responseText);
669
                                            data_ = results.data[0];
670
                                            if (data_ != undefined) {
671
                                                custumFunc = data_.FunctionCode;
672
                                            }
673
                                        }
674
                                    });
675
                                }
676
                                var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
677
                                if (frm) {
678

    
679
                                    if (target) {
680
                                        var f = frm.getForm().findField(target)
681
                                        _store = f.getStore();
682
                                        var _tbl = _store.proxy.extraParams.tableName;
683
                                        var oldParam = _store.proxy.extraParams.param;
684
                                        _store.proxy.extraParams = {
685
                                            tableName: _tbl,
686
                                            param: _label + '[=]' + _Value
687
                                        };
688
                                        _store.load();
689
                                    }
690

    
691
                                    if (custumFunc) {
692
                                        eval(custumFunc)
693
                                    }
694

    
695
                                }
696

    
697
                            },
698

    
699
                        },
700
                    });
701
                }
702

    
703
                break
704
            case "time":
705
                if (defaultValue == '') {
706
                    defaultValue = '00:00';
707
                }
708
                formfield = new Ext.form.TimeField({
709
                    allowBlank: null_,
710
                    fieldLabel: rec.ScreenCaption,
711
                    readOnlyCls: 'minova-readonly',
712
                    readOnly: ReadOnly_,
713
                    labelCls: 'label-minova',
714
                    labelWidth: lw,
715
                    hidden: Hidden_,
716
                    name: rec.FieldName,
717
                    msgTarget: 'side',
718
                    format: 'H:i',
719
                    submitFormat: 'Hi',
720
                    increment: 5,
721
                    value: defaultValue,
722
                    IsPrimaryKey: rec.IsPrimaryKey,
723
                    anchor: '100%',
724
                    formname: formname,
725
                    nameTable: tbl,
726
                    //vtype: 'validateMinovaTime',
727
                    maxLength: 5,
728
                    minLength: 5,
729
                    listeners: {
730

    
731
                        change: function (val) {
732
                            var rv = this.rawValue;
733
                            var me_ = this;
734
                            if (rv.length == 4 && rv != '') {
735
                                var sp = rv.split(':')
736
                                if (sp.length == 1) {
737
                                    me_.setValue(rv.substring(0, 2) + ':' + rv.substring(2, 4));
738
                                }
739
                            }
740
                            var _label = val.name;
741
                            var _form = val.formname;
742
                            var _Value = val.getValue();
743
                            var target = rec.TriggerCombo;
744
                            var custumFunc = rec.SelectFunction;
745
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
746
                                Ext.Ajax.request({
747
                                    async: false,
748
                                    method: 'POST',
749
                                    url: '/UserControl/GetStore',
750
                                    params: {
751
                                        tableName: 'PCMFUNC',
752
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
753
                                    },
754
                                    success: function (response) {
755
                                        var results = Ext.decode(response.responseText);
756
                                        data_ = results.data[0];
757
                                        if (data_ != undefined) {
758
                                            custumFunc = data_.FunctionCode;
759
                                        }
760
                                    }
761
                                });
762
                            }
763
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
764
                            if (frm) {
765

    
766
                                if (target) {
767
                                    var f = frm.getForm().findField(target)
768
                                    _store = f.getStore();
769
                                    var _tbl = _store.proxy.extraParams.tableName;
770
                                    var oldParam = _store.proxy.extraParams.param;
771
                                    _store.proxy.extraParams = {
772
                                        tableName: _tbl,
773
                                        param: _label + '[=]' + _Value
774
                                    };
775
                                    _store.load();
776
                                }
777

    
778
                                if (custumFunc) {
779
                                    eval(custumFunc)
780
                                }
781

    
782
                            }
783

    
784
                        },
785

    
786
                    },
787
                });
788
                break
789
            case "password":
790
                min_ = 1;
791
                max_ = 8;
792
                Ext.Ajax.request({
793
                    async: false,
794
                    method: 'POST',
795
                    url: '/UserControl/GetStore',
796
                    params: {
797
                        tableName: 'PCMEPAPPCONFIG',
798
                        param: 'Active[equal]1'
799
                    },
800
                    success: function (response) {
801
                        var results = Ext.decode(response.responseText);
802
                        data_ = results.data;
803
                        if (data_ != undefined) {
804
                            _min = $.grep(data_, function (r) {
805
                                return r.ConfigName == 'SYSPWDMINLENGTH'
806
                            });
807
                            max_ = _min[0].Value;
808
                            _max = $.grep(data_, function (r) {
809
                                return r.ConfigName == 'SYSPWDMAXLENGTH'
810
                            });
811
                            max_ = _max[0].Value;
812

    
813
                        }
814
                    }
815
                });
816
                formfield = new Ext.form.TextField({
817
                    allowBlank: null_,
818
                    inputType: 'password',
819
                    fieldLabel: rec.ScreenCaption,
820
                    readOnlyCls: 'minova-readonly',
821
                    readOnly: ReadOnly_,
822
                    labelCls: 'label-minova',
823
                    labelWidth: lw,
824
                    hidden: Hidden_,
825
                    name: rec.FieldName,
826
                    msgTarget: 'side',
827
                    value: defaultValue,
828
                    IsPrimaryKey: rec.IsPrimaryKey,
829
                    anchor: '100%',
830
                    formname: formname,
831
                    vtype: 'minovaPassword',
832
                    //vtype: 'passwordConfirm',
833
                    initialPassField: 'RePasword',
834
                    maxLength: max_,
835
                    minLength: min_,
836
                    nameTable: tbl,
837
                    listeners: {
838

    
839
                        change: function (val) {
840
                            var _label = val.name;
841
                            var _form = val.formname;
842
                            var _Value = val.getValue();
843
                            var target = rec.TriggerCombo;
844
                            var custumFunc = rec.SelectFunction;
845
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
846
                                Ext.Ajax.request({
847
                                    async: false,
848
                                    method: 'POST',
849
                                    url: '/UserControl/GetStore',
850
                                    params: {
851
                                        tableName: 'PCMFUNC',
852
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
853
                                    },
854
                                    success: function (response) {
855
                                        var results = Ext.decode(response.responseText);
856
                                        data_ = results.data[0];
857
                                        if (data_ != undefined) {
858
                                            custumFunc = data_.FunctionCode;
859
                                        }
860
                                    }
861
                                });
862
                            }
863
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
864
                            if (frm) {
865

    
866
                                if (target) {
867
                                    var f = frm.getForm().findField(target)
868
                                    _store = f.getStore();
869
                                    var _tbl = _store.proxy.extraParams.tableName;
870
                                    var oldParam = _store.proxy.extraParams.param;
871
                                    _store.proxy.extraParams = {
872
                                        tableName: _tbl,
873
                                        param: _label + '[=]' + _Value
874
                                    };
875
                                    _store.load();
876
                                }
877

    
878
                                if (custumFunc) {
879
                                    eval(custumFunc)
880
                                }
881

    
882
                            }
883

    
884
                        },
885

    
886
                    },
887
                });
888
                break
889
            case "repassword":
890

    
891
                formfield = new Ext.form.TextField({
892
                    allowBlank: null_,
893
                    inputType: 'password',
894
                    readOnlyCls: 'minova-readonly',
895
                    fieldLabel: rec.ScreenCaption,
896
                    readOnly: ReadOnly_,
897
                    labelCls: 'label-minova',
898
                    labelWidth: lw,
899
                    hidden: Hidden_,
900
                    name: rec.FieldName,
901
                    msgTarget: 'side',
902
                    value: defaultValue,
903
                    IsPrimaryKey: rec.IsPrimaryKey,
904
                    anchor: '100%',
905
                    formname: formname,
906
                    vtype: 'passwordConfirm',
907
                    initialPassField: 'Password',
908
                    nameTable: tbl,
909
                    listeners: {
910

    
911
                        change: function (val) {
912
                            var _label = val.name;
913
                            var _form = val.formname;
914
                            var _Value = val.getValue();
915
                            var target = rec.TriggerCombo;
916
                            var custumFunc = rec.SelectFunction;
917
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
918
                                Ext.Ajax.request({
919
                                    async: false,
920
                                    method: 'POST',
921
                                    url: '/UserControl/GetStore',
922
                                    params: {
923
                                        tableName: 'PCMFUNC',
924
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
925
                                    },
926
                                    success: function (response) {
927
                                        var results = Ext.decode(response.responseText);
928
                                        data_ = results.data[0];
929
                                        if (data_ != undefined) {
930
                                            custumFunc = data_.FunctionCode;
931
                                        }
932
                                    }
933
                                });
934
                            }
935
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
936
                            if (frm) {
937

    
938
                                if (target) {
939
                                    var f = frm.getForm().findField(target)
940
                                    _store = f.getStore();
941
                                    var _tbl = _store.proxy.extraParams.tableName;
942
                                    var oldParam = _store.proxy.extraParams.param;
943
                                    _store.proxy.extraParams = {
944
                                        tableName: _tbl,
945
                                        param: _label + '[=]' + _Value
946
                                    };
947
                                    _store.load();
948
                                }
949

    
950
                                if (custumFunc) {
951
                                    eval(custumFunc)
952
                                }
953

    
954
                            }
955

    
956
                        },
957

    
958
                    },
959
                });
960
                break
961
            case "number":
962

    
963
                formfield = new Ext.form.TextField({
964
                    allowBlank: null_,
965
                    readOnlyCls: 'minova-readonly',
966
                    fieldLabel: rec.ScreenCaption,
967
                    readOnly: ReadOnly_,
968
                    labelCls: 'label-minova',
969
                    labelWidth: lw,
970
                    hidden: Hidden_,
971
                    name: rec.FieldName,
972
                    msgTarget: 'side',
973
                    value: defaultValue,
974
                    IsPrimaryKey: rec.IsPrimaryKey,
975
                    anchor: '100%',
976
                    formname: formname,
977
                    fieldStyle: 'text-align:right;',
978
                    vtype: 'validateMinovaNumber',
979
                    nameTable: tbl,
980
                    listeners: {
981

    
982
                        change: function (val) {
983
                            var _label = val.name;
984
                            var _form = val.formname;
985
                            var _Value = val.getValue();
986
                            var target = rec.TriggerCombo;
987
                            var custumFunc = rec.SelectFunction;
988
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
989
                                Ext.Ajax.request({
990
                                    async: false,
991
                                    method: 'POST',
992
                                    url: '/UserControl/GetStore',
993
                                    params: {
994
                                        tableName: 'PCMFUNC',
995
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
996
                                    },
997
                                    success: function (response) {
998
                                        var results = Ext.decode(response.responseText);
999
                                        data_ = results.data[0];
1000
                                        if (data_ != undefined) {
1001
                                            custumFunc = data_.FunctionCode;
1002
                                        }
1003
                                    }
1004
                                });
1005
                            }
1006
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1007
                            if (frm) {
1008

    
1009
                                if (target) {
1010
                                    var f = frm.getForm().findField(target)
1011
                                    _store = f.getStore();
1012
                                    var _tbl = _store.proxy.extraParams.tableName;
1013
                                    var oldParam = _store.proxy.extraParams.param;
1014
                                    _store.proxy.extraParams = {
1015
                                        tableName: _tbl,
1016
                                        param: _label + '[=]' + _Value
1017
                                    };
1018
                                    _store.load();
1019
                                }
1020

    
1021
                                if (custumFunc) {
1022
                                    eval(custumFunc)
1023
                                }
1024

    
1025
                            }
1026

    
1027
                        },
1028

    
1029
                    },
1030
                });
1031
                break
1032
            case "alfa":
1033

    
1034
                formfield = new Ext.form.TextField({
1035
                    allowBlank: null_,
1036
                    readOnlyCls: 'minova-readonly',
1037
                    fieldLabel: rec.ScreenCaption,
1038
                    readOnly: ReadOnly_,
1039
                    labelCls: 'label-minova',
1040
                    labelWidth: lw,
1041
                    hidden: Hidden_,
1042
                    name: rec.FieldName,
1043
                    msgTarget: 'side',
1044
                    value: defaultValue,
1045
                    IsPrimaryKey: rec.IsPrimaryKey,
1046
                    anchor: '100%',
1047
                    formname: formname,
1048
                    vtype: 'alfa',
1049
                    nameTable: tbl,
1050
                    listeners: {
1051

    
1052
                        change: function (val) {
1053
                            var _label = val.name;
1054
                            var _form = val.formname;
1055
                            var _Value = val.getValue();
1056
                            var target = rec.TriggerCombo;
1057
                            var custumFunc = rec.SelectFunction;
1058
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1059
                                Ext.Ajax.request({
1060
                                    async: false,
1061
                                    method: 'POST',
1062
                                    url: '/UserControl/GetStore',
1063
                                    params: {
1064
                                        tableName: 'PCMFUNC',
1065
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
1066
                                    },
1067
                                    success: function (response) {
1068
                                        var results = Ext.decode(response.responseText);
1069
                                        data_ = results.data[0];
1070
                                        if (data_ != undefined) {
1071
                                            custumFunc = data_.FunctionCode;
1072
                                        }
1073
                                    }
1074
                                });
1075
                            }
1076
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1077
                            if (frm) {
1078

    
1079
                                if (target) {
1080
                                    var f = frm.getForm().findField(target)
1081
                                    _store = f.getStore();
1082
                                    var _tbl = _store.proxy.extraParams.tableName;
1083
                                    var oldParam = _store.proxy.extraParams.param;
1084
                                    _store.proxy.extraParams = {
1085
                                        tableName: _tbl,
1086
                                        param: _label + '[=]' + _Value
1087
                                    };
1088
                                    _store.load();
1089
                                }
1090

    
1091
                                if (custumFunc) {
1092
                                    eval(custumFunc)
1093
                                }
1094

    
1095
                            }
1096

    
1097
                        },
1098

    
1099
                    },
1100
                });
1101
                break
1102
            case "amount":
1103
                formfield = new Ext.form.TextField({
1104
                    allowBlank: null_,
1105
                    fieldLabel: rec.ScreenCaption,
1106
                    readOnly: ReadOnly_,
1107
                    readOnlyCls: 'minova-readonly',
1108
                    labelCls: 'label-minova',
1109
                    labelWidth: lw,
1110
                    hidden: Hidden_,
1111
                    name: rec.FieldName,
1112
                    fieldStyle: 'text-align:right;',
1113
                    msgTarget: 'side',
1114
                    IsPrimaryKey: rec.IsPrimaryKey,
1115
                    value: defaultValue,
1116
                    maxLength: rec.Length,
1117
                    anchor: '100%',
1118
                    formname: formname,
1119
                    nameTable: tbl,
1120
                    listeners: {
1121

    
1122
                        change: function (val) {
1123
                            var _label = val.name;
1124
                            var _form = val.formname;
1125
                            var _Value = val.getValue();
1126
                            var target = rec.TriggerCombo;
1127
                            var custumFunc = rec.SelectFunction;
1128
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1129
                                Ext.Ajax.request({
1130
                                    async: false,
1131
                                    method: 'POST',
1132
                                    url: '/UserControl/GetStore',
1133
                                    params: {
1134
                                        tableName: 'PCMFUNC',
1135
                                        param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1136
                                    },
1137
                                    success: function (response) {
1138
                                        var results = Ext.decode(response.responseText);
1139
                                        data_ = results.data[0];
1140
                                        if (data_ != undefined) {
1141
                                            custumFunc = data_.FunctionCode;
1142
                                        }
1143
                                    }
1144
                                });
1145
                            }
1146
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1147
                            if (frm) {
1148

    
1149
                                if (target) {
1150
                                    var f = frm.getForm().findField(target)
1151
                                    _store = f.getStore();
1152
                                    var _tbl = _store.proxy.extraParams.tableName;
1153
                                    var oldParam = _store.proxy.extraParams.param;
1154
                                    _store.proxy.extraParams = {
1155
                                        tableName: _tbl,
1156
                                        param: _label + '[=]' + _Value
1157
                                    };
1158
                                    _store.load();
1159
                                }
1160

    
1161
                                if (custumFunc) {
1162
                                    eval(custumFunc)
1163
                                }
1164

    
1165
                            }
1166

    
1167
                        },
1168

    
1169
                    },
1170
                });
1171
                break
1172
            case "amountencrypt":
1173
                formfield = new Ext.form.TextField({
1174
                    allowBlank: null_,
1175
                    fieldLabel: rec.ScreenCaption,
1176
                    readOnlyCls: 'minova-readonly',
1177
                    readOnly: ReadOnly_,
1178
                    labelCls: 'label-minova',
1179
                    labelWidth: lw,
1180
                    hidden: Hidden_,
1181
                    name: rec.FieldName,
1182
                    msgTarget: 'side',
1183
                    IsPrimaryKey: rec.IsPrimaryKey,
1184
                    value: defaultValue,
1185
                    maxLength: rec.Length,
1186
                    anchor: '100%',
1187
                    isEncrypt: true,
1188
                    formname: formname,
1189
                    nameTable: tbl,
1190
                    vtype: 'validateMinovaXss',
1191
                    fieldStyle: 'text-align:right;',
1192
                    listeners: {
1193

    
1194
                        change: function (val) {
1195
                            var _label = val.name;
1196
                            var _form = val.formname;
1197
                            var _Value = val.getValue();
1198
                            var target = rec.TriggerCombo;
1199
                            var custumFunc = rec.SelectFunction;
1200
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1201
                                Ext.Ajax.request({
1202
                                    async: false,
1203
                                    method: 'POST',
1204
                                    url: '/UserControl/GetStore',
1205
                                    params: {
1206
                                        tableName: 'PCMFUNC',
1207
                                        param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1208
                                    },
1209
                                    success: function (response) {
1210
                                        var results = Ext.decode(response.responseText);
1211
                                        data_ = results.data[0];
1212
                                        if (data_ != undefined) {
1213
                                            custumFunc = data_.FunctionCode;
1214
                                        }
1215
                                    }
1216
                                });
1217
                            }
1218
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1219
                            if (frm) {
1220

    
1221
                                if (target) {
1222
                                    var f = frm.getForm().findField(target)
1223
                                    _store = f.getStore();
1224
                                    var _tbl = _store.proxy.extraParams.tableName;
1225
                                    var oldParam = _store.proxy.extraParams.param;
1226
                                    _store.proxy.extraParams = {
1227
                                        tableName: _tbl,
1228
                                        param: _label + '[=]' + _Value
1229
                                    };
1230
                                    _store.load();
1231
                                }
1232

    
1233
                                if (custumFunc) {
1234
                                    eval(custumFunc)
1235
                                }
1236

    
1237
                            }
1238

    
1239
                        },
1240

    
1241
                    },
1242

    
1243
                });
1244
                break
1245
            case "monthpicker":
1246
                formfield = new MinovaUtil.MinovaES.MinovaMonthPicker({
1247
                    tableName: undefined,
1248
                    allowBlank: null_,
1249
                    fieldLabel: rec.ScreenCaption,
1250
                    readOnly: ReadOnly_,
1251
                    readOnlyCls: 'minova-readonly',
1252
                    hidden: Hidden_,
1253
                    msgTarget: 'side',
1254
                    param: undefined,
1255
                    name: rec.FieldName,
1256
                    formtarget_: rec.FieldName,
1257
                    fieldname: rec.FieldName,
1258
                    IsPrimaryKey: rec.IsPrimaryKey,
1259
                    Sequence: rec.Sequence,
1260
                    labelCls: 'label-minova',
1261
                    vtype: 'validateMinovaXss',
1262
                    nameTable: tbl,
1263
                    listeners: {
1264

    
1265
                        change: function (val) {
1266
                            var _label = val.name;
1267
                            var _form = val.formname;
1268
                            var _Value = val.getValue();
1269
                            var target = rec.TriggerCombo;
1270
                            var custumFunc = rec.SelectFunction;
1271
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1272
                                Ext.Ajax.request({
1273
                                    async: false,
1274
                                    method: 'POST',
1275
                                    url: '/UserControl/GetStore',
1276
                                    params: {
1277
                                        tableName: 'PCMFUNC',
1278
                                        param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1279
                                    },
1280
                                    success: function (response) {
1281
                                        var results = Ext.decode(response.responseText);
1282
                                        data_ = results.data[0];
1283
                                        if (data_ != undefined) {
1284
                                            custumFunc = data_.FunctionCode;
1285
                                        }
1286
                                    }
1287
                                });
1288
                            }
1289
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1290
                            if (frm) {
1291

    
1292
                                if (target) {
1293
                                    var f = frm.getForm().findField(target)
1294
                                    _store = f.getStore();
1295
                                    var _tbl = _store.proxy.extraParams.tableName;
1296
                                    var oldParam = _store.proxy.extraParams.param;
1297
                                    _store.proxy.extraParams = {
1298
                                        tableName: _tbl,
1299
                                        param: _label + '[=]' + _Value
1300
                                    };
1301
                                    _store.load();
1302
                                }
1303

    
1304
                                if (custumFunc) {
1305
                                    eval(custumFunc)
1306
                                }
1307

    
1308
                            }
1309

    
1310
                        },
1311

    
1312
                    },
1313
                })
1314
                break
1315
            case "file":
1316
                //update by hamid 12012017
1317
                formfield = new MinovaUtil.MinovaES.UploadFile({
1318
                    allowBlank: null_,
1319
                    fieldLabel: rec.ScreenCaption,
1320
                    readOnly: ReadOnly_,
1321
                    readOnlyCls: 'minova-readonly',
1322
                    hidden: Hidden_,
1323
                    labelCls: 'label-minova',
1324
                    name: rec.FieldName,
1325
                    msgTarget: 'side',
1326
                    fieldname: rec.FieldName,
1327
                    IsPrimaryKey: rec.IsPrimaryKey,
1328
                    tableName: rec.TableRef, //name tabel yang jadi ref-nya
1329
                    triggerCls: 'x-form-search-trigger',
1330
                    //vtype : 'alphanum', // disable space
1331
                    formtarget: formname, // nama form  yang akan di set value-nya
1332
                    //isLookup: isLookup,
1333
                    anchor: '100%',
1334
                    formname: formname,
1335
                    vtype: 'validateMinovaXss',
1336
                    nameTable: tbl,
1337
                    maxFileSize:rec.SearchFunction,
1338
                    listeners: {
1339

    
1340
                        change: function (val) {
1341
                            var _label = val.name;
1342
                            var _form = val.formname;
1343
                            var _Value = val.getValue();
1344
                            var target = rec.TriggerCombo;
1345
                            var custumFunc = rec.SelectFunction;
1346
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1347
                                Ext.Ajax.request({
1348
                                    async: false,
1349
                                    method: 'POST',
1350
                                    url: '/UserControl/GetStore',
1351
                                    params: {
1352
                                        tableName: 'PCMFUNC',
1353
                                        param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1354
                                    },
1355
                                    success: function (response) {
1356
                                        var results = Ext.decode(response.responseText);
1357
                                        data_ = results.data[0];
1358
                                        if (data_ != undefined) {
1359
                                            custumFunc = data_.FunctionCode;
1360
                                        }
1361
                                    }
1362
                                });
1363
                            }
1364
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1365
                            if (frm) {
1366

    
1367
                                if (target) {
1368
                                    var f = frm.getForm().findField(target)
1369
                                    _store = f.getStore();
1370
                                    var _tbl = _store.proxy.extraParams.tableName;
1371
                                    var oldParam = _store.proxy.extraParams.param;
1372
                                    _store.proxy.extraParams = {
1373
                                        tableName: _tbl,
1374
                                        param: _label + '[=]' + _Value
1375
                                    };
1376
                                    _store.load();
1377
                                }
1378

    
1379
                                if (custumFunc) {
1380
                                    eval(custumFunc)
1381
                                }
1382

    
1383
                            }
1384

    
1385
                        },
1386

    
1387
                    },
1388

    
1389
                });
1390
                break
1391
            case "html": {
1392
                formfield = new Ext.form.TextArea({
1393
                    allowBlank: null_,
1394
                    fieldLabel: rec.ScreenCaption,
1395
                    readOnly: ReadOnly_,
1396
                    readOnlyCls: 'minova-readonly',
1397
                    labelCls: 'label-minova',
1398
                    labelWidth: lw,
1399
                    hidden: Hidden_,
1400
                    name: rec.FieldName,
1401
                    msgTarget: 'side',
1402
                    value: defaultValue,
1403
                    IsPrimaryKey: rec.IsPrimaryKey,
1404
                    maxLength: rec.Length,
1405
                    anchor: '100%',
1406
                    formname: formname,
1407
                    //vtype: 'validateMinovaXss',
1408
                    nameTable: tbl,
1409
                    listeners: {
1410

    
1411
                        change: function (val) {
1412
                            var _label = val.name;
1413
                            var _form = val.formname;
1414
                            var _Value = val.getValue();
1415
                            var target = rec.TriggerCombo;
1416
                            var custumFunc = rec.SelectFunction;
1417
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1418
                                Ext.Ajax.request({
1419
                                    async: false,
1420
                                    method: 'POST',
1421
                                    url: '/UserControl/GetStore',
1422
                                    params: {
1423
                                        tableName: 'PCMFUNC',
1424
                                        param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1425
                                    },
1426
                                    success: function (response) {
1427
                                        var results = Ext.decode(response.responseText);
1428
                                        data_ = results.data[0];
1429
                                        if (data_ != undefined) {
1430
                                            custumFunc = data_.FunctionCode;
1431
                                        }
1432
                                    }
1433
                                });
1434
                            }
1435
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1436
                            if (frm) {
1437

    
1438
                                if (target) {
1439
                                    var f = frm.getForm().findField(target)
1440
                                    _store = f.getStore();
1441
                                    var _tbl = _store.proxy.extraParams.tableName;
1442
                                    var oldParam = _store.proxy.extraParams.param;
1443
                                    _store.proxy.extraParams = {
1444
                                        tableName: _tbl,
1445
                                        param: _label + '[=]' + _Value
1446
                                    };
1447
                                    _store.load();
1448
                                }
1449

    
1450
                                if (custumFunc) {
1451
                                    eval(custumFunc)
1452
                                }
1453

    
1454
                            }
1455

    
1456
                        },
1457

    
1458
                    },
1459
                });
1460
            }
1461
            default:
1462

    
1463
                if (rec.SearchType != '') {
1464
                    if (rec.SearchType == '3') { // lookup tree grid
1465
                        var objClass = rec.ParamCombo;
1466
                        var splitClass = objClass.split("]");
1467
                        var objParent = '';
1468
                        var objClassValueTarget = '';
1469
                        if (splitClass.length == 1) {
1470
                            objClassValueTarget = splitClass[0];
1471
                        } else {
1472
                            if (splitClass.length > 1) {
1473
                                objClassValueTarget = splitClass[1];
1474
                            }
1475
                        }
1476
                        var rel = rec.SearchFunction;
1477
                        var relSplit = rel.split('-');
1478
                        objParent = relSplit[0];
1479
                        var valFilter = relSplit.filter(MinovaUtil.RemoveDuplicateArray);
1480
                        formfield = new MinovaUtil.MinovaES.MinovaLookupTree({
1481
                            allowBlank: null_,
1482
                            fieldLabel: rec.ScreenCaption,
1483
                            readOnly: ReadOnly_,
1484
                            readOnlyCls: 'minova-readonly',
1485
                            IsPrimaryKey: rec.IsPrimaryKey,
1486
                            labelCls: 'label-minova',
1487
                            labelWidth: lw,
1488
                            hidden: Hidden_,
1489
                            name: rec.FieldName,
1490
                            msgTarget: 'side',
1491
                            triggerCls: 'x-form-search-trigger',
1492
                            //vtype: 'alphanum', // disable space
1493
                            treeSructure: rec.SearchFunction, //'O-O-P',
1494
                            objClassValue: objClassValueTarget, //'O',
1495
                            objParent: objParent,
1496
                            objFilter: valFilter,
1497
                            formname: formname,
1498
                            targetField: rec.FieldName,
1499
                            anchor: '100%',
1500
                            formname: formname,
1501
                            nameTable: tbl,
1502
                            //vtype: 'validateLookupTree',
1503
                            editable: false,
1504
                            listeners: {
1505
                                change: function (val) {
1506
                                    // alert('a')
1507
									var me=val;
1508
									var valueFiled=val.getValue();
1509
									if(valueFiled.split('-').length == 1 && valueFiled != '' && valueFiled !='a' ){
1510
										 Mainform = Ext.ComponentQuery.query('[name=' + me.formname + ']')[0].getForm();
1511
										 var _StartDate = MinovaUtil.GetNowDate();
1512
										if (Mainform) {
1513
											if (Mainform.findField('StartDate')) {
1514
												_StartDate = Mainform.findField('StartDate').getValue();
1515
											}
1516
										}
1517
										Ext.Ajax.request({
1518
											async : false,
1519
											method : 'POST',
1520
											url : '/UserControl/GetStore',
1521
											params : {
1522
												tableName : 'PHROM0001',
1523
												param : 'ObjectClass[=]'+me.objClassValue+',ObjectID[=]'+valueFiled+',StartDate[<=]'+_StartDate+',EndDate[>=]'+_StartDate
1524
											},
1525
											success : function (response) {
1526
												var results = Ext.decode(response.responseText);
1527
												data_ = results.data
1528
													if (data_.length > 0) {
1529
														me.setValue(valueFiled + ' - ' + data_[0].ObjectDescription)
1530

    
1531
													}
1532
											}
1533
										});
1534
									}
1535
                                },
1536
                                focus: function (val) {
1537
                                    // alert('focus')
1538
                                },
1539
                                blur: function (val) {
1540
                                    //             alert('focus')
1541
                                    var _label = val.name;
1542
                                    var _form = val.formname;
1543
                                    var _Value = val.getValue();
1544
                                    var target = rec.TriggerCombo;
1545
                                    var custumFunc = rec.SelectFunction;
1546
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1547
                                        Ext.Ajax.request({
1548
                                            async: false,
1549
                                            method: 'POST',
1550
                                            url: '/UserControl/GetStore',
1551
                                            params: {
1552
                                                tableName: 'PCMFUNC',
1553
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1554
                                            },
1555
                                            success: function (response) {
1556
                                                var results = Ext.decode(response.responseText);
1557
                                                data_ = results.data[0];
1558
                                                if (data_ != undefined) {
1559
                                                    custumFunc = data_.FunctionCode;
1560
                                                }
1561
                                            }
1562
                                        });
1563
                                    } else {
1564
                                        eval(custumFunc);
1565
                                    }
1566
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1567
                                    if (frm) {
1568
										
1569
                                        if (target) {
1570
											//saswanto 18Mei2022 start
1571
											if (target =='Profiency'){
1572
												// edit by Tri 20220630 start
1573
												if( tbl == 'PHROM0008') 
1574
												{
1575
													_store = frm.getForm().findField('Proficiency').getStore();
1576
													_store.proxy.extraParams = {
1577
														tableName: 'PHROM0027',
1578
														param: 'EndDate[=]99991231,ObjectID[=]' + val.valData
1579
													};
1580
												}
1581
												else
1582
												{
1583
													_store = frm.getForm().findField('Proficiency').getStore();
1584
													_store.proxy.extraParams = {
1585
														tableName: 'PHROM0027',
1586
														param: 'EndDate[=]99991231,ObjectID[=]' + Ext.ComponentQuery.query('[name=QualificationID]')[0].valData
1587
													};
1588
												}
1589
												// edit by Tri 20220630 end
1590
												//_store = frm.getForm().findField('Proficiency').getStore();
1591
												//_store.proxy.extraParams = {
1592
												//	tableName: 'PHROM0027',
1593
												//	param: 'EndDate[=]99991231,ObjectID[=]' + Ext.ComponentQuery.query('[name=QualificationID]')[0].valData
1594
												//};
1595
												_store.load();												
1596
											}else{
1597
												var f = frm.getForm().findField(target)
1598
												_store = f.getStore();
1599
												var _tbl = _store.proxy.extraParams.tableName;
1600
												var oldParam = _store.proxy.extraParams.param;
1601
												_store.proxy.extraParams = {
1602
													tableName: _tbl,
1603
													param: _label + '[=]' + _Value
1604
												};
1605
												_store.load();
1606
											}
1607
											//saswanto 18Mei2022 end
1608
                                        }
1609

    
1610
                                        if (custumFunc) {
1611
                                            eval(custumFunc)
1612
                                        }
1613

    
1614
                                    }
1615

    
1616
                                },
1617

    
1618
                            },
1619

    
1620
                        });
1621
                    }
1622
                    if (rec.TableRef != "") {
1623
                        if (rec.SearchType == '0') {
1624
                            valueField = null;
1625
                            displayValue = null;
1626
                            Ext.Ajax.request({
1627
                                async: false,
1628
                                method: 'POST',
1629
                                url: '/UserControl/GetStore',
1630
                                params: {
1631
                                    tableName: 'SDATATABLEFIELD',
1632
                                    param: 'TableName[equal]' + rec.TableRef
1633
                                },
1634
                                success: function (response) {
1635
                                    var results = Ext.decode(response.responseText);
1636
                                    data_ = results.data;
1637
                                    if (data_ != undefined) {
1638
                                        valueField_ = $.grep(data_, function (r) {
1639
                                            return r.ValueField == '1'
1640
                                        });
1641
                                        if (valueField_.length > 0) {
1642
                                            valueField = valueField_[0].FieldName
1643
                                        }
1644

    
1645
                                        displayValue_ = $.grep(data_, function (r) {
1646
                                            return r.DisplayValue == '1'
1647
                                        });
1648
                                        if (displayValue_.length > 0) {
1649
                                            displayValue = displayValue_[0].FieldName
1650
                                        }
1651

    
1652
                                    }
1653
                                }
1654
                            });				
1655
							console.log(rec.TableRef); //console.log(Mainform.findField('QualificationID').getValue();) //// add by Tri nwh 20220513 untuk talent
1656
                            formfield = new Ext.form.ComboBox({
1657
                                allowBlank: null_,
1658
                                fieldLabel: rec.ScreenCaption,
1659
                                readOnlyCls: 'minova-readonly',
1660
                                //forceSelection : true,
1661
                                readOnly: ReadOnly_,
1662
                                labelCls: 'label-minova',
1663
                                labelWidth: lw,
1664
                                hidden: Hidden_,
1665
                                IsPrimaryKey: rec.IsPrimaryKey,
1666
                                msgTarget: 'side',
1667
                                name: rec.FieldName,
1668
                                value: defaultValue,
1669
                                formname: formname,
1670
                                validateOnChange: true,
1671
                                width: '95%',
1672
                                vtype: 'validateCombobox',
1673
                                store: Ext.create('Ext.data.Store', {
1674
                                    storeId: 'store' + rec.FieldName,
1675
                                    autoLoad: true,
1676
                                    proxy: {
1677
                                        async: false,
1678
                                        method: 'POST',
1679
                                        type: 'ajax',
1680
                                        url: '/UserControl/GetStoreAuth',
1681
                                        extraParams: {
1682
                                            tableName: rec.TableRef,
1683
                                            param: rec.ParamCombo,
1684
                                            menuId: MinovaUtil.GetMenuID()
1685
                                        },
1686
                                        reader: {
1687
                                            type: 'json',
1688
                                            root: 'data',
1689
                                            totalProperty: 'data[0].TotalCount'
1690
                                        }
1691
                                    }
1692
                                }),
1693
                                formtarget: formname,
1694
                                nameTable: tbl,
1695
                                listeners: {
1696
                                    afterrender: function (f) {
1697
                                        //var store_ = f.getStore();
1698
                                        //store_.load();
1699
                                    },
1700
                                    change: function (val) {
1701
                                        var _label = val.name;
1702
                                        var _form = val.formname;
1703
                                        var _Value = val.getValue();
1704
                                        var target = rec.TriggerCombo;
1705
                                        var custumFunc = rec.SelectFunction;
1706
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1707
                                            Ext.Ajax.request({
1708
                                                async: false,
1709
                                                method: 'POST',
1710
                                                url: '/UserControl/GetStore',
1711
                                                params: {
1712
                                                    tableName: 'PCMFUNC',
1713
                                                    param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
1714
                                                },
1715
                                                success: function (response) {
1716
                                                    var results = Ext.decode(response.responseText);
1717
                                                    data_ = results.data[0];
1718
                                                    if (data_ != undefined) {
1719
                                                        custumFunc = data_.FunctionCode;
1720
                                                    }
1721
                                                }
1722
                                            });
1723
                                        }
1724
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1725
                                        if (frm) {
1726

    
1727
                                            if (target) {
1728
                                                var f = frm.getForm().findField(target)
1729
                                                _store = f.getStore();
1730
                                                var _tbl = _store.proxy.extraParams.tableName;
1731
                                                var oldParam = _store.proxy.extraParams.param;
1732
                                                _store.proxy.extraParams = {
1733
                                                    tableName: _tbl,
1734
                                                    param: _label + '[=]' + _Value,
1735
                                                    menuId: MinovaUtil.GetMenuID()
1736
                                                };
1737
                                                _store.load();
1738
                                            }
1739

    
1740
                                            if (custumFunc) {
1741
                                                eval(custumFunc)
1742
                                            }
1743

    
1744
                                        }
1745

    
1746
                                    },
1747

    
1748
                                },
1749
                                queryMode: 'local',
1750
                                displayField: displayValue,
1751
                                valueField: valueField,
1752
                            });
1753

    
1754
                        } else if (rec.SearchType == '2') {
1755
                            formfield = new MinovaUtil.MinovaES.MinovaLookupGrid({
1756
                                allowBlank: null_,
1757
                                fieldLabel: rec.ScreenCaption,
1758
                                readOnly: ReadOnly_,
1759
                                readOnlyCls: 'minova-readonly',
1760
                                IsPrimaryKey: rec.IsPrimaryKey,
1761
                                msgTarget: 'side',
1762
                                labelCls: 'label-minova',
1763
                                //labelWidth : 250,
1764
                                hidden: Hidden_,
1765
                                name: rec.FieldName,
1766
                                tableName: rec.TableRef, //name tabel yang jadi ref-nya
1767
                                //triggerCls: 'x-form-search-trigger',
1768
                                //vtype: 'alphanum', // disable space
1769
                                vtype: 'validateMinovaXss',
1770
                                formtarget: formname, // nama form  yang akan di set value-nya
1771
                                anchor: '100%',
1772
                                formname: formname,
1773
                                nameTable: tbl,
1774
                                editable: false,
1775
								value: defaultValue,
1776
                                LookupFunction: rec.LookupFunction,
1777
                                listeners: {
1778

    
1779
                                    change: function (val) {
1780
                                        var _label = val.name;
1781
                                        var _form = val.formname;
1782
                                        var _Value = val.getValue();
1783
                                        var target = rec.TriggerCombo;
1784
                                        var custumFunc = rec.SelectFunction;
1785
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1786
                                            Ext.Ajax.request({
1787
                                                async: false,
1788
                                                method: 'POST',
1789
                                                url: '/UserControl/GetStore',
1790
                                                params: {
1791
                                                    tableName: 'PCMFUNC',
1792
                                                    param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1793
                                                },
1794
                                                success: function (response) {
1795
                                                    var results = Ext.decode(response.responseText);
1796
                                                    data_ = results.data[0];
1797
                                                    if (data_ != undefined) {
1798
                                                        custumFunc = data_.FunctionCode;
1799
                                                    }
1800
                                                }
1801
                                            });
1802
                                        }
1803
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1804
                                        if (frm) {
1805

    
1806
                                            if (target) {
1807
                                                var f = frm.getForm().findField(target)
1808
                                                _store = f.getStore();
1809
                                                var _tbl = _store.proxy.extraParams.tableName;
1810
                                                var oldParam = _store.proxy.extraParams.param;
1811
                                                _store.proxy.extraParams = {
1812
                                                    tableName: _tbl,
1813
                                                    param: _label + '[=]' + _Value
1814
                                                };
1815
                                                _store.load();
1816
                                            }
1817

    
1818
                                            if (custumFunc) {
1819
                                                eval(custumFunc)
1820
                                            }
1821

    
1822
                                        }
1823
                                        //set raw value
1824
                                        val.valData = val.getValue()
1825
                                        if (val.getValue() != "") {
1826
                                            data_ = undefined;
1827
                                            Ext.Ajax.request({
1828
                                                async: false,
1829
                                                method: 'POST',
1830
                                                url: '/UserControl/GetStore',
1831
                                                params: {
1832
                                                    tableName: 'PDSCMTABLE',
1833
                                                    param: val.tableName + ',' + val.getValue() + ',hasil'
1834
                                                },
1835
                                                success: function (response) {
1836
                                                    var results = Ext.decode(response.responseText);
1837
                                                    data_ = results.data;
1838
                                                    if (data_ != null) {
1839
                                                        if (data_.length > 0) {
1840
                                                            val.setRawValue(val.getValue() + ' - ' + data_[0].hasil)
1841

    
1842
                                                        }
1843
                                                    }
1844
                                                }
1845
                                            });
1846
                                        }
1847

    
1848
                                    },
1849

    
1850
                                },
1851
                            });
1852
                        } else if (rec.SearchType == '4' && isLookup != true) {
1853
                            formfield = new MinovaUtil.MinovaES.MinovaLookupEmployee({
1854
                                allowBlank: null_,
1855
                                fieldLabel: rec.ScreenCaption,
1856
                                readOnly: ReadOnly_,
1857
                                readOnlyCls: 'minova-readonly',
1858
                                hidden: Hidden_,
1859
                                labelCls: 'label-minova',
1860
                                name: rec.FieldName,
1861
                                msgTarget: 'side',
1862
                                fieldname: rec.FieldName,
1863
                                IsPrimaryKey: rec.IsPrimaryKey,
1864
                                tableName: rec.TableRef, //name tabel yang jadi ref-nya
1865
                                triggerCls: 'x-form-search-trigger',
1866
                                //vtype: 'alphanum', // disable space
1867
                                vtype: 'validateMinovaXss',
1868
                                formtarget: formname, // nama form  yang akan di set value-nya
1869
                                isLookup: isLookup,
1870
                                anchor: '100%',
1871
                                formname: formname,
1872
                                targetField: targetField_,
1873
                                fieldValue: fieldValue_,
1874
                                nameTable: tbl,
1875
                                value: defaultValue,
1876
                                LookupFunction: rec.LookupFunction,
1877
                                filterParam: rec.ParamCombo,
1878
                                listeners: {
1879

    
1880
                                    change: function (val) {
1881
                                        var _label = val.name;
1882
                                        var _form = val.formname;
1883
                                        var _Value = val.getValue();
1884
                                        var target = rec.TriggerCombo;
1885
                                        var custumFunc = rec.SelectFunction;
1886
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1887
                                            Ext.Ajax.request({
1888
                                                async: false,
1889
                                                method: 'POST',
1890
                                                url: '/UserControl/GetStore',
1891
                                                params: {
1892
                                                    tableName: 'PCMFUNC',
1893
                                                    param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1894
                                                },
1895
                                                success: function (response) {
1896
                                                    var results = Ext.decode(response.responseText);
1897
                                                    data_ = results.data[0];
1898
                                                    if (data_ != undefined) {
1899
                                                        custumFunc = data_.FunctionCode;
1900
                                                    }
1901
                                                }
1902
                                            });
1903
                                        }
1904
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1905
                                        if (frm) {
1906

    
1907
                                            if (target) {
1908
                                                var f = frm.getForm().findField(target)
1909
                                                _store = f.getStore();
1910
                                                var _tbl = _store.proxy.extraParams.tableName;
1911
                                                var oldParam = _store.proxy.extraParams.param;
1912
                                                _store.proxy.extraParams = {
1913
                                                    tableName: _tbl,
1914
                                                    param: _label + '[=]' + _Value
1915
                                                };
1916
                                                _store.load();
1917
                                            }
1918

    
1919
                                            if (custumFunc) {
1920
                                                eval(custumFunc)
1921
                                            }
1922

    
1923
                                        }
1924

    
1925
                                    },
1926

    
1927
                                },
1928
                            });
1929
                            //}
1930
                        }
1931

    
1932
                    }
1933
                } else {
1934

    
1935
                    if (rec.FixedValue != '') {
1936

    
1937
                        formfield = new MinovaUtil.MinovaES.MinovaFixValue({
1938
                            allowBlank: null_,
1939
                            fieldLabel: rec.ScreenCaption,
1940
                            readOnlyCls: 'minova-readonly',
1941
                            //forceSelection: true,
1942
                            readOnly: ReadOnly_,
1943
                            labelCls: 'label-minova',
1944
                            labelWidth: lw,
1945
                            hidden: Hidden_,
1946
                            name: rec.FieldName,
1947
                            msgTarget: 'side',
1948
                            IsPrimaryKey: rec.IsPrimaryKey,
1949
                            value: defaultValue,
1950
                            anchor: '100%',
1951
                            formname: formname,
1952
                            formtarget: formname,
1953
                            validateOnChange: true,
1954
                            fixedValue: rec.FixedValue,
1955
                            vtype: 'validateMinovaXss',
1956
                            nameTable: tbl,
1957
                            listeners: {
1958
                                change: function (val) {
1959
                                    var _label = val.name;
1960
                                    var _form = val.formtarget;
1961
                                    var _Value = val.getValue();
1962
                                    var target = rec.TriggerCombo;
1963
                                    var custumFunc = rec.SelectFunction;
1964

    
1965
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1966
                                    if (frm) {
1967

    
1968
                                        if (target) {
1969
                                            var f = frm.getForm().findField(target)
1970
                                            _store = f.getStore();
1971
                                            var _tbl = _store.proxy.extraParams.tableName;
1972
                                            var oldParam = _store.proxy.extraParams.param;
1973
                                            _store.proxy.extraParams = {
1974
                                                tableName: _tbl,
1975
                                                param: _label + '[=]' + _Value
1976
                                            };
1977
                                            // _store.proxy.extraParams = { tableName: _tbl, param: oldParam+','+_label + '[=]' + _Value };
1978
                                            _store.load();
1979
                                        }
1980

    
1981
                                        if (custumFunc) {
1982
                                            eval(custumFunc)
1983
                                        }
1984

    
1985
                                    }
1986

    
1987
                                }
1988

    
1989
                            },
1990
                            valueField: 'code',
1991
                            displayField: 'desc',
1992
                        });
1993
                    } else if (rec.Length > 250 && rec.TableRef == "") {
1994
                        formfield = new Ext.form.TextArea({
1995
                            allowBlank: null_,
1996
                            fieldLabel: rec.ScreenCaption,
1997
                            readOnly: ReadOnly_,
1998
                            readOnlyCls: 'minova-readonly',
1999
                            labelCls: 'label-minova',
2000
                            labelWidth: lw,
2001
                            hidden: Hidden_,
2002
                            name: rec.FieldName,
2003
                            msgTarget: 'side',
2004
                            value: defaultValue,
2005
                            IsPrimaryKey: rec.IsPrimaryKey,
2006
                            maxLength: rec.Length,
2007
                            anchor: '100%',
2008
                            formname: formname,
2009
                            vtype: 'validateMinovaXss',
2010
                            nameTable: tbl,
2011
                            listeners: {
2012

    
2013
                                change: function (val) {
2014
                                    var _label = val.name;
2015
                                    var _form = val.formname;
2016
                                    var _Value = val.getValue();
2017
                                    var target = rec.TriggerCombo;
2018
                                    var custumFunc = rec.SelectFunction;
2019
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2020
                                        Ext.Ajax.request({
2021
                                            async: false,
2022
                                            method: 'POST',
2023
                                            url: '/UserControl/GetStore',
2024
                                            params: {
2025
                                                tableName: 'PCMFUNC',
2026
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2027
                                            },
2028
                                            success: function (response) {
2029
                                                var results = Ext.decode(response.responseText);
2030
                                                data_ = results.data[0];
2031
                                                if (data_ != undefined) {
2032
                                                    custumFunc = data_.FunctionCode;
2033
                                                }
2034
                                            }
2035
                                        });
2036
                                    }
2037
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2038
                                    if (frm) {
2039

    
2040
                                        if (target) {
2041
                                            var f = frm.getForm().findField(target)
2042
                                            _store = f.getStore();
2043
                                            var _tbl = _store.proxy.extraParams.tableName;
2044
                                            var oldParam = _store.proxy.extraParams.param;
2045
                                            _store.proxy.extraParams = {
2046
                                                tableName: _tbl,
2047
                                                param: _label + '[=]' + _Value
2048
                                            };
2049
                                            _store.load();
2050
                                        }
2051

    
2052
                                        if (custumFunc) {
2053
                                            eval(custumFunc)
2054
                                        }
2055

    
2056
                                    }
2057

    
2058
                                },
2059

    
2060
                            },
2061
                        });
2062
                    } else if (rec.FieldDataType == 3) {
2063
                        //defaultValue = rec.DefaultValue;
2064
                        if (defaultValue == null || defaultValue == "") {
2065
                            defaultValue = 0;
2066
                        }
2067
                        //formfield = new MinovaUtil.MinovaES.MinovaFloatField({
2068
                        formfield = new Ext.form.TextField({
2069
                            //formfield =MinovaUtil.MinovaES.MinovaDecimal({
2070
                            allowBlank: null_,
2071
                            fieldLabel: rec.ScreenCaption,
2072
                            readOnly: ReadOnly_,
2073
                            labelCls: 'label-minova',
2074
                            readOnlyCls: 'minova-readonly',
2075
                            labelWidth: lw,
2076
                            msgTarget: 'side',
2077
                            hidden: Hidden_,
2078
                            name: rec.FieldName,
2079
                            IsPrimaryKey: rec.IsPrimaryKey,
2080
                            value: defaultValue,
2081
                            maxLength: rec.Length,
2082
                            precision: rec.Prec,
2083
                            anchor: '100%',
2084
                            formname: formname,
2085
                            vtype: 'validateDecimal',
2086
                            //maskRe: '^[0-9]+(\.[0-9]{1,2})?$',
2087
                            nameTable: tbl,
2088
                            fieldStyle: 'text-align:right;',
2089
                            listeners: {
2090

    
2091
                                change: function (val) {
2092
                                    var _label = val.name;
2093
                                    var _form = val.formname;
2094
                                    var _Value = val.getValue();
2095

    
2096
                                    var target = rec.TriggerCombo;
2097
                                    var custumFunc = rec.SelectFunction;
2098
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2099
                                        Ext.Ajax.request({
2100
                                            async: false,
2101
                                            method: 'POST',
2102
                                            url: '/UserControl/GetStore',
2103
                                            params: {
2104
                                                tableName: 'PCMFUNC',
2105
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2106
                                            },
2107
                                            success: function (response) {
2108
                                                var results = Ext.decode(response.responseText);
2109
                                                data_ = results.data[0];
2110
                                                if (data_ != undefined) {
2111
                                                    custumFunc = data_.FunctionCode;
2112
                                                }
2113
                                            }
2114
                                        });
2115
                                    }
2116
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2117
                                    if (frm) {
2118

    
2119
                                        if (target) {
2120
                                            var f = frm.getForm().findField(target)
2121
                                            _store = f.getStore();
2122
                                            var _tbl = _store.proxy.extraParams.tableName;
2123
                                            var oldParam = _store.proxy.extraParams.param;
2124
                                            _store.proxy.extraParams = {
2125
                                                tableName: _tbl,
2126
                                                param: _label + '[=]' + _Value
2127
                                            };
2128
                                            _store.load();
2129
                                        }
2130

    
2131
                                        if (custumFunc) {
2132
                                            eval(custumFunc)
2133
                                        }
2134

    
2135
                                    }
2136

    
2137
                                },
2138

    
2139
                            },
2140
                        });
2141
                    } else if (rec.FieldDataType == 1) {
2142
                        formfield = new MinovaUtil.MinovaES.MinovaNumberField({
2143
                            allowBlank: null_,
2144
                            fieldLabel: rec.ScreenCaption,
2145
                            readOnly: ReadOnly_,
2146
                            readOnlyCls: 'minova-readonly',
2147
                            labelCls: 'label-minova',
2148
                            labelWidth: lw,
2149
                            msgTarget: 'side',
2150
                            hideTrigger: true,
2151
                            hidden: Hidden_,
2152
                            name: rec.FieldName,
2153
                            IsPrimaryKey: rec.IsPrimaryKey,
2154
                            value: defaultValue,
2155
                            maxLength: rec.Length,
2156
                            anchor: '100%',
2157
                            formname: formname,
2158
                            nameTable: tbl,
2159
                            fieldStyle: 'text-align:right;',
2160
                            listeners: {
2161

    
2162
                                change: function (val) {
2163
                                    var _label = val.name;
2164
                                    var _form = val.formname;
2165
                                    var _Value = val.getValue();
2166
                                    var target = rec.TriggerCombo;
2167
                                    var custumFunc = rec.SelectFunction;
2168
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2169
                                        Ext.Ajax.request({
2170
                                            async: false,
2171
                                            method: 'POST',
2172
                                            url: '/UserControl/GetStore',
2173
                                            params: {
2174
                                                tableName: 'PCMFUNC',
2175
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2176
                                            },
2177
                                            success: function (response) {
2178
                                                var results = Ext.decode(response.responseText);
2179
                                                data_ = results.data[0];
2180
                                                if (data_ != undefined) {
2181
                                                    custumFunc = data_.FunctionCode;
2182
                                                }
2183
                                            }
2184
                                        });
2185
                                    }
2186
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2187
                                    if (frm) {
2188

    
2189
                                        if (target) {
2190
                                            var f = frm.getForm().findField(target)
2191
                                            _store = f.getStore();
2192
                                            var _tbl = _store.proxy.extraParams.tableName;
2193
                                            var oldParam = _store.proxy.extraParams.param;
2194
                                            _store.proxy.extraParams = {
2195
                                                tableName: _tbl,
2196
                                                param: _label + '[=]' + _Value
2197
                                            };
2198
                                            _store.load();
2199
                                        }
2200

    
2201
                                        if (custumFunc) {
2202
                                            eval(custumFunc)
2203
                                        }
2204

    
2205
                                    }
2206

    
2207
                                },
2208

    
2209
                            },
2210
                        });
2211
                    } else if (rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2212
                        formfield = new Ext.form.TextField({
2213
                            fieldLabel: rec.ScreenCaption,
2214
                            allowBlank: true,
2215
                            readOnlyCls: 'minova-readonly',
2216
                            fieldLabel: rec.ScreenCaption,
2217
                            readOnly: true,
2218
                            labelCls: 'label-minova',
2219
                            labelWidth: lw,
2220
                            hidden: Hidden_,
2221
                            name: rec.FieldName,
2222
                            msgTarget: 'side',
2223
                            maxLength: rec.Length,
2224
                            anchor: '100%',
2225
                            formname: formname,
2226
                            nameTable: tbl,
2227
                            listeners: {
2228

    
2229
                                change: function (val) {
2230
                                    var _label = val.name;
2231
                                    var _form = val.formname;
2232
                                    var _Value = val.getValue();
2233
                                    var target = rec.TriggerCombo;
2234
                                    var custumFunc = rec.SelectFunction;
2235
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2236
                                        Ext.Ajax.request({
2237
                                            async: false,
2238
                                            method: 'POST',
2239
                                            url: '/UserControl/GetStore',
2240
                                            params: {
2241
                                                tableName: 'PCMFUNC',
2242
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2243
                                            },
2244
                                            success: function (response) {
2245
                                                var results = Ext.decode(response.responseText);
2246
                                                data_ = results.data[0];
2247
                                                if (data_ != undefined) {
2248
                                                    custumFunc = data_.FunctionCode;
2249
                                                }
2250
                                            }
2251
                                        });
2252
                                    }
2253
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2254
                                    if (frm) {
2255

    
2256
                                        if (target) {
2257
                                            var f = frm.getForm().findField(target)
2258
                                            _store = f.getStore();
2259
                                            var _tbl = _store.proxy.extraParams.tableName;
2260
                                            var oldParam = _store.proxy.extraParams.param;
2261
                                            _store.proxy.extraParams = {
2262
                                                tableName: _tbl,
2263
                                                param: _label + '[=]' + _Value
2264
                                            };
2265
                                            _store.load();
2266
                                        }
2267

    
2268
                                        if (custumFunc) {
2269
                                            eval(custumFunc)
2270
                                        }
2271

    
2272
                                    }
2273

    
2274
                                },
2275

    
2276
                            },
2277
                        });
2278

    
2279
                    } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT") {
2280
                        formfield = new MinovaUtil.MinovaES.SysDateTime({
2281
                            fieldLabel: rec.ScreenCaption,
2282
                            allowBlank: true,
2283
                            readOnlyCls: 'minova-readonly',
2284
                            labelCls: 'label-minova',
2285
                            IsPrimaryKey: rec.IsPrimaryKey,
2286
                            labelWidth: lw,
2287
                            msgTarget: 'side',
2288
                            fieldLabel: rec.ScreenCaption,
2289
                            readOnly: true,
2290
                            hidden: Hidden_,
2291
                            name: rec.FieldName,
2292
                            anchor: '100%',
2293
                            nameTable: tbl,
2294
                            readOnlyCls: 'minova-readonly',
2295
                            //cls:'x-item-disabled'
2296

    
2297
                        });
2298

    
2299
                    } else if (rec.FieldName == 'EmployeeID' && isLookup != true && rec.SearchType == "" || rec.FieldName == 'ApplicantID' || rec.FieldName == 'EmployeeIDFrom' || rec.FieldName == 'EmployeeIDTo') {
2300
                        // if (rec.SearchType == "" || rec.SearchType == null || rec.SearchType == undefined) {
2301
                        var triger = (rec.TriggerCombo).split('$');
2302
                        var targetField_ = triger[0];
2303
                        var fieldValue_ = triger[1];
2304

    
2305
                        formfield = new MinovaUtil.MinovaES.MinovaLookupEmployee({
2306
                            allowBlank: null_,
2307
                            fieldLabel: rec.ScreenCaption,
2308
                            readOnly: ReadOnly_,
2309
                            readOnlyCls: 'minova-readonly',
2310
                            hidden: Hidden_,
2311
                            labelCls: 'label-minova',
2312
                            name: rec.FieldName,
2313
                            msgTarget: 'side',
2314
                            fieldname: rec.FieldName,
2315
                            IsPrimaryKey: rec.IsPrimaryKey,
2316
                            tableName: rec.TableRef, //name tabel yang jadi ref-nya
2317
                            triggerCls: 'x-form-search-trigger',
2318
                            //vtype: 'alphanum', // disable space
2319
                            vtype: 'validateMinovaXss',
2320
                            formtarget: formname, // nama form  yang akan di set value-nya
2321
                            isLookup: isLookup,
2322
                            anchor: '100%',
2323
                            formname: formname,
2324
                            targetField: targetField_,
2325
                            fieldValue: fieldValue_,
2326
                            nameTable: tbl,
2327
                            value: defaultValue,
2328
                            LookupFunction: rec.LookupFunction,
2329
                            filterParam: rec.ParamCombo,
2330
                            listeners: {
2331

    
2332
                                change: function (val) {
2333
                                    var _label = val.name;
2334
                                    var _form = val.formname;
2335
                                    var _Value = val.getValue();
2336
                                    var target = rec.TriggerCombo;
2337
                                    var custumFunc = rec.SelectFunction;
2338
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2339
                                        Ext.Ajax.request({
2340
                                            async: false,
2341
                                            method: 'POST',
2342
                                            url: '/UserControl/GetStore',
2343
                                            params: {
2344
                                                tableName: 'PCMFUNC',
2345
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2346
                                            },
2347
                                            success: function (response) {
2348
                                                var results = Ext.decode(response.responseText);
2349
                                                data_ = results.data[0];
2350
                                                if (data_ != undefined) {
2351
                                                    custumFunc = data_.FunctionCode;
2352
                                                }
2353
                                            }
2354
                                        });
2355
                                    }
2356
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2357
                                    if (frm) {
2358

    
2359
                                        if (target) {
2360
                                            var f = frm.getForm().findField(target)
2361
                                            _store = f.getStore();
2362
                                            var _tbl = _store.proxy.extraParams.tableName;
2363
                                            var oldParam = _store.proxy.extraParams.param;
2364
                                            _store.proxy.extraParams = {
2365
                                                tableName: _tbl,
2366
                                                param: _label + '[=]' + _Value
2367
                                            };
2368
                                            _store.load();
2369
                                        }
2370

    
2371
                                        if (custumFunc) {
2372
                                            eval(custumFunc)
2373
                                        }
2374

    
2375
                                    }
2376

    
2377
                                },
2378

    
2379
                            },
2380
                        });
2381
                        //}
2382
                    } else {
2383
                        formfield = new Ext.form.TextField({
2384
                            allowBlank: null_,
2385
                            fieldLabel: rec.ScreenCaption,
2386
                            readOnly: ReadOnly_,
2387
                            readOnlyCls: 'minova-readonly',
2388
                            labelCls: 'label-minova',
2389
                            labelWidth: lw,
2390
                            msgTarget: 'side',
2391
                            hidden: Hidden_,
2392
                            name: rec.FieldName,
2393
                            IsPrimaryKey: rec.IsPrimaryKey,
2394
                            value: defaultValue,
2395
                            maxLength: rec.Length,
2396
                            anchor: '100%',
2397
                            formname: formname,
2398
                            vtype: 'validateMinovaXss',
2399
                            nameTable: tbl,
2400
                            listeners: {
2401

    
2402
                                change: function (val) {
2403
                                    var _label = val.name;
2404
                                    var _form = val.formname;
2405
                                    var _Value = val.getValue();
2406
                                    var target = rec.TriggerCombo;
2407
                                    var custumFunc = rec.SelectFunction;
2408
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2409
                                        Ext.Ajax.request({
2410
                                            async: false,
2411
                                            method: 'POST',
2412
                                            url: '/UserControl/GetStore',
2413
                                            params: {
2414
                                                tableName: 'PCMFUNC',
2415
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2416
                                            },
2417
                                            success: function (response) {
2418
                                                var results = Ext.decode(response.responseText);
2419
                                                data_ = results.data[0];
2420
                                                if (data_ != undefined) {
2421
                                                    custumFunc = data_.FunctionCode;
2422
                                                }
2423
                                            }
2424
                                        });
2425
                                    }
2426
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2427
                                    if (frm) {
2428

    
2429
                                        if (target) {
2430
                                            var f = frm.getForm().findField(target)
2431
                                            _store = f.getStore();
2432
                                            var _tbl = _store.proxy.extraParams.tableName;
2433
                                            var oldParam = _store.proxy.extraParams.param;
2434
                                            _store.proxy.extraParams = {
2435
                                                tableName: _tbl,
2436
                                                param: _label + '[=]' + _Value
2437
                                            };
2438
                                            _store.load();
2439
                                        }
2440

    
2441
                                        if (custumFunc) {
2442
                                            eval(custumFunc)
2443
                                        }
2444

    
2445
                                    }
2446

    
2447
                                },
2448

    
2449
                            },
2450
                        });
2451
                    }
2452
                }
2453

    
2454
        }
2455

    
2456
        //if (rec.IsPrimaryKey == 1) {
2457
        //    formfield = new Ext.form.TextField({
2458
        //        hidden: true,
2459
        //        name: "Key_" + rec.FieldName,
2460
        //    });
2461
        //}
2462
    }
2463

    
2464
    //
2465
    return (formfield);
2466
}
2467
MinovaUtil.FieldGenerator.Editor = function (rec, null_) {
2468
    var formfield = undefined;
2469
    switch (rec.FormatRef) {
2470
        case "date":
2471
            formfield = new Ext.form.DateField({
2472
                allowBlank: null_,
2473
                //msgTarget: 'side',
2474
                readOnly: rec.ReadOnly,
2475
                name: rec.FieldName,
2476
                format: 'd/m/Y',
2477
                submitFormat: 'Ymd',
2478
                value: defaultValue,
2479
                anchor: '100%',
2480
                hideMode: 'visibility',
2481

    
2482
            });
2483
            break
2484
        case "time":
2485
            formfield = new Ext.form.TimeField({
2486
                allowBlank: null_,
2487
                //msgTarget: 'side',
2488
                readOnly: rec.ReadOnly,
2489
                name: rec.FieldName,
2490
                format: 'Hi',
2491
                submitFormat: 'Hi',
2492
                increment: 5,
2493
                value: defaultValue,
2494
                anchor: '100%'
2495
            });
2496
            break
2497
        case "file":
2498
            formfield = Ext.create('MinovaES.view.uploadfile.uploadfile')
2499
            break
2500
        default:
2501
            if (rec.Length > 49 && rec.TableRef == "") {
2502
                formfield = new Ext.form.TextArea({
2503
                    allowBlank: null_,
2504
                    //msgTarget: 'side',
2505
                    readOnly: rec.ReadOnly,
2506
                    name: rec.FieldName,
2507
                    value: defaultValue,
2508
                    maxLength: rec.Length,
2509
                    anchor: '100%'
2510
                });
2511
            } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT" || rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2512
                formfield = new Ext.form.TextField({
2513
                    allowBlank: true,
2514
                    //msgTarget: 'side',
2515
                    readOnly: true,
2516
                    name: rec.FieldName,
2517
                    maxLength: rec.Length,
2518
                    anchor: '100%'
2519
                });
2520
            } else if (rec.TableRef != "") {
2521
                var fieldsCombo = null;
2522
                Ext.Ajax.request({
2523
                    async: false,
2524
                    method: 'POST',
2525
                    url: '/Devt/GetAllField?tableName=' + rec.TableRef,
2526
                    success: function (response) {
2527
                        var results = Ext.decode(response.responseText);
2528
                        fieldsCombo = results.data;
2529
                    }
2530
                });
2531
                valueField = null;
2532
                Ext.Ajax.request({
2533
                    async: false,
2534
                    method: 'POST',
2535
                    url: '/UserControl/GetStore',
2536
                    params: {
2537
                        tableName: 'SDATATABLEFIELD',
2538
                        param: 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2539
                    },
2540
                    success: function (response) {
2541
                        var results = Ext.decode(response.responseText);
2542
                        data_ = results.data[0];
2543
                        if (data_ != undefined) {
2544
                            valueField = data_.FieldName;
2545
                        }
2546
                    }
2547
                });
2548
                displayValue = null;
2549
                Ext.Ajax.request({
2550
                    async: false,
2551
                    method: 'POST',
2552
                    url: '/UserControl/GetStore',
2553
                    params: {
2554
                        tableName: 'SDATATABLEFIELD',
2555
                        param: 'DisplayValue[equal]1,TableName[equal]' + rec.TableRef
2556
                    },
2557
                    success: function (response) {
2558
                        var results = Ext.decode(response.responseText);
2559
                        data_ = results.data[0];
2560
                        if (data_ != undefined) {
2561
                            displayValue = data_.FieldName;
2562
                            //console.log(data_)
2563
                        }
2564
                    }
2565
                });
2566
                //var field_ = [];
2567
                //fieldsCombo.forEach(function (rec) {
2568
                //    field_.push(rec.FieldName)
2569
                //});
2570

    
2571
                formfield = new Ext.form.ComboBox({
2572
                    allowBlank: null_,
2573
                    //msgTarget: 'side',
2574
                    readOnly: rec.ReadOnly,
2575
                    name: rec.FieldName,
2576
                    value: defaultValue,
2577
                    anchor: '100%',
2578
                    vtype: 'validateCombobox',
2579
                    store: Ext.create('Ext.data.Store', {
2580
                        storeId: 'store' + rec.FieldName,
2581
                        autoLoad: true,
2582
                        //pageSize: 10,
2583
                        //fields: field_,
2584
                        proxy: {
2585
                            method: 'POST',
2586
                            type: 'ajax',
2587
                            url: '/UserControl/GetStore',
2588
                            //params: {
2589
                            extraParams: {
2590
                                tableName: rec.TableRef,
2591
                                param: rec.ParamCombo
2592
                            },
2593
                            reader: {
2594
                                type: 'json',
2595
                                root: 'data',
2596
                                // totalProperty: 'data[0].TotalCount'
2597
                            }
2598
                        }
2599
                    }),
2600
                    listeners: {
2601
                        change: function (val) { }
2602

    
2603
                    },
2604
                    queryMode: 'local',
2605
                    displayField: displayValue,
2606
                    valueField: valueField,
2607
                });
2608
            } else if (rec.FieldDataType == 3) {
2609
                formfield = new MinovaUtil.MinovaES.MinovaFloatField({
2610
                    allowBlank: null_,
2611
                    //msgTarget: 'side',
2612
                    readOnly: rec.ReadOnly,
2613
                    name: rec.FieldName,
2614
                    value: defaultValue,
2615
                    maxLength: rec.Length,
2616
                    precision: rec.Prec,
2617
                    anchor: '100%'
2618
                });
2619
            } else if (rec.FieldDataType == 1) {
2620
                formfield = new MinovaUtil.MinovaES.MinovaNumberField({
2621
                    allowBlank: null_,
2622
                    //msgTarget: 'side',
2623
                    readOnly: rec.ReadOnly,
2624
                    name: rec.FieldName,
2625
                    value: defaultValue,
2626
                    maxLength: rec.Length,
2627
                    anchor: '100%'
2628
                });
2629
            } else {
2630
                formfield = new Ext.form.TextField({
2631
                    allowBlank: null_,
2632
                    //msgTarget: 'side',
2633
                    readOnly: rec.ReadOnly,
2634
                    name: rec.FieldName,
2635
                    value: defaultValue,
2636
                    maxLength: rec.Length,
2637
                    anchor: '100%'
2638
                });
2639
            }
2640
    }
2641
    return (formfield);
2642
}
2643
MinovaUtil.FieldGenerator.Column = function (rec, null_) {
2644
    var gridcol = undefined;
2645
    switch (rec.FormatRef) {
2646
        case "date":
2647
            gridcol = 'minovadatecolumn'
2648
            break
2649
        case "time":
2650
            gridcol = ''
2651
            break
2652
        case "file":
2653
            gridcol = ''
2654
            break
2655
        default:
2656
            if (rec.Length > 49 && rec.TableRef == "") {
2657
                gridcol = ''
2658
            } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT" || rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2659
                gridcol = ''
2660
            } else if (rec.TableRef != "") {
2661
                gridcol = 'MinovaComboColumn'
2662
            } else if (rec.FieldDataType == 3) {
2663
                gridcol = 'numbercolumn'
2664
            } else if (rec.FieldDataType == 1) {
2665
                gridcol = 'numbercolumn'
2666
            } else {
2667
                gridcol = ''
2668
            }
2669
    }
2670
    return (gridcol);
2671
}
2672
MinovaUtil.FieldGenerator.Display = function (rec) {
2673
    var formfield = null;
2674
    var Hidden_ = false;
2675
    if (rec.IsHidden == '1' || IsHidden == true) {
2676
        Hidden_ = true;
2677
    }
2678
    switch (rec.FormatRef) {
2679
        case "date":
2680
            formfield = new MinovaUtil.MinovaES.DisplayDate({
2681
                fieldLabel: rec.ScreenCaption,
2682
                //msgTarget: 'side',
2683
                hidden: Hidden_,
2684
                name: rec.FieldName,
2685
                anchor: '100%'
2686
            });
2687
            break;
2688

    
2689
        default:
2690
            if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT") {
2691
                formfield = new MinovaUtil.MinovaES.DisplaySysDateTime({
2692
                    fieldLabel: rec.ScreenCaption,
2693
                    //msgTarget: 'side',
2694
                    hidden: Hidden_,
2695
                    name: rec.FieldName,
2696
                    anchor: '100%'
2697
                });
2698
            } else if (rec.TableRef != "") {
2699

    
2700
                valueField = null;
2701
                Ext.Ajax.request({
2702
                    async: false,
2703
                    method: 'POST',
2704
                    url: '/UserControl/GetStore',
2705
                    params: {
2706
                        tableName: 'SDATATABLEFIELD',
2707
                        param: 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2708
                    },
2709
                    success: function (response) {
2710
                        var results = Ext.decode(response.responseText);
2711
                        data_ = results.data[0];
2712
                        if (data_ != undefined) {
2713
                            valueField = data_.FieldName;
2714
                        }
2715
                    }
2716
                });
2717
                displayValue = null;
2718
                Ext.Ajax.request({
2719
                    async: false,
2720
                    method: 'POST',
2721
                    url: '/UserControl/GetStore',
2722
                    params: {
2723
                        tableName: 'SDATATABLEFIELD',
2724
                        param: 'DisplayValue[equal]1,TableName[equal]' + rec.TableRef
2725
                    },
2726
                    success: function (response) {
2727
                        var results = Ext.decode(response.responseText);
2728
                        data_ = results.data[0];
2729
                        if (data_ != undefined) {
2730
                            displayValue = data_.FieldName;
2731
                            //console.log(data_)
2732
                        }
2733
                    }
2734
                });
2735
                //var field_ = [];
2736
                //fieldsCombo.forEach(function (rec) {
2737
                //    field_.push(rec.FieldName)
2738
                //});
2739
                formfield = new Ext.form.ComboBox({
2740
                    allowBlank: null_,
2741
                    fieldLabel: rec.ScreenCaption,
2742
                    //msgTarget: 'side',
2743
                    readOnly: rec.ReadOnly,
2744
                    hidden: Hidden_,
2745
                    name: rec.FieldName,
2746
                    value: defaultValue,
2747
                    vtype: 'validateCombobox',
2748
                    anchor: '100%',
2749
                    store: Ext.create('Ext.data.Store', {
2750
                        storeId: 'store' + rec.FieldName,
2751
                        autoLoad: true,
2752
                        //pageSize: 10,
2753
                        //fields: field_,
2754
                        proxy: {
2755
                            method: 'POST',
2756
                            type: 'ajax',
2757
                            url: '/UserControl/GetStore',
2758
                            //params: {
2759
                            extraParams: {
2760
                                tableName: rec.TableRef,
2761
                                param: ''
2762
                            },
2763
                            reader: {
2764
                                type: 'json',
2765
                                root: 'data',
2766
                                totalProperty: 'data[0].TotalCount'
2767
                            }
2768
                        }
2769
                    }),
2770
                    listeners: {
2771
                        change: function (val) { }
2772

    
2773
                    },
2774
                    queryMode: 'local',
2775
                    displayField: displayValue,
2776
                    valueField: valueField,
2777
                });
2778
            }
2779
            break
2780
    }
2781
}
2782

    
2783
//funsi untuk set value form html
2784
// data json
2785
// form_id= id form yang akan diset valuenya
2786
MinovaUtil.FieldGenerator.HtmlSetValues = function (data, form_id) {
2787
    $.each(data, function (key, value) {
2788
        $('#' + key, form_id).val(value);
2789
    });
2790
}
2791

    
2792
MinovaUtil.FieldGenerator.SimpleHtmlDisplay1 = function (divid, tableName, title) {
2793

    
2794
    code = null;
2795
    Ext.Ajax.request({
2796
        async: false,
2797
        method: 'POST',
2798
        url: '/Devt/GetItenDiv',
2799
        /* params : {
2800
		tableName : 'SDATATABLEFIELD',
2801
		param : 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2802
		}, */
2803
        success: function (response) {
2804
            code = response.responseText;
2805

    
2806
        }
2807
    });
2808

    
2809
    $("#" + divid).append(" <h3 class='form-section'>" + title + "</h3>");
2810
    $("#" + divid).append("<div class='row' id='TableName_Content'> " + code + " </div>");
2811

    
2812
}
2813

    
2814
MinovaUtil.FieldGenerator.SimpleHtmlDisplay2 = function (divid, tableName, title) {
2815

    
2816
    code = null;
2817
    Ext.Ajax.request({
2818
        async: false,
2819
        method: 'POST',
2820
        url: '/Devt/GetItenDiv',
2821
        /* params : {
2822
		tableName : 'SDATATABLEFIELD',
2823
		param : 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2824
		}, */
2825
        success: function (response) {
2826
            code = response.responseText;
2827

    
2828
        }
2829
    });
2830

    
2831
    $("#" + divid).append(" <h3 class='form-section'>" + title + "</h3>");
2832
    $("#" + divid).append("<div class='row' id='TableName_Content'> " + code + " </div>");
2833

    
2834
}
2835

    
2836
MinovaUtil.FieldGenerator.ExtjsBuildGrid = function (divid, tableName) {
2837
    var div_ = tableName + 'div'
2838
    $("#" + divid).append('  <div class="row" id="grid"' + tableName + '>' +
2839
        '<div class="col-md-12">' +
2840
        '<h3 class="form-section">Person Info</h3>' +
2841
        '<div class="portlet-body" id=' + div_ + '> </div></div></div>');
2842

    
2843
    Ext.create('MinovaUtil.MinovaES.MinovaGrid1', {
2844
        renderTo: div_,
2845
        isLookup: 1,
2846
        minHeight: 280,
2847
        height: 100,
2848
        tableName: tableName,
2849
        param: '',
2850
        isLookup: false,
2851
        width: '100%',
2852
        name: 'grid' + tableName,
2853
        hidebutton: 0,
2854
        pagesize: 25,
2855
        storename: 'lgrid' + tableName,
2856
    });
2857
}
2858

    
2859
MinovaUtil.FieldGenerator.BuildSimpleGridHtml = function (divid, tableName, title) {
2860

    
2861
    var header = "";
2862
    var ThThead = "";
2863
    for (var i = 0; i < 4; i++) {
2864
        header = "header" + i;
2865
        ThThead = ThThead + "<th>" + header + "</th>";
2866
    }
2867
    var Thead = "<thead>" + ThThead + "</thead>";
2868

    
2869
    var td = "";
2870
    var tdLabel = "";
2871
    var tr = "";
2872
    for (var a = 0; a <= 2; a++) {
2873
        for (var b = 0; b < 4; b++) {
2874
            tdLabel = b;
2875
            td = td + "<td>" + tdLabel + "</td>";
2876
        }
2877
        tr = tr + "<tr>" + td + "</tr>";
2878
        td = "";
2879
    }
2880
    var Tbody = "<tbody>" + tr + "</tbody>";
2881
    var tbl = tableName + "Table";
2882
    var result = "<div class='row' id=" + tbl + ">" +
2883
		"<div class='col-md-10'>" +
2884
		"<h3 class='form-section'>" + title + "</h3>" +
2885
		"<div class='portlet-body'>" +
2886
		"<div class='table-scrollable'>" +
2887
		"<table class='table table-bordered table-hover'>" +
2888
		Thead +
2889
		Tbody
2890
    "</table>" +
2891
    "</div>" +
2892
    "</div>" +
2893
    "</div>" +
2894
    "</div>";
2895
    $("#" + divid).append(result);
2896
}
2897

    
2898
MinovaUtil.FieldGenerator.Header1 = function (divid, companyCode) {
2899
    var logo = undefined;
2900
    var CompanyDescription = undefined;
2901
    Ext.Ajax.request({
2902
        async: false,
2903
        method: 'POST',
2904
        url: '/UserControl/GetStore',
2905
        params: {
2906
            tableName: 'PCMEPCOMPID',
2907
            param: 'CompanyID[equal]' + companyCode
2908

    
2909
        },
2910
        success: function (response) {
2911
            var results = Ext.decode(response.responseText);
2912
            data_ = results.data;
2913
            if (data_.length > 0) {
2914
                logo = data_[0].Logo;
2915
                CompanyDescription = data_[0].CompanyDescription;
2916
            }
2917
        }
2918
    });
2919

    
2920
    var header = //'<div class="row">' +
2921
		'<div class="col-md-3">' +
2922
		'<div class="page-logo">' +
2923
		'<a href="/">' +
2924
		///Devt/GetFileData?FileName=Foto Fazari.jpg&download=false
2925
		'<img src="/Devt/GetFileData?FileName=' + logo + '&download=false" alt="logo" class="logo-default" />' +
2926
		'</a>' +
2927
		'</div>' +
2928
		'</div>' +
2929
		'<div class="col-md-9">' +
2930
		'<h3>' + CompanyDescription + '</h3>' +
2931

    
2932
		'</div>';
2933
    '<div>';
2934

    
2935
    '</div>';
2936

    
2937
    $("#" + divid).append(header);
2938
}
2939

    
2940
MinovaUtil.FieldGenerator.Header2 = function (divid, companyCode) {
2941
    var header = '<div class="row">' +
2942
		'<div class="col-md-9">' +
2943
		'<div class="page-logo">' +
2944
		'<h3> PT Minova Infotech Solutions</h3>' +
2945
		'</div>' +
2946
		'</div>' +
2947
		'<div class="col-md-3">' +
2948
		'<a href="/">' +
2949
		'<img src="../../Metronic/assets/admin/layout4/img/logo-light.png" alt="logo" class="logo-default" />' +
2950
		'</a>' +
2951
		'</div>' +
2952
		'</div>';
2953
    $("#" + divid).append(header);
2954
}
2955

    
2956
MinovaUtil.FieldGenerator.MDWithImage1 = function (divid) {
2957

    
2958
    var nowDate = MinovaUtil.GetNowDate();
2959
    var Photo = 'nophoto.gif';
2960
    var emp = getParam("EmployeeID");
2961
    if (emp == "null") {
2962
        var VariantID = getParam("VariantName");
2963
        Ext.Ajax.request({
2964
            method: 'POST',
2965
            async: false,
2966
            url: '/UserControl/GetStore',
2967
            params: {
2968
                tableName: 'SDATAVARIANT',
2969
                param: 'VariantName[=]' + VariantID
2970
            },
2971
            success: function (response) {
2972
                var results = Ext.decode(response.responseText);
2973
                hasil = Ext.decode(results.data[0].Data);
2974
                emp = hasil.EmployeeID;
2975

    
2976
            }
2977
        });
2978
    }
2979

    
2980
    // get Photo
2981
    Ext.Ajax.request({
2982
        method: 'POST',
2983
        async: false,
2984
        url: '/UserControl/GetStore',
2985
        params: {
2986
            tableName: 'PHRPA0001',
2987
            param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + emp
2988
        },
2989
        success: function (response) {
2990
            var results = Ext.decode(response.responseText);
2991
            hasil = results.data;
2992
            dataPhoto = hasil[0].Picture
2993
            if (dataPhoto != "") {
2994
                Photo = dataPhoto;
2995
            }
2996

    
2997
        }
2998
    });
2999

    
3000
    var header = '<div class="row">' +
3001
		'<div class="col-md-2">' +
3002
		'<div class="page-logo">' +
3003
		'<a href="/">' +
3004
		'<img src="/Devt/GetFileData?FileName=' + Photo + '&download=false" alt="logo" width="133" height="140" />' +
3005
		'</a>' +
3006
		'</div>' +
3007
		'</div>' +
3008
		'<div class="col-md-10" id="formMD">' +
3009

    
3010
		'</div>' +
3011
		'</div>';
3012
    $("#" + divid).append(header);
3013
}
3014

    
3015
MinovaUtil.FieldGenerator.MDWithImage2 = function (divid, companyCode) {
3016
    var header = '<div class="row">' +
3017
		'<div class="col-md-10" id="formMD">' +
3018

    
3019
		'</div>' +
3020
		'<div class="col-md-2">' +
3021
		'<div class="page-logo">' +
3022
		'<a href="/">' +
3023
		'<img src="../../Metronic/assets/admin/layout4/img/logo-light.png" alt="logo" class="logo-default" />' +
3024
		'</a>' +
3025
		'</div>' +
3026
		'</div>' +
3027
		'</div>';
3028
    $("#" + divid).append(header);
3029
}
3030

    
3031
MinovaUtil.FieldGenerator.CvView = function (divid) {
3032

    
3033
    //get all header
3034
    var emp = getParam('EmployeeID');
3035
    // var divid = 'reportContent';
3036
    var CVType = getParam('CVType');
3037
    if (CVType == "null") {
3038
        var VariantID = getParam("VariantName");
3039
        Ext.Ajax.request({
3040
            method: 'POST',
3041
            async: false,
3042
            url: '/UserControl/GetStore',
3043
            params: {
3044
                tableName: 'SDATAVARIANT',
3045
                param: 'VariantName[=]' + VariantID
3046
            },
3047
            success: function (response) {
3048
                var results = Ext.decode(response.responseText);
3049
                hasil = Ext.decode(results.data[0].Data);
3050
                CVType = hasil.CVType;
3051

    
3052
            }
3053
        });
3054
    }
3055
    var LangId = MinovaUtil.GetLangID();
3056
    var header_ = null;
3057
    var results = null;
3058
    var CVDetailType = null;
3059
    //get all field
3060
    Ext.Ajax.request({
3061
        async: false,
3062
        method: 'POST',
3063
        url: '/UserControl/GetStore',
3064
        params: {
3065
            tableName: 'PDSPA0002',
3066
            param: "hd.CVType = '" + CVType + "' AND rt.LangId = '" + LangId + "'"
3067
            //param : "hd.CVType = "+CVType+" AND rt.LangId = "+LangId
3068
        },
3069
        success: function (response) {
3070
            var result = Ext.decode(response.responseText);
3071
            results = result.data;
3072

    
3073
        }
3074
    });
3075
    // generate ui from all field each panel
3076
    var allTable = null;
3077
    var tbl = null;
3078
    var tblTemp = null;
3079

    
3080
    var allHeader = null;
3081
    var head_ = null;
3082
    var headTemp = null;
3083
    var i = 0;
3084
    var countData = results.length;
3085
    results = results.sort(MinovaUtil.SortBy("Sequence"))
3086
    Ext.each(results, function (rec) {
3087
        tblTemp = results[i].TableName;
3088
        headTemp = results[i].CVHeaderTitle;
3089

    
3090
        if (tbl != tblTemp) {
3091

    
3092
            tbl = tblTemp;
3093
            if (allTable == null) {
3094
                allTable = tbl
3095
            } else {
3096
                allTable = allTable + ',' + tbl
3097
            }
3098

    
3099
        }
3100

    
3101
        if (head_ != headTemp) {
3102

    
3103
            head_ = headTemp;
3104
            if (allHeader == null) {
3105
                allHeader = head_
3106
            } else {
3107
                allHeader = allHeader + ',' + head_
3108
            }
3109

    
3110
        }
3111

    
3112
        if (countData > i) {
3113
            i++
3114
        }
3115

    
3116
    });
3117

    
3118
    var splitHeader = allHeader.split(',')
3119
    var splitTable = allTable.split(',')
3120

    
3121
    splitHeader = splitHeader.filter(MinovaUtil.RemoveDuplicateArray);
3122
    splitTable = splitTable.filter(MinovaUtil.RemoveDuplicateArray);
3123

    
3124
    var panel_ = null;
3125
    // build form/grid
3126
    var contHeader = 0;
3127
    splitHeader.forEach(function (hd) {
3128
        //console.log(h)
3129
        panel_ = null;
3130
        panel_ = $.grep(results, function (r) {
3131
            return r.CVHeaderTitle == hd
3132
        });
3133
        panel_ = panel_.sort(MinovaUtil.SortBy("FieldSequence"))
3134
        //get layout type form/grid
3135
        var layout = panel_[0].CVLayout
3136
        var item_ = null
3137
        if (layout == 'Form') {
3138
            var _temtbl = null;
3139
            var dataValues = null;
3140
            Ext.each(panel_, function (rec) {
3141
                var labelId = "label" + rec.TableName + rec.Field
3142
                var labelValue = rec.ScreenCaption
3143
                var valueId = "val" + rec.TableName + rec.Field
3144

    
3145
                if (_temtbl == null) {
3146
                    _temtbl = rec.TableName;
3147
                    //alert(_temtbl)
3148
                    //get table values
3149
                    Ext.Ajax.request({
3150
                        async: false,
3151
                        method: 'POST',
3152
                        url: '/UserControl/GetStore',
3153
                        params: {
3154
                            tableName: rec.TableName,
3155
                            param: 'EmployeeID[=]' + emp
3156
                            // belum di cek start date dan enddate
3157
                        },
3158
                        success: function (response) {
3159
                            var results = Ext.decode(response.responseText);
3160
                            dataValues = results.data[0];
3161

    
3162
                        }
3163
                    });
3164
                }
3165

    
3166
                if (_temtbl != rec.TableName) {
3167

    
3168
                    //get table values
3169
                    Ext.Ajax.request({
3170
                        async: false,
3171
                        method: 'POST',
3172
                        url: '/UserControl/GetStore',
3173
                        params: {
3174
                            tableName: rec.TableName,
3175
                            param: 'EmployeeID[=]' + emp
3176

    
3177
                        },
3178
                        success: function (response) {
3179
                            var results = Ext.decode(response.responseText);
3180
                            dataValues = results.data[0];
3181
                            // console.log(dataValues)
3182

    
3183
                        }
3184
                    });
3185

    
3186
                }
3187
                var _field = null;
3188
                var valueField = null;
3189
                var TableRef = null;
3190
                if (dataValues) {
3191
                    _field = 'dataValues.' + rec.Field;
3192
                    // case field with table ref
3193
                    //get table ref
3194

    
3195
                    Ext.Ajax.request({
3196
                        async: false,
3197
                        method: 'POST',
3198
                        url: '/UserControl/GetStore',
3199
                        params: {
3200
                            tableName: 'SDATATABLEFIELD',
3201
                            param: 'TableName[=]' + rec.TableName + ',' + 'FieldName[=]' + rec.Field
3202

    
3203
                        },
3204
                        success: function (response) {
3205
                            var results = Ext.decode(response.responseText);
3206
                            if (results.length > 0) {
3207
                                TableRef = results.data[0].TableRef;
3208
                            }
3209

    
3210
                        }
3211
                    });
3212
                    if (TableRef != '' && TableRef != null) {
3213
                        //alert(TableRef);
3214
                        //get valuefield and displayfield tableref
3215
                        var data = null;
3216
                        Ext.Ajax.request({
3217
                            async: false,
3218
                            method: 'POST',
3219
                            url: '/UserControl/GetStore',
3220
                            params: {
3221
                                tableName: 'SDATATABLEFIELD',
3222
                                param: 'TableName[=]' + TableRef
3223

    
3224
                            },
3225
                            success: function (response) {
3226
                                data = Ext.decode(response.responseText).data;
3227
                                // data = data_.data[0];
3228
                            }
3229
                        });
3230
                        code = $.grep(data, function (r) {
3231
                            return r.ValueField == '1'
3232
                        });
3233
                        code = code[0].FieldName;
3234
                        desc = $.grep(data, function (r) {
3235
                            return r.DisplayValue == '1'
3236
                        });
3237
                        desc = desc[0].FieldName;
3238
                        //get value display
3239
                        if (code != '' && code != null) {
3240
                            Ext.Ajax.request({
3241
                                async: false,
3242
                                method: 'POST',
3243
                                url: '/UserControl/GetStore',
3244
                                params: {
3245
                                    tableName: TableRef,
3246
                                    param: code + '[=]' + eval(_field)
3247

    
3248
                                },
3249
                                success: function (response) {
3250
                                    var results = Ext.decode(response.responseText);
3251
                                    result = results.data[0];
3252
                                    field_ = "result." + desc;
3253
                                    valueField = eval(field_);
3254

    
3255
                                }
3256
                            });
3257

    
3258
                        }
3259

    
3260
                    } else {
3261
                        valueField = eval(_field);
3262
                    }
3263

    
3264
                }
3265

    
3266
                if (item_ == null) {
3267

    
3268
                    item_ = "<div class='col-md-6'> <div class='form-group'>"
3269
                         + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3270
                         + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3271
                         + valueField + " </div> </div> </div>"
3272
                } else {
3273

    
3274
                    item_ = item_ + "<div class='col-md-6'> <div class='form-group'>"
3275
                         + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3276
                         + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3277
                         + valueField + " </div> </div> </div>"
3278
                }
3279

    
3280
            });
3281
            if (contHeader == 0) {
3282

    
3283
                $("#formMD").append(" <h3 class='form-section'>" + hd + "</h3>");
3284
                $("#formMD").append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3285

    
3286
            } else {
3287
                $("#" + divid).append(" <h3 class='form-section'>" + hd + "</h3>");
3288
                $("#" + divid).append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3289
            }
3290
            contHeader++;
3291

    
3292
        } else {
3293
            var gridPanel = null;
3294
            var header = "";
3295
            var ThThead = "";
3296
            var tr = "";
3297
            var td = "";
3298
            var tdLabel = "";
3299
            var tableName = panel_[0].TableName;
3300
            var allGridCol = null;
3301
            dtEmp = null;
3302
            Ext.Ajax.request({
3303
                async: false,
3304
                method: 'POST',
3305
                url: '/UserControl/GetStore',
3306
                params: {
3307
                    tableName: tableName,
3308
                    param: 'EmployeeID[equal]' + emp
3309
                },
3310
                success: function (response) {
3311
                    var results = Ext.decode(response.responseText);
3312
                    dtEmp = results.data;
3313
                    //  console.log(tableName);
3314
                    //  console.log(dtEmp)
3315

    
3316
                }
3317
            });
3318
            // get structure
3319
            var structure = null
3320
            Ext.Ajax.request({
3321
                async: false,
3322
                method: 'POST',
3323
                url: '/UserControl/GetStore',
3324
                params: {
3325
                    tableName: 'SDATATABLEFIELD',
3326
                    param: 'TableName[equal]' + tableName
3327
                },
3328
                success: function (response) {
3329
                    var results = Ext.decode(response.responseText);
3330
                    structure = results.data;
3331
                    //  console.log(tableName);
3332
                    //  console.log(dtEmp)
3333

    
3334
                }
3335
            });
3336
            Ext.each(panel_, function (rec) {
3337
                header = rec.HeaderTitle;
3338
                if (allGridCol == null) {
3339
                    allGridCol = header
3340
                } else {
3341
                    allGridCol = allGridCol + ',' + header
3342
                }
3343
                ThThead = ThThead + "<th>" + header + "</th>";
3344
            });
3345
            //var splitallGridCol = allGridCol.split(',')
3346
            var Thead = "<thead>" + ThThead + "</thead>";
3347
            // get data by tableName and emp id
3348

    
3349
            for (var a = 0; a < dtEmp.length; a++) { //length data will be populate, create row coloumn
3350
                //console.log(panel_)
3351
                for (var b = 0; b < panel_.length; b++) { //length header
3352
                    // tdLabel = b;
3353

    
3354
                    haed_ = panel_[b].Field;
3355
                    _tdLabel = 'dtEmp[' + a + '].' + haed_;
3356
                    tdLabel = eval(_tdLabel);
3357
                    //structure_ = structure[b].haed_
3358
                    structure_ = $.grep(structure, function (r) {
3359
                        return r.FieldName == haed_
3360
                    });
3361

    
3362
                    var hasil = MinovaUtil.FieldGenerator.GetValueHtml(structure_, tdLabel);
3363

    
3364
                    td = td + "<td>" + hasil + "</td>";
3365

    
3366
                }
3367
                tr = tr + "<tr>" + td + "</tr>";
3368
                td = "";
3369
            }
3370

    
3371
            var Tbody = "<tbody>" + tr + "</tbody>";
3372
            //var tbl = rec.tableName + "Table";
3373
            var tbl = "Table";
3374
            gridPanel = "<div class='row' id=" + tbl + ">" +
3375
                "<div class='col-md-10'>" +
3376
                "<h3 class='form-section'>" + hd + "</h3>" +
3377
                "<div class='portlet-body'>" +
3378
                "<div class='table-scrollable'>" +
3379
                "<table class='table table-bordered table-hover'>" +
3380
                Thead +
3381
                Tbody
3382
            "</table>" +
3383
            "</div>" +
3384
            "</div>" +
3385
            "</div>" +
3386
            "</div>";
3387
            $("#" + divid).append(gridPanel);
3388
        }
3389

    
3390
    });
3391

    
3392
    //set values for/grid
3393
    splitTable.forEach(function (tb) {
3394
        // alert(tb)
3395
    });
3396
}
3397

    
3398
MinovaUtil.FieldGenerator.GetValueHtml = function (structure, oldVlaue) {
3399
    var hasil = null;
3400
    switch (structure_[0].FormatRef) {
3401
        case "date":
3402
            d = oldVlaue.substring(6, 8);
3403
            m = oldVlaue.substring(4, 6);
3404
            y = oldVlaue.substring(0, 4);
3405
            hasil = d + '/' + m + '/' + y;
3406
            break;
3407

    
3408
        case "datetime":
3409
            var d = oldVlaue.substring(6, 8);
3410
            var m = oldVlaue.substring(4, 6);
3411
            var y = oldVlaue.substring(0, 4);
3412
            var h = oldVlaue.substring(8, 10);
3413
            var mt = oldVlaue.substring(10, 12);
3414
            var s = oldVlaue.substring(12, 14);
3415
            hasil = d + '/' + m + '/' + y + '  ' + '  ' + h + ':' + mt + ':' + s;
3416
            break;
3417

    
3418
        default:
3419
            if (structure_[0].SearchType != '') {
3420
                if (structure_[0].TableRef != '') {
3421
                    Ext.Ajax.request({
3422
                        async: false,
3423
                        method: 'POST',
3424
                        url: '/UserControl/GetStore',
3425
                        params: {
3426
                            tableName: 'SDATATABLEFIELD',
3427
                            param: 'TableName[equal]' + structure_[0].TableRef
3428
                        },
3429
                        success: function (response) {
3430
                            var results = Ext.decode(response.responseText);
3431
                            data_ = results.data;
3432
                            code = $.grep(data_, function (r) {
3433
                                return r.ValueField == '1'
3434
                            });
3435
                            desc = $.grep(data_, function (r) {
3436
                                return r.DisplayValue == '1'
3437
                            });
3438
                            code_ = code[0].FieldName;
3439
                            desc_ = desc[0].FieldName;
3440

    
3441
                            if (code) {
3442
                                Ext.Ajax.request({
3443
                                    async: false,
3444
                                    method: 'POST',
3445
                                    url: '/UserControl/GetStore',
3446
                                    params: {
3447
                                        tableName: structure_[0].TableRef,
3448
                                        param: code_ + '[equal]' + oldVlaue
3449
                                    },
3450
                                    success: function (response) {
3451
                                        var results = Ext.decode(response.responseText);
3452
                                        var val = results.data[0];
3453
                                        _val = 'val.' + desc_;
3454
                                        hasil = eval(_val)
3455
                                    }
3456
                                });
3457
                            }
3458

    
3459
                        }
3460
                    });
3461
                }
3462
            } else {
3463
                hasil = oldVlaue;
3464
            }
3465

    
3466
            break
3467

    
3468
    }
3469
    return hasil;
3470
}
3471

    
3472
MinovaUtil.FieldGenerator.BuildHTMLFormView = function (menuid, tableName) {
3473
    var param = '';
3474
    var LangID = '';
3475
    var dataSet = 'PDSBS0007';
3476
    if (menuid != '') {
3477
        param = 'MenuID[=]' + menuid + ',LangId[=]' + LangID;
3478
        dataSet = 'PDSBS0009';
3479
    } else {
3480
        param = "LangID='" + LangID + "',TableName='" + tableName
3481
    }
3482

    
3483
    // get data field structure
3484
    var structure = undefined;
3485
    Ext.Ajax.request({
3486
        async: false,
3487
        method: 'POST',
3488
        url: '/UserControl/GetStore',
3489
        params: {
3490
            tableName: dataSet,
3491
            param: param
3492
        },
3493
        success: function (response) {
3494
            structure = Ext.decode(response.responseText).data;
3495

    
3496
        }
3497
    });
3498

    
3499
    //create html component
3500
    var col = '1';
3501
    var index1 = 0;
3502
    var index2 = 0;
3503
    var jmlhData = structure.length;
3504
    var jmlCol1 = 0;
3505
    var jmlCol2 = 0;
3506
    var dataCol1 = null;
3507
    var dataCol2 = null;
3508
    var countCol1 = 0;
3509
    var countCol2 = 0;
3510
    if (dataSet == 'PDSBS0009') {
3511
        dataCol1 = $.grep(structure, function (r) {
3512
            return r.Column == '1'
3513
        });
3514
        jmlCol1 = dataCol1.length;
3515
        dataCol2 = $.grep(structure, function (r) {
3516
            return r.Column == '2'
3517
        });
3518
        jmlCol2 = dataCol2.length;
3519
    } else {
3520
        dataCol1 = $.grep(structure, function (r) {
3521
            return r.ColumnNo == '1'
3522
        });
3523
        jmlCol1 = dataCol1.length;
3524
        dataCol2 = $.grep(structure, function (r) {
3525
            return r.ColumnNo == '2'
3526
        });
3527
        jmlCol2 = dataCol2.length;
3528
    }
3529

    
3530
    var item_ = null;
3531
    for (i = 0; i < jmlhData; i++) {
3532
        if (i == 0) {
3533
            var dt = dataCol1[countCol1];
3534
            var dt = dataCol1[countCol1];
3535
            var labelId = dt.FieldName + 'id';
3536
            var labelValue = dt.ScreenCaption;
3537
            var valueId = dt.FieldName;
3538
            var valueField = '';
3539
            item_ = "<div class='col-md-6'> <div class='form-group'>"
3540
				 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3541
				 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3542
				 + valueField + " </div> </div> </div>";
3543

    
3544
            countCol1++;
3545
            col = '2';
3546
        } else {
3547
            if (col == '1' && countCol1 < jmlCol1) {
3548
                var dt = dataCol1[countCol1];
3549
                var labelId = dt.FieldName + 'id';
3550
                var labelValue = dt.ScreenCaption;
3551
                var valueId = dt.FieldName;
3552
                var valueField = '';
3553

    
3554
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3555
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3556
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3557
					 + valueField + " </div> </div> </div>";
3558

    
3559
                countCol1++;
3560
                col = '2';
3561
            } else if (col == '2' && countCol2 < jmlCol2) {
3562
                var dt = dataCol2[countCol2];
3563
                var dt = dataCol1[countCol1];
3564
                var labelId = dt.FieldName + 'id';
3565
                var labelValue = dt.ScreenCaption;
3566
                var valueId = dt.FieldName;
3567
                var valueField = '';
3568
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3569
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3570
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3571
					 + valueField + " </div> </div> </div>";
3572

    
3573
                countCol2++;
3574
                col = '1';
3575
            } else {
3576
                // create empety field
3577
                var labelId = 'EmpetyID';
3578
                var labelValue = '';
3579
                var valueId = 'EmpetyField';
3580
                var valueField = '';
3581
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3582
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3583
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3584
					 + valueField + " </div> </div> </div>";
3585
                //change base value
3586
                if (col == '1') {
3587
                    col = '2';
3588
                    countCol1++;
3589
                } else {
3590
                    col = '1';
3591
                    countCol2++
3592
                }
3593
            }
3594
        }
3595
        // add to form
3596
        if (dataSet == 'PDSBS0009') { //
3597
            $("#formHeaderMD").append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3598
        } else {
3599
            $("#formViewMD").append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3600
        }
3601
    }
3602

    
3603
}
3604

    
3605
/*Fungsi untuk Report Generator	*/
3606
MinovaUtil.FieldGenerator.ReportGenerator = function (tableName, store, filter, divid) {
3607
    Ext.create('MinovaUtil.MinovaES.MinovaRptGeneratorGrid', {
3608
        renderTo: divid,
3609
        name: 'result' + tableName,
3610
        storeOutput: store,
3611
        storeName: 'store' + tableName,
3612
        filter: filter,
3613
        tableName: tableName,
3614
        pagesize: 25,
3615
        autoLoad: true,
3616
        height: 400,
3617
        tbar: [{
3618
            xtype: 'button',
3619
            text: 'Action',
3620
            name: 'actionBtn',
3621
            menu: [{
3622
                text: 'Save',
3623
                name: 'Save',
3624
                action: 'Save',
3625
                style: 'font-family: FontAwesome',
3626
                iconCls: 'fa-plus-circle',
3627
            }, {
3628
                text: 'Export Table',
3629
                name: 'ExportTable',
3630
                action: 'ExportTable',
3631
                style: 'font-family: FontAwesome',
3632
                iconCls: 'fa-file-excel-o',
3633
            }
3634
            ],
3635
            layout: {
3636
                type: 'vbox',
3637
                align: 'stretch',
3638
                padding: 5
3639
            }
3640
        }, {
3641
            xtype: 'displayfield',
3642
            value: (Ext.Date.format(new Date(), 'd/m/Y g:i a')),
3643
            id: 'cur_date',
3644
            margin: '0 0 0 810'
3645
        }
3646
        ],
3647
        dockedItems: [{
3648
            xtype: 'pagingtoolbar',
3649
            store: 'store' + tableName,
3650
            dock: 'bottom',
3651
            pageSize: 25,
3652
            displayInfo: true
3653
        }
3654
        ]
3655
    });
3656
}
(4-4/4)