Project

General

Profile

Bug #1865 » mdgenerator.js

package_update - M Azid Wahyudi, 12/14/2022 05:08 PM

 
1
Ext.define('mdgenerator', {});
2

    
3
mdgenerator.createFormCard = function (tableName, layout, param_, renderTo, isDisplay, record, act, isfromgrid) {
4
    var name = 'MinovaGridFormEdit';
5
    var save = true;
6
    var edit = false;
7
    var delete_ = true;
8
    var back = false;
9
    var add = false;
10
    var copy = false;
11
    var cancel = true;
12
    if (isfromgrid == null)
13
        isfromgrid = '1';
14
    if (isDisplay) {
15
        name = 'MinovaGridFormDisplay'
16
    } else {
17
        save = false;
18
        edit = true;
19
        delete_ = false;
20
        add = true;
21
        copy = true;
22
        if (isfromgrid == '1') {
23
            back = false;
24
            cancel = true;
25
        } else {
26
            back = true;
27
            cancel = false;
28
        }
29
    }
30
    var userAction = MinovaUtil.GetActionMenu();
31
    if (userAction != '1') {
32
        Ext.Ajax.request({
33
            async: false,
34
            method: 'POST',
35
            url: '/UserControl/GetStore',
36
            params: {
37
                tableName: 'PCUSTROLE',
38
                param: 'Menu[equal]' + MinovaUtil.GetMenuID() + ',MenuAction[equal]0'
39
            },
40
            success: function (response) {
41
                var results = Ext.decode(response.responseText);
42
                data_ = results.data;
43
                if (data_.length > 0) {
44
                    save = true;
45
                    edit = true;
46
                    delete_ = true;
47
                    add = true;
48
                    copy = true;
49
                    cancel = true;
50
                } else {
51
                    save = true;
52
                    edit = true;
53
                    delete_ = true;
54
                    add = false;
55
                    copy = false;
56
                    cancel = true;
57
                }
58
            }
59
        });
60
    }
61
    if (tableName.toLowerCase().substring(0, 5) == 'phrrc') {
62
        Ext.Ajax.request({
63
            async: false,
64
            method: 'POST',
65
            url: '/UserControl/GetStore',
66
            params: {
67
                tableName: 'phrpa0015',
68
                param: 'ApplicantID[equal]' + getParam('app')
69
            },
70
            success: function (response) {
71
                var results = Ext.decode(response.responseText);
72
                data_ = results.data;
73
                if (data_.length > 0) {
74
                    save = true;
75
                    edit = true;
76
                    delete_ = true;
77
                    add = false;
78
                    copy = false;
79
                    cancel = true;
80
                }
81
            }
82
        });
83
    }
84
    Ext.create('Ext.form.Panel', {
85
        renderTo: renderTo,
86
        name: name + tableName,
87
        formMD: tableName,
88
        act: null,
89
        items: [{
90
                xtype: 'minovaForm',
91
                name: name,
92
                tableName: tableName,
93
                margin: '0 0 10 0',
94
                isDisplay: isDisplay,
95
                //hidden:true
96
                buttons: [{
97
                        text: 'Save',
98
                        hidden: save,
99
                        act: act,
100
                        //margin: '0 3 15 0', //(top, right, bottom, left).
101
                        name: 'btnSaveMD',
102
                        iconCls: 'fa-save',
103
                        style: 'font-family: FontAwesome',
104
                        handler: function () {
105
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
106
                            //p_.mask('Loading...');
107
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
108
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
109
                            //frm.mask('loading..');
110
                            var panelInt = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
111
                            if (panelInt) {
112
                                panelInt.mask('Loading..');
113
                            }
114
                            var valForm = '';
115
                            if (frm.getForm().isValid()) {
116
                                valForm = 1;
117
                            } else {
118
                                valForm = 0;
119
                            }
120

    
121
                            if (grid_.tableName == 'PHRRC0052') {
122
                                if (frm.getForm().monitor.items.items[6].getValue() == '1') {
123
                                    if (frm.getForm().monitor.items.items[7].getValue() == undefined) {
124
                                        valForm = 0;
125
                                    }
126
                                }
127
								if (frm.getForm().monitor.items.items[15].getValue() == '1') {
128
                                    if (frm.getForm().monitor.items.items[16].getValue() == '') {
129
                                        valForm = 0;
130
                                    }
131
                                }
132
								if (frm.getForm().monitor.items.items[18].getValue() == '1') {
133
                                    if (frm.getForm().monitor.items.items[19].getValue() == '') {
134
                                        valForm = 0;
135
                                    }
136
                                }
137
                            }
138
                            if (valForm == 1) {
139
                                Ext.Ajax.request({
140
                                    method: 'POST',
141
                                    //async: false,
142
                                    url: '/Devt/SaveTable',
143
                                    params: {
144
                                        tableName: tableName,
145
                                        data: Ext.encode(frm.getValues()),
146
                                        action: frm.act,
147
                                    },
148
                                    waitMsg: 'Saving Data...',
149
                                    success: function (response) {
150
                                        var result = Ext.decode(response.responseText);
151
                                        if (result.success) {
152

    
153
                                            MinovaMessage('Not Null', '000006', '', 'S');
154
                                            var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
155
                                            var s = menu.getStore();
156

    
157
                                            Ext.Ajax.request({
158
                                                async: false,
159
                                                method: 'POST',
160
                                                url: '/UserControl/GetStore',
161
                                                params: {
162
                                                    tableName: ' PDSPA0013 ',
163
                                                    param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
164

    
165
                                                },
166
                                                success: function (response) {
167
                                                    var results = Ext.decode(response.responseText);
168
                                                    var data_ = results.data;
169
                                                    s.loadData(results.data);
170
                                                    //s.reload()
171
                                                }
172
                                            });
173
                                            grid_.getStore().reload();
174

    
175
                                            frm.setHidden(true);
176
                                            grid_.setHidden(false);
177
                                            var p = Ext.ComponentQuery.query('[name = PanelMdDetail]')[0];
178
                                            p.setHeight(500);
179
                                            if (getParam('ApplicantID') != 'null') {
180
                                                var _param = {
181
                                                    serviceName: 'ERecruitmentAuthentication.asmx',
182
                                                    methodName: 'SendMailChangeMD',
183
                                                    parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
184

    
185
                                                };
186

    
187
                                                var results = null;
188
                                                Ext.Ajax.request({
189
                                                    method: 'post',
190
                                                    type: 'ajax',
191
                                                    params: _param,
192
                                                    url: '/InvokeService/Invoke/',
193
                                                    loadMask: {
194
                                                        msg: 'please wait...'
195
                                                    },
196
                                                    success: function (response) {}
197
                                                });
198
                                            }
199
                                            frm.destroy();
200

    
201
                                        } else {
202

    
203
                                            //MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
204
                                            //1=error 2=warning 4=confirm
205
                                            var msgType = result.message.type;
206
                                            if (msgType == 4) {
207
                                                mdConfirm(tableName, Ext.encode(frm.getValues()), frm.act, result.message.Id)
208
                                            } else {
209
                                                MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
210
                                            }
211
                                        }
212

    
213
                                    },
214
                                    failure: function (response) {
215
                                        pnl.unmask();
216
                                        var result = Ext.decode(response.responseText);
217
                                        console.log(result);
218
                                    }
219
                                });
220

    
221
                            } else {
222
                                var param_ = cekMandatoryIsNull(tableName);
223
                                if (grid_.tableName == 'PHRRC0052' && frm.getForm().monitor.items.items[6].getValue() == '1' && (frm.getForm().monitor.items.items[7].getValue() == undefined)) {
224
                                    MinovaMessage(' Not Null ', ' 000012 ', '', 'E');
225
                                } else if (grid_.tableName == 'PHRRC0052' && frm.getForm().monitor.items.items[15].getValue() == '1' && (frm.getForm().monitor.items.items[16].getValue() == '')){
226
									MinovaMessage(' Not Null ', ' 000013 ', '', 'E');
227
								} else if (grid_.tableName == 'PHRRC0052' && frm.getForm().monitor.items.items[18].getValue() == '1' && (frm.getForm().monitor.items.items[19].getValue() == '')){
228
									MinovaMessage(' Not Null ', ' 000014 ', '', 'E');
229
								} else if (param_ != "") {
230
                                    MinovaMessage(' Not Null ', ' 000009 ', param_, 'E');
231
                                } else {
232
                                    // ada field yang error
233
                                    var error_ = getErrorFields(tableName);
234
                                    if (error_ != ' ') {
235
                                        MinovaMessage(' title ', ' 000005 ', error_, 'E');
236
                                    }
237

    
238
                                }
239
                            }
240
                            //frm.unmask();
241
                            if (panelInt) {
242
                                panelInt.unmask();
243
                            }
244

    
245
                        }
246
                    }, {
247
                        text: 'Cancel',
248
                        hidden: cancel,
249
                        //margin: '0 3 15 0', //(top, right, bottom, left).
250
                        name: 'btnCancelForm',
251
                        iconCls: 'fa-undo',
252
                        style: 'font-family: FontAwesome',
253
                        viewForm: name + tableName,
254
                        handler: function () {
255
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
256
                                var layout = null;
257
                                var pnl = Ext.ComponentQuery.query('[name=panelTab' + tableName + ']')[0];
258
                                if (pnl) {
259
                                    layout = pnl.layoutType;
260
                                }
261
                                if (respone == "yes") {
262
                                    //if (layout == "L004") {
263
                                    Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0].setHidden(true);
264
                                    var FormEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
265
                                    if (FormEdit) {
266
                                        FormEdit.destroy();
267
                                    }
268
                                    var FormDis = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
269
                                    if (FormDis) {
270
                                        FormDis.setHidden(false);
271
                                    }
272
                                    //}
273
                                }
274
                            });
275

    
276
                        }
277
                    }, {
278
                        text: ' Delete ',
279
                        hidden: delete_,
280
                        //margin: ' 0 3 15 0 ', //(top, right, bottom, left).
281
                        iconCls: ' fa-trash-o',
282
                        name: ' btnDeleteMD ',
283
                        style: ' font - family : FontAwesome ',
284
                        action: ' CRUDdelete ',
285
                        handler: function () {
286

    
287
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
288
                            var grid_ = Ext.ComponentQuery.query('[gridMD = ' + tableName + ']')[0];
289
                            MinovaMessage(' Message ', ' 000007 ', ' ', 'C', function (respone) {
290
                                if (respone == "yes") {
291
                                    //frm.mask(' loading..');
292

    
293
                                    if (frm.getForm().isValid()) {
294
                                        Ext.Ajax.request({
295
                                            async: false,
296
                                            method: 'POST',
297
                                            url: '/Devt/SaveTable',
298
                                            params: {
299
                                                tableName: tableName,
300
                                                data: Ext.encode(frm.getValues()),
301
                                                action: '2'
302
                                            },
303
                                            waitMsg: ' Saving Data...',
304
                                            success: function (response) {
305
                                                var result = Ext.decode(response.responseText);
306
                                                var _FileID = frm.getForm().findField('FileID');
307
                                                if (result.success) {
308
                                                    if (_FileID) {
309
                                                        var FileID_ = frm.getForm().findField('FileID').getValue();
310
                                                        var FileName_ = Ext.ComponentQuery.query('[uploadName=uploadName]')[0].getValue(); ;
311
                                                        var valFile = {
312
                                                            Id: FileID_,
313
                                                            FileName: FileName_
314
                                                        };
315
                                                        Ext.Ajax.request({
316
                                                            async: false,
317
                                                            method: 'POST',
318
                                                            url: '/Devt/SaveTable',
319
                                                            params: {
320
                                                                tableName: 'SFILECATALOG',
321
                                                                data: Ext.encode(valFile),
322
                                                                action: '2'
323
                                                            },
324
                                                        });
325
                                                    }
326

    
327
                                                    MinovaMessage(' ', ' BSDEL ', ' ', ' S ');
328
                                                    var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
329
                                                    var s = menu.getStore();
330

    
331
                                                    Ext.Ajax.request({
332
                                                        async: false,
333
                                                        method: 'POST',
334
                                                        url: '/UserControl/GetStore',
335
                                                        params: {
336
                                                            tableName: ' PDSPA0013 ',
337
                                                            param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
338

    
339
                                                        },
340
                                                        success: function (response) {
341
                                                            var results = Ext.decode(response.responseText);
342
                                                            var data_ = results.data;
343
                                                            s.loadData(results.data);
344
                                                            //s.reload()
345
                                                        }
346
                                                    });
347

    
348
                                                    grid_.getStore().reload();
349

    
350
                                                    frm.setHidden(true);
351
                                                    grid_.setHidden(false);
352
                                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
353
                                                    p.setHeight(390);
354
                                                    if (getParam('ApplicantID') != 'null') {
355
                                                        var _param = {
356
                                                            serviceName: 'ERecruitmentAuthentication.asmx',
357
                                                            methodName: 'SendMailChangeMD',
358
                                                            parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
359

    
360
                                                        };
361

    
362
                                                        var results = null;
363
                                                        Ext.Ajax.request({
364
                                                            method: 'post',
365
                                                            type: 'ajax',
366
                                                            params: _param,
367
                                                            url: '/InvokeService/Invoke/',
368
                                                            loadMask: {
369
                                                                msg: 'please wait...'
370
                                                            },
371
                                                            success: function (response) {}
372
                                                        });
373
                                                    }
374
                                                    frm.destroy();
375

    
376
                                                } else {
377

    
378
                                                    //MinovaMessage('Not Null', '000005', result.message.text, 'E')
379
                                                    var msgType = result.message.type;
380
                                                    if (msgType == 4) {
381
                                                        mdConfirm(tableName, Ext.encode(frm.getValues()), '2', result.message.Id)
382
                                                    } else {
383
                                                        MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
384
                                                    }
385
                                                }
386

    
387
                                            },
388
                                            failure: function (response) {
389
                                                pnl.unmask();
390
                                                var result = Ext.decode(response.responseText);
391
                                                console.log(result);
392
                                            }
393
                                        });
394

    
395
                                    } else {
396
                                        var param_ = cekMandatoryIsNull(tableName);
397
                                        if (param_ != "") {
398
                                            MinovaMessage('Not Null', '000009', param_, 'E');
399
                                        } else {
400
                                            // ada field yang error
401
                                            var error_ = getErrorFields(tableName);
402
                                            if (error_ != '') {
403
                                                MinovaMessage('title', '000005', error_, 'E');
404
                                            }
405

    
406
                                        }
407
                                    }
408
                                    //frm.unmask();
409
                                }
410

    
411
                            });
412

    
413
                        }
414
                    }, {
415
                        text: 'Back',
416
                        hidden: back,
417
                        //margin: '0 3 15 0', //(top, right, bottom, left).
418
                        name: 'btnCancelMD',
419
                        iconCls: 'fa-reply',
420
                        style: 'font-family: FontAwesome',
421
                        viewForm: name + tableName,
422
                        handler: function () {
423
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
424
                                if (respone == "yes") {
425
                                    Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0].setHidden(true);
426
                                    Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(false);
427
                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
428
                                    if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
429
                                        Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = null;
430
                                    }
431
                                    var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
432
                                    Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle(grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
433
                                    p.setHeight(460);
434
                                    var FormEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
435
                                    if (FormEdit) {
436
                                        FormEdit.destroy();
437
                                    }
438
                                    var FormDis = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
439
                                    if (FormDis) {
440
                                        FormDis.destroy();
441
                                    }
442
                                }
443
                            });
444
                        }
445
                    }, {
446
                        text: 'Edit',
447
                        hidden: edit,
448
                        record: record,
449
                        //margin: '0 3 15 0', //(top, right, bottom, left).
450
                        //name: 'btnEditMD',
451
                        iconCls: 'fa-edit',
452
                        style: 'font-family: FontAwesome',
453
                        handler: function () {
454
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
455
                            p_.mask('Loading...');
456
                            var tbl = tableName;
457
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
458
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
459
                            renderToForm = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].renderToForm;
460
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
461
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
462
                            } else {
463
                                mdgenerator.createFormCard(tableName, "", "", renderToForm, false, selecton_, '1', '0');
464
                            }
