Page 1 of 1
Time Clock Help
Posted: Mon Jun 13, 2005 9:43 am
by sarbz
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!
Posted: Mon Jun 13, 2005 12:46 pm
by Sphen001
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
Code: Select all
<?php
// Get time logged on, as well as username, etc later
$time_in = microtime();
?>
Do the same for the logging out
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
?>
Hope this helps
Sphen001
Posted: Mon Jun 13, 2005 4:43 pm
by pickle
Here's some sample code that should do what you want
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);
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
+-----------+---------+------+---------+
| Field | Type | Null | Default |
+-----------+---------+------+---------+
| time | int | No | |
| username | varchar | No | |
| punch_in | bool | No | 0 |
| punch_out | bool | No | 0 |
+-----------+---------+------+---------+
Posted: Tue Jun 14, 2005 2:50 pm
by sarbz
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.
Posted: Tue Jun 14, 2005 3:42 pm
by SabbeRubbish
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.
If you need it soon, that's probably the best idea.
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

Posted: Tue Jun 14, 2005 3:59 pm
by Skara
Yeah, what ^ said. This really isn't that hard of a project at all. I'd do it, but I'm really busy with two other jobs. A project like this is just one that takes time.
Posted: Wed Jun 15, 2005 8:20 am
by sarbz
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!
Posted: Thu Jun 16, 2005 8:53 am
by sarbz
Anyone know what something like this would cost to have made?