diff --git a/.env b/.env index e69de29..8dbdbea 100644 --- a/.env +++ b/.env @@ -0,0 +1,6 @@ +GOOGLE_API_KEY=AIzaSyAh5HbTtCHsO_ZWAtCtn_q5h2_Jw7tEfe8 +HUGGING_FACE_API_KEY=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 + +SMS_ACCOUNT_SSID_API_KEY=AC954136eee66cc8ba187c7722f5840d13 +SMS_ACCOUNT_AUTH_API_KEY=d1501d7b07f1625cce8b4c46c1d5a8f1 +SMS_FROM_NUMBER=+12085516281 \ No newline at end of file diff --git a/core/__pycache__/admin.cpython-312.pyc b/core/__pycache__/admin.cpython-312.pyc index 1e396db..996044c 100644 Binary files a/core/__pycache__/admin.cpython-312.pyc and b/core/__pycache__/admin.cpython-312.pyc differ diff --git a/core/__pycache__/forms.cpython-312.pyc b/core/__pycache__/forms.cpython-312.pyc index 0f03eef..16f83b1 100644 Binary files a/core/__pycache__/forms.cpython-312.pyc and b/core/__pycache__/forms.cpython-312.pyc differ diff --git a/core/__pycache__/models.cpython-312.pyc b/core/__pycache__/models.cpython-312.pyc index e747907..a176e1b 100644 Binary files a/core/__pycache__/models.cpython-312.pyc and b/core/__pycache__/models.cpython-312.pyc differ diff --git a/core/__pycache__/urls.cpython-312.pyc b/core/__pycache__/urls.cpython-312.pyc index 2ff7a39..99c1537 100644 Binary files a/core/__pycache__/urls.cpython-312.pyc and b/core/__pycache__/urls.cpython-312.pyc differ diff --git a/core/__pycache__/views.cpython-312.pyc b/core/__pycache__/views.cpython-312.pyc index 4db1db4..ce94179 100644 Binary files a/core/__pycache__/views.cpython-312.pyc and b/core/__pycache__/views.cpython-312.pyc differ diff --git a/core/admin.py b/core/admin.py index d8118d2..304d70a 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Problem,BedsInventory,O2Inventory,Ambulance,StaffMember +from .models import Problem,BedsInventory,O2Inventory,Ambulance,StaffMember,Labor,Attendance,Task,TaskAssignment from import_export.admin import ImportExportModelAdmin @@ -21,4 +21,24 @@ class AmbuAdmin(ImportExportModelAdmin): class StaffAdmin(ImportExportModelAdmin): list_display=['name','role','department'] -admin.site.register(StaffMember,StaffAdmin) \ No newline at end of file +admin.site.register(StaffMember,StaffAdmin) + + +# workforce admin +class labourAdmin(ImportExportModelAdmin): + list_display=['name'] +admin.site.register(Labor,labourAdmin) + +class AttendenceAdmin(ImportExportModelAdmin): + list_display=['labor','date','status'] +admin.site.register(Attendance,AttendenceAdmin) + + +# task assignment admin +class TaskAdmin(ImportExportModelAdmin): + list_display=['title','description'] +admin.site.register(Task,TaskAdmin) + +class TaskAssignAdmin(ImportExportModelAdmin): + list_display=['labor','status'] +admin.site.register(TaskAssignment,TaskAssignAdmin) \ No newline at end of file diff --git a/core/forms.py b/core/forms.py index ee2b356..a161c46 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,6 +1,6 @@ from .models import Problem from django import forms -from .models import BedsInventory, Ambulance, StaffMember, O2Inventory +from .models import BedsInventory, Ambulance, StaffMember, O2Inventory,TaskAssignment class ProblemForm(forms.ModelForm): class Meta: @@ -31,3 +31,21 @@ class O2InventoryForm(forms.ModelForm): class Meta: model = O2Inventory fields = '__all__' + + +# attendence form +from .models import Attendance + +class AttendanceForm(forms.ModelForm): + class Meta: + model = Attendance + fields = ['labor', 'status'] + +# assignment list +class TaskAssignmentForm(forms.ModelForm): + class Meta: + model = TaskAssignment + fields = ['labor', 'task', 'date_assigned', 'status'] + widgets = { + 'date_assigned': forms.DateInput(attrs={'type': 'date'}), + } \ No newline at end of file diff --git a/core/migrations/0004_labor_attendance.py b/core/migrations/0004_labor_attendance.py new file mode 100644 index 0000000..2da5478 --- /dev/null +++ b/core/migrations/0004_labor_attendance.py @@ -0,0 +1,30 @@ +# Generated by Django 5.0.7 on 2024-07-28 02:21 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_ambulance_bedsinventory_o2inventory_staffmember'), + ] + + operations = [ + migrations.CreateModel( + name='Labor', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='Attendance', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField()), + ('status', models.CharField(choices=[('Present', 'Present'), ('Absent', 'Absent')], max_length=10)), + ('labor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.labor')), + ], + ), + ] diff --git a/core/migrations/0005_task_taskassignment.py b/core/migrations/0005_task_taskassignment.py new file mode 100644 index 0000000..01c6cc7 --- /dev/null +++ b/core/migrations/0005_task_taskassignment.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.7 on 2024-07-28 03:21 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_labor_attendance'), + ] + + operations = [ + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=100)), + ('description', models.TextField()), + ], + ), + migrations.CreateModel( + name='TaskAssignment', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date_assigned', models.DateField()), + ('status', models.CharField(max_length=10)), + ('labor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.labor')), + ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.task')), + ], + ), + ] diff --git a/core/migrations/0006_alter_task_description.py b/core/migrations/0006_alter_task_description.py new file mode 100644 index 0000000..74fbf4e --- /dev/null +++ b/core/migrations/0006_alter_task_description.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.7 on 2024-07-28 03:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0005_task_taskassignment'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='description', + field=models.CharField(choices=[('Sewage & Drainage', 'Sewage & Drainage'), ('Waste Management', 'Waste Management'), ('Public Transport', 'Public Transport'), ('Public Health Services', 'Public Health Services'), ('Education and Cultural', 'Education and Cultral'), ('Services', 'Services'), ('Water Treatment and Supplies', 'Water Treatment and Supplies')], max_length=60), + ), + ] diff --git a/core/migrations/__pycache__/0004_labor_attendance.cpython-312.pyc b/core/migrations/__pycache__/0004_labor_attendance.cpython-312.pyc new file mode 100644 index 0000000..1bf7299 Binary files /dev/null and b/core/migrations/__pycache__/0004_labor_attendance.cpython-312.pyc differ diff --git a/core/migrations/__pycache__/0005_task_taskassignment.cpython-312.pyc b/core/migrations/__pycache__/0005_task_taskassignment.cpython-312.pyc new file mode 100644 index 0000000..e29acaf Binary files /dev/null and b/core/migrations/__pycache__/0005_task_taskassignment.cpython-312.pyc differ diff --git a/core/migrations/__pycache__/0006_alter_task_description.cpython-312.pyc b/core/migrations/__pycache__/0006_alter_task_description.cpython-312.pyc new file mode 100644 index 0000000..d347611 Binary files /dev/null and b/core/migrations/__pycache__/0006_alter_task_description.cpython-312.pyc differ diff --git a/core/models.py b/core/models.py index 569fdb0..d6e169f 100644 --- a/core/models.py +++ b/core/models.py @@ -78,4 +78,39 @@ class StaffMember(models.Model): last_updated = models.DateField() def __str__(self): - return f"ID: {self.id} - Name: {self.name} - Role: {self.role}" \ No newline at end of file + return f"ID: {self.id} - Name: {self.name} - Role: {self.role}" + + +# attendence systems + +class Labor(models.Model): + name = models.CharField(max_length=255) + + def __str__(self): + return self.name + +class Attendance(models.Model): + labor = models.ForeignKey(Labor, on_delete=models.CASCADE) + date = models.DateField() + status = models.CharField(max_length=10, choices=[('Present', 'Present'), ('Absent', 'Absent')]) + + def __str__(self): + return f'{self.labor} - {self.date} - {self.status}' + + +# task assign +class Task(models.Model): + title = models.CharField(max_length=100) + description = models.CharField(max_length=60, choices=Problem.PROBLEM_TYPE_CHOICES) + + def __str__(self): + return self.title + +class TaskAssignment(models.Model): + labor = models.ForeignKey(Labor, on_delete=models.CASCADE) + task = models.ForeignKey(Task, on_delete=models.CASCADE) + date_assigned = models.DateField() + status = models.CharField(max_length=10) # e.g., 'Completed', 'Pending' + + def __str__(self): + return f'{self.labor.name} - {self.task.title} - {self.date_assigned} - {self.status}' \ No newline at end of file diff --git a/core/static/core/image/workforce.svg b/core/static/core/image/workforce.svg new file mode 100644 index 0000000..8fd89c3 --- /dev/null +++ b/core/static/core/image/workforce.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/templates/core/app/add_workforce.html b/core/templates/core/app/add_workforce.html new file mode 100644 index 0000000..c314478 --- /dev/null +++ b/core/templates/core/app/add_workforce.html @@ -0,0 +1,19 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+
+
+
+ {% csrf_token %} +