465

    
466
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
467
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
468
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
469
                            if (tinggi < 330) {
470
                                tinggi = 330;
471
                            }
472
                            p.setHeight(tinggi + 100);
473
                            Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
474
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '1';
475
                            //Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Edit - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
476
                            Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Edit' + ' - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
477

    
478
                            setValueAmountEncrypt(tbl);
479
                            p_.unmask();
480
                            setKeyDisabled(true);
481
                        }
482
                    }, {
483
                        text: 'Add',
484
                        hidden: add,
485
                        record: record,
486
                        //margin: '0 3 15 0', //(top, right, bottom, left).
487
                        //name: 'btnAddMD',
488
                        iconCls: 'fa-plus-circle',
489
                        style: 'font-family: FontAwesome',
490
                        handler: function () {
491
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
492
                            p_.mask('Loading...');
493
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
494
                            renderToForm = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].renderToForm;
495
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
496
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
497
                            } else {
498
                                mdgenerator.createFormCard(tableName, "", "", renderToForm, false, '', '0', '0');
499
                            }
500
                            var form_ = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm();
501
                            form_.reset();
502
                            form_.findField('EmployeeID').setValue(getParam('EmployeeID'));
503
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
504
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
505
                            if (tinggi < 330) {
506
                                tinggi = 330;
507
                            }
508
                            p.setHeight(tinggi + 100);
509
                            Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(true);
510
                            Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true); //Bedanya disini
511
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '0';
512
                            Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Add' + ' - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
513
                            p_.unmask();
514
                            setKeyDisabled(false);
515
                        }
516
                    }, {
517
                        text: 'Copy',
518
                        hidden: copy,
519
                        record: record,
520
                        //margin: '0 3 15 0', //(top, right, bottom, left).
521
                        //name: 'btnCopyMD',
522
                        iconCls: 'fa-copy',
523
                        style: 'font-family: FontAwesome',
524
                        handler: function () {
525
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
526
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
527
                            if (selecton_) {
528
                                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
529
                                p_.mask('Loading...');
530
                                renderToForm = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].renderToForm;
531
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
532
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
533
                                } else {
534
                                    mdgenerator.createFormCard(tableName, "", "", renderToForm, false, selecton_, '0', '0');
535
                                }
536
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().reset();
537
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
538
                                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
539
                                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
540
                                if (tinggi < 330) {
541
                                    tinggi = 330;
542
                                }
543
                                p.setHeight(tinggi + 100);
544
                                grid_.setHidden(true);
545
                                Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true); //Bedanya disini
546
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '0'
547
                                    Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Copy' + ' - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
548
                                var tbl = tableName;
549
                                setValueAmountEncrypt(tbl);
550
                                p_.unmask();
551
                                setKeyDisabled(false);
552
                                setFileID(0);
553
                            }
554
                        }
555
                    },
556
                ],
557
            },
558
        ]
559
    });
560

    
561
    Ext.ComponentQuery.query('[name=Main]')[0].lastView = Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0];
562
}
563

    
564
mdgenerator.createFormCardLastRecord = function (tableName, layout, param_, renderTo, isDisplay, record, act) {
565
    var name = 'MinovaGridFormEdit';
566
    var save = true;
567
    var edit = false;
568
    var delete_ = true;
569
    var back = false;
570

    
571
    if (isDisplay) {
572
        name = 'MinovaGridFormDisplay'
573
    } else {
574
        save = false;
575
        edit = true;
576
        delete_ = false;
577
        back = false;
578
    }
579
    Ext.create('Ext.form.Panel', {
580
        renderTo: renderTo,
581
        name: name + tableName,
582
        lastRecForm: name + tableName,
583
        formMD: tableName,
584
        act: null,
585
        items: [{
586
                xtype: 'minovaForm',
587
                name: name,
588
                tableName: tableName,
589
                margin: '0 0 10 0',
590
                isDisplay: isDisplay,
591
                //hidden:true
592
                buttons: [{
593
                        text: 'Save',
594
                        hidden: save,
595
                        act: act,
596
                        //margin: '0 3 15 0', //(top, right, bottom, left).
597
                        name: 'btnSaveMD',
598
                        iconCls: 'fa-save',
599
                        style: 'font-family: FontAwesome',
600
                        handler: function () {
601
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
602
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
603
                            frm.mask('loading..');
604

    
605
                            if (frm.getForm().isValid()) {
606
                                Ext.Ajax.request({
607
                                    method: 'POST',
608
                                    async: false,
609
                                    url: '/Devt/SaveTable',
610
                                    params: {
611
                                        tableName: tableName,
612
                                        data: Ext.encode(frm.getValues()),
613
                                        action: frm.act
614
                                    },
615
                                    waitMsg: 'Saving Data...',
616
                                    success: function (response) {
617
                                        var result = Ext.decode(response.responseText);
618
                                        if (result.success) {
619

    
620
                                            MinovaMessage('Not Null', '000006', '', 'S');
621
                                            var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
622
                                            var s = menu.getStore();
623

    
624
                                            Ext.Ajax.request({
625
                                                async: false,
626
                                                method: 'POST',
627
                                                url: '/UserControl/GetStore',
628
                                                params: {
629
                                                    tableName: ' PDSPA0013 ',
630
                                                    param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
631

    
632
                                                },
633
                                                success: function (response) {
634
                                                    var results = Ext.decode(response.responseText);
635
                                                    var data_ = results.data;
636
                                                    s.loadData(results.data);
637
                                                    //s.reload()
638
                                                }
639
                                            });
640

    
641
                                            grid_.getStore().reload();
642

    
643
                                            console.log('3');
644

    
645
                                            frm.setHidden(true);
646
                                            grid_.setHidden(false);
647
                                            var p = Ext.ComponentQuery.query('[name = PanelMdDetail]')[0];
648
                                            if (getParam('ApplicantID') != 'null') {
649
                                                var _param = {
650
                                                    serviceName: 'ERecruitmentAuthentication.asmx',
651
                                                    methodName: 'SendMailChangeMD',
652
                                                    parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
653

    
654
                                                };
655

    
656
                                                var results = null;
657
                                                Ext.Ajax.request({
658
                                                    method: 'post',
659
                                                    type: 'ajax',
660
                                                    params: _param,
661
                                                    url: '/InvokeService/Invoke/',
662
                                                    loadMask: {
663
                                                        msg: 'please wait...'
664
                                                    },
665
                                                    success: function (response) {}
666
                                                });
667
                                            }
668
                                            p.setHeight(390);
669

    
670
                                        } else {
671

    
672
                                            //MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E')
673
                                            var msgType = result.message.type;
674
                                            if (msgType == 4) {
675
                                                mdConfirm(tableName, Ext.encode(frm.getValues()), frm.act, result.message.Id)
676
                                            } else {
677
                                                MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
678
                                            }
679
                                        }
680

    
681
                                    },
682
                                    failure: function (response) {
683
                                        pnl.unmask();
684
                                        var result = Ext.decode(response.responseText);
685
                                        console.log(result);
686
                                    }
687
                                });
688

    
689
                            } else {
690
                                var param_ = cekMandatoryIsNull(tableName);
691
                                if (param_ != "") {
692
                                    MinovaMessage(' Not Null ', ' 000009 ', param_, 'E');
693
                                } else {
694
                                    // ada field yang error
695
                                    var error_ = getErrorFields(tableName);
696
                                    if (error_ != ' ') {
697
                                        MinovaMessage(' title ', ' 000005 ', error_, 'E');
698
                                    }
699

    
700
                                }
701
                            }
702
                            frm.unmask();
703
                        }
704
                    }, {
705
                        text: ' Delete ',
706
                        hidden: delete_,
707
                        margin: ' 0 3 15 0 ', //(top, right, bottom, left).
708
                        iconCls: ' fa - trash - o ',
709
                        name: ' btnDeleteMD ',
710
                        style: ' font - family : FontAwesome ',
711
                        action: ' CRUDdelete ',
712
                        handler: function () {
713
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
714
                            var grid_ = Ext.ComponentQuery.query('[gridMD = ' + tableName + ']')[0];
715
                            MinovaMessage(' Message ', ' 000007 ', ' ', 'C', function (respone) {
716
                                if (respone == "yes") {
717
                                    frm.mask(' loading..');
718

    
719
                                    if (frm.getForm().isValid()) {
720
                                        Ext.Ajax.request({
721
                                            async: false,
722
                                            method: 'POST',
723
                                            url: '/Devt/SaveTable',
724
                                            params: {
725
                                                tableName: tableName,
726
                                                data: Ext.encode(frm.getValues()),
727
                                                action: '2'
728
                                            },
729
                                            waitMsg: ' Saving Data...',
730
                                            success: function (response) {
731
                                                var result = Ext.decode(response.responseText);
732
                                                if (result.success) {
733

    
734
                                                    MinovaMessage(' ', ' BSDEL ', ' ', ' S ');
735
                                                    var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
736
                                                    var s = menu.getStore();
737

    
738
                                                    Ext.Ajax.request({
739
                                                        async: false,
740
                                                        method: 'POST',
741
                                                        url: '/UserControl/GetStore',
742
                                                        params: {
743
                                                            tableName: ' PDSPA0013 ',
744
                                                            param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
745

    
746
                                                        },
747
                                                        success: function (response) {
748
                                                            var results = Ext.decode(response.responseText);
749
                                                            var data_ = results.data;
750
                                                            s.loadData(results.data);
751
                                                            // console.log(data_)
752

    
753
                                                        }
754
                                                    });
755

    
756
                                                    grid_.getStore().reload();
757
                                                    console.log('4');
758
                                                    frm.setHidden(true);
759
                                                    grid_.setHidden(false);
760
                                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
761
                                                    if (getParam('ApplicantID') != 'null') {
762
                                                        var _param = {
763
                                                            serviceName: 'ERecruitmentAuthentication.asmx',
764
                                                            methodName: 'SendMailChangeMD',
765
                                                            parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
766

    
767
                                                        };
768

    
769
                                                        var results = null;
770
                                                        Ext.Ajax.request({
771
                                                            method: 'post',
772
                                                            type: 'ajax',
773
                                                            params: _param,
774
                                                            url: '/InvokeService/Invoke/',
775
                                                            loadMask: {
776
                                                                msg: 'please wait...'
777
                                                            },
778
                                                            success: function (response) {}
779
                                                        });
780
                                                    }
781
                                                    p.setHeight(390);
782

    
783
                                                } else {
784

    
785
                                                    //MinovaMessage('Not Null', '000005', result.message.text, 'E')
786
                                                    var msgType = result.message.type;
787
                                                    if (msgType == 4) {
788
                                                        mdConfirm(tableName, Ext.encode(frm.getValues()), '2', result.message.Id)
789
                                                    } else {
790
                                                        MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
791
                                                    }
792
                                                }
793

    
794
                                            },
795
                                            failure: function (response) {
796
                                                pnl.unmask();
797
                                                var result = Ext.decode(response.responseText);
798
                                                console.log(result);
799
                                            }
800
                                        });
801

    
802
                                    } else {
803
                                        var param_ = cekMandatoryIsNull(tableName);
804
                                        if (param_ != "") {
805
                                            MinovaMessage('Not Null', '000009', param_, 'E');
806
                                        } else {
807
                                            // ada field yang error
808
                                            var error_ = getErrorFields(tableName);
809
                                            if (error_ != '') {
810
                                                MinovaMessage('title', '000005', error_, 'E');
811
                                            }
812

    
813
                                        }
814
                                    }
815
                                    frm.unmask();
816
                                }
817

    
818
                            });
819

    
820
                        }
821

    
822
                    }, {
823
                        text: 'Go to Grid',
824
                        hidden: back,
825
                        //margin: '0 3 15 0', //(top, right, bottom, left).
826
                        name: 'btnCancelMD',
827
                        iconCls: 'fa-reply',
828
                        style: 'font-family: FontAwesome',
829
                        viewForm: name + tableName,
830
                        handler: function () {
831
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
832
                                if (respone == "yes") {
833
                                    Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0].setHidden(true);
834
                                    Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(false);
835
                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
836
                                    if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
837
                                        Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = null;
838
                                    }
839

    
840
                                    p.setHeight(390);
841
                                }
842
                            });
843

    
844
                        }
845
                    }, {
846
                        text: 'Edit',
847
                        hidden: edit,
848
                        record: record,
849
                        //margin: '0 3 15 0', //(top, right, bottom, left).
850
                        //name: 'btnEditMD',
851
                        iconCls: 'fa-edit',
852
                        style: 'font-family: FontAwesome',
853
                        handler: function () {
854
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
855
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
856
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
857
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
858
                            } else {
859
                                mdgenerator.createFormCard(tableName, "", "", grid_.renderToForm, false, selecton_, '1');
860
                            }
861

    
862
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
863
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
864
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
865
                            if (tinggi < 330) {
866
                                tinggi = 330;
867
                            }
868
                            p.setHeight(tinggi + 100);
869
                            Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
870
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '1';
871
                            //Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Edit - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
872
                            Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Edit' + ' - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
873
                            var tbl = tableName;
874
                            setValueAmountEncrypt(tbl);
875
                        }
876
                    },
877
                ],
