1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
Ext.define('MinovaUtil', {});
|
5
|
MinovaUtil.executeParamQuery = function (params, fn_success, fn_failed, scope) {
|
6
|
var urlQueryParam = '/workflow/LoadDataQuery';
|
7
|
MinovaAjaxPostSync(urlQueryParam, params, fn_success, fn_failed, scope);
|
8
|
}
|
9
|
MinovaUtil.buildParamQuery = function (paramKeys) {
|
10
|
|
11
|
paramKeys = paramKeys ? paramKeys : null
|
12
|
|
13
|
var buildParams = '';
|
14
|
|
15
|
Ext.each(paramKeys, function (param) {
|
16
|
var values = param.value;
|
17
|
var name = param.key;
|
18
|
var obj = name + ':"' + values + '",';
|
19
|
buildParams += obj;
|
20
|
})
|
21
|
buildParams = buildParams.substring(0, buildParams.length - 1)
|
22
|
|
23
|
// Ext.global.console.log(buildParams)
|
24
|
var params = "{params:{" + buildParams + "}}";
|
25
|
// Ext.global.console.log(params)
|
26
|
// Ext.global.console.log(Ext.encode(params))
|
27
|
// Ext.global.console.log(Ext.decode(params))
|
28
|
|
29
|
return Ext.decode(params)// buildParams;
|
30
|
}
|
31
|
MinovaUtil.buildFormsFromTable = function (tableName, formSource) {
|
32
|
function buildingForms(data) {
|
33
|
var fields = [];
|
34
|
var form1 = Ext.widget('form', {layout: 'column'})
|
35
|
var container1 = Ext.widget('container', {columnWidth: 0.5});
|
36
|
var container2 = Ext.widget('container', {columnWidth: 0.5});
|
37
|
// var IsCustomColumns = this.visibleColumns != undefined && this.visibleColumns.length > 0;
|
38
|
Ext.each(data, function (p) {
|
39
|
|
40
|
fields.push(Ext.widget('textfield', {
|
41
|
name: p.column_name,
|
42
|
fieldLabel: p.column_name,
|
43
|
allowBlank: p.is_primary_key == 0,
|
44
|
maxLength: p.max_length
|
45
|
}));
|
46
|
|
47
|
});
|
48
|
for (i = 0; i <= (fields.length); i++) {
|
49
|
//fields.push(field);
|
50
|
if (i < (fields.length / 2))
|
51
|
container1.add(fields[i])
|
52
|
else
|
53
|
container2.add(fields[i]);
|
54
|
}
|
55
|
|
56
|
//this.items.items = [ container1, container2]
|
57
|
//this.doLayout();
|
58
|
//formSource.items.clear();
|
59
|
//formSource.apply({layout:'column'});
|
60
|
form1.add(container1);
|
61
|
form1.add(container2);
|
62
|
formSource.add(form1);
|
63
|
//formSource.items.items = [ container1, container2];
|
64
|
formSource.doLayout();
|
65
|
}
|
66
|
|
67
|
MinovaUtil.executeParamQuery({
|
68
|
paramid: 'getSysTable',
|
69
|
tableName: tableName},
|
70
|
function (s) {
|
71
|
var data = Ext.decode(s.responseText).data;
|
72
|
return buildingForms(data)
|
73
|
}, function (f) {
|
74
|
});
|
75
|
}
|
76
|
MinovaUtil.updateSessions = function (dataSessions) {
|
77
|
|
78
|
if ((dataSessions === null) && (dataSessions === null)) {
|
79
|
// --------- hapus sessions var map
|
80
|
this.SESSIONS.LOGIN.empId !== undefined
|
81
|
? this.SESSIONS.LOGIN.empId = null
|
82
|
: null;
|
83
|
this.SESSIONS.LOGIN.formatName !== undefined
|
84
|
? this.SESSIONS.LOGIN.formatName = null
|
85
|
: null;
|
86
|
this.SESSIONS.LOGIN.userId !== undefined
|
87
|
? this.SESSIONS.LOGIN.userId = null
|
88
|
: null;
|
89
|
// --------- hapus sessions var map
|
90
|
// ---------- hapus setingan applikasi dari store
|
91
|
storeApp = Ext.StoreManager.lookup('base.main.App');
|
92
|
storeApp.removeAll(true);
|
93
|
// ---------- hapus setingan applikasi dari store
|
94
|
return
|
95
|
}
|
96
|
var data = dataSessions;
|
97
|
// --------- sessions var map
|
98
|
this.SESSIONS.LOGIN.empId = data.Sessions.EmpID
|
99
|
this.SESSIONS.LOGIN.formatName = data.Sessions.FormatName
|
100
|
this.SESSIONS.LOGIN.userId = data.Sessions.UserID
|
101
|
// --------- sessions var map
|
102
|
// --------- buat setingan applikasi dari store
|
103
|
storeApp = Ext.StoreManager.lookup('base.main.App');
|
104
|
storeApp.removeAll(true);
|
105
|
storeApp.clearFilter();
|
106
|
storeApp.add(data.AppSettings);
|
107
|
// // --------- buat object sppsetings
|
108
|
var str = "";
|
109
|
storeApp.each(function (r) {
|
110
|
str += '"' + r.data.name + '":"' + r.data.value + '",'
|
111
|
})
|
112
|
var obj = Ext.decode("{" + str.substring(0, str.length - 1) + "}");
|
113
|
MinovaUtil.SESSIONS.APPSETINGS = obj;
|
114
|
// // --------- buat object sppsetings
|
115
|
// --------- buat setingan applikasi dari store
|
116
|
}
|
117
|
MinovaUtil.getActiveTab = function () {
|
118
|
var mainTab = MinovaUtil.WORKFLOW.getMainTab()
|
119
|
return mainTab !== null ? mainTab.getActiveTab() : null;
|
120
|
}
|
121
|
/**
|
122
|
* gunakan fungsi ini untuk memunculkan pesan dialog
|
123
|
* @type {{error: Function, alert: Function, confirm: Function, show: Function}}
|
124
|
*/
|
125
|
MinovaUtil.MESSAGE = {
|
126
|
/**
|
127
|
* memunculkan pesan error
|
128
|
* @param msg
|
129
|
*/
|
130
|
error: function (msg) {
|
131
|
this.show('Error', msg, Ext.Msg.OK, Ext.Msg.ERROR);
|
132
|
},
|
133
|
/**
|
134
|
* memunculkan pesan/alert
|
135
|
* @param msg
|
136
|
*/
|
137
|
alert: function (msg) {
|
138
|
this.show('Information', msg, Ext.Msg.OK, Ext.Msg.INFO);
|
139
|
},
|
140
|
/**
|
141
|
* memunculkan pesan konfirmasi
|
142
|
* @param msg
|
143
|
* @param fnResponse
|
144
|
* @returns {*|Ext.window.MessageBox}
|
145
|
*/
|
146
|
confirm: function (msg, fnResponse) {
|
147
|
return Ext.MessageBox.confirm('Confirmation', msg,
|
148
|
function (btnTxt) {
|
149
|
if (typeof(fnResponse) === 'function') {
|
150
|
new fnResponse(btnTxt);
|
151
|
}
|
152
|
})
|
153
|
},
|
154
|
/**
|
155
|
* memunculkan pesan secara custom
|
156
|
* @param title
|
157
|
* @param message
|
158
|
* @param buttons
|
159
|
* @param icon
|
160
|
*/
|
161
|
show: function (title, message, buttons, icon) {
|
162
|
Ext.Msg.show({
|
163
|
title: title,
|
164
|
msg: message,
|
165
|
buttons: buttons, // Ext.Msg.OK,
|
166
|
icon: icon
|
167
|
// Ext.Msg.ERROR
|
168
|
});
|
169
|
}
|
170
|
}
|
171
|
MinovaUtil.CRUD = {
|
172
|
addRecord: function (button, rec) {
|
173
|
var r = rec ? rec : Ext.data.Model();
|
174
|
button.up('grid').store.add(r);
|
175
|
},
|
176
|
copyRecord: function (button) {
|
177
|
var selRec = button.up('grid').getSelectionModel().getSelection()[0];
|
178
|
var rec = selRec.copy(); // clone the record
|
179
|
Ext.data.Model.id(rec); // automatically generate a unique
|
180
|
// sequential id
|
181
|
button.up('grid').store.add(rec);
|
182
|
},
|
183
|
removeRecord: function (button) {
|
184
|
var selRecs = button.up('grid').getSelectionModel().getSelection();
|
185
|
Ext.each(selRecs, function (rec) {
|
186
|
rec.reject(true);
|
187
|
});
|
188
|
button.up('grid').store.remove(selRecs);
|
189
|
}
|
190
|
}
|
191
|
/**
|
192
|
*
|
193
|
* @type {{autoShowAfterLogin: Function, loadControllerByViewClass: Function, compareWorkplace: Function, isCreatorLogin: Function, isRequest: Function, isInbox: Function, isOutbox: Function, isDraft: Function, isArchive: Function, setReadOnlyViewByProperty: Function, setReadOnlyViewBodyWorkflow: Function, setReadOnlyView: Function, setReadOnlyGridByName: Function, setReadOnlyFormByName: Function, setViewBodyWorkflowFormContent: Function, getViewWorkPlace: Function, getMainTab: Function, getViewHeaderWorkflow: Function, getViewFooterWorkflow: Function, getViewInfoWorkflow: Function, showViewInfoWorkflow: Function, getViewWorkPlaceInbox: Function, getViewWorkflow: Function, getViewActive: Function, getViewBodyWorkflow: Function, getTaskId: Function, getFlowId: Function, getBizprocId: Function, getBizflowId: Function, getRegId: Function, getEmpId: Function, getTaskIdFromView: Function}}
|
194
|
*/
|
195
|
MinovaUtil.WORKFLOW = {
|
196
|
/**
|
197
|
* fungsi ini digunakan untuk memunculkan program/applikasi secara default
|
198
|
* @param loginInfo
|
199
|
*/
|
200
|
autoShowAfterLogin: function (loginInfo) {
|
201
|
// auto show module after login
|
202
|
Ext.global.console.log('configuration ...AUTOSHOWMODULE');
|
203
|
MinovaUtil.executeParamQuery({
|
204
|
paramid: 'wf_base_module_auto_show'
|
205
|
},
|
206
|
function (s) {
|
207
|
//[instance],[seq],[title],[controller],[active],[active_function]
|
208
|
var datas = Ext.decode(s.responseText).data;
|
209
|
if (datas) {
|
210
|
Ext.each(datas, function (d) {
|
211
|
var activeFn = false;
|
212
|
var isFunction = typeof(Ext.decode(d.active_function)) === 'function';
|
213
|
activeFn = isFunction ? (function () {
|
214
|
try {
|
215
|
return Ext.decode(d.active_function)(loginInfo)
|
216
|
} catch (e) {
|
217
|
Ext.global.console.error('try load ' + d.title + '\n' + e);
|
218
|
return false
|
219
|
}
|
220
|
})() : true;
|
221
|
if (activeFn)
|
222
|
MinovaOpenProgram({
|
223
|
title: d.title,
|
224
|
controller: d.controller
|
225
|
});
|
226
|
});
|
227
|
}
|
228
|
},
|
229
|
function (f) {
|
230
|
}
|
231
|
);
|
232
|
},
|
233
|
/**
|
234
|
* fungsi ini digunakan untuk mengambil controller by view class name
|
235
|
* @param viewClass
|
236
|
* @returns {null}
|
237
|
*/
|
238
|
loadControllerByViewClass: function (viewClass) {
|
239
|
// mencari controller dari view
|
240
|
// return controller
|
241
|
var minovaClassView = "MinovaIS.ERP.Web.view";
|
242
|
if (viewClass.indexOf(minovaClassView) >= 0) {
|
243
|
viewClass = viewClass.substring(minovaClassView.length + 1/*plus koma*/);
|
244
|
}
|
245
|
|
246
|
var hasil = null;
|
247
|
Ext.each(MinovaApp.controllers.items, function (c) {
|
248
|
try {
|
249
|
var found = c.views.indexOf(viewClass);
|
250
|
if (found >= 0)
|
251
|
hasil = c;
|
252
|
} catch (e) {
|
253
|
}
|
254
|
})
|
255
|
return hasil;
|
256
|
},
|
257
|
compareWorkplace: function (workplaceXtype) {
|
258
|
var hasil = false;
|
259
|
var _curXtype = MinovaUtil.WORKFLOW.getViewWorkPlace().xtype;
|
260
|
if (_curXtype == workplaceXtype)
|
261
|
hasil = true
|
262
|
return hasil;
|
263
|
},
|
264
|
/**
|
265
|
* cek apakah user login = creator
|
266
|
* @returns {boolean}
|
267
|
*/
|
268
|
isCreatorLogin: function () {
|
269
|
return MinovaUtil.SESSIONS.LOGIN.empId == MinovaUtil.WORKFLOW
|
270
|
.getEmpId() ? true : false;
|
271
|
},
|
272
|
/**
|
273
|
* cek apakah dalam operasi request
|
274
|
* @returns {boolean}
|
275
|
*/
|
276
|
isRequest: function () {
|
277
|
var result = false;
|
278
|
try {
|
279
|
result = this.getViewWorkPlace().getLayout().activeItem.name == 'content' ||
|
280
|
MinovaUtil.WORKFLOW.isDraft();
|
281
|
} catch (e) {
|
282
|
}
|
283
|
return result;
|
284
|
// return this.compareWorkplace('wf-request-requestScreen');
|
285
|
},
|
286
|
/**
|
287
|
* cek apakah dalam operasi inbox
|
288
|
* @returns {*}
|
289
|
*/
|
290
|
isInbox: function () {
|
291
|
return this.compareWorkplace('wf-inbox-InboxScreen');
|
292
|
},
|
293
|
/**
|
294
|
* cek apakah dalam operasi outbox
|
295
|
* @returns {*}
|
296
|
*/
|
297
|
isOutbox: function () {
|
298
|
return this.compareWorkplace('wf-outbox-outboxScreen');
|
299
|
},
|
300
|
/**
|
301
|
* cek apakah dalam operasi draft
|
302
|
* @returns {*}
|
303
|
*/
|
304
|
isDraft: function () {
|
305
|
return this.compareWorkplace('wf-draft-draftScreen');
|
306
|
},
|
307
|
/**
|
308
|
* cek apakah dalam operasi archive
|
309
|
* @returns {*}
|
310
|
*/
|
311
|
isArchive: function () {
|
312
|
return this.compareWorkplace('wf-archive-archiveScreen');
|
313
|
},
|
314
|
|
315
|
isDocument: function () {
|
316
|
if (MinovaUtil.WORKFLOW.isRequest()
|
317
|
|| MinovaUtil.WORKFLOW.isInbox()
|
318
|
|| MinovaUtil.WORKFLOW.isOutbox()
|
319
|
|| MinovaUtil.WORKFLOW.isArchive()
|
320
|
|| MinovaUtil.WORKFLOW.isDraft()) {
|
321
|
return true
|
322
|
} else {
|
323
|
return false
|
324
|
}
|
325
|
},
|
326
|
|
327
|
setReadOnlyViewByProperty: function (opt, bit) {
|
328
|
var view = this.getViewWorkflow().down(opt.xtype + '[name='
|
329
|
+ opt.name + ']');
|
330
|
this.setReadOnlyView(view, bit);
|
331
|
},
|
332
|
setReadOnlyViewBodyWorkflow: function (bit) {
|
333
|
this.setReadOnlyView(this.getViewBodyWorkflow(), bit);
|
334
|
},
|
335
|
|
336
|
setReadOnlyView: function (view, bit) {
|
337
|
function hasEditorProperty(o) {
|
338
|
var hasil = false;
|
339
|
try {
|
340
|
if (o.getEditor()) {
|
341
|
hasil = !hasil;
|
342
|
}
|
343
|
} catch (e) {
|
344
|
}
|
345
|
return hasil;
|
346
|
}
|
347
|
|
348
|
function setObjReadOnly(obj, bit) {
|
349
|
if (hasEditorProperty(obj))
|
350
|
try {
|
351
|
var editor = obj.getEditor();
|
352
|
editor.setReadOnly(bit);
|
353
|
} catch (e) {
|
354
|
}
|
355
|
else {
|
356
|
if (obj.xtype == 'button')
|
357
|
obj.setDisabled(bit);
|
358
|
else if (obj.xtype == 'grid') {
|
359
|
this.setReadOnlyGridByName(obj.name, bit)
|
360
|
// Ext.each(obj.columns, function(b) {
|
361
|
// if (hasEditorProperty(b)) {
|
362
|
// var gEditor = b.getEditor();
|
363
|
// // gEditor.setEditable(c);
|
364
|
// gEditor.setReadOnly(c);
|
365
|
// }
|
366
|
// });
|
367
|
} else {
|
368
|
try {
|
369
|
obj.setReadOnly(bit);
|
370
|
} catch (e) {
|
371
|
}
|
372
|
}
|
373
|
}
|
374
|
}
|
375
|
|
376
|
bit = bit == undefined ? true : bit;
|
377
|
// var obj = this.getViewWorkflow().down(opt.xtype + "[name="
|
378
|
// + opt.name + "]");
|
379
|
var obj = view;
|
380
|
if (obj == null)
|
381
|
return;
|
382
|
|
383
|
if (!obj.hasOwnProperty('items')) {
|
384
|
setObjReadOnly(obj, bit);
|
385
|
} else
|
386
|
Ext.each(obj.query(), function (o) {
|
387
|
try {
|
388
|
// o.setReadOnly(bit)
|
389
|
setObjReadOnly(o, bit);
|
390
|
} catch (e) {
|
391
|
}
|
392
|
})
|
393
|
},
|
394
|
|
395
|
setReadOnlyGridByName: function (gridName, bit) {
|
396
|
bit = bit == undefined ? true : bit;
|
397
|
var obj = this.getViewWorkflow()
|
398
|
.down('grid[name=' + gridName + ']');
|
399
|
if (obj == null)
|
400
|
return;
|
401
|
Ext.each(obj.query('button'), function (c) {
|
402
|
c.setDisabled(bit);
|
403
|
});
|
404
|
Ext.each(obj.columns, function (b) {
|
405
|
try {
|
406
|
var gEditor = b.getEditor();
|
407
|
// gEditor.setEditable(false);
|
408
|
gEditor.setReadOnly(bit);
|
409
|
} catch (e) {
|
410
|
}
|
411
|
});
|
412
|
},
|
413
|
|
414
|
setReadOnlyFormByName: function (formName, bit) {
|
415
|
// default true
|
416
|
bit = bit == undefined ? true : bit;
|
417
|
var obj = this.getViewWorkflow().down('panel[name=' + formName
|
418
|
+ ']')
|
419
|
if (obj == null)
|
420
|
return;
|
421
|
|
422
|
Ext.each(obj.getForm().items, function (frms) {
|
423
|
Ext.each(frms.items, function (fld) {
|
424
|
try {
|
425
|
obj.down(fld.xtype + '[name='
|
426
|
+ fld.name + ']')
|
427
|
.setReadOnly(bit)
|
428
|
} catch (e) {
|
429
|
}
|
430
|
|
431
|
})
|
432
|
})
|
433
|
|
434
|
},
|
435
|
/**
|
436
|
* set value by name
|
437
|
* @param record
|
438
|
*/
|
439
|
setViewBodyWorkflowFormContent: function (record) {
|
440
|
var forms = MinovaUtil.WORKFLOW.getViewBodyWorkflow().query('form');
|
441
|
//if (forms !== 'object') return false;
|
442
|
Ext.each(forms, function (form) {
|
443
|
form.getForm().setValues(record);
|
444
|
});
|
445
|
},
|
446
|
/**
|
447
|
*
|
448
|
* @param viewXtype
|
449
|
* @returns {null}
|
450
|
*/
|
451
|
getViewWorkPlace: function (viewXtype) {
|
452
|
var hasil = null;
|
453
|
try {
|
454
|
switch (viewXtype) {
|
455
|
case 'home' :
|
456
|
hasil = searchWP('panel');
|
457
|
break;
|
458
|
case 'request' :
|
459
|
hasil = searchWP('wf-request-requestScreen');
|
460
|
break;
|
461
|
case 'inbox' :
|
462
|
hasil = searchWP('wf-inbox-InboxScreen');
|
463
|
break;
|
464
|
case 'outbox' :
|
465
|
hasil = searchWP('wf-outbox-outboxScreen');
|
466
|
break;
|
467
|
case 'draft' :
|
468
|
hasil = searchWP('wf-draft-draftScreen');
|
469
|
break;
|
470
|
case 'archive' :
|
471
|
hasil = searchWP('wf-archive-archiveScreen');
|
472
|
break;
|
473
|
|
474
|
default :
|
475
|
if (DesktopUIFront != "1") {
|
476
|
hasil = this.getMainTab().getLayout()
|
477
|
.getActiveItem();
|
478
|
} else {
|
479
|
hasil = this.getMainTab().getActiveWindow().items.items[0];
|
480
|
}
|
481
|
break;
|
482
|
}
|
483
|
return hasil;
|
484
|
} catch (e) {
|
485
|
return null
|
486
|
}
|
487
|
|
488
|
function searchWP(viewXtype) {
|
489
|
var _tab = null;
|
490
|
var tabs;
|
491
|
if (DesktopUIFront != "1") {
|
492
|
tabs = hasil = this.MinovaUtil.WORKFLOW.getMainTab().items.items;
|
493
|
} else {
|
494
|
tabs = hasil = this.MinovaUtil.WORKFLOW.getMainTab().windows.items;
|
495
|
}
|
496
|
Ext.Array.each(tabs, function (tab) {
|
497
|
if (DesktopUIFront != "1") {
|
498
|
if (tab.xtype == viewXtype) {
|
499
|
_tab = tab;
|
500
|
return false;
|
501
|
}
|
502
|
} else {
|
503
|
if (tab.items.items[0].xtype == viewXtype) {
|
504
|
_tab = tab.items.items[0];
|
505
|
return false;
|
506
|
}
|
507
|
}
|
508
|
});
|
509
|
return _tab;
|
510
|
}
|
511
|
},
|
512
|
|
513
|
getMainTab: function () {
|
514
|
try {
|
515
|
if (DesktopUIFront != "1") {
|
516
|
return Ext.ComponentQuery.query('base-main-Tab')[0]
|
517
|
} else {
|
518
|
return MyDesktopApp.getDesktop();
|
519
|
}
|
520
|
} catch (e) {
|
521
|
return null
|
522
|
}
|
523
|
},
|
524
|
/**
|
525
|
*
|
526
|
* @returns {null}
|
527
|
*/
|
528
|
getViewHeaderWorkflow: function () {
|
529
|
var hasil = null;
|
530
|
try {
|
531
|
hasil = this.getViewActive().down('panel[name=wf_form_header]');
|
532
|
} catch (e) {
|
533
|
}
|
534
|
return hasil;
|
535
|
},
|
536
|
/**
|
537
|
*
|
538
|
* @returns {null}
|
539
|
*/
|
540
|
getViewFooterWorkflow: function () {
|
541
|
var hasil = null;
|
542
|
try {
|
543
|
hasil = this.getViewActive().down('panel[name=wf_form_footer]');
|
544
|
} catch (e) {
|
545
|
}
|
546
|
return hasil;
|
547
|
},
|
548
|
/**
|
549
|
*
|
550
|
* @returns {null}
|
551
|
*/
|
552
|
getViewInfoWorkflow: function () {
|
553
|
var hasil = null;
|
554
|
try {
|
555
|
if (this.getViewActive().query('wf-run-formInformation').length > 0) {
|
556
|
hasil = this.getViewActive()
|
557
|
.query('wf-run-formInformation')[0];
|
558
|
} else {
|
559
|
|
560
|
hasil = this.getViewWorkPlace()
|
561
|
.query('wf-request-formInformation')[0];
|
562
|
}
|
563
|
} catch (e) {
|
564
|
}
|
565
|
return hasil;
|
566
|
},
|
567
|
/**
|
568
|
*
|
569
|
* @returns {null}
|
570
|
*/
|
571
|
showViewInfoWorkflow: function () {
|
572
|
var hasil = null;
|
573
|
try {
|
574
|
if (this.getViewActive().query('wf-run-formInformation').length > 0) {
|
575
|
var hasil = MinovaUtil.WORKFLOW.getViewInfoWorkflow()
|
576
|
.up('panel').getLayout().setActiveItem(1);
|
577
|
} else {
|
578
|
var hasil = MinovaUtil.WORKFLOW.getViewInfoWorkflow()
|
579
|
.up('panel').getLayout().setActiveItem(3);
|
580
|
}
|
581
|
} catch (e) {
|
582
|
}
|
583
|
return hasil;
|
584
|
},
|
585
|
getViewWorkPlaceInbox: function () {
|
586
|
var hasil = null;
|
587
|
try {
|
588
|
var workPlaces = this.MinovaUtil.WORKFLOW.getMainTab().items.items
|
589
|
Ext.Array.each(workPlaces, function (wp) {
|
590
|
|
591
|
});
|
592
|
this.MinovaUtil.WORKFLOW.getMainTab().items.items[1].xtype
|
593
|
} catch (e) {
|
594
|
}
|
595
|
return hasil;
|
596
|
},
|
597
|
getViewWorkflow: function (viewXtype) {
|
598
|
var hasil = null;
|
599
|
viewXtype = viewXtype != undefined ? viewXtype : this
|
600
|
.getViewWorkPlace().xtype;
|
601
|
try {
|
602
|
switch (viewXtype) {
|
603
|
case 'wf-request-requestScreen' :
|
604
|
hasil = MinovaUtil.WORKFLOW.getViewWorkPlace().items.items[2];
|
605
|
break;
|
606
|
case 'wf-inbox-InboxScreen' :
|
607
|
hasil = MinovaUtil.WORKFLOW.getViewWorkPlace()
|
608
|
.down('tabpanel').activeTab.down('tabpanel').activeTab;
|
609
|
break;
|
610
|
case 'wf-draft-draftScreen' :
|
611
|
hasil = MinovaUtil.WORKFLOW.getViewWorkPlace()
|
612
|
.down('tabpanel').activeTab.activeTab;
|
613
|
break;
|
614
|
case 'wf-archive-archiveScreen' :
|
615
|
hasil = MinovaUtil.WORKFLOW.getViewWorkPlace()
|
616
|
.down('tabpanel').activeTab.down('tabpanel').activeTab;
|
617
|
break;
|
618
|
case 'wf-outbox-outboxScreen' :
|
619
|
hasil = MinovaUtil.WORKFLOW.getViewWorkPlace()
|
620
|
.down('tabpanel').activeTab.down('tabpanel').activeTab;
|
621
|
break;
|
622
|
default :
|
623
|
break;
|
624
|
|
625
|
}
|
626
|
|
627
|
// if (this.getViewWorkPlace().xtype ==
|
628
|
// 'wf-request-requestScreen') {
|
629
|
// hasil = this.getViewActive().items.items[1]
|
630
|
// } else {
|
631
|
// var mainTab = this.getViewActive()
|
632
|
// hasil = mainTab.down('wf-run-formData').down('panel')
|
633
|
// }
|
634
|
} catch (e) {
|
635
|
}
|
636
|
return hasil;
|
637
|
},
|
638
|
getViewActive: function () {
|
639
|
var hasil = null;
|
640
|
try {
|
641
|
hasil = this.getViewWorkflow()
|
642
|
} catch (e) {
|
643
|
}
|
644
|
return hasil;
|
645
|
},
|
646
|
/**
|
647
|
* untuk mendapatkan panel body
|
648
|
* @returns {null}
|
649
|
*/
|
650
|
getViewBodyWorkflow: function () {
|
651
|
var hasil = null;
|
652
|
try {
|
653
|
|
654
|
if (this.getViewWorkPlace().xtype == 'wf-request-requestScreen') {
|
655
|
hasil = this.getViewActive().items.items[1]
|
656
|
} else {
|
657
|
var mainTab = this.getViewActive()
|
658
|
hasil = mainTab.down('wf-run-formData').down('panel')
|
659
|
}
|
660
|
} catch (e) {
|
661
|
}
|
662
|
return hasil;
|
663
|
},
|
664
|
/**
|
665
|
* untuk mendapatkan task id
|
666
|
* @returns {null}
|
667
|
*/
|
668
|
getTaskId: function () {
|
669
|
var hasil = null;
|
670
|
try {
|
671
|
var obj = this.getViewActive()
|
672
|
.down('textfield[name=task_id_run]');
|
673
|
if (obj) {
|
674
|
hasil = obj.getValue();
|
675
|
}
|
676
|
} catch (e) {
|
677
|
}
|
678
|
return hasil;
|
679
|
},
|
680
|
/**
|
681
|
*
|
682
|
* @param view
|
683
|
* @returns {null}
|
684
|
*/
|
685
|
getFlowId: function (view) {
|
686
|
var hasil = null;
|
687
|
try {
|
688
|
var obj = this.getViewActive().down('combobox[name=action]');
|
689
|
if (obj) {
|
690
|
hasil = obj.getValue();
|
691
|
}
|
692
|
} catch (e) {
|
693
|
}
|
694
|
return hasil;
|
695
|
},
|
696
|
getFlowType: function (view) {
|
697
|
var hasil = null;
|
698
|
try {
|
699
|
var obj = this.getViewActive().down('combobox[name=action]');
|
700
|
if (obj) {
|
701
|
var rec = obj.store.findRecord('code', obj.getValue());
|
702
|
if (rec)
|
703
|
hasil = rec.data.group;
|
704
|
}
|
705
|
} catch (e) {
|
706
|
}
|
707
|
return hasil;
|
708
|
},
|
709
|
/**
|
710
|
*
|
711
|
* @returns {null}
|
712
|
*/
|
713
|
getBizprocId: function () {
|
714
|
var hasil = null;
|
715
|
try {
|
716
|
var obj = this.getViewActive()
|
717
|
.down('textfield[name=bizproc_id]');
|
718
|
if (obj) {
|
719
|
hasil = obj.getValue();
|
720
|
}
|
721
|
} catch (e) {
|
722
|
}
|
723
|
return hasil;
|
724
|
},
|
725
|
/**
|
726
|
*
|
727
|
* @returns {null}
|
728
|
*/
|
729
|
getBizflowId: function () {
|
730
|
var hasil = null;
|
731
|
try {
|
732
|
var obj = this.getViewActive()
|
733
|
.down('textfield[name=bizflow_id]');
|
734
|
if (obj) {
|
735
|
hasil = obj.getValue();
|
736
|
}
|
737
|
} catch (e) {
|
738
|
}
|
739
|
return hasil;
|
740
|
},
|
741
|
/**
|
742
|
* untuk mendapatkan register id
|
743
|
* @returns {null}
|
744
|
*/
|
745
|
getRegId: function () {
|
746
|
var hasil = null;
|
747
|
try {
|
748
|
var obj = this.getViewActive()
|
749
|
.down('textfield[name=request_id]');
|
750
|
if (obj) {
|
751
|
hasil = obj.getValue();
|
752
|
}
|
753
|
} catch (e) {
|
754
|
}
|
755
|
return hasil;
|
756
|
},
|
757
|
/**
|
758
|
* untuk mendapatkan employee i yang request
|
759
|
* @returns {null}
|
760
|
*/
|
761
|
getEmpId: function () {
|
762
|
var hasil = null;
|
763
|
try {
|
764
|
var obj = this.getViewActive()
|
765
|
.down('textfield[name=employee_id]');
|
766
|
if (obj) {
|
767
|
hasil = obj.getValue();
|
768
|
}
|
769
|
} catch (e) {
|
770
|
}
|
771
|
return hasil;
|
772
|
},
|
773
|
getTaskIdFromView: function (view) {
|
774
|
var hasil = null;
|
775
|
try {
|
776
|
var objTaskIdRun = view.up('panel[name=content]')
|
777
|
.down('textfield[name=task_id_run]');
|
778
|
|
779
|
if (objTaskIdRun) {
|
780
|
hasil = objTaskIdRun.getValue();
|
781
|
}
|
782
|
} catch (e) {
|
783
|
}
|
784
|
return hasil;
|
785
|
},
|
786
|
loadRegValues: function () {
|
787
|
var hasil = undefined
|
788
|
if (MinovaUtil.WORKFLOW.isDocument()) {
|
789
|
var regvalues = MinovaUtil.WORKFLOW.loadControllerByViewClass(MinovaUtil.WORKFLOW.getViewBodyWorkflow().$className).regvalues;
|
790
|
Ext.each(regvalues, function (items) {
|
791
|
for (var item in items) {
|
792
|
if (item == MinovaUtil.WORKFLOW.getRegId()) {
|
793
|
hasil = items[MinovaUtil.WORKFLOW.getRegId()]
|
794
|
return true
|
795
|
}
|
796
|
}
|
797
|
})
|
798
|
|
799
|
}
|
800
|
return hasil;
|
801
|
},
|
802
|
getRegValuesByName: function (name) {
|
803
|
var hasil = undefined;
|
804
|
if (!Ext.isEmpty(MinovaUtil.WORKFLOW.loadRegValues())) {
|
805
|
var regvalues = MinovaUtil.WORKFLOW.loadRegValues()
|
806
|
hasil = regvalues.recForms[0][name]
|
807
|
|| regvalues.recGrids[0][name]
|
808
|
}
|
809
|
|
810
|
return hasil;
|
811
|
}
|
812
|
|
813
|
}
|
814
|
/**
|
815
|
*
|
816
|
* @type {{LOGIN: {userId: null, empId: null, formatName: null}, APPSETINGS: {}, TASK: {config: {timerWarning: number, timerWarningTimeout: number}, run: Function, runIdle: Function, stop: Function, methods: {startTimerWarning: Function, stopTimerWarning: Function, startTimerWarningTimeout: Function, stopTimerWarningTimeout: Function, warningTASK: Function, logout2: Function}}}}
|
817
|
*/
|
818
|
MinovaUtil.SESSIONS = {
|
819
|
LOGIN: {
|
820
|
userId: null,
|
821
|
empId: null,
|
822
|
formatName: null
|
823
|
},
|
824
|
APPSETINGS: {},
|
825
|
TASK: {
|
826
|
config: {
|
827
|
timerWarning: 1000 * 60 * 10,
|
828
|
timerWarningTimeout: 1000 * 60
|
829
|
|
830
|
},
|
831
|
run: function () {
|
832
|
// disable all timer
|
833
|
this.stop();
|
834
|
this.methods.stopTimerWarning();
|
835
|
this.methods.stopTimerWarningTimeout();
|
836
|
this.runIdle(false);
|
837
|
|
838
|
// start
|
839
|
this.methods.startTimerWarning();
|
840
|
this.runIdle(true);
|
841
|
try {
|
842
|
clearTimeout(tiemrAutoLogout);
|
843
|
} catch (e) {
|
844
|
}
|
845
|
},
|
846
|
runIdle: function (yes) {
|
847
|
if (yes == true) {
|
848
|
document.onclick = function () {
|
849
|
// console.log('reset idle timeout')
|
850
|
MinovaUtil.SESSIONS.TASK.stop();
|
851
|
MinovaUtil.SESSIONS.TASK.methods.startTimerWarning();
|
852
|
}
|
853
|
document.onmousemove = function () {
|
854
|
// console.log('reset idle timeout')
|
855
|
// MinovaUtil.SESSIONS.TASK.stop();
|
856
|
// MinovaUtil.SESSIONS.TASK.methods.startTimerWarning();
|
857
|
}
|
858
|
document.onkeydown = function () {
|
859
|
// console.log('reset idle timeout')
|
860
|
MinovaUtil.SESSIONS.TASK.stop();
|
861
|
MinovaUtil.SESSIONS.TASK.methods.startTimerWarning();
|
862
|
}
|
863
|
} else {
|
864
|
document.onclick = null;
|
865
|
document.onmousemove = null;
|
866
|
document.onkeydown = null;
|
867
|
}
|
868
|
},
|
869
|
stop: function () {
|
870
|
// this.runIdle(false)
|
871
|
this.methods.stopTimerWarning();
|
872
|
this.methods.stopTimerWarningTimeout();
|
873
|
|
874
|
},
|
875
|
methods: {
|
876
|
startTimerWarning: function () {
|
877
|
sesWarn = setTimeout(this.warningTASK,
|
878
|
MinovaUtil.SESSIONS.TASK.config.timerWarning);
|
879
|
// Ext.global.console.log('init sesWarn (' + sesWarn + ')'
|
880
|
// + MinovaUtil.SESSIONS.TASK.config.timerWarning);
|
881
|
},
|
882
|
stopTimerWarning: function () {
|
883
|
|
884
|
try {
|
885
|
clearTimeout(sesWarn)
|
886
|
// Ext.global.console
|
887
|
// .log('stop sesWarn (' + sesWarn + ')');
|
888
|
} catch (e) {
|
889
|
}
|
890
|
},
|
891
|
startTimerWarningTimeout: function () {
|
892
|
|
893
|
sesWarnTimeout = setTimeout(this.logout2,
|
894
|
MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout);
|
895
|
// Ext.global.console
|
896
|
// .log('init sesWarnTimeout ('
|
897
|
// + sesWarnTimeout
|
898
|
// + ')'
|
899
|
// + +MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout);
|
900
|
},
|
901
|
stopTimerWarningTimeout: function () {
|
902
|
|
903
|
try {
|
904
|
clearTimeout(sesWarnTimeout)
|
905
|
// Ext.global.console.log('stop sesWarnTimeout ('
|
906
|
// + sesWarnTimeout + ')');
|
907
|
} catch (e) {
|
908
|
}
|
909
|
},
|
910
|
|
911
|
warningTASK: function () {
|
912
|
// check ajax request
|
913
|
|
914
|
if (checkAjaxRequests())
|
915
|
return false
|
916
|
|
917
|
MinovaUtil.SESSIONS.TASK.methods.startTimerWarningTimeout();
|
918
|
MinovaUtil.SESSIONS.TASK.runIdle(false)
|
919
|
return call5();
|
920
|
|
921
|
function checkAjaxRequests() {
|
922
|
var b = Ext.Ajax.requests, a;
|
923
|
for (a in b) {
|
924
|
if (b.hasOwnProperty(a)) {
|
925
|
// this.abort(b[a])
|
926
|
// console.log(a)
|
927
|
// MinovaUtil.SESSIONS.TASK.run()
|
928
|
MinovaUtil.SESSIONS.TASK.stop();
|
929
|
MinovaUtil.SESSIONS.TASK.methods
|
930
|
.startTimerWarning();
|
931
|
return true;
|
932
|
}
|
933
|
}
|
934
|
}
|
935
|
|
936
|
function call1() {
|
937
|
Ext.Msg
|
938
|
.prompt(
|
939
|
'Session will be expired in '
|
940
|
+ MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout
|
941
|
/ 1000 + ' second',
|
942
|
'Please enter your password:',
|
943
|
function (btn, text) {
|
944
|
if (btn == 'ok') {
|
945
|
// lanjut
|
946
|
MinovaUtil.SESSIONS.TASK.methods
|
947
|
.stopTimerWarningTimeout();
|
948
|
MinovaUtil.SESSIONS.TASK.methods
|
949
|
.startTimerWarning();
|
950
|
} else {
|
951
|
// logout
|
952
|
MinovaUtil.SESSIONS.TASK.methods
|
953
|
.logout2()
|
954
|
}
|
955
|
})
|
956
|
}
|
957
|
|
958
|
function call2() {
|
959
|
var _confirm = Ext.Msg
|
960
|
.confirm('Session will be expired in '
|
961
|
+ MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout
|
962
|
/ 1000
|
963
|
+ ' second. press OK to continue or Cancel for logout')
|
964
|
if (_confirm) {
|
965
|
// lanjut
|
966
|
MinovaUtil.SESSIONS.TASK.methods
|
967
|
.stopTimerWarningTimeout();
|
968
|
MinovaUtil.SESSIONS.TASK.methods
|
969
|
.startTimerWarning();
|
970
|
} else {
|
971
|
// logout
|
972
|
MinovaUtil.SESSIONS.TASK.methods.logout2()
|
973
|
}
|
974
|
}
|
975
|
|
976
|
function call3() {
|
977
|
|
978
|
var popupRelogin = Ext.create('Ext.window.Window', {
|
979
|
title: 'Session will be expired',
|
980
|
closable: false,
|
981
|
modal: true,
|
982
|
height: 200,
|
983
|
width: 400,
|
984
|
layout: 'fit',
|
985
|
items: [
|
986
|
{
|
987
|
xtype: 'form',
|
988
|
items: [
|
989
|
{
|
990
|
fieldLabel: 'Enter your password to continue'
|
991
|
}
|
992
|
]
|
993
|
}
|
994
|
]
|
995
|
}).show();
|
996
|
}
|
997
|
|
998
|
function call4() {
|
999
|
var popTitle = 'Automatic logout';
|
1000
|
tiemrAutoLogout = setInterval(textUpd, 1000);
|
1001
|
var cd = MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout
|
1002
|
/ 1000;
|
1003
|
|
1004
|
function textUpd() {
|
1005
|
cd = cd - 1;
|
1006
|
try {
|
1007
|
var win = Ext.ComponentQuery
|
1008
|
.query('window[title=' + popTitle + ']')[0];
|
1009
|
var bt = win.down('button[itemId=no]');
|
1010
|
bt.setText('No(' + cd + 's)');
|
1011
|
} catch (e) {
|
1012
|
// Ext.global.console.log(e)
|
1013
|
}
|
1014
|
}
|
1015
|
|
1016
|
return Ext.Msg.confirm(popTitle,
|
1017
|
'Do you want to continue session?', function (btn, text) {
|
1018
|
if (btn == 'yes') {
|
1019
|
// lanjut
|
1020
|
clearTimeout(tiemrAutoLogout);
|
1021
|
MinovaUtil.SESSIONS.TASK.methods
|
1022
|
.stopTimerWarningTimeout();
|
1023
|
MinovaUtil.SESSIONS.TASK.methods
|
1024
|
.startTimerWarning();
|
1025
|
MinovaUtil.SESSIONS.TASK.runIdle(true)
|
1026
|
} else {
|
1027
|
// logout
|
1028
|
MinovaUtil.SESSIONS.TASK.methods
|
1029
|
.logout2()
|
1030
|
}
|
1031
|
});
|
1032
|
}
|
1033
|
|
1034
|
function call5() {
|
1035
|
tiemrAutoLogout = setInterval(textUpd, 1000);
|
1036
|
var cd = MinovaUtil.SESSIONS.TASK.config.timerWarningTimeout
|
1037
|
/ 1000;
|
1038
|
var Vrelogin = getViewRelogin();
|
1039
|
Vrelogin.down('button[name=login]').setText('Relogin');
|
1040
|
Vrelogin.down('button[name=cancel]').setText('Logout');
|
1041
|
Vrelogin.down('textfield[name=user]')
|
1042
|
.setValue(MinovaUtil.SESSIONS.LOGIN.userId);
|
1043
|
Vrelogin.down('textfield[name=user]').setReadOnly(true);
|
1044
|
Vrelogin.down('textfield[name=pass]').setValue('');
|
1045
|
|
1046
|
function textUpd() {
|
1047
|
cd = cd - 1;
|
1048
|
try {
|
1049
|
var bt = Vrelogin.down('button[name=cancel]');
|
1050
|
bt.setText('Logout(' + cd + 's)');
|
1051
|
} catch (e) {
|
1052
|
// Ext.global.console.log(e)
|
1053
|
}
|
1054
|
}
|
1055
|
|
1056
|
function getViewRelogin() {
|
1057
|
var _dialogLogin = null;
|
1058
|
// Get Controller Login
|
1059
|
var _controller = MinovaApp.getController(appName
|
1060
|
+ '.controller.base.main.Login');
|
1061
|
var _curView = Ext.ComponentQuery
|
1062
|
.query('base-main-Login')[0]
|
1063
|
if (_curView != undefined) {
|
1064
|
_dialogLogin = _curView;
|
1065
|
} else {
|
1066
|
_dialogLogin = Ext.create(_controller.views[0]);
|
1067
|
_controller.init();
|
1068
|
}
|
1069
|
|
1070
|
return _dialogLogin;
|
1071
|
}
|
1072
|
|
1073
|
return _dialogLogin.show();
|
1074
|
|
1075
|
}
|
1076
|
},
|
1077
|
logout2: function () {
|
1078
|
// window.location.reload();
|
1079
|
// Ext.global.console.log('Logout')
|
1080
|
try {
|
1081
|
logout();
|
1082
|
} catch (e) {
|
1083
|
window.location.reload();
|
1084
|
}
|
1085
|
}
|
1086
|
}
|
1087
|
|
1088
|
},
|
1089
|
TASK2: {
|
1090
|
config: {
|
1091
|
timerWarning: 1000 * 60 * 30,
|
1092
|
timerRemain: null,
|
1093
|
_interval_check_session: null,
|
1094
|
_setInterval_warning_expired: null
|
1095
|
},
|
1096
|
run: function () {
|
1097
|
// stop
|
1098
|
MinovaUtil.SESSIONS.TASK2.methods.stop_warning();
|
1099
|
MinovaUtil.SESSIONS.TASK2.methods.stop_check_sessions();
|
1100
|
// start
|
1101
|
MinovaUtil.SESSIONS.TASK2.methods.start_check_sessions();
|
1102
|
},
|
1103
|
methods: {
|
1104
|
check_sessions: function () {
|
1105
|
MinovaAjaxPost('/Devt/CheckSession2/', {}, function (s) {
|
1106
|
var result = Ext.decode(s.responseText);
|
1107
|
var data = result.data;
|
1108
|
MinovaUtil.SESSIONS.TASK2.config.timerWarning = data.SessionWarning;
|
1109
|
MinovaUtil.SESSIONS.TASK2.config.timerRemain = data.SessionRemain;
|
1110
|
if (data.SessionRemain <= data.SessionWarning) {
|
1111
|
if (data.SessionRemain <= 0) {
|
1112
|
console.log('Session Expired')
|
1113
|
MinovaUtil.SESSIONS.TASK2.methods.alert_session_expired();
|
1114
|
}
|
1115
|
else {
|
1116
|
console.log('Session expiired in ' + data.SessionRemain / 1000 + 's')
|
1117
|
MinovaUtil.SESSIONS.TASK2.methods.start_warning();
|
1118
|
}
|
1119
|
} else {
|
1120
|
MinovaUtil.SESSIONS.TASK2.methods.stop_warning();
|
1121
|
|
1122
|
}
|
1123
|
}, function (f) {
|
1124
|
});
|
1125
|
},
|
1126
|
stop_warning: function () {
|
1127
|
function getViewRelogin() {
|
1128
|
var _dialogLogin = null;
|
1129
|
// Get Controller Login
|
1130
|
var _controller = MinovaApp.getController(appName
|
1131
|
+ '.controller.base.main.Login');
|
1132
|
var _curView = Ext.ComponentQuery
|
1133
|
.query('base-main-Login')[0]
|
1134
|
if (_curView != undefined) {
|
1135
|
_dialogLogin = _curView;
|
1136
|
} else {
|
1137
|
_dialogLogin = Ext.create(_controller.views[0]);
|
1138
|
_controller.init();
|
1139
|
}
|
1140
|
|
1141
|
return _dialogLogin;
|
1142
|
}
|
1143
|
|
1144
|
getViewRelogin().hide();
|
1145
|
if (!Ext.isEmpty(MinovaUtil.SESSIONS.TASK2.config._setInterval_warning_expired)) {
|
1146
|
clearInterval(MinovaUtil.SESSIONS.TASK2.config._setInterval_warning_expired);
|
1147
|
MinovaUtil.SESSIONS.TASK2.config._setInterval_warning_expired = null;
|
1148
|
}
|
1149
|
},
|
1150
|
stop_check_sessions: function () {
|
1151
|
if (!Ext.isEmpty(MinovaUtil.SESSIONS.TASK2.config._interval_check_session)) {
|
1152
|
clearInterval(MinovaUtil.SESSIONS.TASK2.config._interval_check_session);
|
1153
|
MinovaUtil.SESSIONS.TASK2.config._interval_check_session = null;
|
1154
|
}
|
1155
|
},
|
1156
|
start_check_sessions: function () {
|
1157
|
if (Ext.isEmpty(MinovaUtil.SESSIONS.TASK2.config._interval_check_session))
|
1158
|
MinovaUtil.SESSIONS.TASK2.config._interval_check_session = setInterval(
|
1159
|
function () {
|
1160
|
console.log('execute MinovaUtil.SESSIONS.TASK2.methods.check_sessions()')
|
1161
|
MinovaUtil.SESSIONS.TASK2.methods.check_sessions()
|
1162
|
}, 5000);
|
1163
|
},
|
1164
|
start_warning: function () {
|
1165
|
function _count_down() {
|
1166
|
cd = cd - 1;
|
1167
|
try {
|
1168
|
var bt = Vrelogin.down('button[name=cancel]');
|
1169
|
bt.setText('Logout(' + cd + 's)');
|
1170
|
|
1171
|
if (cd <= 0) {
|
1172
|
MinovaUtil.SESSIONS.TASK2.methods.stop_warning();
|
1173
|
MinovaUtil.SESSIONS.TASK2.methods.alert_session_expired();
|
1174
|
}
|
1175
|
} catch (e) {
|
1176
|
// Ext.global.console.log(e)
|
1177
|
}
|
1178
|
}
|
1179
|
|
1180
|
function getViewRelogin() {
|
1181
|
var _dialogLogin = null;
|
1182
|
// Get Controller Login
|
1183
|
var _controller = MinovaApp.getController(appName
|
1184
|
+ '.controller.base.main.Login');
|
1185
|
var _curView = Ext.ComponentQuery
|
1186
|
.query('base-main-Login')[0]
|
1187
|
if (_curView != undefined) {
|
1188
|
_dialogLogin = _curView;
|
1189
|
} else {
|
1190
|
_dialogLogin = Ext.create(_controller.views[0]);
|
1191
|
_controller.init();
|
1192
|
}
|
1193
|
|
1194
|
return _dialogLogin;
|
1195
|
}
|
1196
|
|
1197
|
if (Ext.isEmpty(MinovaUtil.SESSIONS.TASK2.config._setInterval_warning_expired)) {
|
1198
|
MinovaUtil.SESSIONS.TASK2.config._setInterval_warning_expired = setInterval(_count_down, 1000);
|
1199
|
var cd = Math.round(MinovaUtil.SESSIONS.TASK2.config.timerRemain / 1000);
|
1200
|
|
1201
|
var Vrelogin = getViewRelogin();
|
1202
|
Vrelogin.down('button[name=login]').setText('Relogin');
|
1203
|
Vrelogin.down('button[name=cancel]').setText('Logout');
|
1204
|
Vrelogin.down('textfield[name=user]').setReadOnly(true);
|
1205
|
Vrelogin.down('textfield[name=user]').setValue(MinovaUtil.SESSIONS.LOGIN.userId);
|
1206
|
// Vrelogin.down('combobox[name=instance]').setReadOnly(true);
|
1207
|
Vrelogin.down('textfield[name=pass]').setValue('');
|
1208
|
}
|
1209
|
|
1210
|
// var p1 = "";
|
1211
|
// var p2 = "";
|
1212
|
// var _params = Ext.decode('{"param1":"' + p1 + '","param2":"' + p2 + '"}');
|
1213
|
// showLoadingMask('Please Wait....');
|
1214
|
|
1215
|
// MinovaAjaxPostSync('/Devt/CheckSession2/', _params, function (response) {
|
1216
|
//
|
1217
|
// var result = Ext.decode(response.responseText);
|
1218
|
//
|
1219
|
// if (result.SessionRemain <= result.SessionWarning) { // Not Validate
|
1220
|
// //_dialogLogin.show();
|
1221
|
// loginButtonMode('logout');
|
1222
|
// isAppLogged = false;
|
1223
|
// }
|
1224
|
// else { // Valid
|
1225
|
// Vrelogin.down('textfield[name=user]')
|
1226
|
// .setValue(result.data.UserID);
|
1227
|
//// Vrelogin.down('combobox[name=instance]')
|
1228
|
//// .setValue(result.data.Instance);
|
1229
|
// }
|
1230
|
// });
|
1231
|
|
1232
|
return _dialogLogin.show();
|
1233
|
},
|
1234
|
alert_session_expired: function () {
|
1235
|
Ext.global.console.log('Sessions has expired.');
|
1236
|
alert('Sessions has expired.');
|
1237
|
location.reload();
|
1238
|
},
|
1239
|
logoutFunc: function () {
|
1240
|
// window.location.reload();
|
1241
|
Ext.global.console.log('Logout');
|
1242
|
logout();
|
1243
|
//location.reload()
|
1244
|
|
1245
|
}
|
1246
|
}
|
1247
|
|
1248
|
}
|
1249
|
|
1250
|
}
|
1251
|
/**
|
1252
|
* auto generate by H/V view
|
1253
|
* @type {{title: string, data: Array, topheader: boolean, add: Function, show: Function}}
|
1254
|
*/
|
1255
|
MinovaUtil.PDF = {
|
1256
|
title: 'Default title',
|
1257
|
data: [],
|
1258
|
topheader: true,
|
1259
|
add: function (r) {
|
1260
|
this.data.push(r)
|
1261
|
},
|
1262
|
show: function () {
|
1263
|
// window.open('/workflow/generatepdf/?title=' + (this.title)
|
1264
|
// + '&topheader=' + this.topheader + '&data='
|
1265
|
// + Base64.encode(Ext.encode(this.data)));
|
1266
|
|
1267
|
// build params object
|
1268
|
var aaa = (typeof(data))
|
1269
|
|
1270
|
var obj = [];
|
1271
|
obj.push({
|
1272
|
title: this.title
|
1273
|
});
|
1274
|
obj.push({
|
1275
|
topheader: this.topheader
|
1276
|
});
|
1277
|
obj.push({
|
1278
|
data: this.data
|
1279
|
});
|
1280
|
|
1281
|
window.open('/workflow/generatepdf/?obj='
|
1282
|
+ Base64.encode(Ext.encode(obj)));
|
1283
|
}
|
1284
|
}
|
1285
|
MinovaUtil.UTILITY = {
|
1286
|
RENDERER: {
|
1287
|
formatDate: function (value, metaData, record, rowIndex, colIndex, store, view) {
|
1288
|
try {
|
1289
|
return Ext.Date.format(Ext.Date.parse(value, 'Ymd'),
|
1290
|
MinovaUtil.SESSIONS.APPSETINGS.dateFormat);
|
1291
|
} catch (e) {
|
1292
|
return value;
|
1293
|
}
|
1294
|
}
|
1295
|
},
|
1296
|
|
1297
|
/*
|
1298
|
* IntegraXor Web SCADA - JavaScript Number Formatter
|
1299
|
* http://www.integraxor.com/ author: KPL, KHL (c)2011 ecava Dual
|
1300
|
* licensed under the MIT or GPL Version 2 licenses.
|
1301
|
*/
|
1302
|
// window.format = function(b, a) {
|
1303
|
format: function (b, a) {
|
1304
|
if (!b || isNaN(+a))
|
1305
|
return a;
|
1306
|
var a = b.charAt(0) == "-" ? -a : +a, j = a < 0 ? a = -a : 0, e = b
|
1307
|
.match(/[^\d\-\+#]/g), h = e && e[e.length - 1] || ".", e = e
|
1308
|
&& e[1] && e[0] || ",", b = b.split(h), a = a.toFixed(b[1]
|
1309
|
&& b[1].length), a = +a + "", d = b[1]
|
1310
|
&& b[1].lastIndexOf("0"), c = a.split(".");
|
1311
|
if (!c[1] || c[1] && c[1].length <= d)
|
1312
|
a = (+a).toFixed(d + 1);
|
1313
|
d = b[0].split(e);
|
1314
|
b[0] = d.join("");
|
1315
|
var f = b[0] && b[0].indexOf("0");
|
1316
|
if (f > -1)
|
1317
|
for (; c[0].length < b[0].length - f;)
|
1318
|
c[0] = "0" + c[0];
|
1319
|
else
|
1320
|
+c[0] == 0 && (c[0] = "");
|
1321
|
a = a.split(".");
|
1322
|
a[0] = c[0];
|
1323
|
if (c = d[1] && d[d.length - 1].length) {
|
1324
|
for (var d = a[0], f = "", k = d.length % c, g = 0, i = d.length; g < i; g++)
|
1325
|
f += d.charAt(g), !((g - k + 1) % c) && g < i - c
|
1326
|
&& (f += e);
|
1327
|
a[0] = f
|
1328
|
}
|
1329
|
a[1] = b[1] && a[1] ? h + a[1] : "";
|
1330
|
return (j ? "-" : "") + a[0] + a[1]
|
1331
|
}
|
1332
|
}
|
1333
|
|
1334
|
//}
|