Add Labor

+ + + +
+
+
+
+ +{% endblock index %} \ No newline at end of file diff --git a/core/templates/core/app/assign_task.html b/core/templates/core/app/assign_task.html new file mode 100644 index 0000000..1627ca0 --- /dev/null +++ b/core/templates/core/app/assign_task.html @@ -0,0 +1,30 @@ +{% extends 'core/partial/base.html' %} +{% load static %} + +{% block index %} + +
+
+

Assign Task

+
+ {% csrf_token %} + {{ form.as_p }} + +
+
+
+ +{% endblock index %} \ No newline at end of file diff --git a/core/templates/core/app/mark_attendance.html b/core/templates/core/app/mark_attendance.html new file mode 100644 index 0000000..e533658 --- /dev/null +++ b/core/templates/core/app/mark_attendance.html @@ -0,0 +1,27 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+
+

Mark Attendance

+
+ {% csrf_token %} + {{ form.as_p }} + +
+
+
+ +{% endblock index %} \ No newline at end of file diff --git a/core/templates/core/app/task_assignments.html b/core/templates/core/app/task_assignments.html new file mode 100644 index 0000000..a7b69a4 --- /dev/null +++ b/core/templates/core/app/task_assignments.html @@ -0,0 +1,79 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + +
+
+

