Time Clock Help
Moderator: General Moderators
Time Clock Help
Hello,
This is my first post here. So far, I've been learning php by using and editing pre-written scripts. I'm now looking for a time-clock script for employees to punch in and out with on my company's intranet.
I've searched everywhere, and can't find anything that will work. I've found several scripts for tracking project times, but nothing that offers a simple "punch-in" & "punch-out" solution.
If anyone can point me in the right direction, I'd appreciate it. I know enough to edit code, but not enough to write my own from scratch. My intranet is hosted on a pc with php 5, and mysql 4.1.
Thanks!
This is my first post here. So far, I've been learning php by using and editing pre-written scripts. I'm now looking for a time-clock script for employees to punch in and out with on my company's intranet.
I've searched everywhere, and can't find anything that will work. I've found several scripts for tracking project times, but nothing that offers a simple "punch-in" & "punch-out" solution.
If anyone can point me in the right direction, I'd appreciate it. I know enough to edit code, but not enough to write my own from scratch. My intranet is hosted on a pc with php 5, and mysql 4.1.
Thanks!
-
Sphen001
- Forum Contributor
- Posts: 107
- Joined: Thu Mar 10, 2005 12:24 pm
- Location: Land of the Beaver
Hi,
If you need what I think you do, you're looking to record the times a person logs on, and logs out. What you could do is set up a script that gets the current time, and store it in a database. Then do the same when the user logs out, and compare the two times, and determine the time in between.
The login script could be something like this
Do the same for the logging out
Hope this helps 
Sphen001
If you need what I think you do, you're looking to record the times a person logs on, and logs out. What you could do is set up a script that gets the current time, and store it in a database. Then do the same when the user logs out, and compare the two times, and determine the time in between.
The login script could be something like this
Code: Select all
<?php
// Get time logged on, as well as username, etc later
$time_in = microtime();
?>Code: Select all
<?php
$time_out = microtime();
// Get the total time logged in
$total_time = $time_out - $time_in;
// $total_time is the amount of time spent logged in. You'll have to change it in to a meaningful time using the date() function
?>Sphen001
Here's some sample code that should do what you want
Of course there's some stuff to do like setup your connection, do some error checking, and output the form the user would submit, but that's the general idea of the logic.
Your table could look something like this:
Code: Select all
$curr_time = time();
$user = $_POST['username'];
if(isset($_POST['punch_out']))
{
$query = "INSERT INTO timeclock (time,username,punch_out) VALUES ('$curr_time','$user','1')";
}
else if(isset($_POST['punch_in']))
{
$query = "INSERT INTO timeclock (time,username,punch_in) VALUES('$curr_time','$user','1')";
}
$result = mysql_query($query);Your table could look something like this:
Code: Select all
+-----------+---------+------+---------+
| Field | Type | Null | Default |
+-----------+---------+------+---------+
| time | int | No | |
| username | varchar | No | |
| punch_in | bool | No | 0 |
| punch_out | bool | No | 0 |
+-----------+---------+------+---------+Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Just had a meeting with the "powers that be", and they want something more complex now:(
Here's what they want in a web-based time-clock system:
-punch in and out with pin number specific to an employee
-rounding of time to the 1/4 hour.(ie: 8:07=8:00, 8:08=8:15)
-seperate groups of employess (departments)
-supervisor's have access to only their department's employees' time data
-supervisor's can change in and out times after employees punch in or out
-some way to record an edit made by a supervisor
-ability for supervisors to mark days as vacations or sick days.
They also want to be able to view reports on all of this data.
I should probably post this in the job hunt section now, since I believe it's beyond my capabilities and I can't find anything that does what I want.
If anyone is interested, let me know. I'm sure this could be quite a profitable system. I know of several companies that would purchase something like this.
Here's what they want in a web-based time-clock system:
-punch in and out with pin number specific to an employee
-rounding of time to the 1/4 hour.(ie: 8:07=8:00, 8:08=8:15)
-seperate groups of employess (departments)
-supervisor's have access to only their department's employees' time data
-supervisor's can change in and out times after employees punch in or out
-some way to record an edit made by a supervisor
-ability for supervisors to mark days as vacations or sick days.
They also want to be able to view reports on all of this data.
I should probably post this in the job hunt section now, since I believe it's beyond my capabilities and I can't find anything that does what I want.
If anyone is interested, let me know. I'm sure this could be quite a profitable system. I know of several companies that would purchase something like this.
-
SabbeRubbish
- Forum Newbie
- Posts: 10
- Joined: Fri May 20, 2005 7:15 am
- Location: Belgium
If you need it soon, that's probably the best idea.sarbz wrote:I should probably post this in the job hunt section now, since I believe it's beyond my capabilities and I can't find anything that does what I want.
But if you have a few months left, why not start learning about some database design and build up your application bit by bit? (I mean one bit at a time, not literally bit by bit
It'll be so much more rewarding for you that way
Unfortunately, it has to be completed fairly soon 
I'll have to keep looking for something that's been written already. If I can't find anything this week, they're going to sub the job out to a consulting firm (who will then sub it out to another firm, and then a sales rep, and then finally it will get to a programmer).
Thanks for all the input!
I'll have to keep looking for something that's been written already. If I can't find anything this week, they're going to sub the job out to a consulting firm (who will then sub it out to another firm, and then a sales rep, and then finally it will get to a programmer).
Thanks for all the input!