878

    
879
            },
880
        ]
881
    });
882

    
883
    Ext.ComponentQuery.query('[name=Main]')[0].lastView = Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0];
884

    
885
}
886

    
887
mdgenerator.createFormL002 = function (tableName, layout, param_, renderTo, isDisplay, record, act) {
888
    var name = 'MinovaGridFormEdit';
889
    var save = true;
890
    var edit = false;
891
    var delete_ = true;
892
    var back = false;
893

    
894
    if (isDisplay) {
895
        name = 'MinovaGridFormDisplay'
896
    } else {
897
        save = false;
898
        edit = true;
899
        delete_ = false;
900
        back = false;
901
    }
902
    var userAction = MinovaUtil.GetActionMenu();
903
    if (userAction != '1') {
904
        save = true;
905
        edit = true;
906
        delete_ = true;
907
    }
908

    
909
    if (tableName.toLowerCase().substring(0, 5) == 'phrrc') {
910
        Ext.Ajax.request({
911
            async: false,
912
            method: 'POST',
913
            url: '/UserControl/GetStore',
914
            params: {
915
                tableName: 'phrpa0015',
916
                param: 'ApplicantID[equal]' + getParam('app')
917
            },
918
            success: function (response) {
919
                var results = Ext.decode(response.responseText);
920
                data_ = results.data;
921
                if (data_.length > 0) {
922
                    save = true;
923
                    edit = true;
924
                    delete_ = true;
925
                }
926
            }
927
        });
928
    }
929
    Ext.create('Ext.form.Panel', {
930
        renderTo: renderTo,
931
        name: name + tableName,
932
        collapsible: true,
933
        formMD: tableName,
934
        act: null,
935
        items: [{
936
                xtype: 'minovaForm',
937
                name: name,
938

    
939
                //title: 'judul',
940
                tableName: tableName,
941
                margin: '0 0 10 0',
942
                isDisplay: isDisplay,
943
                //hidden:true
944
                buttons: [{
945
                        text: 'Save',
946
                        hidden: save,
947
                        act: act,
948
                        //margin: '0 3 15 0', //(top, right, bottom, left).
949
                        name: 'btnSaveMD',
950
                        iconCls: 'fa-save',
951
                        style: 'font-family: FontAwesome',
952
                        handler: function () {
953
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
954
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
955
                            //frm.mask('loading..');
956

    
957
                            if (frm.getForm().isValid()) {
958
                                Ext.Ajax.request({
959
                                    method: 'POST',
960
                                    async: false,
961
                                    url: '/Devt/SaveTable',
962
                                    params: {
963
                                        tableName: tableName,
964
                                        data: Ext.encode(frm.getValues()),
965
                                        action: frm.act
966
                                    },
967
                                    waitMsg: 'Saving Data...',
968
                                    success: function (response) {
969
                                        var result = Ext.decode(response.responseText);
970
                                        if (result.success) {
971

    
972
                                            MinovaMessage('Not Null', '000006', '', 'S');
973
                                            var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
974
                                            var s = menu.getStore();
975

    
976
                                            Ext.Ajax.request({
977
                                                async: false,
978
                                                method: 'POST',
979
                                                url: '/UserControl/GetStore',
980
                                                params: {
981
                                                    tableName: ' PDSPA0013 ',
982
                                                    param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
983

    
984
                                                },
985
                                                success: function (response) {
986
                                                    var results = Ext.decode(response.responseText);
987
                                                    var data_ = results.data;
988
                                                    s.loadData(results.data);
989
                                                    //s.reload()
990
                                                }
991
                                            });
992

    
993
                                            grid_.getStore().reload();
994
                                            console.log('5');
995
                                            frm.setHidden(true);
996
                                            grid_.setHidden(false);
997
                                            var p = Ext.ComponentQuery.query('[name = PanelMdDetail]')[0];
998
                                            p.setHeight(390);
999
                                            if (getParam('ApplicantID') != 'null') {
1000
                                                var _param = {
1001
                                                    serviceName: 'ERecruitmentAuthentication.asmx',
1002
                                                    methodName: 'SendMailChangeMD',
1003
                                                    parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
1004

    
1005
                                                };
1006

    
1007
                                                var results = null;
1008
                                                Ext.Ajax.request({
1009
                                                    method: 'post',
1010
                                                    type: 'ajax',
1011
                                                    params: _param,
1012
                                                    url: '/InvokeService/Invoke/',
1013
                                                    loadMask: {
1014
                                                        msg: 'please wait...'
1015
                                                    },
1016
                                                    success: function (response) {}
1017
                                                });
1018
                                            }
1019
                                            frm.destroy();
1020
                                        } else {
1021

    
1022
                                            //MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E')
1023
                                            var msgType = result.message.type;
1024
                                            if (msgType == 4) {
1025
                                                mdConfirm(tableName, Ext.encode(frm.getValues()), frm.act, result.message.Id)
1026
                                            } else {
1027
                                                MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
1028
                                            }
1029
                                        }
1030

    
1031
                                    },
1032
                                    failure: function (response) {
1033
                                        pnl.unmask();
1034
                                        var result = Ext.decode(response.responseText);
1035
                                        console.log(result);
1036
                                    }
1037
                                });
1038

    
1039
                            } else {
1040
                                var param_ = cekMandatoryIsNull(tableName);
1041
                                if (param_ != "") {
1042
                                    MinovaMessage(' Not Null ', ' 000009 ', param_, 'E');
1043
                                } else {
1044
                                    // ada field yang error
1045
                                    var error_ = getErrorFields(tableName);
1046
                                    if (error_ != ' ') {
1047
                                        MinovaMessage(' title ', ' 000005 ', error_, 'E');
1048
                                    }
1049

    
1050
                                }
1051
                                // frm.unmask();
1052
                            }
1053

    
1054
                        }
1055
                    }, {
1056
                        text: ' Delete ',
1057
                        hidden: delete_,
1058
                        margin: ' 0 3 15 0 ', //(top, right, bottom, left).
1059
                        iconCls: ' fa - trash - o ',
1060
                        name: ' btnDeleteMD ',
1061
                        style: ' font - family : FontAwesome ',
1062
                        action: ' CRUDdelete ',
1063
                        handler: function () {
1064
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1065
                            var grid_ = Ext.ComponentQuery.query(' minovagridmd[tableName = ' + tableName + ']')[0];
1066
                            MinovaMessage(' Message ', ' 000007 ', ' ', 'C', function (respone) {
1067
                                if (respone == "yes") {
1068
                                    //frm.mask(' loading..');
1069

    
1070
                                    if (frm.getForm().isValid()) {
1071
                                        Ext.Ajax.request({
1072
                                            method: 'POST',
1073
                                            async: false,
1074
                                            url: '/Devt/SaveTable',
1075
                                            params: {
1076
                                                tableName: tableName,
1077
                                                data: Ext.encode(frm.getValues()),
1078
                                                action: '2'
1079
                                            },
1080
                                            waitMsg: ' Saving Data...',
1081
                                            success: function (response) {
1082
                                                var result = Ext.decode(response.responseText);
1083
                                                if (result.success) {
1084
                                                    if (frm.getForm().findField('FileID')) {
1085
                                                        var FileID_ = frm.getForm().findField('FileID').getValue();
1086
                                                        var FileName_ = Ext.ComponentQuery.query('[uploadName=uploadName]')[0].getValue();
1087
                                                        var valFile = {
1088
                                                            Id: FileID_,
1089
                                                            FileName: FileName_
1090
                                                        };
1091
                                                        Ext.Ajax.request({
1092
                                                            async: false,
1093
                                                            method: 'POST',
1094
                                                            url: '/Devt/SaveTable',
1095
                                                            params: {
1096
                                                                tableName: 'SFILECATALOG',
1097
                                                                data: Ext.encode(valFile),
1098
                                                                action: '2'
1099
                                                            },
1100
                                                        });
1101
                                                    }
1102
                                                    MinovaMessage(' Not Null ', ' 000006 ', ' ', ' S ');
1103
                                                    var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
1104
                                                    var s = menu.getStore();
1105

    
1106
                                                    Ext.Ajax.request({
1107
                                                        async: false,
1108
                                                        method: 'POST',
1109
                                                        url: '/UserControl/GetStore',
1110
                                                        params: {
1111
                                                            tableName: ' PDSPA0013 ',
1112
                                                            param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
1113

    
1114
                                                        },
1115
                                                        success: function (response) {
1116
                                                            var results = Ext.decode(response.responseText);
1117
                                                            var data_ = results.data;
1118
                                                            s.loadData(results.data);
1119
                                                            //s.reload()
1120
                                                        }
1121
                                                    });
1122

    
1123
                                                    grid_.getStore().reload();
1124
                                                    console.log('6');
1125
                                                    frm.setHidden(true);
1126
                                                    grid_.setHidden(false);
1127
                                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1128
                                                    if (getParam('ApplicantID') != 'null') {
1129
                                                        var _param = {
1130
                                                            serviceName: 'ERecruitmentAuthentication.asmx',
1131
                                                            methodName: 'SendMailChangeMD',
1132
                                                            parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
1133

    
1134
                                                        };
1135

    
1136
                                                        var results = null;
1137
                                                        Ext.Ajax.request({
1138
                                                            method: 'post',
1139
                                                            type: 'ajax',
1140
                                                            params: _param,
1141
                                                            url: '/InvokeService/Invoke/',
1142
                                                            loadMask: {
1143
                                                                msg: 'please wait...'
1144
                                                            },
1145
                                                            success: function (response) {}
1146
                                                        });
1147
                                                    }
1148
                                                    p.setHeight(390);
1149
                                                    //frm.unmask();
1150
                                                    frm.destroy();
1151
                                                } else {
1152

    
1153
                                                    //MinovaMessage('Not Null', '000005', result.message.text, 'E')
1154
                                                    var msgType = result.message.type;
1155
                                                    if (msgType == 4) {
1156
                                                        mdConfirm(tableName, Ext.encode(frm.getValues()), '2', result.message.Id)
1157
                                                    } else {
1158
                                                        MinovaMessage(' Not Null ', ' 000005 ', result.message.text, 'E');
1159
                                                    }
1160
                                                }
1161

    
1162
                                            },
1163
                                            failure: function (response) {
1164
                                                pnl.unmask();
1165
                                                var result = Ext.decode(response.responseText);
1166
                                                console.log(result);
1167
                                            }
1168
                                        });
1169

    
1170
                                    } else {
1171
                                        var param_ = cekMandatoryIsNull(tableName);
1172
                                        if (param_ != "") {
1173
                                            MinovaMessage('Not Null', '000009', param_, 'E');
1174
                                        } else {
1175
                                            // ada field yang error
1176
                                            var error_ = getErrorFields(tableName);
1177
                                            if (error_ != '') {
1178
                                                MinovaMessage('title', '000005', error_, 'E');
1179
                                            }
1180

    
1181
                                        }
1182
                                        //frm.unmask();
1183
                                    }
1184
                                }
1185
                            });
1186

    
1187
                        }
1188
                    }, {
1189
                        text: 'Back to Grid',
1190
                        hidden: back,
1191
                        //margin: '0 3 15 0', //(top, right, bottom, left).
1192
                        name: 'btnCancelMD',
1193
                        iconCls: 'fa-reply',
1194
                        style: 'font-family: FontAwesome',
1195
                        viewForm: name + tableName,
1196
                        handler: function () {
1197
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
1198
                                if (respone == "yes") {
1199
                                    Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0].setHidden(true);
1200
                                    //Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(false);
1201
                                    var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1202
                                    if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1203
                                        Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
1204
                                        //Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = null;
1205
                                    }
1206
                                    if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1207
                                        Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(true);
1208
                                        //Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = null;
1209
                                    }
1210
                                    p.setHeight(390);
1211
                                    var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1212
                                    Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle(grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"));
1213

    
1214
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].destroy();
1215
                                }
1216
                            });
1217

    
1218
                        }
1219
                    }, {
1220
                        text: 'Edit',
1221
                        hidden: edit,
1222
                        record: record,
1223
                        //margin: '0 3 15 0', //(top, right, bottom, left).
1224
                        //name: 'btnEditMD',
1225
                        iconCls: 'fa-edit',
1226
                        style: 'font-family: FontAwesome',
1227
                        handler: function () {
1228
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1229
                            p_.mask('Loading...');
1230
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1231
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
1232

    
1233
                            Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
1234
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1235
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
1236
                            } else {
1237
                                mdgenerator.createFormL002(tableName, "", "", renderTo, false, record, '1');
1238
                            }
1239

    
1240
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
1241
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1242
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1243
                            if (tinggi < 330) {
1244
                                tinggi = 380;
1245
                            }
1246
                            p.setHeight(380 + tinggi + 100);
1247

    
1248
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '1';
1249
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Edit - ' + grid_.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
1250
                            var tbl = tableName;
1251
                            setValueAmountEncrypt(tbl);
1252
                            p_.unmask();
1253
                            setKeyDisabled(true);
1254
                        }
1255
                    },
