|
|
@ -2,6 +2,7 @@ package ru.visionlab.femdemo; |
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
|
|
|
import android.app.DatePickerDialog; |
|
|
|
import android.app.ProgressDialog; |
|
|
|
import android.app.TimePickerDialog; |
|
|
|
import android.content.Intent; |
|
|
@ -13,6 +14,7 @@ import android.view.View; |
|
|
|
import android.widget.AdapterView; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.DatePicker; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.ImageButton; |
|
|
|
import android.widget.LinearLayout; |
|
|
@ -38,8 +40,11 @@ import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import cn.pedant.SweetAlert.SweetAlertDialog; |
|
|
|
import ru.visionlab.femdemo.R; |
|
|
|
import ru.visionlab.femdemo.login.LoginActivity; |
|
|
|
import ru.visionlab.femdemo.login.LoginActivityNew; |
|
|
|
import ru.visionlab.femdemo.register.RegisterActivity; |
|
|
|
|
|
|
|
public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
|
|
|
@ -50,13 +55,14 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
String remarks=""; |
|
|
|
LinearLayout timePickerFrom,timePickerTo; |
|
|
|
private int mDayFrom,mMonthFrom,mMonthTo,mYearFrom,mYearTo,mDayTo, mHour, mMinute; |
|
|
|
TextView textTimeFrom,textTimeTo; |
|
|
|
TextView textTimeFrom,textTimeTo,txt_p_date,txt_from_date,txt_to_date; |
|
|
|
|
|
|
|
LinearLayout linearLayout1; |
|
|
|
|
|
|
|
Spinner spinner; |
|
|
|
|
|
|
|
String permission_type,permission_code; |
|
|
|
String permission_type,permission_code,Employeeid; |
|
|
|
String toDate,fromTime,fromDate,currentDateandTime; |
|
|
|
|
|
|
|
ArrayList<PermissionModel> permission_type_list=new ArrayList<>(); |
|
|
|
ArrayList<String> spinner_array=new ArrayList<>(); |
|
|
@ -64,7 +70,11 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
// code for Niladri |
|
|
|
|
|
|
|
RelativeLayout private_date,official_from_date,official_to_date; |
|
|
|
String permission_code; |
|
|
|
String timeset, timeSetFrom,RegisterUser; |
|
|
|
EditText txtDate, txtTime; |
|
|
|
private int mYear, mMonth, mDay; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
@ -75,10 +85,15 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
SharedPreferences shared = getSharedPreferences("MyPrefs", MODE_PRIVATE); |
|
|
|
|
|
|
|
Employeeid = shared.getString("Employeeid", ""); |
|
|
|
RegisterUser = shared.getString("RegisterUser", ""); |
|
|
|
|
|
|
|
private_date=findViewById(R.id.private_date); |
|
|
|
official_from_date=findViewById(R.id.official_from_date); |
|
|
|
official_to_date=findViewById(R.id.official_to_date); |
|
|
|
txt_p_date = findViewById(R.id.txtPDate); |
|
|
|
txt_from_date = findViewById(R.id.txt_from_date); |
|
|
|
txt_to_date = findViewById(R.id.txt_to_date); |
|
|
|
|
|
|
|
|
|
|
|
IsELeaveApprover(); |
|
|
|
//PermissionInsert(); |
|
|
@ -128,10 +143,71 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// private_date.setOnClickListener(new View.OnClickListener() { |
|
|
|
// @Override |
|
|
|
// public void onClick(View v) { |
|
|
|
// open_date(); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
private_date.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
final Calendar c = Calendar.getInstance(); |
|
|
|
mYear = c.get(Calendar.YEAR); |
|
|
|
mMonth = c.get(Calendar.MONTH); |
|
|
|
mDay = c.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
DatePickerDialog datePickerDialog = new DatePickerDialog(PermissionRequestActivity.this, |
|
|
|
new DatePickerDialog.OnDateSetListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDateSet(DatePicker view, int year, |
|
|
|
int monthOfYear, int dayOfMonth) { |
|
|
|
txt_p_date.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year); |
|
|
|
} |
|
|
|
}, mYear, mMonth, mDay); |
|
|
|
datePickerDialog.show(); |
|
|
|
} |
|
|
|
}); |
|
|
|
official_from_date.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
final Calendar c = Calendar.getInstance(); |
|
|
|
mYear = c.get(Calendar.YEAR); |
|
|
|
mMonth = c.get(Calendar.MONTH); |
|
|
|
mDay = c.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
DatePickerDialog datePickerDialog = new DatePickerDialog(PermissionRequestActivity.this, |
|
|
|
new DatePickerDialog.OnDateSetListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDateSet(DatePicker view, int year, |
|
|
|
int monthOfYear, int dayOfMonth) { |
|
|
|
txt_from_date.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year); |
|
|
|
} |
|
|
|
}, mYear, mMonth, mDay); |
|
|
|
datePickerDialog.show(); |
|
|
|
} |
|
|
|
}); |
|
|
|
official_to_date.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
final Calendar c = Calendar.getInstance(); |
|
|
|
mYear = c.get(Calendar.YEAR); |
|
|
|
mMonth = c.get(Calendar.MONTH); |
|
|
|
mDay = c.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
DatePickerDialog datePickerDialog = new DatePickerDialog(PermissionRequestActivity.this, |
|
|
|
new DatePickerDialog.OnDateSetListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDateSet(DatePicker view, int year, |
|
|
|
int monthOfYear, int dayOfMonth) { |
|
|
|
txt_to_date.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year); |
|
|
|
} |
|
|
|
}, mYear, mMonth, mDay); |
|
|
|
datePickerDialog.show(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@ -200,9 +276,20 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
public void onTimeSet(TimePicker view, int hourOfDay, |
|
|
|
int minute) { |
|
|
|
|
|
|
|
timeset=""; |
|
|
|
if(hourOfDay>12) |
|
|
|
{ |
|
|
|
hourOfDay-=12; |
|
|
|
timeSetFrom="PM"; |
|
|
|
} |
|
|
|
else if(hourOfDay==0) |
|
|
|
{ |
|
|
|
hourOfDay+=12; |
|
|
|
timeSetFrom="AM"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
textTimeFrom.setText(hourOfDay + ":" + minute); |
|
|
|
textTimeFrom.setText(hourOfDay + ":" + minute + " " + timeSetFrom); |
|
|
|
} |
|
|
|
}, mHour, mMinute, false); |
|
|
|
timePickerDialog.show(); |
|
|
@ -232,8 +319,19 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
int minute) { |
|
|
|
|
|
|
|
|
|
|
|
timeset=""; |
|
|
|
if(hourOfDay>12) |
|
|
|
{ |
|
|
|
hourOfDay-=12; |
|
|
|
timeset="PM"; |
|
|
|
} |
|
|
|
else if(hourOfDay==0) |
|
|
|
{ |
|
|
|
hourOfDay+=12; |
|
|
|
timeset="AM"; |
|
|
|
} |
|
|
|
|
|
|
|
textTimeTo.setText(hourOfDay + ":" + minute); |
|
|
|
textTimeTo.setText(hourOfDay + ":" + minute+" "+timeset); |
|
|
|
} |
|
|
|
}, mHour, mMinute, false); |
|
|
|
timePickerDialog.show(); |
|
|
@ -249,6 +347,10 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void open_date() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void getPermission(){ |
|
|
@ -266,12 +368,19 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
try { |
|
|
|
_statusMessage = jsonObject.getString("_statusMessage"); |
|
|
|
System.out.println("Status message: "+_statusMessage); |
|
|
|
loading.dismiss(); |
|
|
|
new SweetAlertDialog(PermissionRequestActivity.this, SweetAlertDialog.SUCCESS_TYPE) |
|
|
|
.setTitleText("Permission successful") |
|
|
|
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(SweetAlertDialog sDialog) { |
|
|
|
sDialog.dismissWithAnimation(); |
|
|
|
} |
|
|
|
}).show(); |
|
|
|
} catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
Toast.makeText(PermissionRequestActivity.this, _statusMessage, Toast.LENGTH_SHORT).show(); |
|
|
|
loading.dismiss(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, new com.android.volley.Response.ErrorListener() { |
|
|
@ -297,7 +406,7 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
params.put("totime", textTimeTo.getText().toString()); |
|
|
|
params.put("reason", edtRemarks.getText().toString()); |
|
|
|
params.put("attachment", ""); |
|
|
|
params.put("userid", "a"); |
|
|
|
params.put("userid", RegisterUser); |
|
|
|
if(permission_code.equals("O")){ |
|
|
|
params.put("startdate", fromDate); |
|
|
|
params.put("enddate", toDate); |
|
|
@ -451,7 +560,37 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
@Override |
|
|
|
public void onResponse(String response) { |
|
|
|
|
|
|
|
Toast.makeText(PermissionRequestActivity.this, "Response successful2", Toast.LENGTH_SHORT).show(); |
|
|
|
// Toast.makeText(PermissionRequestActivity.this, "Response successful2", Toast.LENGTH_SHORT).show(); |
|
|
|
|
|
|
|
try { |
|
|
|
JSONArray jsonArray=new JSONArray(response); |
|
|
|
for(int i=0;i<jsonArray.length();i++) |
|
|
|
{ |
|
|
|
JSONObject jb1=jsonArray.getJSONObject(i); |
|
|
|
permission_code=jb1.getString("Permission_code"); |
|
|
|
permission_type=jb1.getString("Permission_NameEN"); |
|
|
|
|
|
|
|
|
|
|
|
// spinner_array.add(permission_type); |
|
|
|
// spinner_array.add |
|
|
|
|
|
|
|
PermissionModel permissionModel=new PermissionModel(); |
|
|
|
permissionModel.setPermission_NameEN(permission_type); |
|
|
|
permissionModel.setPermission_code(permission_code); |
|
|
|
permission_type_list.add(permissionModel); |
|
|
|
} |
|
|
|
|
|
|
|
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter |
|
|
|
(getApplicationContext(), android.R.layout.simple_spinner_item, |
|
|
|
permission_type_list); //selected item will look like a spinner set from XML |
|
|
|
spinnerArrayAdapter.setDropDownViewResource(android.R.layout |
|
|
|
.simple_spinner_dropdown_item); |
|
|
|
spinner.setAdapter(spinnerArrayAdapter); |
|
|
|
|
|
|
|
|
|
|
|
} catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
loading.dismiss(); |
|
|
|
|
|
|
|
|
|
|
@ -463,14 +602,10 @@ public class PermissionRequestActivity extends AppCompatActivity { |
|
|
|
// Log.d("error-=>",error.getMessage()); |
|
|
|
Toast.makeText(PermissionRequestActivity.this, "Failed to get response = " + error.getMessage(), Toast.LENGTH_SHORT).show(); |
|
|
|
loading.dismiss(); |
|
|
|
System.out.println("Error message: "+ error.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.println("Error message: "+ error.getMessage()); } |
|
|
|
}) |
|
|
|
{ |
|
|
|
|
|
|
|
}; |
|
|
|
Volley.newRequestQueue(PermissionRequestActivity.this).add(stringRequest); |
|
|
|
} |
|
|
|
} |
|
|
|
}} |