Project

General

Profile

Support #1727 » MinovaUtil.FieldGenerator.js

Tri Rizqiaty, 11/17/2022 03:34 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
    if (rec.ReadOnly == '1') {
43
        ReadOnly_ = true;
44
    }
45

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

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

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

    
164
                //}),
165
                store: Ext.create('Ext.data.Store', {
166
                    storeId: 'storeDisplay' + rec.FieldName,
167
                    autoLoad: true,
168
                    //fields: ['MenuType', 'MenuDesc'],
169
                    proxy: {
170
                        method: 'POST',
171
                        async: false,
172
                        type: 'ajax',
173
                        url: '/UserControl/GetStore?tableName=' + rec.TableRef + '&param=' + objClass,
174

    
175
                        reader: {
176
                            type: 'json',
177
                            root: 'data'
178
                        }
179
                    }
180
                }),
181
                listeners: {
182

    
183
                    //	var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
184
                    //	Ext.Ajax.request({
185
                    //		method : 'POST',
186
                    //		async : true,
187
                    //		url : '/UserControl/GetStore',
188
                    //		params : {
189
                    //			tableName : rec.TableRef,
190
                    //			param : ''
191
                    //		},
192
                    //		success : function (response) {
193
                    //			var results = Ext.decode(response.responseText);
194
                    //			store.loadData(results.data);
195

    
196
                    //		}
197
                    //	});
198
                    //},
199
                    afterrenderer: function (f) {
200
                        var display = this.displayField;
201
                        var value = this.getValue();
202
                        var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
203
                        //store.load();
204
                        var r = store.findRecord(f.valueField, f.value)
205
                        if (r != null) {
206
                            f.setRawValue(r.get(f.displayField))
207
                        }
208
                    },
209

    
210
                    change: function (f) {
211
                        //alert(this.valueField, value);
212
                        var display = this.displayField;
213
                        var objClass = this.objClass;
214
                        //var field_ = Ext.ComponentQuery.query('[name=' + rec.FieldName + ']')[0];
215
                        var field_ = this;
216
                        var sdateVal = MinovaUtil.GetNowDate();
217
                        if (Ext.ComponentQuery.query('displayfield[name=StartDate]')[0]) {
218
                            sdateVal = Ext.ComponentQuery.query('displayfield[name=StartDate]')[0].getValue();
219
							sdateVal_=sdateVal.substring(6,10)+sdateVal.substring(3,5)+sdateVal.substring(0,2);
220
							sdateVal=sdateVal_;
221
                        }
222
                        var comboParam = field_.comboParam;
223
                        comboParam = comboParam + ',StartDate[<=]' + sdateVal + ',EndDate[>=]' + sdateVal
224
                        var value = this.getValue();
225
                        var store = Ext.StoreMgr.lookup('storeDisplay' + rec.FieldName);
226
                        if (store.data.length == 0) {
227
                            Ext.Ajax.request({
228
                                method: 'POST',
229
                                async: false,
230
                                url: '/UserControl/GetStore',
231
                                params: {
232
                                    tableName: rec.TableRef,
233
                                    param: f.valueField + '[=]' + field_.getValue() + ',' + comboParam
234
                                },
235
                                success: function (response) {
236
                                    var results = Ext.decode(response.responseText);
237
                                    var data_ = results.data;
238
                                    if (data_.length > 0) {
239
                                        var dt = eval('data_[0].' + field_.displayField);
240
                                        field_.setRawValue(dt);
241

    
242
                                    }
243

    
244
                                }
245
                            });
246

    
247
                        } else {
248
                            var r = store.findRecord(f.valueField, f.value)
249
                            if (r != null) {
250
                                f.setRawValue(r.get(f.displayField))
251
                            }
252

    
253
                        }
254

    
255
                    }
256

    
257
                },
258
                queryMode: 'local',
259
                displayField: displayValue,
260
                valueField: valueField,
261
            });
262
        } else {
263
            switch (rec.FormatRef) {
264
                //case 'date':
265
                //    formfield = new Ext.form.Display({
266
                //        ieldBodyCls: 'x-form-trigger-wrap-minova',
267
                //        labelCls: 'label-minova',
268
                //        labelWidth: lw,
269
                //        hidden: Hidden_,
270
                //        fieldLabel: rec.ScreenCaption,
271
                //        name: rec.FieldName,
272
                //        value: rec.DefaultValue,
273
                //        IsPrimaryKey: rec.IsPrimaryKey,
274
                //        padding: 0,
275
                //        anchor: '100%',
276
                //        listeners: {
277
                //            change: function (f) {
278
                //                var value_ = f.getValue();
279
                //                if (value_ != '' && value_ != undefined && value_.length == 8) {
280
                //                    f.setValue(value_.substring(6, 8) + '/' + value_.substring(4, 6) + '/' + value_.substring(0, 4))
281
                //                }
282
                //            }
283
                //        }
284
                //    });
285
                //    break;
286
                case 'date':
287
                    formfield = new Ext.form.Display({
288
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
289
                        labelCls: 'label-minova',
290
                        labelWidth: lw,
291
                        hidden: Hidden_,
292
                        fieldLabel: rec.ScreenCaption,
293
                        name: rec.FieldName,
294
                        value: defaultValue,
295
                        IsPrimaryKey: rec.IsPrimaryKey,
296
                        padding: 0,
297
                        anchor: '100%',
298
                        readOnly: ReadOnly_,
299
                        listeners: {
300
                            change: function (f) {
301
                                var value_ = f.getValue();
302
                                if (value_ != '' && value_ != undefined && value_.length == 8) {
303
                                    f.setValue(value_.substring(6, 8) + '/' + value_.substring(4, 6) + '/' + value_.substring(0, 4))
304
                                }
305
                            }
306
                        }
307
                    });
308
                    break;
309
                case 'datetime':
310
                    formfield = new Ext.form.Display({
311
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
312
                        labelCls: 'label-minova',
313
                        labelWidth: lw,
314
                        hidden: Hidden_,
315
                        fieldLabel: rec.ScreenCaption,
316
                        name: rec.FieldName,
317
                        value: defaultValue,
318
                        IsPrimaryKey: rec.IsPrimaryKey,
319
                        padding: 0,
320
                        readOnly: ReadOnly_,
321
                        anchor: '100%',
322
                        listeners: {
323
                            change: function (f) {
324
                                var value_ = f.getValue();
325
                                if (value_ != '' && value_ != undefined && value_.length == 14) {
326
                                    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))
327
                                }
328
                            }
329
                        }
330
                    });
331
                    break
332
                case "amountencrypt":
333
                    formfield = new Ext.form.Display({
334
                        fieldBodyCls: 'x-form-trigger-wrap-minova',
335
                        labelCls: 'label-minova',
336
                        labelWidth: lw,
337
                        hidden: Hidden_,
338
                        fieldLabel: rec.ScreenCaption,
339
                        name: rec.FieldName,
340
                        value: defaultValue,
341
                        fieldStyle: 'text-align:right;',
342
                        IsPrimaryKey: rec.IsPrimaryKey,
343
                        padding: 0,
344
                        readOnly: ReadOnly_,
345
                        anchor: '100%',
346
                        isEncryptDisplay: true,
347
                        nameTable: tbl
348
                    });
349
                    break
350
                default:
351
                    if (rec.FixedValue == '') {
352
                        formfield = new Ext.form.Display({
353
                            fieldBodyCls: 'x-form-trigger-wrap-minova',
354
                            labelCls: 'label-minova',
355
                            labelWidth: lw,
356
                            hidden: Hidden_,
357
                            readOnly: ReadOnly_,
358
                            fieldLabel: rec.ScreenCaption,
359
                            name: rec.FieldName,
360
                            value: defaultValue,
361
                            IsPrimaryKey: rec.IsPrimaryKey,
362
                            padding: 0,
363
                            anchor: '100%',
364

    
365
                        });
366
                    } else {
367
                        formfield = new Ext.form.Display({
368
                            fieldBodyCls: 'x-form-trigger-wrap-minova',
369
                            labelCls: 'label-minova',
370
                            labelWidth: lw,
371
                            hidden: Hidden_,
372
                            readOnly: ReadOnly_,
373
                            fieldLabel: rec.ScreenCaption,
374
                            name: rec.FieldName,
375
                            value: defaultValue,
376
                            IsPrimaryKey: rec.IsPrimaryKey,
377
                            padding: 0,
378
                            anchor: '100%',
379
                            fixedValue: rec.FixedValue,
380
                            cek: true,
381
                            listeners: {
382

    
383
                                change: function (val) {
384
                                    if (val.cek) {
385
                                        var valueField = val.getValue();
386
                                        var fixed = val.fixedValue;
387
                                        var hasil = fixed.split('||');
388
                                        var code = '';
389
                                        hasil.forEach(function (h) {
390
                                            store_ = h.split('=')
391
                                            //storeData.push({
392
                                            //    code: store_[0],
393
                                            //    desc: store_[1],
394

    
395
                                            //});
396
                                            code = store_[0]
397
                                            if (code == valueField) {
398
                                                val.setValue(store_[1]);
399
                                                val.cek = false;
400
                                            }
401
                                        });
402
                                    }
403
                                }
404
                            }
405
                        });
406
                    }
407
                    break;
408
            }
409
        }
410

    
411
    } else {
412
        switch (rec.FormatRef) {
413
			case "area":
414
			    formfield = new Ext.form.TextArea({
415
                            allowBlank: null_,
416
                            fieldLabel: rec.ScreenCaption,
417
                            readOnly: ReadOnly_,
418
                            readOnlyCls: 'minova-readonly',
419
                            labelCls: 'label-minova',
420
                            labelWidth: lw,
421
                            hidden: Hidden_,
422
                            name: rec.FieldName,
423
                            msgTarget: 'side',
424
                            value: defaultValue,
425
                            IsPrimaryKey: rec.IsPrimaryKey,
426
                            maxLength: rec.Length,
427
                            anchor: '100%',
428
                            formname: formname,
429
                            vtype: 'validateMinovaXss',
430
                            nameTable: tbl,
431
                            listeners: {
432

    
433
                                change: function (val) {
434
                                    var _label = val.name;
435
                                    var _form = val.formname;
436
                                    var _Value = val.getValue();
437
                                    var target = rec.TriggerCombo;
438
                                    var custumFunc = rec.SelectFunction;
439
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
440
                                        Ext.Ajax.request({
441
                                            async: false,
442
                                            method: 'POST',
443
                                            url: '/UserControl/GetStore',
444
                                            params: {
445
                                                tableName: 'PCMFUNC',
446
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
447
                                            },
448
                                            success: function (response) {
449
                                                var results = Ext.decode(response.responseText);
450
                                                data_ = results.data[0];
451
                                                if (data_ != undefined) {
452
                                                    custumFunc = data_.FunctionCode;
453
                                                }
454
                                            }
455
                                        });
456
                                    }
457
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
458
                                    if (frm) {
459

    
460
                                        if (target) {
461
                                            var f = frm.getForm().findField(target)
462
                                            _store = f.getStore();
463
                                            var _tbl = _store.proxy.extraParams.tableName;
464
                                            var oldParam = _store.proxy.extraParams.param;
465
                                            _store.proxy.extraParams = {
466
                                                tableName: _tbl,
467
                                                param: _label + '[=]' + _Value
468
                                            };
469
                                            _store.load();
470
                                        }
471

    
472
                                        if (custumFunc) {
473
                                            eval(custumFunc)
474
                                        }
475

    
476
                                    }
477

    
478
                                },
479

    
480
                            },
481
                        });
482
                    break
483
            case "date":
484
                if (rec.FieldName == 'StartDate' || rec.FieldName == 'EndDate' || rec.FieldName == 'ValidFrom' || rec.FieldName == 'ValidThrough') {
485
                    formfield = new Ext.form.DateField({
486
                        allowBlank: null_,
487
                        readOnlyCls: 'minova-readonly',
488
                        fieldLabel: rec.ScreenCaption,
489
                        readOnly: ReadOnly_,
490
                        msgTarget: 'side',
491
                        hidden: Hidden_,
492
                        labelCls: 'label-minova',
493
                        labelWidth: lw,
494
                        name: rec.FieldName,
495
                        format: 'd/m/Y',
496
                        submitFormat: 'Ymd',
497
                        IsPrimaryKey: rec.IsPrimaryKey,
498
                        value: defaultValue,
499
                        anchor: '100%',
500
                        vtype: 'daterange',
501
                        start: start_,
502
                        end: end_,
503
                        pnl: formname,
504
                        formname: formname,
505
                        nameTable: tbl,
506
                        hideMode: 'visibility',
507
                        listeners: {
508

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

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

    
548
                                    if (custumFunc) {
549
                                        eval(custumFunc)
550
                                    }
551

    
552
                                }
553

    
554
                            },
555

    
556
                        },
557
                    });
558
                } else {
559
                    formfield = new Ext.form.DateField({
560
                        allowBlank: null_,
561
                        fieldLabel: rec.ScreenCaption,
562
                        readOnlyCls: 'minova-readonly',						
563
                        readOnly: ReadOnly_,
564
                        msgTarget: 'side',
565
                        labelCls: 'label-minova',
566
                        labelWidth: lw,
567
                        hidden: Hidden_,
568
                        name: rec.FieldName,
569
						format: 'd/m/Y',
570
                        submitFormat: 'Ymd',
571
                        value: defaultValue,
572
                        IsPrimaryKey: rec.IsPrimaryKey,
573
                        anchor: '100%',
574
                        formname: formname,
575
                        nameTable: tbl,
576
                        hideMode: 'visibility',
577
                        listeners: {
578

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

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

    
618
                                    if (custumFunc) {
619
                                        eval(custumFunc)
620
                                    }
621

    
622
                                }
623

    
624
                            },
625

    
626
                        },
627
                    });
628
                }
629

    
630
                break
631
            case "time":
632
                if (defaultValue == '') {
633
                    defaultValue = '00:00';
634
                }
635
                formfield = new Ext.form.TimeField({
636
                    allowBlank: null_,
637
                    fieldLabel: rec.ScreenCaption,
638
                    readOnlyCls: 'minova-readonly',
639
                    readOnly: ReadOnly_,
640
                    labelCls: 'label-minova',
641
                    labelWidth: lw,
642
                    hidden: Hidden_,
643
                    name: rec.FieldName,
644
                    msgTarget: 'side',
645
                    format: 'H:i',
646
                    submitFormat: 'Hi',
647
                    increment: 5,
648
                    value: defaultValue,
649
                    IsPrimaryKey: rec.IsPrimaryKey,
650
                    anchor: '100%',
651
                    formname: formname,
652
                    nameTable: tbl,
653
                    //vtype: 'validateMinovaTime',
654
                    maxLength: 5,
655
                    minLength: 5,
656
                    listeners: {
657

    
658
                        change: function (val) {
659
                            var rv = this.rawValue;
660
                            var me_ = this;
661
                            if (rv.length == 4 && rv != '') {
662
                                var sp = rv.split(':')
663
                                if (sp.length == 1) {
664
                                    me_.setValue(rv.substring(0, 2) + ':' + rv.substring(2, 4));
665
                                }
666
                            }
667
                            var _label = val.name;
668
                            var _form = val.formname;
669
                            var _Value = val.getValue();
670
                            var target = rec.TriggerCombo;
671
                            var custumFunc = rec.SelectFunction;
672
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
673
                                Ext.Ajax.request({
674
                                    async: false,
675
                                    method: 'POST',
676
                                    url: '/UserControl/GetStore',
677
                                    params: {
678
                                        tableName: 'PCMFUNC',
679
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
680
                                    },
681
                                    success: function (response) {
682
                                        var results = Ext.decode(response.responseText);
683
                                        data_ = results.data[0];
684
                                        if (data_ != undefined) {
685
                                            custumFunc = data_.FunctionCode;
686
                                        }
687
                                    }
688
                                });
689
                            }
690
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
691
                            if (frm) {
692

    
693
                                if (target) {
694
                                    var f = frm.getForm().findField(target)
695
                                    _store = f.getStore();
696
                                    var _tbl = _store.proxy.extraParams.tableName;
697
                                    var oldParam = _store.proxy.extraParams.param;
698
                                    _store.proxy.extraParams = {
699
                                        tableName: _tbl,
700
                                        param: _label + '[=]' + _Value
701
                                    };
702
                                    _store.load();
703
                                }
704

    
705
                                if (custumFunc) {
706
                                    eval(custumFunc)
707
                                }
708

    
709
                            }
710

    
711
                        },
712

    
713
                    },
714
                });
715
                break
716
            case "password":
717
                min_ = 1;
718
                max_ = 8;
719
                Ext.Ajax.request({
720
                    async: false,
721
                    method: 'POST',
722
                    url: '/UserControl/GetStore',
723
                    params: {
724
                        tableName: 'PCMEPAPPCONFIG',
725
                        param: 'Active[equal]1'
726
                    },
727
                    success: function (response) {
728
                        var results = Ext.decode(response.responseText);
729
                        data_ = results.data;
730
                        if (data_ != undefined) {
731
                            _min = $.grep(data_, function (r) {
732
                                return r.ConfigName == 'SYSPWDMINLENGTH'
733
                            });
734
                            max_ = _min[0].Value;
735
                            _max = $.grep(data_, function (r) {
736
                                return r.ConfigName == 'SYSPWDMAXLENGTH'
737
                            });
738
                            max_ = _max[0].Value;
739

    
740
                        }
741
                    }
742
                });
743
                formfield = new Ext.form.TextField({
744
                    allowBlank: null_,
745
                    inputType: 'password',
746
                    fieldLabel: rec.ScreenCaption,
747
                    readOnlyCls: 'minova-readonly',
748
                    readOnly: ReadOnly_,
749
                    labelCls: 'label-minova',
750
                    labelWidth: lw,
751
                    hidden: Hidden_,
752
                    name: rec.FieldName,
753
                    msgTarget: 'side',
754
                    value: defaultValue,
755
                    IsPrimaryKey: rec.IsPrimaryKey,
756
                    anchor: '100%',
757
                    formname: formname,
758
                    vtype: 'minovaPassword',
759
                    //vtype: 'passwordConfirm',
760
                    initialPassField: 'RePasword',
761
                    maxLength: max_,
762
                    minLength: min_,
763
                    nameTable: tbl,
764
                    listeners: {
765

    
766
                        change: function (val) {
767
                            var _label = val.name;
768
                            var _form = val.formname;
769
                            var _Value = val.getValue();
770
                            var target = rec.TriggerCombo;
771
                            var custumFunc = rec.SelectFunction;
772
                            if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
773
                                Ext.Ajax.request({
774
                                    async: false,
775
                                    method: 'POST',
776
                                    url: '/UserControl/GetStore',
777
                                    params: {
778
                                        tableName: 'PCMFUNC',
779
                                        param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
780
                                    },
781
                                    success: function (response) {
782
                                        var results = Ext.decode(response.responseText);
783
                                        data_ = results.data[0];
784
                                        if (data_ != undefined) {
785
                                            custumFunc = data_.FunctionCode;
786
                                        }
787
                                    }
788
                                });
789
                            }
790
                            var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
791
                            if (frm) {
792

    
793
                                if (target) {
794
                                    var f = frm.getForm().findField(target)
795
                                    _store = f.getStore();
796
                                    var _tbl = _store.proxy.extraParams.tableName;
797
                                    var oldParam = _store.proxy.extraParams.param;
798
                                    _store.proxy.extraParams = {
799
                                        tableName: _tbl,
800
                                        param: _label + '[=]' + _Value
801
                                    };
802
                                    _store.load();
803
                                }
804

    
805
                                if (custumFunc) {
806
                                    eval(custumFunc)
807
                                }
808

    
809
                            }
810

    
811
                        },
812

    
813
                    },
814
                });
815
                break
816
            case "repassword":
817

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

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

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

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

    
881
                            }
882

    
883
                        },
884

    
885
                    },
886
                });
887
                break
888
            case "number":
889

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

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

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

    
948
                                if (custumFunc) {
949
                                    eval(custumFunc)
950
                                }
951

    
952
                            }
953

    
954
                        },
955

    
956
                    },
957
                });
958
                break
959
            case "alfa":
960

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

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

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

    
1018
                                if (custumFunc) {
1019
                                    eval(custumFunc)
1020
                                }
1021

    
1022
                            }
1023

    
1024
                        },
1025

    
1026
                    },
1027
                });
1028
                break
1029
            case "amount":
1030
                formfield = new Ext.form.TextField({
1031
                    allowBlank: null_,
1032
                    fieldLabel: rec.ScreenCaption,
1033
                    readOnly: ReadOnly_,
1034
                    readOnlyCls: 'minova-readonly',
1035
                    labelCls: 'label-minova',
1036
                    labelWidth: lw,
1037
                    hidden: Hidden_,
1038
                    name: rec.FieldName,
1039
                    fieldStyle: 'text-align:right;',
1040
                    msgTarget: 'side',
1041
                    IsPrimaryKey: rec.IsPrimaryKey,
1042
                    value: defaultValue,
1043
                    maxLength: rec.Length,
1044
                    anchor: '100%',
1045
                    formname: formname,
1046
                    nameTable: tbl,
1047
                    listeners: {
1048

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

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

    
1088
                                if (custumFunc) {
1089
                                    eval(custumFunc)
1090
                                }
1091

    
1092
                            }
1093

    
1094
                        },
1095

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

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

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

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

    
1164
                            }
1165

    
1166
                        },
1167

    
1168
                    },
1169

    
1170
                });
1171
                break
1172
            case "monthpicker":
1173
                formfield = new MinovaUtil.MinovaES.MinovaMonthPicker({
1174
                    tableName: undefined,
1175
                    allowBlank: null_,
1176
                    fieldLabel: rec.ScreenCaption,
1177
                    readOnly: ReadOnly_,
1178
                    readOnlyCls: 'minova-readonly',
1179
                    hidden: Hidden_,
1180
                    msgTarget: 'side',
1181
                    param: undefined,
1182
                    name: rec.FieldName,
1183
                    formtarget_: rec.FieldName,
1184
                    fieldname: rec.FieldName,
1185
                    IsPrimaryKey: rec.IsPrimaryKey,
1186
                    Sequence: rec.Sequence,
1187
                    labelCls: 'label-minova',
1188
                    vtype: 'validateMinovaXss',
1189
                    nameTable: tbl,
1190
                    listeners: {
1191

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

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

    
1231
                                if (custumFunc) {
1232
                                    eval(custumFunc)
1233
                                }
1234

    
1235
                            }
1236

    
1237
                        },
1238

    
1239
                    },
1240
                })
1241
                break
1242
            case "file":
1243
                //update by hamid 12012017
1244
                formfield = new MinovaUtil.MinovaES.UploadFile({
1245
                    allowBlank: null_,
1246
                    fieldLabel: rec.ScreenCaption,
1247
                    readOnly: ReadOnly_,
1248
                    readOnlyCls: 'minova-readonly',
1249
                    hidden: Hidden_,
1250
                    labelCls: 'label-minova',
1251
                    name: rec.FieldName,
1252
                    msgTarget: 'side',
1253
                    fieldname: rec.FieldName,
1254
                    IsPrimaryKey: rec.IsPrimaryKey,
1255
                    tableName: rec.TableRef, //name tabel yang jadi ref-nya
1256
                    triggerCls: 'x-form-search-trigger',
1257
                    //vtype : 'alphanum', // disable space
1258
                    formtarget: formname, // nama form  yang akan di set value-nya
1259
                    //isLookup: isLookup,
1260
                    anchor: '100%',
1261
                    formname: formname,
1262
                    vtype: 'validateMinovaXss',
1263
                    nameTable: tbl,
1264
                    maxFileSize:rec.SearchFunction,
1265
                    listeners: {
1266

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

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

    
1306
                                if (custumFunc) {
1307
                                    eval(custumFunc)
1308
                                }
1309

    
1310
                            }
1311

    
1312
                        },
1313

    
1314
                    },
1315

    
1316
                });
1317
                break
1318
            case "html": {
1319
                formfield = new Ext.form.TextArea({
1320
                    allowBlank: null_,
1321
                    fieldLabel: rec.ScreenCaption,
1322
                    readOnly: ReadOnly_,
1323
                    readOnlyCls: 'minova-readonly',
1324
                    labelCls: 'label-minova',
1325
                    labelWidth: lw,
1326
                    hidden: Hidden_,
1327
                    name: rec.FieldName,
1328
                    msgTarget: 'side',
1329
                    value: defaultValue,
1330
                    IsPrimaryKey: rec.IsPrimaryKey,
1331
                    maxLength: rec.Length,
1332
                    anchor: '100%',
1333
                    formname: formname,
1334
                    //vtype: 'validateMinovaXss',
1335
                    nameTable: tbl,
1336
                    listeners: {
1337

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

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

    
1377
                                if (custumFunc) {
1378
                                    eval(custumFunc)
1379
                                }
1380

    
1381
                            }
1382

    
1383
                        },
1384

    
1385
                    },
1386
                });
