|
|
@ -2,13 +2,20 @@ package ru.visionlab.femdemo; |
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.ProgressDialog; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.SharedPreferences; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.widget.AdapterView; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
import android.widget.BaseAdapter; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.ImageButton; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.ListAdapter; |
|
|
|
import android.widget.ListView; |
|
|
|
import android.widget.SimpleAdapter; |
|
|
@ -24,8 +31,13 @@ import org.json.JSONArray; |
|
|
|
import org.json.JSONException; |
|
|
|
import org.json.JSONObject; |
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import cn.pedant.SweetAlert.SweetAlertDialog; |
|
|
|
import ru.visionlab.femdemo.models.ApprovalModel; |
|
|
|
|
|
|
|
public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
|
|
|
@ -35,9 +47,12 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
String RequestID,EmployeeID,EmployeeName,LDate,LTimeOut,LTimeIn,NoOfHrs,LeaveType,ApproverID,ApproverName,Reason; |
|
|
|
|
|
|
|
ListView lv; |
|
|
|
ArrayList<HashMap<String,String>> arrayList; |
|
|
|
boolean isreject; |
|
|
|
ArrayList<ApprovalModel> arrayList=new ArrayList<ApprovalModel>(); |
|
|
|
|
|
|
|
String Employeeid; |
|
|
|
String Employeeid,RegisterUser; |
|
|
|
EditText ed_remarks; |
|
|
|
private String permissionid; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
@ -47,6 +62,8 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
SharedPreferences shared = getSharedPreferences("MyPrefs", MODE_PRIVATE); |
|
|
|
Employeeid = shared.getString("Employeeid", ""); |
|
|
|
RegisterUser = shared.getString("RegisterUser", ""); |
|
|
|
|
|
|
|
|
|
|
|
back = findViewById(R.id.back); |
|
|
|
back.setOnClickListener(new View.OnClickListener() { |
|
|
@ -57,7 +74,7 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
arrayList=new ArrayList<>(); |
|
|
|
arrayList=new ArrayList<ApprovalModel>(); |
|
|
|
lv = findViewById(R.id.listview); |
|
|
|
|
|
|
|
|
|
|
@ -90,38 +107,59 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
arrayList.clear(); |
|
|
|
|
|
|
|
JSONArray jsonArray=new JSONArray(response); |
|
|
|
for(int i = 0;i<jsonArray.length();i++){ |
|
|
|
|
|
|
|
JSONObject jb1=jsonArray.getJSONObject(0); |
|
|
|
RequestID = jb1.getString("RequestID"); |
|
|
|
EmployeeID = jb1.getString("EmployeeID"); |
|
|
|
EmployeeName = jb1.getString("EmployeeName"); |
|
|
|
LDate = jb1.getString("LDate"); |
|
|
|
LTimeOut = jb1.getString("LTimeOut"); |
|
|
|
LTimeIn = jb1.getString("LTimeIn"); |
|
|
|
NoOfHrs = jb1.getString("NoOfHrs"); |
|
|
|
LeaveType = jb1.getString("LeaveType"); |
|
|
|
ApproverID = jb1.getString("ApproverID"); |
|
|
|
ApproverName = jb1.getString("ApproverName"); |
|
|
|
Reason = jb1.getString("Reason"); |
|
|
|
|
|
|
|
HashMap<String,String> data = new HashMap<>(); |
|
|
|
data.put("EmployeeName",EmployeeName); |
|
|
|
data.put("EmployeeID",EmployeeID); |
|
|
|
data.put("LeaveType",LeaveType); |
|
|
|
data.put("ApproverName",ApproverName); |
|
|
|
|
|
|
|
arrayList.add(data); |
|
|
|
|
|
|
|
ListAdapter adapter = new SimpleAdapter(ApprovalListActivity.this,arrayList,R.layout.listview_layout |
|
|
|
,new String[]{"EmployeeName","EmployeeID","LeaveType","ApproverName"},new int[]{R.id.EmployeeNameVal,R.id.EmployeeIDVal,R.id.LeaveTypeVal,R.id.ApproverNameVal}); |
|
|
|
lv.setAdapter(adapter); |
|
|
|
for(int i = 0;i<jsonArray.length();i++) { |
|
|
|
|
|
|
|
JSONObject jb1 = jsonArray.getJSONObject(i); |
|
|
|
RequestID = jb1.getString("RequestID"); |
|
|
|
EmployeeID = jb1.getString("EmployeeID"); |
|
|
|
EmployeeName = jb1.getString("EmployeeName"); |
|
|
|
LDate = jb1.getString("LDate"); |
|
|
|
LTimeOut = jb1.getString("LTimeOut"); |
|
|
|
LTimeIn = jb1.getString("LTimeIn"); |
|
|
|
NoOfHrs = jb1.getString("NoOfHrs"); |
|
|
|
LeaveType = jb1.getString("LeaveType"); |
|
|
|
ApproverID = jb1.getString("ApproverID"); |
|
|
|
ApproverName = jb1.getString("ApproverName"); |
|
|
|
Reason = jb1.getString("Reason"); |
|
|
|
|
|
|
|
// HashMap<String,String> data = new HashMap<>(); |
|
|
|
// data.put("EmployeeName",EmployeeName); |
|
|
|
// data.put("EmployeeID",EmployeeID); |
|
|
|
// data.put("LeaveType",LeaveType); |
|
|
|
// data.put("ApproverName",ApproverName); |
|
|
|
ApprovalModel approvalModel = new ApprovalModel(); |
|
|
|
approvalModel.setApproverID(jb1.getString("ApproverID")); |
|
|
|
approvalModel.setRequestID(jb1.getString("RequestID")); |
|
|
|
approvalModel.setEmployeeID(jb1.getString("EmployeeID")); |
|
|
|
approvalModel.setEmployeeName(jb1.getString("EmployeeName")); |
|
|
|
approvalModel.setLDate(jb1.getString("LDate")); |
|
|
|
approvalModel.setLTimeOut(jb1.getString("LTimeOut")); |
|
|
|
approvalModel.setLTimeIn(jb1.getString("LTimeIn")); |
|
|
|
approvalModel.setNoOfHrs(jb1.getString("NoOfHrs")); |
|
|
|
approvalModel.setLeaveType(jb1.getString("LeaveType")); |
|
|
|
approvalModel.setApproverName(jb1.getString("ApproverName")); |
|
|
|
approvalModel.setReason(jb1.getString("Reason")); |
|
|
|
|
|
|
|
arrayList.add(approvalModel); |
|
|
|
} |
|
|
|
|
|
|
|
// ListAdapter adapter = new SimpleAdapter(ApprovalListActivity.this,arrayList,R.layout.listview_layout |
|
|
|
// ,new String[]{"EmployeeName","EmployeeID","LeaveType","ApproverName"},new int[]{R.id.EmployeeNameVal,R.id.EmployeeIDVal,R.id.LeaveTypeVal,R.id.ApproverNameVal}); |
|
|
|
// lv.setAdapter(adapter); |
|
|
|
|
|
|
|
// ArrayAdapter<ApprovalModel> adapter = new ArrayAdapter<ApprovalModel>(getApplicationContext(),R.layout.listview_layout,arrayList); |
|
|
|
lv.setAdapter(new Nr()); |
|
|
|
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { |
|
|
|
ApprovalModel approvalModel=arrayList.get(i); |
|
|
|
Intent intent = new Intent(ApprovalListActivity.this,LeaveRequestDetailsActivity.class); |
|
|
|
Bundle bundle=new Bundle(); |
|
|
|
bundle.putSerializable("Approvaldata", (Serializable) approvalModel); |
|
|
|
intent.putExtras(bundle); |
|
|
|
startActivity(intent); |
|
|
|
} |
|
|
|
}); |
|
|
@ -137,11 +175,158 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
ApproverIDVal.setText(ApproverID); |
|
|
|
ApproverNameVal.setText(ApproverName); |
|
|
|
ReasonVal.setText(Reason); |
|
|
|
*/ } |
|
|
|
*/ |
|
|
|
|
|
|
|
} catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
loading.dismiss(); |
|
|
|
} |
|
|
|
|
|
|
|
}, new com.android.volley.Response.ErrorListener() { |
|
|
|
@Override |
|
|
|
public void onErrorResponse(VolleyError error) { |
|
|
|
// Log.d("error-=>",error.getMessage()); |
|
|
|
Toast.makeText(ApprovalListActivity.this, "Failed to get response = " + error.getMessage(), Toast.LENGTH_SHORT).show(); |
|
|
|
loading.dismiss(); |
|
|
|
System.out.println("Error message: "+ error.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
{ |
|
|
|
|
|
|
|
}; |
|
|
|
Volley.newRequestQueue(ApprovalListActivity.this).add(stringRequest); |
|
|
|
} |
|
|
|
|
|
|
|
private class Nr extends BaseAdapter { |
|
|
|
|
|
|
|
@Override |
|
|
|
public int getCount() { |
|
|
|
return arrayList.size(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object getItem(int position) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public long getItemId(int position) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public View getView(int position, View convertView, ViewGroup parent) { |
|
|
|
LayoutInflater inflater = getLayoutInflater(); |
|
|
|
View v = inflater.inflate(R.layout.listview_layout, null); |
|
|
|
|
|
|
|
TextView EmployeeNameVal=v.findViewById(R.id.EmployeeNameVal); |
|
|
|
TextView EmployeeIDVal=v.findViewById(R.id.EmployeeIDVal); |
|
|
|
TextView LeaveTypeVal=v.findViewById(R.id.LeaveTypeVal); |
|
|
|
TextView ApproverNameVal=v.findViewById(R.id.ApproverNameVal); |
|
|
|
LinearLayout ll_approve=v.findViewById(R.id.ll_approve); |
|
|
|
|
|
|
|
EmployeeNameVal.setText(arrayList.get(position).getEmployeeName()); |
|
|
|
EmployeeIDVal.setText(arrayList.get(position).getEmployeeID()); |
|
|
|
LeaveTypeVal.setText(arrayList.get(position).getLeaveType()); |
|
|
|
ApproverNameVal.setText(arrayList.get(position).getApproverName()); |
|
|
|
|
|
|
|
permissionid=arrayList.get(position).getRequestID(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ll_approve.setOnClickListener(new View.OnClickListener() { |
|
|
|
// @Override |
|
|
|
// public void onClick(View v) { |
|
|
|
// isreject=false; |
|
|
|
// AlertDialog.Builder builder = new AlertDialog.Builder(ApprovalListActivity.this); |
|
|
|
// builder.setTitle("Remarks"); |
|
|
|
// builder.setCancelable(false); |
|
|
|
// |
|
|
|
// // set the custom layout |
|
|
|
// final View customLayout = getLayoutInflater().inflate(R.layout.dialog_approve, null); |
|
|
|
// builder.setView(customLayout); |
|
|
|
// |
|
|
|
// // add a button |
|
|
|
// builder.setPositiveButton("Save", (dialog, which) -> { |
|
|
|
// // send data from the AlertDialog to the Activity |
|
|
|
// ed_remarks = customLayout.findViewById(R.id.ed_remarks); |
|
|
|
// |
|
|
|
// if(ed_remarks.getText().toString().isEmpty()) |
|
|
|
// { |
|
|
|
// Toast.makeText(ApprovalListActivity.this, "Please enter remars", Toast.LENGTH_SHORT).show(); |
|
|
|
// builder.show(); |
|
|
|
// return; |
|
|
|
// |
|
|
|
// } |
|
|
|
// else { |
|
|
|
// PermissionApprovalAction(); |
|
|
|
// } |
|
|
|
// |
|
|
|
// }); |
|
|
|
// // create and show the alert dialog |
|
|
|
// AlertDialog dialog = builder.create(); |
|
|
|
// dialog.show(); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
return v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void PermissionApprovalAction(){ |
|
|
|
|
|
|
|
|
|
|
|
final ProgressDialog loading = ProgressDialog.show(ApprovalListActivity.this, "Fetching information", "Please wait ", false, false); |
|
|
|
|
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/PermissionApprovalAction"; |
|
|
|
StringRequest stringRequest=new StringRequest(Request.Method.POST, url, new com.android.volley.Response.Listener<String>() { |
|
|
|
@Override |
|
|
|
public void onResponse(String response) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
JSONObject jsonObject = new JSONObject(response); |
|
|
|
String _statusMessage = jsonObject.getString("_statusMessage"); |
|
|
|
String _statusCode=jsonObject.getString("_statusCode"); |
|
|
|
|
|
|
|
|
|
|
|
if(_statusCode.equals("200")) |
|
|
|
{ |
|
|
|
String message; |
|
|
|
if(isreject) |
|
|
|
{ |
|
|
|
message="Leave Rejected"; |
|
|
|
} |
|
|
|
else { |
|
|
|
message="Leave Approved"; |
|
|
|
} |
|
|
|
|
|
|
|
new SweetAlertDialog(ApprovalListActivity.this, SweetAlertDialog.SUCCESS_TYPE) |
|
|
|
.setTitleText(message) |
|
|
|
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(SweetAlertDialog sDialog) { |
|
|
|
sDialog.dismissWithAnimation(); |
|
|
|
PermissionApprovalList(); |
|
|
|
} |
|
|
|
}).show(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Toast.makeText(ApprovalListActivity.this, _statusMessage, Toast.LENGTH_LONG).show(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loading.dismiss(); |
|
|
|
} |
|
|
|
|
|
|
@ -157,8 +342,29 @@ public class ApprovalListActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
}) |
|
|
|
{ |
|
|
|
@Override |
|
|
|
protected Map<String, String> getParams() { |
|
|
|
Map<String, String> params = new HashMap<String, String>(); |
|
|
|
|
|
|
|
params.put("permissionID",permissionid); |
|
|
|
params.put("approverID", Employeeid); |
|
|
|
params.put("actionby", RegisterUser); |
|
|
|
params.put("remark", ed_remarks.getText().toString()); |
|
|
|
if(isreject) |
|
|
|
{ |
|
|
|
params.put("actionflag", "R"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
params.put("actionflag", "A"); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("params in Approve "+params); |
|
|
|
return params; |
|
|
|
} |
|
|
|
}; |
|
|
|
Volley.newRequestQueue(ApprovalListActivity.this).add(stringRequest); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|