1256
                ],
1257

    
1258
            },
1259
        ]
1260
    });
1261

    
1262
    Ext.ComponentQuery.query('[name=Main]')[0].lastView = Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0];
1263
}
1264

    
1265
mdgenerator.createGrid = function (tableName, layout, param_, renderTo) {
1266

    
1267
    Ext.create('MinovaUtil.MinovaES.MinovaGridMD', {
1268
        renderTo: renderTo,
1269
        renderToForm: renderTo,
1270
        tableName: tableName,
1271
        storename: tableName + 'Grid',
1272
        name: 'gridMD' + tableName,
1273
        pagesize: 10,
1274
        param: param_,
1275
        height: 330,
1276
        margin: '0 0 10 0',
1277
        tbar: [{
1278
                xtype: 'button',
1279
                text: 'Action',
1280
                name: 'actionGrid',
1281
                menu: [{
1282
                        text: 'Add',
1283
                        name: 'addGrid',
1284
                        action: 'CRUDaddNewRecord',
1285
                        style: 'font-family: FontAwesome',
1286
                        itemId: 'AddData',
1287
                        iconCls: 'fa-plus-circle',
1288

    
1289
                    }, {
1290
                        text: 'Copy',
1291
                        name: 'CopyGrid',
1292
                        iconCls: 'fa-copy',
1293
                        style: 'font-family: FontAwesome',
1294
                    }, {
1295
                        text: 'Edit',
1296
                        name: 'EditGrid',
1297
                        iconCls: 'fa-edit',
1298
                        style: 'font-family: FontAwesome',
1299
                    }, {
1300
                        text: 'Delete',
1301
                        name: 'DeleteGrid',
1302
                        hidden: true,
1303
                        iconCls: 'fa-trash-o',
1304
                        style: 'font-family: FontAwesome',
1305
                    }
1306
                ]
1307
            }, {
1308
                xtype: 'tbfill'
1309
            }, {
1310
                text: 'Clear Filters',
1311
                tooltip: 'Clear all filters',
1312
                name: 'clearbtn',
1313
                handler: function () {
1314
                    var tolbar = this.up()
1315
                        var grid_ = tolbar.up()
1316
                        grid_.filters.clearFilters()
1317
                }
1318
            }, ],
1319

    
1320
        dockedItems: [{
1321
                xtype: 'pagingtoolbar',
1322
                store: tableName + 'Grid',
1323
                dock: 'bottom', //posisi paging
1324
                pageSize: 10,
1325
                displayInfo: true,
1326

    
1327
            }
1328
        ],
1329
    });
1330
}
1331

    
1332
mdgenerator.createGridCard = function (tableName, layout, param_, renderTo, Label) {
1333
    var userAction = MinovaUtil.GetActionMenu();
1334
    var _empID = getParam('EmployeeID');
1335
    if (userAction != '1') {
1336
        add = true;
1337

    
1338
    } else {
1339
        add = false;
1340
    }
1341
    if (tableName.toLowerCase().substring(0, 5) == 'phrrc') {
1342
        _empID = getParam('ApplicantID'); //getParam('app')
1343
        Ext.Ajax.request({
1344
            async: false,
1345
            method: 'POST',
1346
            url: '/UserControl/GetStore',
1347
            params: {
1348
                tableName: 'phrpa0015',
1349
                param: 'ApplicantID[equal]' + _empID
1350
            },
1351
            success: function (response) {
1352
                var results = Ext.decode(response.responseText);
1353
                data_ = results.data;
1354
                if (data_.length > 0) {
1355
                    add = true;
1356

    
1357
                }
1358
            }
1359
        });
1360
    }
1361

    
1362
    Ext.create('MinovaUtil.MinovaES.MinovaGridMD', {
1363
        renderTo: renderTo,
1364
        renderToForm: renderTo,
1365
        tableName: tableName,
1366
        storename: tableName + 'Grid',
1367
        name: 'gridMD' + tableName,
1368
        pagesize: 10,
1369
        param: param_,
1370
        height: 357,
1371
        margin: '0 0 10 0',
1372
        gridMD: tableName,
1373
        tableDesc: Label,
1374
        tbar: [{
1375
                xtype: 'button',
1376
                text: 'Action',
1377
                hidden: add,
1378
                name: 'actionGrid',
1379
                menu: [{
1380
                        text: 'Add',
1381
                        name: 'addGrid',
1382
                        action: 'CRUDaddNewRecord',
1383
                        style: 'font-family: FontAwesome',
1384
                        itemId: 'AddData',
1385
                        iconCls: 'fa-plus-circle',
1386
                        handler: function () {
1387
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1388
                            p_.mask('Loading...');
1389
                            renderToForm = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].renderToForm;
1390
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1391
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
1392
                            } else {
1393
                                mdgenerator.createFormCard(tableName, "", "", renderToForm, false, '', '0');
1394
                            }
1395

    
1396
                            var form_ = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm();
1397
                            form_.reset();
1398
                            form_.findField('EmployeeID').setValue(_empID);
1399
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1400
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1401
                            if (tinggi < 330) {
1402
                                tinggi = 330;
1403
                            }
1404
                            p.setHeight(tinggi + 100);
1405
                            Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(true);
1406
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '0';
1407

    
1408
                            Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Add' + ' - ' + Label + ' - ' + _empID + ' - ' + getParam("FullName"));
1409
                            p_.unmask();
1410
                            setKeyDisabled(false);
1411
                        }
1412
                    }, {
1413
                        text: 'Copy',
1414
                        name: 'CopyGrid',
1415
                        iconCls: 'fa-copy',
1416
                        style: 'font-family: FontAwesome',
1417
                        handler: function () {
1418

    
1419
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1420
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
1421
                            if (selecton_) {
1422
                                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1423
                                p_.mask('Loading...');
1424
                                renderToForm = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].renderToForm;
1425
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1426
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
1427
                                } else {
1428
                                    mdgenerator.createFormCard(tableName, "", "", renderToForm, false, selecton_, '0');
1429
                                }
1430
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().reset();
1431
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
1432
                                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1433
                                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1434
                                if (tinggi < 330) {
1435
                                    tinggi = 330;
1436
                                }
1437
                                p.setHeight(tinggi + 100);
1438
                                grid_.setHidden(true);
1439
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '0'
1440
                                    Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Copy' + ' - ' + grid_.tableDesc + ' - ' + _empID + ' - ' + getParam("FullName"));
1441
                                var tbl = tableName;
1442
                                setValueAmountEncrypt(tbl);
1443
                                p_.unmask();
1444
                                setKeyDisabled(false);
1445
                                setFileID(0);
1446
                            }
1447

    
1448
                        }
1449
                    }, {
1450
                        text: 'Edit',
1451
                        name: 'EditGrid',
1452
                        iconCls: 'fa-edit',
1453
                        style: 'font-family: FontAwesome',
1454
                        handler: function () {
1455
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1456
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
1457
                            if (selecton_) {
1458
                                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1459
                                p_.mask('Loading...');
1460
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1461
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
1462
                                } else {
1463
                                    mdgenerator.createFormCard(tableName, "", "", grid_.renderToForm, false, selecton_, '1');
1464
                                }
1465
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().reset();
1466
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
1467
                                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1468
                                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1469
                                if (tinggi < 330) {
1470
                                    tinggi = 330;
1471
                                }
1472
                                p.setHeight(tinggi + 100);
1473
                                grid_.setHidden(true);
1474
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '1';
1475
                                Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('Edit' + ' - ' + grid_.tableDesc + ' - ' + _empID + ' - ' + getParam("FullName"));
1476
                                var tbl = tableName;
1477
                                setValueAmountEncrypt(tbl);
1478
                                p_.unmask();
1479
                                setKeyDisabled(true);
1480
                            }
1481

    
1482
                        }
1483
                    }, {
1484
                        text: 'Delete',
1485
                        name: 'DeleteGrid',
1486
                        hidden: true,
1487
                        iconCls: 'fa-trash-o',
1488
                        style: 'font-family: FontAwesome',
1489
                    }
1490
                ]
1491
            }, {
1492
                xtype: 'tbfill'
1493
            }, {
1494
                text: 'Clear Filters',
1495
                tooltip: 'Clear all filters',
1496
                name: 'clearbtn',
1497
                handler: function () {
1498
                    var tolbar = this.up()
1499
                        var grid_ = tolbar.up()
1500
                        grid_.filters.clearFilters()
1501
                }
1502
            }, ],