Public Queries

+
+ + + + + + + + + + + + + {% for query in public_problem %} + + + + + + + + + {% endfor %} + +
NameDescriptionSeriousnessImageProblem TypeStatus
{{ query.name }}{{ query.description }}{{ query.seriousness }} + + {{ query.problem_type }}{{ query.status }}
+
+
+

Tasks

+ + + + + + + + + {% for task in tasks %} + + + + + {% endfor %} + +
TitleDescription
{{ task.title }}{{ task.description }}
+ +

Task Assignments

+ + + + + + + + + + + {% for assignment in assignments %} + + + + + + + {% endfor %} + +
Labor NameTask TitleDate AssignedStatus
{{ assignment.labor.name }}{{ assignment.task.title }}{{ assignment.date_assigned }}{{ assignment.status }}
+
+ + +{% endblock index %} \ No newline at end of file diff --git a/core/templates/core/app/welcome.html b/core/templates/core/app/welcome.html index 4d08f46..98979c2 100644 --- a/core/templates/core/app/welcome.html +++ b/core/templates/core/app/welcome.html @@ -66,12 +66,14 @@

IMC Inventory
-
diff --git a/core/templates/core/app/workforce.html b/core/templates/core/app/workforce.html new file mode 100644 index 0000000..2da9fba --- /dev/null +++ b/core/templates/core/app/workforce.html @@ -0,0 +1,37 @@ +{% extends 'maintain/partial/base.html' %} +{% load static %} +{% block index %} + + +
+

Attendance Records

