1
|
Ext.define('MinovaES.controller.masterdata.tm.CtrlGenerateWorkSchedule', {
|
2
|
extend: 'Ext.app.ViewController',
|
3
|
alias: 'controller.CtrlGenerateWorkSchedule',
|
4
|
init: function () {
|
5
|
this.control({
|
6
|
'[name=AddBy]': {
|
7
|
afterrender: this.AddBy,
|
8
|
change: this.ComboAddBy
|
9
|
},
|
10
|
'[name=WorkSchedule]': {
|
11
|
change: this.ComboWorkSchedule
|
12
|
},
|
13
|
'[name=Execute]': {
|
14
|
click: this.Execute
|
15
|
},
|
16
|
'[name=Load]': {
|
17
|
click: this.LoadData
|
18
|
}
|
19
|
|
20
|
});
|
21
|
},
|
22
|
ComboWorkSchedule: function () {
|
23
|
var hasil = null;
|
24
|
var store = null;
|
25
|
//var store_ = null;
|
26
|
var combo = Ext.ComponentQuery.query('[name=WorkSchedule]')[0].getValue();
|
27
|
var grid = Ext.ComponentQuery.query('[name=gridworkschedule]')[0];
|
28
|
var s = grid.getStore();
|
29
|
s.removeAll();
|
30
|
Ext.Ajax.request({
|
31
|
async: false,
|
32
|
method: 'POST',
|
33
|
url: '/UserControl/GetStore',
|
34
|
params: {
|
35
|
tableName: 'PDSTM0003',
|
36
|
param: 'WorkScheduleType[equal]' + combo
|
37
|
},
|
38
|
success: function (response) {
|
39
|
var results = Ext.decode(response.responseText);
|
40
|
hasil = results.data;
|
41
|
s.loadData(results.data);
|
42
|
}
|
43
|
});
|
44
|
},
|
45
|
AddBy: function () {
|
46
|
var AddBy = Ext.ComponentQuery.query('[name=AddBy]')[0].getValue();
|
47
|
var Year = Ext.ComponentQuery.query('[name=Year]')[0];
|
48
|
var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0];
|
49
|
var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0];
|
50
|
if (AddBy == '0') {
|
51
|
StartDate.disable();
|
52
|
EndDate.disable();
|
53
|
Year.enable();
|
54
|
}
|
55
|
else {
|
56
|
Year.disable();
|
57
|
StartDate.enable();
|
58
|
EndDate.enable();
|
59
|
}
|
60
|
},
|
61
|
ComboAddBy: function() {
|
62
|
var AddBy = Ext.ComponentQuery.query('[name=AddBy]')[0].getValue();
|
63
|
var Year = Ext.ComponentQuery.query('[name=Year]')[0];
|
64
|
var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0];
|
65
|
var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0];
|
66
|
if (AddBy == '0') {
|
67
|
StartDate.disable();
|
68
|
EndDate.disable();
|
69
|
Year.enable();
|
70
|
}
|
71
|
else {
|
72
|
Year.disable();
|
73
|
StartDate.enable();
|
74
|
EndDate.enable();
|
75
|
}
|
76
|
},
|
77
|
LoadData: function () {
|
78
|
//Azid 04APRIL2024
|
79
|
//var ws = Ext.ComponentQuery.query('[name=WorkSchedule]')[0].getValue();
|
80
|
var ws = Ext.ComponentQuery.query('[name=WorkSchedule]')[0].selection.data.WorkScheduleType;
|
81
|
var country = Ext.ComponentQuery.query('[name=Country]')[0].getValue();
|
82
|
var year = Ext.ComponentQuery.query('[name=Year]')[0].getValue();
|
83
|
var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0].getValue();
|
84
|
var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0].getValue();
|
85
|
if (year != undefined) {
|
86
|
Ext.Ajax.request({
|
87
|
method: 'POST',
|
88
|
url: '/UserControl/GetStore',
|
89
|
params: {
|
90
|
tableName: "PHRTMWSCAL",
|
91
|
param: "WorkScheduleType[equal]" + ws + ",Country[equal]" + country + ",Year[equal]" + year
|
92
|
},
|
93
|
success: function (response) {
|
94
|
var result = Ext.decode(response.responseText);
|
95
|
if (result.success) {
|
96
|
var grid = Ext.ComponentQuery.query('grid[name=generateWScalender]')[0];
|
97
|
var _store = grid.store;
|
98
|
_store.removeAll();
|
99
|
_store.loadData(result.data);
|
100
|
}
|
101
|
},
|
102
|
failure: function (response) {
|
103
|
}
|
104
|
});
|
105
|
} else {
|
106
|
Ext.Ajax.request({
|
107
|
async: false,
|
108
|
url: '/UserControl/GetStore',
|
109
|
params: {
|
110
|
tableName: "GETPHRTMWSCAL",
|
111
|
param: "WorkScheduleType[=]" + ws + ",Country[=]" + country + ",StartDate[<=]" + StartDate + ",EndDate[>=]" + EndDate
|
112
|
},
|
113
|
success: function (response) {
|
114
|
var result = Ext.decode(response.responseText);
|
115
|
if (result.success) {
|
116
|
var grid = Ext.ComponentQuery.query('grid[name=generateWScalender]')[0];
|
117
|
var _store = grid.store;
|
118
|
_store.removeAll();
|
119
|
_store.loadData(result.data);
|
120
|
}
|
121
|
},
|
122
|
failure: function (response) {
|
123
|
}
|
124
|
});
|
125
|
}
|
126
|
|
127
|
},
|
128
|
|
129
|
Execute: function () {
|
130
|
var me = this;
|
131
|
var form = Ext.ComponentQuery.query('form[name=GenerateWorkScheduleCalender]')[0];
|
132
|
var formparam = form.getForm();
|
133
|
if (formparam.isValid()) {
|
134
|
form.mask('Loading...');
|
135
|
//saswanto 26APRIL2022
|
136
|
var WS = Ext.ComponentQuery.query('[name=WorkSchedule]')[0];
|
137
|
var WSCODE = Ext.ComponentQuery.query('[name=WorkSchedule]')[0].selection.data.WorkScheduleType;
|
138
|
var Country = Ext.ComponentQuery.query('[name=Country]')[0];
|
139
|
var AddBy = Ext.ComponentQuery.query('[name=AddBy]')[0];
|
140
|
var Year = Ext.ComponentQuery.query('[name=Year]')[0];
|
141
|
var StartDate = Ext.ComponentQuery.query('[name=SDate]')[0];
|
142
|
var EndDate = Ext.ComponentQuery.query('[name=EDate]')[0];
|
143
|
Ext.Ajax.request({
|
144
|
method: 'POST',
|
145
|
url: '/Devt/GenerateWSCalender',
|
146
|
params: {
|
147
|
//WorkSchedule: WS.getValue(),
|
148
|
WorkSchedule: WS.selection.data.WorkScheduleType,
|
149
|
Country: Country.getValue(),
|
150
|
AddBy: AddBy.getValue(),
|
151
|
Year: Year.getValue(),
|
152
|
StartDate: StartDate.getValue(),
|
153
|
EndDate: EndDate.getValue()
|
154
|
},
|
155
|
waitMsg: 'Saving Data...',
|
156
|
success: function (response) {
|
157
|
|
158
|
var result = Ext.decode(response.responseText);
|
159
|
if (result.success) {
|
160
|
me.LoadData(WS.getValue(), Country.getValue());
|
161
|
MinovaMessage('', '000006', '', 'S');
|
162
|
form.unmask();
|
163
|
|
164
|
} else {
|
165
|
form.unmask();
|
166
|
MinovaMessage('', '000005', result.message.text, "E")
|
167
|
}
|
168
|
|
169
|
var myyear = '0';
|
170
|
var myStartDate = '0';
|
171
|
var myEndDate = '0';
|
172
|
if (Year.getValue() != undefined || StartDate.getValue() == '' ){
|
173
|
myyear=Year.getValue();
|
174
|
|
175
|
if (StartDate.getValue() != undefined || StartDate.getValue() == ''){
|
176
|
myStartDate = Year.getValue() + '0101';
|
177
|
myEndDate = Year.getValue() + '1231';
|
178
|
}
|
179
|
else
|
180
|
{
|
181
|
myStartDate = StartDate.getValue();
|
182
|
myEndDate = EndDate.getValue();
|
183
|
}
|
184
|
} else {
|
185
|
myStartDate = StartDate.getValue();
|
186
|
myEndDate = EndDate.getValue();
|
187
|
myyear = myStartDate.substring(0, 4);
|
188
|
}
|
189
|
|
190
|
|
191
|
MinovaUtil.ExecuteParamQuery({
|
192
|
ID: "INSERTPHRPA0125",
|
193
|
WorkScheduleType:WS.selection.data.WorkScheduleType,
|
194
|
StartDate:myStartDate,
|
195
|
EndDate:myEndDate,
|
196
|
Year:myyear,
|
197
|
}, function (s) {
|
198
|
var result = Ext.decode(s.responseText);
|
199
|
var dt = Ext.decode(Ext.decode(result.data));
|
200
|
});
|
201
|
|
202
|
|
203
|
},
|
204
|
failure: function (response) {
|
205
|
var result = Ext.decode(response.responseText);
|
206
|
form.unmask();
|
207
|
MinovaMessage('', '000005', result.message.text, "E")
|
208
|
}
|
209
|
});
|
210
|
|
211
|
}
|
212
|
}
|
213
|
});
|