I would like to create a user notification system using emails.
In context it is for employees (user type 1) to log onto my system and enter their timesheet (hours they’ve worked). I would like a notification to be sent to their supervisors (also members of the 'users' table (user type 2) that they have entered the information and it is ready to be checked.
Currently I have a database with a table 'users' which stores information such as 'id' (PRIMARY) AUTO INCREMENTING, 'first_name', 'last_name', 'email', 'user_type', etc.
I know how to sent emails in PHP, and I have a fully functioning log in system however it is these notifications which I cannot get my head around with how to implement.
My current code is not Object-Oriented as it is beyond my skill level at this time.
I would like something simple, it doesn’t have to be perfect. Any suggestions are greatly appreciated.
When an employee successfully enters a timesheet, can you not fetch the list of users and then send them all an e-mail? I’m guessing the timesheet is a web form, so just trigger some code when the form gets submitted.
For example:
However, what might be nicer, is to periodically check (by using a
cronjob) for new timesheets and then e-mail all the supervisors about any new time sheets.I won’t write the full PHP for this, it’s more of a pseudocode outline:
You might then set that to run every day, meaning that supervisors would get a single summary e-mail every day, rather than being bombarded with an e-mail for every submitted timesheet.