+ Add WorkForce + Add Attendance + Assigned Tasks Details + Assign Tasks + + + + + + + + + + {% for record in attendance_records %} + + + + + + {% empty %} + + + + {% endfor %} + +
LaborDateStatus
{{ record.labor.name }}{{ record.date }}{{ record.status }}
No records found.
+ +
+ +{% endblock index %} \ No newline at end of file diff --git a/core/urls.py b/core/urls.py index bf8b98a..fb999ce 100644 --- a/core/urls.py +++ b/core/urls.py @@ -18,5 +18,11 @@ path('health/o2', views.healtho2, name='healtho2'), path('health/ambu', views.healthambu, name='healthambu'), - + path('add-labor/', views.add_labor, name='add_labor'), + path('mark-attendance/', views.mark_attendance, name='mark_attendance'), + path('workforce/', views.workforce, name='workforce'), + + # task + path('task-assignments/', views.task_assignments, name='task_assignments'), + path('assign-task/', views.assign_task, name='assign_task'), ] diff --git a/core/views.py b/core/views.py index f5f782c..63d6117 100644 --- a/core/views.py +++ b/core/views.py @@ -6,7 +6,11 @@ from django.views.decorators.csrf import csrf_exempt import json from core.LLM_Model.test import get_response -from core.models import Problem,BedsInventory,O2Inventory,Ambulance,StaffMember +from core.models import Problem,BedsInventory,O2Inventory,Ambulance,StaffMember,TaskAssignment,Task + +from .models import Attendance, Labor +from .forms import AttendanceForm,TaskAssignmentForm +from django.utils import timezone @login_required def check(request): return redirect("core:user_index") @@ -96,3 +100,59 @@ def healtho2(request): } return render(request,'core/app/o2.html',context) + + +# workforce +@login_required +def workforce(request): + attendance_records = Attendance.objects.all() + context={ + 'attendance_records': attendance_records + } + return render(request,'core/app/workforce.html',context) + +@login_required +def add_labor(request): + if request.method == 'POST': + name = request.POST.get('name') + if name: + Labor.objects.create(name=name) + return redirect('core:workforce') + return render(request, 'core/app/add_workforce.html') + +@login_required +def mark_attendance(request): + if request.method == 'POST': + form = AttendanceForm(request.POST) + if form.is_valid(): + date_today = timezone.now().date() + labor = form.cleaned_data['labor'] + if Attendance.objects.filter(labor=labor, date=date_today).exists(): + return redirect('core:workforce') + attendance = form.save(commit=False) + attendance.date = date_today + attendance.save() + return redirect('core:workforce') + else: + form = AttendanceForm() + return render(request, 'core/app/mark_attendance.html', {'form': form}) + + +# task assignment + +def task_assignments(request): + public_problem=Problem.objects.all() + tasks = Task.objects.all() + assignments = TaskAssignment.objects.select_related('labor', 'task').all() + return render(request, 'core/app/task_assignments.html', {'assignments': assignments,'tasks': tasks,'public_problem':public_problem}) + +def assign_task(request): + if request.method == 'POST': + form = TaskAssignmentForm(request.POST) + if form.is_valid(): + form.save() + return redirect('core:task_assignments') # Redirect to a view that lists task assignments + else: + form = TaskAssignmentForm() + + return render(request, 'core/app/assign_task.html', {'form': form}) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 3a963bb..fe6a960 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/db/chroma.sqlite3 b/db/chroma.sqlite3 index 49e4fc3..74fae29 100644 Binary files a/db/chroma.sqlite3 and b/db/chroma.sqlite3 differ diff --git a/dummy.csv b/dummy.csv index 32d910f..5e20336 100644 --- a/dummy.csv +++ b/dummy.csv @@ -1,21 +1,31 @@ -id,machinery,hours_of_operation,description,status,due_date -1,Excavator,120,Routine maintenance check.,N,2024-07-28 01:37:17 -2,Bulldozer,350,Oil change and filter replacement.,g,2024-07-29 10:15:00 -3,Crane,5000,Complete overhaul.,N,2024-07-30 09:00:00 -4,Loader,450,General maintenance.,g,2024-08-01 11:30:00 -5,Dump Truck,1500,Brake inspection.,N,2024-08-03 14:20:00 -6,Excavator,200,Hydraulic system check.,g,2024-08-05 13:25:00 -7,Bulldozer,300,Engine tune-up.,N,2024-08-07 08:10:00 -8,Crane,4200,Structural inspection.,g,2024-08-09 16:00:00 -9,Loader,800,Transmission service.,N,2024-08-12 10:40:00 -10,Dump Truck,2200,Exhaust system repair.,g,2024-08-15 12:00:00 -11,Excavator,250,Undercarriage inspection.,N,2024-08-17 09:50:00 -12,Bulldozer,350,Filter change.,g,2024-08-20 15:00:00 -13,Crane,4800,Electrical system check.,N,2024-08-22 14:10:00 -14,Loader,600,Coolant system service.,g,2024-08-25 11:30:00 -15,Dump Truck,1800,Tire replacement.,N,2024-08-28 08:00:00 -16,Excavator,300,Engine repair.,g,2024-08-30 10:15:00 -17,Bulldozer,400,Hydraulic fluid change.,N,2024-09-02 13:00:00 -18,Crane,4900,Maintenance and calibration.,g,2024-09-05 12:30:00 -19,Loader,700,General inspection.,N,2024-09-08 15:00:00 -20,Dump Truck,1600,Brake system check.,g,2024-09-10 09:45:00 +id,labor,task,date_assigned,status +1,68,1,2024-07-28,Completed +2,69,2,2024-07-28,Pending +3,70,3,2024-07-28,Completed +4,71,4,2024-07-28,Pending +5,72,5,2024-07-28,Completed +6,73,1,2024-07-28,Pending +7,74,2,2024-07-28,Completed +8,75,3,2024-07-28,Pending +9,76,4,2024-07-28,Completed +10,77,5,2024-07-28,Pending +11,78,1,2024-07-28,Completed +12,79,2,2024-07-28,Pending +13,80,3,2024-07-28,Completed +14,81,4,2024-07-28,Pending +15,82,5,2024-07-28,Completed +16,83,1,2024-07-28,Pending +17,84,2,2024-07-28,Completed +18,85,3,2024-07-28,Pending +19,86,4,2024-07-28,Completed +20,87,5,2024-07-28,Pending +21,88,1,2024-07-28,Completed +22,89,2,2024-07-28,Pending +23,90,3,2024-07-28,Completed +24,91,4,2024-07-28,Pending +25,92,5,2024-07-28,Completed +26,93,1,2024-07-28,Pending +27,94,2,2024-07-28,Completed +28,95,3,2024-07-28,Pending +29,96,4,2024-07-28,Completed +30,97,5,2024-07-28,Pending \ No newline at end of file