1387
            }
1388
            default:
1389

    
1390
                if (rec.SearchType != '') {
1391
                    if (rec.SearchType == '3') { // lookup tree grid
1392
                        var objClass = rec.ParamCombo;
1393
                        var splitClass = objClass.split("]");
1394
                        var objParent = '';
1395
                        var objClassValueTarget = '';
1396
                        if (splitClass.length == 1) {
1397
                            objClassValueTarget = splitClass[0];
1398
                        } else {
1399
                            if (splitClass.length > 1) {
1400
                                objClassValueTarget = splitClass[1];
1401
                            }
1402
                        }
1403
                        var rel = rec.SearchFunction;
1404
                        var relSplit = rel.split('-');
1405
                        objParent = relSplit[0];
1406
                        var valFilter = relSplit.filter(MinovaUtil.RemoveDuplicateArray);
1407
                        formfield = new MinovaUtil.MinovaES.MinovaLookupTree({
1408
                            allowBlank: null_,
1409
                            fieldLabel: rec.ScreenCaption,
1410
                            readOnly: ReadOnly_,
1411
                            readOnlyCls: 'minova-readonly',
1412
                            IsPrimaryKey: rec.IsPrimaryKey,
1413
                            labelCls: 'label-minova',
1414
                            labelWidth: lw,
1415
                            hidden: Hidden_,
1416
                            name: rec.FieldName,
1417
                            msgTarget: 'side',
1418
                            triggerCls: 'x-form-search-trigger',
1419
                            //vtype: 'alphanum', // disable space
1420
                            treeSructure: rec.SearchFunction, //'O-O-P',
1421
                            objClassValue: objClassValueTarget, //'O',
1422
                            objParent: objParent,
1423
                            objFilter: valFilter,
1424
                            formname: formname,
1425
                            targetField: rec.FieldName,
1426
                            anchor: '100%',
1427
                            formname: formname,
1428
                            nameTable: tbl,
1429
                            //vtype: 'validateLookupTree',
1430
                            editable: false,
1431
                            listeners: {
1432
                                change: function (val) {
1433
                                    // alert('a')
1434
									var me=val;
1435
									var valueFiled=val.getValue();
1436
									if(valueFiled.split('-').length == 1 && valueFiled != '' && valueFiled !='a' ){
1437
										 Mainform = Ext.ComponentQuery.query('[name=' + me.formname + ']')[0].getForm();
1438
										 var _StartDate = MinovaUtil.GetNowDate();
1439
										if (Mainform) {
1440
											if (Mainform.findField('StartDate')) {
1441
												_StartDate = Mainform.findField('StartDate').getValue();
1442
											}
1443
										}
1444
										Ext.Ajax.request({
1445
											async : false,
1446
											method : 'POST',
1447
											url : '/UserControl/GetStore',
1448
											params : {
1449
												tableName : 'PHROM0001',
1450
												param : 'ObjectClass[=]'+me.objClassValue+',ObjectID[=]'+valueFiled+',StartDate[<=]'+_StartDate+',EndDate[>=]'+_StartDate
1451
											},
1452
											success : function (response) {
1453
												var results = Ext.decode(response.responseText);
1454
												data_ = results.data
1455
													if (data_.length > 0) {
1456
														me.setValue(valueFiled + ' - ' + data_[0].ObjectDescription)
1457

    
1458
													}
1459
											}
1460
										});
1461
									}
1462
                                },
1463
                                focus: function (val) {
1464
                                    // alert('focus')
1465
                                },
1466
                                blur: function (val) {
1467
                                    //             alert('focus')
1468
                                    var _label = val.name;
1469
                                    var _form = val.formname;
1470
                                    var _Value = val.getValue();
1471
                                    var target = rec.TriggerCombo;
1472
                                    var custumFunc = rec.SelectFunction;
1473
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1474
                                        Ext.Ajax.request({
1475
                                            async: false,
1476
                                            method: 'POST',
1477
                                            url: '/UserControl/GetStore',
1478
                                            params: {
1479
                                                tableName: 'PCMFUNC',
1480
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1481
                                            },
1482
                                            success: function (response) {
1483
                                                var results = Ext.decode(response.responseText);
1484
                                                data_ = results.data[0];
1485
                                                if (data_ != undefined) {
1486
                                                    custumFunc = data_.FunctionCode;
1487
                                                }
1488
                                            }
1489
                                        });
1490
                                    } else {
1491
                                        eval(custumFunc);
1492
                                    }
1493
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1494
                                    if (frm) {
1495

    
1496
                                        if (target) {
1497
                                            var f = frm.getForm().findField(target)
1498
                                            _store = f.getStore();
1499
                                            var _tbl = _store.proxy.extraParams.tableName;
1500
                                            var oldParam = _store.proxy.extraParams.param;
1501
                                            _store.proxy.extraParams = {
1502
                                                tableName: _tbl,
1503
                                                param: _label + '[=]' + _Value
1504
                                            };
1505
                                            _store.load();
1506
                                        }
1507

    
1508
                                        if (custumFunc) {
1509
                                            eval(custumFunc)
1510
                                        }
1511

    
1512
                                    }
1513

    
1514
                                },
1515

    
1516
                            },
1517

    
1518
                        });
1519
                    }
1520
                    if (rec.TableRef != "") {
1521
                        if (rec.SearchType == '0') {
1522
                            valueField = null;
1523
                            displayValue = null;
1524
                            Ext.Ajax.request({
1525
                                async: false,
1526
                                method: 'POST',
1527
                                url: '/UserControl/GetStore',
1528
                                params: {
1529
                                    tableName: 'SDATATABLEFIELD',
1530
                                    param: 'TableName[equal]' + rec.TableRef
1531
                                },
1532
                                success: function (response) {
1533
                                    var results = Ext.decode(response.responseText);
1534
                                    data_ = results.data;
1535
                                    if (data_ != undefined) {
1536
                                        valueField_ = $.grep(data_, function (r) {
1537
                                            return r.ValueField == '1'
1538
                                        });
1539
                                        if (valueField_.length > 0) {
1540
                                            valueField = valueField_[0].FieldName
1541
                                        }
1542

    
1543
                                        displayValue_ = $.grep(data_, function (r) {
1544
                                            return r.DisplayValue == '1'
1545
                                        });
1546
                                        if (displayValue_.length > 0) {
1547
                                            displayValue = displayValue_[0].FieldName
1548
                                        }
1549

    
1550
                                    }
1551
                                }
1552
                            });
1553

    
1554
                            formfield = new Ext.form.ComboBox({
1555
                                allowBlank: null_,
1556
                                fieldLabel: rec.ScreenCaption,
1557
                                readOnlyCls: 'minova-readonly',
1558
                                //forceSelection : true,
1559
                                readOnly: ReadOnly_,
1560
                                labelCls: 'label-minova',
1561
                                labelWidth: lw,
1562
                                hidden: Hidden_,
1563
                                IsPrimaryKey: rec.IsPrimaryKey,
1564
                                msgTarget: 'side',
1565
                                name: rec.FieldName,
1566
                                value: defaultValue,
1567
                                formname: formname,
1568
                                validateOnChange: true,
1569
                                width: '95%',
1570
                                vtype: 'validateCombobox',
1571
                                store: Ext.create('Ext.data.Store', {
1572
                                    storeId: 'store' + rec.FieldName,
1573
                                    autoLoad: true,
1574
                                    proxy: {
1575
                                        async: false,
1576
                                        method: 'POST',
1577
                                        type: 'ajax',
1578
                                        url: '/UserControl/GetStoreAuth',
1579
                                        extraParams: {
1580
                                            tableName: rec.TableRef,
1581
                                            param: rec.ParamCombo,
1582
                                            menuId: MinovaUtil.GetMenuID()
1583
                                        },
1584
                                        reader: {
1585
                                            type: 'json',
1586
                                            root: 'data',
1587
                                            totalProperty: 'data[0].TotalCount'
1588
                                        }
1589
                                    }
1590
                                }),
1591
                                formtarget: formname,
1592
                                nameTable: tbl,
1593
                                listeners: {
1594
                                    afterrender: function (f) {
1595
                                        //var store_ = f.getStore();
1596
                                        //store_.load();
1597
                                    },
1598
                                    change: function (val) {
1599
                                        var _label = val.name;
1600
                                        var _form = val.formname;
1601
                                        var _Value = val.getValue();
1602
                                        var target = rec.TriggerCombo;
1603
                                        var custumFunc = rec.SelectFunction;
1604
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1605
                                            Ext.Ajax.request({
1606
                                                async: false,
1607
                                                method: 'POST',
1608
                                                url: '/UserControl/GetStore',
1609
                                                params: {
1610
                                                    tableName: 'PCMFUNC',
1611
                                                    param: 'FuncName[equal]' + custumFunc + ',Active[=]1'
1612
                                                },
1613
                                                success: function (response) {
1614
                                                    var results = Ext.decode(response.responseText);
1615
                                                    data_ = results.data[0];
1616
                                                    if (data_ != undefined) {
1617
                                                        custumFunc = data_.FunctionCode;
1618
                                                    }
1619
                                                }
1620
                                            });
1621
                                        }
1622
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1623
                                        if (frm) {console.log(target); console.log('nwh'); console.log(Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue());
1624

    
1625
                                            if (target) {
1626
												// edit by Tri nwh 20221109 start
1627
												if (target == 'AppraisalPeriod'){
1628
													if( tbl == 'PDSPM0001') 
1629
													{ console.log('jyp');
1630
														_store = frm.getForm().findField('AppraisalPeriod').getStore();
1631
														_store.proxy.extraParams = {
1632
															tableName: 'PCMAPPPERIOD',
1633
															param: 'Apptype[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()//val.valData
1634
														};
1635
													}
1636
													else if( tbl == 'PHRPA0047') 
1637
													{ console.log('ssh');
1638
														_store = frm.getForm().findField('AppraisalPeriod').getStore();
1639
														_store.proxy.extraParams = {
1640
															tableName: 'PCMAPPPERIOD',
1641
															param: 'Apptype[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()//val.valData
1642
														};
1643
													}
1644
													else 
1645
													{
1646
														var f = frm.getForm().findField(target)
1647
														_store = f.getStore();
1648
														var _tbl = _store.proxy.extraParams.tableName;
1649
														var oldParam = _store.proxy.extraParams.param;
1650
														_store.proxy.extraParams = {
1651
															tableName: _tbl,
1652
															param: _label + '[=]' + _Value,
1653
															menuId: MinovaUtil.GetMenuID()
1654
														};
1655
													}
1656
													_store.load();												
1657
												} // edit by Tri nwh 20221109
1658
												else {
1659
													var f = frm.getForm().findField(target)
1660
													_store = f.getStore();
1661
													var _tbl = _store.proxy.extraParams.tableName;
1662
													var oldParam = _store.proxy.extraParams.param;
1663
													_store.proxy.extraParams = {
1664
														tableName: _tbl,
1665
														param: _label + '[=]' + _Value,
1666
														menuId: MinovaUtil.GetMenuID()
1667
													};
1668
													_store.load();
1669
												}
1670
                                            }
1671

    
1672
                                            if (custumFunc) {
1673
                                                eval(custumFunc)
1674
                                            }
1675

    
1676
                                        }
1677

    
1678
                                    },
1679

    
1680
                                },
1681
                                queryMode: 'local',
1682
                                displayField: displayValue,
1683
                                valueField: valueField,
1684
                            });
1685

    
1686
                        } else if (rec.SearchType == '2') {
1687
                            formfield = new MinovaUtil.MinovaES.MinovaLookupGrid({
1688
                                allowBlank: null_,
1689
                                fieldLabel: rec.ScreenCaption,
1690
                                readOnly: ReadOnly_,
1691
                                readOnlyCls: 'minova-readonly',
1692
                                IsPrimaryKey: rec.IsPrimaryKey,
1693
                                msgTarget: 'side',
1694
                                labelCls: 'label-minova',
1695
                                //labelWidth : 250,
1696
                                hidden: Hidden_,
1697
                                name: rec.FieldName,
1698
                                tableName: rec.TableRef, //name tabel yang jadi ref-nya
1699
                                //triggerCls: 'x-form-search-trigger',
1700
                                //vtype: 'alphanum', // disable space
1701
                                vtype: 'validateMinovaXss',
1702
                                formtarget: formname, // nama form  yang akan di set value-nya
1703
                                anchor: '100%',
1704
                                formname: formname,
1705
                                nameTable: tbl,
1706
                                editable: false,
1707
								value: defaultValue,
1708
                                LookupFunction: rec.LookupFunction,
1709
                                listeners: {
1710

    
1711
                                    change: function (val) {
1712
                                        var _label = val.name;
1713
                                        var _form = val.formname;
1714
                                        var _Value = val.getValue();
1715
                                        var target = rec.TriggerCombo;
1716
                                        var custumFunc = rec.SelectFunction;
1717
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1718
                                            Ext.Ajax.request({
1719
                                                async: false,
1720
                                                method: 'POST',
1721
                                                url: '/UserControl/GetStore',
1722
                                                params: {
1723
                                                    tableName: 'PCMFUNC',
1724
                                                    param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1725
                                                },
1726
                                                success: function (response) {
1727
                                                    var results = Ext.decode(response.responseText);
1728
                                                    data_ = results.data[0];
1729
                                                    if (data_ != undefined) {
1730
                                                        custumFunc = data_.FunctionCode;
1731
                                                    }
1732
                                                }
1733
                                            });
1734
                                        }
1735
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1736
                                        if (frm) {
1737

    
1738
                                            if (target) {
1739
                                                var f = frm.getForm().findField(target)
1740
                                                _store = f.getStore();
1741
                                                var _tbl = _store.proxy.extraParams.tableName;
1742
                                                var oldParam = _store.proxy.extraParams.param;
1743
                                                _store.proxy.extraParams = {
1744
                                                    tableName: _tbl,
1745
                                                    param: _label + '[=]' + _Value
1746
                                                };
1747
                                                _store.load();
1748
                                            }
1749

    
1750
                                            if (custumFunc) {
1751
                                                eval(custumFunc)
1752
                                            }
1753

    
1754
                                        }
1755
                                        //set raw value
1756
                                        val.valData = val.getValue()
1757
                                        if (val.getValue() != "") {
1758
                                            data_ = undefined;
1759
                                            Ext.Ajax.request({
1760
                                                async: false,
1761
                                                method: 'POST',
1762
                                                url: '/UserControl/GetStore',
1763
                                                params: {
1764
                                                    tableName: 'PDSCMTABLE',
1765
                                                    param: val.tableName + ',' + val.getValue() + ',hasil'
1766
                                                },
1767
                                                success: function (response) {
1768
                                                    var results = Ext.decode(response.responseText);
1769
                                                    data_ = results.data;
1770
                                                    if (data_ != null) {
1771
                                                        if (data_.length > 0) {
1772
                                                            val.setRawValue(val.getValue() + ' - ' + data_[0].hasil)
1773

    
1774
                                                        }
1775
                                                    }
1776
                                                }
1777
                                            });
1778
                                        }
1779

    
1780
                                    },
1781

    
1782
                                },
1783
                            });
