User authentication is temporarily unavailable. If this situation persists, please inform your Wiki Admin.

Extensions FAQ

What

Extensions provides a basic method to develop and distribute integrated customisations for Simple Invoices

Why

Previously there was no extension system for Simple Invoices meaning that if a customization to a particular page was required the main Simple Invoices file for that page would have to be edited - Which made it a pain in the ass to develop, to very hard to distribute and pretty much impossible for that customization to be included into the normal Simple Invoices

The Simple Invoices extension system main goal is to make extending Simple Invoices to meet your exact requirement a lot easier and possible to distribute

How extensions work

index.php is the main file in Simple Invoices that does all the work to say what files are to be loaded when and what to present on screen

  • normally based on the url
    • ie. index.php?module=invoices&view=manage

In the above example url index.php would load the relevant files to show the Manage Invoices page

  • it would load all the normal stuff to run Simple Invoices
  • then the php code for this page from ./modules/invoices/manage.php would be loaded
  • then it would load the template for this page from ./templates/default/invoices/manage.tpl
  • and then present a combination of the above file to the browser

The extension system provide a way to override and/or extended what is loaded via index.php

In index.php there are checks at each main include section to see if an extension has been enabled and if it has either include the extensions version of the requested file instead of the normal file or include it inconjunction with the normal file

For an extension to be included correctly the same directory structure for the normal file must be repeated in the extensions directory (ie. ./extensions/gene/modules/invoices/itemised.php would replace the normal file ./modules/invoices/itemised.php if the Gene extension was enabled)

To explain how it works i'll use a quick example from the Gene extension

  • What was required:
    • A customisation of the New Itemised invoice page with additional fields to be available
  • New fields meant that the function that inserts the products into the invoice items table will have to be altered
    • The normal function for this is stored in ./include/sql_queries.php
    • index.php includes the extensions version of sql_queries.php
      • ./extensions/gene/include/sql_queries.php
    • along with the normal ./include/sql_queries.php
    • only the new functions/classes were placed in ./extensions/gene/include/sql_queries.php all the normal functions stayed unedited in ./include/sql_queries.php
  • The logic of the itemised screen has to be altered
    • By including the following file
      • ./extensions/gene/module/invoices/itemised.php
      • it overwrote the default itemised.php file (./modules/invoices/itemised.php)
  • A custom view of the New Itemised invoice page was required
    • By including the following file
      • ./extensions/gene/templates/default/invoices/itemised.tpl
      • it overwrote the default itemised.tpl file (./modules/invoices/itemised.tpl)
  • With these new files loaded a custom version of the Itemised invoices page was displayed
    • and developed in a way to complement Simple Invoices

How to enable an extension

In the current version 2010.x, Extensions can be enabled / disabled by Registering / Unregistering at: Settings → Extensions and clicking on the first green icon on the left of ech extension entry.

In earlier versions:

  • Edit ./config/config.php
  • go to the Extensions section,
  • find the extension you wish to enable
  • and change the $extension['entensions_name']['enabled'] from 0 to 1 (refer below)
####################
/* Extensions */
####################
//1 = enabled 0 = disabled
//name is the director in ./extensions which it lives
$extension['gene']['name'] = "gene";
$extension['gene']['description'] = "gene's purchase order based system extension";
$extension['gene']['enabled'] = "0";
$extension['test']['name'] = "test extension";
$extension['test']['description'] = "this is a test";
$extension['test']['enabled'] = "0";
// dev guys to enable extensions via your local.config.php file
####################
/* Extensions */
####################
//1 = enabled 0 = disabled
//name is the director in ./extensions which it lives
$extension['gene']['name'] = "gene";
$extension['gene']['description'] = "gene's purchase order based system extension";
$extension['gene']['enabled'] = "1";
$extension['test']['name'] = "test extension";
$extension['test']['description'] = "this is a test";
$extension['test']['enabled'] = "0";
// dev guys to enable extensions via your local.config.php file

How to create an extension

  1. Create a directory in ./extensions with the name of your extension
    1. ie ./extensions/gene
  2. Add your extensions details into config/config.php
    1. ie.
      $extension['gene']['name'] = "gene";
      $extension['gene']['description'] = "gene's purchase order based system extension";
      $extension['gene']['enabled'] = "1";
  3. Review index.php to see how the extension system work
  4. include your customised file in their respective directory in ./extensions/'your extension/ ..

Discussion

frank pietruszewski, 2009/03/02 00:40

Tried the 'gene' , enabled it and made a couple invoice & quote. The problem is, instead of it saying PO#, it shows Custom Filed 2 : data The data is correct, custom field words needs to be fixed. Also when I go to save the invoice or quote, it errors BUT makes the form. Good Luck,

Frank
justin, 2009/06/02 04:43

Thanks for the update Frank

note: this extension is not complete and very specific to a certain Simple Invoices user

Cheers

Justin

 
 | wiki/extensions_faq.txt · Last modified: 2016/10/11 06:15 (external edit)