diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc
index 3209f0b..39f3760 100644
Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ
diff --git a/core/templates/core/log_attendance.html b/core/templates/core/log_attendance.html
index 2b22f30..71cae69 100644
--- a/core/templates/core/log_attendance.html
+++ b/core/templates/core/log_attendance.html
@@ -43,7 +43,10 @@
-
+
+
+
Manage Resources
+
{% for checkbox in form.workers %}
diff --git a/core/templates/core/manage_resources.html b/core/templates/core/manage_resources.html
index 0de0a83..b79cd4c 100644
--- a/core/templates/core/manage_resources.html
+++ b/core/templates/core/manage_resources.html
@@ -7,10 +7,22 @@
Manage Resources
-
Toggle the active status of workers, projects, and teams. Inactive items will be hidden from selection forms.
+
Quickly toggle the active status of workers, projects, and teams. Inactive items will be hidden from selection forms.
+
+
+
+
+
+ Status updated successfully.
+
+
+
+
+
+
-
@@ -37,8 +49,7 @@
| Name |
ID Number |
- Status |
- Action |
+ Active Status |
@@ -46,26 +57,18 @@
| {{ worker.name }} |
{{ worker.id_no }} |
-
- {% if worker.is_active %}
- Active
- {% else %}
- Inactive
- {% endif %}
- |
-
+
+
+
|
{% empty %}
- | No workers found. |
+ | No workers found. |
{% endfor %}
@@ -84,8 +87,7 @@
| Name |
Description |
- Status |
- Action |
+ Active Status |
@@ -93,26 +95,18 @@
| {{ project.name }} |
{{ project.description|truncatechars:50 }} |
-
- {% if project.is_active %}
- Active
- {% else %}
- Inactive
- {% endif %}
- |
-
+
+
+
|
{% empty %}
- | No projects found. |
+ | No projects found. |
{% endfor %}
@@ -132,8 +126,7 @@
Name |
Supervisor |
Workers Count |
- Status |
- Action |
+ Active Status |
@@ -142,26 +135,18 @@
{{ team.name }} |
{{ team.supervisor.username|default:"-" }} |
{{ team.workers.count }} |
-
- {% if team.is_active %}
- Active
- {% else %}
- Inactive
- {% endif %}
- |
-
+
+
+
|
{% empty %}
- | No teams found. |
+ | No teams found. |
{% endfor %}
@@ -172,4 +157,57 @@
-{% endblock %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/core/views.py b/core/views.py
index c500732..241de5c 100644
--- a/core/views.py
+++ b/core/views.py
@@ -8,6 +8,7 @@ from django.db.models import Sum, Q
from django.core.mail import send_mail
from django.conf import settings
from django.contrib import messages
+from django.http import JsonResponse
from .models import Worker, Project, Team, WorkLog, PayrollRecord
from .forms import WorkLogForm
from datetime import timedelta
@@ -178,6 +179,13 @@ def toggle_resource_status(request, model_type, pk):
obj.is_active = not obj.is_active
obj.save()
+ if request.headers.get('x-requested-with') == 'XMLHttpRequest':
+ return JsonResponse({
+ 'success': True,
+ 'is_active': obj.is_active,
+ 'message': f"{obj.name} is now {'Active' if obj.is_active else 'Inactive'}."
+ })
+
return redirect('manage_resources')
def payroll_dashboard(request):
@@ -294,4 +302,4 @@ def payslip_detail(request, pk):
'record': record,
'logs': logs,
}
- return render(request, 'core/payslip.html', context)
\ No newline at end of file
+ return render(request, 'core/payslip.html', context)