1784
                        } else if (rec.SearchType == '4' && isLookup != true) {
1785
                            formfield = new MinovaUtil.MinovaES.MinovaLookupEmployee({
1786
                                allowBlank: null_,
1787
                                fieldLabel: rec.ScreenCaption,
1788
                                readOnly: ReadOnly_,
1789
                                readOnlyCls: 'minova-readonly',
1790
                                hidden: Hidden_,
1791
                                labelCls: 'label-minova',
1792
                                name: rec.FieldName,
1793
                                msgTarget: 'side',
1794
                                fieldname: rec.FieldName,
1795
                                IsPrimaryKey: rec.IsPrimaryKey,
1796
                                tableName: rec.TableRef, //name tabel yang jadi ref-nya
1797
                                triggerCls: 'x-form-search-trigger',
1798
                                //vtype: 'alphanum', // disable space
1799
                                vtype: 'validateMinovaXss',
1800
                                formtarget: formname, // nama form  yang akan di set value-nya
1801
                                isLookup: isLookup,
1802
                                anchor: '100%',
1803
                                formname: formname,
1804
                                targetField: targetField_,
1805
                                fieldValue: fieldValue_,
1806
                                nameTable: tbl,
1807
                                value: defaultValue,
1808
                                LookupFunction: rec.LookupFunction,
1809
                                filterParam: rec.ParamCombo,
1810
                                listeners: {
1811

    
1812
                                    change: function (val) {
1813
                                        var _label = val.name;
1814
                                        var _form = val.formname;
1815
                                        var _Value = val.getValue();
1816
                                        var target = rec.TriggerCombo;
1817
                                        var custumFunc = rec.SelectFunction;
1818
                                        if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1819
                                            Ext.Ajax.request({
1820
                                                async: false,
1821
                                                method: 'POST',
1822
                                                url: '/UserControl/GetStore',
1823
                                                params: {
1824
                                                    tableName: 'PCMFUNC',
1825
                                                    param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1826
                                                },
1827
                                                success: function (response) {
1828
                                                    var results = Ext.decode(response.responseText);
1829
                                                    data_ = results.data[0];
1830
                                                    if (data_ != undefined) {
1831
                                                        custumFunc = data_.FunctionCode;
1832
                                                    }
1833
                                                }
1834
                                            });
1835
                                        }
1836
                                        var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1837
                                        if (frm) {
1838

    
1839
                                            if (target) {
1840
                                                var f = frm.getForm().findField(target)
1841
                                                _store = f.getStore();
1842
                                                var _tbl = _store.proxy.extraParams.tableName;
1843
                                                var oldParam = _store.proxy.extraParams.param;
1844
                                                _store.proxy.extraParams = {
1845
                                                    tableName: _tbl,
1846
                                                    param: _label + '[=]' + _Value
1847
                                                };
1848
                                                _store.load();
1849
                                            }
1850

    
1851
                                            if (custumFunc) {
1852
                                                eval(custumFunc)
1853
                                            }
1854

    
1855
                                        }
1856

    
1857
                                    },
1858

    
1859
                                },
1860
                            });
1861
                            //}
1862
                        }
1863

    
1864
                    }
1865
                } else {
1866

    
1867
                    if (rec.FixedValue != '') {
1868

    
1869
                        formfield = new MinovaUtil.MinovaES.MinovaFixValue({
1870
                            allowBlank: null_,
1871
                            fieldLabel: rec.ScreenCaption,
1872
                            readOnlyCls: 'minova-readonly',
1873
                            //forceSelection: true,
1874
                            readOnly: ReadOnly_,
1875
                            labelCls: 'label-minova',
1876
                            labelWidth: lw,
1877
                            hidden: Hidden_,
1878
                            name: rec.FieldName,
1879
                            msgTarget: 'side',
1880
                            IsPrimaryKey: rec.IsPrimaryKey,
1881
                            value: defaultValue,
1882
                            anchor: '100%',
1883
                            formname: formname,
1884
                            formtarget: formname,
1885
                            validateOnChange: true,
1886
                            fixedValue: rec.FixedValue,
1887
                            vtype: 'validateMinovaXss',
1888
                            nameTable: tbl,
1889
                            listeners: {
1890
                                change: function (val) {
1891
                                    var _label = val.name;
1892
                                    var _form = val.formtarget;
1893
                                    var _Value = val.getValue();
1894
                                    var target = rec.TriggerCombo;
1895
                                    var custumFunc = rec.SelectFunction;
1896

    
1897
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1898
                                    if (frm) {
1899

    
1900
                                        if (target) {
1901
                                            var f = frm.getForm().findField(target)
1902
                                            _store = f.getStore();
1903
                                            var _tbl = _store.proxy.extraParams.tableName;
1904
                                            var oldParam = _store.proxy.extraParams.param;
1905
                                            _store.proxy.extraParams = {
1906
                                                tableName: _tbl,
1907
                                                param: _label + '[=]' + _Value
1908
                                            };
1909
                                            // _store.proxy.extraParams = { tableName: _tbl, param: oldParam+','+_label + '[=]' + _Value };
1910
                                            _store.load();
1911
                                        }
1912

    
1913
                                        if (custumFunc) {
1914
                                            eval(custumFunc)
1915
                                        }
1916

    
1917
                                    }
1918

    
1919
                                }
1920

    
1921
                            },
1922
                            valueField: 'code',
1923
                            displayField: 'desc',
1924
                        });
1925
                    } else if (rec.Length > 250 && rec.TableRef == "") {
1926
                        formfield = new Ext.form.TextArea({
1927
                            allowBlank: null_,
1928
                            fieldLabel: rec.ScreenCaption,
1929
                            readOnly: ReadOnly_,
1930
                            readOnlyCls: 'minova-readonly',
1931
                            labelCls: 'label-minova',
1932
                            labelWidth: lw,
1933
                            hidden: Hidden_,
1934
                            name: rec.FieldName,
1935
                            msgTarget: 'side',
1936
                            value: defaultValue,
1937
                            IsPrimaryKey: rec.IsPrimaryKey,
1938
                            maxLength: rec.Length,
1939
                            anchor: '100%',
1940
                            formname: formname,
1941
                            vtype: 'validateMinovaXss',
1942
                            nameTable: tbl,
1943
                            listeners: {
1944

    
1945
                                change: function (val) {
1946
                                    var _label = val.name;
1947
                                    var _form = val.formname;
1948
                                    var _Value = val.getValue();
1949
                                    var target = rec.TriggerCombo;
1950
                                    var custumFunc = rec.SelectFunction;
1951
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
1952
                                        Ext.Ajax.request({
1953
                                            async: false,
1954
                                            method: 'POST',
1955
                                            url: '/UserControl/GetStore',
1956
                                            params: {
1957
                                                tableName: 'PCMFUNC',
1958
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
1959
                                            },
1960
                                            success: function (response) {
1961
                                                var results = Ext.decode(response.responseText);
1962
                                                data_ = results.data[0];
1963
                                                if (data_ != undefined) {
1964
                                                    custumFunc = data_.FunctionCode;
1965
                                                }
1966
                                            }
1967
                                        });
1968
                                    }
1969
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
1970
                                    if (frm) {
1971

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

    
1984
                                        if (custumFunc) {
1985
                                            eval(custumFunc)
1986
                                        }
1987

    
1988
                                    }
1989

    
1990
                                },
1991

    
1992
                            },
1993
                        });
1994
                    } else if (rec.FieldDataType == 3) {
1995
                        //defaultValue = rec.DefaultValue;
1996
                        if (defaultValue == null || defaultValue == "") {
1997
                            defaultValue = 0;
1998
                        }
1999
                        //formfield = new MinovaUtil.MinovaES.MinovaFloatField({
2000
                        formfield = new Ext.form.TextField({
2001
                            //formfield =MinovaUtil.MinovaES.MinovaDecimal({
2002
                            allowBlank: null_,
2003
                            fieldLabel: rec.ScreenCaption,
2004
                            readOnly: ReadOnly_,
2005
                            labelCls: 'label-minova',
2006
                            readOnlyCls: 'minova-readonly',
2007
                            labelWidth: lw,
2008
                            msgTarget: 'side',
2009
                            hidden: Hidden_,
2010
                            name: rec.FieldName,
2011
                            IsPrimaryKey: rec.IsPrimaryKey,
2012
                            value: defaultValue,
2013
                            maxLength: rec.Length,
2014
                            precision: rec.Prec,
2015
                            anchor: '100%',
2016
                            formname: formname,
2017
                            vtype: 'validateDecimal',
2018
                            //maskRe: '^[0-9]+(\.[0-9]{1,2})?$',
2019
                            nameTable: tbl,
2020
                            fieldStyle: 'text-align:right;',
2021
                            listeners: {
2022

    
2023
                                change: function (val) {
2024
                                    var _label = val.name;
2025
                                    var _form = val.formname;
2026
                                    var _Value = val.getValue();
2027

    
2028
                                    var target = rec.TriggerCombo;
2029
                                    var custumFunc = rec.SelectFunction;
2030
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2031
                                        Ext.Ajax.request({
2032
                                            async: false,
2033
                                            method: 'POST',
2034
                                            url: '/UserControl/GetStore',
2035
                                            params: {
2036
                                                tableName: 'PCMFUNC',
2037
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2038
                                            },
2039
                                            success: function (response) {
2040
                                                var results = Ext.decode(response.responseText);
2041
                                                data_ = results.data[0];
2042
                                                if (data_ != undefined) {
2043
                                                    custumFunc = data_.FunctionCode;
2044
                                                }
2045
                                            }
2046
                                        });
2047
                                    }
2048
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2049
                                    if (frm) {
2050

    
2051
                                        if (target) {
2052
                                            var f = frm.getForm().findField(target)
2053
                                            _store = f.getStore();
2054
                                            var _tbl = _store.proxy.extraParams.tableName;
2055
                                            var oldParam = _store.proxy.extraParams.param;
2056
                                            _store.proxy.extraParams = {
2057
                                                tableName: _tbl,
2058
                                                param: _label + '[=]' + _Value
2059
                                            };
2060
                                            _store.load();
2061
                                        }
2062

    
2063
                                        if (custumFunc) {
2064
                                            eval(custumFunc)
2065
                                        }
2066

    
2067
                                    }
2068

    
2069
                                },
2070

    
2071
                            },
2072
                        });