1503

    
1504
        dockedItems: [{
1505
                xtype: 'pagingtoolbar',
1506
                store: tableName + 'Grid',
1507
                dock: 'bottom', //posisi paging
1508
                pageSize: 10,
1509
                displayInfo: true,
1510

    
1511
            }
1512
        ],
1513
        listeners: {
1514
            'itemdblclick': function (me, record, item, index, e, eOpts) {
1515
                // me.el.mask("Loading...");
1516
                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1517
                p_.mask('Loading...');
1518

    
1519
                var g = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1520
                if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1521
                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(false)
1522
                } else {
1523
                    mdgenerator.createFormCard(g.tableName, "", "", g.renderToForm, true, record, '1');
1524
                }
1525

    
1526
                var fDisplay = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
1527
                //mdgenerator.FakeValue(fDisplay)
1528

    
1529
                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1530

    
1531
                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getHeight();
1532
                if (tinggi < 330) {
1533
                    tinggi = 330;
1534
                }
1535
                p.setHeight(tinggi + 150);
1536
                fDisplay.reset();
1537
                fDisplay.getForm().setValues(record.data);
1538
                g.setHidden(true);
1539
                Ext.ComponentQuery.query('[name=DetailMD]')[0].setTitle('view' + ' - ' + g.tableDesc + ' - ' + _empID + ' - ' + getParam("FullName"));
1540
                // me.unmask();
1541
                var tbl = tableName;
1542
                setValueAmountEncryptDisplayField(tbl);
1543
                p_.unmask();
1544
            },
1545
        },
1546
    });
1547

    
1548
    //'gridMD' + tableName
1549
    Ext.ComponentQuery.query('[name=Main]')[0].lastView = Ext.ComponentQuery.query('[name=gridMD' + tableName + ']')[0];
1550
}
1551

    
1552
mdgenerator.createGridL002 = function (tableName, layout, param_, renderTo, Label) {
1553
    var userAction = MinovaUtil.GetActionMenu();
1554
    if (userAction != '1') {
1555
        add = true;
1556

    
1557
    } else {
1558
        add = false;
1559
    }
1560
    if (tableName.toLowerCase().substring(0, 5) == 'phrrc') {
1561
        Ext.Ajax.request({
1562
            async: false,
1563
            method: 'POST',
1564
            url: '/UserControl/GetStore',
1565
            params: {
1566
                tableName: 'phrpa0015',
1567
                param: 'ApplicantID[equal]' + getParam('app')
1568
            },
1569
            success: function (response) {
1570
                var results = Ext.decode(response.responseText);
1571
                data_ = results.data;
1572
                if (data_.length > 0) {
1573
                    add = true;
1574

    
1575
                }
1576
            }
1577
        });
1578
    }
1579
    Ext.create('MinovaUtil.MinovaES.MinovaGridMD', {
1580
        renderTo: renderTo,
1581
        renderToForm: renderTo,
1582
        tableName: tableName,
1583
        storename: tableName + 'Grid',
1584
        name: 'gridMD' + tableName,
1585
        pagesize: 10,
1586
        tableDesc: Label,
1587
        param: param_,
1588
        height: 330,
1589
        margin: '0 0 10 0',
1590
        tbar: [{
1591
                xtype: 'button',
1592
                text: 'Action',
1593
                hidden: add,
1594
                name: 'actionGrid',
1595
                menu: [{
1596
                        text: 'Add',
1597
                        name: 'addGrid',
1598
                        action: 'CRUDaddNewRecord',
1599
                        style: 'font-family: FontAwesome',
1600
                        itemId: 'AddData',
1601
                        iconCls: 'fa-plus-circle',
1602
                        handler: function () {
1603
                            var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1604
                            p_.mask('Loading...');
1605
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1606
                            //var g = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1607
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1608
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1609
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false);
1610

    
1611
                            } else {
1612
                                mdgenerator.createFormL002(tableName, "", "", renderTo, false, '', '0');
1613
                            }
1614

    
1615
                            var fDisplay = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1616

    
1617
                            var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1618

    
1619
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1620
                            if (tinggi < 330) {
1621
                                tinggi = 330;
1622
                            }
1623
                            p.setHeight(390 + tinggi + 70);
1624
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Add - ' + g.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
1625
                            fDisplay.getForm().reset();
1626

    
1627
                            fDisplay.getForm().reset();
1628
                            fDisplay.getForm().findField('EmployeeID').setValue(getParam('EmployeeID'));
1629

    
1630
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1631
                            frm.act = '0';
1632
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1633
                                Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
1634
                            }
1635
                            // go to bottom page
1636
                            $("html, body").animate({
1637
                                scrollTop: $(document).height()
1638
                            }, "slow");
1639
                            p_.unmask();
1640
                            setKeyDisabled(false);
1641
                        }
1642

    
1643
                    }, {
1644
                        text: 'Copy',
1645
                        name: 'CopyGrid',
1646
                        iconCls: 'fa-copy',
1647
                        style: 'font-family: FontAwesome',
1648
                        handler: function () {
1649
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1650
                            //var g = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1651
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1652
                            if (selecton_) {
1653
                                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1654
                                p_.mask('Loading...');
1655
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1656
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false);
1657

    
1658
                                } else {
1659
                                    mdgenerator.createFormL002(tableName, "", "", renderTo, false, '', '0');
1660
                                }
1661

    
1662
                                var fDisplay = Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0];
1663

    
1664
                                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1665

    
1666
                                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1667
                                if (tinggi < 330) {
1668
                                    tinggi = 330;
1669
                                }
1670
                                p.setHeight(390 + tinggi + 70);
1671
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Copy - ' + g.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
1672
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
1673
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1674
                                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
1675
                                }
1676
                                var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1677
                                frm.act = '0';
1678
                                // go to bottom page
1679
                                $("html, body").animate({
1680
                                    scrollTop: $(document).height()
1681
                                }, "slow");
1682
                                var tbl = tableName;
1683
                                setValueAmountEncrypt(tbl);
1684
                                p_.unmask();
1685
                                setKeyDisabled(false);
1686
                                setFileID(0);
1687
                            }
1688

    
1689
                        }
1690

    
1691
                    }, {
1692
                        text: 'Edit',
1693
                        name: 'EditGrid',
1694
                        iconCls: 'fa-edit',
1695
                        style: 'font-family: FontAwesome',
1696
                        handler: function () {
1697
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1698
                            //var g = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1699
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1700
                            if (selecton_) {
1701
                                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1702
                                p_.mask('Loading...');
1703
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1704
                                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false);
1705

    
1706
                                } else {
1707
                                    mdgenerator.createFormL002(tableName, "", "", renderTo, false, '', '1');
1708
                                }
1709

    
1710
                                var fDisplay = Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0];
1711

    
1712
                                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1713

    
1714
                                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1715
                                if (tinggi < 330) {
1716
                                    tinggi = 330;
1717
                                }
1718
                                p.setHeight(390 + tinggi + 100);
1719
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setTitle('Edit - ' + g.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
1720
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
1721
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1722
                                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
1723
                                }
1724
                                var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1725
                                frm.act = '1';
1726
                                // go to bottom page
1727
                                $("html, body").animate({
1728
                                    scrollTop: $(document).height()
1729
                                }, "slow");
1730
                                p_.unmask();
1731
                                setKeyDisabled(true);
1732
                            }
1733

    
1734
                        }
1735

    
1736
                    }, {
1737
                        text: 'Delete',
1738
                        name: 'DeleteGrid',
1739
                        hidden: true,
1740
                        iconCls: 'fa-trash-o',
1741
                        style: 'font-family: FontAwesome',
1742
                    }
1743
                ]
1744
            }, {
1745
                xtype: 'tbfill'
1746
            }, {
1747
                text: 'Clear Filters',
1748
                tooltip: 'Clear all filters',
1749
                name: 'clearbtn',
1750
                handler: function () {
1751
                    var tolbar = this.up()
1752
                        var grid_ = tolbar.up()
1753
                        grid_.filters.clearFilters()
1754
                }
1755
            }, ],
1756

    
1757
        dockedItems: [{
1758
                xtype: 'pagingtoolbar',
1759
                store: tableName + 'Grid',
1760
                dock: 'bottom', //posisi paging
1761
                pageSize: 10,
1762
                displayInfo: true,
1763

    
1764
            }
1765
        ],
1766
        listeners: {
1767
            'itemdblclick': function (me, record, item, index, e, eOpts) {
1768
                // me.el.mask("Loading...");
1769
                //if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1770
                //    var formEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1771
                //    if(formEdit)
1772
                //    {
1773

    
1774
                //    }
1775
                //}
1776
                var p_ = Ext.ComponentQuery.query('[name=Main]')[0];
1777
                p_.mask('Loading...');
1778
                var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1779
                //var g = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
1780
                var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1781
                if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
1782
                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(false);
1783

    
1784
                } else {
1785
                    mdgenerator.createFormL002(tableName, "", "", renderTo, true, selecton_, '1');
1786
                }
1787

    
1788
                var fDisplay = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
1789
                mdgenerator.FakeValue(fDisplay)
1790

    
1791
                var p = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
1792

    
1793
                var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getHeight();
1794
                if (tinggi < 330) {
1795
                    tinggi = 330;
1796
                }
1797
                p.setHeight(390 + tinggi + 100);
1798
                Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setTitle('View - ' + g.tableDesc + ' - ' + getParam("EmployeeID") + ' - ' + getParam("FullName"))
1799
                fDisplay.reset();
1800
                fDisplay.getForm().setValues(selecton_.data);
1801
                if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
1802
                    Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(true);
1803
                }
1804

    
1805
                // me.unmask();
1806

    
1807
                // go to bottom page
1808
                $("html, body").animate({
1809
                    scrollTop: $(document).height()
1810
                }, "slow");
1811
                setValueAmountEncryptDisplayField(tableName);
1812
                p_.unmask();
1813
            },
1814

    
1815
        },
1816
    });
1817
}
1818

    
1819
mdgenerator.FakeValue = function (form_) {
1820
    var form = form_.getForm();
1821

    
1822
    var fields = form.getFields().items;
1823

    
1824
    for (var i = 0; i < fields.length; i++) {
1825
        var field_xtype = fields[i].xtype;
1826

    
1827
        //if (field_xtype === 'numberfield' || field_xtype == 'textfield' || field_xtype == 'combobox' || field_xtype == 'datefield' || field_xtype == 'textareafield') {
1828
        //  fields[i].setValue('n');
1829
        //}
1830

    
1831
    }
1832

    
1833
}
1834

    
1835
cekMandatoryIsNull = function (tableName) {
1836
    var fields_ = Ext.ComponentQuery.query('[nameTable=' + tableName + '][wasValid=false][allowBlank=false]');
1837
    var param_ = '';
1838
    if (fields_.length > 0) {
1839
        for (var i = 0; i < fields_.length; i++) {
1840
            if (i == 0) {
1841
                param_ = ':' + fields_[i].fieldLabel
1842
            } else {
1843
                param_ = param_ + ',' + fields_[i].fieldLabel;
1844
            }
1845

    
1846
        }
1847
    }
1848
    return param_
1849
}
1850

    
1851
getErrorFields = function (tableName) {
1852
    var fields_ = Ext.ComponentQuery.query('[nameTable=' + tableName + '][wasValid=false]');
1853
    var param_ = '';
1854
    if (fields_.length > 0) {
1855
        for (var i = 0; i < fields_.length; i++) {
1856
            if (i == 0) {
1857
                param_ = ':' + fields_[i].fieldLabel;
1858
            } else {
1859
                param_ = param_ + ',' + fields_[i].fieldLabel;
1860
            }
1861

    
1862
        }
1863
    }
1864
    return param_
1865
}
1866

    
1867
setValueAmountEncrypt = function (tableName) {
1868
    var f = Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncrypt=true]');
1869
    for (var i = 0; i < f.length; i++) {
1870
        var hasil = null;
1871
        var dt = Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncrypt=true]')[i].getValue();
1872
        if (dt != "") {
1873
            Ext.Ajax.request({
1874
                async: false,
1875
                method: 'POST',
1876
                url: '/Devt/DecryptData',
1877
                params: {
1878
                    dt: dt
1879

    
1880
                },
1881
                success: function (response) {
1882
                    var results = Ext.decode(response.responseText);
1883
                    hasil = results.data;
1884
                    Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncrypt=true]')[i].setValue(hasil);
1885
                }
1886
            });
1887
        }
1888
    }
1889

    
1890
}
1891

    
1892
setValueAmountEncryptDisplayField = function (tableName) {
1893

    
1894
    var f = Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncryptDisplay=true]');
