Timeclock: using FPDF to generate timesheets

Background

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:

2 thoughts on “Timeclock: using FPDF to generate timesheets”

    1. Good question femos. In this example the fpdfHelper() class is the name I gave the class in my fpdf.php file that is included at the top of this example. The fpdfHelper class extends the core fpdf class and has functions I set up specifically for the timesheet generation. See this post (http://www.rdustinwebstudio.com/code/2009/08/25/get-started-generating-pdfs-today-part-2-extendingreuse/) for a more in depth example of how I set up the fpdfHelper class.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">