2073
                    } else if (rec.FieldDataType == 1) {
2074
                        formfield = new MinovaUtil.MinovaES.MinovaNumberField({
2075
                            allowBlank: null_,
2076
                            fieldLabel: rec.ScreenCaption,
2077
                            readOnly: ReadOnly_,
2078
                            readOnlyCls: 'minova-readonly',
2079
                            labelCls: 'label-minova',
2080
                            labelWidth: lw,
2081
                            msgTarget: 'side',
2082
                            hideTrigger: true,
2083
                            hidden: Hidden_,
2084
                            name: rec.FieldName,
2085
                            IsPrimaryKey: rec.IsPrimaryKey,
2086
                            value: defaultValue,
2087
                            maxLength: rec.Length,
2088
                            anchor: '100%',
2089
                            formname: formname,
2090
                            nameTable: tbl,
2091
                            fieldStyle: 'text-align:right;',
2092
                            listeners: {
2093

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

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

    
2133
                                        if (custumFunc) {
2134
                                            eval(custumFunc)
2135
                                        }
2136

    
2137
                                    }
2138

    
2139
                                },
2140

    
2141
                            },
2142
                        });
2143
                    } else if (rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2144
                        formfield = new Ext.form.TextField({
2145
                            fieldLabel: rec.ScreenCaption,
2146
                            allowBlank: true,
2147
                            readOnlyCls: 'minova-readonly',
2148
                            fieldLabel: rec.ScreenCaption,
2149
                            readOnly: true,
2150
                            labelCls: 'label-minova',
2151
                            labelWidth: lw,
2152
                            hidden: Hidden_,
2153
                            name: rec.FieldName,
2154
                            msgTarget: 'side',
2155
                            maxLength: rec.Length,
2156
                            anchor: '100%',
2157
                            formname: formname,
2158
                            nameTable: tbl,
2159
                            listeners: {
2160

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

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

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

    
2204
                                    }
2205

    
2206
                                },
2207

    
2208
                            },
2209
                        });
2210

    
2211
                    } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT") {
2212
                        formfield = new MinovaUtil.MinovaES.SysDateTime({
2213
                            fieldLabel: rec.ScreenCaption,
2214
                            allowBlank: true,
2215
                            readOnlyCls: 'minova-readonly',
2216
                            labelCls: 'label-minova',
2217
                            IsPrimaryKey: rec.IsPrimaryKey,
2218
                            labelWidth: lw,
2219
                            msgTarget: 'side',
2220
                            fieldLabel: rec.ScreenCaption,
2221
                            readOnly: true,
2222
                            hidden: Hidden_,
2223
                            name: rec.FieldName,
2224
                            anchor: '100%',
2225
                            nameTable: tbl,
2226
                            readOnlyCls: 'minova-readonly',
2227
                            //cls:'x-item-disabled'
2228

    
2229
                        });
2230

    
2231
                    } else if (rec.FieldName == 'EmployeeID' && isLookup != true && rec.SearchType == "" || rec.FieldName == 'ApplicantID' || rec.FieldName == 'EmployeeIDFrom' || rec.FieldName == 'EmployeeIDTo') {
2232
                        // if (rec.SearchType == "" || rec.SearchType == null || rec.SearchType == undefined) {
2233
                        var triger = (rec.TriggerCombo).split('$');
2234
                        var targetField_ = triger[0];
2235
                        var fieldValue_ = triger[1];
2236

    
2237
                        formfield = new MinovaUtil.MinovaES.MinovaLookupEmployee({
2238
                            allowBlank: null_,
2239
                            fieldLabel: rec.ScreenCaption,
2240
                            readOnly: ReadOnly_,
2241
                            readOnlyCls: 'minova-readonly',
2242
                            hidden: Hidden_,
2243
                            labelCls: 'label-minova',
2244
                            name: rec.FieldName,
2245
                            msgTarget: 'side',
2246
                            fieldname: rec.FieldName,
2247
                            IsPrimaryKey: rec.IsPrimaryKey,
2248
                            tableName: rec.TableRef, //name tabel yang jadi ref-nya
2249
                            triggerCls: 'x-form-search-trigger',
2250
                            //vtype: 'alphanum', // disable space
2251
                            vtype: 'validateMinovaXss',
2252
                            formtarget: formname, // nama form  yang akan di set value-nya
2253
                            isLookup: isLookup,
2254
                            anchor: '100%',
2255
                            formname: formname,
2256
                            targetField: targetField_,
2257
                            fieldValue: fieldValue_,
2258
                            nameTable: tbl,
2259
                            value: defaultValue,
2260
                            LookupFunction: rec.LookupFunction,
2261
                            filterParam: rec.ParamCombo,
2262
                            listeners: {
2263

    
2264
                                change: function (val) {
2265
                                    var _label = val.name;
2266
                                    var _form = val.formname;
2267
                                    var _Value = val.getValue();
2268
                                    var target = rec.TriggerCombo;
2269
                                    var custumFunc = rec.SelectFunction;
2270
                                    if (custumFunc.toLowerCase().substring(0, 2) == 'fn') {
2271
                                        Ext.Ajax.request({
2272
                                            async: false,
2273
                                            method: 'POST',
2274
                                            url: '/UserControl/GetStore',
2275
                                            params: {
2276
                                                tableName: 'PCMFUNC',
2277
                                                param: 'FuncName[equal]' + rec.custumFunc + ',Active[=]1'
2278
                                            },
2279
                                            success: function (response) {
2280
                                                var results = Ext.decode(response.responseText);
2281
                                                data_ = results.data[0];
2282
                                                if (data_ != undefined) {
2283
                                                    custumFunc = data_.FunctionCode;
2284
                                                }
2285
                                            }
2286
                                        });
2287
                                    }
2288
                                    var frm = Ext.ComponentQuery.query('form[name=' + _form + ']')[0];
2289
                                    if (frm) {
2290

    
2291
                                        if (target) {
2292
                                            var f = frm.getForm().findField(target)
2293
                                            _store = f.getStore();
2294
                                            var _tbl = _store.proxy.extraParams.tableName;
2295
                                            var oldParam = _store.proxy.extraParams.param;
2296
                                            _store.proxy.extraParams = {
2297
                                                tableName: _tbl,
2298
                                                param: _label + '[=]' + _Value
2299
                                            };
2300
                                            _store.load();
2301
                                        }
2302

    
2303
                                        if (custumFunc) {
2304
                                            eval(custumFunc)
2305
                                        }
2306

    
2307
                                    }
2308

    
2309
                                },
2310

    
2311
                            },
2312
                        });
2313
                        //}
2314
                    } else {
2315
                        formfield = new Ext.form.TextField({
2316
                            allowBlank: null_,
2317
                            fieldLabel: rec.ScreenCaption,
2318
                            readOnly: ReadOnly_,
2319
                            readOnlyCls: 'minova-readonly',
2320
                            labelCls: 'label-minova',
2321
                            labelWidth: lw,
2322
                            msgTarget: 'side',
2323
                            hidden: Hidden_,
2324
                            name: rec.FieldName,
2325
                            IsPrimaryKey: rec.IsPrimaryKey,
2326
                            value: defaultValue,
2327
                            maxLength: rec.Length,
2328
                            anchor: '100%',
2329
                            formname: formname,
2330
                            vtype: 'validateMinovaXss',
2331
                            nameTable: tbl,
2332
                            listeners: {
2333

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

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

    
2373
                                        if (custumFunc) {
2374
                                            eval(custumFunc)
2375
                                        }
2376

    
2377
                                    }
2378

    
2379
                                },
2380

    
2381
                            },
2382
                        });
2383
                    }
2384
                }
2385

    
2386
        }
2387

    
2388
        //if (rec.IsPrimaryKey == 1) {
2389
        //    formfield = new Ext.form.TextField({
2390
        //        hidden: true,
2391
        //        name: "Key_" + rec.FieldName,
2392
        //    });
2393
        //}
2394
    }
2395

    
2396
    //
2397
    return (formfield);
2398
}
2399
MinovaUtil.FieldGenerator.Editor = function (rec, null_) {
2400
    var formfield = undefined;
2401
    switch (rec.FormatRef) {
2402
        case "date":
2403
            formfield = new Ext.form.DateField({
2404
                allowBlank: null_,
2405
                //msgTarget: 'side',
2406
                readOnly: rec.ReadOnly,
2407
                name: rec.FieldName,
2408
                format: 'd/m/Y',
2409
                submitFormat: 'Ymd',
2410
                value: defaultValue,
2411
                anchor: '100%',
2412
                hideMode: 'visibility',
2413

    
2414
            });
2415
            break
2416
        case "time":
2417
            formfield = new Ext.form.TimeField({
2418
                allowBlank: null_,
2419
                //msgTarget: 'side',
2420
                readOnly: rec.ReadOnly,
2421
                name: rec.FieldName,
2422
                format: 'Hi',
2423
                submitFormat: 'Hi',
2424
                increment: 5,
2425
                value: defaultValue,
2426
                anchor: '100%'
2427
            });
2428
            break
2429
        case "file":
2430
            formfield = Ext.create('MinovaES.view.uploadfile.uploadfile')
2431
            break
2432
        default:
2433
            if (rec.Length > 49 && rec.TableRef == "") {
2434
                formfield = new Ext.form.TextArea({
2435
                    allowBlank: null_,
2436
                    //msgTarget: 'side',
2437
                    readOnly: rec.ReadOnly,
2438
                    name: rec.FieldName,
2439
                    value: defaultValue,
2440
                    maxLength: rec.Length,
2441
                    anchor: '100%'
2442
                });
2443
            } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT" || rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2444
                formfield = new Ext.form.TextField({
2445
                    allowBlank: true,
2446
                    //msgTarget: 'side',
2447
                    readOnly: true,
2448
                    name: rec.FieldName,
2449
                    maxLength: rec.Length,
2450
                    anchor: '100%'
2451
                });
2452
            } else if (rec.TableRef != "") {
2453
                var fieldsCombo = null;
2454
                Ext.Ajax.request({
2455
                    async: false,
2456
                    method: 'POST',
2457
                    url: '/Devt/GetAllField?tableName=' + rec.TableRef,
2458
                    success: function (response) {
2459
                        var results = Ext.decode(response.responseText);
2460
                        fieldsCombo = results.data;
2461
                    }
2462
                });
2463
                valueField = null;
2464
                Ext.Ajax.request({
2465
                    async: false,
2466
                    method: 'POST',
2467
                    url: '/UserControl/GetStore',
2468
                    params: {
2469
                        tableName: 'SDATATABLEFIELD',
2470
                        param: 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2471
                    },
2472
                    success: function (response) {
2473
                        var results = Ext.decode(response.responseText);
2474
                        data_ = results.data[0];
2475
                        if (data_ != undefined) {
2476
                            valueField = data_.FieldName;
2477
                        }
2478
                    }
2479
                });
2480
                displayValue = null;
2481
                Ext.Ajax.request({
2482
                    async: false,
2483
                    method: 'POST',
2484
                    url: '/UserControl/GetStore',
2485
                    params: {
2486
                        tableName: 'SDATATABLEFIELD',
2487
                        param: 'DisplayValue[equal]1,TableName[equal]' + rec.TableRef
2488
                    },
2489
                    success: function (response) {
2490
                        var results = Ext.decode(response.responseText);
2491
                        data_ = results.data[0];
2492
                        if (data_ != undefined) {
2493
                            displayValue = data_.FieldName;
2494
                            //console.log(data_)
2495
                        }
2496
                    }
2497
                });
2498
                //var field_ = [];
2499
                //fieldsCombo.forEach(function (rec) {
2500
                //    field_.push(rec.FieldName)
2501
                //});
2502

    
2503
                formfield = new Ext.form.ComboBox({
2504
                    allowBlank: null_,
2505
                    //msgTarget: 'side',
2506
                    readOnly: rec.ReadOnly,
2507
                    name: rec.FieldName,
2508
                    value: defaultValue,
2509
                    anchor: '100%',
2510
                    vtype: 'validateCombobox',
2511
                    store: Ext.create('Ext.data.Store', {
2512
                        storeId: 'store' + rec.FieldName,
2513
                        autoLoad: true,
2514
                        //pageSize: 10,
2515
                        //fields: field_,
2516
                        proxy: {
2517
                            method: 'POST',
2518
                            type: 'ajax',
2519
                            url: '/UserControl/GetStore',
2520
                            //params: {
2521
                            extraParams: {
2522
                                tableName: rec.TableRef,
2523
                                param: rec.ParamCombo
2524
                            },
2525
                            reader: {
2526
                                type: 'json',
2527
                                root: 'data',
2528
                                // totalProperty: 'data[0].TotalCount'
2529
                            }
2530
                        }
2531
                    }),
2532
                    listeners: {
2533
                        change: function (val) { }
2534

    
2535
                    },
2536
                    queryMode: 'local',
2537
                    displayField: displayValue,
2538
                    valueField: valueField,
2539
                });
2540
            } else if (rec.FieldDataType == 3) {
2541
                formfield = new MinovaUtil.MinovaES.MinovaFloatField({
2542
                    allowBlank: null_,
2543
                    //msgTarget: 'side',
2544
                    readOnly: rec.ReadOnly,
2545
                    name: rec.FieldName,
2546
                    value: defaultValue,
2547
                    maxLength: rec.Length,
2548
                    precision: rec.Prec,
2549
                    anchor: '100%'
2550
                });
2551
            } else if (rec.FieldDataType == 1) {
2552
                formfield = new MinovaUtil.MinovaES.MinovaNumberField({
2553
                    allowBlank: null_,
2554
                    //msgTarget: 'side',
2555
                    readOnly: rec.ReadOnly,
2556
                    name: rec.FieldName,
2557
                    value: defaultValue,
2558
                    maxLength: rec.Length,
2559
                    anchor: '100%'
2560
                });
2561
            } else {
2562
                formfield = new Ext.form.TextField({
2563
                    allowBlank: null_,
2564
                    //msgTarget: 'side',
2565
                    readOnly: rec.ReadOnly,
2566
                    name: rec.FieldName,
2567
                    value: defaultValue,
2568
                    maxLength: rec.Length,
2569
                    anchor: '100%'
2570
                });
2571
            }
2572
    }
2573
    return (formfield);
2574
}
2575
MinovaUtil.FieldGenerator.Column = function (rec, null_) {
2576
    var gridcol = undefined;
2577
    switch (rec.FormatRef) {
2578
        case "date":
2579
            gridcol = 'minovadatecolumn'
2580
            break
2581
        case "time":
2582
            gridcol = ''
2583
            break
2584
        case "file":
2585
            gridcol = ''
2586
            break
2587
        default:
2588
            if (rec.Length > 49 && rec.TableRef == "") {
2589
                gridcol = ''
2590
            } else if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT" || rec.DataRef == "CREATEBY" || rec.DataRef == "CHANGEBY") {
2591
                gridcol = ''
2592
            } else if (rec.TableRef != "") {
2593
                gridcol = 'MinovaComboColumn'
2594
            } else if (rec.FieldDataType == 3) {
2595
                gridcol = 'numbercolumn'
2596
            } else if (rec.FieldDataType == 1) {
2597
                gridcol = 'numbercolumn'
2598
            } else {
2599
                gridcol = ''
2600
            }
2601
    }
2602
    return (gridcol);
2603
}
2604
MinovaUtil.FieldGenerator.Display = function (rec) {
2605
    var formfield = null;
2606
    var Hidden_ = false;
2607
    if (rec.IsHidden == '1' || IsHidden == true) {
2608
        Hidden_ = true;
2609
    }
2610
    switch (rec.FormatRef) {
2611
        case "date":
2612
            formfield = new MinovaUtil.MinovaES.DisplayDate({
2613
                fieldLabel: rec.ScreenCaption,
2614
                //msgTarget: 'side',
2615
                hidden: Hidden_,
2616
                name: rec.FieldName,
2617
                anchor: '100%'
2618
            });
2619
            break;
2620

    
2621
        default:
2622
            if (rec.DataRef == "CREATEDT" || rec.DataRef == "CHANGEDT") {
2623
                formfield = new MinovaUtil.MinovaES.DisplaySysDateTime({
2624
                    fieldLabel: rec.ScreenCaption,
2625
                    //msgTarget: 'side',
2626
                    hidden: Hidden_,
2627
                    name: rec.FieldName,
2628
                    anchor: '100%'
2629
                });
2630
            } else if (rec.TableRef != "") {
2631

    
2632
                valueField = null;
2633
                Ext.Ajax.request({
2634
                    async: false,
2635
                    method: 'POST',
2636
                    url: '/UserControl/GetStore',
2637
                    params: {
2638
                        tableName: 'SDATATABLEFIELD',
2639
                        param: 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2640
                    },
2641
                    success: function (response) {
2642
                        var results = Ext.decode(response.responseText);
2643
                        data_ = results.data[0];
2644
                        if (data_ != undefined) {
2645
                            valueField = data_.FieldName;
2646
                        }
2647
                    }
2648
                });
2649
                displayValue = null;
2650
                Ext.Ajax.request({
2651
                    async: false,
2652
                    method: 'POST',
2653
                    url: '/UserControl/GetStore',
2654
                    params: {
2655
                        tableName: 'SDATATABLEFIELD',
2656
                        param: 'DisplayValue[equal]1,TableName[equal]' + rec.TableRef
2657
                    },
2658
                    success: function (response) {
2659
                        var results = Ext.decode(response.responseText);
2660
                        data_ = results.data[0];
2661
                        if (data_ != undefined) {
2662
                            displayValue = data_.FieldName;
2663
                            //console.log(data_)
2664
                        }
2665
                    }
2666
                });
2667
                //var field_ = [];
2668
                //fieldsCombo.forEach(function (rec) {
2669
                //    field_.push(rec.FieldName)
2670
                //});
2671
                formfield = new Ext.form.ComboBox({
2672
                    allowBlank: null_,
2673
                    fieldLabel: rec.ScreenCaption,
2674
                    //msgTarget: 'side',
2675
                    readOnly: rec.ReadOnly,
2676
                    hidden: Hidden_,
2677
                    name: rec.FieldName,
2678
                    value: defaultValue,
2679
                    vtype: 'validateCombobox',
2680
                    anchor: '100%',
2681
                    store: Ext.create('Ext.data.Store', {
2682
                        storeId: 'store' + rec.FieldName,
2683
                        autoLoad: true,
2684
                        //pageSize: 10,
2685
                        //fields: field_,
2686
                        proxy: {
2687
                            method: 'POST',
2688
                            type: 'ajax',
2689
                            url: '/UserControl/GetStore',
2690
                            //params: {
2691
                            extraParams: {
2692
                                tableName: rec.TableRef,
2693
                                param: ''
2694
                            },
2695
                            reader: {
2696
                                type: 'json',
2697
                                root: 'data',
2698
                                totalProperty: 'data[0].TotalCount'
2699
                            }
2700
                        }
2701
                    }),
2702
                    listeners: {
2703
                        change: function (val) { }
2704

    
2705
                    },
2706
                    queryMode: 'local',
2707
                    displayField: displayValue,
2708
                    valueField: valueField,
2709
                });
2710
            }
2711
            break
2712
    }
2713
}
2714

    
2715
//funsi untuk set value form html
2716
// data json
2717
// form_id= id form yang akan diset valuenya
2718
MinovaUtil.FieldGenerator.HtmlSetValues = function (data, form_id) {
2719
    $.each(data, function (key, value) {
2720
        $('#' + key, form_id).val(value);
2721
    });
2722
}
2723

    
2724
MinovaUtil.FieldGenerator.SimpleHtmlDisplay1 = function (divid, tableName, title) {
2725

    
2726
    code = null;
2727
    Ext.Ajax.request({
2728
        async: false,
2729
        method: 'POST',
2730
        url: '/Devt/GetItenDiv',
2731
        /* params : {
2732
		tableName : 'SDATATABLEFIELD',
2733
		param : 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2734
		}, */
2735
        success: function (response) {
2736
            code = response.responseText;
2737

    
2738
        }
2739
    });
2740

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

    
2744
}
2745

    
2746
MinovaUtil.FieldGenerator.SimpleHtmlDisplay2 = function (divid, tableName, title) {
2747

    
2748
    code = null;
2749
    Ext.Ajax.request({
2750
        async: false,
2751
        method: 'POST',
2752
        url: '/Devt/GetItenDiv',
2753
        /* params : {
2754
		tableName : 'SDATATABLEFIELD',
2755
		param : 'ValueField[equal]1,TableName[equal]' + rec.TableRef
2756
		}, */
2757
        success: function (response) {
2758
            code = response.responseText;
2759

    
2760
        }
2761
    });
2762

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

    
2766
}
2767

    
2768
MinovaUtil.FieldGenerator.ExtjsBuildGrid = function (divid, tableName) {
2769
    var div_ = tableName + 'div'
2770
    $("#" + divid).append('  <div class="row" id="grid"' + tableName + '>' +
2771
        '<div class="col-md-12">' +
2772
        '<h3 class="form-section">Person Info</h3>' +
2773
        '<div class="portlet-body" id=' + div_ + '> </div></div></div>');
2774

    
2775
    Ext.create('MinovaUtil.MinovaES.MinovaGrid1', {
2776
        renderTo: div_,
2777
        isLookup: 1,
2778
        minHeight: 280,
2779
        height: 100,
2780
        tableName: tableName,
2781
        param: '',
2782
        isLookup: false,
2783
        width: '100%',
2784
        name: 'grid' + tableName,
2785
        hidebutton: 0,
2786
        pagesize: 25,
2787
        storename: 'lgrid' + tableName,
2788
    });
2789
}
2790

    
2791
MinovaUtil.FieldGenerator.BuildSimpleGridHtml = function (divid, tableName, title) {
2792

    
2793
    var header = "";
2794
    var ThThead = "";
2795
    for (var i = 0; i < 4; i++) {
2796
        header = "header" + i;
2797
        ThThead = ThThead + "<th>" + header + "</th>";
2798
    }
2799
    var Thead = "<thead>" + ThThead + "</thead>";
2800

    
2801
    var td = "";
2802
    var tdLabel = "";
2803
    var tr = "";
2804
    for (var a = 0; a <= 2; a++) {
2805
        for (var b = 0; b < 4; b++) {
2806
            tdLabel = b;
2807
            td = td + "<td>" + tdLabel + "</td>";
2808
        }
2809
        tr = tr + "<tr>" + td + "</tr>";
2810
        td = "";
2811
    }
2812
    var Tbody = "<tbody>" + tr + "</tbody>";
2813
    var tbl = tableName + "Table";
2814
    var result = "<div class='row' id=" + tbl + ">" +
2815
		"<div class='col-md-10'>" +
2816
		"<h3 class='form-section'>" + title + "</h3>" +
2817
		"<div class='portlet-body'>" +
2818
		"<div class='table-scrollable'>" +
2819
		"<table class='table table-bordered table-hover'>" +
2820
		Thead +
2821
		Tbody
2822
    "</table>" +
2823
    "</div>" +
2824
    "</div>" +
2825
    "</div>" +
2826
    "</div>";
2827
    $("#" + divid).append(result);
2828
}
2829

    
2830
MinovaUtil.FieldGenerator.Header1 = function (divid, companyCode) {
2831
    var logo = undefined;
2832
    var CompanyDescription = undefined;
2833
    Ext.Ajax.request({
2834
        async: false,
2835
        method: 'POST',
2836
        url: '/UserControl/GetStore',
2837
        params: {
2838
            tableName: 'PCMEPCOMPID',
2839
            param: 'CompanyID[equal]' + companyCode
2840

    
2841
        },
2842
        success: function (response) {
2843
            var results = Ext.decode(response.responseText);
2844
            data_ = results.data;
2845
            if (data_.length > 0) {
2846
                logo = data_[0].Logo;
2847
                CompanyDescription = data_[0].CompanyDescription;
2848
            }
2849
        }
2850
    });
2851

    
2852
    var header = //'<div class="row">' +
2853
		'<div class="col-md-3">' +
2854
		'<div class="page-logo">' +
2855
		'<a href="/">' +
2856
		///Devt/GetFileData?FileName=Foto Fazari.jpg&download=false
2857
		'<img src="/Devt/GetFileData?FileName=' + logo + '&download=false" alt="logo" class="logo-default" />' +
2858
		'</a>' +
2859
		'</div>' +
2860
		'</div>' +
2861
		'<div class="col-md-9">' +
2862
		'<h3>' + CompanyDescription + '</h3>' +
2863

    
2864
		'</div>';
2865
    '<div>';
2866

    
2867
    '</div>';
2868

    
2869
    $("#" + divid).append(header);
2870
}
2871

    
2872
MinovaUtil.FieldGenerator.Header2 = function (divid, companyCode) {
2873
    var header = '<div class="row">' +
2874
		'<div class="col-md-9">' +
2875
		'<div class="page-logo">' +
2876
		'<h3> PT Minova Infotech Solutions</h3>' +
2877
		'</div>' +
2878
		'</div>' +
2879
		'<div class="col-md-3">' +
2880
		'<a href="/">' +
2881
		'<img src="../../Metronic/assets/admin/layout4/img/logo-light.png" alt="logo" class="logo-default" />' +
2882
		'</a>' +
2883
		'</div>' +
2884
		'</div>';
2885
    $("#" + divid).append(header);
2886
}
2887

    
2888
MinovaUtil.FieldGenerator.MDWithImage1 = function (divid) {
2889

    
2890
    var nowDate = MinovaUtil.GetNowDate();
2891
    var Photo = 'nophoto.gif';
2892
    var emp = getParam("EmployeeID");
2893
    if (emp == "null") {
2894
        var VariantID = getParam("VariantName");
2895
        Ext.Ajax.request({
2896
            method: 'POST',
2897
            async: false,
2898
            url: '/UserControl/GetStore',
2899
            params: {
2900
                tableName: 'SDATAVARIANT',
2901
                param: 'VariantName[=]' + VariantID
2902
            },
2903
            success: function (response) {
2904
                var results = Ext.decode(response.responseText);
2905
                hasil = Ext.decode(results.data[0].Data);
2906
                emp = hasil.EmployeeID;
2907

    
2908
            }
2909
        });
2910
    }
2911

    
2912
    // get Photo
2913
    Ext.Ajax.request({
2914
        method: 'POST',
2915
        async: false,
2916
        url: '/UserControl/GetStore',
2917
        params: {
2918
            tableName: 'PHRPA0001',
2919
            param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + emp
2920
        },
2921
        success: function (response) {
2922
            var results = Ext.decode(response.responseText);
2923
            hasil = results.data;
2924
            dataPhoto = hasil[0].Picture
2925
            if (dataPhoto != "") {
2926
                Photo = dataPhoto;
2927
            }
2928

    
2929
        }
2930
    });
2931

    
2932
    var header = '<div class="row">' +
2933
		'<div class="col-md-2">' +
2934
		'<div class="page-logo">' +
2935
		'<a href="/">' +
2936
		'<img src="/Devt/GetFileData?FileName=' + Photo + '&download=false" alt="logo" width="133" height="140" />' +
2937
		'</a>' +
2938
		'</div>' +
2939
		'</div>' +
2940
		'<div class="col-md-10" id="formMD">' +
2941

    
2942
		'</div>' +
2943
		'</div>';
2944
    $("#" + divid).append(header);
2945
}
2946

    
2947
MinovaUtil.FieldGenerator.MDWithImage2 = function (divid, companyCode) {
2948
    var header = '<div class="row">' +
2949
		'<div class="col-md-10" id="formMD">' +
2950

    
2951
		'</div>' +
2952
		'<div class="col-md-2">' +
2953
		'<div class="page-logo">' +
2954
		'<a href="/">' +
2955
		'<img src="../../Metronic/assets/admin/layout4/img/logo-light.png" alt="logo" class="logo-default" />' +
2956
		'</a>' +
2957
		'</div>' +
2958
		'</div>' +
2959
		'</div>';
2960
    $("#" + divid).append(header);
2961
}
2962

    
2963
MinovaUtil.FieldGenerator.CvView = function (divid) {
2964

    
2965
    //get all header
2966
    var emp = getParam('EmployeeID');
2967
    // var divid = 'reportContent';
2968
    var CVType = getParam('CVType');
2969
    if (CVType == "null") {
2970
        var VariantID = getParam("VariantName");
2971
        Ext.Ajax.request({
2972
            method: 'POST',
2973
            async: false,
2974
            url: '/UserControl/GetStore',
2975
            params: {
2976
                tableName: 'SDATAVARIANT',
2977
                param: 'VariantName[=]' + VariantID
2978
            },
2979
            success: function (response) {
2980
                var results = Ext.decode(response.responseText);
2981
                hasil = Ext.decode(results.data[0].Data);
2982
                CVType = hasil.CVType;
2983

    
2984
            }
2985
        });
2986
    }
2987
    var LangId = MinovaUtil.GetLangID();
2988
    var header_ = null;
2989
    var results = null;
2990
    var CVDetailType = null;
2991
    //get all field
2992
    Ext.Ajax.request({
2993
        async: false,
2994
        method: 'POST',
2995
        url: '/UserControl/GetStore',
2996
        params: {
2997
            tableName: 'PDSPA0002',
2998
            param: "hd.CVType = '" + CVType + "' AND rt.LangId = '" + LangId + "'"
2999
            //param : "hd.CVType = "+CVType+" AND rt.LangId = "+LangId
3000
        },
3001
        success: function (response) {
3002
            var result = Ext.decode(response.responseText);
3003
            results = result.data;
3004

    
3005
        }
3006
    });
3007
    // generate ui from all field each panel
3008
    var allTable = null;
3009
    var tbl = null;
3010
    var tblTemp = null;
3011

    
3012
    var allHeader = null;
3013
    var head_ = null;
3014
    var headTemp = null;
3015
    var i = 0;
3016
    var countData = results.length;
3017
    results = results.sort(MinovaUtil.SortBy("Sequence"))
3018
    Ext.each(results, function (rec) {
3019
        tblTemp = results[i].TableName;
3020
        headTemp = results[i].CVHeaderTitle;
3021

    
3022
        if (tbl != tblTemp) {
3023

    
3024
            tbl = tblTemp;
3025
            if (allTable == null) {
3026
                allTable = tbl
3027
            } else {
3028
                allTable = allTable + ',' + tbl
3029
            }
3030

    
3031
        }
3032

    
3033
        if (head_ != headTemp) {
3034

    
3035
            head_ = headTemp;
3036
            if (allHeader == null) {
3037
                allHeader = head_
3038
            } else {
3039
                allHeader = allHeader + ',' + head_
3040
            }
3041

    
3042
        }
3043

    
3044
        if (countData > i) {
3045
            i++
3046
        }
3047

    
3048
    });
3049

    
3050
    var splitHeader = allHeader.split(',')
3051
    var splitTable = allTable.split(',')
3052

    
3053
    splitHeader = splitHeader.filter(MinovaUtil.RemoveDuplicateArray);
3054
    splitTable = splitTable.filter(MinovaUtil.RemoveDuplicateArray);
3055

    
3056
    var panel_ = null;
3057
    // build form/grid
3058
    var contHeader = 0;
3059
    splitHeader.forEach(function (hd) {
3060
        //console.log(h)
3061
        panel_ = null;
3062
        panel_ = $.grep(results, function (r) {
3063
            return r.CVHeaderTitle == hd
3064
        });
3065
        panel_ = panel_.sort(MinovaUtil.SortBy("FieldSequence"))
3066
        //get layout type form/grid
3067
        var layout = panel_[0].CVLayout
3068
        var item_ = null
3069
        if (layout == 'Form') {
3070
            var _temtbl = null;
3071
            var dataValues = null;
3072
            Ext.each(panel_, function (rec) {
3073
                var labelId = "label" + rec.TableName + rec.Field
3074
                var labelValue = rec.ScreenCaption
3075
                var valueId = "val" + rec.TableName + rec.Field
3076

    
3077
                if (_temtbl == null) {
3078
                    _temtbl = rec.TableName;
3079
                    //alert(_temtbl)
3080
                    //get table values
3081
                    Ext.Ajax.request({
3082
                        async: false,
3083
                        method: 'POST',
3084
                        url: '/UserControl/GetStore',
3085
                        params: {
3086
                            tableName: rec.TableName,
3087
                            param: 'EmployeeID[=]' + emp
3088
                            // belum di cek start date dan enddate
3089
                        },
3090
                        success: function (response) {
3091
                            var results = Ext.decode(response.responseText);
3092
                            dataValues = results.data[0];
3093

    
3094
                        }
3095
                    });
3096
                }
3097

    
3098
                if (_temtbl != rec.TableName) {
3099

    
3100
                    //get table values
3101
                    Ext.Ajax.request({
3102
                        async: false,
3103
                        method: 'POST',
3104
                        url: '/UserControl/GetStore',
3105
                        params: {
3106
                            tableName: rec.TableName,
3107
                            param: 'EmployeeID[=]' + emp
3108

    
3109
                        },
3110
                        success: function (response) {
3111
                            var results = Ext.decode(response.responseText);
3112
                            dataValues = results.data[0];
3113
                            // console.log(dataValues)
3114

    
3115
                        }
3116
                    });
3117

    
3118
                }
3119
                var _field = null;
3120
                var valueField = null;
3121
                var TableRef = null;
3122
                if (dataValues) {
3123
                    _field = 'dataValues.' + rec.Field;
3124
                    // case field with table ref
3125
                    //get table ref
3126

    
3127
                    Ext.Ajax.request({
3128
                        async: false,
3129
                        method: 'POST',
3130
                        url: '/UserControl/GetStore',
3131
                        params: {
3132
                            tableName: 'SDATATABLEFIELD',
3133
                            param: 'TableName[=]' + rec.TableName + ',' + 'FieldName[=]' + rec.Field
3134

    
3135
                        },
3136
                        success: function (response) {
3137
                            var results = Ext.decode(response.responseText);
3138
                            if (results.length > 0) {
3139
                                TableRef = results.data[0].TableRef;
3140
                            }
3141

    
3142
                        }
3143
                    });
3144
                    if (TableRef != '' && TableRef != null) {
3145
                        //alert(TableRef);
3146
                        //get valuefield and displayfield tableref
3147
                        var data = null;
3148
                        Ext.Ajax.request({
3149
                            async: false,
3150
                            method: 'POST',
3151
                            url: '/UserControl/GetStore',
3152
                            params: {
3153
                                tableName: 'SDATATABLEFIELD',
3154
                                param: 'TableName[=]' + TableRef
3155

    
3156
                            },
3157
                            success: function (response) {
3158
                                data = Ext.decode(response.responseText).data;
3159
                                // data = data_.data[0];
3160
                            }
3161
                        });
3162
                        code = $.grep(data, function (r) {
3163
                            return r.ValueField == '1'
3164
                        });
3165
                        code = code[0].FieldName;
3166
                        desc = $.grep(data, function (r) {
3167
                            return r.DisplayValue == '1'
3168
                        });
3169
                        desc = desc[0].FieldName;
3170
                        //get value display
3171
                        if (code != '' && code != null) {
3172
                            Ext.Ajax.request({
3173
                                async: false,
3174
                                method: 'POST',
3175
                                url: '/UserControl/GetStore',
3176
                                params: {
3177
                                    tableName: TableRef,
3178
                                    param: code + '[=]' + eval(_field)
3179

    
3180
                                },
3181
                                success: function (response) {
3182
                                    var results = Ext.decode(response.responseText);
3183
                                    result = results.data[0];
3184
                                    field_ = "result." + desc;
3185
                                    valueField = eval(field_);
3186

    
3187
                                }
3188
                            });
3189

    
3190
                        }
3191

    
3192
                    } else {
3193
                        valueField = eval(_field);
3194
                    }
3195

    
3196
                }
3197

    
3198
                if (item_ == null) {
3199

    
3200
                    item_ = "<div class='col-md-6'> <div class='form-group'>"
3201
                         + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3202
                         + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3203
                         + valueField + " </div> </div> </div>"
3204
                } else {
3205

    
3206
                    item_ = item_ + "<div class='col-md-6'> <div class='form-group'>"
3207
                         + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3208
                         + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3209
                         + valueField + " </div> </div> </div>"
3210
                }
3211

    
3212
            });
3213
            if (contHeader == 0) {
3214

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

    
3218
            } else {
3219
                $("#" + divid).append(" <h3 class='form-section'>" + hd + "</h3>");
3220
                $("#" + divid).append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3221
            }
3222
            contHeader++;
3223

    
3224
        } else {
3225
            var gridPanel = null;
3226
            var header = "";
3227
            var ThThead = "";
3228
            var tr = "";
3229
            var td = "";
3230
            var tdLabel = "";
3231
            var tableName = panel_[0].TableName;
3232
            var allGridCol = null;
3233
            dtEmp = null;
3234
            Ext.Ajax.request({
3235
                async: false,
3236
                method: 'POST',
3237
                url: '/UserControl/GetStore',
3238
                params: {
3239
                    tableName: tableName,
3240
                    param: 'EmployeeID[equal]' + emp
3241
                },
3242
                success: function (response) {
3243
                    var results = Ext.decode(response.responseText);
3244
                    dtEmp = results.data;
3245
                    //  console.log(tableName);
3246
                    //  console.log(dtEmp)
3247

    
3248
                }
3249
            });
3250
            // get structure
3251
            var structure = null
3252
            Ext.Ajax.request({
3253
                async: false,
3254
                method: 'POST',
3255
                url: '/UserControl/GetStore',
3256
                params: {
3257
                    tableName: 'SDATATABLEFIELD',
3258
                    param: 'TableName[equal]' + tableName
3259
                },
3260
                success: function (response) {
3261
                    var results = Ext.decode(response.responseText);
3262
                    structure = results.data;
3263
                    //  console.log(tableName);
3264
                    //  console.log(dtEmp)
3265

    
3266
                }
3267
            });
3268
            Ext.each(panel_, function (rec) {
3269
                header = rec.HeaderTitle;
3270
                if (allGridCol == null) {
3271
                    allGridCol = header
3272
                } else {
3273
                    allGridCol = allGridCol + ',' + header
3274
                }
3275
                ThThead = ThThead + "<th>" + header + "</th>";
3276
            });
3277
            //var splitallGridCol = allGridCol.split(',')
3278
            var Thead = "<thead>" + ThThead + "</thead>";
3279
            // get data by tableName and emp id
3280

    
3281
            for (var a = 0; a < dtEmp.length; a++) { //length data will be populate, create row coloumn
3282
                //console.log(panel_)
3283
                for (var b = 0; b < panel_.length; b++) { //length header
3284
                    // tdLabel = b;
3285

    
3286
                    haed_ = panel_[b].Field;
3287
                    _tdLabel = 'dtEmp[' + a + '].' + haed_;
3288
                    tdLabel = eval(_tdLabel);
3289
                    //structure_ = structure[b].haed_
3290
                    structure_ = $.grep(structure, function (r) {
3291
                        return r.FieldName == haed_
3292
                    });
3293

    
3294
                    var hasil = MinovaUtil.FieldGenerator.GetValueHtml(structure_, tdLabel);
3295

    
3296
                    td = td + "<td>" + hasil + "</td>";
3297

    
3298
                }
3299
                tr = tr + "<tr>" + td + "</tr>";
3300
                td = "";
3301
            }
3302

    
3303
            var Tbody = "<tbody>" + tr + "</tbody>";
3304
            //var tbl = rec.tableName + "Table";
3305
            var tbl = "Table";
3306
            gridPanel = "<div class='row' id=" + tbl + ">" +
3307
                "<div class='col-md-10'>" +
3308
                "<h3 class='form-section'>" + hd + "</h3>" +
3309
                "<div class='portlet-body'>" +
3310
                "<div class='table-scrollable'>" +
3311
                "<table class='table table-bordered table-hover'>" +
3312
                Thead +
3313
                Tbody
3314
            "</table>" +
3315
            "</div>" +
3316
            "</div>" +
3317
            "</div>" +
3318
            "</div>";
3319
            $("#" + divid).append(gridPanel);
3320
        }
3321

    
3322
    });
3323

    
3324
    //set values for/grid
3325
    splitTable.forEach(function (tb) {
3326
        // alert(tb)
3327
    });
3328
}
3329

    
3330
MinovaUtil.FieldGenerator.GetValueHtml = function (structure, oldVlaue) {
3331
    var hasil = null;
3332
    switch (structure_[0].FormatRef) {
3333
        case "date":
3334
            d = oldVlaue.substring(6, 8);
3335
            m = oldVlaue.substring(4, 6);
3336
            y = oldVlaue.substring(0, 4);
3337
            hasil = d + '/' + m + '/' + y;
3338
            break;
3339

    
3340
        case "datetime":
3341
            var d = oldVlaue.substring(6, 8);
3342
            var m = oldVlaue.substring(4, 6);
3343
            var y = oldVlaue.substring(0, 4);
3344
            var h = oldVlaue.substring(8, 10);
3345
            var mt = oldVlaue.substring(10, 12);
3346
            var s = oldVlaue.substring(12, 14);
3347
            hasil = d + '/' + m + '/' + y + '  ' + '  ' + h + ':' + mt + ':' + s;
3348
            break;
3349

    
3350
        default:
3351
            if (structure_[0].SearchType != '') {
3352
                if (structure_[0].TableRef != '') {
3353
                    Ext.Ajax.request({
3354
                        async: false,
3355
                        method: 'POST',
3356
                        url: '/UserControl/GetStore',
3357
                        params: {
3358
                            tableName: 'SDATATABLEFIELD',
3359
                            param: 'TableName[equal]' + structure_[0].TableRef
3360
                        },
3361
                        success: function (response) {
3362
                            var results = Ext.decode(response.responseText);
3363
                            data_ = results.data;
3364
                            code = $.grep(data_, function (r) {
3365
                                return r.ValueField == '1'
3366
                            });
3367
                            desc = $.grep(data_, function (r) {
3368
                                return r.DisplayValue == '1'
3369
                            });
3370
                            code_ = code[0].FieldName;
3371
                            desc_ = desc[0].FieldName;
3372

    
3373
                            if (code) {
3374
                                Ext.Ajax.request({
3375
                                    async: false,
3376
                                    method: 'POST',
3377
                                    url: '/UserControl/GetStore',
3378
                                    params: {
3379
                                        tableName: structure_[0].TableRef,
3380
                                        param: code_ + '[equal]' + oldVlaue
3381
                                    },
3382
                                    success: function (response) {
3383
                                        var results = Ext.decode(response.responseText);
3384
                                        var val = results.data[0];
3385
                                        _val = 'val.' + desc_;
3386
                                        hasil = eval(_val)
3387
                                    }
3388
                                });
3389
                            }
3390

    
3391
                        }
3392
                    });
3393
                }
3394
            } else {
3395
                hasil = oldVlaue;
3396
            }
3397

    
3398
            break
3399

    
3400
    }
3401
    return hasil;
3402
}
3403

    
3404
MinovaUtil.FieldGenerator.BuildHTMLFormView = function (menuid, tableName) {
3405
    var param = '';
3406
    var LangID = '';
3407
    var dataSet = 'PDSBS0007';
3408
    if (menuid != '') {
3409
        param = 'MenuID[=]' + menuid + ',LangId[=]' + LangID;
3410
        dataSet = 'PDSBS0009';
3411
    } else {
3412
        param = "LangID='" + LangID + "',TableName='" + tableName
3413
    }
3414

    
3415
    // get data field structure
3416
    var structure = undefined;
3417
    Ext.Ajax.request({
3418
        async: false,
3419
        method: 'POST',
3420
        url: '/UserControl/GetStore',
3421
        params: {
3422
            tableName: dataSet,
3423
            param: param
3424
        },
3425
        success: function (response) {
3426
            structure = Ext.decode(response.responseText).data;
3427

    
3428
        }
3429
    });
3430

    
3431
    //create html component
3432
    var col = '1';
3433
    var index1 = 0;
3434
    var index2 = 0;
3435
    var jmlhData = structure.length;
3436
    var jmlCol1 = 0;
3437
    var jmlCol2 = 0;
3438
    var dataCol1 = null;
3439
    var dataCol2 = null;
3440
    var countCol1 = 0;
3441
    var countCol2 = 0;
3442
    if (dataSet == 'PDSBS0009') {
3443
        dataCol1 = $.grep(structure, function (r) {
3444
            return r.Column == '1'
3445
        });
3446
        jmlCol1 = dataCol1.length;
3447
        dataCol2 = $.grep(structure, function (r) {
3448
            return r.Column == '2'
3449
        });
3450
        jmlCol2 = dataCol2.length;
3451
    } else {
3452
        dataCol1 = $.grep(structure, function (r) {
3453
            return r.ColumnNo == '1'
3454
        });
3455
        jmlCol1 = dataCol1.length;
3456
        dataCol2 = $.grep(structure, function (r) {
3457
            return r.ColumnNo == '2'
3458
        });
3459
        jmlCol2 = dataCol2.length;
3460
    }
3461

    
3462
    var item_ = null;
3463
    for (i = 0; i < jmlhData; i++) {
3464
        if (i == 0) {
3465
            var dt = dataCol1[countCol1];
3466
            var dt = dataCol1[countCol1];
3467
            var labelId = dt.FieldName + 'id';
3468
            var labelValue = dt.ScreenCaption;
3469
            var valueId = dt.FieldName;
3470
            var valueField = '';
3471
            item_ = "<div class='col-md-6'> <div class='form-group'>"
3472
				 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3473
				 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3474
				 + valueField + " </div> </div> </div>";
3475

    
3476
            countCol1++;
3477
            col = '2';
3478
        } else {
3479
            if (col == '1' && countCol1 < jmlCol1) {
3480
                var dt = dataCol1[countCol1];
3481
                var labelId = dt.FieldName + 'id';
3482
                var labelValue = dt.ScreenCaption;
3483
                var valueId = dt.FieldName;
3484
                var valueField = '';
3485

    
3486
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3487
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3488
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3489
					 + valueField + " </div> </div> </div>";
3490

    
3491
                countCol1++;
3492
                col = '2';
3493
            } else if (col == '2' && countCol2 < jmlCol2) {
3494
                var dt = dataCol2[countCol2];
3495
                var dt = dataCol1[countCol1];
3496
                var labelId = dt.FieldName + 'id';
3497
                var labelValue = dt.ScreenCaption;
3498
                var valueId = dt.FieldName;
3499
                var valueField = '';
3500
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3501
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3502
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3503
					 + valueField + " </div> </div> </div>";
3504

    
3505
                countCol2++;
3506
                col = '1';
3507
            } else {
3508
                // create empety field
3509
                var labelId = 'EmpetyID';
3510
                var labelValue = '';
3511
                var valueId = 'EmpetyField';
3512
                var valueField = '';
3513
                item_ = "<div class='col-md-6'> <div class='form-group'>"
3514
					 + "<label class='control-label col-md-4 ' id=" + labelId + ">"
3515
					 + labelValue + "</label> <div class='col-md-8' id=" + valueId + "> "
3516
					 + valueField + " </div> </div> </div>";
3517
                //change base value
3518
                if (col == '1') {
3519
                    col = '2';
3520
                    countCol1++;
3521
                } else {
3522
                    col = '1';
3523
                    countCol2++
3524
                }
3525
            }
3526
        }
3527
        // add to form
3528
        if (dataSet == 'PDSBS0009') { //
3529
            $("#formHeaderMD").append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3530
        } else {
3531
            $("#formViewMD").append("<div class='row' id='TableName_Content'> " + item_ + " </div>");
3532
        }
3533
    }
3534

    
3535
}
3536

    
3537
/*Fungsi untuk Report Generator	*/
3538
MinovaUtil.FieldGenerator.ReportGenerator = function (tableName, store, filter, divid) {
3539
    Ext.create('MinovaUtil.MinovaES.MinovaRptGeneratorGrid', {
3540
        renderTo: divid,
3541
        name: 'result' + tableName,
3542
        storeOutput: store,
3543
        storeName: 'store' + tableName,
3544
        filter: filter,
3545
        tableName: tableName,
3546
        pagesize: 25,
3547
        autoLoad: true,
3548
        height: 400,
3549
        tbar: [{
3550
            xtype: 'button',
3551
            text: 'Action',
3552
            name: 'actionBtn',
3553
            menu: [{
3554
                text: 'Save',
3555
                name: 'Save',
3556
                action: 'Save',
3557
                style: 'font-family: FontAwesome',
3558
                iconCls: 'fa-plus-circle',
3559
            }, {
3560
                text: 'Export Table',
3561
                name: 'ExportTable',
3562
                action: 'ExportTable',
3563
                style: 'font-family: FontAwesome',
3564
                iconCls: 'fa-file-excel-o',
3565
            }
3566
            ],
3567
            layout: {
3568
                type: 'vbox',
3569
                align: 'stretch',
3570
                padding: 5
3571
            }
3572
        }, {
3573
            xtype: 'displayfield',
3574
            value: (Ext.Date.format(new Date(), 'd/m/Y g:i a')),
3575
            id: 'cur_date',
3576
            margin: '0 0 0 810'
3577
        }
3578
        ],
3579
        dockedItems: [{
3580
            xtype: 'pagingtoolbar',
3581
            store: 'store' + tableName,
3582
            dock: 'bottom',
3583
            pageSize: 25,
3584
            displayInfo: true
3585
        }
3586
        ]
3587
    });
3588
}
(2-2/4)