1895
    for (var i = 0; i < f.length; i++) {
1896
        var hasil = null;
1897
        var dt = Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncryptDisplay=true]')[i].getValue();
1898
        if (dt != "") {
1899
            Ext.Ajax.request({
1900
                async: false,
1901
                method: 'POST',
1902
                url: '/Devt/DecryptData',
1903
                params: {
1904
                    dt: dt
1905

    
1906
                },
1907
                success: function (response) {
1908
                    var results = Ext.decode(response.responseText);
1909
                    hasil = results.data;
1910
                    Ext.ComponentQuery.query('[nameTable=' + tableName + '][isEncryptDisplay=true]')[i].setValue(hasil);
1911
                }
1912
            });
1913
        }
1914
    }
1915
}
1916

    
1917
createGridCustomization = function (Label, tableName, renderTo) {
1918
    var userAction = MinovaUtil.GetActionMenu();
1919
    var add = false;
1920
    var copy = false;
1921
    var edit = false;
1922
    if (userAction != '1') {
1923
        actionBtn = true;
1924

    
1925
    } else {
1926
        actionBtn = false;
1927
    }
1928
    if (tableName.toLowerCase() == 'sdatatablefield') {
1929
        add = true;
1930
        copy = true;
1931
    }
1932
    Ext.create('MinovaUtil.MinovaES.MinovaGridMD', {
1933
        renderTo: renderTo,
1934
        tableName: tableName,
1935
        storename: tableName + 'Grid',
1936
        name: 'gridMD' + tableName,
1937
        pagesize: 10,
1938
        param: '',
1939
        height: 470,
1940
        margin: '0 0 10 0',
1941
        gridMD: tableName,
1942
        tableDesc: Label,
1943
        tbar: [{
1944
                xtype: 'button',
1945
                text: 'Action',
1946
                hidden: actionBtn,
1947
                name: 'actionGrid',
1948
                menu: [{
1949
                        text: 'Add',
1950
                        hidden: add,
1951
                        name: 'addGrid',
1952
                        action: 'CRUDaddNewRecord',
1953
                        style: 'font-family: FontAwesome',
1954
                        itemId: 'AddData',
1955
                        iconCls: 'fa-plus-circle',
1956
                        handler: function () {
1957
                            var me = this;
1958
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1959
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1960
                            //if (selecton_) {
1961
                            var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1962
                            if (display) {
1963
                                display.setHidden(false);
1964
                            } else {
1965
                                createFormCustomization(tableName, renderTo, false, selecton_, '0');
1966
                                g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1967

    
1968
                            }
1969

    
1970
                            g.setHidden(true);
1971
                            var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1972
                            fEdit.getForm().reset();
1973
                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
1974
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
1975
                            if (tinggi < 520) {
1976
                                tinggi = 520;
1977
                                fEdit.setHeight(520);
1978
                                Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0].setHeight(520);
1979
                            }
1980
                            p.setHeight(tinggi + 100);
1981
                            fEdit.act = '0';
1982
                            fEdit.setHidden(false);
1983
                            setKeyDisabled(false);
1984
                            //}
1985
                        }
1986
                    }, {
1987
                        text: 'Copy',
1988
                        hidden: copy,
1989
                        name: 'CopyGrid',
1990
                        iconCls: 'fa-copy',
1991
                        style: 'font-family: FontAwesome',
1992
                        handler: function () {
1993

    
1994
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
1995
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
1996
                            if (selecton_) {
1997
                                var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
1998
                                if (display) {
1999
                                    display.setHidden(false);
2000
                                } else {
2001
                                    createFormCustomization(tableName, renderTo, false, selecton_, '0');
2002
                                    g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2003

    
2004
                                }
2005

    
2006
                                g.setHidden(true);
2007
                                var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2008
                                fEdit.getForm().setValues(selecton_.data);
2009
                                var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2010
                                var tinggi = fEdit.getHeight();
2011
                                if (tinggi < 520) {
2012
                                    tinggi = 520;
2013
                                    fEdit.setHeight(520);
2014
                                    Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0].setHeight(520);
2015
                                }
2016
                                p.setHeight(tinggi + 100);
2017
                                fEdit.act = '0';
2018
                                setKeyDisabled(false);
2019
                                setFileID(0);
2020
                            }
2021
                        }
2022
                    }, {
2023
                        text: 'Edit',
2024
                        hidden: edit,
2025
                        name: 'EditGrid',
2026
                        iconCls: 'fa-edit',
2027
                        style: 'font-family: FontAwesome',
2028
                        handler: function () {
2029
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2030
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2031
                            if (selecton_) {
2032
                                var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2033
                                if (display) {
2034
                                    display.setHidden(false);
2035
                                } else {
2036
                                    createFormCustomization(tableName, renderTo, false, selecton_, '1');
2037
                                    g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2038

    
2039
                                }
2040

    
2041
                                g.setHidden(true);
2042
                                var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2043
                                fEdit.getForm().setValues(selecton_.data);
2044
                                var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2045
                                var tinggi = fEdit.getHeight();
2046
                                if (tinggi < 520) {
2047
                                    tinggi = 520;
2048
                                    fEdit.setHeight(520);
2049
                                    Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0].setHeight(520);
2050
                                }
2051
                                p.setHeight(tinggi + 100);
2052
                                fEdit.act = '1';
2053
                                setKeyDisabled(true);
2054
                            }
2055
                        }
2056
                    }, {
2057
                        text: 'Delete',
2058
                        name: 'DeleteGrid',
2059
                        hidden: true,
2060
                        iconCls: 'fa-trash-o',
2061
                        style: 'font-family: FontAwesome',
2062
                    }
2063
                ]
2064
            }, {
2065
                xtype: 'tbfill'
2066
            }, {
2067
                text: 'Search',
2068
                tooltip: 'Search',
2069
                tableName: tableName,
2070
                name: 'btnSearchCust',
2071
                handler: function () {
2072
                    btnSearchCust(tableName);
2073
                }
2074

    
2075
            }, {
2076
                text: 'Clear Filters',
2077
                tooltip: 'Clear all filters',
2078
                name: 'clearbtn',
2079
                handler: function () {
2080
                    var tolbar = this.up()
2081
                        var grid_ = tolbar.up()
2082
                        grid_.filters.clearFilters()
2083
                        //SASWANTO 09 FEB 2022
2084
                        $("#button-1345-btnIconEl").click();
2085
                    $("#button-1090-btnIconEl").click();
2086
                }
2087
            }, ],
2088

    
2089
        dockedItems: [{
2090
                xtype: 'pagingtoolbar',
2091
                store: tableName + 'Grid',
2092
                dock: 'bottom', //posisi paging
2093
                pageSize: 10,
2094
                displayInfo: true,
2095

    
2096
            }
2097
        ],
2098
        listeners: {
2099
            'itemdblclick': function (me, record, item, index, e, eOpts) {
2100
                var me = this;
2101
                var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2102
                var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2103
                if (selecton_) {
2104
                    var display = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
2105
                    if (display) {
2106
                        display.setHidden(false);
2107
                    } else {
2108
                        createFormCustomization(tableName, renderTo, true, selecton_, null);
2109
                        g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2110

    
2111
                    }
2112

    
2113
                    g.setHidden(true);
2114
                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getForm().setValues(selecton_.data);
2115
                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2116
                    var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getHeight();
2117
                    if (tinggi <= 520) {
2118
                        tinggi = 520;
2119
                        Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHeight(520);
2120
                        Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0].setHeight(520);
2121
                    }
2122
                    p.setHeight(tinggi + 100);
2123
                }
2124
            },
2125

    
2126
        },
2127
    });
2128

    
2129
    Ext.ComponentQuery.query('[name=mainPanel]')[0].tableName = tableName;
2130
}
2131

    
2132
createFormCustomization = function (tableName, renderTo, isDisplay, record, act) {
2133
    var name = 'MinovaGridFormEdit';
2134
    var save = true;
2135
    var edit = false;
2136
    var delete_ = true;
2137
    var back = false;
2138

    
2139
    if (isDisplay) {
2140
        name = 'MinovaGridFormDisplay'
2141
    } else {
2142
        save = false;
2143
        edit = true;
2144
        delete_ = false;
2145
        back = false;
2146
    }
2147
    var userAction = MinovaUtil.GetActionMenu();
2148
    if (userAction != '1') {
2149
        save = true;
2150
        edit = true;
2151
        delete_ = true;
2152
    }
2153

    
2154
    if (tableName.toLowerCase() == 'sdatatablefield') {
2155
        delete_ = true;
2156

    
2157
    }
2158
    Ext.create('Ext.form.Panel', {
2159
        renderTo: renderTo,
2160
        name: name + tableName,
2161
        formMD: tableName,
2162
        act: null,
2163
        items: [{
2164
                xtype: 'minovaForm',
2165
                name: name,
2166
                tableName: tableName,
2167
                margin: '0 0 10 0',
2168
                isDisplay: isDisplay,
2169
                buttons: [{
2170
                        text: 'Save',
2171
                        hidden: save,
2172
                        act: act,
2173
                        name: 'btnSaveMD',
2174
                        iconCls: 'fa-save',
2175
                        style: 'font-family: FontAwesome',
2176
                        handler: function () {
2177

    
2178
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2179
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
2180
                            var panelInt = Ext.ComponentQuery.query('[name=PanelMdDetail]')[0];
2181
                            if (panelInt) {
2182
                                panelInt.mask('Loading..');
2183
                            }
2184

    
2185
                            if (frm.getForm().isValid()) {
2186
                                Ext.Ajax.request({
2187
                                    method: 'POST',
2188
                                    //async: false,
2189
                                    url: '/Devt/SaveTable',
2190
                                    params: {
2191
                                        tableName: tableName,
2192
                                        data: Ext.encode(frm.getValues()),
2193
                                        action: frm.act
2194
                                    },
2195
                                    waitMsg: 'Saving Data...',
2196
                                    success: function (response) {
2197
                                        var result = Ext.decode(response.responseText);
2198
                                        if (result.success) {
2199

    
2200
                                            MinovaMessage('Not Null', '000006', '', 'S');
2201

    
2202
                                            grid_.getStore().reload();
2203
                                            console.log('7');
2204
                                            frm.setHidden(true);
2205
                                            grid_.setHidden(false);
2206
                                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2207
                                            p.setHeight(520);
2208
                                            if (getParam('ApplicantID') != 'null') {
2209
                                                var _param = {
2210
                                                    serviceName: 'ERecruitmentAuthentication.asmx',
2211
                                                    methodName: 'SendMailChangeMD',
2212
                                                    parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
2213

    
2214
                                                };
2215

    
2216
                                                var results = null;
2217
                                                Ext.Ajax.request({
2218
                                                    method: 'post',
2219
                                                    type: 'ajax',
2220
                                                    params: _param,
2221
                                                    url: '/InvokeService/Invoke/',
2222
                                                    loadMask: {
2223
                                                        msg: 'please wait...'
2224
                                                    },
2225
                                                    success: function (response) {}
2226
                                                });
2227
                                            }
2228

    
2229
                                        } else {
2230

    
2231
                                            MinovaMessage('Not Null', '000005', result.message.text, 'E')
2232
                                        }
2233

    
2234
                                    },
2235
                                    failure: function (response) {
2236

    
2237
                                        var result = Ext.decode(response.responseText);
2238
                                        console.log(result);
2239
                                    }
2240
                                });
2241

    
2242
                            } else {
2243
                                var param_ = cekMandatoryIsNull(tableName);
2244
                                if (param_ != "") {
2245
                                    MinovaMessage('Not Null', '000009', param_, 'E');
2246
                                } else {
2247
                                    // ada field yang error
2248
                                    var error_ = getErrorFields(tableName);
2249
                                    if (error_ != '') {
2250
                                        MinovaMessage('title', '000005', error_, 'E');
2251
                                    }
2252

    
2253
                                }
2254
                            }
2255
                            if (panelInt) {
2256
                                panelInt.unmask();
2257
                            }
2258

    
2259
                        }
2260
                    }, {
2261
                        text: 'Delete',
2262
                        hidden: delete_,
2263
                        iconCls: 'fa-trash-o',
2264
                        name: 'btnDeleteMD',
2265
                        style: 'font-family: FontAwesome',
2266
                        action: 'CRUDdelete',
2267
                        handler: function () {
2268

    
2269
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2270
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
2271
                            MinovaMessage('Message', '000007', '', 'C', function (respone) {
2272
                                if (respone == "yes") {
2273

    
2274
                                    if (frm.getForm().isValid()) {
2275
                                        Ext.Ajax.request({
2276
                                            async: false,
2277
                                            method: 'POST',
2278
                                            url: '/Devt/SaveTable',
2279
                                            params: {
2280
                                                tableName: tableName,
2281
                                                data: Ext.encode(frm.getValues()),
2282
                                                action: '2'
2283
                                            },
2284
                                            waitMsg: 'Saving Data...',
2285
                                            success: function (response) {
2286
                                                var result = Ext.decode(response.responseText);
2287
                                                if (result.success) {
2288

    
2289
                                                    MinovaMessage('', 'BSDEL', '', 'S');
2290
                                                    grid_.getStore().reload();
2291
                                                    console.log('8');
2292
                                                    frm.setHidden(true);
2293
                                                    grid_.setHidden(false);
2294
                                                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2295
                                                    p.setHeight(520);
2296
                                                    if (getParam('ApplicantID') != 'null') {
2297
                                                        var _param = {
2298
                                                            serviceName: 'ERecruitmentAuthentication.asmx',
2299
                                                            methodName: 'SendMailChangeMD',
2300
                                                            parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
2301

    
2302
                                                        };
2303

    
2304
                                                        var results = null;
2305
                                                        Ext.Ajax.request({
2306
                                                            method: 'post',
2307
                                                            type: 'ajax',
2308
                                                            params: _param,
2309
                                                            url: '/InvokeService/Invoke/',
2310
                                                            loadMask: {
2311
                                                                msg: 'please wait...'
2312
                                                            },
2313
                                                            success: function (response) {}
2314
                                                        });
2315
                                                    }
2316

    
2317
                                                } else {
2318

    
2319
                                                    MinovaMessage('Not Null', '000005', result.message.text, 'E')
2320
                                                }
2321

    
2322
                                            },
2323
                                            failure: function (response) {
2324

    
2325
                                                var result = Ext.decode(response.responseText);
2326
                                                console.log(result);
2327
                                            }
2328
                                        });
2329

    
2330
                                    } else {
2331
                                        var param_ = cekMandatoryIsNull(tableName);
2332
                                        if (param_ != "") {
2333
                                            MinovaMessage('Not Null', '000009', param_, 'E');
2334
                                        } else {
2335
                                            // ada field yang error
2336
                                            var error_ = getErrorFields(tableName);
2337
                                            if (error_ != '') {
2338
                                                MinovaMessage('title', '000005', error_, 'E');
2339
                                            }
2340

    
2341
                                        }
2342
                                    }
2343

    
2344
                                }
2345

    
2346
                            });
2347

    
2348
                        }
2349

    
2350
                    }, {
2351
                        text: 'Back to Grid',
2352
                        hidden: back,
2353
                        name: 'btnCancelMD',
2354
                        iconCls: 'fa-reply',
2355
                        style: 'font-family: FontAwesome',
2356
                        viewForm: name + tableName,
2357
                        handler: function () {
2358
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
2359
                                if (respone == "yes") {
2360
                                    Ext.ComponentQuery.query('[name=' + name + tableName + ']')[0].setHidden(true);
2361
                                    Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0].setHidden(false);
2362
                                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2363
                                    if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
2364
                                        Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = null;
2365
                                    }
2366
                                    var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2367
                                    //p.setTitle(grid_.tableDesc);
2368
                                    p.setHeight(520);
2369
                                }
2370
                            });
2371

    
2372
                        }
2373
                    }, {
2374
                        text: 'Edit',
2375
                        hidden: edit,
2376
                        record: record,
2377
                        iconCls: 'fa-edit',
2378
                        style: 'font-family: FontAwesome',
2379
                        handler: function () {
2380
                            var me = this;
2381
                            var tbl = tableName;
2382
                            var grid_ = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2383
                            var selecton_ = grid_.getView().getSelectionModel().getSelection()[0];
2384
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0]) {
2385
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHidden(false)
2386
                            } else {
2387
                                createFormCustomization(tableName, renderTo, false, selecton_, '1');
2388
                            }
2389

    
2390
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getForm().setValues(selecton_.data);
2391
                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2392
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight();
2393
                            if (tinggi < 520) {
2394
                                tinggi = 520;
2395
                                Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].setHeight(520);
2396
                                Ext.ComponentQuery.query('minovaform[tableName=' + tableName + ']')[0].setHeight(520);
2397
                            }
2398
                            p.setHeight(tinggi + 100);
2399
                            Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].setHidden(true);
