Project

General

Profile

Bug #2098 » IMFI LOCK USER.txt

Saswanto Tampan, 04/03/2023 01:00 PM

 
1
var limitRowPerpage = 100;
2
var isCurrentAdmin1 = '';
3

    
4
var MyArrayStore = {
5
	xtype : 'arraystore',
6
	data : [['', 'All'], ['1', 'Yes'], ['0', 'No']],
7
	storeId : 'MyArrayStore',
8
	fields : [{
9
				name : 'code'
10
			}, {
11
				name : 'desc'
12
			}]
13
};
14

    
15
var MyArrayStore1 = {
16
	xtype : 'arraystore',
17
	data : [['', 'All'], ['1', 'Active'], ['0', 'NonActive']],
18
	storeId : 'MyArrayStore',
19
	fields : [{
20
				name : 'code'
21
			}, {
22
				name : 'desc'
23
			}]
24
};
25
var MyArrayStore2 = {
26
	xtype : 'arraystore',
27
	data : [['', 'All'], ['1', 'Locked'], ['0', 'Unlock']],
28
	storeId : 'MyArrayStore',
29
	fields : [{
30
				name : 'code'
31
			}, {
32
				name : 'desc'
33
			}]
34
};
35

    
36
var MyArrayStoreTitle = {
37
	xtype : 'arraystore',
38
	data : [['1', 'Mr'], ['2', 'Mrs']],
39
	storeId : 'MyArrayStore',
40
	fields : [{
41
				name : 'code'
42
			}, {
43
				name : 'desc'
44
			}]
45
};
46

    
47
var MyArrayStoreLanguage = {
48
	xtype : 'arraystore',
49
	data : [['1', 'ID'], ['2', 'EN']],
50
	storeId : 'MyArrayStore',
51
	fields : [{
52
				name : 'code'
53
			}, {
54
				name : 'desc'
55
			}]
56
};
57

    
58
var editor = new Ext.ux.grid.RowEditor({
59
			saveText : 'OK'
60
		});
61

    
62
var store_GetAllRoleID = new Ext.data.JsonStore({
63
			autoLoad : true,
64
			fields : ['code', 'desc', 'code_desc'],
65
			sortInfo : {
66
				field : "desc",
67
				direction : "ASC"
68
			},
69
			method : 'GET',
70
			url : "HR_Core/GetAllRoleID/"
71
		});
72

    
73
var flagCommand = '';
74

    
75
var dataColumnGridSearch = Ext.data.Record.create([{
76
			name : 'user_id'
77
		}, {
78
			name : 'emp_id'
79
		}, {
80
			name : 'user_name'
81
		}, {
82
			name : 'status'
83
		}, {
84
			name : 'position'
85
		}, {
86
			name : 'organization'
87
		}, {
88
			name : 'ldap_id'
89
		}, {
90
			name : 'approval'
91
		}, {
92
			name : 'locked'
93
		},
94
		{name:'is_deleted'
95
		}]);
96

    
97
var dataColumnGridApprovalUserData = Ext.data.Record.create([{
98
			name : 'field_name'
99
		}, {
100
			name : 'valueFrom'
101
		}, {
102
			name : 'valueTo'
103
		}]);
104

    
105
var SearchStore = new Ext.data.Store({
106
			proxy : new Ext.data.HttpProxy({
107
						waitMsg : 'please wait...',
108
						url : '/UserAdministration/SearchEmployee/',
109
						method : 'POST'
110
					}),
111
			reader : new Ext.data.JsonReader({
112
						root : 'data',
113
						successProperty : 'success',
114
						messageProperty : 'message',
115
						/*
116
						 * idProperty : 'user_id', ini jika di aktifkan, maka
117
						 * akan di filter by User ID,, dan UNIQ
118
						 */
119
						totalProperty : 'TotalRecords'
120
					}, dataColumnGridSearch),
121
			listeners : {
122

    
123
				exception : function() {
124
				}
125
			}
126
		});
127

    
128
var ApprovalUserdataStore = new Ext.data.Store({
129
			proxy : new Ext.data.HttpProxy({
130
						waitMsg : 'please wait...',
131
						url : '/UserAdministration/ApprovalDataUser/',
132
						method : 'POST'
133
					}),
134
			reader : new Ext.data.JsonReader({
135
						root : 'data',
136
						successProperty : 'success',
137
						messageProperty : 'message',
138
						/*
139
						 * idProperty : 'user_id', ini jika di aktifkan, maka
140
						 * akan di filter by User ID,, dan UNIQ
141
						 */
142
						totalProperty : 'TotalRecords'
143
					}, dataColumnGridApprovalUserData),
144
			listeners : {
145

    
146
				exception : function() {
147
				}
148
			}
149
		});
150

    
151
var getUserByIdStore = {
152
	xtype : 'jsonstore',
153
	url : '/UserAdministration/GetUser',
154
	storeId : 'SearchStore',
155
	root : 'data',
156
	method : 'POST',
157
	fields : [
158

    
159
	{
160
				name : 'user_id'
161
			}, {
162
				name : 'title'
163
			}, {
164
				name : 'first_name'
165
			}, {
166
				name : 'middle_name'
167
			}, {
168
				name : 'last_name'
169
			}, {
170
				name : 'format_name'
171
			}, {
172
				name : 'language'
173
			}, {
174
				name : 'ldap_id'
175
			}, {
176
				name : 'phone_country'
177
			}, {
178
				name : 'phone_region'
179
			}, {
180
				name : 'phone_num'
181
			}, {
182
				name : 'phone_ext'
183
			},
184

    
185
			{
186
				name : 'fax_country'
187
			}, {
188
				name : 'fax_region'
189
			}, {
190
				name : 'fax_num'
191
			}, {
192
				name : 'fax_ext'
193
			},
194

    
195
			{
196
				name : 'email'
197
			}, {
198
				name : 'hp_country'
199
			}, {
200
				name : 'hp_num'
201
			},
202

    
203
			{
204
				name : 'valid_from'
205
			}, {
206
				name : 'valid_through'
207
			},
208

    
209
			{
210
				name : 'status'
211
			}, {
212
				name : 'approval'
213
			}, {
214
				name : 'locked'
215
			}
216

    
217
	]
218
};
219

    
220
var columnRoles = Ext.data.Record.create([{
221
			name : 'UniQKey'
222
		}, {
223
			name : 'flag'
224
		}, {
225
			name : 'role_id'
226
		}, {
227
			name : 'role_name'
228
		}, {
229
			name : 'approval'
230
		}, {
231
			name : 'is_deleted'
232
		}, {
233
			name : 'role_active'
234
		}, {
235
			name : 'role_valid_from'
236
		}, {
237
			name : 'role_valid_to'
238
		}, {
239
			name : 'createby'
240
		},
241
		{name:'is_deleted'}
242
		
243
		]);
