Commit 305f54f6 authored by Felizia Tiburcio's avatar Felizia Tiburcio

test queries

parent 29048426
......@@ -215,7 +215,7 @@ header {
color:#FEFCFD;
}
#order-table, #receipt-table {
#order-table, #receipt-table, #scheduling-table {
display: flex;
justify-content: center;
}
......
......@@ -9,4 +9,20 @@
{% block content %}
<h1 class='view-title'>Schedule </h1>
<table id="scheduling-table">
<tr>
<th>Week</th>
<th>Staff</th>
<th>Role</th>
<th>Day-Mgr</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
<td>Alfreds Futterkiste</td>
</tr>
</table>
{% endblock %}
......@@ -18,16 +18,23 @@ class Employee(models.Model):
class EmployeeRole(models.Model):
ROLES = [
('Cashier', 'Cashier'),
('Preparation', 'Preparation'),
('Cleaning', 'Cleaning'),
]
IS_MANAGER = [
('Y', 'Y'),
('N', 'N'),
]
role_id = models.AutoField(primary_key=True)
role_date = models.DateField()
employee = models.ForeignKey(Employee, models.DO_NOTHING)
role_description = models.CharField(max_length=20, choices=ROLES)
is_manager = models.CharField(max_length=1)
is_manager = models.CharField(max_length=1, choices=IS_MANAGER)
class Meta:
managed = False
......
......@@ -22,11 +22,48 @@ def inventory(request):
def schedule(request):
for employee in Employee.objects.raw('SELECT * FROM employee'):
print(employee.employee_name)
# for role in EmployeeRole.objects.all():
# print(role.role_description)
# filter employees and roles by date in order
for row in EmployeeRole.objects.raw('''SELECT * FROM employeerole RIGHT JOIN employee ON (employeerole.employee_id=employee.employee_id)
ORDER BY role_date ASC'''):
print(row.employee_name, row.role_description, row.role_date)
# filter employees and roles in alphabetical order
for row in EmployeeRole.objects.raw('''SELECT * FROM employeerole RIGHT JOIN employee ON (employeerole.employee_id=employee.employee_id)
ORDER BY employee_name, role_date ASC'''):
print(row.employee_name, row.role_description, row.role_date)
# filter employees by roles
for row in EmployeeRole.objects.raw('''SELECT role_id,employee_name, role_date FROM employeerole RIGHT JOIN employee ON (employeerole.employee_id=employee.employee_id)
WHERE role_description ILIKE 'cashier' '''):
print(row.employee_name, row.role_description, row.role_date, '- filter by roles')
# filter employees by manager for the day
for row in EmployeeRole.objects.raw('''SELECT role_id,employee_name, role_date FROM employeerole RIGHT JOIN employee ON (employeerole.employee_id=employee.employee_id)
WHERE is_manager ILIKE 'Y' '''):
print(row.employee_name, row.role_description, row.role_date, '- manager for the day')
# filter employees by week
for row in EmployeeRole.objects.raw('''SELECT * FROM employeerole RIGHT JOIN employee ON (employeerole.employee_id=employee.employee_id)
WHERE role_date <= '2025-09-06' AND role_date >= '2025-09-01' ORDER BY role_date '''):
pass
# employeeroles = {}
# for role in EmployeeRole.objects.raw('''SELECT * FROM employeerole'''):
# print dates when they're managers
# if role.is_manager == 'Y':
# print(role.employee.employee_name, 'is a manager on', role.role_date)
#
# employeename = role.employee.employee_name
# employeerole = role.role_description
# day_mgr = []
# if role.employee.employee_name not in employeeroles:
# employeeroles[employeename] = employeerole
#
# print(employeeroles)
return render(request, "blizzardblast/templates/schedule.html")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment