Project

General

Profile

Bug #650 » CtrlGeneratePersonalWS.js

Perbaikan query pada CtrlGeneratePersonalWS.js - Muhammad Bintar, 12/20/2021 03:30 PM

 
1
Ext.define('MinovaES.controller.masterdata.tm.CtrlGeneratePersonalWS', {
2
    extend: 'Ext.app.ViewController',
3
    alias: 'controller.CtrlGeneratePersonalWS',
4
    init: function () {
5
        this.control({
6
            '[name=Type]': {
7
                afterrender: this.ChangePeriode,
8
                change: this.ChangePeriode
9
            },
10
            '[name=Execute]': {
11
                click: this.Execute
12
            }
13
            //'[name=Load]': {
14
            //    click: this.LoadData
15
            //}
16

    
17
        });
18
    },
19
    AddBy: function () {
20
        var AddBy = Ext.ComponentQuery.query('[name=AddBy]')[0].getValue();
21
        var Year = Ext.ComponentQuery.query('[name=Year]')[0];
22
        var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
23
        var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
24

    
25
        if (AddBy == '0') {
26
            StartDate.disable();
27
            EndDate.disable();
28
            Year.enable();
29
        }
30
        else {
31
            Year.disable();
32
            StartDate.enable();
33
            EndDate.enable();
34
        }
35
    },
36
    //LoadData: function () {
37
    //    var ws = Ext.ComponentQuery.query('[name=WorkSchedule]')[0].getValue();
38
    //    var country = Ext.ComponentQuery.query('[name=Country]')[0].getValue();
39
    //    var year = Ext.ComponentQuery.query('[name=Year]')[0].getValue();
40
    //    Ext.Ajax.request({
41
    //        method: 'POST',
42
    //        url: '/UserControl/GetStore',
43
    //        params: {
44
    //            tableName: "PHRTMWSCAL",
45
    //            param: "WorkScheduleType[equal]" + ws + ",Country[equal]" + country + ",Year[equal]" + year
46
    //        },
47
    //        success: function (response) {
48
    //            var result = Ext.decode(response.responseText);
49
    //            if (result.success) {
50
    //                var grid = Ext.ComponentQuery.query('grid[name=generatePersonalWS]')[0];
51
    //                var _store = grid.store;
52
    //                _store.removeAll();
53
    //                _store.loadData(result.data);
54
    //            }
55
    //        },
56
    //        failure: function (response) {
57
    //        }
58
    //    });
59
    //},
60
    Execute: function () {
61
        var me = this;
62
        var form = Ext.ComponentQuery.query('form[name=GeneratePersonalWS]')[0];
63
        var formparam = form.getForm();
64
        if (formparam.isValid()) {
65
            form.mask('Loading...');
66
            var EmpStart = Ext.ComponentQuery.query('[name=EmployeeIDFrom]')[0];
67
            var EmpEnd = Ext.ComponentQuery.query('[name=EmployeeIDTo]')[0];
68
            var Year = Ext.ComponentQuery.query('[name=Year]')[0];
69
            var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0];
70
            var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0];
71
            var menuid = MinovaUtil.GetMenuID();
72
            var Type = Ext.ComponentQuery.query('[name=Type]')[0].getValue();
73
            MinovaUtil.ExecuteParamQuery({
74
                ID: "TM_DeletePWS",
75
                EmployeeIDFrom: EmpStart.getValue(),
76
                EmployeeIDTo: EmpEnd.getValue(),
77
                Year: Year.getValue(),
78
                StartDate: StartDate.getValue(),
79
                EndDate: EndDate.getValue(),
80
                Type: Type,
81
            }, function (s) {
82
                var result = Ext.decode(s.responseText);
83
                var dt = Ext.decode(Ext.decode(result.data));
84
                if (Type == '1') {
85
                Ext.Ajax.request({
86
                    method: 'POST',
87
                    url: '/TM/GeneratePersonalWS',
88
                    params: {
89
                            EmployeeIDFrom: EmpStart.getValue(),
90
                        EmployeeIDTo: EmpEnd.getValue(),
91
                        Year: Year.getValue(),
92
                        menuid: "TM07"
93
                    },
94
                    waitMsg: 'Saving Data...',
95
                    success: function (response) {
96
                        var result = Ext.decode(response.responseText);
97
                        var storeMedClaim = Ext.StoreMgr.lookup("storegeneratePersonalWS");
98
                        storeMedClaim.loadData(Ext.decode(result.data));
99
                        if (result.success) {
100
                            MinovaMessage('', '000006', '', 'S');
101
                            form.unmask();
102
                        } else {
103
                            form.unmask();
104
                            MinovaMessage('', '000005', result.message.text, "E")
105
                        }
106
                    },
107
                    failure: function (response) {
108
                        var result = Ext.decode(response.responseText);
109
                        form.unmask();
110
                        MinovaMessage('', '000005', result.message.text, "E")
111
                    }
112
                });                
113
            } else {
114
                Ext.Ajax.request({
115
                    method: 'POST',
116
                    url: '/TM/GeneratePersonalWSPeriod',
117
                    params: {
118
                        EmployeeIDFrom: EmpStart.getValue(),
119
                        EmployeeIDTo: EmpEnd.getValue(),
120
                        StartDate: StartDate.getValue(),
121
                        EndDate: EndDate.getValue(),
122
                        menuid: "TM07"
123
                    },
124
                    waitMsg: 'Saving Data...',
125
                    success: function (response) {
126

    
127
                        var result = Ext.decode(response.responseText);
128
                        var storeMedClaim = Ext.StoreMgr.lookup("storegeneratePersonalWS");
129
                        storeMedClaim.loadData(Ext.decode(result.data));
130
                        if (result.success) {
131
                            MinovaMessage('', '000006', '', 'S');
132
                            form.unmask();
133
                        } else {
134
                            form.unmask();
135
                            MinovaMessage('', '000005', result.message.text, "E")
136
                        }
137
                    },
138
                    failure: function (response) {
139
                        var result = Ext.decode(response.responseText);
140
                        form.unmask();
141
                        MinovaMessage('', '000005', result.message.text, "E")
142
                    }
143
                });
144
            }	
145
            }, function (f) {
146
				var result = Ext.decode(response.responseText);
147
				form.unmask();
148
				MinovaMessage('', '000005', result.message.text, "E")
149
            });            
150
        }
151
    },
152
    ChangePeriode: function () {
153
        var AddBy = Ext.ComponentQuery.query('[name=Type]')[0].getValue();
154
        var Year = Ext.ComponentQuery.query('[name=Year]')[0];
155
        var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0];
156
        var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0];
157
        if (AddBy == '1') {
158
            StartDate.disable();
159
            EndDate.disable();
160
            Year.enable();
161
        }
162
        else {
163
            Year.disable();
164
            StartDate.enable();
165
            EndDate.enable();
166
        }
167
    },
168
});
(2-2/2)