====== Smart Invoice Numbering ====== ===== Description ====== I wanted to output my invoice numbers into this form: 000022, 000023, etc... I decided to do this with a Smarty plugin, so that I wouldn't have to change any of the core code, only my invoice templates. ===== Installation ===== Upload the PHP file **function.invoice_number.php** inside the plug-in folder: /simpleinvoices/include/smarty_plugins/ to enable the plugin for all Simple Invoices' template files (all templates inside /simpleinvoices/templates/default). You're not ready yet. The invoice templates (/templates/invoices/) won't load the plug-in. So, you also need to upload the file **function.invoice_number.php** into this folder: /templates/invoices/{yourinvoicetemplate}/plugins/. Now the plug-in is automatically loaded and usable. ===== Download ===== You can download the zip file [[http://www.gelderblomwebdesign.nl/public/simpleinvoices/smarty_invoice_number.zip|here]]. \\ - or refer the below [[#Code]] section ===== Examples ===== ==== Basic usage ==== In most templates, the invoice number is printed with this code:
{$invoice.id}Change it to this form:
{invoice_number invoiceId=$invoice.id}This will invoke the Smarty function that adds the 0's, so that the invoice number is exactly 0 characters long, eg: 000022. ==== Specify the length ==== If you want to specify the length of your invoice number (default is 6), you can easily change this. Just add the parameter length=8, or any other length, to the smarty code. For example:
{invoiceNumber invoiceId=$invoice.id length=8}===== Author and copyright ===== This code is donated to the Simple Invoices community and is therefor part of the Simple Invoices project and freely usable ([[http://simpleinvoices.org/philosophy|philosophy]]). The original author is [[http://www.gelderblomwebdesign.nl/|Gelderblom Webdesign]], a Dutch webdesign company. ===== Code ===== File: function.invoice_number.php
~~DISCUSSION~~