Customizing Bamboo Invoice

In a previous entry, I wrote about using Bamboo Invoice to create and mange the invoicing for my small software company. Now I want to walk through customizing the invoice to include some extra things.

The Problem

The base invoice is nice, but I really want to have the invoice due date printed on the invoice. Sure the default invoice has the payment terms and the invoice date but I did not want my customers to have to guess when their payment was due. What would be great is if there was a line on the invoice that said “Due” and had a date based off of the payment terms I already set.

Getting the Date

Luckily, all of the data needed to display the due date is already included with Bamboo Invoice. All I need to do is to display it. Bamboo Invoice uses two files to display the invoice, view.php and pdf.php. Both of these files are pretty similar, one shows an HTML version of the invoice and the other shows a PDF version.

First I need to get the date the invoice was created and then add in the number of days from the payment terms. Since the views each have an invoice object called $row I can just access the attribute dateIssued to get when the invoice was created.


This data is stored as a MYSQL DATE field so I needed to convert it back into a unix date and time in order to display it. Bamboo Invoice provides a useful function mysql_to_unix that does this exact thing.


The next step I had to do was to format the Due Date in a human readable format, such as August 16, 2007 and not as the unix time of ‘1187308680’. To do this I hacked some date conversions using the PHP date and mktime functions.

 <?php echo date("F d, Y", mktime(0,0,0,

Basically this is taking the Month (date “m”), Day (date “d”), and Year (date “Y”) of the invoice and creating a new date in unix time but formatted as “Month day, four digit year”. Now some PHP hacker might ask why am I converting the date from unix to a number and back to unix again instead of just using the date from mysql_to_unix like so:

   echo date("F d, Y", mysql_to_unix($row->dateIssued));

The reason is we need to now add in the number of days that a payment is due in. By converting the unix time to an integer we can easily add in our days, which are stored as an integer in Bamboo Invoice.

 <?php echo date("F d, Y", mktime(0,0,0,
    date("d",mysql_to_unix($row->dateIssued)) + $this->settings_model->getSetting('daysPaymentDue'),

Now we just need to add some pretty HTML and we have a nice snippet to show the due date.

   <?php echo date("F d, Y", mktime(0,0,0,
      date("d",mysql_to_unix($row->dateIssued)) + $this->settings_model->getSetting('daysPaymentDue'),

Since we want this to be included in both the HTML and PDF versions, it would be best to extract this snippet into a separate file to include into the view files. This will also make upgrade easier because we are not putting as much logic in the source files distributed by the Bamboo Invoice team. If you save this snippet into a file in the bamboo_system_files/application/views/includes/ directory you will have an easy way to add this to each view. I named mine


The HTML view file is called bamboo_system_files/application/views/invoices/view.php. Open this file and look for a good place that you want to display your due date, I chose to put mine right under the Payment Terms. Since we setup the code in an include file all we have to add to this is the line:

<?php $this->load->view('includes/'); ?>

Now we should have a Due Date on our invoices in the web browser.

PDF View

The last step is to modify the PDF view. This process is exactly like the HTML view but using the file bamboo_system_files/application/views/invoices/pdf.php.


We have now added a simple Due Date calculation to our invoices for Bamboo Invoices. Although it was simple, there are a lot of other things we can now do this these simple concepts.

Example of the due date on an invoice
Example of the due date on an invoice

Another customization I added to my invoices is a link to an online form that will display the amount and invoice number for my customers to pay.

If you have any questions, feel free to ask me and I can help.

Eric Davis


  1. Alex says:

    This looks like a great addition to the generated invoices, thanks for sharing it.

    I wonder if the code could indeed be simplified a little though – how about something like this?

    echo date(“F d, Y”
    , intval(mysql_to_unix($row->dateIssued))
    + ($this->settings_model->getSetting(‘daysPaymentDue’) * 86400)

    I didn’t test this, so I really have no idea if it works as desired, but perhaps it will. :)

  2. Alex says:

    Ok, fine – I’ll put it all on one line.

    echo date(“F d, Y”, intval(mysql_to_unix($row->dateIssued)) + ($this->settings_model->getSetting(‘daysPaymentDue’) * 86400));

  3. sawan says:

    the software is just gr8.

    you should think of expanding the application more to add features list payment gateway and things like that!

  4. Derek Allard says:

    Hello Sawan, I’m the developer of BambooInvoice, and I’m thrilled to hear your kind words. Thanks. The features list is always growing, but there aren’t currently any plans to integrate payment options into Bamboo. That said, I’ll keep it in mind.

    You can follow the development of Bamboo on my blog if you’re interested. Eric has linked to it above.

    @Eric: let me publicly thank you for your BambooInvoice articles! They are well presented, informative, and I consider them a big help to the community. Thank you sir!

  5. gadi says:

    Great stuff! thanks.

    One thing with my version of Bamboo Invoice you need to change the settings from ‘daysPaymentDue’ to ‘days_payment_due’
    Otherwise you get an error on the invoice view.

    My code will be…

    Due Date:
    date(“d”,mysql_to_unix($row->dateIssued)) + $this->settings_model->getSetting(‘days_payment_due’),


  6. guest says:

    Thanks for this. Is it possible to change the design of the invoice, in terms of layout and colour?

Comments are closed.