Project

General

Profile

Bug #1539 » HR_APP_fnGetPosition_20220909.js

Tri Rizqiaty, 09/09/2022 02:20 PM

 
1
var md = cmbMasterData.getValue();
2
console.log(md);
3
var empid = hidEmpId.getValue();
4
//alert (empid);
5
var empid_ = fldTransempid.getValue();
6
//alert (empid_);
7
var percode = perCode.getValue();
8
var accesscode = accessCode.getValue();
9
var mdcat = mdCat.getValue();
10
var gen;
11
if (empid == undefined) {
12
	gen = percode + mdcat + accesscode + "0002" + empid_;
13
	//alert (gen);
14
} else {
15
	gen = percode + mdcat + accesscode + "0002" + empid;
16
	//alert (gen);
17
}
18
if (md == '0055') {
19
	gen = percode + mdcat + accesscode + "0055" + empid;
20
}
21
var date_ = Ext.getCmp('start_date' + gen).getValue();
22
var datenow = new Date();
23

    
24
//var cc = "";
25
//var job = "";
26
var emp_area = "";
27
var emp_off = "";
28

    
29
var cls = node.attributes.object_type;
30
var obj = node.attributes.object_id;
31
var p_obj = node.attributes.par_object_id;
32
var p_cls = node.attributes.par_object_type;
33
var cc = node.attributes.cost_center;
34
var is_vac = node.attributes.is_vacant;
35
var job = node.attributes.job;
36

    
37
var dt = null;
38
$.ajax({
39
	url: "HR_ORM_EXT/GetObjectTreeByQuery",
40
	data: {
41
		tree_struct_code: 'O-O-P-E',
42
		key_date: date_,
43
		node: 'P' + obj
44
	},
45
	success: function (result) {
46
		dt = result.data.length;
47
		if	(md == '0055') //// add by Tri nwh 20220907 start
48
		{
49
			var fldPosID = Ext.getCmp(fldLookPosID.getValue());
50
			var fldOrgID = Ext.getCmp(fldLookOrgID.getValue());
51
			var fldCCID = Ext.getCmp(fldLookCCID.getValue());
52
			var fldJobID = Ext.getCmp(fldLookJobID.getValue());
53
			var fldEmpAreaID = Ext.getCmp(fldLookEmpAreaID.getValue());
54
			var fldEmpOffID = Ext.getCmp(fldLookEmpOffID.getValue());
55

    
56
			fldPosID.setValue(obj);
57
			fldOrgID.setValue(p_obj);
58
			fldJobID.setValue(job);
59
			if (fldCCID != undefined) {
60
				fldCCID.setValue(cc);
61
			}
62

    
63
			Ext.getCmp(_serialRandomize.getValue()).hide();
64
		} //// add by Tri nwh 20220907 end
65
		else
66
		{
67
			if  (dt == 0) {
68

    
69
				// if (cls == "P" && is_vac) //ori
70
				if ((cls == "P" && is_vac) || (cls == "P" && perCode.value == "app")) // add
71
					// irwan
72
					// 20110509
73
				{
74
					if ((!is_vac) && (perCode.value == "app")) {
75
						fnShowMsgText("the Position specified is already occupied.");
76
					} // add irwan 20110510
77
					try {
78
						$.ajax({
79
							url: "HR_OM/GetProperties",
80
							data: {
81
								object: node.attributes.object_id,
82
								date: datenow.format('Ymd')
83
								// node.attributes.start_date
84
							},
85
							success: function (result) {
86
								//cc = result.O_cc_id;
87
								//job = result.O_job_id;
88
								emp_area = result.O_EmpArea_txt; // "--emp_area---";
89
								emp_off = result.O_EmpOffice_txt; // "--emp_off---";
90
								// alert(cc +"-" + job);
91
							}
92
						})
93
					} catch (e) {}
94
					try {
95
						$.ajax({
96
							url: "Mega_PA/GetUnitLevelCode",
97
							data: {
98
								posisi: node.attributes.object_id,
99
								//date : datenow.format('Ymd')
100
								// node.attributes.start_date
101
							},
102
							success: function (result) {
103
								//cc = result.O_cc_id;
104
								//job = result.O_job_id;
105
								//emp_area = result.O_EmpArea_txt;// "--emp_area---";
106
								//emp_off = result.O_EmpOffice_txt;// "--emp_off---";
107
								//alert(result);
108
								if (Ext.getCmp('unit_level' + gen) != undefined) {
109
									Ext.getCmp('unit_level' + gen).setValue(result);
110
								}
111

    
112
							}
113
						})
114
					} catch (e) {}
115
					try {
116
						$.ajax({
117
							url: "Mega_PA/GetUnitLevelDescription",
118
							data: {
119
								posisi: node.attributes.object_id,
120
								//date : datenow.format('Ymd')
121
								// node.attributes.start_date
122
							},
123
							success: function (result) {
124
								//cc = result.O_cc_id;
125
								//job = result.O_job_id;
126
								//emp_area = result.O_EmpArea_txt;// "--emp_area---";
127
								//emp_off = result.O_EmpOffice_txt;// "--emp_off---";
128
								//alert(result);
129
								if (Ext.getCmp('unit_level_txt' + gen) != undefined) {
130
									Ext.getCmp('unit_level_txt' + gen).setValue(result);
131
								}
132

    
133
							}
134
						})
135
					} catch (e) {}
136
					var fldPosID = Ext.getCmp(fldLookPosID.getValue());
137
					var fldOrgID = Ext.getCmp(fldLookOrgID.getValue());
138
					var fldCCID = Ext.getCmp(fldLookCCID.getValue());
139
					var fldJobID = Ext.getCmp(fldLookJobID.getValue());
140
					var fldEmpAreaID = Ext.getCmp(fldLookEmpAreaID.getValue());
141
					var fldEmpOffID = Ext.getCmp(fldLookEmpOffID.getValue());
142

    
143
					fldPosID.setValue(obj);
144
					fldOrgID.setValue(p_obj);
145
					fldJobID.setValue(job);
146
					if (fldCCID != undefined) {
147
						fldCCID.setValue(cc);
148
					}
149

    
150
					Ext.getCmp(_serialRandomize.getValue()).hide();
151

    
152
				} else if (cls == "P") {
153
					fnShowMsgText("the Position specified is already occupied.");
154
				}
155
			} else {
156
				alert('Posisi yang dipilih sudah memiliki relasi')
157
			}
158
		}
159
	}
160
})
(3-3/5)