Creating Your Own Invoice Templates

Custom invoice templates live in application/views/invoice/templates. You need the following files:

  • views/invoice/templates/*your_template_name*
  • views/invoice/templates/*your_template_name*/view.php
  • views/invoice/templates/*your_template_name*/pdf.php

It is recommended that you create your own Argentum Module for your invoice templates.

view.php is the main invoice template. It is a basic Kohana view file. You should put any custom styles inside a <style> block at the top of the file. This is required for the DomPDF PDF generator to work properly. This file just needs to be the main body HTML, not with the entire HTML headers.

pdf.php is the PDF version of the invoice file. This should be a complete HTML file. It is recommended to include your view.php file for consistency. You can do this by running the following line in your pdf.php file:

Please note that if you include your own images in the invoice file, DomPDF does not support PNG24 with an alpha channel.

View Variables

There is only one main view variable in the invoice template: $invoice. However, this object has many properties you can access to display your information. They are:

  • $invoice->id - The invoice number
  • $invoice->title - The invoice title
  • $invoice->comments - The comments on the invoice, if any
  • $invoice->client - The client object model that the invoice is assigned to.
  • $invoice->find_operation_types - Returns an array of all operation types assigned to this invoice. Each array member is also an array with the following key/value pairs: name, rate, time.
  • $invoice->find_related('tickets') - Returns a database result object of all tickets assigned to this invoice.
  • $invoice->find_related('non_hourly') - Returns a database result object of all non-hourly items assigned to this invoice.
  • $invoice->find_sales_tax() - Returns the sales tax for this invoice.