1

I am trying to build an online attendance system where employees sign in and check in daily except for weekends and vacations.

so , my idea was to create a daily attendance record as a table in the database.

Attendance_date_daily         date
Employee_ID                   number(auto generated)
Check_in_time                 time
Check_out_time                time
Attendence_status             varchar

I am using codeigniter v 3.0.0

it's easy to create a model to get the current time and save it in the database when the user check in/out. but the problem is that, if the user was absent for a day or more , then the system will not create a record for those days.

moreover, i can't create the records beforehand. since i don't know when the user will have his/her vacation and working days may differ.

what is the best way to create and manage those daily records?

alkhamis
  • 49
  • 3
  • 9
  • ps: my supervisor's solution was to create a the records automatically everyday with mysql and create a "not confirmed" statues . when users press check in/out, the system will save them in the database. then, it will check the previous records for "not confirmed statues" and ask the user to choose if he was absent/vacation/forgot to check in/out. – alkhamis Jul 06 '15 at 20:07
  • 3
    There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.I would suggest that you find a development forum (perhaps [quora](http://www.quora.com/Computer-Programming)?) to work out generalities. Then, when/if you have specific coding issues, come back to StackOverflow and we'll be glad to help. – Jay Blanchard Jul 06 '15 at 20:08

1 Answers1

1

One possible solution may be to allow the employees to do their check-in each day normally which would populate the database for those days.

In order to add the absence records for those who have not checked in you could use CRON or something similar to schedule a task at perhaps midnight each day. Use this task to target a url that would run a method in a controller that will check employees against the daily records. Obviously for those whom have checked in no action will be performed, although for those who have not and are not marked as on vacation or not working you update the database to add the absence records.

With a system like this you would typically invoke the url to perform the update using whatever system you use with wget or something similar to 'load' the url and force it to run. A security consideration also would be that you'll want to add in a secret key as a GET parameter or something similar so that the method can check that it's being invoked via the task and not e.g. someone visiting the url by comparing the GET parameter with a stored key that you've set.

Daniel Waghorn
  • 2,997
  • 2
  • 20
  • 33
  • 1
    my supervisor suggested that i use event scheduler in mysql to create the records daily at midnight. then users can check out until that time which theoretically will work i don't think that there is a security concern since you can use: defined('BASEPATH') OR exit('No direct script access allowed'); in codeigniter unless if i misunderstood that part thanks for your replay, you confirmed my supervisor plan. – alkhamis Jul 06 '15 at 22:57
  • Checking the `BASEPATH` constant will secure it to an extent although to be sure I'd definitely still include something like the key verification since a user in theory could still access the page maliciously whilst authenticated and it'd reset the database for the day. – Daniel Waghorn Jul 06 '15 at 23:09
  • 1
    how about this : $this->input->is_cli_request() which ensures that this controller cannot be accessed directly from a url. – alkhamis Jul 07 '15 at 11:28
  • @DanielWaghorn you rock mate – Zionnite Jun 13 '23 at 09:42