Developing New Scripts
Directory Structure
The scripts that make up the system are seperated into just two directories. The main root directory contains all the scripts that are called directly from links in the system. Scripts or portions of scripts that are included in one or more of the main scripts are held in the includes/ sub-directory. The scripts to create the database are held under the sql directory - these are sql scripts created by mysqldump. Documentation is under the doc/ sub-directory where this manual and the FAQ are held. Font files required by pdf.php the R&OS class file for creating pdf reports are held in the fonts/ sub-directory. Formatting style sheets are held under the css - see the themes section under getting started above.
Construction of new scripts should make use of the following building blocks that are used throughout the system.
session.inc
This page must be included after the page has set the variable $PageSecurity to an appropriate integer (see the security schema section), session.inc has the following functons:
- Establishes a session if none already exists and checks that an authorised user is logged in - if so it checks that the user is authorised for the specific page being called, based on the value of $PageSecurity.
- It in turn includes the scripts:
- config.php - this script contains all the configuration settings for the system. Including session.inc in the script at the start ensures that all system variables defined in config.php are available to the script.
- ConnectDB.inc - this script initiates a connection to the database and contains all the database abstraction functions. When interacting with the database, only functions defined in this script are used not the mysql specific functions, since a change in database would be otherwise be difficult to effect. By using this file, only the functions in this script need to be modified for any other database to be used.
header.inc
This file should be included after the variable $title has been set to the name of the page. This file relies on config.php being already loaded, so session.inc (which in turn includes config.php) must be included before header.inc. The code in this script has the following functions:
- Sets up the normal system banner with the links to the menu, item selection, customer and supplier selection pages.
- Sets the style sheet used throughout the system.
footer.inc
This file contains the small logo, company name and copyright notice with the closing