AdminEntry
9 years agoQrew Cadet
Conditionally counting records based on field on new record
The setup:
Employees { Timesheet_Employees (1:M) { Employee Records (1:M)
EMPLOYEES
Employee_Name,
etc. (this table captures basic employee info.)
TIMESHEETS (This table captures information about the shift being worked. The header portion of a timesheet)
Timesheet_Date,
Supervisor_Name,
etc...
TIMESHEET_EMPLOYEES (children records to TIMESHEETS and to EMPLOYEES. Each Employee may be part of one or more Timesheets.) There is a Many-to-Many relationship between TIMESHEETS and EMPLOYEES through this table. This table captures a record for each shift that the employee works. One employee may work more than one shifts in any given day.
Related_Timesheet,
Related_Employee,
Start_Time,
End_Time,
Per_Diem, etc.
.
The Per Diem field is a Boolean field. Employees are only allowed to have 1 per diem on any given day that they work (only one Per Diem per day regardless of how many shifts they work).
So if I'm the employee, I may be working the AM shift with my supervisor Paul, and he gives me my per diem for the day (he checks the per diem box on my employee record for this shift). Then in the evening - same day - I may work another shift, this time with supervisor Ryan. Ryan doesn't know that I already received my per diem for the day, so he checks the per diem box on my employee record for the evening shift. Now I have 2 per diems in one day.
I need to be able to determine when an employee (in EMPLOYEES) has been given the per diem by his supervisor for the day, so that he doesn't accidentally get another per diem on the same day from another supervisor.
My thoughts so far revolve around conditionally counting the number of per diems the Employee has where the date of the record (not the Date Created, but the Timesheet Date) is equal to the date of the current timesheet, and then use a form rule to hide the per diem box when that count is > 0. I just can't seem to figure out how to execute it.
Any thoughts on how to do this? Or any suggestions on a better approach?
Thanks in advance.
Employees { Timesheet_Employees (1:M) { Employee Records (1:M)
EMPLOYEES
Employee_Name,
etc. (this table captures basic employee info.)
TIMESHEETS (This table captures information about the shift being worked. The header portion of a timesheet)
Timesheet_Date,
Supervisor_Name,
etc...
TIMESHEET_EMPLOYEES (children records to TIMESHEETS and to EMPLOYEES. Each Employee may be part of one or more Timesheets.) There is a Many-to-Many relationship between TIMESHEETS and EMPLOYEES through this table. This table captures a record for each shift that the employee works. One employee may work more than one shifts in any given day.
Related_Timesheet,
Related_Employee,
Start_Time,
End_Time,
Per_Diem, etc.
.
The Per Diem field is a Boolean field. Employees are only allowed to have 1 per diem on any given day that they work (only one Per Diem per day regardless of how many shifts they work).
So if I'm the employee, I may be working the AM shift with my supervisor Paul, and he gives me my per diem for the day (he checks the per diem box on my employee record for this shift). Then in the evening - same day - I may work another shift, this time with supervisor Ryan. Ryan doesn't know that I already received my per diem for the day, so he checks the per diem box on my employee record for the evening shift. Now I have 2 per diems in one day.
I need to be able to determine when an employee (in EMPLOYEES) has been given the per diem by his supervisor for the day, so that he doesn't accidentally get another per diem on the same day from another supervisor.
My thoughts so far revolve around conditionally counting the number of per diems the Employee has where the date of the record (not the Date Created, but the Timesheet Date) is equal to the date of the current timesheet, and then use a form rule to hide the per diem box when that count is > 0. I just can't seem to figure out how to execute it.
Any thoughts on how to do this? Or any suggestions on a better approach?
Thanks in advance.