2400
                            Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].act = '1';
2401
                            setKeyDisabled(true);
2402
                        }
2403
                    },
2404
                ],
2405

    
2406
            },
2407
        ]
2408
    });
2409

    
2410
}
2411

    
2412
createGridCustomizationL002 = function (Label, tableName, renderTo) {
2413
    var userAction = MinovaUtil.GetActionMenu();
2414
    var add = false;
2415
    var copy = false;
2416
    var edit = false;
2417
    if (userAction != '1') {
2418
        actionBtn = true;
2419

    
2420
    } else {
2421
        actionBtn = false;
2422
    }
2423
    if (tableName.toLowerCase() == 'sdatatablefield') {
2424
        add = true;
2425
        copy = true;
2426
    }
2427

    
2428
    Ext.create('MinovaUtil.MinovaES.MinovaGridMD', {
2429
        renderTo: renderTo,
2430
        tableName: tableName,
2431
        storename: tableName + 'Grid',
2432
        name: 'gridMD' + tableName,
2433
        pagesize: 10,
2434
        param: '',
2435
        height: 470,
2436
        margin: '0 0 10 0',
2437
        gridMD: tableName,
2438
        tableDesc: Label,
2439
        tbar: [{
2440
                xtype: 'button',
2441
                text: 'Action',
2442
                hidden: actionBtn,
2443
                name: 'actionGrid',
2444
                menu: [{
2445
                        text: 'Add',
2446
                        hidden: add,
2447
                        name: 'addGrid',
2448
                        action: 'CRUDaddNewRecord',
2449
                        style: 'font-family: FontAwesome',
2450
                        itemId: 'AddData',
2451
                        iconCls: 'fa-plus-circle',
2452
                        handler: function () {
2453
                            var me = this;
2454
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2455
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2456
                            //if (selecton_) {
2457
                            var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2458
                            if (display) {
2459
                                display.destroy();
2460
                            } else {
2461
                                display = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
2462
                                if (display) {
2463
                                    display.destroy();
2464
                                }
2465
                            }
2466
                            createFormCustomizationL002(Label, tableName, renderTo, false, selecton_, '0');
2467
                            g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2468

    
2469
                            //g.setHidden(true);
2470
                            var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2471
                            fEdit.getForm().reset();
2472
                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2473
                            var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0].getHeight() + 520;
2474
                            p.setHeight(tinggi + 10);
2475
                            fEdit.act = '0';
2476
                            setKeyDisabled(false);
2477
                            fEdit.setHidden(false);
2478
                            $('html, body').animate({
2479
                                scrollTop: 2000
2480
                            }, 500);
2481
                            //}
2482
                        }
2483
                    }, {
2484
                        text: 'Copy',
2485
                        hidden: copy,
2486
                        name: 'CopyGrid',
2487
                        iconCls: 'fa-copy',
2488
                        style: 'font-family: FontAwesome',
2489
                        handler: function () {
2490

    
2491
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2492
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2493
                            if (selecton_) {
2494
                                var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2495
                                if (display) {
2496
                                    display.setHidden(false);
2497
                                } else {
2498
                                    display = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
2499
                                    if (display) {
2500
                                        display.destroy();
2501
                                    }
2502
                                }
2503
                                createFormCustomizationL002(Label, tableName, renderTo, false, selecton_, '0');
2504
                                g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2505

    
2506
                                //g.setHidden(true);
2507
                                var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2508
                                fEdit.getForm().setValues(selecton_.data);
2509
                                var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2510
                                var tinggi = fEdit.getHeight() + 520;
2511
                                p.setHeight(tinggi + 10);
2512
                                fEdit.act = '0';
2513
                                setKeyDisabled(false);
2514
                                setFileID(0);
2515
                                $('html, body').animate({
2516
                                    scrollTop: 2000
2517
                                }, 500);
2518
                            }
2519
                        }
2520
                    }, {
2521
                        text: 'Edit',
2522
                        hidden: edit,
2523
                        name: 'EditGrid',
2524
                        iconCls: 'fa-edit',
2525
                        style: 'font-family: FontAwesome',
2526
                        handler: function () {
2527
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2528
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2529
                            if (selecton_) {
2530
                                if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
2531
                                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].destroy()
2532
                                }
2533
                                var display = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2534
                                if (display) {
2535
                                    display.setHidden(false);
2536
                                } else {
2537
                                    display = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
2538
                                    if (display) {
2539
                                        display.destroy();
2540
                                    }
2541
                                }
2542
                                createFormCustomizationL002(Label, tableName, renderTo, false, selecton_, '0');
2543
                                g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2544

    
2545
                                //g.setHidden(true);
2546
                                var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2547
                                fEdit.getForm().setValues(selecton_.data);
2548
                                var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2549
                                var tinggi = fEdit.getHeight() + 520;
2550

    
2551
                                p.setHeight(tinggi + 10);
2552
                                setKeyDisabled(true);
2553
                                fEdit.act = '1';
2554
                                $('html, body').animate({
2555
                                    scrollTop: 2000
2556
                                }, 500);
2557
                            }
2558
                        }
2559
                    }, {
2560
                        text: 'Delete',
2561
                        name: 'DeleteGrid',
2562
                        hidden: true,
2563
                        iconCls: 'fa-trash-o',
2564
                        style: 'font-family: FontAwesome',
2565
                    }
2566
                ]
2567
            }, {
2568
                xtype: 'tbfill'
2569
            }, {
2570
                text: 'Search',
2571
                tooltip: 'Search',
2572
                tableName: tableName,
2573
                name: 'btnSearchCust',
2574
                handler: function () {
2575
                    btnSearchCust(tableName);
2576
                }
2577

    
2578
            }, {
2579
                text: 'Clear Filters',
2580
                tooltip: 'Clear all filters',
2581
                name: 'clearbtn',
2582
                handler: function () {
2583
                    var tolbar = this.up()
2584
                        var grid_ = tolbar.up()
2585
                        grid_.filters.clearFilters()
2586
                }
2587
            }, ],
2588

    
2589
        dockedItems: [{
2590
                xtype: 'pagingtoolbar',
2591
                store: tableName + 'Grid',
2592
                dock: 'bottom', //posisi paging
2593
                pageSize: 10,
2594
                displayInfo: true,
2595

    
2596
            }
2597
        ],
2598
        listeners: {
2599
            'itemdblclick': function (me, record, item, index, e, eOpts) {
2600
                var me = this;
2601
                var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2602
                var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2603
                if (selecton_) {
2604

    
2605
                    var fEdit = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2606
                    if (fEdit) {
2607
                        fEdit.destroy();
2608
                    }
2609
                    var display = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0];
2610
                    if (display) {
2611
                        display.setHidden(false);
2612
                    } else {
2613
                        createFormCustomizationL002(Label, tableName, renderTo, true, selecton_, null);
2614
                        g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2615

    
2616
                    }
2617

    
2618
                    //g.setHidden(true);
2619
                    Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getForm().setValues(selecton_.data);
2620
                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2621
                    var tinggi = Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].getHeight();
2622

    
2623
                    p.setHeight(tinggi + 520 + 10);
2624
                    $('html, body').animate({
2625
                        scrollTop: 2000
2626
                    }, 500);
2627
                }
2628
            },
2629

    
2630
        },
2631
    });
2632

    
2633
    Ext.ComponentQuery.query('[name=mainPanel]')[0].tableName = tableName;