244
var secondGridStoreDeleted = new Ext.data.JsonStore({
245
			fields : columnRoles,
246
			root : 'data'
247
		});
248

    
249
var writerRoles = new Ext.data.JsonWriter({
250
			encode : true,
251
			writeAllFields : false
252
		});
253

    
254
var MyRoles = new Ext.data.Store({
255
			proxy : new Ext.data.HttpProxy({
256
						waitMsg : 'please wait...',
257
						url : '/UserAdministration/UserRoles/',
258
						method : 'POST'
259
					}),
260
			writer : writerRoles,
261
			autoSave : false,
262
			reader : new Ext.data.JsonReader({
263
						root : 'data',
264
						successProperty : 'success',
265
						messageProperty : 'message',
266
						/*
267
						 * idProperty : 'user_id', ini jika di aktifkan, maka
268
						 * akan di filter by User ID,, dan UNIQ
269
						 */
270
						totalProperty : 'TotalRecords'
271
					}, columnRoles),
272
			listeners : {
273

    
274
				exception : function() {
275
				}
276
			}
277
		});
278

    
279
var log_sysuser = {
280
	xtype : 'jsonstore',
281
	storeId : 'log_sysuser',
282
	fields : [{
283
				name : 'field'
284
			}]
285
};
286

    
287
var log_roles = {
288
	xtype : 'jsonstore',
289
	storeId : 'log_roles',
290
	fields : [{
291
				name : 'field'
292
			}]
293
};
294

    
295
var titleStore = {
296
	xtype : 'jsonstore',
297
	storeId : 'titleStore',
298
	fields : [{
299
				name : 'code'
300
			}, {
301
				name : 'desc'
302
			}]
303
};
304

    
305
var language_store = {
306
	xtype : 'jsonstore',
307
	storeId : 'language_store',
308
	fields : [{
309
				name : 'code'
310
			}, {
311
				name : 'desc'
312
			}]
313
};
314
var mainLayOut = {
315
	xtype : 'container',
316
	height : 450,
317
	layout : {
318
		type : 'border'
319
	},
320
	listeners : {
321
		afterRender : function(container, position) {
322

    
323
			CheckRoleLogin();
324
		}
325
	},
326
	items : [{
327
		xtype : 'panel',
328
		layout : {
329
			type : 'fit'
330
		},
331
		title : '',
332
		region : 'center',
333
		items : [{
334
			xtype : 'container',
335
			layout : {
336
				type : 'border'
337
			},
338
			items : [{
339
				xtype : 'panel',
340
				height : 120,
341
				layout : {
342
					type : 'column'
343
				},
344
				title : 'Header',
345
				region : 'north',
346
				items : [{
347
							xtype : 'form',
348
							border : false,
349
							title : '',
350
							id : 'form_header_left',
351
							columnWidth : 0.5,
352
							items : [{
353
										xtype : 'textfield',
354
										fieldLabel : 'User ID',
355
										anchor : '100%',
356
										boxMaxWidth : 180,
357
										id : 'header_user_id',
358
										name : 'header_user_id',
359
										cls : 'minova-mandatory'
360
									}, {
361
										xtype : 'checkbox',
362
										fieldLabel : 'Status Active',
363
										boxLabel : '',
364
										anchor : '100%',
365
										id : 'header_status_active',
366
										name : 'header_status_active'
367
									}, {
368
										xtype : 'textfield',
369
										fieldLabel : 'LDAP ID',
370
										anchor : '100%',
371
										boxMaxWidth : 180,
372
										id : 'header_ldap_id',
373
										name : 'header_ldap_id'
374
									}]
375
						}, {
376
							xtype : 'form',
377
							id : 'form_header_right',
378
							border : false,
379
							title : '',
380
							columnWidth : 0.5,
381
							items : [
382
									LookUpField('header_emp_id', 200, 500, 500,
383
											'Employee', 'md01', true), {
384
										xtype : 'checkbox',
385
										fieldLabel : 'Need for Approval',
386
										checked:true,
387
										boxLabel : '',
388
										anchor : '100%',
389
										id : 'header_approval',
390
										name : 'header_approval',
391
										readOnly : true
392
									}, {
393
										xtype : 'checkbox',
394
										fieldLabel : 'Status Lock',
395
										boxLabel : '',
396
										anchor : '100%',
397
										id : 'header_status_lock',
398
										name : 'header_status_lock'
399
									}]
400
						}]
401
			}, {
402
				xtype : 'panel',
403
				width : 100,
404
				layout : {
405
					type : 'fit'
406
				},
407
				title : '',
408
				region : 'center',
409
				items : [{
410
					xtype : 'container',
411
					layout : {
412
						type : 'border'
413
					},
414
					items : [{
415
						xtype : 'tabpanel',
416
						activeTab : 0,
417
						region : 'center',
418
						width : 100,
419
						listeners : {
420
							'tabchange' : function(tabPanel, tab) {
421

    
422
								if (tab.id == 'tabApproval') {
423

    
424
									if (Ext.getCmp('header_user_id').getValue().length > 0) {
425

    
426
										Ext.getCmp('gridApprovalUserLog').store
427
												.setBaseParam(
428
														'userid',
429
														Ext
430
																.getCmp('header_user_id')
431
																.getValue());
432

    
433
										Ext.getCmp('gridApprovalUserLog').store
434
												.load();
435

    
436
									}
437
								}
438

    
439
								if (tab.id == 'tabRoles') {
440
									if (Ext.getCmp('header_user_id').getValue().length > 0) {
441
										LoadRoles();
442
									}
443
								}
444

    
445
							}
446
						},
447
						items : [{
448
							xtype : 'panel',
449
							title : 'Personal Data',
450
							layout : 'column',
451
							id : 'idTabPanelPersonal',
452
							items : [{
453
										xtype : 'form',
454
										title : '',
455
										id : 'personalDataLeft',
456
										width : 59,
457
										columnWidth : 0.5,
458
										height : 200,
459
										border : false,
460
										items : [{
461
													xtype : 'combo',
462
													fieldLabel : 'Title',
463
													
464
													store : MyArrayStoreTitle,
465
													width : 100,
466
													name : 'title',
467
													id : 'title',
468
													boxMaxWidth : 100,
469
													displayField : 'desc',
470
													mode : 'local',
471
													triggerAction : 'all',
472
													valueField : 'code'
473

    
474
												}, {
475
													xtype : 'textfield',
476
													fieldLabel : 'First Name',
477
													boxMaxWidth : 150,
478
													cls : 'minova-mandatory',
479
													width : 150,
480
													name : 'first_name',
481
													id : 'first_name'
482
												}, {
483
													xtype : 'textfield',
484
													fieldLabel : 'Middle Name',
485
													
486
													boxMaxWidth : 150,
487
													width : 150,
488
													name : 'middle_name',
489
													id : 'middle_name'
490
												}, {
491
													xtype : 'textfield',
492
													fieldLabel : 'Last Name',
493
													
494
													boxMaxWidth : 150,
495
													width : 150,
496
													name : 'last_name',
497
													id : 'last_name'
498
												}, {
499
													xtype : 'textfield',
500
													fieldLabel : 'Format Name',
501
													
502
													boxMaxWidth : 150,
503
													width : 150,
504
													name : 'format_name',
505
													id : 'format_name'
506
												}, {
507
													xtype : 'combo',
508
													fieldLabel : 'Language',
509
													
510
													boxMaxWidth : 100,
511
													store : MyArrayStoreLanguage,
512
													width : 100,
513
													name : 'language',
514
													id : 'language',
515
													boxMaxWidth : 100,
516
													displayField : 'desc',
517
													mode : 'local',
518
													triggerAction : 'all',
519
													valueField : 'code'
520
												}]
521
									}, {
522
										xtype : 'form',
523
										title : '',
524
										columnWidth : 0.5,
525
										height : 200,
526
										border : false,
527
										id : 'personalDataRight',
528
										items : [{
529
													xtype : 'container',
530
													height : 23,
531
													width : 297,
532
													layout : {
533
														type : 'column'
534
													},
535
													items : [{
536
																xtype : 'displayfield',
537
																width : 105,
538
																value : 'Phone'
539
															}, {
540
																xtype : 'numberfield',
541
																id : 'phone-country',
542
																emptyText : 'country',
543
																name : 'phone-country',
544
																width : 52
545
															}, {
546
																xtype : 'numberfield',
547
																width : 61,
548
																id : 'phone-region',
549
																name : 'phone-region',
550
																emptyText : 'region'
551
															}, {
552
																xtype : 'numberfield',
553
																width : 69,
554
																id : 'phone-number',
555
																name : 'phone-number',
556
																emptyText : 'number'
557
															}]
558
												}, {
559
													xtype : 'numberfield',
560
													fieldLabel : 'Phone Ext',
561
													
562
													width : 100,
563
													boxMaxWidth : 100,
564
													name : 'phone_ext',
565
													id : 'phone_ext'
566
												}, {
567
													xtype : 'container',
568
													height : 23,
569
													width : 297,
570
													layout : {
571
														type : 'column'
572
													},
573
													items : [{
574
																xtype : 'displayfield',
575
																width : 105,
576
																value : 'Fax'
577
															}, {
578
																xtype : 'numberfield',
579
																id : 'fax-country',
580
																emptyText : 'country',
581
																name : 'fax-country',
582
																width : 52
583
															}, {
584
																xtype : 'numberfield',
585
																width : 61,
586
																id : 'fax-region',
587
																name : 'fax-region',
588
																emptyText : 'region'
589
															}, {
590
																xtype : 'numberfield',
591
																width : 69,
592
																id : 'fax-number',
593
																name : 'fax-number',
594
																emptyText : 'number'
595
															}]
596
												}, {
597
													xtype : 'numberfield',
598
													fieldLabel : 'Fax Ext',
599
													
600
													boxMaxWidth : 100,
601
													width : 100,
602
													name : 'fax_ext',
603
													id : 'fax_ext'
604
												}, {
605
													xtype : 'textfield',
606
													fieldLabel : 'Email',
607
													
608
													boxMaxWidth : 150,
609
													width : 150,
610
													name : 'email',
611
													id : 'email',
612
													vtype:'email'
613
												}, {
614
													xtype : 'container',
615
													height : 23,
616
													width : 297,
617
													layout : {
618
														type : 'column'
619
													},
620
													items : [{
621
																xtype : 'displayfield',
622
																width : 105,
623
																value : 'Mobile'
624
															}, {
625
																xtype : 'numberfield',
626
																id : 'mobile-country',
627
																emptyText : 'country',
628
																name : 'mobile-country',
629
																width : 52
630
															}, {
631
																xtype : 'numberfield',
632
																width : 100,
633
																id : 'mobile-number',
634
																name : 'mobile-number',
635
																emptyText : 'number'
636
															}]
637
												}]
638
									}]
639
						}, {
640
							xtype : 'panel',
641
							title : 'Logon',
642
							id : 'idTabPanelLogon',
643
							items : [{
644
										xtype : 'form',
645
										title : '',
646
										id : 'formUserLogonForm',
647
										height : 200,
648
										border : false,
649
										layout : 'form',
650
										items : [{
651
													xtype : 'textfield',
652
													fieldLabel : 'Password',
653
													
654
													name : 'password',
655
													id : 'password',
656
													inputType:'password',
657
													cls : 'minova-mandatory'
658
												}, {
659
													xtype : 'textfield',
660
													fieldLabel : 'Re-Type Password',
661
													
662
													name : 're_password',
663
													id : 're_password',
664
													inputType:'password',
665
													cls : 'minova-mandatory'
666
												}, {
667
													xtype : 'datefield',
668
													fieldLabel : 'Valid From',
669
													name : 'valid_from',
670
													id : 'valid_from',
671
													format : 'd/m/Y',
672
													cls : 'minova-mandatory'
673
													//format : 'Ymd'
674
												}, {
675
													xtype : 'datefield',
676
													fieldLabel : 'Valid Through',
677
													name : 'valid_through',
678
													id : 'valid_through',
679
													//format : 'Ymd'
680
													format : 'd/m/Y',
681
													cls : 'minova-mandatory'
682
												}]
683
									}]
684
						}, {
685
							xtype : 'panel',
686
							title : 'Roles',
687
							layout : 'border',
688
							id : 'tabRoles',
689
							items : [{
690
								xtype : 'grid',
691
								id : 'gridMyRoles',
692
								plugins : editor,
693
								title : '',
694
								store : MyRoles,
695
								region : 'center',
696
								columns : [
697

    
698
								{
699
											dataIndex : 'role_id',
700
											header : 'Role Name',
701
											sortable : true,
702
											width : 150,
703
											align : 'right',
704
											editor : {
705
												xtype : 'combo',
706
												mode : 'local',
707
												typeAhead : true,
708
												store : store_GetAllRoleID,
709
												displayField : 'desc',
710
												valueField : 'code',
711
												triggerAction : 'all',
712
												allowBlank : false
713
											}
714
										}, {
715
											// xtype : 'textfield',
716
											dataIndex : 'role_active',
717
											header : 'Active',
718
											sortable : true,
719
											width : 100,
720
											editor : {
721

    
722
												xtype : 'combo',
723
												allowBlank : false,
724
												typeAhead : true,
725
												triggerAction : 'all',
726
												lazyRender : true,
727
												mode : 'local',
728
												displayField : 'desc',
729
												valueField : 'code',
730
												store : new Ext.data.ArrayStore(
731
														{
732
															id : 0,
733
															fields : ['code',
734
																	'desc'],
735
															data : [
736
																	[0,
737
																			'No Active'],
738
																	[1,
739
																			'Active']]
740
														})
741

    
742
											}
743
										}, {
744
											// xtype : 'booleancolumn',
745
											dataIndex : 'approval',
746
											header : 'Need for Approval',
747
											sortable : true,
748
											width : 100,
749
											editor : {
750
												xtype : 'combo',
751
												typeAhead : true,
752
												triggerAction : 'all',
753
												allowBlank : false,
754
												lazyRender : true,
755
												mode : 'local',
756
												displayField : 'desc',
757
												valueField : 'code',
758
												readOnly:true,
759
												value:'1',
760
												store : new Ext.data.ArrayStore(
761
														{
762
															id : 0,
763
															fields : ['code',
764
																	'desc'],
765
															data : [[0, 'No'],
766
																	[1, 'Yes']]
767
														})
768

    
769
											}
770
										},
771
										{
772
											//xtype : 'datecolumn',
773
											dataIndex : 'is_deleted',
774
											header : 'Is Deleted',
775
											sortable : true,
776
											width : 100,
777
											editor : {
778
												xtype : 'textfield',
779
												allowBlank : true,
780
												readOnly:true
781
											}
782
										},
783
											{
784
											// xtype : 'datecolumn',
785
											format : 'd/m/Y',
786
											dataIndex : 'role_valid_from',
787
											header : 'Valid From',
788
											sortable : true,
789
											width : 100,
790
											editor : {
791
												xtype : 'datefield',
792
												allowBlank : false,
793
												format : 'd/m/Y'
794
											}
795
										}, {
796
											// xtype : 'datecolumn',
797
											format : 'd/m/Y',
798
											dataIndex : 'role_valid_to',
799
											header : 'Valid To',
800
											sortable : true,
801
											width : 100,
802
											editor : {
803
												xtype : 'datefield',
804
												allowBlank : false,
805
												format : 'd/m/Y'
806
											}
807
										},
808
										{
809
											//xtype : 'datecolumn',
810
											dataIndex : 'createby',
811
											header : 'Create By',
812
											sortable : true,
813
											width : 100,
814
											editor : {
815
												xtype : 'textfield',
816
												allowBlank : true,
817
												readOnly:true
818
											}
819
										}],
820
								tbar : {
821
									xtype : 'toolbar',
822
									items : [{
823
												xtype : 'button',
824
												text : 'Add',
825
												iconCls : 'icon-add',
826
												id : 'btnuserAdm-Add-Role',
827
												width : 62,
828
												handler : function() {
829
													AddNewRole();
830
												}
831
											}, {
832
												xtype : 'button',
833
												text : 'Remove',
834
												id : 'btnuserAdm-Remove-Role',
835
												iconCls : 'icon-delete',
836
												handler : function() {
837

    
838
													editor.stopEditing();
839
													var grid = Ext
840
															.getCmp('gridMyRoles');
841
													var s = grid
842
															.getSelectionModel()
843
															.getSelections();
844
													for (var i = 0, r; r = s[i]; i++) {
845

    
846
														secondGridStoreDeleted
847
																.add(r);
848
														grid.store.remove(r);
849
													}
850

    
851
												}
852
											}]
853
								}
854
							}]
855
						}, {
856
							xtype : 'panel',
857
							title : 'Approval Data',
858
							layout : 'border',
859
							id : 'tabApproval',
860
							items : [{
861
								xtype : 'tabpanel',
862
								activeTab : 0,
863
								region : 'center',
864
								id : 'mainTabPanelUserAdm',
865
								listeners : {
866
									'tabchange' : function(tabPanel, tab) {
867

    
868
									}
869
								},
870

    
871
								items : [{
872
									xtype : 'panel',
873
									title : 'Log Data Users',
874
									layout : 'border',
875
									id : 'tabLogDataUser',
876
									items : [{
877
												xtype : 'grid',
878
												title : '',
879
												id : 'gridApprovalUserLog',
880
												store : ApprovalUserdataStore,
881
												region : 'center',
882
												columns : [{
883
															xtype : 'gridcolumn',
884
															dataIndex : 'field_name',
885
															header : 'Field Name',
886
															sortable : true,
887
															width : 100
888
														}, {
889
															xtype : 'gridcolumn',
890
															dataIndex : 'valueFrom',
891
															header : 'Value From',
892
															sortable : true,
893
															width : 100
894
														}, {
895
															xtype : 'gridcolumn',
896
															dataIndex : 'valueTo',
897
															header : 'Value To',
898
															sortable : true,
899
															width : 100
900
														}]
901
											}]
902
								}/*
903
									 * , { xtype : 'panel', title : 'Log User
904
									 * Roles', layout : 'border', id :
905
									 * 'tabLogUserroles', items : [{ xtype :
906
									 * 'grid', title : 'My Grid', store :
907
									 * log_roles, region : 'center', columns : [{
908
									 * xtype : 'gridcolumn', dataIndex :
909
									 * 'string', header : 'Column', sortable :
910
									 * true, width : 100 }, { xtype :
911
									 * 'numbercolumn', dataIndex : 'number',
912
									 * header : 'Column', sortable : true, width :
913
									 * 100, align : 'right' }, { xtype :
914
									 * 'datecolumn', dataIndex : 'date', header :
915
									 * 'Column', sortable : true, width : 100 }, {
916
									 * xtype : 'booleancolumn', dataIndex :
917
									 * 'bool', header : 'Column', sortable :
918
									 * true, width : 100 }] }] }
919
									 */]
920
							}]
921
						}]
922
					}]
923
				}],
924
				bbar : {
925
					xtype : 'toolbar',
926
					items : [{
927
								xtype : 'button',
928
								text : 'Save',
929
								id : 'btnuserAdm-Save',
930
								iconCls : 'icon-disk',
931
								handler : function(btn) {
932
									
933
									//var _result = validate_field();
934
									
935
									//if(_result==''){
936
										SaveAll();
937
										Ext.getCmp('btnuserAdm-Delete').hide();
938
									//}
939
									
940
								}
941
							}, {
942
								xtype : 'button',
943
								text : 'Approve',
944
								id : 'btnuserAdm-Approve',
945
								iconCls : 'icon-accept',
946
								handler : function(btn) {
947
									flagCommand = 'APPROVE';
948
									SaveAll();
949
								}
950

    
951
							}, {
952
								xtype : 'button',
953
								text : 'Reject',
954
								iconCls : 'icon-cross',
955
								id : 'btnuserAdm-Reject',
956
								handler : function(btn) {
957
									flagCommand = 'REJECT';
958
									SaveAll();
959
								}
960

    
961
							}, {
962
								xtype : 'button',
963
								text : 'Cancel',
964
								id : 'btnuserAdm-Cancel',
965
								iconCls : 'icon-arrow_undo',
966
								handler : function(btn) {
967

    
968
									flagCommand = 'CANCEL';
969
									ResetField();
970
									Ext.getCmp('btnuserAdm-Delete').hide();
971
								}
972
							},{
973
								xtype : 'button',
974
								text : 'Release Session',
975
								id : 'btnuserAdm-release',
976
								iconCls : 'icon-reset',
977
								handler : function(btn) {
978
									
979
									ReleaseSession();
980
								}
981

    
982
							}]
983
				}
984
			}]
985
		}]
986
	}, {
987
		xtype : 'panel',
988
		width : 212,
989
		layout : {
990
			type : 'fit'
991
		},
992
		title : 'Search Users',
993
		collapsible : true,
994
		split : true,
995
		region : 'west',
996
		items : [{
997
			xtype : 'container',
998
			layout : {
999
				type : 'border'
1000
			},
1001
			items : [{
1002
						xtype : 'form',
1003
						title : '',
1004
						height : 135,
1005
						region : 'north',
1006
						items : [{
1007
									xtype : 'textfield',
1008
									fieldLabel : 'User ID / Name',
1009
									anchor : '100%',
1010
									id : 'search_userid'
1011
								}, {
1012
									xtype : 'combo',
1013
									displayField : 'desc',
1014
									mode : 'local',
1015
									store : MyArrayStore,
1016
									triggerAction : 'all',
1017
									valueField : 'code',
1018
									anchor : '100%',
1019
									fieldLabel : 'Need for Approval',
1020
									
1021
									id : 'search_approval'
1022
								}, {
1023
									xtype : 'combo',
1024
									displayField : 'desc',
1025
									mode : 'local',
1026
									store : MyArrayStore1,
1027
									triggerAction : 'all',
1028
									valueField : 'code',
1029
									anchor : '100%',
1030
									fieldLabel : 'Status',
1031
									id : 'search_status'
1032
								}, {
1033
									xtype : 'combo',
1034
									displayField : 'desc',
1035
									mode : 'local',
1036
									store : MyArrayStore2,
1037
									triggerAction : 'all',
1038
									valueField : 'code',
1039
									anchor : '100%',
1040
									fieldLabel : 'Status Lock',
1041
									id : 'search_lock'
1042
								}],
1043
						bbar : {
1044
							xtype : 'toolbar',
1045
							buttonAlign : 'center',
1046
							items : [{
1047
										xtype : 'button',
1048
										text : 'Search',
1049
										iconCls : 'icon-find',
1050
										width : 82,
1051
										handler : function(btn) {
1052
											SearchUsers();
1053
										}
1054
									}]
1055
						}
1056
					}, {
1057
						xtype : 'panel',
1058
						width : 100,
1059
						layout : {
1060
							type : 'fit'
1061
						},
1062
						title : '',
1063
						bbar : {
1064
							xtype : 'toolbar',
1065
							items : [{
1066
								xtype : 'button',
1067
								text : 'Edit',
1068
								id : 'btnuserAdm-Edit',
1069
								iconCls : 'icon-application_form_edit',
1070
								width : 55,
1071
								handler : function(btn) {
1072

    
1073
									InitialTab(); //
1074

    
1075
									if (isCurrentAdmin1 == 'maker' || isCurrentAdmin1=='all') {
1076
										Ext.getCmp('btnuserAdm-Delete').show();
1077
									}
1078

    
1079
									flagCommand = 'EDIT';
1080
									disableEnableField(flagCommand);
1081
									var selected = Ext
1082
											.getCmp('gridSearchEmployee')
1083
											.getSelectionModel().getSelected();
1084

    
1085
									var user_id = selected.get('user_id');
1086
									var emp_id = selected.get('emp_id');
1087
									var status = selected.get('status');
1088
									var locked = selected.get('locked');
1089
									var approval = selected.get('approval');
1090
									// Binding Data
1091
									BindingData(user_id, approval);
1092
								}
1093
							}, {
1094
								xtype : 'button',
1095
								text : 'Add',
1096
								iconCls : 'icon-add',
1097
								id : 'btnuserAdm-Add',
1098
								handler : function(btn) {
1099

    
1100
									flagCommand = "ADD";
1101
									ResetField();
1102
									InitialTab();
1103
									Ext.getCmp('btnuserAdm-Delete').hide();
1104
								}
1105
							}, {
1106
								xtype : 'button',
1107
								text : 'Delete',
1108
								id : 'btnuserAdm-Delete',
1109
								iconCls : 'icon-delete',
1110
								handler : function(btn) {
1111
									flagCommand = "DELETE";
1112
									SaveAll();
1113
									Ext.getCmp('btnuserAdm-Delete').hide();
1114
								}
1115
							}]
1116
						},
1117
						region : 'center',
1118
						items : [{
1119
							xtype : 'grid',
1120
							title : 'Result',
1121
							autoScroll : true,
1122
							id : 'gridSearchEmployee',
1123
							store : SearchStore,
1124
							region : 'center',
1125
							selModel : new Ext.grid.RowSelectionModel({
1126
										singleSelect : true
1127
									}),
1128
							columns : [{
1129
										xtype : 'gridcolumn',
1130
										dataIndex : 'user_id',
1131
										header : 'User ID',
1132
										sortable : true,
1133
										width : 100
1134
									}, {
1135
										xtype : 'gridcolumn',
1136
										dataIndex : 'emp_id',
1137
										header : 'Employee ID',
1138
										sortable : true,
1139
										width : 100
1140
									}, {
1141
										xtype : 'gridcolumn',
1142
										dataIndex : 'user_name',
1143
										header : 'Name',
1144
										sortable : true,
1145
										width : 100,
1146
										align : 'right'
1147
									}, {
1148
										xtype : 'gridcolumn',
1149
										dataIndex : 'approval',
1150
										header : 'Need for Approval',
1151
										sortable : true,
1152
										width : 50
1153
									}, {
1154
										xtype : 'gridcolumn',
1155
										dataIndex : 'status',
1156
										header : 'Status',
1157
										sortable : true,
1158
										width : 50
1159
									}, {
1160
										xtype : 'gridcolumn',
1161
										dataIndex : 'locked',
1162
										header : 'Locked',
1163
										sortable : true,
1164
										width : 50
1165
									}, {
1166
										xtype : 'gridcolumn',
1167
										dataIndex : 'is_deleted',
1168
										header : 'Is deleted',
1169
										sortable : true,
1170
										width : 50
1171
									}],
1172

    
1173
							bbar : {
1174
								xtype : 'toolbar',
1175
								items : [{
1176
									xtype : 'paging',
1177
									displayInfo : true,
1178
									pageSize : limitRowPerpage,
1179
									store : SearchStore,
1180
									displayInfo : true,
1181
									displayMsg : 'Displaying data {0} - {1} of {2}',
1182
									emptyMsg : "No data to display"
1183
								}]
1184
							}
1185
						}]
1186
					}]
1187
		}]
1188
	}]
1189
};
1190

    
1191
function BindingData(user_id, approval) {
1192

    
1193
	if (approval == 'Yes') {
1194
		approval = '1';
1195
	} else {
1196
		approval = '0';
1197
	}
1198
	if (flagCommand == 'EDIT') {
1199
		Ext.Ajax.request({
1200
					url : '/UserAdministration/GetUser',
1201
					params : {
1202
						userid : user_id,
1203
						approval : approval
1204
					},
1205
					method : 'POST',
1206
					success : function(result, request) {
1207

    
1208
						var data = Ext.decode(result.responseText).data;
1209

    
1210
						// Binding
1211
						Ext.getCmp('title').setValue(data.title);
1212
						Ext.getCmp('first_name').setValue(data.first_name);
1213
						Ext.getCmp('middle_name').setValue(data.middle_name);
1214
						Ext.getCmp('last_name').setValue(data.last_name);
1215
						Ext.getCmp('format_name').setValue(data.format_name);
1216

    
1217
						Ext.getCmp('language').setValue(data.language);
1218

    
1219
						var phone = data.phone_country + '-'
1220
								+ data.phone_region + '-' + data.phone_num;
1221
						Ext.getCmp('phone-country')
1222
								.setValue(data.phone_country);
1223
						Ext.getCmp('phone-region').setValue(data.phone_region);
1224
						Ext.getCmp('phone-number').setValue(data.phone_num);
1225

    
1226
						Ext.getCmp('phone_ext').setValue(data.phone_ext);
1227

    
1228
						var fax = data.fax_country + '-' + data.fax_region
1229
								+ '-' + data.fax_num;
1230

    
1231
						Ext.getCmp('fax-country').setValue(data.fax_country);
1232
						Ext.getCmp('fax-region').setValue(data.fax_region);
1233
						Ext.getCmp('fax-number').setValue(data.fax_num);
1234

    
1235
						Ext.getCmp('fax_ext').setValue(data.fax_ext);
1236

    
1237
						Ext.getCmp('email').setValue(data.email);
1238

    
1239
						var mobile_num = data.hp_country + '-' + data.hp_num;
1240

    
1241
						Ext.getCmp('mobile-country').setValue(data.hp_country);
1242
						Ext.getCmp('mobile-number').setValue(data.hp_num);
1243

    
1244
						Ext.getCmp('valid_from').setRawValue(data.valid_from);
1245
						Ext.getCmp('valid_through')
1246
								.setRawValue(data.valid_through);
1247

    
1248
						LookUpSetValue('header_emp_id', data.emp_id);
1249
						LookUpSetDisplay('header_emp_id', data.emp_id);
1250

    
1251
						Ext.getCmp('header_user_id').setValue(data.user_id);
1252

    
1253
						Ext.getCmp('header_status_active').setValue(false);
1254
						Ext.getCmp('header_status_lock').setValue(false);
1255
						Ext.getCmp('header_approval').setValue(false);
1256
						Ext.getCmp('header_ldap_id').setValue(data.ldap_id);
1257

    
1258
						if (data.status == 1) {
1259
							Ext.getCmp('header_status_active').setValue(true);
1260
						}
1261
						if (data.locked == 1) {
1262
							Ext.getCmp('header_status_lock').setValue(true);
1263
						}
1264
						if (data.approval == 1) {
1265
							Ext.getCmp('header_approval').setValue(true);
1266
						}
1267

    
1268
					}
1269
				});
1270
	}
1271

    
1272
}
1273

    
1274
function InitialTab() {
1275

    
1276
	Ext.getCmp('tabLogDataUser').show();
1277

    
1278
	// Ext.getCmp('tabLogUserroles').show();
1279

    
1280
	Ext.getCmp('tabApproval').show();
1281

    
1282
	Ext.getCmp('tabRoles').show();
1283

    
1284
	Ext.getCmp('idTabPanelLogon').show();
1285

    
1286
	Ext.getCmp('idTabPanelPersonal').show();
1287

    
1288
}
1289

    
1290
function CheckRoleLogin() {
1291
	Ext.Ajax.request({
1292
				url : '/UserAdministration/CheckRoleLogin',
1293
				params : {},
1294
				method : 'POST',
1295
				success : function(result, request) {
1296
					var data = Ext.decode(result.responseText);// .data;
1297

    
1298
					var btnAdd = Ext.getCmp('btnuserAdm-Add');
1299
					var btnEdit = Ext.getCmp('btnuserAdm-Edit');
1300
					var btnDelete = Ext.getCmp('btnuserAdm-Delete');
1301
					var btnSave = Ext.getCmp('btnuserAdm-Save');
1302
					var btnApprove = Ext.getCmp('btnuserAdm-Approve');
1303
					var btnReject = Ext.getCmp('btnuserAdm-Reject');
1304
					var btnCancel = Ext.getCmp('btnuserAdm-Cancel');
1305
					var btnAddRole = Ext.getCmp('btnuserAdm-Add-Role');
1306
					var btnRemoveRole = Ext.getCmp('btnuserAdm-Remove-Role');
1307
					isCurrentAdmin1 = '';
1308

    
1309
					btnAdd.show();
1310
					btnEdit.show();
1311
					btnDelete.hide();
1312
					btnSave.show();
1313
					btnApprove.show();
1314
					btnReject.show();
1315
					btnCancel.show();
1316
					btnAddRole.show();
1317
					btnRemoveRole.show();
1318

    
1319
					if (data.isAdminAll) {
1320
						// isCurrentAdmin1=true;
1321
						isCurrentAdmin1='all';
1322
					}
1323
					if (data.isAdmin1) {
1324
						btnAdd.show();
1325
						btnEdit.show();
1326
						// btnDelete.show();
1327
						btnSave.show();
1328
						btnApprove.hide();
1329
						btnReject.hide();
1330
						btnCancel.show();
1331
						btnAddRole.show();
1332
						btnRemoveRole.show();
1333
						isCurrentAdmin1 = 'maker';
1334
					}
1335
					if (data.isAdmin2) {
1336
						btnAdd.hide();
1337
						btnEdit.show();
1338
						btnDelete.hide();
1339
						btnSave.hide();
1340
						btnApprove.show();
1341
						btnReject.show();
1342
						btnCancel.show();
1343
						btnAddRole.hide();
1344
						btnRemoveRole.hide();
1345
					}
1346
				}
1347
			});
1348
}
1349
function disableEnableField(command) {
1350

    
1351
	Ext.getCmp('header_user_id').setReadOnly(false);
1352
	if (command == 'EDIT') {
1353
		Ext.getCmp('header_user_id').setReadOnly(true);
1354
	}
1355
}
1356

    
1357
function LoadRoles() {
1358
	if(flagCommand=="EDIT"){
1359
		Ext.getCmp('gridMyRoles').store.setBaseParam('userid', Ext
1360
						.getCmp('header_user_id').getValue());
1361
		Ext.getCmp('gridMyRoles').store.load();
1362
	}
1363
}
1364

    
1365
function ResetField() {
1366
	// flagCommand = '';
1367
	Ext.getCmp('form_header_left').getForm().reset();
1368
	Ext.getCmp('form_header_right').getForm().reset();
1369
	Ext.getCmp('personalDataLeft').getForm().reset();
1370
	Ext.getCmp('personalDataRight').getForm().reset();
1371
	Ext.getCmp('formUserLogonForm').getForm().reset();
1372
	disableEnableField('');
1373
	Ext.getCmp('gridMyRoles').store.removeAll();
1374
}
1375

    
1376
function AddNewRole() {
1377
	var grid = Ext.getCmp('gridMyRoles');
1378
	var newrec = new columnRoles({
1379
				flag : 'NEW',
1380
				role_id : '',
1381
				role_name : '',
1382
				approval : '1',
1383
				role_active : '1',
1384
				role_valid_from : (new Date()).format('d/m/Y'),
1385
				role_valid_to : '31/12/9999'
1386

    
1387
			});
1388

    
1389
	editor.stopEditing();
1390
	grid.store.insert(0, newrec);
1391
	grid.getView().refresh();
1392
	grid.getSelectionModel().selectRow(0);
1393
	editor.startEditing(0);
1394
}
1395

    
1396

    
1397
var validate_field=function(){
1398

    
1399
	
1400
}
1401

    
1402
function AfterSaveAnError(){
1403
	
1404
}
1405

    
1406
function AfterSaveAnSuccess(){
1407
	
1408
}
1409

    
1410
function SaveAll() {
1411
	
1412
	//-- validation before send to server
1413
	
1414
	/*if(validate_field()==false){
1415
		return;
1416
	}*/
1417
	
1418
	var gridMyRolesTmp = Ext.getCmp('gridMyRoles');
1419
	
1420
	var allRecords = gridMyRolesTmp.store.getModifiedRecords();
1421

    
1422
	var data_arrayNonDeleted = [];
1423
	for (i = 0; i < allRecords.length; i++) {
1424
		var dataNew = allRecords[i].data;
1425
		var dataChanges = allRecords[i].getChanges();
1426
		data_arrayNonDeleted.push(dataNew);
1427
	}
1428

    
1429
	var data_arrayDeleted = [];
1430
	secondGridStoreDeleted.each(function(store) {
1431
				data_arrayDeleted.push(store.data);
1432
			});
1433

    
1434
			
1435
			
1436
	var header_left = Ext.getCmp('form_header_left').getForm().getValues();
1437

    
1438
	var header_right = Ext.getCmp('form_header_right').getForm().getValues();
1439

    
1440

    
1441
	var personalDataLeft = Ext.getCmp('personalDataLeft').getForm().getValues();
1442
	
1443
	
1444

    
1445
	var personalDataRight = Ext.getCmp('personalDataRight').getForm()
1446
			.getValues();
1447

    
1448
			
1449
			
1450
	var userLogon = Ext.getCmp('formUserLogonForm').getForm().getValues();
1451

    
1452
	var approvalChecklist = Ext.getCmp('header_approval').getValue();
1453
	//alert('test1');
1454
	
1455
	//var personal_data =
1456

    
1457
	Ext.Ajax.request({
1458
				url : '/UserAdministration/SaveChanges',
1459
				params : {
1460
					flagCommand : flagCommand,
1461
					header_left : Ext.encode(header_left),
1462
					header_right : Ext.encode(header_right),
1463
					personalDataLeft : Ext.encode(personalDataLeft),
1464
					personalDataRight : Ext.encode(personalDataRight),
1465
					userLogon : Ext.encode(userLogon),
1466
					dataDeleted : Ext.encode(data_arrayDeleted),
1467
					dataNonDeleted : Ext.encode(data_arrayNonDeleted),
1468
					approval:approvalChecklist
1469
				},
1470
				method : 'POST',
1471
				success : function(result, request) {
1472
					var data = Ext.decode(result.responseText);
1473
					
1474
					if(data.success){
1475
						
1476
						if(header_right.header_status_lock != undefined || header_right.header_status_lock == 'on'){
1477
							
1478
							Ext.Ajax.request({
1479
								url: '/Workflow/LoadDataQuery',
1480
								method: 'POST',
1481
								params: {
1482
									paramid: 'base_sys_user',
1483
									user_id: header_left.header_user_id
1484
								},
1485
								success: function(response, opts) {
1486
									var obj = Ext.decode(response.responseText).data;
1487
								},
1488
								failure: function(response, opts) {
1489
								}
1490
							});							
1491
													
1492
						}						
1493
												
1494
						
1495
						InitialTab();
1496
						alert(data.message);
1497
						SearchUsers();
1498
						LoadRoles();
1499
						ResetField();
1500
						AfterSaveAnSuccess();
1501
						
1502
					}else{
1503
						alert(data.message); // Error
1504
						AfterSaveAnError();
1505
						//InitialTab();
1506
						//SearchUsers();
1507
						//LoadRoles();
1508
						//ResetField();
1509
						//AfterSaveAnSuccess();
1510
					}
1511
				}
1512
			});
1513
}
1514

    
1515
function ReleaseSession(){
1516
	
1517
	var userId = Ext.getCmp('header_user_id').getValue();
1518
	
1519
	Ext.Ajax.request({
1520
		
1521
				url : '/UserManagement/ReleaseOpenSession',
1522
				params : {
1523
					userID : userId
1524
				},
1525
				method : 'POST',
1526
				success : function(result, request) {
1527
					
1528
					var data = Ext.decode(result.responseText);
1529
					if(data.success){
1530
						alert('Session User ID "'+userId+'" has been realeased');
1531
					}
1532
				}
1533
			});
1534
	
1535
}
1536

    
1537
function SearchUsers() {
1538
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('userid', Ext
1539
					.getCmp('search_userid').getValue());
1540
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('approval', Ext
1541
					.getCmp('search_approval').getValue());
1542
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('status_active', Ext
1543
					.getCmp('search_status').getValue());
1544
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('status_lock', Ext
1545
					.getCmp('search_lock').getValue());
1546

    
1547
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('start', 0);
1548
	Ext.getCmp('gridSearchEmployee').store.setBaseParam('limit',
1549
			limitRowPerpage);
1550

    
1551
	Ext.getCmp('gridSearchEmployee').store.load();
1552
}
1553
return mainLayOut;
(1-1/3)