For consultancies that bill on an hourly basis - lawyers,accountants et al - time tracking is a critical part of the billingprocess. For small- and medium-size organizations, resource tracking,allocation and analysis is essential for business efficiency and planning.This article addresses both requirements by teaching you how to build atimesheet system to track and analyze work hours with PHP and MySQL.
Of the five options available on the main menu, I've just taken care of two - or, if you want to get technical about it, 40% of the project is now complete. I'll do one more, just to put me on the right side of the halfway mark, and then shut shop for the day.
Since I'm asleep on my feet, I think I'll skip the data entry and report generation code for the moment - this is bound to be complex, and I need all my wits about me to tackle them. Instead, I think I'll handle the last item on the menu next - the "logout.php" script.
<?
// logout.php - destroy user session
// destroy session data
session_start();
session_destroy();
// redirect to index page
header("Location:index.html");
?>
I don't even think this qualifies to be called a script -
it's just three lines of code. All it does is destroy the current session and redirect the browser back to the index page to await a new login.
And that's about it for the moment. We've accomplished a fair amount of work so far - we've got the requirements down, designed a database schema, put together scripts to handle user login and logout, and written all code necessary to display project and task information.
In the concluding part of this article, I will be discussing the scripts which handle timesheet display, record addition and deletion, and report generation. These scripts, especially the ones that handle report generation, will be substantially more complex than the ones you've just seen, so I need to give them some thought before sitting down to write the code. Why don't you do the same, and we'll get together soon to compare notes?
Note: All examples in this article have been tested on Linux/i586 with Apache 1.3.12, mySQL 3.23 and PHP 4.06. Examples are illustrative only, and are not meant for a production environment. YMMV!