Timeclock: using FPDF to generate timesheets


Read background information on the design of the timeclock system!

Single vs. Multiple timesheets

Since each student’s timesheet is formated the same way, whether it is generated as a single timesheet or as part of multiple timesheets, I developed a class to create the timesheets.

Figure 1: A sample timesheet
Figure 1: A sample timesheet

In the class is a function called outputPDF which accepts one argument: an array of the timesheet values. Inside the function we begin creating the page.

Now that we’ve got the timesheet ready let’s create a function that determines the timesheet type.

There are a few things we want to accomplish with this function.

  • include and instantiate the fpdf library
  • Call the FPDF page numbering function and create the first page:
  • Set the page title:
  • check to see if the type is single and if so, generate the timesheet:
  • if the type isn’t single check to see if it is multiple and if so, generate the timesheets:

So all together it looks like this:

Timeclock: simplifying timesheets


One of the cool things about the timeclock is the ability to generate pdf timesheets on demand. The Hartman Union Building (HUB) administrative assistant is tasked with producing timesheets for approximately 100 student employees every two weeks.


The old time clock system generated arbitrary numbers for each student employee. At the end of each two week pay period the administrative assistant had to manually enter each employee’s time clock number, generate and print a timesheet report. As you can imagine, this was a tedious and time consuming task.

Problem Solved!

Before I began creating the timeclock I talked to the administrative assistant to identify what she liked and disliked about the current system. The problem outlined above was her greatest dislike. I created the new timeclock system to revolve around the unique student ID number issued to students upon their acceptance to the university. This allows the administrative assitant to select an employee by their name and generate a timesheet for that individual. Even better, I went one step further to reduce her workload: now she can generate a single pdf file with all employees’ timesheets ready to print. This takes only a few minutes instead of the entire afternoon!

Read more about how I generate the timesheets!