-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
792 additions
and
430 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
app/src/main/java/com/example/intellimills/AdminDashboardActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
package com.example.intellimills; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
public class AdminDashboardActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_admin_dashboard); | ||
|
||
// Get a reference to the btnPermitApproval button | ||
Button btnPermitApproval = findViewById(R.id.btnPermitApproval); | ||
|
||
// Set an OnClickListener for the btnPermitApproval button | ||
btnPermitApproval.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
// Open the PermitApprovalActivity when the button is clicked | ||
Intent permitApprovalIntent = new Intent(AdminDashboardActivity.this, PermitApprovalActivity.class); | ||
startActivity(permitApprovalIntent); | ||
} | ||
}); | ||
|
||
// Add similar code for other buttons to open their respective activities | ||
// For example, if you have a button for Extraction Approval, add code here to open ExtractionApprovalActivity. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 78 additions & 3 deletions
81
app/src/main/java/com/example/intellimills/DriverLeaveFormActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,89 @@ | ||
package com.example.intellimills; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.widget.Toast; | ||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.database.DatabaseReference; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class DriverLeaveFormActivity extends AppCompatActivity { | ||
|
||
private EditText nameEditText; | ||
private EditText idEditText; | ||
private EditText reasonEditText; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_driver_leave_form); | ||
|
||
nameEditText = findViewById(R.id.name3); | ||
idEditText = findViewById(R.id.Id); | ||
reasonEditText = findViewById(R.id.editTextText4); | ||
|
||
Button clearButton = findViewById(R.id.button11); | ||
clearButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
// Clear all EditText fields | ||
nameEditText.setText(""); | ||
idEditText.setText(""); | ||
reasonEditText.setText(""); | ||
} | ||
}); | ||
|
||
Button submitButton = findViewById(R.id.button7); | ||
submitButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
// Get the user's input | ||
String name = nameEditText.getText().toString(); | ||
String id = idEditText.getText().toString(); | ||
String reason = reasonEditText.getText().toString(); | ||
|
||
// Validate the input and submit to Firebase | ||
if (!name.isEmpty() && !id.isEmpty() && !reason.isEmpty()) { | ||
submitLeaveToFirebase(name, id, reason); | ||
} else { | ||
Toast.makeText(DriverLeaveFormActivity.this, "Please fill in all fields.", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void submitLeaveToFirebase(String name, String id, String reason) { | ||
// Replace this with your Firebase database reference | ||
DatabaseReference leaveRef = FirebaseDatabase.getInstance().getReference("leave_requests"); | ||
|
||
// Create a unique key for the leave request | ||
String leaveId = leaveRef.push().getKey(); | ||
|
||
// Create a map to store the leave data | ||
Map<String, Object> leaveData = new HashMap<>(); | ||
leaveData.put("name", name); | ||
leaveData.put("id", id); | ||
leaveData.put("reason", reason); | ||
|
||
// Push the data to Firebase | ||
leaveRef.child(leaveId).updateChildren(leaveData) | ||
.addOnCompleteListener(new OnCompleteListener<Void>() { | ||
@Override | ||
public void onComplete(@NonNull Task<Void> task) { | ||
if (task.isSuccessful()) { | ||
Toast.makeText(DriverLeaveFormActivity.this, "Submission successful.", Toast.LENGTH_SHORT).show(); | ||
} else { | ||
Toast.makeText(DriverLeaveFormActivity.this, "Submission failed. Please try again.", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/example/intellimills/PermitApprovalActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.example.intellimills; | ||
|
||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TableRow; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.google.firebase.database.DataSnapshot; | ||
import com.google.firebase.database.DatabaseError; | ||
import com.google.firebase.database.DatabaseReference; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import com.google.firebase.database.ValueEventListener; | ||
|
||
public class PermitApprovalActivity extends AppCompatActivity { | ||
|
||
private DatabaseReference databaseReference; | ||
private static final String TAG = "PermitApprovalActivity"; | ||
|
||
private Button updateButton; | ||
private TableRow secondRow; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_permit_approval); | ||
|
||
// Replace "your_project_name" with your actual Firebase project name | ||
databaseReference = FirebaseDatabase.getInstance().getReference().child("Harvest Applications"); | ||
|
||
updateButton = findViewById(R.id.btnUpdate); | ||
secondRow = findViewById(R.id.secondRow); // Assuming you have a TableRow with this ID in your XML layout | ||
|
||
updateButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
fetchDataFromFirebaseForSecondRow(); | ||
} | ||
}); | ||
|
||
fetchDataFromFirebaseForSecondRow(); | ||
} | ||
|
||
private void fetchDataFromFirebaseForSecondRow() { | ||
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() { | ||
@Override | ||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) { | ||
// Assuming "Harvest Applications" is a direct child of the root | ||
DataSnapshot harvestApplicationsSnapshot = dataSnapshot.child("Harvest Applications"); | ||
|
||
// Assuming the second row data is stored under a specific child (e.g., "record1") | ||
DataSnapshot secondRowDataSnapshot = harvestApplicationsSnapshot.child("record1"); | ||
|
||
// Assuming you have TextViews in the second row with IDs userarea, usercounty, etc. | ||
updateTextView(secondRow, R.id.userarea, secondRowDataSnapshot.child("userarea").getValue(String.class)); | ||
updateTextView(secondRow, R.id.usercounty, secondRowDataSnapshot.child("usercounty").getValue(String.class)); | ||
// Add similar lines for other fields | ||
|
||
// Update the UI for other fields as needed | ||
} | ||
|
||
@Override | ||
public void onCancelled(@NonNull DatabaseError databaseError) { | ||
Log.w(TAG, "fetchDataFromFirebaseForSecondRow:onCancelled", databaseError.toException()); | ||
} | ||
}); | ||
} | ||
|
||
private void updateTextView(TableRow row, int textViewId, String value) { | ||
TextView textView = row.findViewById(textViewId); | ||
if (textView != null) { | ||
textView.setText(value); | ||
} | ||
} | ||
} |
Oops, something went wrong.