Implement BantuanFormActivity API

This commit is contained in:
riz081 2025-07-01 11:44:30 +07:00
parent ddf76d2540
commit 9dac55d07a
2 changed files with 441 additions and 369 deletions

View File

@ -37,23 +37,17 @@ import java.util.concurrent.Executors;
public class BantuanFormActivity extends AppCompatActivity { public class BantuanFormActivity extends AppCompatActivity {
// UI Components // UI Components
private EditText etTerminalId, etNomorTelepon, etDeskripsiMasalah; private EditText etTicketCode;
private Spinner spinnerTanggalKejadian, spinnerJenisMasalah; private Spinner spinnerSource, spinnerIssue, spinnerMerchant, spinnerAssign, spinnerResolvedDate;
private LinearLayout uploadContainer; private TextView tvStatus;
private TextView uploadText;
private Button btnKirim; private Button btnKirim;
private LinearLayout backNavigation; private LinearLayout backNavigation;
// Data // Data
private String selectedDate = ""; private String selectedResolvedDate = "";
private String selectedFileName = "";
private Uri selectedFileUri = null;
private ExecutorService executor = Executors.newSingleThreadExecutor(); private ExecutorService executor = Executors.newSingleThreadExecutor();
private Handler mainHandler = new Handler(Looper.getMainLooper()); private Handler mainHandler = new Handler(Looper.getMainLooper());
// File picker launcher
private ActivityResultLauncher<Intent> filePickerLauncher;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -69,8 +63,6 @@ public class BantuanFormActivity extends AppCompatActivity {
initViews(); initViews();
setupSpinners(); setupSpinners();
setupListeners(); setupListeners();
setupFilePicker();
loadUserData();
// Initialize button state // Initialize button state
updateButtonState(); updateButtonState();
@ -78,17 +70,17 @@ public class BantuanFormActivity extends AppCompatActivity {
private void initViews() { private void initViews() {
// Form fields // Form fields
etTerminalId = findViewById(R.id.et_terminal_id); etTicketCode = findViewById(R.id.et_ticket_code);
etNomorTelepon = findViewById(R.id.et_nomor_telepon);
etDeskripsiMasalah = findViewById(R.id.et_deskripsi_masalah);
// Spinners // Spinners
spinnerTanggalKejadian = findViewById(R.id.spinner_tanggal_kejadian); spinnerSource = findViewById(R.id.spinner_source);
spinnerJenisMasalah = findViewById(R.id.spinner_jenis_masalah); spinnerIssue = findViewById(R.id.spinner_issue);
spinnerMerchant = findViewById(R.id.spinner_merchant);
spinnerAssign = findViewById(R.id.spinner_assign);
spinnerResolvedDate = findViewById(R.id.spinner_resolved_date);
// Upload section // Status (read-only)
uploadContainer = findViewById(R.id.upload_container); tvStatus = findViewById(R.id.tv_status);
uploadText = findViewById(R.id.upload_text);
// Buttons // Buttons
btnKirim = findViewById(R.id.btn_kirim); btnKirim = findViewById(R.id.btn_kirim);
@ -96,31 +88,77 @@ public class BantuanFormActivity extends AppCompatActivity {
} }
private void setupSpinners() { private void setupSpinners() {
// Setup Date Spinner with date picker // Setup Source Spinner
String[] dateOptions = {"Pilih Tanggal Kejadian", "Pilih dari kalender"}; String[] sourceOptions = {
"Pilih Source",
"WhatsApp",
"Website Hubungi Kami"
};
ArrayAdapter<String> sourceAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, sourceOptions);
sourceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerSource.setAdapter(sourceAdapter);
// Setup Issue Spinner
String[] issueOptions = {
"Pilih Issue",
"Koneksi EDC Bermasalah",
"Permintaan Tambahan EDC",
"Pergantian EDC"
};
ArrayAdapter<String> issueAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, issueOptions);
issueAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerIssue.setAdapter(issueAdapter);
// Setup Merchant Spinner
String[] merchantOptions = {
"Pilih Merchant",
"Surabaya",
"Jakarta Selatan",
"Jakarta Pusat",
"Jakarta Barat",
"Palembang",
"Bogor Timur",
"Bandung Utara",
"Yogyakarta Selatan",
"Cilacap Barat",
"Bekasi Timur",
"Tangerang Selatan",
"Depok Tengah",
"Kediri Kota"
};
ArrayAdapter<String> merchantAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, merchantOptions);
merchantAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerMerchant.setAdapter(merchantAdapter);
// Setup Assign Spinner
String[] assignOptions = {
"Pilih Assign",
"welno hedi prabowo putro jenaka prima",
"rizqika",
"budi",
"binomo",
"budi",
"Irfan Muslim Saputra"
};
ArrayAdapter<String> assignAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, assignOptions);
assignAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerAssign.setAdapter(assignAdapter);
// Setup Resolved Date Spinner with date picker
String[] dateOptions = {"Pilih Tanggal Resolved", "Pilih dari kalender"};
ArrayAdapter<String> dateAdapter = new ArrayAdapter<>(this, ArrayAdapter<String> dateAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, dateOptions); android.R.layout.simple_spinner_item, dateOptions);
dateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); dateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTanggalKejadian.setAdapter(dateAdapter); spinnerResolvedDate.setAdapter(dateAdapter);
// Setup Issue Type Spinner // Set status to fixed value
String[] issueTypes = { if (tvStatus != null) {
"Pilih Jenis Masalah", tvStatus.setText("Pengajuan");
"Transaksi gagal tapi saldo terpotong", }
"QRIS tidak terbaca",
"EDC tidak merespon / hang",
"Gagal cetak struk",
"Masalah koneksi internet",
"Error pada aplikasi",
"Masalah settlement",
"Kartu tidak terbaca",
"Printer bermasalah",
"Lainnya"
};
ArrayAdapter<String> issueAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, issueTypes);
issueAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerJenisMasalah.setAdapter(issueAdapter);
} }
private void setupListeners() { private void setupListeners() {
@ -129,8 +167,52 @@ public class BantuanFormActivity extends AppCompatActivity {
backNavigation.setOnClickListener(v -> onBackPressed()); backNavigation.setOnClickListener(v -> onBackPressed());
} }
// Date spinner listener // Source spinner listener
spinnerTanggalKejadian.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() { spinnerSource.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
updateButtonState();
}
@Override
public void onNothingSelected(android.widget.AdapterView<?> parent) {}
});
// Issue spinner listener
spinnerIssue.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
updateButtonState();
}
@Override
public void onNothingSelected(android.widget.AdapterView<?> parent) {}
});
// Merchant spinner listener
spinnerMerchant.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
updateButtonState();
}
@Override
public void onNothingSelected(android.widget.AdapterView<?> parent) {}
});
// Assign spinner listener
spinnerAssign.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
updateButtonState();
}
@Override
public void onNothingSelected(android.widget.AdapterView<?> parent) {}
});
// Resolved Date spinner listener
spinnerResolvedDate.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
if (position == 1) { // "Pilih dari kalender" if (position == 1) { // "Pilih dari kalender"
@ -143,24 +225,8 @@ public class BantuanFormActivity extends AppCompatActivity {
public void onNothingSelected(android.widget.AdapterView<?> parent) {} public void onNothingSelected(android.widget.AdapterView<?> parent) {}
}); });
// Issue type spinner listener // Text watcher for EditText field
spinnerJenisMasalah.setOnItemSelectedListener(new android.widget.AdapterView.OnItemSelectedListener() { setupTextWatcher();
@Override
public void onItemSelected(android.widget.AdapterView<?> parent, View view, int position, long id) {
updateButtonState();
}
@Override
public void onNothingSelected(android.widget.AdapterView<?> parent) {}
});
// Text watchers for EditText fields
setupTextWatchers();
// Upload container listener
if (uploadContainer != null) {
uploadContainer.setOnClickListener(v -> openFilePicker());
}
// Submit button listener // Submit button listener
if (btnKirim != null) { if (btnKirim != null) {
@ -172,7 +238,7 @@ public class BantuanFormActivity extends AppCompatActivity {
} }
} }
private void setupTextWatchers() { private void setupTextWatcher() {
android.text.TextWatcher textWatcher = new android.text.TextWatcher() { android.text.TextWatcher textWatcher = new android.text.TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@ -186,14 +252,8 @@ public class BantuanFormActivity extends AppCompatActivity {
} }
}; };
if (etTerminalId != null) { if (etTicketCode != null) {
etTerminalId.addTextChangedListener(textWatcher); etTicketCode.addTextChangedListener(textWatcher);
}
if (etNomorTelepon != null) {
etNomorTelepon.addTextChangedListener(textWatcher);
}
if (etDeskripsiMasalah != null) {
etDeskripsiMasalah.addTextChangedListener(textWatcher);
} }
} }
@ -204,67 +264,29 @@ public class BantuanFormActivity extends AppCompatActivity {
if (isFormValid) { if (isFormValid) {
// Active state - Red background // Active state - Red background
btnKirim.setBackgroundResource(R.drawable.button_active_background); btnKirim.setBackgroundColor(0xFFDE0701); // Red color matching theme
btnKirim.setTextColor(getResources().getColor(android.R.color.white)); btnKirim.setTextColor(getResources().getColor(android.R.color.white));
btnKirim.setEnabled(true); btnKirim.setEnabled(true);
btnKirim.setAlpha(1.0f);
} else { } else {
// Inactive state - Gray background // Inactive state - Gray background
btnKirim.setBackgroundResource(R.drawable.button_inactive_background); btnKirim.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));
btnKirim.setTextColor(getResources().getColor(android.R.color.darker_gray)); btnKirim.setTextColor(getResources().getColor(android.R.color.white));
btnKirim.setEnabled(false); btnKirim.setEnabled(false);
btnKirim.setAlpha(0.6f);
} }
} }
private boolean checkFormValidity() { private boolean checkFormValidity() {
// Check if all required fields have values // Check if all required fields have values
boolean hasTerminalId = etTerminalId != null && !etTerminalId.getText().toString().trim().isEmpty(); boolean hasTicketCode = etTicketCode != null && !etTicketCode.getText().toString().trim().isEmpty();
boolean hasPhoneNumber = etNomorTelepon != null && !etNomorTelepon.getText().toString().trim().isEmpty(); boolean hasSource = spinnerSource != null && spinnerSource.getSelectedItemPosition() > 0;
boolean hasDate = !selectedDate.isEmpty(); boolean hasIssue = spinnerIssue != null && spinnerIssue.getSelectedItemPosition() > 0;
boolean hasIssueType = spinnerJenisMasalah != null && spinnerJenisMasalah.getSelectedItemPosition() > 0; boolean hasMerchant = spinnerMerchant != null && spinnerMerchant.getSelectedItemPosition() > 0;
boolean hasDescription = etDeskripsiMasalah != null && !etDeskripsiMasalah.getText().toString().trim().isEmpty(); boolean hasAssign = spinnerAssign != null && spinnerAssign.getSelectedItemPosition() > 0;
boolean hasResolvedDate = !selectedResolvedDate.isEmpty();
return hasTerminalId && hasPhoneNumber && hasDate && hasIssueType && hasDescription; return hasTicketCode && hasSource && hasIssue && hasMerchant && hasAssign && hasResolvedDate;
}
private void setupFilePicker() {
filePickerLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
selectedFileUri = result.getData().getData();
if (selectedFileUri != null) {
selectedFileName = getFileName(selectedFileUri);
if (uploadText != null) {
uploadText.setText(selectedFileName);
uploadText.setTextColor(getResources().getColor(android.R.color.black));
}
}
}
});
}
private void loadUserData() {
try {
JSONObject userData = LoginActivity.getUserDataAsJson(this);
if (userData != null) {
// Auto-fill phone number if available
String phone = userData.optString("phone", userData.optString("mobile", ""));
if (!phone.isEmpty() && etNomorTelepon != null) {
etNomorTelepon.setText(phone);
}
// Auto-fill terminal ID if available
String terminalId = userData.optString("terminal_id", userData.optString("tid", ""));
if (!terminalId.isEmpty() && etTerminalId != null) {
etTerminalId.setText(terminalId);
}
}
} catch (Exception e) {
// Silent fail - user can fill manually
}
// Update button state after loading data
updateButtonState();
} }
private void showDatePicker() { private void showDatePicker() {
@ -275,16 +297,21 @@ public class BantuanFormActivity extends AppCompatActivity {
Calendar selectedCalendar = Calendar.getInstance(); Calendar selectedCalendar = Calendar.getInstance();
selectedCalendar.set(year, month, dayOfMonth); selectedCalendar.set(year, month, dayOfMonth);
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); // Format for API (ISO 8601)
selectedDate = dateFormat.format(selectedCalendar.getTime()); SimpleDateFormat apiFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault());
selectedResolvedDate = apiFormat.format(selectedCalendar.getTime());
// Format for display
SimpleDateFormat displayFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
String displayDate = displayFormat.format(selectedCalendar.getTime());
// Update spinner to show selected date // Update spinner to show selected date
String[] updatedOptions = {"Pilih Tanggal Kejadian", selectedDate}; String[] updatedOptions = {"Pilih Tanggal Resolved", displayDate};
ArrayAdapter<String> updatedAdapter = new ArrayAdapter<>(this, ArrayAdapter<String> updatedAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, updatedOptions); android.R.layout.simple_spinner_item, updatedOptions);
updatedAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); updatedAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTanggalKejadian.setAdapter(updatedAdapter); spinnerResolvedDate.setAdapter(updatedAdapter);
spinnerTanggalKejadian.setSelection(1); spinnerResolvedDate.setSelection(1);
// Update button state after date selection // Update button state after date selection
updateButtonState(); updateButtonState();
@ -294,43 +321,55 @@ public class BantuanFormActivity extends AppCompatActivity {
calendar.get(Calendar.DAY_OF_MONTH) calendar.get(Calendar.DAY_OF_MONTH)
); );
// Set max date to today
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
datePickerDialog.show(); datePickerDialog.show();
} }
private void openFilePicker() { private int getSourceId(int position) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); switch (position) {
intent.setType("*/*"); case 1: return 1; // WhatsApp
intent.addCategory(Intent.CATEGORY_OPENABLE); case 2: return 2; // Website Hubungi Kami
default: return 0;
// Add multiple MIME types for different file types
String[] mimeTypes = {"image/*", "application/pdf", "text/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
try {
filePickerLauncher.launch(Intent.createChooser(intent, "Pilih File Pendukung"));
} catch (Exception e) {
Toast.makeText(this, "Error opening file picker: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
} }
} }
private String getFileName(Uri uri) { private int getIssueId(int position) {
String fileName = "File terpilih"; switch (position) {
try { case 1: return 4; // Koneksi EDC Bermasalah
android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null); case 2: return 5; // Permintaan Tambahan EDC
if (cursor != null && cursor.moveToFirst()) { case 3: return 6; // Pergantian EDC
int nameIndex = cursor.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME); default: return 0;
if (nameIndex != -1) { }
fileName = cursor.getString(nameIndex); }
}
cursor.close(); private int getMerchantId(int position) {
} switch (position) {
} catch (Exception e) { case 1: return 1; // Surabaya
// Return default name if error case 2: return 2; // Jakarta Selatan
case 3: return 3; // Jakarta Pusat
case 4: return 4; // Jakarta Barat
case 5: return 5; // Palembang
case 6: return 6; // Bogor Timur
case 7: return 7; // Bandung Utara
case 8: return 8; // Yogyakarta Selatan
case 9: return 9; // Cilacap Barat
case 10: return 10; // Bekasi Timur
case 11: return 11; // Tangerang Selatan
case 12: return 12; // Depok Tengah
case 13: return 13; // Kediri Kota
default: return 0;
}
}
private int getAssignId(int position) {
switch (position) {
case 1: return 1; // welno hedi prabowo putro jenaka prima
case 2: return 2; // rizqika
case 3: return 3; // budi
case 4: return 4; // binomo
case 5: return 5; // budi
case 6: return 6; // Irfan Muslim Saputra
default: return 0;
} }
return fileName;
} }
private void submitForm() { private void submitForm() {
@ -343,52 +382,59 @@ public class BantuanFormActivity extends AppCompatActivity {
btnKirim.setText("Mengirim..."); btnKirim.setText("Mengirim...");
// Prepare form data // Prepare form data
String terminalId = etTerminalId.getText().toString().trim(); String ticketCode = etTicketCode.getText().toString().trim();
String nomorTelepon = etNomorTelepon.getText().toString().trim(); int sourceId = getSourceId(spinnerSource.getSelectedItemPosition());
String deskripsiMasalah = etDeskripsiMasalah.getText().toString().trim(); int issueId = getIssueId(spinnerIssue.getSelectedItemPosition());
String jenisMasalah = spinnerJenisMasalah.getSelectedItem().toString(); int merchantId = getMerchantId(spinnerMerchant.getSelectedItemPosition());
int assignId = getAssignId(spinnerAssign.getSelectedItemPosition());
submitToAPI(terminalId, nomorTelepon, selectedDate, jenisMasalah, deskripsiMasalah); submitToAPI(ticketCode, sourceId, issueId, merchantId, assignId, selectedResolvedDate);
} }
private boolean validateForm() { private boolean validateForm() {
boolean isValid = true; boolean isValid = true;
// Validate Terminal ID // Validate Ticket Code
if (etTerminalId.getText().toString().trim().isEmpty()) { if (etTicketCode.getText().toString().trim().isEmpty()) {
etTerminalId.setError("Terminal ID wajib diisi"); etTicketCode.setError("Ticket Code wajib diisi");
isValid = false; isValid = false;
} }
// Validate Phone Number // Validate Source
if (etNomorTelepon.getText().toString().trim().isEmpty()) { if (spinnerSource.getSelectedItemPosition() == 0) {
etNomorTelepon.setError("Nomor telepon wajib diisi"); Toast.makeText(this, "Pilih Source", Toast.LENGTH_SHORT).show();
isValid = false; isValid = false;
} }
// Validate Date // Validate Issue
if (selectedDate.isEmpty()) { if (spinnerIssue.getSelectedItemPosition() == 0) {
Toast.makeText(this, "Pilih tanggal kejadian", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Pilih Issue", Toast.LENGTH_SHORT).show();
isValid = false; isValid = false;
} }
// Validate Issue Type // Validate Merchant
if (spinnerJenisMasalah.getSelectedItemPosition() == 0) { if (spinnerMerchant.getSelectedItemPosition() == 0) {
Toast.makeText(this, "Pilih jenis masalah", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Pilih Merchant", Toast.LENGTH_SHORT).show();
isValid = false; isValid = false;
} }
// Validate Description // Validate Assign
if (etDeskripsiMasalah.getText().toString().trim().isEmpty()) { if (spinnerAssign.getSelectedItemPosition() == 0) {
etDeskripsiMasalah.setError("Deskripsi masalah wajib diisi"); Toast.makeText(this, "Pilih Assign", Toast.LENGTH_SHORT).show();
isValid = false;
}
// Validate Resolved Date
if (selectedResolvedDate.isEmpty()) {
Toast.makeText(this, "Pilih tanggal resolved", Toast.LENGTH_SHORT).show();
isValid = false; isValid = false;
} }
return isValid; return isValid;
} }
private void submitToAPI(String terminalId, String nomorTelepon, String tanggalKejadian, private void submitToAPI(String ticketCode, int sourceId, int issueId, int merchantId,
String jenisMasalah, String deskripsiMasalah) { int assignId, String resolvedAt) {
String authToken = LoginActivity.getToken(this); String authToken = LoginActivity.getToken(this);
if (authToken == null || authToken.isEmpty()) { if (authToken == null || authToken.isEmpty()) {
@ -403,7 +449,7 @@ public class BantuanFormActivity extends AppCompatActivity {
executor.execute(() -> { executor.execute(() -> {
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
URL url = new URL("https://be-edc.msvc.app/tickets/create"); URL url = new URL("https://be-edc.msvc.app/tickets");
connection = (HttpURLConnection) url.openConnection(); connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
@ -415,22 +461,14 @@ public class BantuanFormActivity extends AppCompatActivity {
// Create JSON payload // Create JSON payload
JSONObject payload = new JSONObject(); JSONObject payload = new JSONObject();
payload.put("terminal_id", terminalId); payload.put("ticket_code", ticketCode);
payload.put("phone_number", nomorTelepon); payload.put("source_id", sourceId);
payload.put("incident_date", tanggalKejadian); payload.put("issue_id", issueId);
payload.put("issue_type", jenisMasalah); payload.put("merchant_id", merchantId);
payload.put("description", deskripsiMasalah); payload.put("status", "new");
payload.put("is_sla_violated", true);
// Add user info payload.put("assigned_to", assignId);
try { payload.put("resolved_at", resolvedAt);
JSONObject userData = LoginActivity.getUserDataAsJson(this);
if (userData != null) {
payload.put("user_name", userData.optString("name", ""));
payload.put("user_email", userData.optString("email", ""));
}
} catch (Exception e) {
// Continue without user info
}
// Send request // Send request
try (OutputStream os = connection.getOutputStream()) { try (OutputStream os = connection.getOutputStream()) {
@ -471,9 +509,6 @@ public class BantuanFormActivity extends AppCompatActivity {
// Clear form // Clear form
clearForm(); clearForm();
// Optionally go back to previous screen
// finish();
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(this, "Tiket berhasil dikirim!", Toast.LENGTH_LONG).show(); Toast.makeText(this, "Tiket berhasil dikirim!", Toast.LENGTH_LONG).show();
clearForm(); clearForm();
@ -511,24 +546,15 @@ public class BantuanFormActivity extends AppCompatActivity {
} }
private void clearForm() { private void clearForm() {
if (etTerminalId != null) etTerminalId.setText(""); if (etTicketCode != null) etTicketCode.setText("");
if (etNomorTelepon != null) etNomorTelepon.setText("");
if (etDeskripsiMasalah != null) etDeskripsiMasalah.setText("");
if (spinnerTanggalKejadian != null) spinnerTanggalKejadian.setSelection(0); if (spinnerSource != null) spinnerSource.setSelection(0);
if (spinnerJenisMasalah != null) spinnerJenisMasalah.setSelection(0); if (spinnerIssue != null) spinnerIssue.setSelection(0);
if (spinnerMerchant != null) spinnerMerchant.setSelection(0);
if (spinnerAssign != null) spinnerAssign.setSelection(0);
if (spinnerResolvedDate != null) spinnerResolvedDate.setSelection(0);
selectedDate = ""; selectedResolvedDate = "";
selectedFileName = "";
selectedFileUri = null;
if (uploadText != null) {
uploadText.setText("Pilih di sini");
uploadText.setTextColor(getResources().getColor(android.R.color.darker_gray));
}
// Reload user data for next form
loadUserData();
// Update button state after clearing form // Update button state after clearing form
updateButtonState(); updateButtonState();

View File

@ -1,188 +1,234 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="#f5f5f5"> android:background="#F5F5F5">
<!-- Custom AppBar --> <!-- Custom AppBar -->
<include layout="@layout/component_appbar_small" /> <include layout="@layout/component_appbar_small" />
<!-- Form Content --> <!-- Main Content -->
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1"
android:paddingHorizontal="16dp"
android:paddingTop="16dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical">
android:padding="16dp"
android:background="@android:color/white">
<TextView <!-- Form Card -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Formulir Helpdesk untuk Merchant" android:layout_marginBottom="16dp"
android:textSize="20sp" app:cardCornerRadius="12dp"
android:textStyle="bold" app:cardElevation="2dp"
android:textColor="@android:color/black" app:cardBackgroundColor="@android:color/white">
android:layout_marginBottom="8dp"/>
<TextView <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mohon isi data Anda pada formulir di bawah ini untuk melaporkan masalah yang terjadi."
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="24dp"/>
<!-- Terminal ID -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Terminal ID (TID)"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<EditText
android:id="@+id/et_terminal_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="123456789011"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="16dp"/>
<!-- Nomor Telepon -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nomor Telepon"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<EditText
android:id="@+id/et_nomor_telepon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="+62 8xxxxxxxxx"
android:inputType="phone"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="16dp"/>
<!-- Tanggal Kejadian -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tanggal Kejadian"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<Spinner
android:id="@+id/spinner_tanggal_kejadian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="16dp"/>
<!-- Jenis Masalah -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jenis Masalah"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<Spinner
android:id="@+id/spinner_jenis_masalah"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="16dp"/>
<!-- Deskripsi Masalah -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Deskripsi Masalah"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<EditText
android:id="@+id/et_deskripsi_masalah"
android:layout_width="match_parent"
android:layout_height="120dp"
android:hint="Tulis di sini..."
android:inputType="textMultiLine"
android:gravity="top"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="16dp"/>
<!-- Upload Dokumen -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Upload Dokumen Pendukung"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"/>
<LinearLayout
android:id="@+id/upload_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp"
android:background="@android:drawable/editbox_background"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true">
<TextView
android:id="@+id/upload_text"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:orientation="vertical"
android:text="Pilih di sini" android:padding="20dp">
android:textColor="@android:color/darker_gray"
android:textSize="14sp"/>
<TextView <!-- Form Title -->
android:layout_width="wrap_content" <TextView
android:layout_height="wrap_content" android:layout_width="match_parent"
android:text="+" android:layout_height="wrap_content"
android:textSize="24sp" android:text="Formulir Helpdesk untuk Merchant"
android:textColor="@android:color/darker_gray"/> android:textSize="18sp"
android:textStyle="bold"
android:textColor="#DE0701"
android:layout_marginBottom="8dp" />
</LinearLayout> <!-- Form Subtitle -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mohon isi data Anda pada formulir di bawah ini untuk melaporkan masalah yang terjadi."
android:textSize="14sp"
android:textColor="#666666"
android:layout_marginBottom="24dp"
android:lineSpacingExtra="2dp" />
<!-- Ticket Code Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ticket Code"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_ticket_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:hint="Masukkan kode tiket (contoh: #20240312)"
android:padding="16dp"
android:textSize="14sp"
android:textColorHint="#AAAAAA"
android:layout_marginBottom="20dp"
android:singleLine="true" />
<!-- Source Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Source"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="20dp"
android:padding="16dp" />
<!-- Issue Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Issue"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner_issue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="20dp"
android:padding="16dp" />
<!-- Merchant Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Merchant"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner_merchant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="20dp"
android:padding="16dp" />
<!-- Status Field (Read-only) -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Status"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:orientation="horizontal"
android:gravity="center_vertical"
android:padding="16dp"
android:layout_marginBottom="20dp">
<TextView
android:id="@+id/tv_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pengajuan"
android:textSize="14sp"
android:textColor="#666666" />
</LinearLayout>
<!-- Assign Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Assign To"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner_assign"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="20dp"
android:padding="16dp" />
<!-- Resolved Date Field -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Resolved Date"
android:textSize="14sp"
android:textColor="#333333"
android:layout_marginBottom="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner_resolved_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_marginBottom="12dp"
android:padding="16dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<!-- Submit Button --> <!-- Submit Button -->
<Button <LinearLayout
android:id="@+id/btn_kirim"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:layout_margin="16dp" android:orientation="vertical"
android:text="Kirim Sekarang" android:padding="16dp"
android:textColor="@android:color/white" android:background="@android:color/white"
android:textSize="16sp" android:elevation="4dp">
android:textStyle="bold"
android:background="@drawable/button_inactive_background" <Button
android:elevation="2dp" android:id="@+id/btn_kirim"
android:enabled="false"/> android:layout_width="match_parent"
android:layout_height="52dp"
android:text="Kirim Sekarang"
android:textSize="16sp"
android:textStyle="bold"
android:textAllCaps="false"
android:background="@android:color/darker_gray"
android:textColor="@android:color/white"
android:enabled="false"
android:stateListAnimator="@null"
android:elevation="0dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>