2634
}
2635

    
2636
createFormCustomizationL002 = function (Label, tableName, renderTo, isDisplay, record, act) {
2637
    var name = 'MinovaGridFormEdit';
2638
    var save = true;
2639
    var edit = false;
2640
    var delete_ = true;
2641
    var back = false;
2642
    var title = "Edit ";
2643
    if (isDisplay) {
2644
        name = 'MinovaGridFormDisplay';
2645
        title = "View ";
2646
    } else {
2647
        save = false;
2648
        edit = true;
2649
        delete_ = false;
2650
        back = false;
2651
    }
2652
    if (act == '0') {
2653
        title = "Add ";
2654
    }
2655
    if (act == '99') {
2656
        title = "Copy ";
2657
        act = '0';
2658
    }
2659
    var userAction = MinovaUtil.GetActionMenu();
2660
    if (userAction != '1') {
2661
        save = true;
2662
        edit = true;
2663
        delete_ = true;
2664
    }
2665

    
2666
    if (tableName.toLowerCase() == 'sdatatablefield') {
2667
        delete_ = true;
2668

    
2669
    }
2670
    Ext.create('Ext.form.Panel', {
2671
        renderTo: renderTo,
2672
        name: name + tableName,
2673
        formMD: tableName,
2674
        title: title + Label,
2675
        collapsible: true,
2676

    
2677
        act: null,
2678
        items: [{
2679
                xtype: 'minovaForm',
2680
                name: name,
2681
                tableName: tableName,
2682
                margin: '0 0 10 0',
2683
                isDisplay: isDisplay,
2684
                buttons: [{
2685
                        text: 'Save',
2686
                        hidden: save,
2687
                        act: act,
2688
                        name: 'btnSaveMD',
2689
                        iconCls: 'fa-save',
2690
                        style: 'font-family: FontAwesome',
2691
                        handler: function () {
2692

    
2693
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2694
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
2695

    
2696
                            if (frm.getForm().isValid()) {
2697
                                Ext.Ajax.request({
2698
                                    method: 'POST',
2699
                                    async: false,
2700
                                    url: '/Devt/SaveTable',
2701
                                    params: {
2702
                                        tableName: tableName,
2703
                                        data: Ext.encode(frm.getValues()),
2704
                                        action: frm.act
2705
                                    },
2706
                                    waitMsg: 'Saving Data...',
2707
                                    success: function (response) {
2708
                                        var result = Ext.decode(response.responseText);
2709
                                        if (result.success) {
2710

    
2711
                                            MinovaMessage('Not Null', '000006', '', 'S');
2712
                                            grid_.getStore().reload();
2713
                                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2714
                                            p.setHeight(520);
2715
                                            if (getParam('ApplicantID') != 'null') {
2716
                                                var _param = {
2717
                                                    serviceName: 'ERecruitmentAuthentication.asmx',
2718
                                                    methodName: 'SendMailChangeMD',
2719
                                                    parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
2720

    
2721
                                                };
2722

    
2723
                                                var results = null;
2724
                                                Ext.Ajax.request({
2725
                                                    method: 'post',
2726
                                                    type: 'ajax',
2727
                                                    params: _param,
2728
                                                    url: '/InvokeService/Invoke/',
2729
                                                    loadMask: {
2730
                                                        msg: 'please wait...'
2731
                                                    },
2732
                                                    success: function (response) {}
2733
                                                });
2734
                                            }
2735
                                            frm.destroy();
2736
                                        } else {
2737

    
2738
                                            MinovaMessage('Not Null', '000005', result.message.text, 'E')
2739
                                        }
2740

    
2741
                                    },
2742
                                    failure: function (response) {
2743

    
2744
                                        var result = Ext.decode(response.responseText);
2745
                                        console.log(result);
2746
                                    }
2747
                                });
2748

    
2749
                            } else {
2750
                                var param_ = cekMandatoryIsNull(tableName);
2751
                                if (param_ != "") {
2752
                                    MinovaMessage('Not Null', '000009', param_, 'E');
2753
                                } else {
2754
                                    // ada field yang error
2755
                                    var error_ = getErrorFields(tableName);
2756
                                    if (error_ != '') {
2757
                                        MinovaMessage('title', '000005', error_, 'E');
2758
                                    }
2759

    
2760
                                }
2761
                            }
2762

    
2763
                        }
2764
                    }, {
2765
                        text: 'Delete',
2766
                        hidden: delete_,
2767
                        iconCls: 'fa-trash-o',
2768
                        name: 'btnDeleteMD',
2769
                        style: 'font-family: FontAwesome',
2770
                        action: 'CRUDdelete',
2771
                        handler: function () {
2772

    
2773
                            var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2774
                            var grid_ = Ext.ComponentQuery.query('[gridMD=' + tableName + ']')[0];
2775
                            MinovaMessage('Message', '000007', '', 'C', function (respone) {
2776
                                if (respone == "yes") {
2777

    
2778
                                    if (frm.getForm().isValid()) {
2779
                                        Ext.Ajax.request({
2780
                                            async: false,
2781
                                            method: 'POST',
2782
                                            url: '/Devt/SaveTable',
2783
                                            params: {
2784
                                                tableName: tableName,
2785
                                                data: Ext.encode(frm.getValues()),
2786
                                                action: '2'
2787
                                            },
2788
                                            waitMsg: 'Saving Data...',
2789
                                            success: function (response) {
2790
                                                var result = Ext.decode(response.responseText);
2791
                                                if (result.success) {
2792
                                                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2793
                                                    p.setHeight(520);
2794
                                                    if (getParam('ApplicantID') != 'null') {
2795
                                                        var _param = {
2796
                                                            serviceName: 'ERecruitmentAuthentication.asmx',
2797
                                                            methodName: 'SendMailChangeMD',
2798
                                                            parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
2799

    
2800
                                                        };
2801

    
2802
                                                        var results = null;
2803
                                                        Ext.Ajax.request({
2804
                                                            method: 'post',
2805
                                                            type: 'ajax',
2806
                                                            params: _param,
2807
                                                            url: '/InvokeService/Invoke/',
2808
                                                            loadMask: {
2809
                                                                msg: 'please wait...'
2810
                                                            },
2811
                                                            success: function (response) {}
2812
                                                        });
2813
                                                    }
2814
                                                    MinovaMessage('', 'BSDEL', '', 'S');
2815
                                                    grid_.getStore().reload();
2816
                                                    console.log('9');
2817
                                                    var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2818
                                                    if (frm) {
2819
                                                        frm.destroy();
2820
                                                    } else {
2821
                                                        Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].destroy()
2822
                                                    }
2823

    
2824
                                                } else {
2825

    
2826
                                                    MinovaMessage('Not Null', '000005', result.message.text, 'E')
2827
                                                }
2828

    
2829
                                            },
2830
                                            failure: function (response) {
2831

    
2832
                                                var result = Ext.decode(response.responseText);
2833
                                                console.log(result);
2834
                                            }
2835
                                        });
2836

    
2837
                                    } else {
2838
                                        var param_ = cekMandatoryIsNull(tableName);
2839
                                        if (param_ != "") {
2840
                                            MinovaMessage('Not Null', '000009', param_, 'E');
2841
                                        } else {
2842
                                            // ada field yang error
2843
                                            var error_ = getErrorFields(tableName);
2844
                                            if (error_ != '') {
2845
                                                MinovaMessage('title', '000005', error_, 'E');
2846
                                            }
2847

    
2848
                                        }
2849
                                    }
2850

    
2851
                                }
2852

    
2853
                            });
2854

    
2855
                        }
2856

    
2857
                    }, {
2858
                        text: 'Back to Grid',
2859
                        hidden: back,
2860
                        name: 'btnCancelMD',
2861
                        iconCls: 'fa-reply',
2862
                        style: 'font-family: FontAwesome',
2863
                        viewForm: name + tableName,
2864
                        handler: function () {
2865
                            MinovaMessage('Message', '000011', '', 'C', function (respone) {
2866
                                if (respone == "yes") {
2867
                                    var frm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2868
                                    if (frm) {
2869
                                        frm.destroy();
2870
                                    } else {
2871
                                        Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].destroy()
2872
                                    }
2873
                                    var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2874
                                    p.setHeight(520);
2875

    
2876
                                }
2877
                            });
2878

    
2879
                        }
2880
                    }, {
2881
                        text: 'Edit',
2882
                        hidden: edit,
2883
                        record: record,
2884
                        iconCls: 'fa-edit',
2885
                        style: 'font-family: FontAwesome',
2886
                        handler: function () {
2887
                            var me = this;
2888
                            var tbl = tableName;
2889
                            if (Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0]) {
2890
                                Ext.ComponentQuery.query('[name=MinovaGridFormDisplay' + tableName + ']')[0].destroy()
2891
                            }
2892
                            var g = Ext.ComponentQuery.query('minovagridmd[tableName=' + tableName + ']')[0];
2893
                            var selecton_ = g.getView().getSelectionModel().getSelection()[0];
2894
                            createFormCustomizationL002(Label, tableName, renderTo, false, selecton_, '1');
2895
                            var eForm = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + tableName + ']')[0];
2896
                            eForm.getForm().setValues(selecton_.data);
2897
                            eForm.act = '1';
2898
                            var p = Ext.ComponentQuery.query('[name=mainPanel]')[0];
2899
                            var tinggi = eForm.getHeight() + 520;
2900

    
2901
                            p.setHeight(tinggi + 10);
2902
                            setKeyDisabled(true);
2903
                            $('html, body').animate({
2904
                                scrollTop: 2000
2905
                            }, 500);
2906
                        }
2907
                    },
2908
                ],
2909

    
2910
            },
2911
        ]
2912
    });
2913

    
2914
}
2915

    
2916
setKeyDisabled = function (param) {
2917
    var fields_ = Ext.ComponentQuery.query('[IsPrimaryKey=1]')
2918
        for (var i = 0; i < fields_.length; i++) {
2919
            fields_[i].setReadOnly(param);
2920
        }
2921
}
2922

    
2923
btnSearchCust = function (tableName) {
2924

    
2925
    var pnl = Ext.ComponentQuery.query('[name=mainCustomization]')[0];
2926
    var main_ = Ext.ComponentQuery.query('[name=mainSearch' + tableName + ']')[0];
2927
    if (main_) {
2928
        main_.show();
2929
    } else {
2930
        Ext.create('MinovaES.view.customization.searchform', {
2931
            title: 'Search - ' + pnl.title,
2932
            tableName: tableName,
2933
            name: 'mainSearch' + tableName,
2934
        }).show();
2935
    }
2936

    
2937
}
2938

    
2939
setFileID = function (param) {
2940
    var fields_ = Ext.ComponentQuery.query('[name=FileID]')
2941
        for (var i = 0; i < fields_.length; i++) {
2942
            fields_[i].setValue(param);
2943
        }
2944
}
2945

    
2946
mdSaveForce = function (tableName, data, act) {
2947

    
2948
    Ext.Ajax.request({
2949
        method: 'POST',
2950
        //async: false,
2951
        url: '/Devt/SaveTable',
2952
        params: {
2953
            tableName: tableName,
2954
            data: data,
2955
            action: act,
2956
            force: true
2957
        },
2958
        waitMsg: 'Saving Data...',
2959
        success: function (response) {
2960
            var result = Ext.decode(response.responseText);
2961
            if (result.success) {
2962

    
2963
                MinovaMessage('Not Null', '000006', '', 'S');
2964
                var menu = Ext.ComponentQuery.query('[name = gridMenuMD]')[0];
2965
                var s = menu.getStore();
2966

    
2967
                Ext.Ajax.request({
2968
                    async: false,
2969
                    method: 'POST',
2970
                    url: '/UserControl/GetStore',
2971
                    params: {
2972
                        tableName: ' PDSPA0013 ',
2973
                        param: "ModuleType='" + MinovaUtil.GetModuleType() + "'  AND Language='" + getParam("Lang") + "'"
2974

    
2975
                    },
2976
                    success: function (response) {
2977
                        var results = Ext.decode(response.responseText);
2978
                        var data_ = results.data;
2979
                        s.loadData(results.data);
2980
                        //s.reload()
2981
                    }
2982
                });
2983
                grid_.getStore().reload();
2984
                console.log('10');
2985
                frm.setHidden(true);
2986
                grid_.setHidden(false);
2987
                var p = Ext.ComponentQuery.query('[name = PanelMdDetail]')[0];
2988
                p.setHeight(390);
2989
                if (getParam('ApplicantID') != 'null') {
2990
                    var _param = {
2991
                        serviceName: 'ERecruitmentAuthentication.asmx',
2992
                        methodName: 'SendMailChangeMD',
2993
                        parameter: 'TableName=' + tableName + '&EmployeeID=' + getParam('ApplicantID')
2994

    
2995
                    };
2996

    
2997
                    var results = null;
2998
                    Ext.Ajax.request({
2999
                        method: 'post',
3000
                        type: 'ajax',
3001
                        params: _param,
3002
                        url: '/InvokeService/Invoke/',
3003
                        loadMask: {
3004
                            msg: 'please wait...'
3005
                        },
3006
                        success: function (response) {}
3007
                    });
3008
                }
3009
                frm.destroy();
3010

    
3011
            }
3012

    
3013
        },
3014
        failure: function (response) {
3015
            pnl.unmask();
3016
            var result = Ext.decode(response.responseText);
3017
            //console.log(result);
3018
        }
3019
    });
3020

    
3021
}
3022
mdConfirm = function (tableName, data, act, msgid) {
3023
    MinovaMessage('Message', msgid, '', 'C', function (respone) {
3024
        if (respone == "yes") {
3025
            mdSaveForce(tableName, data, act)
3026
        }
3027

    
3028
    });
3029
}
(2-2/2)