Sei sulla pagina 1di 326

PHP Report Maker 9 Help

PHP Report Maker 9 Help

Table of Contents
1. PHP Report Maker 9.................................................................................................................. 3
1.1 What's New ......................................................................................................................... 3
1.2 System Requirements ......................................................................................................... 9
1.3 Installation and Uninstallation .......................................................................................... 10
1.4 License and Ordering Information .................................................................................... 11
1.5 Technical Support ............................................................................................................. 11
1.6 Disclaimer of Warranty ..................................................................................................... 12
1.7 Third-party Tools ............................................................................................................... 12
1.8 Introduction to PHP and MySQL ...................................................................................... 14
1.9 Preparing Your Data .......................................................................................................... 22
1.10 Quick Start ...................................................................................................................... 24
1.11 Project Setup................................................................................................................... 29
1.11.1 Data Source Setup.................................................................................................... 29
1.11.2 PHP Settings ............................................................................................................. 36
1.11.3 HTML Settings .......................................................................................................... 41
1.11.4 Security Settings....................................................................................................... 46
1.11.5 Generate Settings .................................................................................................... 53
1.11.6 Table Setup .............................................................................................................. 56
1.11.7 Field Setup ............................................................................................................... 62
1.11.8 Chart Setup .............................................................................................................. 82
1.11.9 Gantt Chart Setup .................................................................................................... 89
1.11.10 Using Custom View ................................................................................................ 96
1.11.11 Detail and Summary Report Setup ...................................................................... 101
1.11.12 Crosstab Report Setup ......................................................................................... 106
1.11.13 Dashboard Setup.................................................................................................. 111
1.11.14 Compatibility Properties Setup ............................................................................ 114
1.11.15 Server Events and Client Scripts .......................................................................... 118
1.11.16 Custom Templates ............................................................................................... 145
1.11.17 Custom Files ......................................................................................................... 150
1.11.18 Custom Fields ....................................................................................................... 155
1.11.19 Linked Tables ....................................................................................................... 157
1.11.20 Multi-Language Project ........................................................................................ 162

PHP Report Maker 9 Help


1.12 Application Root ........................................................................................................... 168
1.13 Project File .................................................................................................................... 170
1.14 Tools .............................................................................................................................. 171
1.15 FusionCharts ................................................................................................................. 190
1.16 Customizing Template .................................................................................................. 202
1.16.1 Control File ............................................................................................................. 205
1.16.2 System Functions ................................................................................................... 208
1.16.3 Template Object Properties ................................................................................... 220
1.16.4 Using User Code ..................................................................................................... 239
1.16.5 Template Tags ........................................................................................................ 242
1.17 Tutorials ........................................................................................................................ 244
1.17.1 Connecting Remote MySQL using PHPMaker Connection Script .......................... 244
1.17.2 Advanced Security - User ID Security ..................................................................... 247
1.17.3 Advanced Security - Static User Level Security ...................................................... 253
1.17.4 Advanced Security - Dynamic User Level Security ................................................. 258
1.17.5 Custom View .......................................................................................................... 264
1.17.6 Detail and Summary Report ................................................................................... 269
1.17.7 Crosstab Report ..................................................................................................... 276
1.17.8 Drill Down Report .................................................................................................. 283
1.17.9 Dashboard Report .................................................................................................. 294
1.17.10 Custom Template ................................................................................................. 298
1.17.11 Chart..................................................................................................................... 303
1.17.12 Gantt Chart .......................................................................................................... 306
1.17.13 Compatibility Properties - Integrating with existing PHPMaker project ............. 322

PHP Report Maker 9 Help

1. PHP Report Maker 9

PHP Report Maker is a powerful reporting tool that can generate dynamic PHP Web reports
from MySQL, PostgreSQL, Microsoft Access, Microsoft SQL Server and Oracle
database. You can instantly create live detail and summary reports or crosstabs reports
for your Websites. JavaScript (HTML 5) charts (column, bar, line, pie, area, doughnut,
multi-series and stacked chart) and Flash charts (Funnel, Candlestick and Gantt chart) are
supported. The generated Web pages are pure PHP, no server side or client-side component
is required. PHP Report Maker is designed for high flexibility, numerous options enable you
to generate the reports that best suits your needs. The generated codes are clean and easyto-customize. The PHP scripts can be run on Windows servers
(MySQL/PostgreSQL/Access/MSSQL/Oracle) or Linux/Unix servers
(MySQL/PostgreSQL/Oracle). PHP Report Maker can save you tons of time and is suitable for
both beginners and experienced developers alike.

Also See:
What's New in PHP Report Maker 9(See 1.1)
License and ordering(See 1.4)

1.1 What's New

What's New in PHP Report Maker 9

Linked Tables from Multiple Databases


Now you can add Linked Tables from other databases of different database type

PHP Report Maker 9 Help

Custom Fields
Add custom fields to a table or view with SQL expression.

PHP Report Maker 9 Help

Dropdown Selection Lists


Show the options in dropdown panel (supports SELECT, RADIO and CHECKBOX) with minwidth and max-height settings.

Multi-column Radio button list

Multi-column Checkbox list

PHP Report Maker 9 Help

Selection list (select-one) / Single


column radio button list

Selection list (select-multiple) /


Single column checkbox list

Option Template for Dropdown Selection Lists


Show options in HTML with JsRender template.

PHP Report Maker 9 Help

Session Keep Alive and Session Timeout


Keeps session alive by Ajax or show session timeout countdown to remind users.

Simplified Client Side Events and "fields" jQuery Plugin


Add client side events easily and manipulate/validate the fields quickly with PHP Report
Maker's "fields" jQuery plugin.

PHP Report Maker 9 Help

Import/Export of Theme Settings

Import/Export Feature of Multi-Language Property Editor

New Language Selection Buttons


Use button group with tooltip.

More Server Events

Language_Load - For customizing the language phrases, fired after the language
file is loaded.

More Advanced Settings

PHP Report Maker 9 Help

Format project file - Add indentation to XML nodes in the project file
Allow login by session variables - For use with User_CustomValidate server event
Session timeout period (minutes) - Specifies the session time-out period if the user
does not refresh or request a page
Session keep alive interval (seconds) - Specifies the interval to send Ajax request to
the server for keeping the session alive
Session time out countdown period (seconds) - Specifies the countdown period
before session ends
Use ADOdb driver for MySQL - Use the full ADOdb driver for MySQL instead of the
lite version (ewmysql.php)
Reduce image size only (image resize) - Specifies if enlarging image is preferred
(Migrated from previous Image Resize extension)
Always keep aspect ratio (image resize) - Specifies if aspect ratio should be kept
(Migrated from previous Image Resize extension)

More

Use mysqli extension by default


Anonymous User becomes a built-in dynamic User Levels
Image Resize functionality (does not require Image Resize extension anymore)
SelectLimit() support for MSSQL >= 2005
Global array for passing server side values to client side
"addoption" and "newoption" client side event for lookup fields
JavaScript alerts replaced by Modal dialog
jQuery and JsRender updated
Multi-Language support for reCAPTCHA and JsCalendar
QRCode/BarCode Custom View Tags combined
A new built-in "plain" theme
UTF-8 output files if project charset is utf-8
PHPMailer updated
Setting PHPMailer properties in Email_Sending server event
mobile_detect.php updated and mobile-detect.js adopted
Bootstrap 3.3.6
Many other minor improvements

1.2 System Requirements


PHP Report Maker

Windows XP/2003/Vista/2008/2012/7/8/10

PHP Report Maker requires a few other system files. If you do not have latest version of
these files, you may experience ActiveX errors. To update your system, go the Microsoft
download pages listed below.

Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack (vbrun60sp6.exe)
Microsoft Windows Script 5.7 (Windows XP)
Microsoft Windows Script 5.7 (Windows Server 2003)
MSXML Parser 3.0
IIS Express (only required if you want to use IIS Express as testing web server)

If you use Microsoft Access, SQL Server or Oracle, PHP Report Maker requires the following
database drivers to connect to the database:

PHP Report Maker 9 Help

Microsoft Data Access Components (MDAC) 2.8 (for Microsoft Access and SQL
Server)
Microsoft Jet 4.0 Service Pack 8 (SP8) (for Microsoft Access <= 2003)
2007 Office System Driver: Data Connectivity Components (for Microsoft Access
2007)
Microsoft Access Database Engine 2010 Redistributable (for Microsoft Access 2010)
Microsoft SQL Server 2012 Native Client (X86 Package) (for Microsoft SQL Server
2005/2008/2012)
Oracle Client (for Oracle)

Server

Linux/Unix (MySQL/PostgreSQL/Oracle) or Windows


(MySQL/PostgreSQL/Access/MSSQL/Oracle) web server
PHP >= 5.3

Browser

IE 9+, Chrome/Firefox/Safari/Opera (current stable version and the


version that preceded it).
Adobe Flash Player 8 or later (optional, only required for Funnel, Candlestick and
Gantt charts)

1.3 Installation and Uninstallation


Before you install PHP Report Maker, you must log in Windows as an user
with administrative privileges.
Important

PHP Report Maker 9 can co-exist with previous version of PHP Report Maker. You do NOT
need to uninstall previous version of PHP Report Maker if you don't want to.
Double-click on the downloaded installer to start the installation process. Follow the prompts
and change the settings whenever necessary.
To uninstall PHP Report Maker, go to [Control Panel]. Click [Add/Remove Programs]
and select [PHP Report Maker 9].

Note for Windows Vista/7 (or later) users:


In Windows Vista/7 (or later), User Account Control (UAC) is enabled by default, members of
the administrators group do NOT have full administrator privileges.
When you install (by double-clicking the installer or right-clicking the installer and choose
Run as administrator), an User Account Control prompt may be displayed and ask you
if you allow the program to make changes to your computer, click Yes to let the installer run
elevated.
If you still cannot install successfully, log in Windows as the built-in administrator
account to install. The built-in administrator account is disabled by default, you may need
to enable the built-in administrator account first:
1. Login as administrator. Open a command prompt (under All Programs ->
Accessories) in administrator mode by right-clicking and choosing Run as
administrator,
2. Type the command: net user administrator /active:yes. You should see:
"The command completed successfully."

10

PHP Report Maker 9 Help


3. Log out. You'll now see the Administrator account show up on the login screen.
Log in as the built-in administrator and install again. After successful installation, if you want
to disable the built-in administrator account. Logout and re-login as your regular user
account, and then open an administrator mode command prompt as above. Type the
command: net user administrator /active:no. The administrator account will now
be disabled, and should not show up on the login screen anymore.

1.4 License and Ordering Information


PHP Report Maker is not a free software. You are permitted to use this program for a period
of 30 days. Continued use after that will require payment of the registration fee.
Benefits for registered users

Free upgrades of all minor versions for 12 months


Free email support for 6 months
Email notifications of upgrades
Access to registered user site
Additional extensions (if any)

After receiving your license key, register by clicking [Help]->[Register].


To register the program in Windows Vista/2008/2012/7/8/10 (or later), you need
administrative privileges and you may need to start the program by right clicking the
program file (.exe file) in the installed folder or its shortcut on the desktop and choose Run
as administrator. For more info on User Account Control (UAC), read:
http://support.microsoft.com/kb/922708
Note

Registration can be done as follows:


Credit Card Payments
http://www.hkvstore.com/phpreportmaker/purchase.asp
Mail order or Wire Transfer
Hong Kong Dollars Cheque or Money Order (List price), OR
International Bank Cheque or International Money Order or Wire Transfer or other payment
method (List price plus 25%)
Please contact sales@hkvstore.com for information about our bank account.

1.5 Technical Support


Registered users are entitled to 6 months free email support. Send your technical support
request to php.support@hkvstore.com.
Your email message should include the following information:
1. Is the problem reproducible? If so, how?
2. What version of Windows is your PC running?
3. What version of PHP Report Maker are you running? (Click [Help] and then
[About...] to check)
4. What database and what version are you using?

11

PHP Report Maker 9 Help


5. What OS the server is running? Windows or Linux? What version of PHP is running?
(Note that PHP 4 is not supported.)
6. If any error message was displayed, please include the full text of error message.
7. Your project file (.prp file)(See 1.13) and your database (.sql file) with enough data
for reproducing the problem.
8. Your license information. Emails without license information will be ignored.
While we are happy to support your usage of our software, please note that technical
support does NOT entail customization of templates, extensions or generated code, writing
server events or client scripts (JavaScripts) or custom template, integrating third-party
code, setting up web server, or any other issues not directly related to the workings of the
software. Request for debugging or modifying code not generated from the original template
will be ignored.
Note

1.6 Disclaimer of Warranty


PHP Report Maker is supplied "AS IS". The authors disclaim all warranties, expressed or
implied, including, without limitation, the warranties of merchantability and of fitness for any
purpose. The authors assume no liability for damages, direct or consequential, which may
result from the use of PHP Report Maker.
Please note this program is Shareware. It is not Freeware. You are permitted to try the
program for a maximum of 30 days. Continued use will require payment of the registration
fee. Please refer to the License and Ordering(See 1.4) Section for details.

1.7 Third-party Tools


All the following tools are not developed by the author of PHP Report Maker and are not
part of PHP Report Maker, NO TECHNICAL SUPPORT WILL BE PROVIDED.
Note

PHP Report Maker uses the following third-party tools in template/extensions:


JSCalandar
Website: http://www.dynarch.com/projects/calendar/old
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above.
PHPMailer
Website: http://phpmailer.sourceforge.net
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above.
DOMPDF
Website: http://code.google.com/p/dompdf
DOMPDF is available under the terms of the LGPL License.
Requires MBString and DOM extensions.
WARNING! This extension is EXPERIMENTAL only. There are some known issues of
DOMPDF, please read the developer website for more information. Known issues includes
(but now limited to):

not particularly tolerant to poorly-formed HTML input


large files can take a while to render
use a lot of memory

12

PHP Report Maker 9 Help


jQuery
Website: http://jquery.com/
jQuery is released under MIT License.
JsRender
Website: https://github.com/BorisMoore/jsrender
JsRender is released under MIT License.
Bootstrap
Website: http://getbootstrap.com/
Bootstrap is licensed under Apache License v2.0.
Barcode and QRCode
Website: http://www.phpclasses.org/package/2441-PHP-Generate-barcode-graphs-usingdifferent-standards.html
The class is distributed for free without warranty.
PHP Thumb
Website: https://github.com/masterexploder/PHPThumb
PHP Thumb is distributed under the MIT License.
Supports GIF, JPEG and PNG images only. Requires PHP GD2 extension.

Additional extensions: (for registered users only)


Additional extensions are provided for registered users as examples of customzing and
extending template only, NO TECHNICAL SUPPORT WILL BE PROVIDED. Registered users
will be provided information to download the extensions. These tools will NOT automatically
work with PHP Report Maker without the extensions.
Note

Horizontal Menu
Replaces the graphical extension for previous versions. Uses Bootstrap Navbar as horizontal
menu.
FusionCharts XT
Developer Website: http://www.fusioncharts.com/
FusionCharts XT is distributed under a special OEM license for PHP Report Maker.
PHP Report Maker does not support all charts in FusionCharts XT, see FusionCharts(See
1.15) for supported chart types. FusionCharts Free will still be used for Funnel Charts,
Candlestick Charts and Gantt Charts.
FusionCharts XT does NOT include PowerCharts XT, FusionWidgets XT and
FusionMaps XT.
PHP Report Maker does NOT support PowerCharts XT, FusionWidgets XT and
FusionMaps XT.
IMPORTANT NOTE: When you use PHP Report Maker with a registered license, you may
deploy FusionCharts to your websites together with PHP Report Maker generated scripts.
However, you may not rent, lease, lend or sublicense FusionCharts. If you use the
generated scripts and charts to build your web application as a product for public distribution
or commercial sale, you may not re-distribute FusionCharts with your product, you must
purchase your own OEM license for your product from the developer of FusionCharts.

13

PHP Report Maker 9 Help


Documentation
http://www.fusioncharts.com/developers/
CAPTCHA
Generates CAPTCHA image. Requires PHP GD extension with GD2.
Also support reCAPTCHA (https://developers.google.com/recaptcha/). reCAPTCHA is
OPTIONAL. If you choose to use reCAPTCHA, note that reCAPTCHA is a Web service,
meaning that the CAPTCHA images are served directly from reCAPTCHA's servers to the end
users, the end users need to be online. To use the service, you must register at the
reCAPTCHA Web site and obtain public and private keys.
PHPExcel
Website: http://phpexcel.codeplex.com
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above. Requires PHP version 5.2.0 or higher, PHP extension php_zip enabled (for
Excel2007 format), PHP extension php_xml enabled and PHP extension php_gd2 enabled (if
not compiled in). This extension supports exporting to 'Excel5' or 'Excel2007' format and
supports exporting images and charts, but it does NOT support styling cells.
PHPWord
Website:http://phpword.codeplex.com/
This program is available under the terms of the GNU Lesser General Public License version
2.1 or above. Requires PHP 5.2.x or newer, PHP Extension ZipArchive, PHP Extension xmllib.
For opening by PHPWord created files in Microsoft Office < 2007 you need the Microsoft
Office Compatibility Pack. This extension supports exporting to Word 2007 format and
supports exporting images and charts, but it does NOT support styling cells.
Time Picker
Website: http://jonthornton.github.io/jquery-timepicker/
Timepicker Plugin for jQuery is made available under the open source MIT License.

1.8 Introduction to PHP and MySQL


What is PHP?
PHP is a widely-used general-purpose server-side scripting language that can be embedded
into HTML. You can think of it as a "plug-in" for your Web server that will allow it to do more
than just send plain Web pages when browsers request them. With PHP installed, your Web
server will be able to read a new kind of file (called a PHP script) that can do things like
retrieve up-to-the-minute information from a database and insert it into a Web page before
sending it to the browser that requested it. PHP is completely free to download and use. If
you are new to PHP and want to get some idea of how it works, try the introductory tutorial.
PHP Home Page
Manual
Download

What is MySQL?
MySQL is a relational database management system, or RDBMS. It has become the world's
most popular open source database because of its consistent fast performance, high
reliability and ease of use. PHP has MySQL extension which makes it really easy to access
data in MySQL.

14

PHP Report Maker 9 Help


MySQL Home Page
Manual
Download

Useful MySQL Database Administration Tools


phpMyAdmin (freeware)

Installing PHP and MySQL on Windows


Both PHP and MySQL support various platforms, including Windows. It is recommended
that you install MySQL and PHP on your computer so you can easily develop and
test your PHP locally before uploading to your production server.
If you use Internet Information Services (IIS), you can install PHP on your Windows system
PHP for Windows installer which installs PHP for IIS, it configures the web server as well.
Alternatively, you can use Microsoft Web Platform Installer, see http://php.iis.net/.
If you do not have IIS, you can use other Web server such as Apache. If you have difficulties
installing PHP and MySQL, you might as well try EasyPHP which is an "out of the box"
Apache, MySQL, and PHP installation for Windows.
For PHP 5, MySQL is not enabled by default, so the php_mysql.dll (or php_mysqli.dll) DLL
must be enabled in php.ini. Also, PHP needs access to the MySQL client library. A file named
libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL
this file needs to be available to the Windows systems PATH.
The next step is to set up a valid configuration file for PHP, the php.ini. PHP searches for
php.ini in the locations described in The configuration file.
If you're using NTFS on Windows, make sure that the user running the web server has
read permissions to your php.ini (e.g. make it readable by Everyone).
Note

Some Important Settings in php.ini for Using PHP on Windows


extension_dir - In what directory PHP should look for dynamically loadable extensions. It
should be set to the folder where your extensions are installed, e.g.
extension_dir="C:\Program Files (x86)\PHP\ext"
session.save_path - This is the path where session data files are stored. Make sure this
setting points to an existing folder on your machine, e.g.
session.save_path="C:\Windows\Temp"
If you're using NTFS on Windows, make sure that the user running the web server has
write permissions to this folder (e.g. make it readable and writable by Everyone). See the
section Configuring Permissions below.
Note

upload_tmp_dir - If you want to use file upload, make sure this setting points to an existing
folder on your machine, e.g. upload_tmp_dir="C:\Windows\Temp"
If you're using NTFS on Windows, make sure that the user running the web server has
write permissions to this folder (e.g. make it readable and writable by Everyone). See the
section Configuring Permissions below.
Note

php_com_dotnet.dll - If you use MS Access or MS SQL Server (on Windows server), the COM
extension is required. As of PHP 5.3.15 / 5.4.5, the COM extension

15

PHP Report Maker 9 Help


requires php_com_dotnet.dll to be enabled inside of php.ini, i.e.
extension=php_com_dotnet.dll
Also make sure you have installed the php_com_dotnet.dll in the extension folder
(extension_dir) specified in php.ini.
Note

Internet Information Services (IIS)


IIS 7.x or later is included with Windows Vista/2008/2012/7/8/10 and is installed via
Programs->Turn on or off Windows features in the Control Panel. Read:
http://www.iis.net/learn/install/installing-iis-7/installing-iis-on-windows-vista-and-windows7

Creating Virtual Directories in IIS 7 (Windows Vista or Later)

The IIS manager user interface consists of three panes.

The left hand side pane is Connections, the middle pane is Workspace and the right hand
side pane is Actions.
The Connections pane lists application pools and websites. The workspace pane consists of
two tabs at the bottom namely Features View and Content View. The Features View
allows you to work with the settings of the selected item from Connections pane whereas
the Content View displays all the child nodes (content) of the selected item.
Application pool is a group of IIS applications that are isolated from other application
pools. Each application pool runs in its own worker process. Any problem with that process
affects the applications residing in it and not the rest of the applications. You can configure
application pools individually.

16

PHP Report Maker 9 Help


In order to create a new application pool, select "Application Pools" under Connections pane.
Then click on "Add application pool" from Actions pane. This will open a dialog as shown
below:

Specify a name for the new pool to be created. Select .NET framework version that all the
applications from the pool will use. Also select pipeline mode. There are two pipeline modes
viz. integrated and classic. The integrated mode uses the integrated request processing
model whereas the classic mode uses the older request processing model. Click OK to create
the application pool.
Your new application pool will now be displayed in the Workspace pane. To configure the
application pool click on the "Advanced Settings" option under Actions pane. The following
figure shows many of the configurable properties of an application pool.

17

PHP Report Maker 9 Help

If you use 64-bit Windows, set Enable 32-Bit Applications to True. (See Running on 64bit Windows Operating System below.)
To create a new web site, select Web Sites node under Connections pane and then click on
"Add Web Site" under Actions pane. This opens a dialog as shown below:

18

PHP Report Maker 9 Help

Here, you can specify properties of the new web site including its application pool and
physical location.
Creating an IIS application or a Virtual Directory is quick and simple. Just right click on
the web site and choose either "Add Application" or "Add Virtual Directory" to open
respective dialogs (see below).

19

PHP Report Maker 9 Help

An existing Virtual directory can be marked as an IIS application by right clicking on it and
selecting "Convert to Application".
If you use IE, you may encounter the following error messages when you run PHP pages
with IIS 7:
An error occurred on the server when processing the URL. Please contact the system
administrator.
Go to Internet Options -> Advanced, disable Show friendly HTTP error messages.

20

PHP Report Maker 9 Help

Configuring Permissions
An important aspect of working with file upload to a folder on the Web server is to correctly
configure permissions.
When a Web application uses a file, the application must have Read permission to the file so
the application can access the data. Additionally, the application must have Write permission
to the folder that contains the file. Write permission is required because the file may be
created at run time.
If you use Linux/Unix, CHMOD your upload folder to "777" by using your FTP software.
To use an Access database in an PHP Web application, you must configure the folder that
contains the Access database to have both Read and Write permissions for the IIS user
account.
The default anonymous IIS user depends on IIS version. In IIS 5, it is
IUSR_<MachineName>. In IIS 6 and IIS 7 it can be NETWORKSERVICE or IUSR. In IIS 7.5
it depends on Application Pool, read Application Pool Identities for detail.
To set permissions in the folder (if you're using NTFS on Windows),

21

PHP Report Maker 9 Help


1. In Windows Explorer, move to the root folder for the Web site. e.g.
C:\Inetpub\wwwroot\ExampleSite.
2. If the folder does not already exist, create one.
3. Right-click the folder, click Properties, and then click the Security tab.

4. Under Group or user names, look for or add the user.


5. Verify that the account has Read and Write permissions for the folder.
Similarly, set permissions in the folder where the audit trail log file reside.

Running on 64-bit Windows Operating System

Windows Server 2008 or Windows 7 64-bit (IIS 7.x)


On 64-bit Windows 2008/7, IIS 7.x can run both 32-bit and 64-bit worker processes
simultaneously. To run 32-bit Web applications in IIS 7.x on 64-bit Windows all it needs is to
assign the 32-bit applications to a separate application pool in IIS and turn on the Enable
32-Bit Applications switch for that application pool. To do this, open IIS Manager, open
Application Pool, select the application pool, and then click Advanced Settings. In
Enable 32-Bit Applications, select True.

1.9 Preparing Your Data


Before creating any reports in PHP Report Maker, you must prepare your data first.

22

PHP Report Maker 9 Help

1. Make sure ALL data are available using Views


The first thing to consider in preparing your data is to make ALL data to be displayed
available in the source table.
In PHP Report Maker, each report is based on a single source table (or view), you need to
make sure all data are available in the source table. If you have foreign keys in your table
and you want to display data from the referenced table, you should use view (or "query" in
MS Access) of the your database and create joins to combine data from the tables first.
Example
In the tutorial of Crosstab Report(See 1.17.7), we create a View first, you can see that the
relationships are as follows:

The main data is actually stored in the OrderDetails table, but we obtain the following
information using the joins between tables:
Company name - Use the OrderID field in the OrderDetails table to trace back to the
Orders table, then use the CustomerID in the Orders table to trace back to the Customers
table to get the CompanyName.
Product name - Use the ProductID field in the Order Details table to trace back to the
Products table to get the ProductName.
Category name - Use the ProductID field in the OrderDetails table to trace back to the
Products table to get the ProductName, then use the CatergoryID in the Products table to
trace back to the Categories table to get the CategoryName.
With the company name, product name and category name present in one single source the "Orders By Product" View, you can create reports and use them to group your data.
Otherwise, you can only group by OrderID or ProductID which are only integers and make
the report much less readable.
Notes

1. Make sure the data referenced by the foreign keys are unique or the grouping will be
wrong. For example, if you have 2 different CustomerID in your orders table but
they both have the same company name, these 2 companies will become

23

PHP Report Maker 9 Help


indistinguishable in the view; if you group the data by customer name, the result will
be wrong.
2. To enhance performance, only select the data you want to use when you create the
views. Do not use asterisk(*) to select all fields (unless you really need to use all of
them).

2. Filtering Data
The second thing to consider is filtering of the data. Always retrieve the least amount of data
from the database for best performance.
For example, if your data ranges across 3 years and you only need to see one year data in
your report each time, you can create a report and select the year at runtime (Run-time
refers to when you run the generated script. Run-time filtering is well supported for users to
see partial data that they are interested in), but this would mean that the PHP script will
need to handle 3 times the data needed to show initially. There is performance penalty if the
size of your data is large and it will take a longer time for the report page to show. You have
2 alternatives:
1. Use Extended Filter for the field and choose a default year, or
2. Create 3 views in your database for each year.
then your report for a particular year will load faster.

After you prepare the data, connect to the database using PHP Report Maker, then right click
the database pane or click [Edit] and then choose [Add Report (Detail/Summary)] or
[Add Report (Crosstab)] or [Add Report (Gantt)] to create a report.

1.10 Quick Start

Quick Start
PHP Report Maker connects to MySQL, extracts tables and fields information, and generates
PHP scripts instantly based on these information.
To generate scripts, you just need to follow the tabs and setup the options, that is:
[Database] -> [PHP] -> [HTML] -> [Security] -> [Generate]
However, if you are a first time user, we recommend you to generate a basic PHP application
and get to know how PHP Report Maker and PHP works first.
If you have not used PHP before, it is recommended that you read Introduction to PHP
and MySQL(See 1.8) first.
Note

To generate your first PHP project, you can skip the options and use default settings first. In
other words, you skip the intermediate steps and go directly to the [Generate] tab after
connecting to your data source, that is:
[Database] -> [Generate]

24

PHP Report Maker 9 Help


You can generate the web site quickly by the following steps:
1. Start up PHP Report Maker. There are two connection methods to connect to your MySQL
server - DIRECT or URL. As explained in Introduction to PHP and MySQL(See 1.8), it is
recommended that you have a local MySQL server during development. You usually connect
to MySQL by the DIRECT method, the URL method is only used when you want to conenct to
a remote MySQL server which does not allow direct connection. (See Tutorial - Connecting
Remote MySQL using PHP Report Maker Connection Script(See 1.17.1).)
In this example, we use direct connection. Enter connection details for the MySQL Server .

2. Click the [Connect] button to load the database information. Tables and fields
information will be loaded and displayed on the left hand side.

25

PHP Report Maker 9 Help

Note that in the database pane on left, there is a checkbox beside each table or view. The
checkbox determines if report for the table/view will be generated. As they are only source
tables that your reports to be based on, the checkbox for these tables/views are not checked
by default. However, as a quick start example, we use them direclty for simplicity.
Check at least one of them so we have something to generate for. Alternatively, you can
click on the [Tables] or [Views] or [Custom Views] or [Reports] node in the database
pane (or click [View] -> [Tables/Views] in the main menu) to go the Table Setup(See
1.11.6) page and select all tables.

26

PHP Report Maker 9 Help

3. Click the [Generate] tab and select the follows:


Template file - The zipped file that contains the template of the generated pages. Just use
the default template is shipped with PHP Report Maker.
Application root folder - The root folder of your PHP application.
Destination folder - The folder that the generated scripts will reside. This can be same as
the application root folder or a subfolder under the application root folder. In this case, we
use the same folder for simplicity.

27

PHP Report Maker 9 Help

To run PHP you need to setup a website or virtual directory (See Introduction to PHP and
MySQL(See 1.8)). If you are not familiar with web server, you can install IIS Express which
can be downloaded from Microsoft website. Then select [IIS Express] and [Browse after
generation] in PHP Report Maker.
4. Click the [Generate] button, the generation process will begin. After the web site is
generated successfully, a completion message will be displayed. The web site should then be
ready to run. Browse to the website and - voila! - you'll see PHP displaying the data in your
website.

As a quick start example, these are only reports in simplest form. After understanding how
PHP Report Maker works, you can go on to create more sophisticated reports, Detail and
Summary Report(See 1.11.11) or Crosstab Report(See 1.11.12) are just a few more steps
away. You can take advantage of various options provided by PHP Report Maker to present
your data. See Project Setup(See 1.11) for full details.

28

PHP Report Maker 9 Help

1.11 Project Setup


To make use of the various features of PHP Report Maker and create scripts that best suit
your Web sites, read the following information and get to know the options PHP Report
Maker provide. It is assumed that you have basic knowledges of HTML and PHP and the
technical terms are used without further explanation.
First of all, read:
Preparing Your Data for Reports(See 1.9)
To generate a Web report site, please perform the following steps:
1.
2.
3.
4.
5.

Database(See 1.11.1)
PHP(See 1.11.2)
HTML(See 1.11.3)
Security(See 1.11.4)
Generate(See 1.11.5)

To create reports, please read:

Detail and Summary Report Setup(See 1.11.11)


Crosstab Report Setup(See 1.11.12)
Gantt Report Setup(See 1.11.9)
Dashboard Setup(See 1.11.13)

To further control the functionality of the generated scripts, you can setup different options
for each table, field or chart:

Table Setup(See 1.11.6)


Field Setup(See 1.11.7)
Chart Setup(See 1.11.8)

1.11.1 Data Source Setup


If you are not at the [Database] tab yet, clicking the
icon in the toolbar to go to
[Database] tab. PHP Report Maker can connect to MySQL, PostgresSQL, Oracle, Microsoft
Access and Microsoft SQL Server.
1. MySQL
Select MySQL as database type.

29

PHP Report Maker 9 Help

There are 2 connection methods you can choose:


Direct Connection (default)
1. Enter your database host/server name (or IP address), username, password and
port number (default is 3306 for MySQL),
2. Select your database,
3. Select the SQL Identifier Quote Character, default is backquote (`) for MySQL,
4. Click the [Connect] button to load the database information.
The server name or IP should be valid on your production Web server also. Otherwise
you'll need to modify the generated connection info in ewrcfg*.php before you upload it to
your production server. For example, if you have a testing MySQL Server installed on the
same computer, you can use "localhost" as server name when you connect to it with PHP
Report Maker. The generated scripts will then try to connect to a MySQL Server on the same
computer as the production Web server, if this is not the case, the connection will fail.
URL Connection (for remote database)
Note

(Also see Tutorial - Connecting Remote MySQL using PHP Report Maker Connection
Script(See 1.17.1))
While the direct connection method is quick and easy, some remote MySQL server may not
allow direct connection. PHP Report Maker provides an alternative simple way to connect
remote servers:
1. Upload the PHP connection script provided by PHP Report Maker to your site. Note
that:
a.
b.

The script is named "phpmaker.php" and can be found under your installed
folder, usually C:\Program Files (x86)\PHP Report Maker <n>\,
Always use the script shipped with your version of PHP Report
Maker. PHP Report Maker may not work with scripts shipped with
previous versions.

30

PHP Report Maker 9 Help


2. If it is the first time that you use this script, you may want to test the script with
your browser:
a.

Browse to this script with your browser,

b.

Enter the connection info,

c.

Click "Get Database List" and then "View Schema", you should be able to
view the schema of your database in XML properly. Now go back to PHP
Report Maker.

3. Enter the SAME connection information, select URL for connection method, enter the
URL of the script (e.g. http://servername/path/phpmaker.php), you can test the URL
by clicking the [Test] button,

31

PHP Report Maker 9 Help


4. Click the [Connect] button to load the database information. PHP Report Maker will
connect to the database server through the PHP script over HTTP.

2. PostgreSQL
Select PostgreSQL as database type.

There are 2 connection methods you can choose:


Direct Connection (default)
1. Enter your database host/server name (or IP address), username, password and
port number (default is 5432 for PostgreSQL),
2. Select your database,
3. Select the SQL Identifier Quote Character, default is double quote (") for
PostgreSQL,
4. Click the [Connect] button to load the database information.
The server name or IP should be valid on your production Web server also. Otherwise
you'll need to modify the generated connection info in ewrcfg*.php before you upload it to
your production server. For example, if you have a testing PostgreSQL Server installed on
the same computer, you can use "localhost" as server name when you connect to it with PHP
Report Maker. The generated scripts will then try to connect to a PostgreSQL Server on the
same computer as the production Web server, if this is not the case, the connection will fail.
URL Connection (for remote database)
Note

Similar to above for MySQL.

32

PHP Report Maker 9 Help


3. Microsoft Access (Windows only)
If you use Microsoft Access database, you need to have OLEDB drivers installed on both
the PC running PHP Report Maker and on the web server. See System Requirements(See
1.2). (ODBC connection is not recommended and not supported.)
Note

Select Microsoft Access as database type,

Click the

Select the Microsoft Access database file by clicking the


button,
Specify the database path where the database file will reside under the your
application root,
Connect button to load the database information.

Database path is relative to application root. Use slashes "/" as path delimiter, no
leading slash. e.g. If the application root of your website is C:\Inetpub\wwwroot\demo and
you enter "data/" in this textbox, the folder for the database will be
C:\Inetpub\wwwroot\demo\data. If you are not sure which folder is application root, please
read Creating Virtual Directories in IIS(See 1.8).
Note

4. Microsoft SQL Server (Windows only)


If you use SQL Server 2000/2005/2008/2012 and have installed SQL Server 2012
Native Client on your computer, then Microsoft SQL Server and Microsoft SQL Server
2005/2008/2012 database type will be available for selection. You can use this database
type for connection to SQL Server 2000, 2005, 2008 or 2012. You can download SQL Server
2012 Native Client from the Microsoft website. See System Requirements(See 1.2). The
native client must also be installed on the web server. (ODBC connection is not
recommended and not supported.)
Note

Select Microsoft SQL Server (or Microsoft SQL Server 2005/2008/2012 if you
use SQL Server 2005/2008/2012 or later) as database type,
Enter the name or IP of the SQL server,
Enter the User ID and Password,
Select the database you want or just enter the name of your database,

33

PHP Report Maker 9 Help

Click the

Connect button to load the database information.

The server name or IP should be valid on your production Web server also. Otherwise
you'll need to modify the generated connection information in ewrcfg*.php before you
upload it to your production server. For example, if you have a testing SQL Server installed
on the same computer, you can use "(local)" as server name when you connect to it with
PHP Report Maker. The generated scripts will then try to connect to a SQL Server on the
same computer as the production Web server, if this is not the case on the server, the
connection will fail. It is common that SQL Server is installed on a different server in
production environment.
Note

5. Oracle
NoteIf

you have installed Oracle client on your computer, this database type will be available
for selection. You can download Oracle client from the Oracle website. Make sure the path of
your Oracle client (e.g. oci.dll) is among the Path variable under Windows Environment
Variables -> System variable.

Select Oracle as database type,


Enter the Oracle Service name,
Enter the User ID and Password,
Select the Schema you want or just enter the Schema name,
Click the

Connect button to load the database information.

The Oracle service name should be valid on your production Web server also. Otherwise
you'll need to modify the generated connection string in ewrcfg*.php before you upload it to
your production server.
Note

34

PHP Report Maker 9 Help

Load from PMP Project File


If you previously saved your project file (.pmp file), you can load it back by clicking the
open button on the tool bar (or select "Project", "Open" from the menu bar). At completion,
the tables and fields information will be loaded and displayed on the left pane.

35

PHP Report Maker 9 Help


The database pane is dockable. If you prefer to display the database pane on the right hand
side, simply drag it to the right side.

SQL Identifier Quote Character


Most databases support quoting of identifiers (database, table, and field names) with a
character. If the identifier is a restricted word or contains special characters or spaces you
must always quote it with the quote character. In most cases, you do not need to change
this setting, PHP Report Maker will use the default quote character for your databases.
However, if for some reason you need to specify it explicitly, select the [SQL Identifier
Quote Character] that suits your case.
Dynamic Table Loading
By default all tables in the database are loaded. It is convenient but loading and
sychronization could be slow if your database contains a large number of tables or fields. If
this option is enabled, a table will only be loaded when you select it in the database pane. If
you just use a few tables out of a large database, this feature enables you to work much
faster than before. To enable this feature, simply check [Load tables dynamically]
BEFORE pressing the [Connect] button.

1.11.2 PHP Settings


General Options

Add shell call

(For Unix-based server only) If you put the PHP parser binary
somewhere outside of the web tree of files, for example, in
/usr/local/bin, you will have to put a line similar to:
#!/usr/local/bin/php as the first line of any file containing PHP tags.
(You will also need to make the file executable.)

36

PHP Report Maker 9 Help


Set locale

Set locale information. PHP Report Maker uses localeconv() which


returns data based upon the current locale as set by setlocale().
Different systems have different naming schemes for locales.
If you do not know the correct locale string on your server or you
want to override system locale and use your own locale settings, click
the [...] button and enter your locale settings.

Refer to localeconv() for the definition of the settings.


If you use Multi-Language (see below), DO NOT use this
setting unless all languages share the same locale settings. Each
language has its own locale settings and you should specify locale
settings for each language in the respective language file. (See
Customizing Template(See 1.16))
Note

No Cache

Whether caching is required on browser

Default Date Format yyyy/mm/dd, mm/dd/yyyy, dd/mm/yyyy,


yyyy-mm-dd, mm-dd-yyyy, dd-mm-yyyy,
yyyy.mm.dd, mm.dd.yyyy, dd.mm.yyyy, and above settings with
time
File folder

Temporary file folder for Export-to-Email/PDF/Excel/Word


(PHPExcel/PHPWord for registered users only), and email log file.
Important

1. If you use Export-to-Email/PDF/Excel/Word


(PHPExcel/PHPWord only) or email log to text file, you must
grant write permission to this folder on your server so the

37

PHP Report Maker 9 Help


script can write temporary files in this folder.
2. If you have field specific file folder, set it in the View Tag
panel (see Field Setup(See 1.11.7)).
Multi-Language

Enable multi-language project. If enabled, a combobox will appear on


the top of the generated scripts for user to select language. See
Tools(See 1.14) for selecting languages for the multi-language
project.
Important

1. Multi-Language project must use utf-8 encoding. The charset


of the project must be "utf-8".
2. The data in your database must be stored in unicode,
otherwise your data will not be displayed properly.
3. If you have customized the template and put unicode
characters in the template directly instead of using language
files, enable the Advanced Setting UTF-8 output files (see
Customizing Template(See 1.16) and Tools(See 1.14)).
Default Language

Default language of the project. It must be compatible with Charset


(see HTML Settings(See 1.11.3)). Default is English.
There is always one default language for a project. Only the English
language file (english.xml) is shipped with PHP Report Maker. If your
project is single language but you use another language, create a
language file for your language (see Customizing Template(See
1.16)), put it in the "languages" subfolder under the installation folder
and then select your default language using this combobox.
If you enable Multi-Language, you must select one of the selected
languages as the default language.

Server-side
validation

Enable server-side form validation for Extended Filter.


If the available validation format in the Report Field Settings
panel (see Field Setup(See 1.11.7)) does not fulfil your requirements,
you can use your own server-side validation code using Sever Event
and Client Scripts(See 1.11.15).
Note

Client-side
validation

Enable Client-side (JavaScript) form validation for Extended Filter.


If the available validation format in the Report Field Settings
panel (see Field Setup(See 1.11.7)) does not fulfil your requirements,
you can use your own client-side validation code using Sever Event
and Client Scripts(See 1.11.15).
Note

Report Page Options (Global)

38

PHP Report Maker 9 Help

Records per
Number of records to be displayed on the list page of all tables.
page
Selectable
page sizes

Number of records to be selected by user. Comma separated values, e.g.


10,20,50,ALL.
Note

Paging
section
style
Sort type

"ALL" (without quotes) is supported, other values must be integers.

"NumericPages" or "NextPrev"

None, Single column or Multiple column. If Multiple column is selected,


the generated list page supports multi-column sorting by Ctrl-clicking the table
header.

Paging
section at
top

Show the paging section at top

Paging
section at
bottom

Show the paging section at bottom

Export

Records can export to Print, Excel, Word, PDF or Email. HTML format is
used as a printer friendly version.
Use button dropdown - show the export links as a button with dropdown
menu. Default is showing the export links as a row of icons.

39

PHP Report Maker 9 Help


Notes (Export to PDF)

1. The extension is an experimental extension only. There are


known issues, see Third-party Tools(See 1.7) and read the note in the
extension setup page (see Tools -> Extensions(See 1.14)) for more
information before use. Only enable it if necessary.
2. The extension performs best if you are using non-unicode
alphanumerical characters (e.g. iso-8859-1) only. If you use unicode,
configure advanced settings for the extension, read the note in the
extension setup page (see Tools -> Extensions(See 1.14)) for more
information.
3. The extension supports images (jpg, gif and png only), but a
temporary folder is required during export, the extension uses the File
folder (see above) because write permission for the folder should be
already setup.
Notes for Export to Excel/Word (for PHPExcel/PHPWord extension only):

1. This extension is for registered users only, it requires some other PHP
extensions, read the note in the extension setup page (see Tools ->
Extensions(See 1.14)) for more information before use.
2. The extension supports images (jpg, gif and png only), but a temp
folder is required during export, the extension uses the File folder
(see above), make sure you specify an upload folder and set up the
write permssion.
3. This extension does not support styling cells.
If the report contain charts rendered by FusionCharts
(not FusionCharts Free), the chart will be converted to embedded images in
email content.
Export type - Determines what to export. The follows are supported:
Notes for Export to Email:

All Pages - Records in all pages are exported


Current Page - All records in current page are exported

Comparison

Format

HTML P E
(Print D m Excel
)
F ail

Word

PHPExcel (for PHPWord (for


registered
registered
users)
users)

P
HTML
HT
(NOT
HTML D
ML
F
native)

HTML
(NOT
native)

Excel 5/2007
(native)

Images
Charts (as
images)
(Requires
FusionCharts)
Custom
Template(See
1.11.16)

40

Word 2007 only


(native)

PHP Report Maker 9 Help

Email Settings

SMTP server

The host name or IP of the SMTP server.


Some servers do not support "localhost" as SMTP server, in such
case you need to specify a valid SMTP server in the network.
Note

SMTP server
port

Port number of SMTP server. Default is 25.

SMTP server
username

User name for SMTP server authentication. If your SMTP server does not
require authentication, leave it blank.

SMTP server
password

Password for SMTP server authentication. If your SMTP server does not
require authentication, leave it blank.

Security

Protocol used by the SMTP server. Possible values are: SSL or TLS.
Leave this setting empty if your SMTP server does not use such
protocols.
Note

PHP Report Maker use PHPMailer to send email, make sure you upload the subfolder
"phpmailer" generated in the destination folder.
Note

1.11.3 HTML Settings


General

41

PHP Report Maker 9 Help

Title

Title displayed on all pages.


If you use Multi-Language (see PHP Settings(See 1.11.2)), use MultiLanguage Property Editor, see Tools(See 1.14) for details.
Note

Charset

Charset setting used in the META tag of the site and for exporting data.
If you use Multi-Language (see PHP Settings(See 1.11.2)), this setting
must be utf-8.
Note

Font

Default text font (not specified if not entered)

Size

Default font size (pixel). Unit must be in pixel for working with Bootstrap (see
below).

Site icon

Icon of the site. For browsers to show your URL with an icon. Must be an .ico
file.

Site header Logo image in the header


logo
Note This setting is enabled in registered version only. Registered version
allows no logo.
Site footer Footer text (e.g. copyright statement)
text
Notes

1. If you use Multi-Language (see PHP Settings(See 1.11.2)), use MultiLanguage Property Editor, see Tools(See 1.14) for details.
2. This setting is enabled in registered version only.

Theme
Provides over a dozen of themes for you to setup the look and feel of your project quickly.

42

PHP Report Maker 9 Help

You can change the various properties of the selected theme to suit your style. The property
name are self-explanatory.
Themes are intergrated with Bootstrap, you can customize Bootstrap properties directly in
the Theme tab, scroll down to find the Bootstrap variables which start with "@".
To export custom theme settings, click the [Export theme] button to export the theme to an
external xml file. To import custom theme settings from earlier saved xml files, click the
[Import theme] button.

Notes

43

PHP Report Maker 9 Help


1. Changing a setting in the user interface does not change the corresponding setting
in the theme definitions, it only changes the setting for the project. The theme
definition files (in XML format) are installed in the subfolder "themes" under the
installation folder. You can easily add your own themes by duplicating one of the
theme definition file (except the theme.xml which is for defining the settings and
data type in a theme), rename it and modify the settings in the file, just make sure
you give your theme an unique theme name.
2. Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and
easier web development, to get started, check out http://getbootstrap.com/.
3. After changing theme properties, make sure you re-generate *.css files.

Styles

Edit styles

A separate CSS stylesheet will be generated for each project. Click the
[Edit styles] button to open CSS editor.
Notes

1. All projects use CSS stylesheet.


2. If you have TopStyle Pro (v1.5+) or TopStyle Lite (v1.5-3.1)
installed on your PC, PHP Report Maker will use it automatically.
Notes

When you edit the CSS styles in the editor, note the follows:

1. DO NOT MODIFY the system styles section, it is generated by the


system, your modifications will be overwritten. If you want to
change the stylesheet template, modify the ew.css in the "themes"
subfolder under the installed directory. Only modify the ew.css if
you have the necessary knowledges in CSS.
2. DO NOT REMOVE THE FOLLOWING COMMENTS:

BEGIN_USER_STYLES
END_USER_STYLES
You MUST write your styles between these two comment
lines, styles outside this user styles section will be

44

PHP Report Maker 9 Help


discarded.
3. If you want to override the system styles, you can copy the styles
to the User Styles Section, or you can use a separate user
stylesheet.
User StylesheetSpecify an external user stylesheet (will be copied across during
generation)

You can see the effect of new settings immediately in the preview window at the bottom of
the HTML tab.

Other than choosing color from the palettes, the color picker can also pick color directly from
screen using the "eyedropper".

45

PHP Report Maker 9 Help

1.11.4 Security Settings

Administrator Login (HardCoded)

Administrator user id and password

Login Name

Login Name for administrator

Password

Password for administrator

Use Existing Table

Link to existing table for login name and password


validation

Table

Existing table in database containing login name and


password information

Login Name Field

Login Name field in table used for authentication

Password Field

Password field in table used for authentication

Login Options

Login options in the login page:

46

PHP Report Maker 9 Help

Auto-login - Auto login until the user logout explicitly


When you enable the auto-login feature, a few cookies
will be placed on the user's computer to identify the
user, meaning that the user do not have to type
username and password every time he/she visit the site.
For this reason, you should advise your users not to use
this feature on a public or shared computer, as any other
user of the computer will be able to access the account.
Remember username - Save the user's user name in
cookie
Always ask - Do not save user name and password,
always ask for them in the login page

Advanced Security
Advanced Security feature allows you to setup User ID, assign User Levels to users and
create a complete user registration system. To setup, click the [Advanced] button.
User ID
User ID Security secures data at record level. Protected tables must have an [User ID
Field] for identifying which user a record belongs to. The User ID field names can be
different in tables though. When User ID security is enabled, users can only access their own
data.
[Parent User ID Field] stores the parent User ID that the user belongs to. For example, a
parent user can be the manager that the employee reports to. You can select an Parent User
ID for users so the parent user can view the child users' records as his/her own.

47

PHP Report Maker 9 Help

Steps to setup User ID security for different tables/views:


1. Click on User ID in the left pane,
2. Select the [User ID field] from your user table, this field is usually the primary key
of the User Table. (note: if this field is not set, the feature is disabled)
3. To enable Parent User ID security, select the [Parent User ID field] from your user
table, (note: if this field is not set, the feature is disabled)
4. In the [User ID Field] column, select the User ID Field for the tables/views that
requires User ID security.

User Level
User Level Security secures data at table level. Each user level is granted with specific
permissions to tables in the database.
There are 2 types of User Level security:
1. Static User Levels - the User Levels and the permissions are defined in this form and
the User Levels are not to be changed after script generation.

48

PHP Report Maker 9 Help

Steps to setup static User Level security for different tables/views:


1. Click on User Levels in the left pane,
2. Select an integer field in your user table as the [User Level field], (Note: if this
field is not set, the feature is disabled)
3. Define your user levels, click
user level.

icon the add an user level and

icon to delete an

2. Dynamic User Levels - the User Levels and the permissions are defined in 2 tables in
the database, the User Levels can still be changed with the generated scripts.

49

PHP Report Maker 9 Help

Steps to setup static User Level security for different tables/views:


1. Click on User Levels in the left pane,
2. Select an integer field in your user table as the [User Level field],(note: if this
field is not set, the feature is disabled)
3. Switch to the [Dynamic User Levels] tab, check [Enable Dynamic User Levels],
4. Select your User Level Table and User Level Permission Table and the required
fields.
The User Level Table and User Level Permission Table must have the following fields,
note the data types, User Level ID and the Permission fields must be of integer type, the
field names can be different though:

If you want PHP Report Maker to create these 2 tables in your database, click the [Create
tables] button, the following form will display for you to change the table/field names if
necessary. You can change the table/field names and then click OK to continue.

50

PHP Report Maker 9 Help

If you have projects created by previous versions of PHP Report Maker you may want to use
dynamic User Levels and migrate the previously defined static User Levels in the project to
the database. After selecting or creating the User Level and User Level Permission
tables/fields, just click the [Migrate] button to let PHP Report Maker do that for you.
Important Notes on Anonymous Users

1. From v9, the permissions for anonymous users are integrated in the User Level
security settings. See built-in user levels for anonymous users below.
There are three built-in user levels:
Anonymous - Anonymous user level is a built-in user level for the anonymous user (i.e.
users that have not logged in). The User Level ID of the anonymous user is -2.
Administrator - Administrator user level is a built-in user level that has all permissions plus
the privileges to modify User IDs and User Levels. Its permissions are same as that of the
hard-coded Administrator. The User Level ID of Administrator is -1.
Default - Default user level is built-in user level with user level = 0. Since User Level field is
an integer field, if you set a default value of 0 for this field, this user level will become the
default user level for the user after registration and before the Administrator assigning
another higher user level.
Important Notes on User Levels

1. Even you enable all permissions for an user defined User Level, the User Level will
NOT become same as this Administrator User Level. User defined User Levels will
not have the permissions to manage users.
2. It is possible to use single login and common Dynamic User Levels for multiple
projects provided that ALL projects use the same project name and same Advanced
Security tables (i.e. User Table, User Level Table and User Level Permission Table).
If all projects uses the same database and same Advanced Security tables, then the
latter condition is automatically fulfilled. However, if the projects use different
databases, you need to use Database_Connecting(See 1.11.15) server event to
change the connection info so the user can get the Dynamic User Levels from the
common Advanced Security tables correctly during login. For the projects not using

51

PHP Report Maker 9 Help


the database with the common Advanced Security tables, you still need to create
dummy Advanced Security tables (with same table/field names as the common
Advanced Security tables) in the project database so you can setup Advanced
Security.
3. PHP Report Maker does not support data modification, it does NOT generate scripts
to update the User Level Table and User Level Permission Table. Use PHPMaker if
you need to do so.

User Login Options

MD5 password

Use MD5 password


If you enable MD5 password, make sure that the
passwords in your user table are stored as MD5 hash (32character hexadecimal number) of the clear text
password. If you also use case-insensitive password,
convert the clear text passwords to lower case first before
calculating MD5 hash. Otherwise, existing users will not be
able to login.
Note

Case-sensitive password

Use case-sensitive password


If you enable case-insensitive password, make sure
that the passwords in your user table are stored on
lowercase. If you also enable MD5 password, convert the
clear text passwords to lower case first before calculating
MD5 hash. Otherwise, existing users will not be able to
login.
Note

52

PHP Report Maker 9 Help


CAPTCHA (requires extension)Optionally requires user to type letters or digits from a
distorted image that appears on the screen. For use with
login page.
Requires CAPTCHA extension, click Tools ->
Extensions from the main menu to enable. Also see
Third-party Tools(See 1.7).
Note

Requires activation

Specify if the user table has an Activated field (see


below).

Activated field

Specifiy the field in user table used for storing the status
of user. A boolean field is recommended, although an
integer field or a string field will also work.

Also See:
Tutorial - User ID Security(See 1.17.2)
Tutorial - Static User Level Security(See 1.17.3)
Tutorial - Dynamic User Level Security(See 1.17.4)

1.11.5 Generate Settings

53

PHP Report Maker 9 Help


Template file

Template archive (zip file)

Application root folder

The root folder of the PHP application. See Application Root(See


1.12) for detail.

Destination folder

The destination folder where the PHP scripts are to be generated.


The folder is usually same as the application root folder or a
subfolder under the application root folder.

Output filename

None - no prefix/suffix is added


Prefix - a prefix is added to all output file names
Infix - an infix is added to all output file names
Suffix - a suffix is added to all output file names
Infix is only applicable to files for table-specific files (i.e. files
started with table name).
Note

Prefix/Infix/Suffix

The string to be concatenated to output file names when the


Prefix/Infix/Suffix option is specified.

Lowercase

Specify whether output file names are in lowercase

Extension

Extension name of the generated scripts, default is "php"

Default page

File name of the default page, default is "index.php"

Start page

Specify the first page that the default page (usually "index.php")
should redirect users to.
If this setting is left blank, user will be redirected to the List page
of the default table (see Table Setup(See 1.11.6)) or the first
table that the user have permssion to access.
If this setting is not blank, the default page will simply redirect
user to the page you specify, e.g. a page not generated by the
current project. If you start the site by the typical index.php,
leave this setting blank, do NOT enter index.php or there will be a
indefinite loop.

Testing web server

Specify the web server that you want to use to test the generated
site. For use with Browse after generation (see below). You
can choose IIS Express or Other. Requires IIS Express installed
on the same machine as PHP Report Maker.
IIS Express is a simpler and self-contained version of IIS that is
optimized for developers. IIS Express is free, does not require
administrative privileges to run and supports all Windows
platforms XP and above. It can be downloaded from
microsoft.com.
If you choose Other web server (e.g. you use IIS or Apache),
you need to specify Testing root URL (see below) also.

Browse after generationSpecify whether to open a browser to test the generated site
after script generation.
Testing root URL

Specify the URL of your testing site that maps to the Application
root folder (see above). For use with Browse after

54

PHP Report Maker 9 Help


generation. If you use IIS Express, this setting is NOT
required.
For example, if you have set up a website like:
Application root folder: C:\Documents and
Settings\Administrator\My Documents\mycompany.com
Destination folder: C:\Documents and
Settings\Administrator\My Documents\mycompany.com\project1
and you have setup your testing website's document root at the
application root folder, so that you browse the main site by:
http://localhost/
and browse the PHP Report Maker generated site by:
http://localhost/project1/
Then the Testing root URL should be:
http://localhost/
(NOT http://localhost/project1/, which points to the Destination
folder).
PHP Report Maker will calculate the relative path and add
"project1/" to the Testing root URL when opening the browser.

After setting above, click the [Generate] button to generate scripts. PHP Report Maker
allows you select scripts to generate, just select the files you want to generate in the
[Output] column. If you want include PHP Report Maker scripts into your custom PHP
scripts, you may not want to generate header and footer in those pages. Then you can
enable [No header/footer] for those pages. Note that header includes the menu and the
project tite.
After selection, then click the [Generate] button.
If it is your first generation for the project or you have changed some project level
settings, you must select [Other files] to generate the non table-specific pages.
Note

If you modify settings for a table and want to re-generate script for that table only, you can
click [Unselect All], then select the files you want to re-generate and click the [Generate]
button to generate again.
You can also right-click the column header of [Output] or [No header/footer] to quickly
select all or unselect all items in the column.

55

PHP Report Maker 9 Help

If you need to abort script generation in the middle of the process, just click the [Cancel]
button under the progress bar that displayed during generation.

Also See:
Project File(See 1.13)
Compatibility Properties Setup (See 1.11.14)

1.11.6 Table Setup


For simplicity, we use "table" in the following description to refer to any of database
object in the project. A database object can be either a table, a view, a Custom View or a
report.
Note

After loading the database, the tables will be shown in the database pane on the left pane.
To access ALL setting for a table (including Table-specific Options), click the table node of
any table in the database pane and then click the [Table] tab to go to the Table Setup
page. This is the setup page for a single table.

56

PHP Report Maker 9 Help

You can also click on the [Tables] or [Views] or [Custom Views] or [Reports] node in
the database pane to go to the Tables Setup page which is a grid showing the most
frequently used settings for all tables. If you need to set these settings for multiple tables,
this page allow you to view and set them quickly. Note that this page does not include
Table-specific Options.
The Table Setup pages consists of two section. The upper section is a grid showing available
options of all tables. The lower section contain two panels, the [Table-specific Options]
panel and the [Report Settings] panel for the selected table.

57

PHP Report Maker 9 Help

For all checkbox or combobox columns, if you want to apply the setting to ALL tables or
views, you can choose your setting at the [Tables] or [Views] or [Custom Views] or
[Reports] row.
Note

If you prefer to view the tables in alphabetical order, click [Tools]->[Sort Tables
Alphabetically] (see Tools(See 1.14)).
You can still change the display order of the menu item by drag-and-drop. Select a table by
clicking the first column - [Table Name] column, then drag and drop to where you want.
Note that a table cannot be moved out of its parent node.
Note that changing the display order of table in this Table Setup page does not change the
display order of the tables in the menu. To change the display order of the menu item, click
[Tools]->[Menu Editor] (see Tools(See 1.14)).

The available table level settings are as follows:


Generate

Select/unselect a particular table for generation

Caption

To change the caption of a table, click on [Caption] box to


make the necessary change.
If you use Multi-Language (see PHP Settings(See
1.11.2)), use Multi-Language Property Editor, see Tools(See
1.14) for details.
Note

Filter

Specify a filter (WHERE clause) for the table. Click the [...]
button in [Filter] column, the Filter Editor will popup. Enter your
filter, you can drag the field names from the left pane to the
editor, the SQL identifier quote characters will also be added for
you automatically.

58

PHP Report Maker 9 Help


The filter must be a valid PHP string as the WHERE clause
will be concatenated to the SQL string.
Note

Sort

Specify the sort fields (ORDER BY clause) for the table. Click the
[...] button in [Sort] column, the following dialog box will
popup. You can choose up to 6 fields, in either ascending or
descending order.

59

PHP Report Maker 9 Help

Default

Set a Table as the Default Table. The Default table is the first
table the user see when visiting your site. Select the table you
want in the [Default] column.

Export Page Size

Specifies the number of groups (or records if no grouping field)


in each page of the exported document (page breaks will be
inserted between pages). Default is 0, i.e. disabled, no page
breaks. If you enter n (where n > 0), there will a page break
inserted every n groups/records.
Notes

1. Does not work with exporting to Excel by HTML.


However, it is supported by PHPExcel extension (for
registered users), see Third-Party Tools(See 1.7).
2. If the data for each page is too large for one physical
page, it may still span more than one page before
starting a new page.
Requires Search Criteria Specifies if the report requires search criteria (filtering). Default
is disabled.
If enabled, the report always requires search criteria. When
the page is initially loaded, no records will be displayed until
searching is done. (Remember to enable Filter or Extended Filter
or both)
Note

Fields per row


(Extended Filters)

Specifies the number of fields per row in the Extended Filter


panel. Default is 0 (unspecified), one field per row.

60

PHP Report Maker 9 Help

Table-specific Options
Same as the list page options as described in PHP Setup(See 1.11.2) except that the options
are table-specific, meaning you can have different list page options for different tables. To
use table-specific options, select a table in the grid, uncheck [Use global settings] in the
[Table-specific Options] panel, the panel will be enabled for you to setup.

Report Settings
Show Report

Show both report data (in HTML table) and charts (if any).
If you want the report to show charts only, uncheck this
setting.

Include Row Sums

Includes row sums for the crosstab report


Note

Include Detail

For use with Crosstab reports only

If checked, records belonged to each grouping level will be


displayed under the grouping level title, then followed by
the summary. If unchecked, the details records are
skipped, only the summary will be displayed.
Note

NOT applicable to Crosstab reports.

Show Compact Summary ViewIf checked, the summary will be displayed as columns for
each group. If unchecked, the summary are displayed at
the bottom of each group (as in previous versions).
Notes

1. Only applicable when Include Detail and


Summary is unchecked (i.e. show summary only)
2. NOT applicable to Crosstab reports.

61

PHP Report Maker 9 Help


Show Page Summary

If checked, the summary for the records in the current


page will be displayed at the end of the page.

Show Grand Summary

If checked, the summary for all the records in the report


will be displayed at the end of the page.

1.11.7 Field Setup


After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). Click on any database object to go to the
Field Setup Page for that object at any time.
If PHP Report Maker finds any unsupported fields in a table, an [Unsupported Fields] tab
will appear. You can click on the tab to view the list of fields that are not supported.
The Field Setup pages consists of two section. The upper section is a grid showing available
options of all fields. The lower section contain two panels, the [View tag] panel and the
[Report Field Settings] panel for the selected field.

The grid consists of the following sections:

General
Report Page
Drill Down

General
Field Name Field Name (read only)
Data Type

Data Type (read only)

Size

Maximum field length (read only)

Expression

The expression for custom field (Custom Fields only). See also Custom

62

PHP Report Maker 9 Help


Fields(See 1.11.18).
Caption

Caption to be displayed

Primary KeySpecify the primary key of the table. For use with showing BLOB field as image
only.
You should use the same primary key as declared in the database, do
not change it unless you are absolutely sure that the selected field(s) values
are unique. Otherwise a record cannot be located properly and unexpected
results may occur.
Important

Report Page
Show

Show field in report page

Width

Specify field column width


e.g. If you enter "200px" (without quotes), the output will be style="width:
200px"

Wrap

Enable/Disable wrapping of field value

Filter

Enable/Disable popup filter for the field in the report.


Normally, distinct values in the field will be populated in the popup filter.
However, if the field is group-level fields, the grouping intervals will be
used. If enabled, you can optionally enable "Range" for the filter. If the
data type of the field is datetime, you can also optionally enable relative
filters. See [Report Field Settings] below for details.
Always use as few filters as possible, especially for Detail and
Summary Reports that have a large number of detail records. The more
filters applied, the slower the page loads.
Note

Extended FilterEnable/Disable extended for the field in the report.


Extended Filter is a filter to be displayed at the top of the report. By default
it will be displayed as a textbox for you to enter values and search.
However, it can also be displayed as a combobox and has a default value.
See [Report Field Settings] below for details.
Contrary to popup filters, performance of the report will be enhanced
by the number of extended filters. The more extended filters applied, the
faster the page loads. It is because the extended filter is done by SQL while
popup filter are done by JavaScript.
Note

Filter Opr 1

First filter operator


Each extended filter can use up to 2 filter operators. However, if the
first filter operator is "BETWEEN", the second operator is ignored.
Note

Filter Opr 2

Second filter operator

Drill Down
Detail
Report

If field value is displayed in a report, you can drill down by setting up a


hyperlink linked to a detail report. To setup a detail report, click the "..." to

63

PHP Report Maker 9 Help


open the Drill Down setup form:

Select a report as detail report, then select the parameters. Select Source
Field from the current report and Target Field from the detail report. The
report will then build hyperlinks for the field values to pass the selected field
values from the current repor to the detail report.
To make the detail report shows meaningful details, you need to pass the
required parameters from the current report to the detail report. Select the
field values you need to pass, make sure they are sufficient for selecting the
relevant records in the detail report. See Tutorial - Drill Down Report(See
1.17.8).
Parameter

If checked, the current report can be used a detailed report and the selected
field is a parameter.
Normally you do not need to manually enable this setting, after you set up
detail report using the Drill Down setup form, PHP Report Maker will enable
this for the required fields in the detail report.

Note

Custom field display order by drag-and-drop

You can change the field order defined in the database by simple drag-and-drop. Simply
click the Field Name column to select the field, then drag it to where you want. PHP Report
Maker will generate PHP and display records according to this order. (For Detail and
Summary Report only)

View Tag Panel

64

PHP Report Maker 9 Help


You can click the icon on the View Tag panel toolbar to select how to display the field. After
selecting the View Tag, you can further setup its properties in the View tag panel.

There are two types of View tag, Formatted Text and Image.
Formatted Text - View Tag to display the field value as formatted text with optional
hyperlink. Properties:
Style
Bold

Display as Bold (enclosed with <b> </b> tags)

Italic

Display as Italic (enclosed with <i> </i> tags)

Align

Left/Center/Right/Justify. Align the data (enclosed with <div> </div>


tags)

Format
None

No formatting

Currency

Display in currency format

Date/Time

Display in date format

Number

Display in number format

Percent

Display in percent format

String

Format the field value with specified PHP string function or custom
function

Max Length (List


page)

Truncate the field value at specified max. length and append "..." to the
end.
Note

This setting only applied to memo fields in list page and must be

65

PHP Report Maker 9 Help


larger than 0 to take effect.
Replace CR+LF by Replace Carriage Return + Line Feed by "<br>".
<BR>
Note This setting only applied to memo fields.
Hyperlink
HREF field

Target
Prefix

Display the field as hyperlink with the href attribute set to the value of
this field. It can be the field itself.
Target attribite of the hyperlink. Possible values are: _top, _parent,
_self, or _blank. You can also enter your own.
Prefix added before the HREF field value. You can select one of the
follows:
-

None (no prefix, relative path of URL)


http:// (prefix http:// added, absolute path of URL)
mailto: (prefix mailto: added, email link)
ftp:// (prefix ftp:// added, ftp link)
file:// (prefix file:// added, file link)
news:// (prefix news:// added, newsgroup link)

You can also enter your own partial URL (preceding the HREF field
value)
This setting is a string to be quoted by double quotes, if you want
to use PHP variable, wrap it in "{" and "}". Since "{" can not be
escaped, this syntax will only be recognised when the "$" immediately
follows the "{". Read PHP Strings for more information on parsing
variable in string.
Note

For example, you can enter: (no quotes)

mypage.php?id=
The value of the HREF field will be appended to the end of the your
prefix in the outputted HTML.
If you want pass a field value, you can enter: (no quotes)

mypage.php?myfield={$this->UrlEncode($this->MyField>CurrentValue)}&id=
If you need to pass parameters which should not be URL-encoded, for
example, if you use ew_Encrypt() to encrypt your parameter, you can
enter: (no quotes)

mypage.php?myfield={$this->Raw(ew_Encrypt($this>MyField->CurrentValue))}&id=
Suffix

Suffix added after the HREF field value. You can use this setting to
append additional URL parameters.
For example, you can enter: (no quotes)

&field2={$this->UrlEncode($this->Field2-

66

PHP Report Maker 9 Help


>CurrentValue)}
Since this is a suffix, you should always use "&" at the beginning of the
string.
Custom View Tag
Custom View Tag Display the field value in report page by custom code.
Important

1. Custom View Tag overrides ALL above View Tag settings.


2. Custom View Tag supports Detail and Summary Reports only
and does not support grouping fields.
There are some ready-to-use Custom View Tag for you to choose:

Barcode (including QR code)


Google Map

If your data stores information for above, just click the down arrow
button to open the setup form, enable one of them, then click the
Advanced tab to setup, then click OK to save your settings.
Notes

1. Only one of above Custom View Tag can be selected at a time.


All records will use the same Custom View Tag. For instance,
you can NOT use Barcode for a record and use Google Map
for next record.
2. The above Custom View Tags are provided as examples only.
The third party tools used are not developed by the author of
PHP Report Maker and are not part of PHP Report Maker, NO
TECHNICAL SUPPORT WILL BE PROVIDED.
You can also create your Custom View Tag, they are implemented in
exactly the same way as template extensiion (see Customizing
Template(See 1.16)). Custom View Tags must be placed under the
subfolder "customviewtags" of the installation folder. Each Custom
Viiew Tag must have a XML description file so it can be loaded for
selection. You can open an XML file in the "customviewtags" subfolder
to see the content, which is self-explanatory. Unzip the zip file to see
how it is implemented.
If you want absolute freedom, click the [...] button to enter your own
code to display the your data in your own PHP, HTML and JavaScript.
If you choose to enter your own code, you are completely on
your own to display the field value. Intermediate knowledge in PHP,
HTML and JavaScript is required.
Important

Custom View Tag is HTML, if you want to embed PHP code, use <?php
and ?>, if you want to use JavaScript, use <script

type="text/javascript"> and </script>.


Note

DO NOT use $this in your PHP code. There is no $this in the

context, you can use CurrentPage() to get the current page object.

67

PHP Report Maker 9 Help


To reuse the original code, you can generate scripts without Custom
View Tag first, then customize the field in View page as needed. When
done, copy and paste your customized code to PHP Report Maker user
interface as your Custom View Tag.
The original code will also be generated in a hidden DIV with
id="orig_<table>_<field>", you can also reuse it by JavaScript.
Example 1
Output the field value conditionally:

<?php
if (CurrentPage()->MyField->CurrentValue == "xxx") {
// Assume string field
echo "something";
} else {
echo "something else";
}
?>
Example 2
Output a custom link:

<a href="mypage.php?id=<?php echo


urlencode(CurrentPage()->MyField->CurrentValue) ?>">My
Link</a>
Example 3
Reuse the original code by JavaScript. Replace some code in the orginal
code by regular expression:

<div id="my_unique_id"></div>
<script type="text/javascript">
$("#my_unique_id").html($("#orig_MyTable_MyField").htm
l().replace("xxx", "yyy").concat("zzz")); // Replace
part of the old code by new code, and append something
at the end
</script>
Notes

1. Always use a DIV with unique ID to output your code. DO NOT


use document.write().
2. After outputting the code as innerHTML of the output DIV. You
can also further manipulate the content of the DIV by
JavaScript. Alternatively, you can manipulate the content of the
hidden DIV containing the original code by JavaScript and then
copy the innerHTML to the output DIV.

Image - View Tag to display as Image using <img> tag. The field can be a BLOB field or a
field storing the file name of the image.

68

PHP Report Maker 9 Help

IMG Tag attributes


Width

Specify the width of the image

Height

Specify the height of the image

Image
Resize

Specify if the image should be resized to above dimensions.


This option requires Image Resize extension (for registered users). Also
read Third-party Tools(See 1.7).
Note

File Folder Specify the path of the image. This folder must be relative to the application
root(See 1.12).
If not specified, the global File Folder will be used, read PHP Settings(See
1.11.2).

Hyperlink (same as above)

Field Settings Panel


Crosstab Report
Crosstab

This read-only property show the type of the field in the report,
possible values are:

Row Heading
Column Heading
Value
(Not shown)

You can click the [...] button to edit the report.


Grouping Level

If the field is Row Heading in the report, this read-only


property show the grouping level, possible values are 1-4.

69

PHP Report Maker 9 Help


You can click the [...] button to edit the report.
Show Summary

If the field is Row Heading in the report, this property sets if


summary should be displayed at the end of each grouping level.

Summary Value

If the field is Value field in the report, this property sets the
summary value, possible values are:

Grouping Interval

If the field is Column Heading field in the report and is of


date/time type, this property sets the interval for the field
values, possible value are:

Year filter

AVG
COUNT
MAX
MIN
SUM

Year
Quarter
Month
Date
Date/Time

If the field is Column Heading field in the report and is of


date/time type, and the Grouping Interval is Quarter or
Month, this setting become available. If unchecked, quarters or
months of different year in the report will be displayed together.
If checked, a combobox for the available years will be added
automatically to the report so user can select which year's data
to display.

Comma Separated ValuesIf the field store comma separated values (e.g.
"value1,value2,value3") and you want to split them into
separate values for filtering, enable this setting.
Note

The values must be delimited by commas without spaces.

Detail and Summary Report


Detail/Summary

This read-only property show the type of the field in the report,
possible values are:

Group-level
Value
(Not shown)

You can click the [...] button to edit the report.


Grouping Level

If the field is group-level field in the report, this read-only


property show the grouping level, possible values are 1-4.
You can click the [...] button to edit the report.

70

PHP Report Maker 9 Help


Show Summary

If the field is group-level field in the report, this property sets


if summary should be displayed at the end of each grouping
level.

Grouping Interval

If the field is group-level field in the report and is of


date/time type, this property sets the interval for the field
values, possible value are:

Normal (All distinct values)


Quarter
Month
Week
Day
Hour
Minute

If the field is group-level field in the report and is of string


type, this property sets the interval for the field values, possible
value are:

Normal (All distinct values)


1st Letter
2 Initial Letters
3 Initial Letters
4 Initial Letters
5 Initial Letters

If the field is group-level field in the report and is of numeric


type, this property sets the interval for the field values, possible
value are:

Summary Values

Normal (All distinct values)


10s
50s
100s
500s
1000s
5000s
10000s

If the field is Value field in the report and is of numeric type,


this property sets the summary values, possible values are:

Avg
Max
Min
Sum
Count

More than one summary values are allowed. Select Skip null/0
if you want to skip null and zeroes when calculating above
values.
Comma Separated ValuesIf the field store comma separated values (e.g.
"value1,value2,value3") and you want to split them into

71

PHP Report Maker 9 Help


separate values for filtering, enable this setting.
Note

The values must be delimited by commas without spaces.

Filters
Relative Days

Add the following options in the popup filter and Extended Filter:

Yesterday
Today
Tomorrow

Relative Day PeriodsAdd the following options in the popup filter and Extended Filter:

Relative Weeks

Add the following options in the popup filter and Extended Filter:

Relative Months

Last year
This year
Next year

Add the following options in the popup filter and Extended Filter:

Range

Last month
This month
Next month

Add the following options in the popup filter and Extended Filter:

Past / Future

Last two weeks


Last week
This week
Next week
Next two weeks

Add the following options in the popup filter and Extended Filter:

Relative Years

Last 30 days
Last 14 days
Last 7 days
Next 7 days
Next 14 days
Next 30 days

Past
Future

Add [From] and [To] combobox in the popup filter for user to select
a range of field values to filter.
This option is only available for field with Filter (popup filter)
enabled in above grid, NOT applicable to Extended Filter.
Note

Default values

Default values of Filter (popup filter) without Extended Filter


enabled.
Notes

72

PHP Report Maker 9 Help


1. If both Filter (popup filter) and Extended Filter are
enabled, the default values for Extended Filter will be used
(see below).
2. The default values must be a valid PHP expression of array,
e.g. array("value1", "value2", "value3"). If you
want to specify above special filters, use "@@FilterID". The
filter ID is same the filter name with pascal case (the first
letter in the identifier and the first letter of each subsequent
concatenated word are capitalized) and no spaces, e.g. the ID
for the Last two weeks filter is "LastTwoWeeks", then you
specify it as default value by, e.g.
array("@@LastTwoWeeks").

Notes

1. The optional Relative Days, Relative Day Periods, Relative Weeks, Relative
Months, Relative Years, Past/Future filters are only available for datetime field
with "Filter" enabled in above grid. These options are also not available when the
field is set as Column Headings in Crosstab Report.
2. If you enable a group of filters above but want to disable some of the filters under
the group, you can unregister them using Filters_Load server event, see the
example in Server Events and Client Scripts(See 1.11.15).

Extended Filters
Display as

Specify how the extended filter is displayed, possible values are:

TEXT - textbox (default)


SELECT-ONE - combobox
SELECT-MULTIPLE - listbox (multiple selection)
CHECKBOX - checkboxes
RADIO - radio buttons

Normally the extended filter is displayed as textbox for user to input


search criteria. If this setting is enabled, the extended filter will be
displayed as combobox. Each option in the combobox will be a
distinct value of the field in the database.
If the field not displayed as TEXT, the default filter operator will
be "=", the Filter Opr 1 and Filter Opr 2, if specified, will be
overridden.
Note

Default value

Default value for the extended filter


If you want to auto-select an option in the extended filter, enter a
default value. Make sure the value exists among the options or it will
not be found and no option in the extended filter will be selected.
The default value will be directly assigned to a variable, please
make sure that the input value is a valid PHP expression. If it is a
string, it must be double-quoted. If it is a date, it must be doublequoted and in the format of default data format. If you use SELECTMULTIPLE or CHECKBOX, the imput value will be generated as
array(<Default value>), so you can enter more than one value with
Note

73

PHP Report Maker 9 Help


comma as delimiter, e.g. "value1","value2".
Default value (for
opr 2)

Default value for the extended filter with "BETWEEN" as filter


operator 1 or with filter operator 2 selected. For use with extended
filter displayed as TEXT (textbox) only.
The default value will be directly assigned to a variable, please
make sure that the input value is a valid PHP expression. If it is a
string, it must be double-quoted. If it is a date, it must be doublequoted and in the format of the default date format.
Note

Size

Size attribute of the <select> element (number of visible options).


For use with SELECT-ONE or SELECT-MULTIPLE (see above) only.

Size

Size attributeof the <input type="text> tag (width of an <input>


element, in characters). For use with TEXT (see above) only.

Maxlength

Maxlength attribute of the <input type="text> tag (maximum


number of characters allowed). For use with TEXT (see above) only.

Parent field #1

If a filter is display as TEXT with Auto-Suggest and Force


Selection enabled, or as SELECT-ONE, SELECT-MULTIPLE,
CHECKBOX, RADIO, the filter can have up to 4 parent filter. If a
selection list has parent field(s), the parent/child fields become
Dynamic Selection Lists. When the parent filters' selected value is
changed, the options in the child filter will be filtered accordingly,
based on the field values in the report.

Parent field #2

Parent field #2 (see Parent field #1 above)

Parent field #3

Parent field #3 (see Parent field #1 above)

Parent field #4

Parent field #4 (see Parent field #1 above)

Use dropdown

Show the options in dropdown panel with min-width and max-height


settings, e.g.

RADIO

74

PHP Report Maker 9 Help


CHECKBOX
Note that if the field is displayed as RADIO and Repeat columns
(see below) is 1 (single column), the options will be displayed same
as SELECT-ONE with Use dropdown enabled, radio buttons will be
hidden, e.g.

Similarly, if the field is displayed as CHECKBOX and Repeat


columns is 1 (single column), the options will be displayed same as
SELECT-MULTIPLE and Use dropdown enabled, e.g.

Dropdown minwidth (px)


Dropdown max-

Minimum width for dropdown


Maximum height for dropdown

75

PHP Report Maker 9 Help


height (px)
Option Template

Optional JsRender template for options. See section below.

Auto-Suggest

For use with filter displayed as TEXT, enable this to add AutoSuggest feature to the textbox. The dropdown list is built from
distinct values of the field in the report.
The number of options in the dropdown list is 10 by default, you can
adjust it by changing the Auto-Suggest maximum display entries
setting under Advanced Settings(See 1.14).

Force Selection

For use with filter displayed as TEXT with Auto-Suggest. Forces the
user to select an option from the dropdown list. If user enters other
search criteria in the textbox, it will not be accepted.

Filter

Additional filter to be added to the WHERE clause for getting the


options from database.
The setting must be a valid PHP expression. If it is a string, it
must be single or double quoted.
Note

Order

Repeat columns
Date Interval

Sorting order of the options in the filter. Either ASC (ascending) or


DESC (descending).
For use use RADIO or CHECKBOX only. Specifies the no. of radio
buttons of checkboxes per row.
Display the extended filter as combobox of date interval (for date
fields only)
If the field is date field, other than Display as, you can also further
choose to use date interval. If this setting is enabled, Display as is
overridden. The extended filter will be displayed as combobox with
date intervals instead of distinct values. For example, if you select
"Year", the combobox will only contain options of years, not options
of distinct dates.
Possible date intervals are:

Default Year

Year
Quarter
Month
Day

Default year for the Date Interval combobox. Enter full year (yyyy),
e.g. 2008.
This setting can also be a valid PHP expression (e.g. a function)
which returns the year, e.g. date('Y')
Note

Default Quarter

Default quarter for the Date Interval combobox. Possible values are
1-4.
This setting can also be a valid PHP expression (e.g. a function)
which returns the quarter, e.g. ewr_CurrentQuarter()
Note

76

PHP Report Maker 9 Help


Default Month

Default month for the Date Interval combobox. Possible values are
1-12.
This setting can also be a valid PHP expression (e.g. a function)
which returns the month, e.g. date('n')
Note

Default Day

Default day for the Date Interval combobox. Possible values are 131.
This setting can also be a valid PHP expression (e.g. a function)
which returns the day, e.g. date('j')
Note

Validate

Supported validation formats are:

Integer
Float
Range
Date(yyyy/mm/dd)
Date(mm/dd/yyyy)
Date(dd/mm/yyyy)
Time(hh:mm:ss)
Email
Credit card
GUID
US phone number
US zip code
US social security number
Regular Expression

Notes

1. For simplicity the validation format indicates the date format


with "/" as date separator, but the actual date separator used
in the scripts is determined by the Default date format
setting (see PHP Settings(See 1.11.2)).
2. If Regular Expression, client side and server side
arguments must be entered, depend on if you have enabled
client-side and server-side validation (see PHP Settings(See
1.11.2)), see Arguments (Client-side) and Arguments
(Server-side) below.
3. You can add your own functions for validation. The function
must accept at least one argument (the value) and return
true (valid value) or false (invalid value). If your functions
requires additional arguments, see Arguments (Clientside) and Arguments (Server-side) below. You can add
your function names (comma separated) in the Advanced
Setting CustomValidationFunctions. (See Tools(See
1.14).) Note that since it is both JavaScript and PHP function
name, it must be a string that corresponds to a valid
identifier for both sides. For example, you can enter
"myValidateFunction1,myValidateFunction2" (no quotes). If
you have enabled client side validation, you need to provide
your JavaScript function. If you have enabled server-side
validation, you need to provide your PHP function. You can
put your functions in the Global Code section for server and
client scripts respectively (see Server Events and Client
Scripts(See 1.11.15)) so they are available for use in the
generated scripts.
Arguments (Client- Arguments for the JavaScript functions for validation. For Regular

77

PHP Report Maker 9 Help


side)

Expression and custom validation functions only.


This is JavaScript arguments, it should be comma separated (if
more than one) JavaScript expressions. e.g. If it is a string, it must
be single or double quoted.
Note

If the Validate setting (see above) is Regular Expression, this


setting must be a valid JavaScript regular expression pattern along
with flags that identify how to apply the pattern (delimit the pattern
by "/" characters, not single or double quotes), e.g.

/foobar/i
See Creating a Regular Expression for more information about the
pattern and flags.
Arguments (Server- Arguments for the PHP functions for validation. For Regular
side)
Expression and custom validation functions only.
This is PHP arguments, it should be comma separated (if more
than one) PHP expressions. e.g. If it is a string, it must be double
quoted.
Note

If Regular Expression, arguments must be the the pattern to


search for, as a single or double quoted string, e.g.

'/foobar/i'
See PHP function preg_match for more information about the pattern.
Use date/time
picker

Check this option to use a visual date/time picker instead of manual


input.
Note

1. This option is only available for the date validation formats


with or without time: Date(yyyy/mm/dd),
Date(mm/dd/yyyy), Date(dd/mm/yyyy), and Time
2. The popup calendar and time picker are not developed by the
author of PHP Report Maker and no technical support will be
provided. (See Third-party Tools(See 1.7).)
Error message

Enter the error message to popup if error occurs.


If you use Multi-Language (see PHP Settings(See 1.11.2)), use
Multi-Language Property Editor, see Tools(See 1.14) for details.
Note

Client side events

You can manipulate fields in the Extended Search panel on the client
side quickly with "fields" jQuery plugin (see Server Events and Client
Scripts(See 1.11.15)).
Example 1
Set field values based on current field value

{ // keys = event types, values = handler functions


"change": function(e) {
if (this.value == "xxx") {
$(this).fields("FieldA").value("yyy"); //
Set value to FieldA
//$(this).fields("FieldA").visible(false)

78

PHP Report Maker 9 Help


; // true to show, false to hide
//$(this).fields("FieldA").readonly(true)
; // true as readonly, false as normal (for Text and
TextArea only)
//$(this).fields("FieldA").disabled(true)
; // true as disabled, false as normal
} else {
$(this).fields("FieldB").value("zzz"); //
Set value to FieldB
}
}
}
Example 2
Client side calculation based on user input

{ // keys = event types, values = handler functions


"change keyup": function(e) {
var $row = $(this).fields(); // Get an object
of all fields, each property is a jQuery object of
the input element(s) of a field
var st = $row["UnitPrice"].toNumber() *
$row["Quantity"].toNumber() * (1 $row["Discount"].toNumber()); // Convert to number
and calculate
$row["SubTotal"].value(st); // Set result to
a field
}
}
All client side events are generated in the script
ewrusrevt<version>.js, after changing client side events, remember
to re-generate the .js file.
Note

Manipulating Display Values of Options by Client Scripts


By default, if a field is set as an Extended Filter and to be displayed as SELECT-ONE,
SELECT-MULITPLE, CHECKBOX, RADIO, the options are the distinct values of the field,
the values of the option and the display value are the same value. If the options needs to
show some additional data, you can add additional display values by selecting your own
display values using Lookup_Selecting Server Event (see Server Events and Client
Scripts(See 1.11.15)) and you can add up to 3 additional display values, i.e. totally 4 display
values, e.g.

if ($fld->FldName == "CustomerID") // Assume the field with Extended


Filter is "CustomerID"
$fld->LookupSql = "SELECT DISTINCT CustomerID AS lf, CustomerID AS
df1, CompanyName AS df2 FROM customers ORDER BY CustomerID"; // Get
your own display values from the customer table
In above SQL, the aliases of the fields are arbitrary, but the sequence of the fields must
be the option value first, and then the display values #1 to #4. The display value #2 to #4
are optional.
Note

By default, the options are displayed as comma separated values of the display field values.
If you just want to change the display value separator from comma to other string, you can
use server events such as Page_Load (see Server Events and Client Scripts) to set the field
object's DisplayValueSeparator property, e.g. if the field name is "MyField",

79

PHP Report Maker 9 Help


$this->MyField->DisplayValueSeparator = "-"; // Use hyphen as separator
$this->MyField->DisplayValueSeparator = array(",", "|", "-"); // Array
of separators (max. 3) for display field #2 to #4

Option Template
If you have enabled Use dropdown and added additional display values by Client Script,
you can display the values in your own HTML by Option Template, e.g. continuing above
example, you can add:

'<span class="text-info">{{:df1}}</span> <em><small class="textmuted">({{:df2}})</small>'


Then the options for the field will be displayed in your HTML format like:

Option Template supports the following tags:

{{:lf}}

Option value

{{:df1}}

Display value #1

{{:df2}}

Display value #2

{{:df3}}

Display value #3

{{:df4}}

Display value #4

Notes

1. By default, only {{:lf}} and {{:df1}} have values and both have the same
value, if you want to use {{:df2}}, {{:df3}} and {{:df4}}, you must add your
additonal display values by Lookup_Selecting Server Event as described above.
2. Option template is in the format of JsRender template, refer to JsRender API for
more details.

80

PHP Report Maker 9 Help


If you display the field as TEXT (see above) and use Auto-Suggest (see above),
sometimes you just want to use the additional data in option template but not in the input
textbox, then again you can set the DisplayValueSeparator property by server event such
as Page_Load (see Server Events and Client Scripts). If the separator for a display field is
not specified, the display field value will not be placed in the input textbox You must always
put the additional data in the last (n) display field(s). Then you can hide display field #2 to
#4 by:

$this->MyField->DisplayValueSeparator = array(); // Display field #2 to


#4 hidden

Ajax by Server Events and Client Scripts


Sometimes you may want to access the lookup table by Ajax yourself. For example, after
the user entering a value for a field, you may want to auto-fill another field in your own way,
then you can use Server Events and Client Scripts(See 1.11.15) to do it. Say, if you want to
fill the product price when you select a product number (using products table as lookup
table) when inserting a new record, you can auto-fill the product price field either
asynchronously or synchronously with your code.
Example 1: Auto-Fill synchronously
Write Page_Load server event for your report: (PHP)

ewr_SetClientVar("MyCustomSql", ewr_Encrypt("SELECT UnitPrice FROM


products WHERE ProductID = {query_value}")); // Pass a server side
variable (encrypted SQL) to client side
Note that the WHERE clause of your SQL must contain the tag {query_value} which will
be replaced by the input value.
The variable will be passed to client side as property of the ewrVar object so you can get it
back by ewrVar.MyCustomSql or ewrVar["MyCustomSql"].
Write a Startup Script to attach onchange event: (JavaScript)

$("#x_ProductID").change(function() {
var result = ewr_Ajax(ewrVar.MyCustomSql, $(this).val()); // Send
the encrypted SQL and client side input value to server side by Ajax
for execution and get the result
$("#sv_UnitPrice").val(result); // Set the result (manipulate it
first if necessary) to the target field
});
The function ewr_Ajax() reuses the generated script for Ajax (ewrajax*.php) so there
is no need to write server side handler. For synchronous requests, if the result is a
recordset, it is in the format of array of object. If the result is a row, it is in the format of
object. If the result is a single value, it is in the format of string, remember to convert it to
the proper data type before manipulation. The function also supports asynchronous request,
just pass a callback function as the third argument, but the result from the server side is not
processed and therefore is always in the format of array of object. See the source code of
ewr_Ajax() in the generated ewr*.js for details.
Note

Example 2: Auto-Fill asynchronously

81

PHP Report Maker 9 Help


Write a Startup Script to attach onchange event: (JavaScript)

$("#sv_ProductID").change(function() {
$.post(ewr_CurrentPage(), { "myajax": 1, "token": EWR_TOKEN,
"value": $(this).val() }, function(result) { // Post back your custom
data (with the synchronizer token)
$("#sv_UnitPrice").val(result); // Set the result (manipulate
it first if necessary) to the target field
});
});
Write a server side handler, check your custom data "myajax" in Page_Load server event
and return the required value. In this example, only a single value is required so
ewr_ExecuteScalar() (see Server Events and Client Scripts(See 1.11.15)) is used, e.g.
(PHP)

if (@$_POST["myajax"] == 1 && @$_POST["value"] != "") { // Check if it


is your custom Ajax and if the query value is present
$val = ewr_ExecuteScalar("SELECT UnitPrice FROM products WHERE
ProductID = " . $_POST["value"]); // Get the desired value (assume
ProductID is integer so no need to quote the value)
echo $val; // Return the value (manipulate it first if necessary)
$this->Page_Terminate(); // Terminate the page
}
If you want to return a whole row (as JavaScript object) so you can fill multiple fields, you
may want to use ewr_ExecuteRow() (see Server Events and Client Scripts(See 1.11.15))
and json-encode the row before returning it so that you do not need to convert before using
it in your callback function on the client side, e.g.

$val = json_encode(ewr_ExecuteRow("SELECT * FROM products WHERE


ProductID = " . $_POST["value"]));

1.11.8 Chart Setup


From v8, all charts are JavaScript charts except Candlestick, Funnel and Gantt charts.
Read FusionCharts(See 1.15) for more information.
Note

PHP Report Maker supports charting. It is possible to create more than one charts for each
report. (Note that negative values cannot be plotted.)
After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). Click on any database object to go to the
Chart Setup Page for that object at any time. The Chart Setup Page is next to the Field
Setup page, if the active page is Field Setup Page, click the [Chart] tab to switch to the
Chart Setup Page.
The Chart Setup pages consists of two section. The left section is a list showing all charts for
the report. The right section is a panel showing various properties of the selected chart.

82

PHP Report Maker 9 Help

In the left section, the toolbar has the following buttons:


Add a new chart
Remove selected chart
Move the selected chart up. The sequence determines the displaying order of the charts in
the generated script and in the menu.
Move the selected chart down. The sequence determines the displaying order of the
charts in the generated script and in the menu.
Duplicate the selected chart as a new chart and copy the chart properties. Since each
chart has many properties, this feature enables you to create a new chart faster.
To setup chart properties, select a chart in the left section first, then you can modify its
properties in the right panel.
You should become familiar with the charting terminology so that you'll know what to look
for when you want to edit a chart. Read FusionCharts(See 1.15) first if necessary.

General

83

PHP Report Maker 9 Help


Name

The name of the chart.


This is an internal name of the chart for referencing the chart, it is
recommended that you use alphanumerical characters only for
the name, also make sure the chart names for each report is
unique. This is analogous to field name of a field in a database
table.

Caption

The caption of the chart.


This is the actual caption to be displayed on the chart and is
analogous to field caption of a field in a database table.

Chart type

The type of the chart. Possible values are:

Column 2D Chart
Column 3D Chart
Pie 3D Chart
Pie 2D Chart
Line 2D Chart
Bar 2D Chart
Area 2D Chart
Doughnut 2D Chart
Candlestick (Flash chart)
Funnel Chart (Flash chart)
Multi-series Column 2D Chart
Multi-series Column 3D Chart
Multi-series Line 2D Chart
Multi-series Area 2D Chart
Multi-series Bar 2D Chart
Stacked Column 2D Chart
Stacked Column 3D Chart
Stacked Area 2D Chart
Stacked Bar 2D Chart
Multi-Series Column 2D Line Dual Y Chart
Multi-Series Column 3D Line Dual Y Chart
Doughnut 3D Chart
Multi-series Bar 3D Chart
Stacked Bar 3D Chart
Bar 3D Chart
Scroll Charts - Note that not all charts support scrolling,
only the Column 2D, Line 2D and Area 2D charts are
scrollable. To enable scrolling, go the [Advanced] tab (see
below) and set numVisiblePlot to a value larger than 0.

Show

Show or hide the chart in the report page.

Position

The position of the chart in the report. Possible values are:

Top
Bottom
Left
Right

Default is Bottom. Note that by default the dimension of each chart


is 550px(W) x 450px(H), if you put the chart on left or right of the
report, the user may to need to scroll horizontally to view the chart.

84

PHP Report Maker 9 Help


Sort Type

Specifies how to sort the data for charting. Possible values are:

NO SORT - default, data not sorted


X ASC - sort by category labels in ascending order
X DESC - sort by category labels in descending order
Y ASC - sort by values in ascending order
Y DESC - sort by values in descending order
RUN TIME - sort by above in runtime, a combobox will be
generated above the chart for user to choose how to sort

Custom sort sequenceCustom sort the data for charting. You can enter comma separated
values, e.g. if Sort Type is X ASC or X DESC, the chart is sorted
by category labels, then you can enter your custom order by:

label1,label2,label3,...
If the labels contains comma, you can enter an array, e.g.

array("label1","label2","label3",...) or
["label1","label2","label3",...] (the latter syntax
requires PHP >= 5.4)
Width

Width of the total area of the chart. Default is 550 (pixels).

Height

Height of the total area of the chart. Default is 450 (pixels).

Background color

The background color of total area of the chart

Show labels

Show labels on the (usually horizontal) axis that displays the


category labels for all the data series.

Show values

Show values as data labels at data points to indicate the specific


value or category.

Show hover

Show hovering box when the user moves the mouse cursor over the
data point. The hovering box shows the label and value of the data
point.

Transparency (%)

Transparency of the data point. 0% is transparent, 100% is opaque.

Color palette

Specify colors of the data points. You can customize your own color
palette by clicking [...] button and change the colors.
Alternatively, you can use FusionCharts' built-in palette
attribute, in such casesm set this setting as empty.
Note

Category (X) Axis


Title

X-axis (category) title. Displays the category of the plotted data.

Category field

The field that contains the categories of the chart

Value (Y) Axis


Title

Title 2

Y-axis (value) title. Displays a description for the scale of values


against which the data is plotted.
Secondary Y-axis (value) title 2. For use with Multi-Series Column

85

PHP Report Maker 9 Help


2D/3D Line Dual Y charts only.
Value field

The field that contains the values of the chart

Summary Value

Summary value of the chart, by default it is same as the summary


value of the field. Supported values are:

SUM
AVG
COUNT
MIN
MAX

Open field

The field that contains the "open" values of the chart. For
Candlestick charts only.

High field

The field that contains the "high" values of the chart. For
Candlestick charts only.

Low field

The field that contains the "low" values of the chart. For
Candlestick charts only.

Close field

The field that contains the "close" values of the chart. For
Candlestick charts only.

Name field

The field that contains the names of the vertical lines. Vertical lines
are only drawn if the field value is not empty. For Candlestick
charts only.

Series
Series type

Specify how the series are defined. Possible values are:

Series Field - Values for all series are from the same field.
The series are defined by a field that contains the series
name.
Series Per Field - Values of each values are from different
columns of the source table.

Series field

Specify the field that contains the series name when Series type is
set as Series Field.

Series fields

Specify the field names of each series when Series type is set as
Series Per Field. Click the [...] button to open the setup from and
select the column for each series.

Drill Down
Detail Report

You can drill down the chart values (Y Axis) by setting up a detail
report.
To setup a detail report, click the [...] button to open the Drill Down
setup form. Select a report as detail report, then select the
parameters. Select Source Field from the current report and
Target Field from the detail report. The report will then build
hyperlinks for the field values to pass the selected field values from
the current report to the detail report.

86

PHP Report Maker 9 Help


To make the detail report shows meaningful details, you need to
pass the required parameters from the current report to the detail
report. Select the field values you need to pass, make sure they are
sufficient for selecting the relevant records in the detail report.
Notes

1. To drill down a chart value, you should at least pass the


Category field as parameter.
2. If you use Series Field (see above), you should also pass
the Series field(s).
Setting up of detail report for chart is exactly same as setting up
detail report for reports, see Tutorial - Drill Down Report(See
1.17.8). If you want to drill down to another chart directly, you can
create a report and disable the Show Report option, see Table
Setup(See 1.11.6).
Trendline (up to 4 trendlines)
Show

Show the trend line

Start value

The starting y-axis value for the trendline. Say, if you want to plot a
slanted trendline from value 102 to 109, the startValue would 102.

End value

The ending y-axis value for the trendline. Say, if you want to plot a
slanted trendline from value 102 to 109, the endValue would 109. If
you do not specify a value for endValue, it would automatically
assume the same value as startValue.

Color

Color of the trend line and its associated text.

Display value

If you want to display a string caption for the trend line by its side,
you can use this attribute. Example: displayValue='Last Month
High'. When you don't supply this attribute, it automatically takes
the value of startValue.

Thickness

Thickness of the trend line

Is trend zone

Whether the trend would display a line, or a zone (filled colored


rectangle).

Show on top

Whether the trend line/zone would be displayed over other


elements of the chart.

Alpha

Alpha (transparency) of the trend line (%)

Tool Text

Specifies the text that will be displayed when mouse is hovered


over the trend line.

Value on right

Renders the trend-line label on the right. Default is to render on the


left.

Dashed

Make trend line dashed. Default is normal.

Dash length

Sets the length of each dash of a trend line(in pixels).

Dash gap

Sets the gap between two consecutive dashes in trend lines (in

87

PHP Report Maker 9 Help


pixels).
For secondary axis

Show the trend line on the secondary y-axis. By default, the trend
line shows up on the primary y-axis.

Advanced
There are many other advanced chart properties for configuring the chart. Select your chart
and click the [Advanced] tab to setup.
Not all displayed advanced properties are supported by each chart type. Refer to
FusionCharts documentation for list of the supported advanced properties of each chart type.
Note

Notes

1. If a setting is a checkbox (boolean) and it is displayed as null (not checked and not
unchecked), that means it will use the chart's default value.
2. If a setting is a number and it is displayed as 0 in gray (it does not mean the real
zero, which will be displayed in black), that means it will use the chart's default
value.
3. The advanced chart setting exportEnabled is for exporting the chart only, see
FusionCharts documentation.
Grid Component

88

PHP Report Maker 9 Help


If you are using FusionCharts (not FusionCharts Free), the advanced chart properties
include Grid Component which can display single-series data in a tabular format. You can
combine the grid component with any single-series chart to form a good looking combo.

To enable Grid Component for your singe-series chart, scroll to the Grid Component
section under the Advanced table, enable useGridComponent property and then set the
related properties under it.

Also See:
FusionCharts(See 1.15)
Tutorial - Chart
(See 1.17.11)Tutorial - Drill Down Report(See 1.17.8) (See 1.17.11)

1.11.9 Gantt Chart Setup


NoteGantt

chart is implemented with FusionCharts Free which is Flash based. It may not
be displayed by mobile devices and it does not support export.
A Gantt chart is created from one existing table or view. If you need to display data from
more than one table or view, join them first using a view in your database, see Preparing
Your Data for Reports(See 1.9).
After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). To create a report, right click the
database pane and select [Add Report (Gantt)]. Alternatively, you can click [Edit] in the
main menu and then select [Add Report (Gantt)].
The Gantt Chart setup form will show up:

89

PHP Report Maker 9 Help

Enter your settings to setup your Gantt chart.


General
Name

Name of the chart

Source table (Task table)Source table of the chart. It must be the task table which must
at least have the following 4 fields, the field names can be
different from below though:

start='Date': This attribute sets the start date for this


particular task
end='Date': This attribute sets the end date for this
particular task.
Id='Alphanumeric Value': Each task needs to have a id,
so that it can be easily referenced back in XML. You can
set the id of the task using this attribute.
name='String Name': This attributes sets the name of
the task, which will be displayed on the chart.

Your task table can have the following optional fields. The field
names in the table must be same as below, including
lettercase. Add the fields in your table as needed.

90

PHP Report Maker 9 Help

processId='Process Id': Each task needs to belong a


process, as we had earlier indicated. For this attribute,
you need to specify the process id, against which you
want to plot this task. Process id are assigned by you in
the optional process table (see below). If you use
process table, this field is compulsory.
hoverText='hover caption text': If you want to display
more information as the tool tip of this task bar, you can
specify that hover text here.
link='URL Encoded link': If you intend to provide a
hyper link for the task bar, you can set the link in this
attribute.
animation='1/0': This attribute lets you set whether
this particular task bar would animate or not.
font='Font Face': Defines the font face in which text will
be rendered.
fontSize='Numeric Value': Defines the font size in
which text will be rendered.
fontColor='Hex Color': Defines the color in which text
will be rendered.
color='Hex Color': This attribute helps you define the
background color for the task bar. If you need to show a
gradiented background, just specify the list of colors
here using a comma.
alpha='Numeric Value': This attribute helps you specify
the transparency of the task bar.
showBorder='1/0': This attribute lets you specify
whether a border would appear around the task bar.
borderColor='Hex Color': Color of the task bar border.
borderThickness='Numeric Value': Thickness of the
task bar border.
borderAlpha='Numeric Value 0-100': Alpha of the task
bar border.
showName='1/0': Configuration whether to show the
name of this tasks over the task bar.
showStartDate='1/0': Configuration whether to show
the start date of this task on the left of task bar.
showEndDate='1/0': Configuration whether to show
the end date of this task on the right side of the task
bar.
height='Numeric Value': If you intend to specify an
explicit height for the task bar, you can do so using this
attribute. Otherwise, FusionCharts automatically
calculates the best possible value.
topPadding='Numeric Value': If you intend to specify
an explicit top padding for the task bar, you can do so
using this attribute. Otherwise, FusionCharts
automatically calculates the best possible value.
taskDatePadding='Numeric Value': If you intend to
specify an explicit distance between task bar and date
textbox, you can do so using this attribute. Otherwise,
FusionCharts automatically calculates the best possible
value.

Remember that you DO NOT need to assign a "#" at the


beginning of the hex color code for the color fields. In fact,
whenever you need to provide any hex color code, you do not
have to assign the # at the beginning.
Note

Chart width (px)

Width of the chart in pixels

91

PHP Report Maker 9 Help


Chart height (px)

Height of the chart in pixels

Fields
Task ID

The task ID field of the Task table. The IDs should be


alphanumeric values (integer field recommended).

Task name

The task name field of the Task table. The field should be a
string (varchar) field.

Start date

The start date field of the Task table. The field should be a
date/time field.

End date

The end date field of the Task table. The field should be a
date/time field.

From task ID (optional) Optional. A field with alphanumeric value (integer field
recommended) to specify a connector for the task (as end task).
The field should contain value of the start task ID from where
the connector will originate
This setting simplifies using single connector for each task (start
from the end of the specified task and end at the start of the
current task) and eliminates the need for a connector table. If
you need to use more than one connectors for ea ck task, you'll
need to use connector table (see below).
Milestone date (optional)Optional. A date/time field to specify a milestone of the task.
This setting simplifies using single milestone for each task and
eliminates the need for a milestone table. If you need to use
more than one milestones for ea ck task. You'll need to use
milestone table (see below).
Categories
Category 1

Define the category of the chart.


A Gantt chart is constructed with a horizontal axis representing
the total time span of the project, broken down into increments
(for example, days, weeks, or months). Gantt chart allows you
to define up to 3 categories and sub-categories to show dates
broken into smaller units. For example, if you were to show a
Gantt Chart spanning 2 years, you can the first sub-category as
quarters, then divide these quarters into months.
You can select a pre-defined category from the dropdown list.
Supported values are:

_YEAR
_QUARTER
_MONTH
_WEEK
_DAY

If you just want a text header, you can just enter your text
instead of selecting from the dropdown list.

92

PHP Report Maker 9 Help


Category 2 (Optional)

Optional. A subcategory. Supported values same as above.

Category 3 (Optional)

Optional. A subcategory. Supported values same as above.

Advanced (Optional)
Process table

The vertical data table of the chart representing the tasks that
make up the project (for example, if the project is outfitting
your computer with new software, the major tasks involved
might be: conduct research, choose software, install software) is
called process names.
This table is optional. If each process has only one task only,
you do not need this table at all. This is only required if you
need multiple tasks for each process.
The field names in the table must be same as below,
including lettercase. Only the name and id field are required,
other fields are optional. Add the fields in your table as needed.

name='Display Name': This attribute sets the name of


the process, which will be displayed on the chart.
id='Alphanumeric Id': Each process needs to have an ID
specified by you. Based on this id, the tasks related to
this process will be plotted against it.
link='URL Encoded link': If you wish to hyperlink each
process name on the chart, you can use this attribute to
specify the link for each process name.
font='Font Face': Defines the font face in which text will
be rendered.
fontSize='Numeric Value': Defines the font size in
which text will be rendered.
fontColor='Hex Color': Defines the color in which text
will be rendered.
isBold='1/0': Sets whether the text will be shown as
bold or not.
isUnderLine='1/0': Sets whether the text will be shown
as underline.
verticalPadding='Numeric Value': Specifies the top
margin.
align='left/center/right': Specifies the horizontal
alignment of text.
vAlign='left/center/right': Specifies the vertical
alignment of text.

Each Gantt chart can have one data table, which can show
tabular information along side the process names. After
selecting the process table, you can click the [...] button and
select up to 6 fields from the process table.
Milestone table

Milestones are important checkpoints or interim goals for a


project. You can represent them using stars, diamonds etc on
Gantt Chart.
This table is optional. If each task has only one milestone only,
you do not need this table at all. This is only required if you
need multiple milestones for each task.
The field names in the table must be same as below,

93

PHP Report Maker 9 Help


including lettercase. Only the date and taskId field are
required, other fields are optional. Add the fields in your table as
needed.

Connector table

date='Date': Date where you want the milestone to be


placed.
taskId='Task Id': The id of the task over whose bar you
want the milestone to be placed.
shape = 'star/polygon': Shape of the milestone.
numSides='Numeric Value 3-x': Number of sides that
the milestone would have. For example, for a diamond,
you can set shape to star and then set this value to 4.
startAngle='Angle': Starting angle of the polygon/star
drawn as milestone.
radius='Numeric value': Radius of the polygon/star
drawn as milestone.
borderColor='Hex Color': Border color of the milestone.
borderThickness='Numeric Value': Border thickness of
the milestone.
color='Hex Color': Background fill color of the
milestone.
alpha='Numeric Value 0-100': Transparency level of the
milestone.

Task connectors are used to connect various task bars on the


chart, to indicate the flow of process. Using task connectors, we
can show the dependency of one task over another, or the
general flow of the entire set of tasks.
This table is optional. If each task has only one connector only,
you do not need this table at all. This is only required if you
need multiple connectors for each task.
The field names in the table must be same as below,
including lettercase. Only the fromTaskId and toTaskId
field are required, other fields are optional. Add the fields in
your table as needed.

fromTaskId='Task Id': Id of the task (which you had


earlier specified as an attribute of <task> element) from
where the connector will originate.
toTaskId='Task Id': Id of the task (which you had
earlier specified as an attribute of <task> element) from
where the connector will terminate.
fromTaskConnectStart='1/0': Configuration whether
the connector will join the originating task bar at the
start position or end position.
toTaskConnectStart='1/0': Configuration whether the
connector will join the terminating task bar at the start
position or end position.
Color='Hex Code': Color of the connector.
Thickness='Numeric Value': Thickness of the connector
line in pixels.
Alpha='Numeric Value 0-100': Transparency of the
connector line.
isDashed='1/0': Configuration whether the connector

94

PHP Report Maker 9 Help


line will appear as dashed/solid line.

Trendline table

Trendlines can be used to show important dates on the chart like today or scheduled date etc.
This table is optional. This is only required if you need to draw
trendlines in the chart.
The field names in the table must be same as below,
including lettercase. Only the start field is required, other
fields are optional. Add the fields in your table as needed.

start='Date': Start date for the trend zone.


end='Date': End date for the trend zone. If you intend
to draw a trend line instead of a trend zone, then you do
not need to specify a value for this attribute.
displayValue='String Value': If you want to display
your custom value beneath the trend line, you can do so
here. Example, you can show the trend line and label it
as "Today".
color='Hex Color': Color of the trend line.
thickness='Numeric Value': Thickness (in pixels) of the
trend line.
alpha='Numeric Value 0-100': Transparency level of the
trend line/zone.
isTrendZone='1/0': Option to set whether it will appear
as a trend zone or a trend line.

Press [OK] to finish setup. When a report is created, the field settings will be copied from
the source table. But from then on, the Report has its own field settings and is much like
other table in PHP Report Maker.
To edit a Report, right click the Report in the database pane and select [Edit Report].
Alternatively, you can select the Report first, then click [Edit] in the main menu and then
select [Edit Report].

Notes

1. After a report is created, a report works independently from the source table it
based on. Changing the structure of the source table does not change the report. If
you delete a field in the source table that is used by a report, the report will fail.
Also, a Report has its own field settings, changing field settings in the source table
does not change the field settings in related Reports.
2. Report supports User ID and User Level. (See Security(See 1.11.4))

Also See:

95

PHP Report Maker 9 Help


Tutorial - Gantt Chart
(See 1.17.12)Security Setup(See 1.11.4) (See 1.17.7)

1.11.10 Using Custom View


WARNING! Custom View expects simple SELECT statements only, they are NOT designed
to and cannot replace views provided by the database. PHP Report Maker supports creating
database view, you should always use database views whenever available. Views provided
by database allow you to use them more like regular tables. If you use MySQL 5, you should
ALWAYS use MySQL view.
A Custom View is basically a stored SELECT statement. Custom View allows you to
save your SELECT statements in a project as a virtual table. If your database does not
support views (e.g. MySQL 4), you'll find this feature useful.

Converting Custom View to Database View


Custom View expects a simple SELECT statement only. If you create a Custom View with a
SELECT statement with some complex clauses, or with an UNION statement instead of a
single SELECT statement, the sorting or searching may fail. In such cases you should change
the Custom View to database view. PHP Report Maker allows converting your Custom View
to database view provided that the database user have CREATE VIEW privilege.
After loading the database in PHP Report Maker, the database objects (tables, views, custom
views and reports) will be shown in the left pane (the database pane). To convert a Custom
View to database view, right click the Custom View in the database pane and select
[Convert Custom View to View]. Alternatively, you can select the Custom View first, then
click [Edit] in the main menu and then select [Convert Custom View to View]. After
creating the view, the existing Custom View and field settings will be moved to the new
view. If your project is connected to a development database, export the new views and
recreate them on your production database during deployment.
If under some circumstances you cannot change Custom View to database view (e.g. you
are still using MySQL 4.1) and you must use Custom View, you can try use a derived table
(supported since MySQL 4.1) in the format of SELECT * FROM (<Original SQL>) AS t as the
SQL of the Custom View. (Note for MySQL 4.1 users only: If you upgrade to MySQL 5 later,
you should convert your Custom Views to MySQL views. If you use the derived table
approach before, edit the Custom View, remove the derived table and use the original SQL
first, MySQL 5 still does not support subquery in the FROM clause when creating view.)

Creating Custom View


To create a custom view, right click the database pane and select [Add Custom View].
Alternatively, you can click [Edit] in the main menu and then select [Add Custom View].
The Custom View Setup window will show up:

96

PHP Report Maker 9 Help

PHP Report Maker will give the new Custom View a temporary name, CustomView<n>,
where n is an integer. If you want to change the name, enter a new name in the [Custom
View name] edit box in the main toolbar.
It is recommended that the built-in visual query builder be used to build your SQL. The
query builder interface is intuitive and fully supports drag-n-drop, in most cases you don't
need to type the table or field names.
On the left hand side, the available tables are displayed in the table pane. On the right hand
side, there are three tabs: [Builder], [SQL] and [Result]. (The [Result] tab will only be
visible after you execute the SQL.)

Builder
To build your SQL, drag your tables from the table pane on the left to the builder area and
check the required fields.
To create a link between two objects (i.e. join them) you should select the field by which
you want to link an object with another and drag it to the corresponding field of another
object. After you finish dragging, a line will appear between the linked fields. The join type
created by default is INNER JOIN, i.e. only matching records of both tables will be included
in resulting dataset. To define other types of joins you should right click the link and select
the Edit... item from the drop down menu or simply double-click it to open the Link
Properties dialog. This dialog allows you to define join type and other link properties.
The easiest way to add a field to the list of query output fields is to check the checkbox at
the left of field name in the Query Building Area. To include all the fields of an object you
should click the checkbox at the left of the asterisk item of an object.
Note

You should select your fields explicitly, not using the * symbol.

97

PHP Report Maker 9 Help


Another way is to select a field name from the drop-down list of the Expression column in
the Columns Pane. And the most common way is to write any valid expression to the
Expression column in the Columns Pane.
To remove a field from the list of query output fields you should uncheck the checkbox at
the left of field name in the Query Building Area or you may remove it by unchecking the
Output column checkbox. Such operations as removing lines from the Columns Pane or reordering output fields are available by right clicking on the left-most gray column via the
drop-down menu.
To define sorting of output query fields you should use the Sort Type and Sort Order
columns of the Columns Pane.
The Sort Type column allows you to specify how the fields will be sorted - in Ascending or
Descending order.
The Sort Order column allows you to setup the order in which fields will be sorted, if there
are more than one field to sort specified.
To cancel sorting by some field you should clear the Sort Type column for this field.
To define criteria for the expression listed in the Columns Pane you must use the Criteria
column.
Here you should write the criteria omitting the expression itself. For get the following criteria
in your query

WHERE (field >= 10) AND (field <= 20)


you should write

>= 10 AND <= 20


in the Criteria column.
You may specify several criteria for one expression using the Or... columns. These criteria
will be concatenated in the query with the OR operator.
To setup grouping by some of the fields and/or to define aggregate functions on grouped
rows you may use the Group by column.
You may select one of the following values for this column from the drop-down list:

"Expression" and "Where": These values are used when no grouping is specified.
The "Expression" value is set when this expression is used as output expression in
the SELECT clause and nothing else. The "Where" value is set automatically when
you define a criteria to this expression that results in including this expression to the
WHERE clause. Normally you shouldn't care about value of the Group By column
when you don't want to define grouping.
"Group by" and "Having": These values are similar to the previous two, but used
when you want to define grouping in your query. In this case you should set the
"Group by" value for all columns you want to group by. Specifying criteria for the
grouped columns will include these criteria in the HAVING clause. If you want to
include an expression ONLY in the HAVING clause you should set the "Having" value
in the Group By column for this expression.
Aggregate functions (Count, Sum, etc): By selecting one of these values you will
create an aggregate expression for the value indicated in the Expression column.

98

PHP Report Maker 9 Help

SQL
You can always click the [SQL] tab to check the SQL generated by the query builder, the
SQL editor is also syntax-highlighted to enhance the readability of the SQL.

The SQL tab is actually an SQL editor, you can type your SQL directly without using the
query builder here, or paste your SQL from elsewhere, or open a saved SQL script (*.sql)
from file.
Notes

1. If the SQL is not generated by the built-in query builder, there are chances that
query builder cannot parse the SQL and display it visually in the [Builder] tab.
However, this does not necessarily mean that the SQL is invalid, you can verify its
validity by executing it (see below) and check if it returns the data you want in the
[Result] tab. And you can create the Custom View directly by click the OK button
without switching to the [Builder] tab.
2. If you type your SQL directly, always use aliases (use "AS") for fields whenever
applicable. Otherwise, the alias will be assigned by the database and you will not be
able to refer to the field with a known and meaningful name.

Result
When you have finished your SQL, you can test the SQL by any one of the following ways:
(for "DIRECT" connection only)

Clicking the
[Execute] button in the toolbar
Pressing [F9] on your keyboard
Clicking [Query] in the menu and then [Execute]

99

PHP Report Maker 9 Help

The [Result] tab will become visible and display the result data. If the data is correct, the
Custom View setup is almost done.
Note: Executing the SQL is for testing the SQL only. The data displayed in the [Result] tab
will not show the memo fields and blob fields, they may be represented by "(MEMO)" and
"(BLOB)" only. This is not related to the data that will be displayed by the generated scripts.
Since a Custom View is based on an existing table, there is an option that the fields in the
Custom View use the same Field Setup(See 1.11.7) (Edit Tags, View Tags, etc.) as the
source table. If you want to copy field settings, check the checkbox [Copy field settings
from source table (when applicable)]; if not, uncheck it. Then you can press [OK] to
finish.
Note: "when applicable" means that if enabled, field settings will be copied from the
source table when a new Custom View is created, or when a new field is found after editing
a Custom View, and the field can be found from existing tables. (This is also why building a
SQL with the built-in query builder and not using * symbol are recommended, these ensure
that the SQL can be parsed and therefore the source table and source field can be found.)
When a Custom View is added, PHP Report Maker will load it and display it in the database
pane and Table Setup page under the [Custom Views] node. To view the SELECT
statement of the Custom View, right click the Custom View in database pane and select
[Object Properties]. Alternatively, you can select the Custom View first, then click
[Project] in the main menu and then select [Object Properties].
To edit a custom view, right click the Custom View in the database pane and select [Edit
Custom View]. Alternatively, you can select the Custom View first, then click [Edit] in the
main menu and then select [Edit Custom View].
When a Custom View is added or edited, PHP Report Maker will check the SQL. If the SQL is
invalid, the icon of the Custom View will have a cross on it like
, you can view the error in
the [Object Properties] window and then edit the Custom View to correct the SQL.

100

PHP Report Maker 9 Help

Important

1. After a Custom View is created, it works independently from the table(s) it based on.
Changing the structure of the source table(s) does not change the Custom View. If
you delete a field in the source table that is used by a Custom View, the Custom
View will fail. You should edit the Custom View to update the SELECT statement.
Also, a Custom View has its own field settings, changing field settings in the source
table does not change the field settings in related Custom Views.
2. During searching, sorting and grouping, PHP Report Maker generated codes need to
change the WHERE and/or ORDER BY clause of SQL for the list page dynamically.
For Custom Views, since there might be fields with aliases, it is necessary to use the
actual expressions of the aliases in order to ensure the result SQL works. For
example, if you have a field, "UnitPrice*12 AS TotalPrice" in your SQL, you cannot
sort using "ORDER BY TotalPrice", you need to use "ORDER BY UnitPrice*12".
Therefore, if your Custom View contain fields with aliases, it is important that the
SQL can be parsed correctly by PHP Report Maker. To make sure that, here are the
recaps:
a. It is recommended that the built-in visual query builder be used to build
your SQL.
b. You should select your fields explicitly, not using the * symbol.
c. If you type your SQL directly, always use aliases (use "AS") for fields
whenever applicable.

1.11.11 Detail and Summary Report Setup


A report is created from one existing table or view. If you need to display data from more
than one table or view, join them first using a view in your database, see Preparing Your
Data for Reports(See 1.9).
After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). To create a report, right click the
database pane and select [Add Report (Detail/Summary)]. Alternatively, you can click
[Edit] in the main menu and then select [Add Report (Detail/Summary)].
The Report Setup window will show up:

101

PHP Report Maker 9 Help

The Report Setup window has 4 tabs. Go through these tabs one by one to setup your
report.

General
PHP Report Maker will give the new Report a temporary name, Report<n>, where n is an
integer. If you want to change the name, enter a new name in the [Report name] edit box.
Then you can select a table, or a view, or a Custom View form the [Table or View]
combobox.
The field in the table will be displayed in the [Available fields] listbox, select fields you
want to display by moving them to the [Selected fields] listbox. It is recommended that
you select only the fields you required or the report page may be too wide to view without
scrolling.
This settings in this tab are mandatory.

Grouping Levels

102

PHP Report Maker 9 Help

You can optionally add up to 6 grouping levels and choose to show summary for each level.
Select the grouping field for each level in the comboboxes.
You can sort the values of the grouping fields in either ascending or descending order. After
selecting the grouping fields, press the buttons next to the comboboxes to change the sort
order.
To enable summary, check [Show Summary] next to the grouping fields. When any of the
[Show Summary] fields is selected, the [Summary Values] tab will appear for you to
setup the summary values later. (See below)

Sort Order

103

PHP Report Maker 9 Help

You can optionally sort records by up to 6 fields, in either ascending or descending order.
Select the sorting fields in the comboboxes. Press the button to change the sort order.

Summary Values

104

PHP Report Maker 9 Help

If any of the [Show Summary] checkboxes is selected in the [Grouping Levels] tab, this
tab will become visible. You can optionally select aggregate values for each selected numeric
field. Available summary values are [Sum], [Avg], [Min], [Max] and [Count]. These
summary values will be shown at the end of the grouping levels with [Show Summary]
enabled. You can optionally enable [Skip null/0] to skip null and zeroes when calculating
the summary values.
In this tab, you can also choose what to show:
[Detail and Summary] - Records belonged to each grouping level will be displayed under
the grouping level title, then followed by the summary.
[Summary Only] - Only the summary for each grouping level will be displayed. Other fields
(not grouping level) will not be displayed.
You can also optionally choose to [Show page summary] and/or [Show grand
summary] for all records at the end of the report. If [Show page summary] is enabled,
the summary for the records in the current page will be displayed at the end of the page. If
[Show grand summary] is enabled, the summary for all the records in the report will be
displayed at the end of the page.
If you choose [Summary Only], you can optionally choose [Show compact summary
view]. If enabled, the summary for each group will be diplayed as columns instead of at the
end of each group.
Press [OK] to finish setup. When a report is created, the field settings will be copied from
the source table. But from then on, the Report has its own field settings and is much like
other table in PHP Report Maker.

105

PHP Report Maker 9 Help


To edit a Report, right click the Report in the database pane and select [Edit Report].
Alternatively, you can select the Report first, then click [Edit] in the main menu and then
select [Edit Report]. Note that the source table of a report cannot be changed.

Important Notes

1. After a report is created, a report works independently from the source table it
based on. Changing the structure of the source table does not change the report. If
you delete a field in the source table that is used by a report, the report will fail.
Similarly, if the report is based on a Custom View and you change the SELECT
statement of the Custom View, the report may fail if a field in the report is missing.
However, in the latter case, when a Custom View is edited, PHP Report Maker will
check the validity of the SQL. If the SQL fails, both the Custom View and reports
that based on the Custom View will be displayed with a cross in the icon, like

and

. Also, a Report has its own field settings, changing field settings in the source
table does not change the field settings in related Reports.
2. Report supports User ID and User Level. (See Security(See 1.11.4))

Also See:
Security Setup(See 1.11.4)
Tutorial - Detail and Summary Report(See 1.17.7)

1.11.12 Crosstab Report Setup


A report is created from one existing table or view. If you need to display data from more
than one table or view, join them first using a view in your database, see Preparing Your
Data for Reports(See 1.9).
After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). To create a report, right click the
database pane and select [Add Report (Crosstab)]. Alternatively, you can click [Edit] in
the main menu and then select [Add Report (Crosstab)].
The Crosstab Report Setup window will show up:

106

PHP Report Maker 9 Help

The Crosstab Report Setup window has 4 tabs. Go through these tabs one by one to setup
your report.

General
PHP Report Maker will give the new Report a temporary name, Report<n>, where n is an
integer. If you want to change the name, enter a new name in the [Report name] edit box.
Then you can select a table, or a view, or a Custom View form the [Table or View]
combobox.
This settings in this tab are mandatory.

Row Headings

107

PHP Report Maker 9 Help

Select the field that you want display the field values as row headings. You can optionally
select up to 6 fields. Select fields in the order you want information displayed in the row
headings. For example, you could sort and group values by Country and then State.
You can sort the values of the row heading fields in either ascending or descending order.
After selecting the fields, press the buttons next to the comboboxes to change the sort
order.
Check Show summary if you want to show sumary for each group.

Column Headings

108

PHP Report Maker 9 Help

Select the field that you want display the field values as column headings. For example, you
would select Employee Name to see each employee's name as a column heading.
You can sort the values of the column heading field in either ascending or descending order.
After selecting the fields, press the buttons next to the comboboxes to change the sort
order.
If the field is of date/time type, the [Grouping Interval] property sets the interval for the
field values, possible value are:

Year
Quarter
Month
Date
Date/Time

If the field is of date/time type, and the [Grouping Interval] is Quarter or Month, the
[Year filter] setting become available. If unchecked, quarters or months of different year in
the report will be displayed together. If checked, a combobox for the available years will be
added automatically to the report so user can select which year's data to display.
If you use Date or Date/Time, make sure the distinct values of date or date/time in
the source table are not too many or the number of columns may exceed that your database
can support. For example, if you have orders each day in a year and you should not use
Date as grouping interval or there will be 365 columns! In addition, even if your database
can support it, the user will still need to scroll horizontally to see the report.
Note

Value

109

PHP Report Maker 9 Help

Select the [Field] and the [Summary value] that you want to calculate for each column
and row intersection. For example, you could calculate the sum of the field Order Amount for
each employee (column) by country and state (row). Possible values of summary value are:

AVG
COUNT
MAX
MIN
SUM

If you want to include sums for each row, select [Includes row sums] for the report.
You can choose up to 4 summary values.
Finally, you can choose to [Show page summary] and/or [Show grand summary] for all
records at the end of the report. If [Show page summary] is enabled, the summary for
the records in the current page will be displayed at the end of the page. If [Show grand
summary] is enabled, the summary for all the records in the report will be displayed at the
end of the page. These options are enabled by default.
Press [OK] to finish setup. When a report is created, the field settings will be copied from
the source table. But from then on, the Report has its own field settings and is much like
other table in PHP Report Maker.
To edit a Report, right click the Report in the database pane and select [Edit Report].
Alternatively, you can select the Report first, then click [Edit] in the main menu and then
select [Edit Report]. Note that the source table of a report cannot be changed.

110

PHP Report Maker 9 Help

Important Notes

1. After a report is created, a report works independently from the source table it
based on. Changing the structure of the source table does not change the report. If
you delete a field in the source table that is used by a report, the report will fail.
Similarly, if the report is based on a Custom View and you change the SELECT
statement of the Custom View, the report may fail if a field in the report is missing.
However, in the latter case, when a Custom View is edited, PHP Report Maker will
check the validity of the SQL. If the SQL fails, both the Custom View and reports
that based on the Custom View will be displayed with a cross in the icon, like

and

. Also, a Report has its own field settings, changing field settings in the source
table does not change the field settings in related Reports.
2. Report supports User ID and User Level. (See Security(See 1.11.4))

Also See:
Security Setup
(See 1.11.4)Tutorial - Crosstab Report (See 1.17.7)

1.11.13 Dashboard Setup


A Dashboard report allows you select any charts you have created in your project and show
them in one single Dashboard report page, with links back to the original reports. Using this
feature, you can enable users of your system to quickly understand the key indicators of
your system with the visually rich charts.
After loading the database, the database objects (tables, views, Custom Views and reports)
will be shown in the left pane (the database pane). To create a report, right click the
database pane and select [Add Report (Dashboard)]. Alternatively, you can click [Edit]
in the main menu and then select [Add Report (Dashboard)].
The Dashboard Report Setup window will show up:

111

PHP Report Maker 9 Help


General
Name

Name of the report

Type

Type of the report. Possible values are:

Vertical - Charts are displayed vertically


Horizontal - Charts are displayed horizontally
Custom - Charts are displayed with your own Custom Template (see
below)

Charts
Chart <n> Charts (from other reports) to be included in the Dashboard report
Width (px) Width of the chart (pixels) in the Dashboard report
Height
(px)

Height of the chart (pixels) in the Dashboard report

Press [OK] to finish setup. The Dashboard will appear under [Reports] in the Database
pane on the left.
To edit a Report, right click the Report in the database pane and select [Edit Report].
Alternatively, you can select the Report first, then click [Edit] in the main menu and then
select [Edit Report].
If you have selected Custom as the report type, you must provide a Custom Template.
Select the dashboard report in the Database pane, you'll see the Code (Server Events,
Client Scripts and Templates) tab on the right.
Select Custom Template > Table-Specific > Dashboard -> CustomTemplate and enter
your HTML as the template of the Dashboard report page.

112

PHP Report Maker 9 Help

Custom Template is HTML, if you want to embed PHP code, you need to use <?php and ?>
to enclose your code, if you want to use JavaScript, you need to use <script

type="text/javascript"> and </script>.


Use {{{chart<n>}}} to denote a selected chart in your dashboard report. Note that <n> is
an integer, e.g. chart1, chart2, chart3, etc. and there is no spaces between "chart" and
"<n>". For example,

<table>
<tr><td>{{{chart1}}}</td><td>{{{chart2}}}</td></tr>
<tr><td colspan="2">{{{chart3}}}</td></tr>
</table>
During script generation, {{{chart<n>}}} will be replaced by the actual chart content you
specify in the Charts setting.

Important Notes

1. The dashboard report requires the source reports' *info.php and *chart.php scripts,
when you generate or re-generate dashboard reports, make sure you have selected
those scripts.
2. After a report is created, if you rename or delete a source chart, the report will fail.
Make sure you updated the report settings after renaming or deleting a source chart.
3. Report supports User ID and User Level. (See Security(See 1.11.4))

113

PHP Report Maker 9 Help

Also See:
Tutorial - Dashboard Report (See 1.17.9)

1.11.14 Compatibility Properties Setup


Compatibility Properties are used to make the generated scripts work with an existing PHP
application.
If your PHP application generated by PHP Report Maker is standalone, that is, resides in a
separate folder from other PHP application, there is no need to set these properties.
However, if you mix the generated scripts with other PHP application in the same folder, the
generated header, footer, login, logout and default pages may overwrite the same pages for
the existing PHP application because these file names are typical and both applications
possibly have the same file names. For example, if you generated the output scripts to the
same destination folder of an PHPMaker project, those files will be overwritten.
If the Compatibility Properties are enabled, during script generation, the header, footer,
login, logout and default pages can be skipped so they won't overwrite existing files.
Instead, the generated scripts will use the paths of header, footer, login, logout and default
pages specified by the Compatibility Properties so both PHP application shares the existing
files. Therefore, once you have customized the header and footer for use with both PHP
applications, they will not be overwritten the next time you re-generate scripts using PHP
Report Maker.
The header and footer files are included in the script using, e.g. <?php include_once
"phprptinc/header.php" ?>. If you generate the output scripts to a folder at a level
Note

different from the existing PHP application, do NOT use Compatibility Properties unless you
are sure that your header and footer work fine at different level. For example, if relative
paths are used in the header and footer, the paths will be translated to different paths when
the header or footer is included by scripts at different levels.

Set up the Compatibility Properties Automatically (Requires PHPMaker 12 or Later)


If the existing PHP application is generated by PHPMaker 12 (or later), the compatibiltiy can
be set up easily in the PHPMaker project. PHPMaker can load the PHP Report Maker project,
set up the compatibility properties automatically and load the menu items from the PHP
Report Maker project to the PHPMaker project. Since PHPMaker will update your PHP Report
Maker project, to avoid overwriting each other, you should save your PHP Report Maker
project and close PHP Report Maker first. Then in PHPMaker, open the Menu Editor, click
the [Import] button in the toolbar,

Note: This is menu editor in PHPMaker.

114

PHP Report Maker 9 Help


Select your PHP Report Maker 9 project, click [OK]. The imported menu items will be
represented by orange icons, you can then re-arrange the display order of the menu items if
necessary.

If you re-open the PHP Report Maker project in PHP Report Maker, click [Tools] ->
[Compatibility Properties] and you'll see that the compatibility properties has been setup.
If you change User Level settings in your PHP Report Maker project later, the imported
menu items in the PHPMaker project will NOT be updated automatically, you'll need to
repeat above again.
Note

Set up the Compatibility Properties Manually


If the existing PHP application is not generated by PHPMaker, you can also set up the
Compatibility Properties manually. In PHP Report Maker, click [Tools] -> [Compatibility
Properties], the following form will show up:

115

PHP Report Maker 9 Help

Properties:
Project Name

Specifies the project name of the project.


In our products, project name is generally used in session
variable names to distinguish projects. To make your PHP
Report Maker project works with our other products, for
example, PHPMaker, you must use the same project
name.
Normally, the project name is the same as the project file
name, but there are cases that the project name is
different, it is therefore recommended that you check the
project name of the PHPMaker project first (see Project
File(See 1.13)), then you enter the same project name to
PHPMaker. Since project name is used in session variable
names, it is case-sensitive.
Notes

1. If you don't use security, there is no need to


change the project name.
2. If you save the project as the another file name
using [Save As...], the project name will still be
changed accordingly. If you want to keep the
project name unchanged, use [Save a Copy...].
(See Project File(See 1.13))
Enable compatibility propertiesCheck this to enable compatibility properties.

116

PHP Report Maker 9 Help


Header (include file)

Specifies the path of the header include file.


Default value is "(Template)", which means the path is
determined by the template.
When enabled, the path you enter will be used in the
generated script as follows:

<?php include_once "your header path"; ?>

Footer (include file)

Specifies the path of the footer include file.


Default value is "(Template)", which means the path is
determined by the template.
When enabled, the path you enter will be used in the
generated script as follows:

<?php include_once "your footer path"; ?>


Login page

Specifies the path of the login page.


Default value is "(Template)", which means the path is
determined by the template.
When enabled, the path you enter will be used in the
generated script as follows:

header("Location: your login page"); or <a


href="your login page">...</a>

Logout page

Specifies the path of the logout page.


Default value is "(Template)", which means the path is
determined by the template.
When enabled, the path you enter will be used in the
generated script as follows:

<a href="your logout page">...</a>


(Also see note below.)
Specifies the path of the default page.
Default page

Default value is "(Template)", which means the path is


determined by the template.
When enabled, the path you enter will be used in the
generated script as follows:

header("Location: your default page");

If compatibility properties is enabled but the path is empty, the file in the template will
still be generated by PHP Report Maker and used by other generated scripts as normal.
Note

117

PHP Report Maker 9 Help

Also See:
Tutorial - Compatibility Properties - Integrating with existing PHPMaker project(See 1.17.13)

1.11.15 Server Events and Client Scripts


PHP Report Maker now supports server events and client scripts. You can create your own
functionality by writing your own customized server and client side codes. The customized
codes are stored in your projects so you can migrate your project to other templates or
future versions easily. This feature reduces the need of template customization and create
maximum possibilities for you to customize and create more advanced features for your
projects.
The steps to create the server events and client scripts are as follows:
After loading the database, the database objects (tables, views, custom views and reports)
will be shown in the left pane (the database pane). Click on any table to go to the Field
Setup Page and the Server Events and Client Scripts page at any time.
For simplicity, we use "table" in the following description to refer to any of database
object in the project. A database object can be either a table, a view, a custom view or a
report.
Note

118

PHP Report Maker 9 Help

The treeview shows the available server events and client scripts that you can add to your
project:
Server Events Server-side PHP procedures
Global

The events are applicable to all PHP pages

Table-SpecificThe set of events are table-specific, the events are applicable to the selected
table only
Other

The events are applicable to some common pages in the project only

Client Scripts Client-side JavaScript


Global

The JavaScript are included in all pages with header and footer

Table-SpecificThe JavaScript are table-specific, they are included to pages for the selected
table only
Other

The JavaScript are included in some common pages in the project only

To add your custom scripts to the server events or client scripts, select an item in the
treeview, then enter your code in the editor.
The editor supports Find and Replace. Press Ctrl-F to open the Find dialog and press Ctrl-H
to open the Replace dialog.
You can click the [Reset] button to discard the existing code and reload template code for
the server event or client script.

Code Repository
PHP Report Maker now provides a Code Repository for easy reuse of your code across
projects and sharing with other users. Click the [Code Repository] button to open it,
categorized reusable code will be displayed:

119

PHP Report Maker 9 Help

You can add the code to the editor by clicking the [Add to Editor] button, or by doubleclicking the item, or simply drag the item to the editor. The reusable code is stored in XML
files which reside in s subfolder name "code" under the installation folder. The format of the
XML files is simple, there are 3 parts:
1. description - description of the reusable code
2. code - code to be inserted to editor
3. globalcode - common code to be inserted to Global Code (see below), this code will
only be inserted once into the project. For example , if your code is used several
times in your project and your code calls a helper function, it is unnecessary to
include the helper function several times. In this case you put your helper function in
the globalcode section, then the function will only be included one time.
There are a few example files in the "code" folder, you can copy and modify for your own
code and then save them under the "code" folder for reuse.

Server Events
In general, server events are fired in the following order:

Page_Loading (Global function)


Page_Load (Page/Table class method)
Page_Rendering (Global function)
Page_Render
Page_DataRendering
Page_* / Cell_* / Row_* / Chart_* (Page/Table class method)
Page_DataRendered
Page_Unload (Page/Table class method)
Page_Unloaded (Global function)

Notes

120

PHP Report Maker 9 Help


1. From v6, the page class inherit from the table class, so you can use $this in the
page class methods to access table class members. For backward compatibility, the
table object is kept and it is an alias of the page object, so you can also use $this
in the table class methods to access page class members.
2. The Page_Unload and Page_Unloaded are server side events to be fired every
time the page is accessed and before the HTML is outputted to the browser on the
client side. They are NOT events to be fired before you leave the page and reload
the page or go to another page. For example, if you submit a form in the page,
usually it submits to the page itself, you are actually reloading the page, all server
events will be fired again. For another example, if you click a hyperlink which links to
another page, the page on the server side is not even accessed again and no server
events for the page will be fired.
3. If a server event is a global function, there is NO $this in the function context. If
you want to refer to the current page object, you can use the global function
CurrentPage().
4. In the following table, the <fieldname> in code, e.g. in $this-><fieldname>><property> or x_<fieldname>, represents the field variable name. In general,
the field name is alphanumeric, field variable name is same as the field name.
Otherwise, spaces are replaced by underscores, and other non alphanumeric
characters are replaced by their hexadecimal string representation of their unicode
value. If the variable is a reserved word or starts with a digit, it will be prepended
with an underscore. If you are not sure, drag a field from the database pane to the
editor instead of typing the field variable name. However, note that if the field name
is quoted, e.g. rs['<fieldname>'], <fieldname> is the actual field name as in
the database, not the field variable name.
5. Server events are functions or class methods, if you need to use global variables in
the events, note the PHP variable scope, you must use the global keyword or
$GLOBALS.
Available server events are:
Global -> All Pages
Page_Head

The code you entered in this event will be placed in the header.php
before closing the <head> section. You can use this event to can
add your code in head section. Note: This is a global function.
Example
Include custom JavaScript and CSS stylesheet.

ewr_AddClientScript("xxx.js"); // Add JavaScript


ewr_AddStylesheet("xxx.css"); // Add CSS stylesheet
Database_Connecting This event will be fired by all PHP pages before connecting to the
database. Note: This is a global function.
If MySQL/PostgreSQL, the argument is an array with the following
keys: host, port, user, pass, db. If Access/MSSQL, the argument
is the connection string for ADO. You can use this event to
change the connection string (e.g. changing connection info with
server, or even connect to other databases).
Example 1

// MySQL/PostgreSQL
function Database_Connecting(&$info) {
//var_dump($info);
// assume the scripts are generated with

121

PHP Report Maker 9 Help


connection info for local PC
if (ewr_CurrentUserIP() <> "127.0.0.1") { //
not connecting to local PC
// connect to the production database
$info["host"] = "localhost";
$info["user"] = "xxx";
$info["pass"] = "yyy";
$info["db"] = "production_db";
}
}
Example 2
It is possible to use single login and common Dynamic User Levels
for multiple projects provided that ALL projects use the same
project name and same Advanced Security tables (i.e. User Table,
User Level Table and User Level Permission Table). If all projects
uses the same database and same Advanced Security tables, then
the latter condition is auto fulfilled. However, if the projects use
different databases, you can use this event to change the
connection info so the user can get the Dynamic User Levels from
the common Advanced Security tables correctly during login, e.g.

// MySQL/PostgreSQL
function Database_Connecting(&$info) {
//var_dump($info);
if (CurrentPageID() == "login") { // login page
// connect to the common database with the
common Advanced Security tables
$info["host"] = "localhost";
$info["user"] = "xxx";
$info["pass"] = "yyy";
$info["db"] = "common_db";
}
}
Database_Connected This event will be fired by all PHP pages after connecting to the
database. Note: This is a global function.
The argument is the connection object, you can use it to execute
your own statements.
Example
Call a stored procedure after connection.

function Database_Connected(&$conn) {
$conn->Execute("CALL MyStoredProcedure");
}
Language_Load

This event will be fired when the language file is loaded. You can
use it to change the language phrases if necessary. Note: This
event is a language class member.
Example

122

PHP Report Maker 9 Help


function Language_Load() {
$this->setPhrase("MyID", "MyValue"); // Refer
to language file for the actual phrase id
$this->setPhraseClass("MyID", "glyphicon
glyphicon-xxx ewIcon"); // Refer to
http://getbootstrap.com/components/#glyphicons for
icon name
}
Page_Loading

This event will be called by all PHP pages at the beginning of the
page. If the pages involves database connection, it will be called
after connecting to the database and before the Page_Load event.
Note: This is a global function, NOT page class member.

Page_Rendering

This event will be called by all PHP pages before outputting HTML
for the page. Note: This is a global function, NOT page class
member.

Page_Unloaded

This event will be called by all PHP pages at the end of the page. If
the pages involves database connection, it will be called before
closing database connection and after the Page_UnLoad event.
Note: This is a global function, NOT page class member.

Global Code

Code to be included in all PHP pages. This may contain your


constants, variables and functions.

User_CustomValidate For use with security. (See Security Settings(See 1.11.4)) This
event is fired before default user validation. You can use this event
to validate the user yourself. The arguments are the user name and
password the user entered. Return TRUE if the username and
password pass your custom validation. Note: This event is a
security class member.
From v6, default validation will continue after this event is
fired. If you return TRUE, the user will always pass the default
validation and get the User ID and User Level, if any. If you return
FALSE, the default validation proceeds as normal. If you use
Advanced Security, you still need the user table to store user
information such as User ID and User Level, although the password
field value can be empty or any value if you return TRUE.
Note

Example 1
Login user by Windows user name.

// Note: This event is a Security class member, so


you can refer to other members of the Security
class directly
function User_CustomValidate(&$usr, &$pwd) {
// e.g. Simple Windows authentication
if (ewr_ServerVar("LOGON_USER") <> "") {
$usr = ewr_ServerVar("LOGON_USER");
return TRUE;
}
return FALSE;
}

123

PHP Report Maker 9 Help


Example 2
Login user by LDAP. (The following example code can be found in
Code Repository.)

// Note: This event is a Security class member, so


you can refer to other members of the Security
class directly
function User_CustomValidate(&$usr, &$pwd) {
// e.g. LDAP authentication example for
User_CustomValidate server event
if (!function_exists("ldap_connect"))
die("LDAP extension not installed.");
$ldapconn = ldap_connect("ldap.example.com",
389) or die("Could not connect to LDAP server.");
// Note: Replace the host name and port
if ($ldapconn && ldap_bind($ldapconn, $usr,
$pwd)) {
$this->setCurrentUserName($usr); // Set the
current user name
return TRUE;
}
return FALSE;
}
User_Validated

For use with security. (See Security Settings(See 1.11.4)) This


event is fired after successful user login. The user info is passed to
the event as an array (see note), you can get more info of the user
and use it as you need. Note: This event is a security class
member.
Notes

1. This event is not fired for the hard-coded administrator.


2. In previous version, the argument $rs was an object, so you
needed to get a field value by $rs->fields('<fieldname>').
For consistency with other events, the argument has been
changed to array so you can get a field value by
$rs['<fieldname>'].
Example
Add current user's country to session variable

// Note: This event is a Security class member, so


you can refer to other members of the Security
class directly
function User_Validated(&$rs) {
$_SESSION["UserCountry"] = $rs['Country'];
}
UserLevel_Loaded

For use with User Level security. (See Security Settings(See


1.11.4)) This event is fired after successful user login and after the
User Level settings are loaded. It is possible to do actions such as
changing or adding User Level permissions. Note: This event is a
security class member.
Example
Change the permissions of an User Level for a table

124

PHP Report Maker 9 Help


// Note: This event is a Security class member, so
you can refer to other members of the Security
class directly
function UserLevel_Loaded() {
$this->DeleteUserPermission("Sales", "orders",
EWR_ALLOW_LIST);
$this->AddUserPermission("Managers", "orders",
EWR_ALLOW_LIST);
}
MenuItem_Adding

This event is fired for custom menu items before it is added to the
menu. The menu item info is passed to the event as an instance of
the cMenuItem object (see below). Return FALSE if you don't want
to show the menu item. If you return TRUE, the menu item will be
added to the menu, but it does not mean that it will be always
displayed. A menu item will be displayed only if its Allowed
property is TRUE. When the menu item is passed to this event, the
Allowed property is set based on the User Level Security of the
project, you can however change it by setting $Item->Allowed as
TRUE or FALSE as needed. Note: This is a global function.
Example
Only show a menu item after the user has logged in

function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return False if menu item not allowed
if ($Item->Text == "Download") {
return IsLoggedIn();
} else {
return TRUE;
}
}
Menu_Rendering

This event is fired before the menu is rendered. You can manipulate
the menu items in this event. The argument is the menu object.
(See Menu Object below.) Note: This is a global function.
Example 1
Add an additional menu item to the menu for logged in users only.

function Menu_Rendering(&$Menu) {
if ($Menu->IsRoot) { // Root menu
$Menu->AddMenuItem(10000, "MyMenuName",
"MyMenuText", "MyPage.php", -1, "", IsLoggedIn());
$Menu->MoveItem("Logout", $Menu->Count() 1); // Move to last
}
}
Example 2
Remove all the default menu items and use your own menu items.

function Menu_Rendering(&$Menu) {
if ($Menu->IsRoot) { // Root menu

125

PHP Report Maker 9 Help


$Menu->Clear();
$Menu->AddMenuItem(1, "MyMenuName1",
"MyMenuText1", "MyPage1.php");
$Menu->AddMenuItem(2, "MyMenuName2",
"MyMenuText2", "MyPage2.php");
}
}
UserID_Loading

For use with User ID security. (See Security Settings(See 1.11.4))


This event is fired after successful user login and before loading the
User ID and its child User IDs of the current user. These User IDs
determine which records the current user can access. It is possible
to do actions such as changing the User ID of the current user so
the user can access records that he/she can access by its original
User ID. Note: This event is a security class member.
Example
Change the user's User ID to his parent user's user ID and let the
user access more records (accessible by the parent user).

// Note: This event is a Security class member, so


you can refer to other members of the Security
class directly
function UserID_Loading() {
if (CurrentParentUserID() <> "")
$this->CurrentUserID =
CurrentParentUserID();
}
UserID_Loaded

For use with User ID security. (See Security Settings(See 1.11.4))


This event is fired after loading the User ID and its child User IDs of
the current user. These User IDs determine which records the
current user can access. It is possible to do actions such as adding
or deleting the loaded User IDs for the current user so the user can
access more or less records that he/she can access by its originally
loaded User IDs. Note: This event is a security class member.
Example
Add more User IDs to the user and let the user access more records

// Note: This event is a Security class member, so


you can refer to other members of the Security
class directly
function UserID_Loaded() {
if (CurrentUserName() == "nancy")
$this->AddUserID($this>GetUserIDByUserName("janet"));
}
Chart_Rendering

This event is fired before the chart XML is built. You can still change
the chart properties using this event. Note: This event is a chart
class member.
The chart object instance contains all the information about the
chart to be rendered. It is an instance of the crChart class, refer to
ewrfn*.php for members of the object.

126

PHP Report Maker 9 Help


Chart_DataRendered This event is fired after the each value is set for the chart. You can
modify label, value, and attributes by this event. Note: This event
is a chart class member.
The parameter is:
node - The XML DOMElement of the <set> element in chart XML. If
FusionCharts Free, the attributes includes name and value
attributes. If FusionCharts, the attributes includes label and
value attributes. There are various other attributes. Refer to
FusionCharts(See 1.15) documentation for the attributes supported
by each chart. Refer to PHP 5 DOMElement on how to work with an
XML DOMElement, usually you use the getAttribute and setAttribute
method to get/set the attribute values.
Example
Specify a color according to value.

function Chart_DataRendered($node) {
if ($node->getAttribute("value") == "xxx") //
Note that getAttribute() returns string
$node->setAttribute("color", "FF0000"); //
Note: Use hex color codes without "#"
}
Chart_Rendered

This event is fired after the chart XML is built and before the XML is
outputted. You can still modify the XML using this event. Note:
This event is a chart class member.
The chart object instance contains all the information about the
chart to be rendered. It is an instance of the crChart class, refer to
ewrfn*.php for members of the object. You can get the XML
document by $this->XmlDoc and manipulate it by by PHP 5
DOMDocument, then save it back to the chartxml argument for
output. Refer to FusionCharts(See 1.15) documentation for chart
attributes.
The parameters is:
chartxml - the XML (string) to be outputted. You can also directly
manipulate it as string by string functions.
Example
Set chart subcaption by code

function Chart_Rendered(&$chartxml) {
$doc = $this->XmlDoc; // Get the DOMDocument
object
$doc->documentElement>setAttribute('subCaption', 'My SubCaption'); //
Modify the XML
$chartxml = $doc->saveXML(); // Output the XML
to $chartxml
}
Table-Specific -> Report Page (Note: These events are members of the page class)

127

PHP Report Maker 9 Help


Page_Load

This event will be called after connecting to the database.


The export links are stored as a crListOptions object, you can
manipulate the links in the same way. You can get a link by name
using $this->ExportOptions->Item["name"]. The default names of
the options are:

html
excel
word
pdf
email

Note that the names are case-sensitive. They are in lowercase.


Example
This example hides the export to PDF link in List page:

function Page_Load() {
$item = @$this->ExportOptions->Items["pdf"];
if ($item)
$item->Visible = FALSE;
}
Page_Render

This event will be called before outputting HTML for the page. You
can use this event to make some last minute changes to the page
before it is outputted.

Page_Unload

This event will be called before closing database connection.

Page_Selecting

This event will be called before selecting records. The argument of


the event is the filter (part of the WHERE clause of the SQL) for
selecting records, you can customize the filter to change the records
to be selected.
Example
Add your own filter. Note that the $filter may have value, append
your filter to it, not replace it.

function Page_Selecting(&$filter) {
ewr_AddFilter($filter, "Field1 = 1234"); // Add
your own filter expression
}
Page_FilterLoad

This event allows you to add custom filter to the popup and
extended filter of the fields. (Previously named as Filters_Load or
CustomFilter_Load.)
Example 1
Add 'StartsWithA' filter to a string field.
You can use the ewr_RegisterFilter() function to add your custom
filter, the parameters of the event are:

fld - the field object


FilterName - the filter name
DisplayName - the display name of the filter to be

128

PHP Report Maker 9 Help

displayed in the popup filter


FunctionName - the PHP function to be called for building
the WHERE clause. The function must have one and only
one parameter which is the field expression to be used in
the WHERE clause. You can put the function in Global
Code. (Note: The following example function is already in
the template, do not put it in the Global Code again.) This
argument is optional, if you use function, you can add your
code in Page_Filtering event

function GetStartsWithAFilter($FldExpression) {
return $FldExpression . " LIKE 'A%'";
}
Then you can enter event code as below:

function Filters_Load() {
ewr_RegisterFilter($this->MyStringField,
'StartsWithA', 'Starts With A',
'GetStartsWithAFilter'); // Register your custom
filter with your function
ewr_UnregisterFilter($this->MyDateField,
'LastTwoWeeks'); // Unregister the built-in filter
"Last two weeks"
}
Example 2
Alternatively, If you don't write a function in Global Code, you can
use Page_Filtering server event, e.g.

function Filters_Load() {
ewr_RegisterFilter($this->MyStringField,
'StartsWithA', 'Starts With A'); // Register your
custom filter without function, leave the
implementation in Page_Filtering event
}
Also see the example for Page_Filtering event below.
Page_FilterValidated This event will be called after the search criteria is assigned to the
field objects. You can modify the search criteria in this event.
This event is a member of the table class. There is no arguments for
this event. To change the search criteria, change the SearchValue,
SearchOperator, SearchCondition, SearchValue2, SearchOperator2
property of the field object.
Example

function Page_FilterValidated() {
$this->MyField1->SearchValue = "your search
criteria"; // Filter value
}
Page_Filtering

This event will be called before the search criteria is saved for the
session. The argument of the event is the part of WHERE clause
built from the filter and/or Extended Filters. You can modify the
WHERE clause in this event.

129

PHP Report Maker 9 Help


The arguments are:

fld - the field object


filter - the partial WHERE clause built from the selected
filter
typ - the type of the filter, possible values are: dropdown
(Extended Filter as selection list), extended (Extended
Filter as textbox), popup (Popup Filter), or custom
(Custom Filter)
opr - the current filter operator (for dropdown type or
extended type only) or current custom filter ID (for
custom type only)
val - the filter value (for dropdown type or extended type
only)
cond - the condition to join the second filter operator and
value, either AND or OR (optional, for extended type only)
opr2 - the second filter operator (optional, for extended
type only)
val2 - the second filter value (optional, for extended type
only)

Example
If you have registered a custom filter using Filters_Load event
(see above), you can implement your filter here, e.g. referring to
example 2 for Filters_Load above,

// Page Filtering event


function Page_Filtering(&$fld, &$filter, $typ, $opr
= "", $val = "", $cond = "", $opr2 = "", $val2 =
"") {
// var_dump($fld); // View the properties of the
field
// Note: ALWAYS CHECK THE FILTER TYPE ($typ)!
// if ($typ == "dropdown" && $fld->FldName ==
"MyField") // Dropdown filter
// $filter = "..."; // Modify the filter
// if ($typ == "extended" && $fld->FldName ==
"MyField") // Extended filter
// $filter = "..."; // Modify the filter
// if ($typ == "popup" && $fld->FldName ==
"MyField") // Popup filter
// $filter = "..."; // Modify the filter
if ($typ == "custom" && $opr == "StartsWithA" &&
$fld->FldName == "MyStringField") // Custom filter,
$opr is the custom filter ID
ewr_AddFilter($filter, $fld->FldExpression .
" LIKE 'A%'"); // Modify the filter
}
Also see the example for Page_Filtering server event below.
Page_DataRendering This event will be called before report rendering. You can use this
event to add HTML above the report. The parameter is:
header - set your HTML to this parameter.

130

PHP Report Maker 9 Help


Page_DataRendered This event will be called after report rendering. You can use this
event to add HTML below the report. The parameter is:
footer - set your HTML to this parameter.
Page_Breaking

This event will be called before inserting HTML page breaks (DIV tag
by default) for print/export. You can use this event to change the
HTML code. The parameters are:
break - Boolean. Specify to insert code or not
content - HTML code as page break

Row_Rendering

This event will be called before rendering (e.g. applying the View
Tag settings) a record.

Row_Rendered

This event will be called after rendering a record.


This is an extremely useful event for conditional formatting, you can
do a lot of things with this event, such as changing font color, font
styles, row background color, cell background color, etc. by
changing the table or field class properties in the event according to
field values.
The table class has a RowAttrs property which is an associative
array of HTML attributes for the table row. The field class has
CellAttrs, ViewAttrs for the table cell and View Tag of the field
respectively. The keys of these arrays must be valid HTML
attributes for the HTML tag, always use lowercase for the keys. The
attribute values will be outputted as double quoted attributes, so if
you have double quotes in your values, try to use single quotes if
possible, or use "&quot;".
Example
Click "Cars" node on the database panel, select [Server
Events/Client Scripts], and click [Table Specific] - >
[Common] - > [Row_Rendered] server event. The default
Row_Rendered event code is shown. Change as follow:

function Row_Rendered() {
// Use var_dump to view the arguments for
development or debugging, e.g.
//var_dump($this->RowAttrs, $this->Trademark,
$this->Trademark->CellAttrs, this->Trademark>ViewAttrs);
// Change the row color
if ($this->Trademark->ViewValue == "BMW") {
$this->RowAttrs["style"] = "color: red;
background-color: #ccffcc";
}
// Change the cell color
if ($this->Cyl->CurrentValue == 4) {
$this->Cyl->CellAttrs["style"] =
"background-color: #ffcccc";

131

PHP Report Maker 9 Help


} elseif ($this->Cyl->CurrentValue
$this->Cyl->CellAttrs["style"]
"background-color: #ffcc99";
} elseif ($this->Cyl->CurrentValue
$this->Cyl->CellAttrs["style"]
"background-color: #ffccff";
}

== 6) {
=
== 8) {
=

// Change text style


if ($this->Category->CurrentValue == "SPORTS")
{
$this->Category->ViewAttrs["style"] =
"color: #00cc00; font-weight: bold; backgroundcolor: #ffff99";
}
}
Cell_Rendered

This event will be called after rendering a cell.


This event is fired before Row_Rendered event, if you set the
same setting in the Row_Rendered event, it will be overwritten by
the Row_Rendered event.
Note

This is another extremely useful event for conditional formatting. It


is especially useful for the dynamic columns for Crosstab reports as
there are many dynamic columns for the same Column Field in the
report. This event saves you from accessing the arrays for the
columns, you can get/set the values passed to the event as
arguments directly.
The arguments are:
Field - the field object
CurrentValue - current value of the cell (unformatted)
ViewValue - view value of the cell (formatted)
ViewAttrs - associative array of the View Tag attributes
CellAttrs - associative array of the table cell attributes
HrefValue - href attribute of the hyperlink for the ViewValue
LinkAttrs - associative array of attributes of the hyperlink for the
ViewValue
The keys of the CellAttrs, ViewAttrs and LinkAttrs arrays must
be valid HTML attributes for the HTML tag, always use lowercase for
the keys. The attribute values will be outputted as double quoted
attributes, so if you have double quotes in your values, try to use
single quotes if possible, or use "&quot;".
Example
Click "Cars" node on the database panel, select [Server
Events/Client Scripts], and click [Table Specific] - >
[Common] - > [Row_Rendered] server event. The default
Row_Rendered event code is shown. Change as follow:

function Cell_Rendered(&$Field, $CurrentValue,


&$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue,
&$LinkAttrs) {
// Use var_dump to view the arguments for

132

PHP Report Maker 9 Help


development or debugging, e.g.
//var_dump($Field, $CurrentValue, $ViewValue,
$ViewAttrs, $CellAttrs, $HrefValue, $LinkAttrs);
// Change the cell color for the Cyl field
if ($Field->FldName == "Cyl") {
if ($CurrentValue == 4) {
$CellAttrs["style"] = "backgroundcolor: #ffcccc";
} elseif ($CurrentValue == 6) {
$CellAttrs["style"] = "backgroundcolor: #ffcc99";
} elseif ($CurrentValue == 8) {
$CellAttrs["style"] = "backgroundcolor: #ffccff";
}
}
}
Email_Sending

This event is fired before the email is sent. You can customize the
email content using this event. Email_Sending event has the
following parameters:
Email - the email object instance which contain all the information
about the email to be sent. It is an instance of the crEmail class,
refer to ewrfn*.php for members of the object.
Args - an array which contains additional information. By default it
is empty.
Return FALSE in the event if you want to cancel the email sending.
Example
Use a field value of the the new record in the email

function Email_Sending(&$Email, &$Args) {


//var_dump($Email); exit(); // Uncomment to
debug
$Email->Content .= "\nSent by " .
CurrentUserName();
return TRUE;
}
Message_Showing

This event is fired before the message stored in the session variable
is shown.
The first argument $msg is the message to be shown, the second
argument $type is the type of the message.
Example
Replace an error message by custom message

// Message Showing event


// $type = ''|'success'|'failure'|'warning'
function Message_Showing(&$msg, $type) {
//var_dump($msg, $type); // Uncomment to view
message and type
if ($type == 'success') {
//$msg = "your success message";

133

PHP Report Maker 9 Help


} elseif ($type == 'failure') {
if (strpos($msg, "Some standard failure
message") !== FALSE) // The original failure
message contains some keywords you want to replace
$msg = "My custom failure message";
} elseif ($type == 'warning') {
//$msg = "your warning message";
} else {
//$msg = "your message";
}
}
Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation. In general, the form data
can be accessed by $this-><Field>->SearchValue (e.g. $this->HP>SearchValue). Refer to the generated code for actual variable
names.
A parameter CustomError is passed to the event, add your error
message and return False if the form values do not pass your
validation.
Example
Make sure an integer field value meet a certain requirement

function Form_CustomValidate(&$CustomError) {
global $orders;
if (intval($this->Qty->SearchValue) <= 0) {
// Return error message in CustomError
$CustomError = "Quantity must be larger
than 0.";
return FALSE;
} else {
return TRUE;
}
}
Lookup_Selecting

For use with Extended Filter and Auto-Suggest (see Field


Setup(See 1.11.7)). This event is fired before selecting records from
table for Auto-Suggest. You can use this event to change the filter.
Example 1
Modify the lookup table filter when a selection list looks up display
values from the table.

function Lookup_Selecting($fld, &$filter) {


if ($fld->FldName == "MyExtendedFilterField")
$filter = str_replace("xxx", "yyy",
$filter);
}
Example 2
Add additional filter to the filter

function Lookup_Selecting($fld, &$filter) {


if ($fld->FldName == "MyExtendedFilterField")
ewr_AddFilter($filter, "MyField = 'xxx'");
// Assume the field is of string type

134

PHP Report Maker 9 Help


}
UserID_Filtering

For use with User ID security. (See Security Settings(See 1.11.4))


This event is fired before adding the User ID filter to the WHERE
clause of the table. It is possible to modify, replace or add filter so
the user can access more or less records that he/she can access by
its originally loaded User IDs.
Example
Assume you have 2 User ID fields in the current table and in the
user table, and you want to filter by both User ID fields.

function UserID_Filtering(&$filter) {
ewr_AddFilter($filter, "MyUserIDField2 = " .
CurrentUserInfo("MyUserIDField2InUserTable")); //
Assume the field is of integer type
}
Other -> Login Page
Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Message_Showing

Use this event to change the error message to be displayed in the


page.

Form_CustomValidateThis event is fired after the normal form validation. You can use this
event to do your own custom validation.
A parameter CustomError is passed to the event, add your error
message and return False if the form values do not pass your
validation.
Other -> Logout Page
Page_Load

This event will be called at the beginning of the page.

Page_Unload

This event will be called at the end of the page.

Client Scripts
In general, each page has two blocks of JavaScripts:
Client Script - the first block of JavaScript to be included at the beginning of the page, you
can put your JavaScript variables and functions there. The View Tag (for display) and Edit
Tag (for input) of the fields supports Custom Attributes (See Field Setup(See 1.11.7)) so you
can add your own attributes to work with your own JavaScript included here.
Startup Script - the second block of JavaScript to be included at the end of the page, you
can put code here to "start up" your JavaScript.
Note

In the following table, the <fieldname> in code represents the field variable name. In

general, if the field name is alphanumeric, field variable name is same as the field name.
Otherwise, spaces are replaced by underscores, and other non alphanumeric characters are
replaced by their hexadecimal string representation of their unicode value. If the variable is
a reserved word or starts with a digit, it will be prepended with an underscore. If in doubt,

135

PHP Report Maker 9 Help


always inspect HTML source in your browser to check the actual id, name, and
other attributes of the elements.
Global -> Pages with header/footer
Client Script

The script will be placed in the header and therefore included in all
pages with header.
This event is NOT related to the No header/footer setting in
the Generate form (see Generate Settings(See 1.11.5)). Even if No
header/footer is enabled, this event will also be fired.
Note

Startup Script

The script will be placed in the footer and therefore included in all
pages with footer.
This is a very useful event which is fired for all pages with footer,
you can almost do everything by changing the document DOM of
those pages.
This event is NOT related to the No header/footer setting in
the Generate form (see Generate Settings(See 1.11.5)). Even if No
header/footer is enabled, this event will also be fired.
Note

Use jQuery to replace the logo

$("#ewHeaderRow").html('<img src="path/mylogo.png"
alt="xxx">');
Global Code

JavaScript code to be included in all pages with header. This may


contain your global constants, variables and functions.

Table-Specific -> Report Page


Client Script

The script will be placed after the header. This may contain your
JavaScript variables and functions for the page. You can also use
this event to subscribe a custom event.
Example 1
Subscribe the "rendertemplate" event for Custom Template(See
1.11.16).

$(document).on("rendertemplate", function(e, args)


{
//alert(JSON.stringify(args)); // Uncomment to
view the arguments
args.data = [{key1: "value1", key2: "value2"}];
// Pass custom data to the template
});
Example 2
Subscribe the jQuery ajaxSend event before an Ajax request is sent
(e.g. "updateoption", "autosuggest")

$(document).ajaxSend(function(event, jqxhr,
settings) {
var data = settings.data;
//console.log(data); // Uncomment to view data
in browser console

136

PHP Report Maker 9 Help


if (ewr_Get("ajax", data) == "updateoption" &&
ewr_Get("name", data) == "sv_MyField") // Ajax
selection list
settings.data = data.replace("xxx", "yyy");
// Replace data with custom data
});
Example 3
Subscribe the "updatedone" event for Dynamic Selection Lists. The
event fires after options of a child field is updated.

$(document).on("updatedone", function(e, args) {


//console.log(args); // Uncomment to view the
arguments in browser console
alert($(args.target).data("field") + " has been
updated.");
});
Startup Script

The script will be placed before the footer. This is a very useful
event which you can almost do everything by changing the
document DOM.
PHPMaker provides a jQuery plugin .fields() for you to easily
get/set the form values in client side events such as Startup Script
and Form_CustomValidate (see below)

$row = $(this).fields(); // return an object of all


fields, each property is a jQuery object of the
input element(s) of a field
$field = $row["<fieldname>"]; // get jQuery object
of the input element(s) of a field
You can also get the jQuery object for a field directly,

$field = $(this).fields("<fieldname>"); // return


jQuery object of the input element(s) of a field
The jQuery object of the field is the jQuery object of the input
element of the field. (Note that if Edit Tag of the field is CHECKBOX
or RADIO, the jQuery object may contain more than one elements.)
For example, if the page is an Edit page and the field is named
"Field1" and it is a textbox, $(this).fields("Field1") is
equivalent to $("#x_Field1"). The advantages of using

.fields() plugin is that the returned jQuery object has the


following additional methods:
.value() get field value, .value(value) set the field
value.
.value([value])

This method is NOT the same as jQuery's


.val() method. This method takes other features
(e.g. AutoSuggest) into consideration.
Note

.visible() get the visibility of the field,


.visible(value) set the visibility of the field. The
.visible([value]) value should be a boolean value.
Note

137

PHP Report Maker 9 Help


1. This method shows/hides the DIV of the
field, NOT just the input element(s) of
the field itself in Extended Filter.
2. The setter is NOT the same as jQuery's
.toggle() method.
Get/Set the readonly attribute of the input
element. The value should be a Boolean value.
.readonly(value)
Note For <input type="text"> and <textarea>
only.
Get/Set the disabled attribute of the input
element. The value should be a Boolean value.
.disabled(value)

A disabled control's value is NOT submitted


with the form. Use this carefully in Extended
Filter or the field may be filtered.
Note

.row()

Get the jQuery object of the row (<div>) of the


field.

.toNumber()

Get the input value as a JavaScript Number (by


default the input value is string).

.toDate()

Get the input value as a moment object (by


default the input value is string).

.toJsDate()

Get the input value as a JavaScript Date object


(by default the input value is string).

Example 1
Add onchange event to the field named "Field1" in Add/Edit page
to change other fields by jQuery plugin .fields()

$("#sv_Field1").change(function() { // Assume
Field1 is a text input
if (this.value == "xxx") {
$(this).fields("FieldA").value("yyy"); //
Set value to FieldA
} else {
$(this).fields("FieldB").value("zzz"); //
Set value to FieldB
}
});
Example 2
Add onclick event to a field (checkbox) by jQuery

$("input[name='sv_MyField[]']").click(function() {
if (this.checked) { // Checkbox is checked
// Do something
} else { // Not checked
// Do something else
}
});

138

PHP Report Maker 9 Help


In general, the HTML form element for the field is named as
sv_FieldName, inspect the element in your browser to check the
actual name. In the event handler, "this" is the form element which
fired the event.
Example 3
Subscribe the "rendertemplate" event for Custom Template(See
1.11.16) and pass data from another table by PHP.

$(document).on("rendertemplate", function(e, args)


{
//alert(JSON.stringify(args)); // Uncomment to
view the arguments
args.data = <?php echo ewr_ExecuteJson("SELECT
Field1, Field2, ... FROM MyTable WHERE
MyPrimaryKeyField = " . $Page>FirstRowData["MyForeignKeyField"]); ?>; // Pass
additional data to the template and assume the
primary key field is number
});
The $Page->FirstRowData property contains the data of the first
row in the report (as an associative array), but note that report
data is not loaded yet when Client Script is fired, so you should
subscribe the event by Startup Script. The ewr_ExecuteJson()
function executes the SQL and return the first row by default, you
can then use the retrieved data in your Custom Template by
JsRender Tags (see Custom Template(See 1.11.16)).
Form_CustomValidateThis function is called after the normal form validation. You can use
this event to do your own custom validation. The form object can be
accessed by the parameter fobj. In general, the field can be
referred to as fobj.elements["sv_FieldName"]. (The element
names may have different names, always refer to the generated
code for the actual form element names.) Return false if the form
values do not pass your validation. Note: This function is a member
of the JavaScript page class.
You can also use the jQuery plugin .fields() in this event.
Example 1
Make sure an integer field value meet a certain requirement

function(fobj) { // DO NOT CHANGE THIS LINE!


var $qty = $(this).fields("Qty"); // Get a
field as jQuery object by field name
if ($qty.toNumber() % 10 != 0) // Assume Qty is
a textbox
return this.OnError($qty, "Order quantity
must be multiples of 10."); // Return false if
invalid
return true; // Return true if valid
}
Example 2
Compare 2 date fields

139

PHP Report Maker 9 Help


function(fobj) { // DO NOT CHANGE THIS LINE!
var $row = $(this).fields(); // Get all fields
if ($row["Start"].toJsDate() >
$row["End"].toJsDate()) // Assume Start and End are
textboxes
return this.OnError($row["End"], "The End
Date must be later than the Start Date."); //
Return false if invalid
return true; // Return true if valid
}
Example 3
Manipulation of date fields

function(fobj) { // DO NOT CHANGE THIS LINE!


var $start = $(this).fields("Start"), $end =
$(this).fields("End"); // Get fields as jQuery
objects by field names
if ($start.toDate().add(7,
"days").isAfter($end.toDate())) // Assume Start and
End are textboxes
return this.OnError($end, "The End Date
must be at least 7 days after the Start Date."); //
Return false if invalid
return true; // Return true if valid
}
Chart_Rendering

This event is fired when the JavaScript chart object has finished
loading the XML data and before rendering.
The event arguments are :
chart - This JavaScript chart object
chartid - This ID of the chart

Chart_Rendered

This event is raised when the JavaScript chart object has finished
rendering. This call is made only once per loaded chart SWF (even if
new data is supplied to it). It can be used to invoke any further
JavaScript methods on chart.
The event arguments are :
chart - This JavaScript chart object
chartid - This ID of the chart

Other -> Login Page


Client Script

The script will be placed after the header.

Startup Script

The script will be placed before the footer.

Form_CustomValidateThis function is called after the normal form validation. You can use
this event to do your own custom validation. The form object can be
accessed by the parameter fobj. Return False if the form values do
not pass your validation.

It is recommended that you develop your server event and client scripts in the
generated script so you can edit and test it immediately. When you finish your custom
script, copy it to PHP Report Maker custom script editor and save it.
Note

140

PHP Report Maker 9 Help

Objects in PHP Report Maker Generated Code


The following objects are available in the generated code and you can use them in the
Server Events to add more power to the code. The most important objects are:
Page Object
The Page object is generated for most pages. You can access the object properties using the
-> notation (e.g. CurrentPage()->PageID). The page class inherits from the table class
generated for each table. The methods and properties of the page class varies with page, for
the complete list of methods and properties, please refer to the generated class
"cr<Table>_<PageID>" (e.g. crCars_rpt) and the table class "cr<Table>" in the generated
scripts.
Field Object
A <Field> object is generated for each field in a table. You can access the object properties
using the -> notation (e.g. CurrentPage()->Trademark->CurrentValue). For the
complete list of methods and properties, please refer to the class "crField" in the generated
file "ewrfn*.php".
Chart Object
A <Chart> object is generated for each chart in a table. For example, the "Chart1" object is
generated for the chart named "Chart1" for the table. You can access the object properties
using the -> notation (e.g. CurrentPage()->Chart1). For the complete list of methods
and properties, please refer to the class "crChart" in the generated file "ewrfn*.php".
Security Object
The Security object is used to store the current Advanced Security settings. Please refer to
the class "crAdvancedSecurity" in the generated file "ewrfn*.php" for the complete list of
methods and properties.
Email Object
The Email object contains the required information of the email to be sent, the instance of
the object will be passed to the Email_Sending events as argument and let you modify the
email. Please refer to the class "crEmail" in the generated file "ewrfn*.php" for the complete
list of methods and properties.
Menu Object
The Menu object contains all information of a menu, the instance of the menu will be passed
to the Menu_Rendering events as argument and let you work with the menu. Please refer
to the class "crMenu" in the generated file "ewrfn*.php" for the complete list of methods and
properties.
MenuItem Object
The MenuItem object contains all information of the menu item, the instance of the menu
item will be passed to the MenuItem_Adding events as argument and let you work with
the menu item. Please refer to the class "crMenuItem" in the generated file "ewrfn*.php" for
the complete list of methods and properties.
ExportOpions Object
The ExportOptions object contains all information of the export links in the report page, you
can access the object by CurrentPage()->ExportOptions. Please refer to the class
"crListOptions" in the generated file "ewrfn*.php" for the complete list of methods and
properties.

141

PHP Report Maker 9 Help


Language Object
The language Object lets you retrieve a phrase of the active language during runtime. The
phrase can be retrieved in the generated scripts using methods such as Phrase, TablePhrase
and FieldPhrase. Please refer to the class "crLanguage" in the generated file "ewrfn*.php" for
the complete list of methods and properties.
There are a few other objects in the generated code, please refer to the source code of the
file "ewrfn*.php" in the generated scripts.

Some Global Functions


The following are some useful global function available in the generated code for you to get
information easier in server events:
Notes

1. In the following table, the argument $dbname or $tablename or $fieldname is


the database/table/field variable name. It is case-sensitive. In general, if the name
is alphanumeric, the variable name is same as the name. Otherwise, spaces are
replaced by underscores, and other non alphanumeric characters are replaced by
their hexadecimal string representation of their unicode value. If the variable is a
reserved word, it will be prepended with an underscore. If you use databases with
the same name, check the database variable name in the Add Linked Table form,
see Linked Tables(See 1.11.15).
2. If MS Access, the $dbname is the file name of the database without the extension.
If Oracle, the $dbname is the schema name.
3. Argument in square brackets means that the argument is optional.
4. If $dbname is not specified, the database of the project is assumed. If $dbname is
specified, the specified database of Linked Tables is used.
Function name

Description

Example

Conn([$dbname])

Get the global $rs = Conn()connection


>Execute("SELECT ...");
object.
// execute a SELECT

statement and get

If $dbname is recordset object


not specified, it
returns the
$rs = Conn("MyDbName")connection
>Execute("SELECT ...");
object for the // execute a SELECT
database of the statement and get
project. If
recordset object
$dbname is
specified, it
returns the
connection
object for the
specified
database of a
Linked Table.

Security()

Get the global Security()security object >ShowUserLevelInfo(); //

Display all the User


Level settings (for debug

142

PHP Report Maker 9 Help


Function name

Description

Example

only)
Language()

Get the global Language()language


>setPhrase("AddLink",
object
"xxx"); // change the

wording for the "Add"


link
CurrentUserName()

Get current
user name.

$username =
CurrentUserName();

CurrentUserID()

For used with


User ID
Security (see
Security
Settings(See
1.11.4)). Get
current User
ID.

$userid =
CurrentUserID();

CurrentUserLevel()

For used with $levelid =


User Level
CurrentUserLevel();
Security (see
Security
Settings(See
1.11.4)). Get
current user's
User Level ID
(integer).

CurrentUserInfo($fieldname)

For used with $email =


CurrentUserInfo("email");
Advanced
Security (see
Security
Settings(See
1.11.4)). Get
current user's
info from the
user table. The
argument is
the field name
in the user
table.

CurrentPageID()

if (CurrentPageID() ==
Get current
"crosstab") {
page ID. A
...your code...
page ID
}
identifies the
page type, it
can be "rpt",
"summary",
"crosstab", etc.

143

PHP Report Maker 9 Help


Function name

Description

Example

CurrentPage()

Get current
page object.

$page = CurrentPage();

CurrentLanguageID()

Get current
language ID.

$langid =
CurrentLanguageID();

IsLoggedIn()

For used with if (IsLoggedIn()) {


...your code...
Advanced
Security (see }
Security
Settings(See
1.11.4)). Get
the login status
of the current
user.

IsAdmin()

For used with if (IsAdmin()) {


Advanced
...your code...
Security (see }
Security
Settings(See
1.11.4)).
Check if the
current user is
an
administrator.

ew_Execute($sql [,$dbname])

Execute
UPDATE,
INSERT, or
DELETE
statements.

ew_ExecuteRow($sql [,$dbname])

Executes the $row =


query, and
ewr_ExecuteRow("SELECT *
returns the
FROM MyTable WHERE...");
first row as an
array.

ew_ExecuteScalar($sql [,$dbname])Executes the

ewr_Execute("UPDATE
MyTable SET...
WHERE...");

$value =

ewr_ExecuteScalar("SELECT
query, and
returns the
MyField FROM MyTable
first column of WHERE...");
the first row.
ReportDbHelper([$dbname])

Get database $db = ReportDbHelper();


helper object of
a databse (also
see Custom
Files(See
1.11.17)).

144

PHP Report Maker 9 Help


There are many other functions in the generated code, please refer to the source code of the
file "ewrfn*.php" in generated scripts.

1.11.16 Custom Templates

Custom Templates
By default reports are exported in tabular format. Custom Template enables you to rearrange data in the report in your own way for better printing with browsers or exporting to
other format.
Notes

1. Custom Template currently supports Simple reports and Detail and Summary
reports only. (Crosstab reports are NOT supported.)
2. Do not confuse Custom Template (which is a table level setting within a project)
with customizing the whole template zip file. If you want to customize the general
layout of the generated site or customize something for all tables and all projects,
you should customize the template zip file, see Customizing Template.

How it Works
If a Custom Template is provided, PHP Report Maker splits the original code in many small
client side templates. A client side template is HTML code enclosed by <script
type="text/html"> and </script>. Since browsers do not know how to execute "text/html"
scripts, they simply ignore it. So it is possible to re-assemble HTML from the small client side
templates by JavaScript based on your provided Custom Template. In other words, it is
simply re-arrangement of existing HTML parts in browser.
During script generation, PHP Report Maker converts your Custom Template to a client side
template and outputs JavaScript to render the template. The client side template is rendered
by JsRender (see Third-Party Tools(See 1.7)) which is a third-party JavaScript template
engine optimized for high-performance pure string-based rendering. The generated scripts
only use its "template composition" feature to render HTML from other external templates,
your Custom Template can however make use of its JsRender API to do a lot of other things.
(Note that JsRender is still in beta, if you use its features directly, be aware that there may
be some breaking changes in the future.)

Custom Template Tags


To let you create your Custom Template easily, PHP Report Maker supports the following
Custom Template Tags. Since JsRender supports tags enclosed by {{ and }} (double curly
brackets, see below), in order to let you use them in your Custom Template, PHP Report
Maker Custom Template Tags uses {{{ and }}} (triple curly brackets) to differentiate. Note
that Custom Template Tags will be converted to JsRender tags during script generation, they
can only be used in PHP Report Maker user interface, they cannot be used elsewhere such as
template (zip file) or generated scripts.

145

PHP Report Maker 9 Help


In the following table, field represents the field variable name. In general, if the field
name is alphanumeric, field variable name is same as the field name. Otherwise, spaces are
replaced by underscores, and other non alphanumeric characters are replaced by their
hexadecimal string representation of their unicode value. If the variable is a reserved word
or starts with a digit, it will be prepended with an underscore. If you are not sure, drag a
field from the database pane to the editor instead of typing {{{field}}}.

{{{field}}}

Field value

{{{caption field}}}

Field caption

{{{value field}}}

Field value (same as


{{{field}}})

{{{sum|avg|min|max|cnt field}}}

Field group level summary value


(Sum/Average/Minimum/Maximu
m/Count)

{{{count}}}

Number of detail records in the


group

{{{row_cnt}}}

The row index (1-based) of the


detail record in the group

{{{pagesum|pageavg|pagemin|pagemax|pagecnt
field}}}

Field page summary value


(Sum/Average/Minimum/Maximu
m/Count)

{{{grandsum|grandavg|grandmin|grandmax|grand Field grand summary value


cnt field}}}
(Sum/Average/Minimum/Maximu
m/Count)
In simple report, there is no
grouping fields, use this tag
instead of above tags for
summary values.
Note

Current filters of the report

{{{current_filters}}}

The advanced setting "Show


current filters" or "Show drill
down filters" must be enabled for
this tag to work, see Advanced
Settings(See 1.14).
Note

JsRender Tags
The FIRST ROW of the data for the report will also be passed to the Custom Template, you
can use JsRender tags enclosed by {{ and }} (double curly brackets) to show them in your
Custom Template. Remember that PHP Report Maker Custom Template Tags uses {{{ and

}}} (triple curly brackets) while JsRender tags use double curly brackets. Custom Template
Tags will be converted to JsRender tags during script generation, while JsRender tags will be

146

PHP Report Maker 9 Help


kept intact. In the following table, field represents the field variable name similar to
Custom Template Tags.

{{:field}}

Field value

{{>field}}

HTML-encoded field value

Notes

1. The first row data is unformatted raw data from the database. If you want to format
the data, you can use Client Script of the page (see Server Events and Client
Scripts(See 1.11.15)) to subscribe the "rendertemplate" event and format the data.
2. See JsRender API for complete information of JsRender tags.

How to Use
To enter your Custom Template for a table, follow the following steps:
1. Select the table in the database pane,
2. Select the Code tab (which contains Server Events, Client Scripts and
Templates),
3. Scroll down the treeview or collapse the Server Events and Client Scripts node,
select a template node under Custom Templates,
Template Name

Description

CustomTemplateHeader

This is the custom template header. You can put


report header (such as company name and/or logo) in
this section of the custom template.

CustomTemplateGroupHeader<n>This is the group header for the nth group (where n =


1-6). You can put report group level information (such
as group caption and value) in this section of the
custom template. If you have two grouping fields in
your reports, enter the custom templates for the two
groups only. This section is not used in simple reports.
CustomTemplateBody

This is the custom template body. You can put report


details in this section of the custom template.

CustomTemplateGroupFooter<n> This is the group footer for the nth group (where n =
1-6). This section is not used in simple reports.
CustomTemplateFooter

4.

This is the custom template footer.

Custom Template let you customize the layout of the data originally placed in
the main HTML table of the page, it cannot customize other parts of the page.
Note

147

PHP Report Maker 9 Help


5. For example, if the report has 2 grouping levels, the custom templates are:

6. Enter your Custom Template in the editor.


You can enter the first character of a field name and then press Ctrl + Space to
open the completion list of the editor and select a {{{field}}} tag.
Note

148

PHP Report Maker 9 Help

Then just generate and run your scripts in your browser as usual.

Important Notes

1. Keep your Custom Template as simple as possible. For printer friendly version,
the outputted HTML is rendered by the browser itself, browser can understand
complex HTML. However, for other export format, the outputted HTML is to be
rendered by other applications such as Word, Excel, DOMPDF and email client, they
may not be able to render your complex HTML properly, so always keep your
template simple.
2. Remember that Custom Template is rearrangement of existing some HTML
fragments in the page, all other code is still the same, the fields in the Custom
Template should be the same as the original script. The available fields are
same as the original script, if you try to include other fields in the table or from other
table by Custom Template, it will NOT work without writing your own code.
3. Custom Template is HTML, if you want to embed PHP code, you need to use <?php
and ?> to enclose your code, if you want to use JavaScript, you need to use
<script type="text/javascript"> and </script>.
4. DO NOT use $this in your PHP code. There is no $this in the context, you can
however use CurrentPage() to get the current page object.
5. Avoid using JavaScript in the template. If you need to use JavaScript, try to put your
JavaScripts in Client Scripts and Startup Scripts of the page (see Server Events and
Client Scripts(See 1.11.15)). If you have to use JavaScript in the template, DO NOT
using document.write() because the script will be extracted from the template
and be executed at the end of the template, you can however use a DIV with unique
id and write to its innerHTML.
6. CustomTemplateBody is the template for a record. Your Custom Template needs
NOT to be a HTML table, but if it is, then CustomTemplateHeader and
CustomTemplateFooter must at least contains <table> and </table>
respectively, and you need to provide the <tr> and <td> tags in these templates.
7. If you use images in your Custom Template, you must put your images under the
project's File folder (see PHP Settings(See 1.11.2) > General Options -> File
Folder). Note that Export to Excel/Word (not by PHPExcel/PHPWord) does NOT
support images, and exporting by PHPExcel/PHPWord does not support Custom
Template (see PHP Settings(See 1.11.2) > General Options -> Export).
8. Before the Custom Template is applied, the jQuery event "rendertemplate" will be
fired, you can use Client Script of the page (see Server Events and Client
Scripts(See 1.11.15)) to subscribe this event and pass additional data to the Custom
Template.

149

PHP Report Maker 9 Help


9. If you want to use Custom Template for export only, disable the advanced setting
Use Custom Template for viewing, see Advanced Settings(See 1.14).

Also See:
Tutorial - Custom Template(See 1.17.10)

1.11.17 Custom Files


Custom Files enables you to add your own files to the project. Basically, a custom file is a
blank page with the layout of the project for you to add your own content so it will have a
consistent look and feel like other generated files.

How to Use
To create a Custom File, simply right click the database pane or click Edit in the main menu,
then select Add File, the following form will show:

The properties are as follows:


File name with extension.
Notes

File Name

1. Do not include path, you can enter Output


Folder later (see below).
2. Do not use characters not allowed as a file
name on your machine or on your server.
Alphanumerical characters only is
recommended.
3. If file name on your server is case-sensitive,
make sure you enter the file name in correct
lettercase. If you have selected Lowercase
in Generate tab (see Generate Settings(See
1.11.5)), the file name will be converted to
lowercase during generation.
4. The file name cannot be same as any table
(including view, Custom View and report)
name.

150

PHP Report Maker 9 Help

Caption

The caption of the page. This is similar to table


caption for a table and will be shown up in the menu
and in the Breadcrumbs of the page.

Includes common files

For .php file only. Specify whether to include the


common files (mainly header, menu and footer) in
the file so it will be consistent with other generated
scripts and able to use PHP Report Maker classes
and functions.
The output folder of the page. This must be relative
to application root of the project (see Generate
Settings(See 1.11.5)).
For example, if you have set up a website like:
Application root folder:
C:\Users\Administrator\Documents\mycompany.co
m

Output folder (relative to


application root)

Destination folder:
C:\Users\Administrator\Documents\mycompany.co
m\project1
and you want to generate your Custom File in the
destination folder, you should enter "project1/" (no
quotes).
Do NOT use parent path ".." or the file will be
generated outside the application root leading to
some unexpected results.
Note

After entering above properties, click OK button to save. The Custom File will show up in the
database pane under the Custom Files node:

151

PHP Report Maker 9 Help

To edit the Custom File properties, right click the Custom File in the database pane and
select Edit File.
To delete a Custom File, right click the Custom File in the database pane and select Delete
File.
To enter content for the file, select the Custom File in the database pane , then select the
Code tab (which contains Server Events, Client Scripts and Custom Templates) in the
right pane.
Scroll down the treeview or collapse the Server Events and Client Scripts node, select the
Custom Templates -> Table-Specific -> Custom File -> Content node, then you can
enter or paste your content in the editor:

152

PHP Report Maker 9 Help

Then just save your project generate and run your scripts in your browser as usual.

Although it is convenient to save your own files in the project, you should avoid
saving all the contents in the project or the project will become so large that the
performance of the UI will be affected. If the file content is large, you can put the content in
an external file and then include it in the Custom File. If the number of files is large, put the
minimum number of files in the project by Custom Files only, you can generate a blank
Custom File and duplicate it as containers for other files, then just add menu items to the
project by the Menu Editor for those external files.
Important

Examples
Example 1 - Include an external file instead of saving the page content in the project.

<?php include_once "MyPage.php"; // Includes an external file ?>

Example 2 - Add a Bootstrap Panel in the page to show some news.

<div class="panel panel-default">


<div class="panel-heading">Latest news</div>
<div class="panel-body">
<p>PHP Report Maker 9.0 is released</p>
</div>
</div>
The result:

153

PHP Report Maker 9 Help

Example 3 - Add multiple Bootstrap Panels in the page as a dashboard page. Use database
helper to execute SQLs and display data as HTML table.
To use the database helper, click Tools -> Advanced Settings (see Tools(See 1.14))
and enable Generate database helper and make sure you generate the file named
ewrdbhelper<version>.php. The database helper is generated in the destination folder of the
project. If Includes common files is enabled, it is auto-loaded so there is no need to
explicitly include the script.
Note

<?php
$dbhelper =& ReportDbHelper(); // Create instance of the database
helper by ReportDbHelper("<dbvar>") or by class name (e.g.
cr<dbvar>_db) where <dbvar> is database variable name
?>
<div class="panel panel-default">
<div class="panel-heading">Out of stock products</div>
<?php
$sql = "SELECT DISTINCT " .
"`categories`.`CategoryName` AS `CategoryName`," .
"`products`.`ProductName` AS `ProductName`," .
"`products`.`QuantityPerUnit` AS `QuantityPerUnit`" .
" FROM `categories` JOIN `products` ON (`categories`.`CategoryID`
= `products`.`CategoryID`)" .
" WHERE " .
"`products`.`UnitsInStock` <= 0";
echo $dbhelper->ExecuteHtml($sql, array("fieldcaption" => TRUE,
"tablename" => array("products", "categories"))); // Execute a SQL and
show as HTML table
?>
</div>
<div class="panel panel-default">
<div class="panel-heading">Discontinued products</div>
<?php
$sql = "SELECT DISTINCT " .
"`categories`.`CategoryName` AS `CategoryName`," .
"`products`.`ProductName` AS `ProductName`," .
"`products`.`QuantityPerUnit` AS `QuantityPerUnit`," .
"`products`.`UnitsInStock` AS `UnitsInStock`" .
" FROM `categories` JOIN `products` ON (`categories`.`CategoryID`
= `products`.`CategoryID`)" .
" WHERE " .
"`products`.`Discontinued` = '1'";
echo $dbhelper->ExecuteHtml($sql, array("fieldcaption" => TRUE,
"tablename" => array("products", "categories"))); // Execute a SQL and
show as HTML table
?>
</div>
The result:

154

PHP Report Maker 9 Help

Note

Other than ExecuteHtml(), there are a few other useful methods in the database

helper class, refer to the source code of the file rpt-db.php in the template for details. You
can also extend the database helper class (e.g. in server side Global Code, see Server
Events and Client Scripts(See 1.11.15)) and add your own methods.

1.11.18 Custom Fields


The feature enables you to add your own Custom Fields to a table or view based on valid
SQL expressions. You can treat a Custom Field as a dummy field you added to the table and
the value of the Custom Field is evaluated from the specified SQL expression. Once added,
the field can be treated as a normal field and will appear in all generated pages. You can use
Server Events and Client Scripts to manipulate the Custom Field to display any content you
want.
Important Notes

1. The SQL expression must be a valid SQL expression for the database based on the
fields of the table/view. Otherwise, the Custom Field cannot be created.
2. If no SQL expression is entered, the Custom Field will be a blank field and you need
to write your own Server Events and/or Client Scripts to handle the value of the
Custom Field.

155

PHP Report Maker 9 Help


3. A Custom Field is not an actual field in the database table/view so input
value will NEVER be inserted/updated to the database.

How to Use
To add a Custom Field to a table/view, simply right click on any database table/view (in the
database pane) or click Edit in the main menu, then select Add Custom Field, the following
form will show:

The properties are as follows:


Field Name

Field name of the Custom Field. Note that the field name cannot be the same as
any fields/Custom Fields in the table/view

Caption

The caption of the Custom Field.

Expression A valid SQL Expression based on existing fields.


After entering above properties, click OK button to save. The Custom Field will show up in
the Fields panel of the specific table/view.

To edit the Custom Field, right click the Custom Field and select Edit Custom Field.
To delete the Custom Field, right click the Custom Field and select Delete Custom Field.

156

PHP Report Maker 9 Help


Testing SQL Expression
Custom Field is just a subquery in the SELECT statement for the table, e.g.

SELECT *, (SQL Expression) AS CustomField FROM MyTable


The highlighted part is the Custom Field, it is a subquery inserted to the normal SELECT
statement for the table. That is why the expression for the Custom Field must be a valid SQL
Expression. To make sure your SQL expression is valid, you can test your expression in your
database manager first by executing:

SELECT (SQL Expression) AS CustomField FROM MyTable


e.g. SELECT (`UnitPrice`*`Quantity`*(1-`Discount`)) AS SubTotal FROM

MyTable
If it works, your SQL expression is valid, then you can enter your SQL Expression and

CustomField to create your Custom Field and use them as Expression and Field Name in
the Add Custom Field dialog said above.

1.11.19 Linked Tables


Linked Tables enables you to add tables/views from other databases to the project.
Supported databases include MySQL, PostgresSQL, Microsoft Access, Microsoft SQL Server
and Oracle. Linked Tables can be used like regular tables in the project, for example, you
can generate Add/Edit/Delete/Update scripts for the Linked Tables, you can use a Linked
Table as lookup table, user table, master or detail table.
Note

Using Linked Tables in Custom Views or Views is not supported.

Adding a Linked Table


To add new Linked Tables, simply right click the database pane or click [Edit] in the main
menu, then select [Add Linked Table], the following form will show:

157

PHP Report Maker 9 Help

Click the [Add Database] button in the toolbar to add a database.


The Database Connection form is same as that in the Database tab, see Database Setup(See
1.11.1) for detail.

Enter your database connection information and click the [Connect] button to load the
database information. The list of tables/views of the selected database will be displayed.

158

PHP Report Maker 9 Help


The database combobox will show the database name, database variable name and the
database type. The database variable name is to be used for retrieving the database
information in server side code such as server events (see Server Events and Client
Scripts(See 1.11.15)). By default it is same as the database name if the database name
contains alphanumeric characters and underscore only. Otherwise, the database variable
name will be different, with non-alphanumeric characters replaced. Besides, the database
name of a Linked Table can be same as the main database or database of other Linked
Tables. If database names are the same, an index will be appended to the database variable
name. If your project uses databases with the same name and you need to write server side
code, make sure you check the variable name here.
Note

Select the tables/views you need and click [OK]. The selected tables/views will be added to
the project as a Linked Table and will appear under the [Linked Tables] node of the database
pane. You can then manipulate the Linked Table as a regular table/view.

Deleting a Linked Table


To remove a Linked Table from the project, right click the Linked Table in the database
pane, and click Delete Linked Table. Click "Yes" to confirm deletion.

Note that if the database related with the Linked Table being deleted no longer has any
other Linked Tables associated, you may want to remove this database from the project as
well.
To do that, right click the database pane or click [Edit] in the main menu, then select [Add
Linked Table]

159

PHP Report Maker 9 Help

Select the database you want to remove from the dropdown selection, and click the
[Remove Database] button. Click "OK" to confirm deletion.

Synchronizing with Database of Linked Tables


If you are adding Linked Tables and you have altered the database of the Linked Tables, you
may want to synchronize the table list with the database so you can choose the new or
renamed tables. Or if you have changed some connection information of the database such
as the username or password, you may also want to update it.
To do that, right click the database pane or click [Edit] in the main menu, then select [Add
Linked Table], select the database and click the [Synchronize Database] button.

160

PHP Report Maker 9 Help

The connection information will be displayed again.

Change the connection information if necessary and then press the [Synchronize] button.
If you create a Linked Table and then rename the table in your database, the Linked
Table will fail, synchronizing with the database will NOT fix it since if a table is a renamed
table cannot be determined. You need to delete the old Linked Table and create a new one.
Note

161

PHP Report Maker 9 Help

1.11.20 Multi-Language Project

Multi-Language Project
Important

1. Multi-Language project must use utf-8 for everything. The charset of the
project must be "utf-8".
2. The data in your database must be stored in unicode, otherwise your data will
not be displayed properly.
3. If you have to customize the template and put unicode characters directly in the
template instead of using language file, always use utf-8 encoding and enable the
Advanced Setting UTF-8 output files (see Customizing Template(See 1.16) and
Tools(See 1.14)).
4. Only the English language file is provided by our products, you'll need to prepare the
language files for other languages yourself. You may also check our website and see
if there are any user submitted language files. If you want to share your language
files with others (without any conditions), you can submit your language file to us
too.

Making Language Files


Language files are placed in the subfolder "languages" under the installed folder. The files
are used for all templates.
To translate a language, duplicate the shipped english.xml and rename it. It is
recommended that the file name should contain alphanumeric characters (and underscore)
and in lowercase only.
1. Open the new XML file with any text or XML editor, you'll see the root node:

<ew-language date="2015/12/07" version="9.0.0" id="en"


name="English" desc="English" author="e.World Technology Ltd.">
You must change at least the id, name and desc attributes.
The id is an identifier for identifying the language in generated scripts, it must be
unique. It is recommended that you use the following values as the language IDs.
Language

Value Language

Value Language

Value

Arabic

ar

German (Austria)

de-AT Portuguese

pt

Bengali

bn

German
(Switzerland)

de-CH

Bulgarian

bg
Greek

el

Hebrew

iw

Hindi

hi

Catalan

zh-CN

Chinese

zh-

pt-BR

Portuguese (Portugal) pt-PT

ca

Chinese
(Simplified)

Portuguese (Brazil)

162

Romanian

ro

Russian

ru

Serbian

sr

PHP Report Maker 9 Help


(Traditional)

TW

Hungarain

hu

Slovak

sk

Croatian

hr

Indonesian

id

Slovenian

sl

Czech

cs

Italian

it

Spanish

es

Danish

da

Japanese

ja

Spanish (Latin
America)

es419

Dutch

nl

Kannada

kn
Swedish

sv

English (UK)

en-GB Korean

Tamil

ta

Telugu

te

Thai

th

Turkish

tr

Ukrainian

uk

Urdu

ur

Vietnamese

vi

ko

English (US)

en

Latvian

lv

Estonian

et

Lithuanian

lt

Filipino

fil

Malay

ms

Finnish

fi

Malayalam

ml

French

fr

Marathi

mr

Norwegian

no

French (Canadian) fr-CA


German

de

Persian

fa

Gujarati

gu

Polish

pl

The name is for displaying the language name in the user interface (which does not
support unicode), it should contain alphanumeric characters, underscore and spaces
only.
The desc is for displaying the language name in generated scripts, it can be in the
encoding of the XML file.
For example, if you want to make language file for Traditional Chinese, you may
rename the file as chinese.xml and modify the node as:

<ew-language date="2015/12/07" version="9.0.0" id="zh-TW"


name="Traditional Chinese" desc="" author="e.World
Technology Ltd.">
2. The language file contains a <locale> node. If you use Multi-Language, you must
customize the locale settings for each language. Either enter the locale string for the
language OR set use_system_locale to "0" to disable system locale and customize
the other locale settings. For example, you may want to change the decimal point as
"," and thousand separator as ".":

<locale>
<phrase id="locale" value=""/><!-- *** system locale for this
language -->
<phrase id="use_system_locale" value="0"/><!-- *** change to "0"
to disable system locale and use the following settings *** -->
<phrase id="decimal_point" value=","/>
<phrase id="thousands_sep" value="."/>
<phrase id="mon_decimal_point" value="."/>
<phrase id="mon_thousands_sep" value=","/>

163

PHP Report Maker 9 Help


<phrase id="currency_symbol" value="$"/>
<phrase id="positive_sign" value=""/>
<phrase id="negative_sign" value="-"/>
<phrase id="frac_digits" value="2"/>
<phrase id="p_cs_precedes" value="1"/>
<phrase id="p_sep_by_space" value="0"/>
<phrase id="n_cs_precedes" value="1"/>
<phrase id="n_sep_by_space" value="0"/>
<phrase id="p_sign_posn" value="3"/>
<phrase id="n_sign_posn" value="3"/>
<phrase id="time_zone" value="US/Pacific"/><!-- *** used for
multi-language site only *** -->
</locale>
If use_system_locale is set to "1", only the locale setting will be used. If
use_system_locale is set to "0", the locale setting will be ignored and other
settings (i.e. decimal_point, thousands_sep, etc.) will be used.
Note

3. You can edit or even add your own phrases. Just open the language file with any
text or XML editor, edit/add your <phrase> nodes. Make sure you provide an unique
id to each phrase. The id must be alphanumerical only.
The phrases are not limited to text, you can also use HTML, e.g.

<phrase id="FieldRequiredIndicator" value="&lt;span


class=&quot;ewRequired&quot;&gt;&amp;nbsp;*&lt;/span&gt;"/>
If you want to use an image instead of text for a phrase, you can use the
"imageurl", "imagewidth" and "imageheight" attributes, e.g.

<phrase id="UnmatchedValue" value="Value does not exist"


imageurl="{_images}/warn.gif" imagewidth="16" imageheight="15"/>
where {_images} is the image folder defined in control.xml, by default it is
"phpimages", you should place your own images in the generated image subfolder.
Alternatively, you can put your images in the "images" subfolder of the template.
4. Language file is an XML file, when you edit the file, make sure that you keep it wellformed. If you use HTML tags or special characters in the attributes of the
XML tags, you need to use entity references. For example, to insert the >
symbol, you need to use &lt;. Make sure your characters are supported by the
encoding of the XML file specified in the processing instruction node (the first line).
You can load the file in your browser to check if the file is well-formed, if it is, the
browsers should be able to load and display it without any errors.
DO NOT use old language files from previous versions directly or the new phrases will
be missing. You should compare the English version of the language files from old and new
version and then add the new phrases to your new language file.
Note:

Selecting Language Files for Project


Click [Tools] -> [Languages] to select the languages you want to use in the project. If
more than one language is selected, a combobox will appear on the top of the generated
scripts for user to select language.

164

PHP Report Maker 9 Help

Enabling Multi-Language and Selecting Default Language


If you want to use multi-language project, make sure you have enabled Multi-Language in
the [PHP]->[General] tab (see PHP Settings(See 1.11.2)).
Then, select a Default Language in the [PHP]->[General] tab (see PHP Settings(See
1.11.2)).

165

PHP Report Maker 9 Help

Multi-Language Property Editor


If you use single language, you do NOT need to use this editor, just enter your phrases
in the general user interface. Only use this editor if you use Multi-Language.
Note

Some text properties support Multi-Language. This editor allows you to enter your
property values for each language. Supported properties are:

Table/Field Captions
Field Error Message
Chart Caption
Chart X Axis Title
Chart Y Axis Title
Chart Primary Y Axis Title
Chart Secondary Y Axis Title
Menu Text
Site Title and Footer Text

To edit these properties, click [Tools] -> [Multi-Language Property Editor] to open the
editor. Alternatively, you can also click the small button next to above properties in the user
interface to open.

166

PHP Report Maker 9 Help

Select a property in the Property pane on the left to edit, then enter your properties in
unicode. For example, you can copy and paste from Word.
The editor supports import/export of the phrases (of the mutli-language properties only, not
including the phrases in the language files):

Click the export button to export the phrases to a XML file so you can edit the file with text
or XML editor or share the file with other project. Click thie import button to choose the XML
file that you want to import so you can quicky use edited phrases or easily reuse other
project's XML file.
Previously saved properties are displayed in bold font. Once you use this editor to save
your unicode text, the saved unicode property values will always be used prior to the original
property values (in the general user interface) . The original property value will only be used
if unicode property value of the language cannot be found. If you want to edit the property,
always go back to this editor. After editing and saving unicode properties, remember
to re-generate the languages file and upload them again.
Note

Using Server Events


If you prefer to customize the language phrases by code, you can use the Language_Load
server event. You can use the global function CurrentLanguageID() to get the current
language ID and write your code accordingly. See Server Events and Client Scripts(See
1.11.15) for more details.

167

PHP Report Maker 9 Help

1.12 Application Root


Note that file folders are relative to application root. This enables the user to put the files in
folder outside of the script folder.
Where is the application root? PHP Report Maker scripts looks for the application root in the
following sequence:

1. Root Relative Path


Root Relative Path is the path relative to destination folder. The destination folder is the
folder where the generated scripts reside.
When you generate scripts, you must specify the [Application root folder] and the
[Destination folder] correctly based on your folder structure. The relative folder structure
on your local computer must be the same as that on your production server.
For example, if you put the generated scripts in a subfolder,

In this case, the Root Relative Path is therefore the parent folder of the script, i.e. "..". The
scripts will use this relative path to find the application root.
It is recomended that you set the [Application root folder] to the root folder of your
Website where is accessed by http://www.mycompany.com/.
On your testing server, you may work with multiple projects and test your projects one
folder level lower at http://localhost/<projectname>/ (cf. http://<projectname>/). In this

168

PHP Report Maker 9 Help


case you should set the [Application root folder] in each project as the root folder of the
project (the folder that is accessed by http://localhost/<projectname>/). After uploading to
the production server, the site may be then accessed by http://www.mycompany.com/ (cf.
http://localhost/<projectname>/), but as long as the relative location of the two folders
(Application Root folder and the script folder) are the same, the scripts will still work
properly.

2. Document root
If Root Relative Path is empty, the script checks the following variables:
$_SERVER["APPL_PHYSICAL_PATH"].
If you use IIS on Windows (e.g. you are using PHP with MS Access or SQL Server on
Windows), this variable should return the physical path of the application root of your web
site, read Creating Virtual Directories in IIS(See 1.8) in Introduction to PHP and
MySQL(See 1.8).
If Root Relative Path is empty, the script checks the following variables:
$_SERVER["DOCUMENT_ROOT"] or $_ENV["DOCUMENT_ROOT"].
If you use Apache, it is usually the physical path of your Website root. e.g. On Linux, it may
return
/home/username/public_html which can be accessed by http://www.mycompany.com/
You can put your generated scripts in your Website root, or you can put the generated
scripts in a subfolder under your website root, e.g.
/home/username/public_html/scripts which can be accessed by
http://www.mycompany.com/scripts/
When you generate scripts, you still need to specify the [Application root folder] and the
[Destination folder] based on your folder structure so that the relative location of the two
folders is correct.

3. Script Path
If both Root Relative Path and Document Root are empty, the script will use the path of the
current script.

4. Custom Path
The above three approaches should handle most cases. If in some special cases they don't
return the path you want, you can modify the function ewr_AppRoot() in phprptfn.php
(template) or ewrfn*.php (generated script). You can simply customize the template and
specify your real server path directly. For example,
Windows:

function ewr_AppRoot() {
return 'C:\Inetpub\wwwroot\MyWebRoot\'; // replace with your real
server path directly, include the trailing path delimiter
}

169

PHP Report Maker 9 Help


Linux/Unix:

function ewr_AppRoot() {
return '/home/username/public_html/'; // replace with your real
server path directly, include the trailing path delimiter
}
Remember that you must also check the value of the constant EW_ROOT_RELATIVE_PATH,
make sure it correctly points to your application folder relative to the script folder. Using
above example, you specify that the application root is "C:\Inetpub\wwwroot\MyWebRoot",
if your scripts are placed in "C:\Inetpub\wwwroot\MyWebRoot\MyScripts\", then
EW_ROOT_RELATIVE_PATH should be "..".
TIP: You can call the PHP function phpinfo() (i.e. <?php phpinfo(); ?>) to view your
server information, including the server paths. Alternatively, in the generated scripts (that
includes phpfn<version>.php), you can call the function ewr_WritePaths() (i.e. <?php

echo ewr_WritePaths(); ?>) to view the path settings in your project.

1.13 Project File


A project file is an XML file which stores all settings of a particular project. You should save a
project file for each site you generate and back it up. You will NOT be able to create a
project file backwardly from the generated scripts later.
A project file is an XML file, like other XML document, it is human-legible. You should be able
to open a project file in any text editor and view the content. Each object (e.g. database,
table, field, etc) is represented by an XML node in the project file. The object properties are
saved as attributes of the node.
A project file is in utf-8 encoding, your text editor needs to support utf-8. Most text editors
support utf-8 nowadays. You can simply use Notepad if you do not have other text editors.
With basic understanding of XML, you can change the settings manually. However, If you
modify a project file, make sure your keep it well-formed. To check if the file is well-formed,
you can change the file extension to .xml and open it with Internet Explorer or Firefox. If the
file can be loaded and displayed properly in the browser, it is well-formed.

Auto Backup
When you save a project, the old version will be saved to the subfolder <Documents
folder>\<product name>\Backup folder first, you can recover older versions of your project
from the backup folder in case of corrupted projects or other accidental losses. Note that
only the latest 10 versions will be kept, older versions will be deleted.
The Documents folder is your personal folder in which you can store your personal
files. For example, in Windows XP, the actual location of the Documents folder is
C:\Documents and Settings\<user name>\My Documents by default, where C is the drive in
which Windows is installed, and <user name> is the currently logged-on user. In Windows
Vista (or later), the folder is C:\Users\<user Name>\Documents.
Note

Project Name
Each project has a project name. By default the file name (without extension) of the project
file is used as project name. Before you name your project file when saving it for the first

170

PHP Report Maker 9 Help


time, a temporary name, Project<n>, where n is a number, is used. The project name is an
important property, it is used in the generated codes to identify your project.
Note

It is recommended that only alphanumerical characters is used in project name.

If you need to change the project name, use Advanced Settings(See 1.14).

Project ID
Each project has a project ID which is a GUID (globally unique identifier). The value of a
GUID is represented as a 32-character hexadecimal string, such as {095F6728-DF53-4763A372-D8F2EAC959F2}. It is used to identify the project and the scripts generated by it.
Each script generated by the project has the project ID. An XML file named <GUID>.xml is
also generated for each project in the subfolder named by the project name under the
application root(See 1.12). The XML file contains some project information and is used to
share with other projects (e.g. PHPMaker project) with the same project name. So do not
reveal the project ID to public and do not change the project ID unless absolutley necessary.
If you really need to, use Advanced Settings(See 1.14).
If you use Dynamic User Level (see Advanced Security(See 1.11.4)), the project ID is also
used in the User Level Permission table as a prefix of the table name so that the table
names from different projects will not clash.

Save As vs. Save A Copy


If you want to create a new project based on an existing project, use [Save As...] under
the [Project] menu. If [Save As...] is used, the project name and project ID are
changed in the new file. The new file is NOT the same project anymore.
If you want to create a backup copy or another version of an existing project, you should
use [Save a Copy...] to save the file with another name. If [Save a Copy...] is used, the
project name and project ID are NOT changed. The project name may not be same as
the file name anymore. However, with the same project name and project ID, scripts
generated from these project files will still work like they are generated from the same
project file.

Also See:
Object Properties(See 1.16.3)

1.14 Tools

Tools

171

PHP Report Maker 9 Help


Click [Tools] in the main menu bar to access the following useful tools available in PHP
Report Maker.
Synchronization
Languages
Multi-Language Property Editor
Extensions
Advanced Settings
Copy Table Settings
Copy Field Settings
Sort Tables Alphabetically
Delete Template Cache
Compatibility Properties(See 1.11.14)
Menu Editor

Synchronization
During the course of project development, it is common that you have altered your database
schema. To save the effort of doing the customization from scratch again, PHP Report Maker
provides you with the ability to synchronize your project data with the database. The
synchronization process can be invoked in the following situations:

1. When working in PHP Report Maker


Simply click [Tools]->[Synchronize] or click the button on the toolbar to perform the
synchronization. PHP Report Maker will check automatically to see if the database schema
has been altered. If there are changes, you will be prompted whether or not to proceed with
the synchronization.
2. When opening a project file
When open a project file, PHP Report Maker will automatically check the database to see if
the schema has been altered. You will be prompted to keep or update to the new schema.
If the database contains a large number of tables/fields, this auto-synchronization
feature may make reloading a project file slow. In that case you can disable this feature by
unchecking [Tool]->[Auto Synchronize].
Note

Languages
If you want to use multi-language project, make sure you have enabled Multi-Language in
the [PHP]->[General] tab (see PHP Settings(See 1.11.2)), then click [Tools] ->
[Languages] to select the languages you want to use in the project. If more than one
language is selected, a combobox will appear on the top of the generated scripts for user to
select language.

172

PHP Report Maker 9 Help

After selecting the languages, select a Default Language in the [PHP]->[General] tab
(see PHP Settings(See 1.11.2)).
Read Multi-Language Project(See 1.11.20) for details.

Multi-language Property Editor


Some text properties support unicode input for multi-language project through MultiLanguage Property Editor.
Read Multi-Language Project(See 1.11.20) for details.

Extensions
Click [Tools]->[Extensions] to enable or disable these extensions. If the extension has
advanced settings (NOT every extension has it), you'll see the [Advanced] tab after
selecting the extension. Click the [Advanced] to configure advanced settings for the
extension.

173

PHP Report Maker 9 Help

Advanced Settings
Advanced Settings are some advanced general settings for PHP Report Maker, or some
rarely changed settings for the project, or custom defined settings for use during code
generation. Click [Tools] -> [Advanced Settings] to change these settings:

174

PHP Report Maker 9 Help

General

General settings for PHP Report Maker (for all


projects)

Custom validation functions

The comma separated function names for the


Validate feature (see Field Setup(See 1.11.7))
You can add your own PHP/JavaScript functions
for custom server/client-side validation. The
function name is used for both PHP and
JavaScript, so it must be a valid function name
for both languages. You can put your server-side
and client-side validation function in the Global
Code (see Server Events and Client Scripts(See
1.11.15)) section of server-side and client-side
respectively.

Script engine timeout (milliseconds)

The Windows Script engine timeout period.


PHP Report Maker uses Windows Script to
generate scripts dynamically, if you have a lot of
tables or fields, the script engine may time out
during generating a file and prompt you to
cancel execution or continue. To avoid this
problem, you can increase this timeout setting.
For example, you can increase 60000 ms (one
minute) at a time.

UTF-8 output files

If enabled, the output file is in utf-8 encoding.

175

PHP Report Maker 9 Help


Otherwise, it is ASCII by default.
The template files and output files are in ASCII
encoding by default. Since the phrases are
separated into XML language files in utf-8
encoding, ASCII encoding will suit most cases as
the scripts contain code only. When you
customize a template, it is recommended you
use the language file also. If you have to put
unicode characters directly in the template files,
you must always use utf-8 and save the file in
utf-8 encoding with the byte order mark (EF BB
BF), and enable this setting to make the code
generator output files in utf-8 encoding.
IIS Express (iisexpress.exe) path

The installed path of iisexpress.exe. For use with


Browse after generation and IIS Express as
Testing web server, read Generate
Settings(See 1.11.5).
PHP Report Maker will try to find automatically
where iisexpress.exe is installed. If no found,
enter your path here.

IIS Express port

The port to be used by IIS Express. For use with


Browse after generation and IIS Express as
Testing web server, read Generate
Settings(See 1.11.5).
PHP Report Maker will try to find a free port
automatically. If you want to specific one
explicitly, enter it here.

PHP CGI (php-cgi.exe) path

The installed path of php-cgi.exe. For use with


Browse after generation and IIS Express as
Testing web server, read Generate
Settings(See 1.11.5).
IIS Express uses php-cgi.exe to run the testing
site, make sure you have included php-cgi.exe
when you install PHP on your PC. If not,
download the zip file from php.net and put the
php-cgi.exe in your installation folder for PHP
(usually <Program Files>\PHP).
PHP Report Maker will try to find automatically
where php-cgi.exe is installed. If not found,
enter your path here.

Format project file

Format and indent project file so that it is more


readable

Project

Settings for the current project only

Project name

Project name. See Project File(See 1.13) for


more info.

176

PHP Report Maker 9 Help


Project ID

Unique ID of the project. Do not change the


project ID unless absolutely necessary. See
Project File(See 1.13) for more info.

Debug

Show the SQL and runtime error for debugging.


The setting is generated in ewrcfg*.php, if you
change this setting only, you only need to regenerate ewrcfg*.php. Alternatively, you can
manually modify the file and change the
constant EWR_DEBUG_ENABLED.

Compress project .css

Compress the project stylesheet (i.e.


<project>.css) and output minified .css file.

Compress project .js

Compress the project JavaScript file (i.e.


ewp<version>.js) and output minified .js file.

Generate database helper

Generate a database helper named


<database>db2.php for including in current or
other project for simple access to the database
and retrieiving data.

Disable project CSS styles

Do not generate the the project stylesheet.


If you use this setting, there will be no CSS
styles generated for the scripts and the HTML
will be malformed, make sure you provide your
own CSS styles, for example, by specifying your
own stylesheet, read HTML Settings(See
1.11.3).
Note

Character encoding (for Ajax/iconv)

Specify the encoding for iconv


Some features require conversion between your
encoding and utf-8. If you use non English
languages, you may need to set character
encoding for these features. By default PHP
Report Maker will setup the encoding
automatically based on your project's Charset
setting. If that is incorrect, you can specify
yours. Make sure either iconv functions or
multibyte string functions are enabled and your
encoding is supported. See PHP manual for
details.

MySQL charset (for SET NAMES)

Specify the charset for MySQL SET NAMES


statement.
If actually charset encoding of your data is
different from the charset of your project, you
may need to specify this setting for MySQL to
convert between them. Read
http://dev.mysql.com/doc/refman/5.0/en/chars
et-connection.html before using this setting.

Default time zone

Specify the default time zone of the server.


Read

177

PHP Report Maker 9 Help


http://www.php.net/manual/en/function.datedefault-timezone-set.php and
http://www.php.net/manual/en/timezones.php
for supported time zones.
Use DOM XML for Language object

Use PHP 5 DOM XML to load language file


instead of using PHP XML parser.
By default the scripts use PHP XML parser to
load the language file for faster loading. If your
PHP setup does not have PHP XML parser
installed or you want to manipulate the loaded
XML document by DOM XML, enable this setting.

Use JavaScript popup message

Use JavaScript popup message to display


messages of the application.
By default the messages are displayed above
the main table. This options uses JavaScript to
show the message as a popup message on page
load.

Disable button on submit

Disable submit buttons when submitting the


form.
Enable this setting if you need to prevent user
submitting the form more than once (by clicking
the submit button) when the browser is
submitting the form.

Allow login by URL

Allow passing username and password to the


login page as URL parameters.
By default the login page accepts HTTP POST
only. If this setting is enabled, it accepts HTTP
GET also, then user can login by URL , e.g.

login.php?username=xxx&password=yyy
(where "yyy" is a plain text password)
For example, this allows user login by using PHP
cURL from your own scripts.
For security, you should pass an encrypted
password whenever possible. In fact, usually
you can retrieve an encrypted password (e.g. a
md5 hashed password) from other web
application only, if it is same as the encrypted
password for your project (e.g. MD5 password
is enabled in the project, or the project uses the
same user table), then you can pass an
additional URL parameter encrypted=1 to let
the scripts know how to compare the passwords,
e.g.

login.php?username=xxx&password=xyz&e
ncrypted=1 (where "xyz" is an encrypted

178

PHP Report Maker 9 Help


password)
Allow login by session variables

Allow passing username and password to the


login page via session variables.
By default the login page accepts HTTP POST
only. If this setting is enabled, it accepts session
varaibles also, then user can auto-login by
setting some session varaibles , e.g.

$_SESSION[EWR_PROJECT_NAME .
"_Username"] = "xxx"; // where
EW_PROJECT_NAME is the constant of
your project name (see above) and
"xxx" is user name
$_SESSION[EWR_PROJECT_NAME .
"_Password"] = "yyy"; // where "yyy"
is a plain text password
For security, you should pass an encrypted
password whenever possible. In fact, usually
you can retrieve an encrypted password (e.g. a
md5 hashed password) from other web
application only, if it is same as the encrypted
password for your project (e.g. MD5 password
is enabled in the project, or the project uses the
same user table), then you can pass an
additional session variable to let the scripts
know how to compare the passwords, e.g.

$_SESSION[EWR_PROJECT_NAME .
"_Username"] = "xxx"; // where "xxx"
is user name
$_SESSION[EWR_PROJECT_NAME .
"_Password"] = "xyz"; // where "xyz"
is an encrypted password
$_SESSION[EWR_PROJECT_NAME .
"_Encrypted"] = TRUE;
Remove XSS

Specify if sensitive keywords allowing XSS


attack should be removed.
If enabled, all user input string will be checked
against an array of sensitive keywords. If
discovered, those keywords will be broken by
inserting "<x>" to prevent XSS attack. If this
behavior is unwanted, you can disable this
feature at your own risks. Re-generate and reupload the ewrcfg*.php after changing this
setting.
If you just want to allow some sensitive
keywords, you can customize the array
$EWR_XSS_ARRAY in rpt-config.php of the
template. (Read Customizing Template(See
1.16).)

179

PHP Report Maker 9 Help


Check token for form post

Check synchronizer token for form post (e.g.


Popup filters)

Session timeout period (minutes)

Specifies the session time-out period if the user


does not refresh or request a page.
PHP has its own settings for session timeout,
you can configure them in php.ini, read
http://php.net/manual/en/session.configuration.
php, but sometimes you may want to control the
session period yourself, then you can setup
BOTH this setting and the Session keep alive
interval (seconds) setting (see below) to a
positive value.

Session keep alive interval (seconds)

Specifies the interval to send Ajax request to the


server for keeping the session alive.
Notes

1. For this setting to work, this setting


MUST be SHORTER than the
session.gc_maxlifetime and
session.cookie_lifetime in php.ini,
otherwise the session will be expired by
PHP first. Do not set the interval too
short, making requests to the server
every 300-600 seconds (5-10 minutes)
should be enough.
2. To enable this feature, this setting must
be set to a value larger than 0.
Session time out countdown period
(seconds)

Specifies the countdown period before session


ends.
When the session is about to end, a modal
dialog will show up to remind user and let the
user choose to continue the session. If the user
does not respond after the countdown period,
the session will expire.

Show current filter

Show current filter, for example, for debug

Initiate filter panel as collapsed

Collapse the extended filter panel on page load.


However, if the filter panel has values, it will be
expanded automatically.

Language files

Default language files (comma separated)

Allow no paging section

Allow no paging section in the reports.


If both paging section at top and that at bottom
are disabled, users will not be able to go to the
second or later pages. The scripts will use
paging section at bottom by default to make
sure paging is possible. If you want to allow no
paging section (e.g. you always have all records
in one page), enable this setting.

180

PHP Report Maker 9 Help


Use hierarchical User ID

For used with User ID Security. (see Security


Settings(See 1.11.4).)
If enabled, a parent user can view records of
child users and grandchild users and so on. If
disabled, a parent user can only view records of
child users.

Use ADOdb driver for MySQL

Use ADOdb driver if MySQL database is used (by


default a customized lite version
ewmysql<n>.php is used)

Oracle charset

By default the project character is also used for


connecting to Oracle. If you need to use a
different charset, specify it with this setting.

Oracle compare

For setting Oracle's NLS_COMP parameter.


Requires Oracle 10gR2 (or later). Possible
values are: BINARY, LINGUISTIC, ANSI.
For example, if you want to do case insensitive
search you can select LINGUISTIC.

Oracle sort

For setting Oracle's NLS_SORT parameter.


Requires Oracle 10gR2 (or later).
For example, if you want to do case insensitive
search you can enter "BINARY_CI" (no double
quotes).

Auto-Suggest maximum display entries Specify the number of options to be displayed


during Auto-Suggest. Default is 10.
Use contains for Auto-Suggest

Use "contains" instead of "starts with" for AutoSuggest.

Hide user table password field

If enabled, passwords in the user table will be


displayed as "********" in reports.

Thumbnail default width (px)

For use with extension for image resize. (see


Third-party Tools(See 1.7).)
If a target resize width is <= 0, this default
width will be used. If this setting is also 0, the
width will be auto-adjusted to keep the aspect
ratio.

Thumbnail default height (px)

For use with extension for image resize. (see


Third-party Tools(See 1.7).)
If a target height width is <= 0, this default
height will be used. If this setting is also 0, the
height will be auto-adjusted to keep the aspect
ratio.

Reduce image size only (image resize) Do not resize if image is smaller than the resize
dimension.

181

PHP Report Maker 9 Help


Always keep aspect ratio (image
resize)

Keep aspect ratio during image resize.

Use Colorbox for images

Specify if colorbox should be used to displayed


full size image on clicking the thumbnail in the
List/View page. Default is true.

Multiple file separator

Specify the file name separator used to separate


the file names (e.g. saved by multiple file upload
feature of PHPMaker). By default, comma is
used. If you allow file names with comma, you
can enter another separator, e.g. "|".

Max email recipient

To avoid abusing the export to email feature,


the number of email addresses in the recipient
field is limited to the specified value. Default is
3.

Max email sent count per session

To avoid abusing the export to email feature,


the number of emails can be sent by the user in
each session is limited to the specified value.
Default is 3.

Max email sent session period

To avoid abusing the export to email feature,


the number of email within a period of time is
limited to the specified value. The unit is
minutes. Default value is 20.
Write email log (see below) must be
enabled for this to work.
Note

Write email log

Specify if the email sent should be logged.


The File folder (see PHP Settings) will be
used to store the log file. Make sure you have
specified the file folder and granted write
permission.
Note

Email log field size limit

Specify the general size for all fields (see below)


to be logged.
If you don't need to log everything, you may
want to log the first nth characters for each field
only. Enter the maximum number of characters
for all fields, including the "..." appended to the
end.

Write email log to database

By default the log is written to a daily log file in


the specified File folder (see PHP Setup(See
1.11.2)), if you want to log to a database table,
enable this setting and the table name and field
names below.

Email log table name

Table name of the email log table.

Email log DateTime field name

Datetime field for logging the date and time of

182

PHP Report Maker 9 Help


email sent.
Email log IP field name

String field for logging IP of the sender.

Email log Sender field name

String field for logging email address of the


sender.

Email log Recipient field name

String field for logging email address of the


recipients.

Email log Subject field name

String field for logging subject of the emails.

Email log Message field name

String field for logging the message of the


emails.

Use ILIKE operator (PostgreSQL)

Use ILIKE instead of LIKE for case-insensitive


search (for PostgreSQL only).

Collation for LIKE operator (MySQL)

Use the specified COLLATION for the LIKE


operator (for MySQL only).

Collation for LIKE operator (Microsoft


SQL Server)

Use the specified COLLATION for the LIKE


operator (for Microsoft SQL Server only).

Show blank series for chart

Show blank series for chart

Show zero values in stacked chart

Show zero values in stacked chart

Use popup panel for drill down

Use a popup panel to show the detail report in


the same page. If disabled, user will be
redirected to the drill down report directly after
clicking the drill down link.

Show drill down filters

Show current drill down filters in the detail


report.

Use responsive layout

Use responsive layout for mobile devices


automatically. Default is TRUE.
If disabled, there will be NO mobile
features, everything will be for desktop only.
Note

Use place holder for text box

Add placeholder attribute to form elements


automatically. Possible values are:

Use css-flip

None - no placeholder
Caption - use field caption (see Field
Setup)(See 1.11.7) as placeholder
attribute value (default)

Use Twitter css-flip to convert the generated


<project>.css, bootstrap.css and bootstraptheme.css to RTL version (*-rtl.css) and add
dir="rtl" attribute to the BODY tag.
Note

1. PHP Report Maker and Bootstrap 3 do


NOT support RTL. This setting is it is

183

PHP Report Maker 9 Help


provided for users' convenience only.
2. css-flip just flips the CSS, using it alone
cannot make everything perfectly RTL
automatically. You'll still to adjust some
CSS (and JavaScript) yourself to make
your website completely RTL. However,
this will be a very good start point for
your own customization.
3. css-flip is not written by the author of
PHP Report Maker. NO TECHNICAL
SUPPORT WILL BE PROVIDED.

The settings are defined in the settings.xml located at the "src" folder. If you are an
advanced user who customize templates, you can also add your own settings to the
"Project" section. Open the settings.xml with a text or XML editor, add a <setting> node
under the "Project" section. Make sure you provide an unique id to the setting. Supported
data type is "String", "Integer" and "Boolean". If not specified, default is "String". The
setting value can be retrieved in the template during code generation (NOT during runtime
of the generated script) using the PROJ.GetV(id) method. Also read Template Tags(See
Note

1.16.5) and Object Properties(See 1.16.3).

Copy Table Settings


If you use database built-in query/view to make an alternate version of a table, you need to
set up the table and field settings again, this tool help you quickly copies table and field
settings from the source table to the view. Click [Tools] -> [Copy Table Settings] to open
the following form:

184

PHP Report Maker 9 Help

Select the [Source table] and the [Target table] (e.g. the query/view), click OK to copy
the table settings. If a field in the target table has the same name as that in the source
table, field settings will also be copied.
This feature copies setting without validation. If settings from the source table/field are
not applicable to the target table/field, errors may result. Check the settings after copying.
Note

Copy Field Settings


When you create a Custom View, PHP Report Maker allows you to copy field settings from
the source table. However, when database built-in query/view is used, you need to set up
the field settings again, this tool help you quickly copies field settings from the source table
to the view. Click [Tools] -> [Copy Field Settings] to open the following form:

Select the [Source table] and the [Target table] (e.g. the query/view), the fields of the
target table will be listed in the left column, you can then select the respective source fields
(from the specified source table) in the right column and click OK to copy the field settings.
This feature copies setting without validation. If settings from the source table/field are
not applicable to the target table/field, errors may result. Check the settings after copying.
Note

Sort Tables Alphabetically


If you prefer to have the table list displayed in the user interface in alphabetical order, click
[Tools] -> [Sort Tables Alphabetically] to do so.

185

PHP Report Maker 9 Help


Notes

1. Re-arranging the table display order by drag-and-drop in the Table Setup page is
still supported, so the display order will NOT be re-sorted automatically after
synchronizing the project with your database even there are new tables added to the
database. Use this tool to sort again if necessary.
2. Only tables are sorted, the display order of the fields in the user interface or in the
generated scripts will NOT be affected by this tool.
3. The display order of the menu items in the generated scripts is still controlled by the
Menu Editor, using this tool will NOT affect the menu items.

Delete Template Cache


PHP Report Maker will reuse the pre-processed template scripts to speed up codegeneration. We refer to these pre-processed scripts as "template cache", sometimes these
template cache may become corrupted resulting from, for example, generating with a
corrupted template or badly customized template. In these cases you may want to delete
bad template cache and let PHP Report Maker builds the template cache again. You can do
so by either clicking [Tools] -> [Delete Template Cache] or by manually removing the
folder for the template under your Documents folder, i.e. <Documents Folder>\PHP Report
Maker\Templates\<TemplateName>.zip\. (Also see Customizing Template(See 1.16).)

Compatibility Properties
See Compatibility Properties Setup(See 1.11.14).

Menu Editor
PHP Report Maker allow you to modify the menu in the generated site, to open the menu
editor, click [Tools] -> [Menu Editor] in the main menu or click the "Menu Editor" icon in
the toolbar.

186

PHP Report Maker 9 Help

Use the following toolbar buttons to manage your menu items:


Add item

Add a new menu item


You can add new menu items and link
them to your own URLs. Just click the
button to add and then enter your URL.
Note that the URL of the List pages of the
tables are uneditable, they will be
generated by PHP Report Maker
automatically.
Add a child menu item to the focused
menu item

Add child item

You can also easily drag-and-drop the icon


of a menu item to another menu item to
create child menu items.
Delete

Delete the focused menu item

Edit item

Edit the displayed text of the focused


menu item. You can also click the text
directly to edit.

Post

Post the changes you make to the focused


menu item.

Cancel

Cancel the changes you make to the


focused menu item.

Refresh

Refresh the menu items

Move up one level

Move the focused menu item up one level

Move down one level

Move the focused menu item down one

187

PHP Report Maker 9 Help


level
Move Up

Move the menu item up

Move Down

Move the menu item down

Expand all items

Expanse all menu items so all menu items


of each level are shown

Collapse all items

Collapse all menu items so only menu


items of the first level are shown

Import items from PHP Report Maker projectImport menu items from PHP Report
Maker project
Delete imported menu items

Delete imported menu items

Multi-Language

Show Multi-Language Property Editor for


editing unicode menu text

Chart menu items

Show/hide the menu items for charts

You can show/hide the menu items by checking/unchecking the checkboxes beside the menu
item text. If a parent menu item is hidden, all the child items will also be hidden.
If you want to use special characters in the menu caption, use HTML entities such as
"&#euro;", or you can enter unicode caption using Multi-Language Property Editor, see
Multi-Language Property Editor above.
If your custom menu items requires login, uncheck [Allow Anonymous User]. For other
(non custom) menu items, this setting is same as the List/Search/View permission for
Anonymous User in Advanced Security. (See Security Settings(See 1.11.4).)
After modifying, make sure you click [OK] to save the changes.
By default, the menu is vertical.

Registered user can use the Horizontal Menu(See 1.7) extension, click [Tools] ->
[Extensions] to enable the graphical extension, then click [Advanced] tab to set the
menu options.

188

PHP Report Maker 9 Help

Grouped menu items is supported. Grouped menu items are to be set up in the same way as
a sub menu. You can check the title menu item in the Group Title column of the Menu
Editor:

Then menu group title will be displayed like:

189

PHP Report Maker 9 Help

Since horizontal menu cannot display menu groups like vertical menu, group title
should not be enabled for root level menu items in horizontal menu. If enabled, they will be
only be displayed as normal submenus. However, since submenu is vertical, you can use
group title for menu items in submenus.
Note

1.15 FusionCharts
FusionCharts XT
FusionCharts XT is a comprehensive JavaScript (HTML5) charting library for both web and
mobile.
In the evaluation version of PHP Report Maker, only the evaluation version of FusionCharts
is included. There is no feature limitation in the evaluation version of FusionCharts, except
that the charts are watermarked.
Registered users of PHP Report Maker are entitled to use the benefit of the
FusionCharts extension with licensed version of FusionCharts. Registered users will be
provided info to download the extension.
PHP Report Maker does NOT support all charts in FusionCharts, it supports the following
chart types only. Refer to the developer's website for documentation:
http://www.fusioncharts.com/developers/documentation.
Notes

1. FusionCharts XT does NOT include PowerCharts XT, FusionWidgets XT and


FusionMaps XT.
2. PHP Report Maker does NOT support PowerCharts XT, FusionWidgets XT
and FusionMaps XT.

Column Chart

Both 2D & 3D, with 3D-lighting and gradients. Also, glass effect column
chart supported.

190

PHP Report Maker 9 Help

Pie Chart

Both 2D & 3D, with 3D-lighting and gradients. Also, interactive slicing
and rotation are supported.

Bar Chart

Both 2D & 3D, with 3D-lighting and gradients.

191

PHP Report Maker 9 Help

Line Chart

2D

Doughnut Chart

Both 2D & 3D, with 3D lighting and gradients. Also, interactive slicing
and rotation are supported.

192

PHP Report Maker 9 Help

Area Chart

2D

MultiSeries/Stacked
Charts

2D Line and 2D Area Charts. Both 2D & 3D Bar and Column charts,
with 3D lighting and gradients

193

PHP Report Maker 9 Help

194

PHP Report Maker 9 Help

195

PHP Report Maker 9 Help

196

PHP Report Maker 9 Help

Dual Y Axis
Combination
Charts

2D/3D Column (primary Y Axis) & Line (secondary Y Axis). Support for
3D lighting effect and gradient fills. Scrollable charts available (see
below).

197

PHP Report Maker 9 Help

Scrollable charts

2D Column, line and area charts with scrollable x-axis

198

PHP Report Maker 9 Help

199

PHP Report Maker 9 Help


Grid Component

Notes

1. FusionCharts support export. PHP Report Maker supports exporting charts to


PDF/Word/Excel/Email. Read PHP Settings(See 1.11.2) for detail.
2. Export requires PHP Imagick extension or cURL extension. Check phpinfo and make
sure either one (or both) is usable.
3. If your web server does not have PHP Imagick extension installed, the exported
chart is retrieved by cURL from fusioncharts.com's export handler service, so your
web server must be online for export to work.

FusionCharts Free
FusionCharts XT does NOT include PowerCharts XT, FusionWidgets XT and
FusionMaps XT by the same developer. FusionCharts Free was a Flash-based (NOT
JavaScript/HTML5) product, it has been already discontinued and is no longer supported by
the developer. PHP Report Maker continues to use FusionCharts Free to provide backward
compatibility for Funnel Charts, Candlestick Charts and Gantt Charts. Refer to the
developer's website for documentation: http://www.fusioncharts.com/goodies/fusionchartsfree.
Notes

1. Only Funnel Charts, Candlestick Charts and Gantt Charts of FusionCharts


Free are supported. All other charts are NOT supported any more.
2. FusionCharts Free does NOT support export.

200

PHP Report Maker 9 Help


Gantt Chart

Funnel Chart

Candlestick Chart

FusionCharts XT and FusionCharts Free are not developed by the author of PHP
Report Maker and are not part of PHP Report Maker, read Third-part Tools(See 1.7) for more
information. NO technical support will be provided.
Note

201

PHP Report Maker 9 Help

Also See:
Third Party Tools(See 1.7)
Tutorial - Chart (See 1.17.11)

1.16 Customizing Template


A template is a zip file of code snippets needed to generate the output files. Template is fully
customizable, you can customize the default template shipped with the product to suit your
own needs in your web applications.
Customizing templates requires necessary knowledge in the related web technologies, HTML
and JavaScript, and understanding on how template works. Please read the follows carefully
before customizing the template.
The template engine is Windows Script and the scripting language is JavaScript, to
customize template you need to have basic knowledge of JavaScript. If you are not familiar
with the scripting language, refer to the JavaScript Fundamentals and JavaScript Reference.

Zipped Template, Unzipped Template and Template Cache


To generate output files, the code generator first unzips the template to the subfolder
\<product name>\Templates\<template name> under your Documents folder, preprocesses the scripts in the template into template cache, then use the template cache to
generate output files. If the unzipped template already exists, the code generator will skip
the unzip process and reuse the template cache so the time required for generation is
minimized.
If you want to customize a template, normally you customize the files in the zipped
template, but you'll need to zip it back after customization, for example, by dragging the
customized files back to the zipped template. The unzipped template under the Documents
folder provides an optional way to customize the template without re-zipping the template.
Either way, you should zip it back after all the customizations are done.
The Documents folder is your personal folder in which you can store your personal
files. For example, in Windows 7, the actual location of the Documents folder is
C:\Users\<user name>\Documents by default, where C is the drive in which Windows is
installed, and <user name> is the currently logged-on user.
Note

If you prefer to work with the unzipped template but you have not generated any files yet,
do once first. Then you can modify the unzipped files under the subfolder named "Script".
For example, if the template archive is named as "default.zip", it will be unzipped to the
folder <document folder>\<product name>\Templates\default.zip\, you can modify files
under the subfolder "Script" under it.
The customized files will not be zipped back to the template archive automatically. It
you want to transfer or share your template, you need to zip the template files back to a
template archive yourself. When you zip the template files, make sure you zip the files and
subfolders in the unzipped folder, not the unzipped folder itself. Otherwise there will be one
level different. Using above example, you should add the files and subfolders under
<document folder>\<product name>\Templates\default.zip\ to the template archive, NOT
the whole folder.
Note

202

PHP Report Maker 9 Help


When changes in the zipped template is detected, the code generator will ask you to confirm
overwriting the old unzipped version, you should answer carefully, especially if you've
implemented some customizations previously. Always back up your customized
template first!

Control File
The core of the template file is a control file named control.xml. It is an XML file containing
all the necessary instructions for the generation process. During generation the code
generator will parse the control.xml and follows the instructions to generate the output files
one by one. If you want to add an output file, you need to add a <control> tag in the control
file. If the file is to be included in other file(s), you may need to add <session> tags in
control.xml also. See Control File(See 1.16.1) for details.

Language File
All the phrases in the template are separated into a single XML language file for easy
translation to other languages and sharing. If you want to translate a template, this should
be the only file you need to translate.
Language files are placed in the subfolder "languages" under the installed folder. The files
are used for all templates.
See Multi-Language Project(See 1.11.20) for more information on making a language file.

File Encoding
The template files and output files are in ASCII encoding by default. Since the phrases are
separated into XML language files in utf-8 encoding, ASCII encoding will suit most cases as
the scripts contain code only. When you customize a template, it is recommended you use
the language file also. If you have to put unicode characters directly in the template files,
you must always use utf-8 and save the file in utf-8 encoding with the byte order mark (EF
BB BF), and enable the Advanced Setting UTF-8 output Files (see Tools(See 1.14)) to
make the code generator output files in utf-8 encoding.

General Layout
To change the general layout, just modify the file "rpt-template.php" in the template. This
file will be generated as header and footer.

Subfolders
Subfolders are defined in control.xml, if you want to add and copy additional subfolders, you
also need to add a <control> tag in the control file(See 1.16.1).

Template Tags and Object Properties

203

PHP Report Maker 9 Help


The code generator processes the Template Tags(See 1.16.5), assembles the output files
using the code snippets from template files and generate code according to Object
Properties(See 1.16.3). Template object properties are project settings either inputted from
the user interface or restored from a project file. Template Tags are in the format of HTML
comment, when you customize template you should use an editor that will not unexpectedly
alter or remove the HTML comments, otherwise incorrect result may occur.

User Code File


Advanced users can customize the dynamically generated code by overriding an existing
template tag using User Code. To override an existing template tag, you need to add your
own function in the User Code File. (See Using User Code(See 1.16.4).) By default, the
User Code File is named as "usercode.js" and can be found under the "src" subfolder of the
installed directory.
You can use your own custom functions in the template. To use custom functions, write and
put them in the User Code File. Then just use template tag to call them in the template.
(See Using User Code(See 1.16.4))

Extensions
Integrating third-party tools can be done by extensions. An extension is modification of
template to make the template supports additional feature(s) implemented in the extension.
Extensions may add or change code sessions in the template.
An extension has the same structure as template and you can modify them in exactly the
same way as modifying the main template.
Extensions files (in zipped format) must be placed under the subfolder "extensions" of the
installation folder. Each extension must have a XML description file so the product can load it
in the user interface for selection. You can open an XML file in the "extensions" subfolder to
see the content, which is self-explanatory. Unzip the extension and see how it is
implemented.
Read Tools(See 1.14) on how to select extensions for a project before generation.
An extension is NOT a template, do NOT select an extension as a template for
generation.
Note

Note that all extensions are provided as examples on how to customize and extend the
template only, the third party tools used in them are not developed by the author of PHP
Report Maker and are not part of PHP Report Maker, NO TECHNICAL SUPPORT WILL BE
PROVIDED. Also see Third-party Tools(See 1.7) for more information on the third-party
tools.

Custom View Tags


Custom View Tags is same as extensions except that it is used to display a field in the List
and View pages with your own code. A Custom View Tag has the same structure as
extension and you can modify them in exactly the same way.
Custom View Tag files (in zipped format) must be placed under the subfolder
"customviewtags" of the installation folder. Each Custom View Tag must have a XML
description file so the product can load it in the Field Setup page for selection.. You can open

204

PHP Report Maker 9 Help


an XML file in the "extensions" subfolder to see the content, which is self-explanatory. Unzip
the extension and see how it is implemented.
Read Field Setup(See 1.11.7) on how to select Custom View Tag for a field.
Note that all Custom View Tags are provided as examples how to customize and extend the
template only, the third party tools used in them are not developed by the author of PHP
Report Maker and are not part of PHP Report Maker, NO TECHNICAL SUPPORT WILL BE
PROVIDED.

Also See:
Control File(See 1.16.1)
Template Tags(See 1.16.5)
Object Properties(See 1.16.3)
Using User Code(See 1.16.4)
Third-party Tools(See 1.7)
Tools(See 1.14)

1.16.1 Control File


The core of the template file is a control file named "control.xml". It is an XML file and it
contains all the necessary information for the generation process. It is structured in 3 levels,
namely the product, control and session level:
control.xml
<?xml version="1.0" standalone="yes"?>
<product>
<control>
<session/>
...
<session/>
</control>
...
<control>
<session/>
...
<session/>
</control>
</product>

1. <product>
The top level is the product level identified by the <product> tag. (The tag name "product"
will be replaced by unique product name identifier in respective products.) It gives a brief
description of the template and serves for product and version information purpose. The
changes in this tag will be checked every time you generate scripts with a template.
Syntax:

205

PHP Report Maker 9 Help


<product
date="release_date"
version="version_number"
desc="description"
language="lang_name"
author="author_name">
...
</product>

Attributes

Description

date

Template created date (yyyy/mm/dd)

version

Template version number

desc

Brief description of the template

language

Language of the template

author

Author of the template

2. <control>
The next level is the control level identified by the <control> tag. Each <control> specify an
output file or a set of output files that will be generated by the code generator.
Syntax:
<control
id="control_id"
type="control_type"
ofile="output_file_name"
oext="output_file_extension"
ifiles="input_files"
space="True/False"
ofolder="output_file_folder"
cond="conditions">
...
</control>

AttributesDescription
ofile

Output file name

oext

Output file extension

type

Control type:
"table" - table-related files:
For example, the scripts that will perform "list", "view", "add", "edit" and "delete"
functions for the table. The output of this type is a set of file, one for each table.
"other" - include files:

206

PHP Report Maker 9 Help


AttributesDescription
These files are usually include files that may be included by other files. For
example, the header file and footer file.
"copy" - files that will be directly copied:
These files that will be copied directly from the templates, such as image files.
The target to be copied can be a file or a folder.
id

Control ID. This attribute identifies which page is being generated.


Example:
type="table"
id="list" - list page
id="add" - add page
id="edit" - edit page
id="delete" - delete page
id="view" - view page
id="search" - search page
type="other"
id="loginh" - login page (hard coded user id and password)
id="loginl" - login page (use information from table for user id and password)
id="logout" - logout page
type="copy"
all ids are treated as files to be copied

ifiles

List of input files to be processed (comma delimited)

ofolder

Output file folder (used for type="copy" only)

space

Remove empty lines (True / False)

cond

Condition for generation. (see below)

action

For use with extensions only.


"add" - add file or folder to the the main template, or
"change" - change file in the main template

3. <session>
The third level is the session level (identified by the <session> tag). For each <control>,
there can be multiple sessions that will constitute the output. Each session can be a specific
segment from the input files or an include statement.
Syntax:
<session
type="session_type"
value="session_value"
/>

207

PHP Report Maker 9 Help


Attributes Description
type

Session type:
"key" - output the code segment identified by the key from the list of input files
"include" - create an include statement

value

Session value:
type="other"
key value of code segment (identified by session tags in input files)
type="include"
include file name

action

For use with extensions only.


"change" - change a session in the control level

Conditions
Condition checking is used extensively in templates to control the code generation process.
Codes will only be generated if the condition specified is met.
The syntax of condition checking is as follow:

condition1[,condition2...]
Condition format:

Object_Type/Object_Property/Operator/Value1[|Value2...]
Object Type and Object Property:
See Object Properties(See 1.16.3) for details
Operator:
EQ = equal
NE = not equal
GT = greater than
GE = greater than or equal to
LT = less than
LE = less than or equal to
IN = contain value
NI = not contain value
Value:
value for comparison
(Note that single/double quotes are NOT required for string type values.)

1.16.2 System Functions


1. Common utility functions
Function Name

Description

ew_SetDb(tablename) (v9+)

Set up current database for table name


Parms
tablename - table name

208

PHP Report Maker 9 Help


ew_GetDbId(tablename) (v9+)

Return database id for table name


Parms
tablename - table name

ew_DbType(dbid) (v9+)

Return database type for database id


Parms
dbid - database id

ew_IsAutoSuggest(fld) (v8+)

Return if field is auto suggest field


Parms
fld - field object

ew_UseForLabel(fld) (v8+)

Return if field use for label


Parms
fld - field object

ew_HasUserTable() (v8+)

Return if user table used

ew_IsNotEmpty(val) (v6+)

Return if value is not empty


Parms
val - value

ew_IsEmpty(val) (v6+)

Return if value is empty


Parms
val - value

ew_InArray(val, ar) (v6+)

Return if value is in array


Parms
val - value
ar - array

ew_FormObj(ctlid) (v6+)

Return form object name


Parms
ctlid - control id

ew_SqlSelect(sSelectLimit, sDistinct,
sSelect, sFrom) (v6+)

Return SQL SELECT statement


Parms
sSelectLimit - SELECT LIMIT part
sDistinct - use SELECT DISTINCT
sSelect - SELECT part
sFrom - FROM part

ew_CustomScriptRowCnt() (v8+)

Return custom template row count

ew_CustomScriptRowCntVar() (v8+)

Return custom template row count variable

ew_CustomScriptGroupVar() (v7+)

Return custom template group variable

ew_CustomScriptRowVar() (v7+)

Return custom template row variable

ew_CustomScriptGroupIndex(fld, cnt, grp) Return custom template group index


Parms
(v7+)
fld - field object
cnt - group count

209

PHP Report Maker 9 Help


grp - grouping field or not
ew_CustomScriptId(name, type ,idx) (v7+) Return custom template script id
Parms
name - script name
type - script type
idx - row index
ew_CustomScriptTag(name, type,
classname, idx) (v7+)

Return custom template script tag


Parms
name - script name
type - script type
classname - class name
idx - row index

ew_GetJsScript(html)

Return javascript from html


Parms
html - html content

ew_RemoveJsScript(html)

Remove javascript from html


Parms
html - html content

ew_GetFieldHtmlTag(f) (v6+)

Return field html tag


Parms
f - field object

ew_NullIfFunction(fld) (v6+)

Return SQL NULLIF function for different


database type
Parms
fld - field SQL

ew_CastFieldForLike(fld, type, dtfmt) (v6+) Return SQL that cast non-string field for LIKE
statement
Parms
fld - field SQL
type - field type
dtfmt - date format
ew_ContainText(Str, Find)

Return True if "Find" in "Str"


Parms
Str - Source string
Find - Find string

ew_HasTagValue(fld, val)

Return if field contains tag value


Parms
fld - field object
val - tag value

ew_FldTagValues(fld)

Return field tag values


Parms
fld - field object

ew_SplitTagValues(str)

Return an array of tag values


Parms

210

PHP Report Maker 9 Help


str - "value 1","value 2",...
ew_IsBinaryField(Fld)

Return True if field is binary


Parms
Fld - field object

ew_SummaryValueName(id)

Return summary value name


- (SumValue / AvgValue / MinValue / MaxValue)
Parms
id (String) - Sum/Avg/Min/Max

ew_SummaryViewValueName(id)

Return summary view value name


- (SumViewValue / AvgViewValue /
MinViewValue / MaxViewValue)
Parms
id (String) - Sum/Avg/Min/Max

ew_CssInherit(parm)

Return "inherit" if parm is empty

ew_AddSquareBrackets(varname, fld)

Add square brackets to variable


Parms
varname - variable name
fld - field object

ew_PageObj()

Return page object name

ew_GetPageObjByCtrlId(ctlid) (v6+)

Return page object name based on control id


Parms
ctlid - control id

ew_GetCtrlById(id) (v6+)

Return control object based on control id


Parms
ctlid - control id

ew_Val(v)

Return PHP TRUE/FALSE value


Parms
v - boolean value

ew_JsVal(v)

Return JavaScript true/false value


Parms
v - boolean value

ew_RandomKey()

Return random key

ew_FolderPath(id)

Return folder path


Parms
id - control id

ew_GetFileNameByCtrlID(id)

Return file name based on control id


Parms
id - control id

ew_RelFolder(f)

Return relative folder to current output folder


Parms

211

PHP Report Maker 9 Help


f - folder path
ew_RelPath(f1, f2)

Return relative folder of f1 to f2


Parms
f1 - folder path 1
f2 - folder path 2

ew_OutputRelPath(f) (v8+)

Return output relative folder


Parms
f - folder path

ew_DestRelPath(f) (v8+)

Return relative folder to destination folder


Parms
f - folder path

ew_AppRootRelPath(f) (v8+)

Return relative folder to application root


Parms
f - folder path

ew_EscapeString(sSrc, sEsc)

Return escaped string


Parms
sSrc - source string
sEsc - escape string
(double quote for VB, backslash for JS)

ew_DoubleQuote(str, cnt)

Return double quoted string


Parms
str - source string
cnt - quote count

ew_Quote(str)

Escape double quote in string


Parms
str - source string

ew_Quote2(str)

Escape double quote in string (including $ sign)


Parms
str - source string

ew_SQuote(str)

Escape single quote in string


Parms
str - source string

ew_UnQuote(str)

Remove embracing single/double quotes in


string
Parms
str - source string

ew_GetFieldType(fType)

Return field type based on ADO field type


Parms
fType - ADO Field Type
Output
1 - Numeric
2 - Date
3 - String
4 - Boolean

212

PHP Report Maker 9 Help


5 - GUID
6 - Others
7 - Time
ew_IsDbGrpFld(grptype)

Return True if database group type


Parms
grptype - "f", "i", "y", "q", "m", "w", "d", "h",
"min"

ew_DbGrpSql(grptype, grpint)

Return grouping SQL


Parms
grptype - "f", "i", "y", "q", "m", "w", "d", "h",
"min"
grpint - grouping interval ("f" / "i" types only)

ew_BoolFieldTagValues(ftype, tagvalues)

Return tag values for Boolean field


Parms
ftype - ADO Field Type
tagvalues - original tag values

ew_SQLPart(sSQL, sId)

Return part of the SQL


Parms
sSQL - original SQL
sId - token for different part of SQL
(SELECT, FROM, WHERE, GROUP BY, HAVING,
ORDER BY, LIMIT)

ew_RecPerPageList(sList, iRec)

Return record per page list (comma separated)


Parms
sList - original record per page list
iRec - default record per page

ew_ChartCount(Pos)

Return number of charts in position


Parms
Pos - 1 (Top), 2 (Left), 3 (Right), 4 (Bottom),
Not specified (All)

ew_FieldSqlName(fld)

Return the sql name for the field


Parms
fld - field object

ew_FieldSqlNameBase(fld, tbl) (v9.0+)

Return the sql name for the field


Parms
fld - field object
tbl - table object

ew_QuotedName(name)

Return the properly quoted sql name


Parms
name - table/field name

ew_TableName(tbl)

Return the sql table name


Parms
tbl - table object

213

PHP Report Maker 9 Help


ew_IsDateFilter(f) (v6+)

Return true if field is enabled for date filter


Parms
f - field object

ew_IsPopupFilter(f) (v6+)

Return true if field is enabled for popup filter


Parms
f - field object

ew_IsFieldDrillDown(f) (v6+)

Return true if field is enabled for drill down


report
Parms
f - field object

ew_FieldDrillDownUrl(f) (v6+)

Return field drill down url


Parms
f - field object

ew_IsChartDrillDown(cht) (v6+)

Return true if chart is enabled for drill down


report
Parms
cht - chart object

ew_ChartDrillDownUrl(cht) (v6+)

Return chart drill down url


Parms
cht - chart object

ew_DateSql(f) (v6+)

Return date SQL


Parms
f - field object

2. Overridable Functions
USAGE: SYSTEMFUNCTIONS.<FunctionName>
Function Name

Description

Charset()

Return meta tag for charset


specified

FavIcon()

Return <link> tags for favicon


specified

CssFile()

Return <link> tag for css file


specified

GetScript(scripttype,codetype,scriptname)

Return server/client scripts


Parms
scripttype - script type (Server /
Client)
codetype - code type (Global /
Table / Other)
scriptname - script name

GetServerScript(codetype,scriptname)

Return server scripts


Parms

214

PHP Report Maker 9 Help


codetype - code type (Global /
Table / Other)
scriptname - script name
GetClientScript(codetype,scriptname)

Return client scripts


Parms
codetype - code type (Global /
Table / Other)
scriptname - script name

ScriptExist(scripttype,codetype,scriptname)

Return if server event / client script


exists
Parms
scripttype - script type (Server /
Client)
codetype - code type (Global /
Table / Other)
scriptname - script name

ServerScriptExist(codetype,scriptname)

Return if server event exists


Parms
codetype - code type (Global /
Table / Other)
scriptname - script name

ClientScriptExist(codetype,scriptname)

Return if client script exists


Parms
codetype - code type (Global /
Table / Other)
scriptname - script name

CustomTemplateExist() (v7+)

Return if custom template exists

GetCustomTemplate() (v7+)

Return custom template codes

ParseTemplate(template,templateid) (v7+)

Pase and return custom template


content
Parms
template - template source codes
templateid - template id

RenderCustomTemplate() (v7+)

Return codes that render the


custom template

GetTemplateScript(CodeType,ScriptName) (v7+)

Return template scripts


Parms
codetype - code type (Table)
scriptname - template name

GetCustomViewTemplate(fld) (v7+)

Return custom view template for


field
Parms
fld - field object

215

PHP Report Maker 9 Help


IsBoolFld()

Return if field is boolean

PHPCgiPath()

Return CGI path

NoCache()

Return PHP no cache codes

IncludeFile(id,parm)

Return PHP include file statement


Parms
id - control id
parm - "compat" to generate
compat header/footer

ConnectionString()

Return database connection string

Security()

Return security checking codes

ScriptSummaryViewRefer()

Return PHP codes for rendering


summary field for VIEW (HREF)

ScriptViewRefer()

Return PHP codes for rendering


field for VIEW (HREF)

ScriptGroupView()

Return PHP codes for rendering


grouping field for VIEW

ScriptGroupSummaryView()

Return PHP codes for rendering


grouping field for VIEW (Summary)

ScriptView()

Return PHP codes for rendering


field for VIEW

ScriptSummaryView(id)

Return PHP codes for rendering


field for VIEW (Summary)
Parms
id - Sum/Avg/Min/Max

ScriptViewCall(cv, vv, dtl)

Return PHP codes for rendering


field for VIEW
Parms
cv - current value
vv - view value
dtl - detail field

ScriptViewNo(cv, vv)

Return PHP codes for rendering


field for VIEW (AutoNumber field)

ScriptViewText(cv, vv)

Return PHP codes for rendering


field for VIEW (TEXT field)

ScriptViewFormat(parm)

Return PHP codes for field VIEW


TAG format
Parms
parm - field to be formatted

216

PHP Report Maker 9 Help


ScriptViewPassword(cv, vv)

Return PHP codes for rendering


field for VIEW (PASSWORD field)

ScriptViewValues(cv, vv)

Return PHP codes for rendering


field for VIEW (Lookup Value field)

ScriptViewTextarea(cv, vv)

Return PHP codes for rendering


field for VIEW (TEXTAREA field)

ScriptViewHidden(cv, vv)

Return PHP codes for rendering


field for VIEW (HIDDEN field)

ScriptViewFile(cv, vv)

Return PHP codes for rendering


field for VIEW (FILE field)

ScriptViewHref(cv, vv)

Return PHP codes for rendering


field for VIEW (HREF field)

FieldSummaryGroupView()

Return field control for Summary


Group VIEW

FieldGroupView()

Return field control for Group VIEW

FieldSummaryView(id, lvl)

Return field control for Summary


VIEW
Parms
id - summary id
lvl - group level

FieldView()

Return field control for VIEW

FieldViewCall(cv, vv, id, lvl)

Return field control for VIEW

FieldViewCheckbox(cv, vv, id, lvl)

Return field control for VIEW


(CHECKBOX field)

FieldViewText(cv, vv, id, lvl)

Return field control for VIEW (TEXT


field)

FieldViewFile(cv, vv, id, lvl)

Return field control for VIEW (FILE


field)

FieldViewHref(ctl, vv)

Return field control for VIEW (HREF


field)
Parms
ctl - control to be HREF

FieldSearch()

Return extended filter textbox 1

FieldSearch2()

Return extended filter textbox 2

FieldSearchLookup(autopostback)

Return field control for search


lookup field
Parms
autopostback - auto post back the

217

PHP Report Maker 9 Help


search form after selection
FieldSearchRadio(ctl, autopostback)

Return field control for search


lookup field (RADIO)
Parms
ctl - field control
autopostback - auto post back the
search form after selection

FieldSearchCheckbox(ctl, autopostback)

Return field control for search


lookup field (CHECKBOX)
Parms
ctl - field control
autopostback - auto post back the
search form after selection

FieldSearchSelect(ctl, autopostback)

Return field control for search


lookup field (SELECT)
Parms
ctl - field control
autopostback - auto post back the
search form after selection

FieldSearchAjax(ctl, autopostback)

Return field control for search


lookup field (AJAX)
Parms
ctl - field control
autopostback - auto post back the
search form after selection

FieldEditText(ctl, val)

Return field control for EDIT (TEXT


field)
Parms
ctl - control
val - value

FieldOperator()

Return extended filter field operator


1

FieldOperator2()

Return extended filter field operator


2

FieldOperatorCall(ctl, val, opr)

Return extended filter field operator


based on parameter
Parms
ctl - control
val - value
opr - operator

FieldSearchCondition()

Return extended filter condition

GroupByFieldNames()

Return group by field names


(separated by CrLf)

218

PHP Report Maker 9 Help


OrderByFieldNames()

Return order by field names


(separated by CrLf)

ParmFieldNames()

Return drill down parameter field


names (separated by CrLf)

JsValidator()

Return JS validator for extended


filter

JsValidatorCall(ctl)

Return JS validator for extended


filter based on parameter
Parms
ctl - control

JsDefaultMsg()

Return JS default error message for


extended filter

PhpValidator()

Return PHP (Server Side) validator


for extended filter

PhpValidatorCommon(fld, msg)

Return PHP (Server Side) validator


for extended filter based on
parameters
Parms
fld - field name
msg - error message

PhpDefaultMsg()

Return PHP (Server Side) default


error message for extended filter

RowFieldNames()

Return row field names for crosstab


report (separated by CrLf)

ColumnFieldNames()

Return crosstab column field name

SummaryFieldNames()

Return crosstab summary field


name

CrosstabSql(sqlpart)

Return crosstab SQL part


Parms
sqlpart - SQL part token
SELECT, FROM, WHERE, GROUP BY,
ORDER BY, SELECT AGGREGATE,
GROUP BY AGGREGATE

CrosstabYearSql()

Return crosstab SQL to get distinct


year values

DistinctColumnSql(sqlpart)

Return crosstab SQL part to get


distinct column values
Parms
sqlpart - SQL part token
SELECT

219

PHP Report Maker 9 Help


Return summary/list SQL part
Parms
sqlpart - SQL part token
SELECT, FROM, WHERE, GROUP BY,
HAVING, ORDER BY, SELECT
AGGREGATE, AGGREGATE PREFIX

ReportSql(sqlpart)

LookupSql(bDistinct, sSelect, sFilter, sRunTimeFilterVar, Return codes for lookup SQL


Parms
bAddUserIDFilter, sSelectLimit, sDefaultOrderBy)
bDinstinct - use DISTINCT
sSelect - SELECT SQL part
sFilter - filter SQL
sRunTimeFilterVar - run time filter
variable
bAddUserIDFilter - add user id
filter
sSelectLimit - SELECT LIMIT
sDefaultOrderBy - default order by
SelectionList()

Return selection list in JSON

ConnectionString(db) (v9.0+)

Return database connection string


Parms
db - database object

DatabaseConnection(db) (v9.0+)

Return database connection array


Parms
db - database object

1.16.3 Template Object Properties


Please refer to the following table for detailed description of Objects and their properties for
use with Template Tags(See 1.16.5).

I. Objects
Project

Description

CTRL

Control Object

PROJ

Project Object

CUSTOMSCRIPTS (v4+)

Custom Scripts Object

MENULIST (v3+)

MenuList Object

DB

Database Object

TABLE

Table Object

CHART

Chart Object

220

PHP Report Maker 9 Help


FIELD

Field Object

LANGUAGE (v4+)

Language Object

PROJ.LINKDBS (v9+)

Link Database Object

You can view the object properties by opening your Project File(See 1.13) with a text
editor. Project file is an XML file, each object is represented by an XML node in the project
file. The object properties are saved as attributes of the node. The property name is same as
the attribute name.
Note

II. Properties
You can use the standard dot notation to access properties of the objects.
Example

<!--##=PROJ.ProjName##-->
This line will write the project name in the output file.
CTRL Object
The CTRL Object points to the current control in control.xml that is being generated.
Property

Description

Data Type

CtrlId

ID (e.g. rpt, summary, crosstab, etc.)

String

CtrlType

Control type (e.g. table, report, field, other,


String
copy, etc.)

PROJ Object
The PROJ Object points to the current project. You can access the current project properties
by PROJ.PropertyName.
Property

Description

Data Type

ProjID (v5.1+)

Project ID (GUID)

String

ProjName

Project Name

String

ProjVar

Project variable

String

MultiLanguage (v4+)

Multiple language project

Boolean

DefaultLanguageFile
(v4+)

Default language file

String

LanguageFiles (v4+)

Language files supported (comma

221

String

PHP Report Maker 9 Help


separated)
AppCompat

Application in compatibility mode

Boolean

AppHeader

Compatibility mode header file name

String

AppFooter

Compatibility mode footer file name

String

AppLogin

Compatibility mode login file name

String

AppLogout

Compatibility mode logout file name

String

AppDefault

Compatibility mode default file name

String

AppCssFolder

Css folder name (relative path)

String

AppChartCssFile

Chart Css file name

String

AppCompatVersion
(v4+)

Compatible version

Integer

CodePage (v4+)

Code Page

Long

Cache

Allow Cache

Boolean

CharSet

Character Set

String

CSS

External CSS file

String

OutputNameType

Output File Name Type:


"" - None
"Prefix" - Prefix
"Suffix" - Suffix

String

OutputNameExt

Output File Name Prefix or Suffix

String

OutputNameLCase

Output File Name in lowercase

Boolean

BodyTitle

Body Title Description

String

BodyFont

Body Font

String

BodySize

Body Size

String

BodyBgColor

Body Background Color

String

BodyTextColor

Body Text Color

String

BodyLnkColor

Body Link Color

String

BodyVLnkColor

Body Vlink Color

String

BodyALnkColor

Body Alink Color

String

BodyLeftMargin

Body Left Margin

Integer

BodyTopMargin

Body Top Margin

Integer

222

PHP Report Maker 9 Help

DocType (v5+)

Document Type
(NONE,HTML,XHTML,HTML5)

String

ApplicationTheme (v3+)Application Theme

String

HeaderColor (v3+)

Page header color

String

HeaderLogo (v3+)

Page header logo file name

String

HeaderHeight (v3+)

Page header height

Integer

MenuColor (v3+)

Page menu color

String

FooterColor (v3+)

Page footer color

String

FooterFontColor (v3+) Page footer font color

String

FooterText (v3+)

Page footer text

String

TblWidth

Table width

String

TblPadding

Table padding

Integer

TblBorder

Table border

Integer

TblSpacing

Table spacing

Integer

TblBgColor

Table background color

String

TblHdrFontColor

Table header font color

String

TblHdrColor

Table header background color

String

TblAltColor

Table use alternate row color

Boolean

TblAltColor1

Table alternate color 1

String

TblAltColor2

Table alternate color 2

String

Template

Template file location

String

Destination

Output destination folder location

String

SecType

Security type:
"None" - no security
"Hard Code" - use hard coded administrator
login / password
String
"Use Table" - use security table
"Both" - use security table & hard coded
administrator login / password

SecLoginID

Administrator login id

String

SecPasswd

Administrator password

String

SecTbl

User table name

String

SecLoginIDFld

User table login id field

String

SecPasswdFld

User table password field

String

223

PHP Report Maker 9 Help


SecLoginCaptcha (v6+) Use login captcha

Boolean

SecRegisterActivate

Boolean

User needs activation

SecRegisterActivateFld User activation field name

String

SecSenderEmail

Sender email address

String

SmtpServer

Smtp server name

String

SmtpServerPort

Smtp server port

Long

SmtpSecureOption
(v6+)

Smtp secure option (ssl/tls)

String

MemoCRLFReplace

Replace CRLF with BR for memo field

Boolean

TestWebServer (v6+)

Testing web server


1 - IIS Express
2 - Other

Integer

DefaultDateFormat

Default date format:


0 - General date (system)
1 - Long date (system)
2 - Short date (system)
3 - Long time (system)
4 - Short time (system)
5 - "yyyy/mm/dd"
6 - "mm/dd/yyyy"
7 - "dd/mm/yyyy"
9 - "yyyy/mm/dd hh:nn:ss"
10 - "mm/dd/yyyy hh:nn:ss"
11 - "dd/mm/yyyy hh:nn:ss"

Integer

DateSeparator

Date separator: "/", "-", "."

String

SetLocale

Set locale (PHP)

Boolean

Locale

Locale (PHP)

String

CGI

Use CGI

Boolean

CGIPath

CGI path

String

Ext

File extension

String

DefaultPage

Default page

String

UseMySqli

Use mysqli extension

Boolean

StartPage (v6+)

Start page

String

XMLEncoding

XML encoding charset

String

RptColColor

Report column color

String

RptGrpColor1

Report group 1 color

String

RptGrpColor2

Report group 2 color

String

224

PHP Report Maker 9 Help


RptGrpColor3

Report group 3 color

String

RptGrpColor4

Report group 4 color

String

RptGrpSummaryColor1 Report summary color 1

String

RptGrpSummaryColor2 Report summary color 2

String

RptGrpSummaryColor3 Report summary color 3

String

RptGrpSummaryColor4 Report summary color 4

String

RptPageTotalColor

Report page total color

String

RptGrandTotalColor

Report grand total color

String

PagerBackColor

Pager background color

String

FooterBackColor

Footer background color

String

UploadPath (v4+)

Image Path (for uploaded images)

String

CssStyles

User css style content

String

AutoSync

Auto synchronize when open project

Boolean

AutoBrowseURL (v6+) Auto browse URL

String

AutoBrowse

Browse after Generation

Boolean

BodyStyle

Body Style

String

OtherGen

Generate other scripts

Boolean

OtherGenList (v4+)

Generation list for other scripts. Format:


@db=1,@css=0,... (Generate "db" = Yes,
Generate "css" = No, etc...)

String

OtherExpanded (v4+)

Expand the other generation list (for


display)

Boolean

OtherOverwrite
(deprecated in v4+)

Overwrite Other Scripts

Boolean

PromptOnOverwrite
(deprecated in v4+)

Prompt on Overwrite

Boolean

DynamicLoadDB

Load database dynamically

Boolean

MD5Password

Use MD5 password

Boolean

CaseSensitivePassword Use Case Sensitive password

Boolean

ServerValidate

Use server validation

Boolean

ClientValidate

Use client validation

Boolean

RecPerPage

Records per page

Integer

RecPerPageList

Comma separated values for records per

225

String

PHP Report Maker 9 Help


page
PrinterFriendly (v4+)

Printer friendly

Boolean

ExportHtml

Export to html

Boolean

ExportWord

Export to word

Boolean

ExportExcel

Export to excel

Boolean

ExportEmail (v4+)

Export to email

Boolean

ExportPDF (v5+)

Export to PDF

Boolean

ExportType (v4+)

Export type:
"PAGE" = export current page
"ALL" = export all records

String

SortType

Sort type
0 - no sort
1 - single column sort
2 - multi-column sort

Integer

PagerStyle

Pager style:
1 - numeric pager
2 - nextprev pager

Integer

TopPageLink

Pager on top

Boolean

BottomPageLink (v3+) Pager on bottom

Boolean

LinkOnLeft

Links on left

Boolean

RepeatColumns (v4+)

Repeat column count for radios and


checkboxes

Integer

AppRootFolder

Application root folder

String

RootRelativePath (v6+) Root relative path

String

RecipientEmail (v4+)

Receiver email

String

SMTPServerUsername
(v4+)

Smtp server user name

String

SMTPServerPassword
(v4+)

Smtp server password

String

FavIcon (v4+)

File path for FavIcon

String

LoginOption (v4+)

Login options: (comma separated list of


following options, e.g. "AUTO,USER,ASK")
"AUTO" - Auto login until logout explicitly
"USER" - Save user name
"ASK" - Always ask for user name and
password

String

ChartMenuItems (v4+) Show chart menu items

226

Boolean

PHP Report Maker 9 Help


UseDropDownForExport Use dropdown for export links
(v7+)

Boolean

Custom Scripts Object


The Custom Scripts Object contains the collection of all custom scripts defined in the current
project. Each custom script has the following properties.
Property

Description

Data Type

ScriptType

Script type (Server/Client)

String

ScriptCodeType

Script code type (Global/Table/Other)

String

ScriptName

Script name

String

ScriptCtrlID

Script control id

String

ScriptL1Key

Script level 1 key (table/other name)

String

ScriptL2Key

Script level 2 key (reserved for future use)

String

ScriptCode

Custom script code

String

MenuList Object
The MenuList Object contains the menu items defined in the current project. It has the
following properties.
Property

Description

Data Type

Count

Number of menu items in the menu list

Integer

Item(i)
The ith item in the
Array of menu items
menu, which contains
the following properties

Item Object

MenuID

Menu id

Integer

MenuText

Menu display text

String

MenuParentID

Menu parent id

Integer

MenuGroup (v5+)

Menu group

Boolean

MenuExtUrl

Menu external url (for MenuCustomUrl =


True only)

String

MenuAnonymous (v4+) Menu anonymous access

227

Integer

PHP Report Maker 9 Help


MenuUrl

Menu url

String

MenuType (v4+)

Menu type (Table/Chart)

String

MenuCustomUrl

Menu use custom url

Boolean

MenuLevel

Menu level

Integer

MenuShow

Menu show this item

Boolean

MenuDisplayOrder

Menu display order

Integer

DB Object
The DB Object points to the current database. You can access the current database
properties by DB.PropertyName.
Property

Description

Data Type

DBSeq (v9.0+)

Database sequence

Integer

DBID (v9.0+)

Database id

String

DBName

Database Name

String

DBVar (v8+)

Database variable

String

DBType

Database Type

String

DBPath

Database Type

String

DBPhyPath

Database Physical Path

String

DBUID

User ID

String

DBPwd

Password

String

DBQuoteS

Database Start Quote Character

String

DBQuoteE

Database End Quote Character

String

DBConnstr

DB Connection String

String

DBADOVer

ADO Version

String

DBDBMSName

DBMS Name

String

DBDBMSVer

DBMS Version

String

DBOLEDBVer

OleDb Version

String

DBProviderName

Provider Name

String

228

PHP Report Maker 9 Help


DBProviderVer

Provider Version

String

DBSchema

Schema Name

String

MaxUploadSize

Upload Field maximum upload size

Integer

SecUserLevelFld

User Level Field for Advanced Security

String

SecDefault

Default Security String

String

SecuUserIDFld

User ID Field for Advanced Security

String

SecuParentUserIDFld

Parent User ID Field for Advanced Security String

UseDynamicUserLevel
(v3+)

Use dynamic user level

Boolean

UserLevelTbl (v3+)

User Level Table

String

UserLevelIdFld (v3+)

User Level ID Field

String

UserLevelNameFld (v3+) User Level Name Field

String

UserLevelPrivTbl (v3+)

String

User Level Permission Table

UserLevelPrivTblNameFld
User Level Permission Table Name Field
(v3+)

String

UserLevelPrivUserLevelFld
User Level Permission User Level Field
(v3+)

String

UserLevelPrivPrivFld
(v3+)

String

User Level Permission Permission Field

TABLE Object
The TABLE Object points to the current table. You can access the current table properties by
TABLE.PropertyName.
Property

Description

Data Type

TblSchema (v4+)

Table schema name

String

TblName

Table name

String

TblType

Table type
String
(TABLE/VIEW/CUSTOMVIEW/REPORT/LINKTABLE)

TblKey

Table key

String

TblGen

Generate this table

Boolean

229

PHP Report Maker 9 Help

TblGenList (v4+)

Generation list for table scripts. Format:


info=1,list=0,... (Generate "info" = Yes, Generate String
"list" = No, etc...)

TblList

Show table in menu

Boolean

TblCaption

Table caption

String

TblExtSearchFldPerRow
(v8+)

Extended search fields per row

Integer

TblVar

Table variable name

String

TblDefault

Table link from default page

Boolean

TblFilter

Table filter

String

TblUserIDFld

Table user id field name

String

TblSecurity

Table security settings for advanced security

String

TblOverwrite (deprecated
Overwrite table scripts
in v4+)

Boolean

TblLoaded

Boolean

Table is loaded

TblRptShowSummaryView
Show summary view
(v5+)

Boolean

TblRptShowDetails

Show report details

Boolean

TblRptShowGrandTotal

Show report grand total

Boolean

OutputFolder (v8+)

Custom file output folder

String

IncludeFiles (v8+)

Include common files for custom files

Boolean

TblReportType

Report type:
"rpt" - simple report
"summary" - summary report
"crosstab" - crosstab report

String

TblShowReport

Show report

Boolean

TblRptShowPageTotal

Show report page total

Boolean

TblRowSum

Show report row sum (crosstab only)

Boolean

TblCustomSQL

Table custom sql (custom views only)

String

TblCustomError

Error loading custom views / reports

String

TblRptSrc

Report source table (reports only)

Boolean

TblUseGlobal

Use global settings

Boolean

TblRecPerPage

Groups/records per page

Integer

TblRecPerPageList

Dynamic values for groups/records per page

String

230

PHP Report Maker 9 Help


TblPrinterFriendly (v4+)

Printer friendly

Boolean

TblExportHtml

Export to html

Boolean

TblExportWord

Export to word

Boolean

TblExportExcel

Export to excel

Boolean

TblExportEmail (v4+)

Export to email

Boolean

TblExportPDF (v5+)

Export to PDF

Boolean

TblExportType (v4+)

Export type:
"PAGE" = export current page
"ALL" = export all records

String

TblSortType

Sort type
0 - no sort
1 - single column sort
2 - multi-column sort

Integer

TblPagerStyle

Pager style:
1 - numeric pager
2 - nextprev pager

Integer

TblTopPageLink

Pager on top

Boolean

TblBottomPageLink (v3+) Pager on bottom

Boolean

TblLinkOnLeft

Links on left

Boolean

TblShowBlankListPage

Show blank report page

Boolean

TblUserLevelPriv (v6+)

Use table in dynamic user level security

Boolean

TblUseDropDownForExportUse dropdown for export links


(v7+)

Boolean

TblDashboardType (v7+) Dashboard type (Vertical/Horizontal/Custom) for String


Dashboard Report
LinkDBID (v9.0+)

Link database id (for table type = "LINKTABLE"


only)

LinkTableName (v9.0+)

Linked table name (for table type = "LINKTABLE"


String
only)

LinkTableType (v9.0+)

Linked table type (for table type = "LINKTABLE"


only)

String

CrosstabSummaryFields
(v9.0+)

Crosstab summary field names (separated by


"||")

String

CrosstabSummaryTypes
(v9.0+)

Crosstab summary field types (separated by "||") String

CHART Object

231

String

PHP Report Maker 9 Help


The CHART Object points to the current chart. You can access the current chart properties
by CHART.PropertyName.
Property

Description

Data Type

ChartSeq

Chart ordering sequence

Integer

ChartName

Chart name

String

ChartVar

Chart variable name

String

ShowChart

Show chart in report

Boolean

ChartSourceTable (v7+) Chart source table name (for Dashboard


Report only)

String

ChartSourceChart (v7+) Chart source chart name (for Dashboard


Report only)

String

ChartXFldName

Chart X axis field name

String

ChartYFldName

Chart Y axis field name

String

ChartSeriesYAxis (v4+)

Chart y-axis series ("1" / "2", comma


separated)

String

ChartNameFldName
(v4+)

Chart name field name (candlestick chart


only)

String

ChartSeriesFldName

Chart series field name (multi-series or


stacked charts)

String

ChartSeriesFldOrder
(v4+)

Chart series field order ("ASC" / "DESC")

String

ChartSummaryType
(v3+)

Chart summary type


(SUM/AVG/MIN/MAX/COUNT)

String

ChartType

Chart type:
(Single series)
1 - Column 2D
2 - Pie 2D
3 - Bar 2D
4 - Line 2D
5 - Column 3D
6 - Pie 3D
7 - Area 2D
8 - Dougnut 2D
(Multi series)
9 - Column 2D
10 - Column 3D
11 - Line 2D
12 - Area 2D
13 - Bar 2D
(Stacked)

Integer

232

PHP Report Maker 9 Help


14 - Column 2D
15 - Column 3D
16 - Area 2D
17 - Bar 2D
(Combination)
18 - Column 2D Line Dual Y (v4+)
19 - Column 3D Line Dual Y (v4+)
(Financial)
20 - Candlestick (v4+)
(Other)
21 - Gantt (v4+)
22 - Funnel (v4+)
ChartSeriesType (v4+)

Chart series type ("0" = series field / "1" =


Integer
multiple column fields)

ChartHtml5 (v5+)

Use html 5 chart

Boolean

ChartWidth

Chart width (in pixel)

Integer

ChartHeight

Chart height (in pixel)

Integer

ChartBgColor

Background color

String

ChartCaption

Chart caption

String

ChartChartBgColor

Chart background color

String

ChartChartBorderColor Chart border color

String

ChartNumGridLines

Chart number of gridlines

Integer

ChartGridColor

Chart gridline color

String

ChartXAxisName

Chart X axis name

String

ChartXAxisNameRotatedChart X axis name is rotated

Boolean

ChartYAxisName

Chart Y axis name

String

ChartPYAxisName (v4+)

Chart primary Y axis name (combination


chart only)

String

ChartSYAxisName
(v4+)

Chart secondary Y axis name (combination


String
chart only)

ChartYAxisNameRotated Chart Y axis name is rotated

Boolean

ChartYAxisMinValue

Chart Y axis minimum value

Long

ChartYAxisMaxValue

Chart Y axis maximum value

Long

ChartShowNames

Chart show names (X axis values)

Boolean

ChartShowValues

Chart show values (Y axis values)

Boolean

ChartShowHover

Chart show hover (X,Y values on chart)

Boolean

ChartAlpha

Chart alpha (transparency 0-100)

Integer

233

PHP Report Maker 9 Help

ChartColorPalette

Chart color palette (comma separated color


String
codes)

ChartSortType

Chart sort type:


0 - no sort
1 - X ASC
2 - X DESC
3 - Y ASC
4 - Y DESC
5 - run time

Integer

ChartPosition

Chart position:
1 - top
2 - left
3 - right
4 - bottom

Integer

ChartDrillTable (v6+)

Chart drill down table name

String

ChartDrillSourceFields
(v6+)

Chart drill down source field names


(separated by "||")

String

ChartDrillTargetFields
(v6+)

Chart drill down target field names


(separated by "||")

String

FIELD Object
The FIELD Object points to the current field. You can access the current field properties by
FIELD.PropertyName.
Property

Description

Data Type

FldName

Field name

String

FldAlias

Field alias name

String

FldSourceName

Field source name

String

FldSourceTable

Field source table name

String

FldSourceField

Field source field name

String

FldType

Field data type

Integer

FldTypeName

Field data type name

String

NativeDataType

Field native data type

Integer

FldSQL (v9.0+)

Field SQL (for custom field only)

String

FldIsCustom (v9.0+)

Field is custom field

Boolean

FldSupport

Field is supported

Boolean

234

PHP Report Maker 9 Help


FldSize

Field Size

Integer

FldUniqueIdx

Field has unique index

Boolean

FldZeroLen

Field support zero-length string


(For Access database only)

Boolean

FldReq

Field is required (NOT NULL)

Boolean

FldIsPrimaryKey

Field is primary key

Boolean

FldAutoIncrement

Field is auto increment field

Boolean

FldAttribute

Field ADO attributes

Long

FldMin (v4+)

Minimum value for validation

Variant

FldMax (v4+)

Maximum value for validation

Variant

FldErrMsg (v4+)

Error message if validation failed

String

FldValidate (v4+)

Validate format

String

FldServerValidateArgs (v4+) Validate arguments (server side)

String

FldClientValidateArgs (v4+) Validate arguments (client side)

String

FldPopCalendar

Use popup calendar

Boolean

FldGenerate

Field generate enabled

Boolean

FldList

Field show in report

Boolean

FldSearch

Field allow search (popup filter)

Boolean

FldExtendedBasicSearch

Field allow extended search (extended


filter)

Boolean

FldFilterDropDown

Field is dropdown filter (extended filter)

Boolean

FldDateSearch

Field date search type


- Year
- Quarter
- Month
- Day

String

FldDateSearchDefaultYear

Field date search default year value

String

FldDateSearchDefaultQuarterField date search default quarter value

String

FldDateSearchDefaultMonth Field date search default month value

String

FldDateSearchDefaultDay

String

Field date search default day value

235

PHP Report Maker 9 Help


FldSearchMultiValue (v6+)

Search as comma separated values

Boolean

FldSrchOpr

Field search operator

String

FldSrchOpr2

Field second search operator

String

FldDefault

Field default value for search operator

Variant

FldDefault2 (v4+)

Field default value for second search


operator

Variant

FldDefaultSearch (v5+)

Field default value for poup search

Variant

FldCaption

Field caption

String

FldVar

Field variable

String

FldViewTag

Field view tag

String

FldViewThumbnail (v4+)

Field view as thumbnail

Boolean

FldHtmlTag (v3+)

Field html tag (used for non-TEXT


extended filter)
- "TEXT" (Text box)
- "SELECT" (Drop down)
String
Note: If FldSelectMultiple is enabled, used
as (List box)
- "RADIO" (Radio box)
- "CHECKBOX" (Checkbox)

FldSelectType (v6+)

Field select type ("Table" = auto suggest) String

FldTagLnkOrderType (v6+)

Field lookup order type (ASC/DESC)

String

FldTagAType

Href type

String

FldTagATarget

Href target type (A)

String

FldTagAPrefix

Href prefix (A)

String

FldTagASuffix

Href suffix (A)

String

FldBold

Field bold enabled

Boolean

FldItalic

Field italic enabled

Boolean

FldAlign

Field alignment

String

FldFmtType

Field format type:


"Currency" - format as currency
"Date/Time" - format as Date/Time
"Number" - format as number
"Percent" - format as percent
"String" - format as string

String

236

PHP Report Maker 9 Help

FldDtFormat

Field date format:


See PROJ.DefaultDateFormat for details

Integer

FldNumDigits

Field number of digits after decimal

Integer

FldIncLeadDigit

Field include leading digit

Integer

FldUseParen

Field use parenthesis for negative

Integer

FldGpDigits

Field group digits

Integer

FldHrefFld

Field hyperlink to field

String

FldStrFunc

Field string function

String

FldMemoMaxLength

Maximum length for memo field

Integer

FldSelectFilter (v6+)

Field select filter

String

FldQuoteS

Field start quote character

String

FldQuoteE

Field end quote character

String

FldColumnWidth

Field column width

String

FldColumnWrap

Field column wrap

Boolean

FldGroupByType

Field group by type:


"n" - Normal
"y" - Year (date fields)
"q" - Quarter (date fields)
"m" - Month (date fields)
"w" - Week (date fields)
"d" - Day (date fields)
"h" - Hour (date fields)
"min" - Minute (date fields)
"i" - Interval (numeric fields)
"f" - First few characters (string fields)

String

FldGroupByInterval

Field group by interval (valid for group by


Long
type = "i" & "f" only)

FldRowID

Field row index (crosstab report only)

FldColumnID

Field column index (crosstab report only) Integer

FldColumnDateType

Field column date type: (column field is


date only)
"y" - Year
"q" - Quarter
"m" - Month
"d" - Date

String

FldColumnDateSelect

Field column date with selectable year

Boolean

237

Integer

PHP Report Maker 9 Help

FldSummaryID

Field summary index (crosstab report


only)

Integer

FldSummaryType

Field summary type:


"AVG" - Average
"COUNT" - Count
"MAX" - Maximum
"MIN" - Minimum
"SUM" - Sum

String

FldFilterName

Field filter name (relative filter names,


comma separated)

String

FldUseRange

Field use range (use range selection in


popup filter)

Boolean

FldGroupBy

Field grouping sequence

Integer

FldGroupByShowSummary

Field grouping show summary (report


only)

Boolean

FldOrderBy

Field ordering sequence

Integer

FldOrder

Field order type (ASC/DESC)

String

FldRptAggSum

Aggregate sum of field

Boolean

FldRptAggAvg

Aggregate average of field

Boolean

FldRptAggMin

Aggregate minimum of field

Boolean

FldRptAggMax

Aggregate maximum of field

Boolean

FldRptAggCnt (v6+)

Aggregate count of field

Boolean

FldRptSkipNull (v6+)

Skip null values

Boolean

FldRepeatColumns (v4+)

Repeat column count for radios and


checkboxes

Integer

FldUploadPath (v4+)

Field level upload file path

String

FldResizeQuality (v4+)

Resize file quality

Integer

FldSelectForceSelection
(v6+)

Force selection for auto suggest

Boolean

FldMemoCRLFReplace

Replace CRLF with BR for memo field

Boolean

FldViewTemplate (v7+)

Field custom view template

String

FldDrillParameter (v6+)

Field is drill down parameter

Boolean

FldDrillTable (v6+)

Field drill down table

String

238

PHP Report Maker 9 Help

FldDrillSourceFields (v6+)

Field drill down source fields (separated


by "||")

String

FldDrillTargetFields (v6+)

Field drill down target fields (separated


by "||")

String

FldOptionTemplate (v9.0+)

Optional template for auto fill/auto


suggest

String

FldDropdown (v9.0+)

Use bootstrap dropdown for field

Boolean

FldDropdownWidth (v9.0+) Dropdown width

Integer

FldDropdownHeight (v9.0+) Dropdown height

Integer

LANGUAGE Object
Method

Description

Data Type

Phrase (deprecated in
v4+)

Method to retrieve a phrase in the language


String
file

Method to get language file id based on


language id. For example, With the
language id "english" and the language file
header as follow:
LANGUAGE.GetFileId(id)
<ew-language date="2014/10/02"
String
(v4+)
version="8.0.0" id="en" name="English"
desc="English" author="e.World Technology
Ltd.">
The method will return "en".
Language phrases are returned from the run time PHP codes <?php echo
$ReportLanguage->Phrase("<phrase>") ?>. Please refer to the description on
Note

"Language Block" in section "Template Tags" for more details.

PROJ.LINKDBS Object
The PROJ.LINKDBS Object contains the collection of all link databases defined in the current
project. The object can be accessed via PROJ.LINKDBS as follows.

for (var i = 1, len = PROJ.LINKDBS.Count(); i <= len; i++)


var db = PROJ.LINKDBS.Seq(i);
Each link database has the same properties as the DB object above.

1.16.4 Using User Code


To provide full code generation flexibility. It is allowed to override an existing code
generating function or create your own custom code generating function to suit your needs.
To do this you need to write your JavaScript functions and place them in the User Code File
for the changes to take effect.

239

PHP Report Maker 9 Help


By default, the User Code File is named as "usercode.js" and can be found under the "src"
subfolder of the installed directory. However, you can rename it or put it elsewhere if
necessary. In that case, you need to modify the following registry key:

HKEY_CURRENT_USER\Software\<product name>\<version>\Settings\General
Value name: UserCode
Using User Code requires knowledge in JavaScript. If you are not familiar with the
scripting language, refer to the JavaScript Fundamentals and JavaScript Reference. In most
cases you only need to use the most basic string functions.
Note

I. Overriding System Function


In the User Code File, you can override virtually all exposed functions. Refer to the System
Functions(See 1.16.2) list for functions that you can override.
Although there are many system functions, in real applications you usually only need to
customize a few of them, for example,
Script_View - This function generates code to render the fields in list, view and delete
pages.
Script_Edit - This function generates insert/update codes for the fields in add/copy and edit
pages.
FieldView - This function outputs code for displaying the field in list, view and delete pages.
FieldEdit - This function outputs code for the field as form elements in add/copy, edit and
search pages.
In general, you compare the generated codes with the corresponding page in the template,
find out which tag generate the codes you want to customize. Then you can call the replace
or concat method of the system function in the User Code File. Both mehtod is same as the
JavaScript replace and concat methods.

SYSTEMFUNCTIONS.<Function>.replace("original code", "your code");


SYSTEMFUNCTIONS.<Function>.concat("your code 1", "your code 2", ...);

where <Function> is the system function name.


Follow the following steps to override a system function. For example, if you want to
override the function FieldView,
Step 1 - View the original code first, make sure the codes you want to replace is indeed
generated by the function.
Example

SYSTEMFUNCTIONS.FieldView.modifiers.push(function() {
alert(this.result); // View the old value
});

Step 2 - Generate scripts, view the generated code, copy the code you want to replace,
modify it as you need.
Step 3 - Replace it.

240

PHP Report Maker 9 Help


Example 1 - Directly replace part of the code

SYSTEMFUNCTIONS.FieldView.replace(<old_code>, "new_code"); // Replace


part of the code
<old_code> can be a string or regular expression.
Example 2 - Find the part of code to be replaced and then modify and replace it

var OriginalCode = SYSTEMFUNCTIONS.FieldView.result;


var StartPos = OriginalCode.indexOf("start_code"); // Find the start
position of the old code
var EndPos = OriginalCode.indexOf("end_code", StartPos); // Find the
end position of the old code
if (StartPos > -1 && EndPos > -1 && EndPos > StartPos) { // Found
var OldCode = OriginalCode.substring(StartPos, EndPos +
"end_code".length); // Extract the code starting with "start_code" and
ends with "end_code"
var NewCode = ...OldCode...; // Write your code to modify the old
code as you need
SYSTEMFUNCTIONS.FieldView.replace(OldCode, NewCode); // Replace
the old code
}
Example 3 - Append your code to the end of the original code

SYSTEMFUNCTIONS.<function>.concat("<code_1>", "<code_2>", ...);


Example 4 - Use your own function to modify the code. Add your function to the System
Function's modifiers which is an array of functions, you can add as many modifier functions
as you need.

SYSTEMFUNCTIONS.FieldView.modifiers.push(function() {
var oldvalue = this.result; // Get old value
alert(oldvalue); // View the old value
var newvalue = <your code here>; // Modify the oldvalue or write
your own code
this.result = newvalue; // Overwrite value
});

II. User functions used in Extensions


The user functions used in Extensions must take the following form:

var <Ext> = {
FieldEdit_Prefix: function(ctl, ctlid) {
return "...";
}
FieldEdit_Suffix: function(ctl, ctlid) {
return "...";
}
}

241

PHP Report Maker 9 Help


It is a user object with name <Ext> which should be the same as the extension name. It
contains two methods "FieldEdit_Prefix" and "FieldEdit_Suffix". The "FieldEdit_Prefix"
method returns a prefix value which is appended to the start of the output from the
"FieldEdit" system function. Similarly, the "FieldEdit_Suffix" method returns a suffix value
which is appended to the end of the output from the "FieldEdit" system function. Both
methods take on a parameter "ctl" which contains the name of the field control to be
created. The parameter "ctlid" contains an ID which denotes the mode of the control, e.g.
"add", "edit", etc.. (See usercode.js in the "jscalendar" and "fckeditor" extensions as
examples.)

Also See:
Customizing Template
(See 1.16)Template Tags(See 1.16.5)
Object Properties(See 1.16.3)
System Functions(See 1.16.2)

1.16.5 Template Tags


The code generator processes the following template tags inside the templates to generate
the working codes, intermediate or advanced users can make use of these tags to create
custom templates. These tags are case-insensitive. All template tags have the same basic
syntax:
Syntax:
<!--##...##-->
Due to the HTML comment style format, these script blocks will be treated as HTML
comments in any editors. Therefore, you can use your favorite editor to edit the template
provided that these special tags are kept in place.
It is important to understand how templates tags works. During code generation, the code
generator reads the template file, executes the scripts in the template tags, and finally,
write the codes to the output file.

1. Session Tags
Syntax:
<!--##session session_name##-->
...session content here...
<!--##/session##-->
Note

1. The keyword "session" is immediately after the start tag <!--##,


2. The session_name is the name of the session, only alphanumerical characters should
be used, no spaces, and it is not quoted,
3. The tags must be in pairs, with a start session tag and an end session tag,
4. The end session tags contain a "/" immediately after the tag, i.e. <!--##/.
The code generator locates the source of a output file according to the sequence of sessions
specified in the control.xml of the template. Each session tag carries a session name that
identifies the lines of code that will be extracted.

242

PHP Report Maker 9 Help

2. Script Block
To generate codes according to the project settings, there are many script blocks in each
session. Each script block is enclosed by special start and end tags.
Syntax:
<!--##
...Script here...
##-->
The scripting language used in the script block is JScript provided by Windows Script. To
customize template, you need to know JScript.
In a script block, you can create variables and constants, use conditional statements, do
looping, write procedures, etc. You can also access all settings in the project within the
script block. (See Object Properties(See 1.16.3) for details.) With script blocks, you can
generate virtually any codes you want.
Example

<!--## if (TABLE.TblType == "VIEW") { ##-->


...code here...
<!--# } ##-->
In this example the codes in between will only be generated if the table is a view. "TABLE" is
a template object and "TblType" is one of its properties.

3. Function Block
Function block output an object property as string or output a string return by a function.
Syntax:
<!--##=...##-->
Note the "=" symbol immediately after the start tag.
The function can be a built-in system function or an user function defined in user code file
(see Using User Code(See 1.16.4)). You can refer to the System Functions(See 1.16.2) list
for functions that you can call or override.

Format
Syntax:
<!--##=Object.Property##-->
Example 1 - Accessing object property

<!--##=PROJ.ProjName##-->
This line will write the project name in the output file.
Example 2 - Calling a function

243

PHP Report Maker 9 Help


<!--##
// This is a script block
function MyFunction() {
return "This is my custom function";
}
##-->
<!--##=MyFunction()##-->
This line calls the function "MyFunction" and write the string returned by the function in the
output file. In real cases, the returned string is the code you want to generate.

4. Function Block with Indentation


Syntax:
<!--##~...##-->
Note the "~" symbol immediately after the start tag. This function is same as function block
above except that output block will be indented with the space before the block.

Also See:
Template Object Propeties(See 1.16.3)
System Functions(See 1.16.2)
Using User Code(See 1.16.4)

1.17 Tutorials

Advanced Security - User ID Security(See 1.17.2)


Advanced Security - Static User Level Security(See 1.17.3)
Advanced Security - Dynamic User Level Security(See 1.17.4)
Custom View(See 1.17.5)
Detail and Summary Report(See 1.17.6)
Crosstab Report(See 1.17.7)
Drill Down Report(See 1.17.8)
Chart(See 1.17.11)
Gantt Chart(See 1.17.12)
Dashboard Report(See 1.17.9)
Custom Template(See 1.17.10)
Compatibility Properties - Integrating with existing PHP Report Maker project(See
1.17.13)

1.17.1 Connecting Remote MySQL using PHPMaker


Connection Script
In this tutorial we will show you how to use the new connection method which can connect
to any remote database using a PHP script provided by PHP Report Maker.

Steps to Setup Remote Connection

244

PHP Report Maker 9 Help


1. Uploading the PHP script to your site
The connection is named phpmaker.php and can be found under the installation folder,
e.g. C:\Program Files\PHP Report Maker <version>. Upload the script to site first.
Always use the script shipped with your version of PHP Report Maker. PHP Report Maker
may not work with script shipped with previous versions.
Note

2. Testing the script


If this is the first time to use this connection method, you may want to test the script and
get to understand how it works. You don't need to test the script as described in this step
next time. Instead, you can simply press the [Test] button in PHP Report Maker to test the
script after entering the URL.
a.

Browse to the script using your browser

b.
Enter the connection information, click [Get Database List], a combobox populated
with the available databases should be shown. Select the Database you want to connect,
click [View Schema]

245

PHP Report Maker 9 Help

c.
If you can view the schema of database in XML like the follows, the script is working
properly. PHP Report Maker will talk to this script similarly and get the database schema
over HTTP.

3. Loading PHP Report Maker


Open PHP Report Maker, enter the connection information, URL of the script and encoding if
necessary.

246

PHP Report Maker 9 Help


Note that you are actually connecting to your database through the PHP script on the server,
so in most cases the host/server name is "localhost" unless the database server is not
installed on the same server as the Web server.
Click the dropdown button of database combobox, you should be able to see the available
database. Select your database, click the [Connect] button. The database info should be
loaded and displayed in the left pane.

Using file URL


If for some reason you cannot get the database schema using HTTP, you can also save the
schema in your browser (Step 3.c. above) as a local .xml file and enter the file URL, e.g.
"file://C:\phpmaker.xml", to connect.

1.17.2 Advanced Security - User ID Security


In this tutorial we will show you how to setup User ID Advanced Security Access in PHP
Report Maker. We will use the demo database for demonstration.
User ID
User ID Security secures data at record level. Protected tables must have an User ID field
for identifying which user a record belongs to. The User ID field names can be different in
tables though. When User ID security is enabled, users can only access their own data.
The "Employees" table and "Orders" table in the demo.mdb will be used in this example.
Fields in Table "Employees"

247

PHP Report Maker 9 Help

Fields in Table "Orders"

Steps to Setup Advanced Security


1. Loading PHP Report Maker

248

PHP Report Maker 9 Help


Open PHP Report Maker and connect to the demo database. Open PHP Report Maker and
connect to the demo database. Note that the tables and views are not selected by default,
these tables and views are the source tables of your reports. However, to demonstrate the
User ID Security, we use these tables directly in this tutorial for simplicity. The setup for
Detail and Summary Report(See 1.11.11) and Crosstab Report(See 1.11.12) is exactly the
same.
In the database pane, check the "Orders" table to generate a simple report for it.
(Alternatively, you can also select tables in the [Generate] column of the Table Setup(See
1.11.6) page.)
In the Field Setup page on the right hand side. In the [Filter] column, check the checkbox
for the field "EmployeeID" to create a filter for this field in the report.

2. Setting up Security
Click on the [Security] tab, there are two sections for the login process:
Administrator Login
If you tick this option, a hard-coded Administrator account will be generated which has all
access right to all tables/views.
Use Existing Table
Tick this option to set up the user access levels. You should select the security table and the
corresponding Login Name and Password fields.

249

PHP Report Maker 9 Help

To set up the user ID, click on the [Advanced] button. A popup window will appear.
3. Setting up User ID Field
You can set up the [User ID] Field and [Parent User ID] as follow:

As the caption suggests, the User ID Field is a field to identify users. The field values for
each user must be unique. So typically the primary key of the User Table is used as User ID
Field.
To identify the records owned by a user, the records must also have a field to store the User
ID value. Therefore, all protected tables must have an User ID field, the field names can be

250

PHP Report Maker 9 Help


different though. To setup User Data for different tables/views, select the "User ID Field" for
the tables/views that requires User ID security.
a. Click on User ID in the left pane,
b. Select the User ID field from your user table, (otherwise the feature is disabled)
c. In the User ID Field column, select the User ID Field for the tables/views that requires
User ID security.
[Parent User ID] field stores the parent User ID that the user belongs to. For example, a
parent user can be the manager that the employee reports to. You can select an Parent User
ID for users so the parent user can modify the child users' records as his/her own.
(otherwise the feature is disabled)
Parent User ID is hierarchical, parent users can access the records owned by the child
users of their child users, and there is no limit of levels.
Note

In this example, we set the Parent User ID Field as the "ReportsTo" field.
4. PHP Script Generation
Click the [Generate] button and PHP Report Maker will generate the required PHP scripts
automatically.
5. Running the PHP Application
Login as employee #1 using "nancy" and user name and "1234" as password. Go to the
"Orders" table. As we have used User ID security for the table, we can only access employee
#1 (nancy)'s records.

If you now log out and login again as employee #3 using "janet" as user name and "1234"
as password, you can only access employee #3 (janet)'s records:

251

PHP Report Maker 9 Help

But if you now lo gout and login again as employee #2 using "andrew" as user name and
"1234" as password, you can only access employee #1(nancy), #3 (janet), #4(margaret),
#5(steven) and #8(laura)'s records because "andrew" is the parent user of them, all these
users report to "andrew".

If you click the popup filter button


user(s) and/or your own.

in the header, you can filter the records for your child

252

PHP Report Maker 9 Help

Notes

1. Only Administrator can manage User ID and Parent User ID.


2. There are two types of Advanced Security - User ID Security and User Level
Security. User ID Security secures data at record level and User Level Security
secures data at table level. They can work independently or work together. See the
following tutorials on User Level Security also.

Also see:
Advanced Security - User Level Security(See 1.17.3)

1.17.3 Advanced Security - Static User Level Security


In this tutorial we will show you how to setup static User Level Security in PHP Report
Maker. We will use the demo database for demonstration.
User Level
User Level Security secures data at table level. Each user level is granted with specific
permissions to tables in the database. Users with different access levels are restricted with
different rights.
Note: User Levels and the permissions are defined in the project. If you change them
settings after script generation, you'll need to modify the generated script or re-generate the
scripts again.
The "Employees" table and "Orders" table in the demo.mdb will be used in this example.
Fields in Table "Employees"

253

PHP Report Maker 9 Help

Fields in Table "Orders"

Steps to Setup Static User level Security


1. Loading PHP Report Maker

254

PHP Report Maker 9 Help


Open PHP Report Maker and connect to the demo database. Note that the tables and views
are not selected by default, these tables and views are the source tables of your reports.
However, to demonstrate the User Level Security, we use these tables directly in this tutorial
for simplicity. The setup for Detail and Summary Report(See 1.11.11) and Crosstab
Report(See 1.11.12) is exactly the same.
In the database pane, check the "Orders" table and some other tables to generate simple
reports for them. (Alternatively, you can also select tables in the [Generate] column of the
Table Setup(See 1.11.6) page.)
2. Setting up User Levels
Click on the [Security] tab, there are two sections for the login process:
Administrator Login
If you tick this option, a hard-coded Administrator account will be generated which has all
access right to all tables/views.
Use Existing Table
Tick this option to set up the user access levels. You should select the security table and the
corresponding Login Name and Password fields.

To set up the user levels, click on the [Advanced] button. A popup window will appear.
Click on the [User Levels] button. Select the User Level Field.
The User Level field must be of integer data type. Non integer fields will not be
seen in the User Level Field combobox.
Important

There are three built-in user levels:


Anonymous - Anonymous user level is a built-in user level for the anonymous user (i.e.
users that have not logged in). The User Level ID of the anonymous user is -2.

255

PHP Report Maker 9 Help


Administrator - Administrator user level is a built-in user level that has all permissions plus
the privileges to modify User IDs and User Levels. Its permissions are same as that of the
hard-coded Administrator. The User Level ID of Administrator is -1.
Default - Default user level is built-in user level with user level = 0. Since User Level field is
an integer field, if you set a default value of 0 for this field, this user level will become the
default user level for the user after registration and before the Administrator assigning
another higher user level.

Click
finish.

to add a new user level. Enter the description, and default permissions. Click OK to

For each user level, you can set refine the permission for different tables/views. Click OK to
finish.

256

PHP Report Maker 9 Help

3. PHP Script Generation


Click the [Generate] button and PHP Report Maker will generate the required PHP scripts
automatically.
4. Running the PHP Application
To see the Advanced Security works, we login using "andrew" as user name and "1234" as
password. The user is of "Manager" user level. In the menu, you'll see that you can access
all allowed reports.

Now we logout and then login again as employee #1 using "nancy" as user name and "1234"
as password.
According to the user level defined by us, users with "Sales" user level has view permission
to the "Orders" table only. In the menu, you'll see no links to other reports.

257

PHP Report Maker 9 Help

If you try to go to other reports by typing the URL directly in your browser, you're not
allowed to view it and you'll be redirected back to a report that you have permission.

There are two types of Advanced Security implemented in PHP Report Maker - User ID
Security and User Level Security. User ID Security secures data at record level; User Level
Security secures data at table level. They can work independently or work together. (See
Advanced Security - User ID Security) (See 1.17.2)
Note

Also See:
Advanced Security - User ID Security(See 1.17.4)
Advanced Security - Dynamic User Level Security(See 1.17.4)

1.17.4 Advanced Security - Dynamic User Level Security


In this tutorial we will show you how to setup User Level Security. We will use the demo
database for demonstration.
User Level
User Level Security secures data at table level. Each user level is granted with specific
permissions to tables in the database. Users with different access levels are restricted with
different add/copy, list/search/view, delete and edit rights.
There are 2 types of User Level security:
1. Static User Levels - the User Levels and the permissions are defined in the project and
the User Levels are not to be changed after script generation.
2. Dynamic User Levels - the User Levels and the permissions are defined in 2 tables in
the database, the User Levels can still be changed with the generated scripts.
In this tutorial we use dynamic User Level Security.
The "Employees" table and "Orders" table in the demo will be used in this example.
Fields in Table "Employees"

258

PHP Report Maker 9 Help

Fields in Table "Orders"

Dynamic User Level Security stores the User Level information in the database, so you need
to add 2 tables to your database - User Level Table and User Level Permission Table
which must have the following fields, note the data types, User Level ID and the Permission
fields must be of integer type, the field names can be different though:

259

PHP Report Maker 9 Help

You can create these 2 tables in the database yourself or you can use PHP Report Maker to
create these 2 tables for you, please see below.

Steps to Setup Advanced Security


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Setting up User Levels
Click on the [Security] tab, there are two sections for the login process:
Administrator Login
If you tick this option, a hard-coded Administrator account will be generated which has all
access right to all tables/views.
Use Existing Table
Tick this option to set up the user access levels. You should select the security table and the
corresponding Login Name and Password fields.

260

PHP Report Maker 9 Help


To set up the user levels, click on the [Advanced] button. A popup window will appear.
Click on the [User Levels] button. Select the User Level Field.
The User Level field must be of integer data type. Non integer fields will not be
seen in the User Level Field combobox.
Important

To use dynamic User Levels, switch to the [Dynamic User Levels] and check [Enable
Dynamic User Levels].

If you want PHP Report Maker to create these 2 tables in your database, click the [Create
tables] button, the following form will display for you to change the table/field names if
necessary. You can change the table/field names and then click OK to continue.

261

PHP Report Maker 9 Help

If you have projects created by previous versions of PHP Report Maker you may want to use
dynamic User Levels and migrate the previously defined static User Levels in the project to
the database. After selecting or creating the User Level and User Level Permission
tables/fields, just click the [Migrate] button to let PHP Report Maker do that for you.
You'll need to specify the User Level Table and the User Level Permission Table and the
related fields. (If you use PHP Report Maker to create the tables, PHP Report Maker will set
up the tables/fields automatically also.)
User Level Table - the table for storing the User Levels
User Level ID Field - the ID of an User Level, this field must be integer type
User Level Name Field - the name of an User Level, this field should be string field
A typical User Level Table should contain data like this:

Note that there are two built-in user levels:


Administrator - Administrator is a built-in user level that has all permissions plus the
privileges to modify User IDs and User Levels. Its permissions are same as that of the hardcoded Administrator Login. The User Level ID of Administrator is -1.
Default - Default user level is built-in user level with user level = 0. Since User Level field is
an integer field, if you set a default value of 0 for this field, this user level will become the
default user level for the user after registration and before the Administrator assigning
another higher user level.

262

PHP Report Maker 9 Help


You can add your own User Levels with User Level ID starting from 1.
User Level Permission Table - the table for storing the permission of the User Levels
Table Name Field - the table name of each table in the database, this field should be of
string type
User Level ID Field - the ID of an User Level, this field must be integer type
Permission Field - the permission of the specified User Level ID in the specified table, this
field must be integer type also.
A typical User Level Permission Table should contain data like this:

Click OK to close the Advanced Security Setup form.


PHP Report Maker does not support data modification, it does NOT generate scripts to
update the User Level Table and User Level Permission Table.
Note

3. PHP Script Generation


Click the [Generate] button and PHP Report Maker will generate the required PHP scripts
automatically.
4. Running the PHP Application
To see the Advanced Security works, we login using "andrew" as user name and "1234" as
password. The user is of "Manager" user level. In the menu, you'll see that you can access
all allowed reports.

263

PHP Report Maker 9 Help

Now we logout and then login again as employee #1 using "nancy" as user name and "1234"
as password.
According to the user level defined by us, users with "Sales" user level has view permission
to the "Orders" table only. In the menu, you'll see no links to other reports.

If you try to go to other reports by typing the URL directly in your browser, you're not
allowed to view it and you'll be redirected back to a report that you have permission.

There are two types of Advanced Security - User ID Security and User Level Security.
User ID Security secures data at record level; User Level Security secures data at table
level. They can work independently or work together. (See Advanced Security - User ID
Security) (See 1.17.2)
Note

Also see:
Advanced Security - User ID Security(See 1.17.4)
Advanced Security - Static User Level Security(See 1.17.3)

1.17.5 Custom View


WARNING! Custom View expects simple SELECT statements only, they are NOT designed
to and cannot replace views provided by the database. PHP Report Maker supports creating
database view, you should always use database views whenever available. Views provided
by database allow you to use them more like regular tables. If you use MySQL 5, you should
ALWAYS use MySQL view.
Note

Before reading this tutorial, please read Using Custom View(See 1.11.10) first.

In this tutorial we will show you how to create a Custom View. We will use the demo
database for demonstration.
We will build a SELECT statement which can show the customer's company name, the
product name and total price of an order item. Four tables, "OrderDetails", "Orders",
"Customers" and "Products" table.

264

PHP Report Maker 9 Help


Fields in Table "OrderDetails".

Fields in Table "Orders".

Fields in Table "Customers".

Fields in Table "Products".

265

PHP Report Maker 9 Help

Steps to Setup Custom View


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Creating the Custom View
Right click [Custom Views] in database pane and select [Add Custom View], or click
[Edit] in the main menu and then select [Add Custom View].
The Custom View Setup window will show up:

Build the SELECT statement as follows:


1. Drag "Customers", "Orders", "OrderDetails" and "Product" tables from table pane
into builder area,
2. Create the joins, always start from the main table. In this case, the main table is
"Order Details", others are just lookup tables. (We join Orders and then Customers
table to lookup the CompanyName, and join the Products table to lookup the
ProductName.) So we drag [Order Details].OrderID to Orders.OrderID, and [Order
Details].ProductID to Products.ProductID, then drag Orders.CustomerID to
Customers.CustomerID,
3. Check the required fields.

266

PHP Report Maker 9 Help

Click [SQL] tab and edit the SELECT statement in the SQL editor directly, add a calculated
field in the SELECT clause:

orderdetails.UnitPrice * orderdetails.Quantity * (1 orderdetails.Discount) AS `Extended Price`

Change the name of the custom view from the temporary name "CustomView1" to that you
want, in this example, we use "Order Details Extended".
On the toolbar, there is a checkbox labelled [Copy field settings from source table
(when applicable)]. We keep this checked so the Field level setup (e.g. View Tag settings)
will be copied from the field's source table.
Click [OK] to finish. The custom view is added under [Custom Views] in database pane.
Select the Custom View in the database pane to generate scripts for it.

267

PHP Report Maker 9 Help

Format the field as follows:

Select the
[Format]
Select the
Select the
[Format]

field "Unit Price", in the [View Tag] panel, select "Currency" for
and then change the [No. of digits after decimal] to "2".
field "Discount", in the [View Tag] panel, select "Percent".
field "Extended Price", in the [View Tag] panel, select "Currency" for
and then change the [No. of digits after decimal] to "2".

3. PHP Script Generation


Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Run the scripts, click the "Reports" button and select "Order Details Extended" to see the
result.

268

PHP Report Maker 9 Help

1.17.6 Detail and Summary Report


Before reading this tutorial, please read Detail and Summary Report Setup(See
1.11.11) first.
Note

In this tutorial we will show you how to create a Detail and Summary Report in PHP Report
Maker. We will use the demo database for demonstration.
We will use the view "order_details_extended" to create a report which shows the order
items in orders of each customer:

Note that there is a calculated field:

269

PHP Report Maker 9 Help

Steps to Create the Report


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Adding a report
Right click [Reports] on the database pane then click [Add Report (Detail/Summary)],
or click [Edit] in the main menu and then select [Add Report (Detail/Summary)].
The Report Setup window will show up, enter the report name, for example, we use "Sales
by Customer". Select the view "Order Details extended" as source table. Select the required
fields for the report (not necessarily all fields). In this example, we select all the field by
clicking the [>>] button.

270

PHP Report Maker 9 Help

Click the [Grouping Levels] tab, since we want to group the order items by company and
then by order, we select "CompanyName" and then "OrderID" as grouping level. (If you
want to sort in group-level fields in descending order, click the button next to the field to
switch the order.)
Check [Show summary] for both levels (the [Summary Values] tabs become visible).

271

PHP Report Maker 9 Help

Click the [Sort Order] tab, since we want to sort the order items by product name, we
select "ProductName" as sorting field. (If you want to sort in descending order, click the
button next to the field to switch the order.)

272

PHP Report Maker 9 Help

Now click the [Summary Values] tab. We want to see total price and average quantity of
order item in an order, so we check [Avg] for the field "Quantity" and check [Sum] for the
field "Extended Price".
We want to see details of each order item, so we use the default option [Details and
summary]. We also leave [Show grand summary] checked as default because we want
to know the total price and average quantity of order item for all orders.

273

PHP Report Maker 9 Help

If you want to show summary only (that is, only show the grouping fields and summary
values), you can select [Summary only] and [Show compact summary view].
Click [OK] to finish.
The report will be added in database pane. Click the report to go to the Field Setup page,
you can optionally enable filters for some fields in the [Filter] column.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Browse the generated site, go to the "Sales by Customer" report to see the result.
Summary values are shown at the end of each level. The grand summary is also shown at
the end of report.

274

PHP Report Maker 9 Help

In step 2 above, if you have selected [Summary only] and [Show compact summary
view], the compact report will only show the grouping fields and summary values:

275

PHP Report Maker 9 Help

Also See
Tutorial - Drill Down Report (See 1.17.8)

1.17.7 Crosstab Report


Note

Before reading this tutorial, please read Crosstab Report Setup(See 1.11.12) first.

In this tutorial we will show you how to create a Crosstab Report in PHP Report Maker. We
will use the demo database for demonstration.
As explained in Preparing Your Data for Reports(See 1.9), PHP Report Maker can create a
report query from a single table, but an individual table may not contains data suitable as
the data source for a crosstab query. If you need more than one table to get the result you
want, which is almost always the case, you must design a view (MySQL 5) specifically for
crosstab presentation.
In this example, we use the view "orders by products" to generate a crosstab report that
shows quarterly sales by product for different years.

276

PHP Report Maker 9 Help

Steps to Create the Report


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Adding a report
Right click [Reports] on the database pane then click [Add Report (Crosstab)], or click
[Edit] in the main menu and then select [Add Report (Crosstab)].
The Crosstab Report Setup form will show up, enter the report name, for example, we use
"Quarterly Orders by Product". Select the View "Orders By Products" as source table.

277

PHP Report Maker 9 Help

Click the [Row Headings] tab, since we want to group the order items by category name
and then by product name, we select "CategoryName" and then "ProductName" as row
headings. We also want to see the summary for each category so we check the [Show
summary] checkbox for the field "CategoryName".

278

PHP Report Maker 9 Help

Click the [Column Headings] tab, since we show the order date (quarterly) as column
headings, we select "OrderDate" as [Field] and select "Quarter" as [Interval].
When we prepare the data by creating the view, we can filter the orders to a particular year
by using a WHERE clause, in that case, the report will be for that particular year only.
In this example, however, we did not filter the data in the view, the data includes orders for
more than one years. If your group by "Quarter", orders in the same quarter but different
years will be grouped together. That is usually not what you want, so we enable the [Year
filter] feature, PHP Report Maker can create a combobox of the years according to the data
and display data for a year at a time.
The [Year filter] option is only available if the row heading field is of date/time type,
and the [Grouping Interval] is Quarter or Month.
Note

279

PHP Report Maker 9 Help

Now click the [Value] tab. We want to see the total order amount by product, so we select
"Amount" as the [Field] and select "SUM" as [Summary value].
Click [Include row sums] to let the report calculation sum of the each row, that is, the
total amount of the quarters.
Since there are quite a few products, the report will not be displayed in one single page
(depends on the [Record per page] setting), we select [Show page summary] to make
the report show the summary of the orders displayed in the current page only. Moreover, we
check [Show grand summary] so we'll always see the summary of all orders too.

280

PHP Report Maker 9 Help

Click [OK] to finish.


The report will be added in database pane. Field level setup will be copied from the source
table.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Browse the generated site, click "Quarterly Orders by Product" in the menu to run the
report. Note that:

A column is added automatically to show the row sums.


The page and grand summary are also shown at the end of report.
The year combobox above the report. You can change it to view report for other
years.

281

PHP Report Maker 9 Help

Also See
Tutorial - Drill Down Report (See 1.17.8)

282

PHP Report Maker 9 Help

1.17.8 Drill Down Report


In this tutorial we will show you how to create a Drill Down Report in PHP Report Maker. We
will use the demo database for demonstration.
We will continue to use the detail and summary report created in Tutorial - Detail and
Summary Report(See 1.17.6). If you have not yet created the detail and summary report,
refer to the tutorial and create it first. We use the compact report:

Above report does not show the order details in each order. Now we create a detail report so
user can click the sum of Extended Price (the last column) to see the order details of each
company or each order.

Steps to Create the Report


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Adding a Detail Report (if not already exists)
The detail report can be any report in the project, it can be an existing report or a new
report, as long as the report contains the required data and the required fields as
parameters for filtering.
Note

283

PHP Report Maker 9 Help


In this example, we can simply use the source view "order_details_extended" or even the
report "Sales by Customer" itself as detail report, both contains data we want to show in the
detail report. However, "order_details_extended" does not have grouping fields so we cannot
group the records by order ID. The report "Sales by Customer" itself has an extra grouping
level (Company Name) that we do not need to show in the detail report. So we'll create a
new report as detail report.
Right click [Reports] on the database pane then click [Add Report (Detail/Summary)],
or click [Edit] in the main menu and then select [Add Report (Detail/Summary)].
Following the same steps in Tutorial - Detail and Summary Report(See 1.17.6), name it as
"Sales by Order".

Note that this time we only use one grouping level as we do not need to show the company
name:

284

PHP Report Maker 9 Help

285

PHP Report Maker 9 Help


We want to see details of each order item, so check [Details and summary]. We also
enable [Show grand summary] because we want to know the total price and average
quantity of order item for all orders.

Click [OK] to finish.


3. PHP Script Generation
Now click the main report in database pane to select it, the fields will be shown in the right
pane. Select the "Extended Price" field (for which we want to create the hyperlinks to r drill
down), scroll to right and find the [Detail Report] column under [Drill Down] section:

286

PHP Report Maker 9 Help

click the [...] button to open the Drill Down setup form, select the just created report "Sales
by Order" as detail report. To enable the detail report to show order details, we need to pass
the "CompnayName" and "OrderID" field values from the main report to the detail report, so
we map the field as follows:

The field names of source field and target fields can be different, but they must contain
the same set of field values so records in the detail table can be properly filtered.
Note

Click [OK] to finish.

287

PHP Report Maker 9 Help


If you now click the detail report and inspect the [Parameter] column, you'll see that PHP
Report Maker has setup the target fields as parameters:

4. PHP Script Generation


Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
5. Running the PHP Application
Browse the generated site, go to "Sales by Customer" report to see the result. Note that
now the "Extended Price (SUM)" values are colored (with hyperlinks):

288

PHP Report Maker 9 Help

Click the "Extended Price (SUM)" for each Order ID, you'll see the order details:

Click the "Extended Price (SUM)" for each customer, you'll see the order details of each
order of the customer:

289

PHP Report Maker 9 Help

Click the Grand Total of "Extended Price (SUM)", you'll see all the order details:

Drill Down Advanced Settings


Note that there are 2 advanced settings(See 1.14) for drill down:
Use popup panel for drill down - Use a popup panel to show the detail report in the same
page. If disabled, user will be redirected to the detail report directly after clicking the drill
down link. If enabled, the detail report will be displayed in a popup panel by default, if you
want to go to the detail report directly (not in popup panel), press Ctrl key and click the link.
Note that charts does not support Ctrl-click.
Show drill down filters - Show current drill down filters in the detail report.

Drill Down for Charts

290

PHP Report Maker 9 Help


You can also drill down the chart values (Y Axis) by setting up a detail report, see Chart
Setup(See 1.11.8). Setting up of detail report for chart is exactly same as setting up detail
report for reports.
For example, we add a chart for the crosstab report Quarterly Orders by Product we
created in the tutorial Tutorial - Crosstab Report(See 1.17.7) as following:

The generated chart will be like:

291

PHP Report Maker 9 Help

Now we create another chart as a drill down chart. We can reuse the underlying view of the
report, that is the view orders_by_product, we create a chart for it as the following:

292

PHP Report Maker 9 Help


To drill down to the chart only without showing the tabular report, we disable the Show
Report option for the view, see Table Setup(See 1.11.6).
Then we can go back to the Chart Setup page for the crosstab report Quarterly Orders by
Product to setup the drill down, click the "..." button of the Detail report row:

The Drill Down setup form will be displayed. We select the view orders_by_product as
detail report and we pass the Category (X) Axis value, in this example, category name, to
the detail report:

293

PHP Report Maker 9 Help

Generate scripts again, click the bars in the chart under the crosstab report Quarterly
Orders by Product and you'll see the drill down chart:

1.17.9 Dashboard Report


Note

Before reading this tutorial, please read Dashboard Report Setup(See 1.11.13) first.

A Dashboard report allows you select any charts you have created in your project and show
them in one single Dashboard report page, with links back to the original reports. Using this
feature, you can enable users of your system to quickly understand the key indicators of
your system with the visually rich charts.

294

PHP Report Maker 9 Help


In this tutorial we will show you how to create a Dashboard Report in PHP Report Maker. We
will use the demo project for demonstration.
We will use the column 2D chart created in Tutorial - Chart(See 1.17.11) and the Gantt
chart created in Tutorial - Gantt Chart (See 1.17.12) for the example. If you have not yet
created the charts, please follow the respective tutorials and create the charts first.
Steps to Create the Dashboard Report
1. Loading PHP Report Maker
Open PHP Report Maker and then open the demo project.
2. Adding the Dashboard Report
Right click [Reports] on the database pane then click [Add Report (Dashboard)], or click
[Edit] in the main menu and then select [Add Report (Dashboard)].

a.
b.

c.
d.
e.
f.
g.

The Report Setup window will show up, enter the report name, here we will use the
default "Dashboard1".
Then select the report type (Vertical/Horizontal/Custom). If you want to display
the charts in simple vertical and horizontal layout, just choose Vertical or
Horizontal.
In this example, we will use our own custom template, so we choose Custom. Later,
we'll write our custom template.
Here we choose the charts for the Dashboard Report first. In this example, we select
the Dow Jones Industrial Index Chart ("dj1|Chart1") and the Order By Categories
Chart ("Quarterly Orders By Product|OrdersByCategory").
Click [OK] to finish. You should find the new report appears under the Reports
node of the Database pane.
To specify the custom template for the new Dashboard report, Select the Dashboard
report in the Database pane,
Go to the [Code (Server Events, Client Scripts and Templates)] tab on the
right, scroll down to find Custom Template > Table-Specific > Dashboard ->
CustomTemplate,
Enter your custom template in HTML. In this example, we use a simple template:

<div class="chart1">{{{chart1}}}</div>
<div class="chart2">{{{chart2}}}</div>

295

PHP Report Maker 9 Help


{{{chart1}}} and {{{chart2}}} (and so on) denotes the charts you specified
in the Charts setting above. (Note that in these tags there is no spaces between
"chart" and the chart number.) They will be replaced by the actual chart content
during script generation.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Browse the generated site, go to "Dashboard 1" report to see the result.

296

PHP Report Maker 9 Help

Click on the chart to go to the original report where the chart is from.

297

PHP Report Maker 9 Help

1.17.10 Custom Template

Tutorial - Custom Template


You can now use Custom Template to print your reports in your own layout.
Before reading this tutorial, please read Custom Templates(See 1.11.16) and
understand the concept of Custom Template first.
Note

In this tutorial we will show you how to create a Custom Template for exporting an order
from a report. We will use the demo project for demonstration.
The Custom Template support simple or Detail and Summary reports only. We'll create an
export template for a report similar to the Detail and Summary report created in Tutorial Detail and Summary Report(See 1.17.6). Refer to the tutorial to create another view, the
only difference is that we'll show some customer information in the export version, so we
add some more fields from the customers table in the view:

Then we create the same Detail and Summary Report as in above tutorial, we name it as,
say, "Sales By Customers 2". Note that there are 2 grouping fields:

298

PHP Report Maker 9 Help

When you select the fields, you do not need to select above additional fields (ContactName,
ContactTitle, Address, City, Region, PostalCode, Country, and Phone) that you don't
normally show in the report. Alternatively, you can unselect them in the Show column of
Field Setup(See 1.11.7) page after you have created the report.
We also enable Extended Filter for the OrderID so we can select an order from the report
before we export it:

299

PHP Report Maker 9 Help

Steps to Create the Custom Template


1. Loading PHP Report Maker
Open PHP Report Maker and then open the demo project.
2. Adding the Custom Template
Select the "Sales By Customers 2" report, then click the [Code (Server Events, Client
Scripts and Templates)] tab and expand on the [Custom Templates] node. You will see
that there are many different sections for the custom template, as shown in the diagram
below.

300

PHP Report Maker 9 Help

Each template refers to a different part of the report, you can enter your own HTML for
them. (See Custom Template Tags(See 1.11.16) for the meanings of the tags with triple
curly brackets.)
Template Name

Sample codes for this tutorial

CustomTemplateHeader

<p><?php echo date("F j, Y"); ?><p>


<p>
{{:CompanyName}}<br>
{{:Address}}<br>
{{:City}}<br>
{{:Country}}<br>
Attn: {{:ContactName}}
</p>
Since the fields CompanyName, Address, City,
Country, ContactName are not shown in the report, we
cannot use Custom Template Tags to show them.
(Remember that Custom Template is re-arrangement of
existing HTML fragments.) However, the first row of the
report is passed to the template as additional data, we
can make use of it by JsRender tags as above.
Note

CustomTemplateGroupHeader2<p><b>Order Number:</b> {{{OrderID}}} </p>

<table class="ewTable ewExportTable">


<tr>
<td><b>{{{caption ProductName}}}</b></td>
<td><b>{{{caption UnitPrice}}}</b></td>
<td><b>{{{caption Quantity}}}</b></td>
<td><b>{{{caption Discount}}}</b></td>
<td><b>{{{caption Extended_Price}}}</b></td>
</tr>
Note

We use CustomTemplateGroupHeader2 instead of

301

PHP Report Maker 9 Help


CustomTemplateGroupHeader here because we want
to show the sum of Extended Price in the order. And
OrderID is the second grouping field of the report.
CustomTemplateBody

<tr>
<td>{{{ProductName}}}</td>
<td>{{{UnitPrice}}}</td>
<td>{{{Quantity}}}</td>
<td>{{{Discount}}}</td>
<td>{{{Extended_Price}}}</td>
</tr>

CustomTemplateGroupFooter2 <tr>

<td colspan="4"><div style="text-align:


right;"><b>Total</b></div></td>
<td><b>{{{sum Extended_Price}}}</b></td>
</tr>
</table>
We use CustomTemplateGroupFooter2 instead of
CustomTemplateGroupFooter here because we want
to show the sum of Extended Price in the order. And
OrderID is the second grouping field of the report.
Note

CustomTemplateFooter

<br>
<p>Some additional information here.</p>

After entering the sample codes in the corresponding templates above, click [OK] to finish.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Browse the generated site, go to "Sales by Customer 2" report, select an order in the
Extended Filter panel, we'll see:

302

PHP Report Maker 9 Help


Now click Export -> Printer Friendly or Export to PDF to see the result:

1.17.11 Chart
Note

Before reading this tutorial, please read Chart Setup(See 1.11.8) first.

In this tutorial we will show you how to create a chart to present report data in PHP Report
Maker. We'll continue to use the Crosstab Report we created in the Crosstab Report
tutorial(See 1.17.7) and create a chart to show the total order amount by product category.

Steps to Create the Chart


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Adding a Chart
To add a chart to a report, click the report in the database pane on the left, the tabbed Field
Setup page and Chart Setup Page will show up on the right. Click the [Charts] tab to go the
Chart Setup Page.
Click [+] button to add a new chart.
Enter chart [Name] (preferably alphanumerical characters only) as "OrdersByCategory"and
[Caption] as "Orders By Category".
In this example we draw a column chart so we leave the [Chart type] setting unchanged at
the default value - [Column 2D Chart].
Under [Category (X) Axis], select "CategoryName" for the [Category field] setting.
Under [Category (Y) Axis], select "Amount" for the [Value field] setting.
Check [Show labels] so we'll see the category names on the X axis.
Check [Show values] so we'll see the amount at the top of each column.

303

PHP Report Maker 9 Help


Check [Show hover] so we'll see a hovering box displaying the category name and its
amount when we move the mouse over each column.

There are many other advanced chart properties for you to configure the chart, click
[Advanced] tab to setup:
Not all displayed advanced properties are supported by each chart type. Refer to
FusionCharts documentation for list of the supported advanced properties of each chart type.
Note

304

PHP Report Maker 9 Help

In this example, we rotate the category names (rotateLabels) and use slanted labels
(slantLabels) on the X axis so they won't overlap each other.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Click the "Reports" menu button and select "Quarterly Orders by Product" (or select the submenu "Orders By Category") to run the report and see the chart.

305

PHP Report Maker 9 Help

Also See
Tutorial - Drill Down Report (See 1.17.8)

1.17.12 Gantt Chart


Before reading this tutorial, please read Gantt Chart Setup(See 1.11.9) and make sure
you understand what is task, process, category, milestone, connector, etc. first.
Note

In this tutorial we will show you how to create a Gantt chart in PHP Report Maker. We will
use the demo database for demonstration.
In this example we start by creating the simplest Gantt chart from just one table - the task
table. We create the table as follows:

Steps to Setup Gantt Chart


1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.

306

PHP Report Maker 9 Help


2. Creating the Gantt Chart
Right click the database pane or click [Edit] in the main menu bar, select [Add Report
(Gantt)], and enter the follows:

Click [OK] to save the settings.


3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate
the required PHP scripts automatically.
4. Running the PHP Application
Run the scripts, click "Gantt 1" in the menu to see the result.

307

PHP Report Maker 9 Help

Adding Multiple Tasks per Process


In above example we only have one task for each process, so we do not need the process
table. However, there are chances that there are multiple tasks for each process. Then
you'll need to use a process table.
We use another task table (tasks2) as example:

Since we need to define which process a task belongs to, so we need the processId field.
Note that field name MUST be "processId", including the lettercase. In fact, other than the
Task ID, Task name, Start date, End date, From task ID and Milestone date field, all
other field names and lettercase (for example, the color and hoverText field in above
table) must be the same as listed in Gantt Chart Setup(See 1.11.9). The field length for
color fields is 6 only because we DO NOT need to assign a "#" at the beginning of the hex
color code for the color fields.
We create a process table as follows:

308

PHP Report Maker 9 Help

Again, the field names and lettercase (id and name field) must be the same as listed in
Gantt Chart Setup(See 1.11.9).
Then we create another Gantt chart as follows:

Generate and see the result:

309

PHP Report Maker 9 Help

If a process table is used, you can add a data table, which can show tabular information
along side the process names. After selecting the process table, you can click the [...]
button and select up fields from the process table.

Click [OK] to save.

310

PHP Report Maker 9 Help


Increase the width of the chart from 550 to 600 to make room for the extra column.
Note

The field caption of the field in the process table will be used as the column header.

Generate and see the result:

The widths of the columns are auto-adjusted by the chart. However, you can also
explicitly specify them by server event, see example below.
Note

Connectors
Task connectors are used to connect various task bars on the chart, to indicate the flow of
process. Using task connectors, we can show the dependency of one task over another, or
the general flow of the entire set of tasks.
1. Adding a Single Connector per Task
PHP Report Maker supports a singe connector for each task (start from the end of the
specified task and end at the start of the current task) without using a connector table.
Using above example, right the Gantt chart in the database pane, select [Edit Report], and
select the [From Task ID] field as follows:

311

PHP Report Maker 9 Help

The From task ID field contains value of the start task ID from where the connector will
originate.
Generate again and see the result:

312

PHP Report Maker 9 Help

Note the connectors in above chart. Other than the limitation that there can be only one
connector per task, the connectors are also assumed to be joined from the end position of
the start task. If you want more connectors per task or more control on the connectors, you
can use connector table.
2. Adding Multiple Connectors per Task
If you need to use more than one connectors for each task, you'll need to use connector
table. In this example, we create a simple connector table as follows:

Again, the field names and lettercase must be the same as listed in Gantt Chart Setup(See
1.11.9).
Right click the Gantt chart in the database pane, select [Edit Report], and select the new
table as the [Connector table] setting.

313

PHP Report Maker 9 Help

Generate again and see the result:

314

PHP Report Maker 9 Help

Note the differences:


1. There are more than one connectors per task,
2. The connector can start from the start position of the start task,
3. The colors and thickness of the connectors are determined by the respective field in
the connector table.

Milestones
Milestones are important checkpoints or interim goals for a project. You can represent them
using stars, diamonds etc on Gantt Chart.
1. Adding a Single Milestone per Task
PHP Report Maker supports a singe milestone for each task without using a milestone
table.
Using above example, right the Gantt chart in the database pane, select [Edit Report], and
select the [Milestone date] field as follows:

315

PHP Report Maker 9 Help

The milestone date field should be a datetime field containing the date of the milestone.
Generate again and see the result:

316

PHP Report Maker 9 Help

2. Adding Multiple Milestones per Task


If you need to use more than one milestones for each task or need more control on the
milestone properties, you'll need to use milestone table. In this example, we create a
simple milestone table as follows:

Again, the field names and lettercase must be the same as listed in Gantt Chart Setup(See
1.11.9).
Right the Gantt chart in the database pane, select [Edit Report], and select the table as
the [Connector table].

317

PHP Report Maker 9 Help

Generate again and see the result:

318

PHP Report Maker 9 Help

Trendlines
Trendlines can be used to show important dates on the chart - like today or scheduled date
etc. If you need to add trendlines to the chart, you'll need to use a trendline table.
We create a trendline table as follows:

Again, the field names and lettercase must be the same as listed in Gantt Chart Setup(See
1.11.9).
Right the Gantt chart in the database pane, select [Edit Report], and select the table as
the [Trendline table].

319

PHP Report Maker 9 Help

Generate and see the result:

320

PHP Report Maker 9 Help

Customizing Gantt Chart by Server Events


Notes

1. If you are not familiar with server events, please read Server Events and Client
Scripts(See 1.11.15) first.
2. Using server event to customize Gantt chart requires basic to intermediate
knowledge in PHP classes and PHP DOM functions for manipulating XML.
There are 2 server events you can use to customize the chart:
1. Chart_Rendering Event
This event is fired before the chart XML is built. You can still change the chart properties
using this event, the parameters is:
$chart - the chart object instance which contain all the information about the chart to be
rendered. It is an instance of the crGantt class, if you use this event to customize the Gantt
chart, you need to be familiar with the Gantt chart class (crGantt), refer to generated
ganttfn.php for members of the class.
There are various methods in the Gantt chart class you can use to customize the chart,
please refer to the source code of the class crGantt generated in ganttfn.php.
Example - Adding a trendline by code instead of using Trendline table
Note

This example is for Gantt chart only, it is NOT applicable to other chart types.

321

PHP Report Maker 9 Help


// Chart Rendering event
function Chart_Rendering() {
// var_dump($this);
// Adjust the width of the process name column
$this->ProcessesAttrs['width'] = 150;
// Dates must be in yyyy-mm-dd format
$this->AddTrendline(array('start'=>'2011-03-12',
'displayValue'=>'MyTrendline', 'color'=>'0000FF', 'thickness'=>'1'));
}
2. Chart_Rendered Event
This event is fired after the chart XML is built and before the XML is outputted. You can
customize the XML using this event, the parameters is:
$chart - the chart object instance which contain all the information about the chart to be
rendered. It is an instance of the crGantt class, refer to generated ganttfn.php for members
of the class. Note that this parameter is read-only in the event. You can access the XML
document object by $chart->XmlDoc, modify it by PHP 5 DOM functions and then output the
XML to the $chartxml argument.
$chartxml - the XML (string) to be outputted. You can manipulate it by string functions
directly.
Example - Modifying the chart attributes by PHP 5 DOM functions

// Chart Rendered event


function Chart_Rendered(&$chartxml) {
$doc = new DOMDocument();
$doc->loadXML($chartxml);
$doc->documentElement->setAttribute('showTaskNames', '1');
$chartxml = $doc->saveXML(); // Output the XML
}

1.17.13 Compatibility Properties - Integrating with


existing PHPMaker project
Note

Before reading this tutorial, please read Compatibility Properties Setup(See 1.11.14)

first.
In this tutorial we will show you how to put scripts generated by PHP Report Maker together
with scripts generated by PHPMaker. We'll use security in both projects and demonstrate
how you can make them compatible with each other.
To make PHPMaker and PHP Report Maker projects work together, there are 3 requirements:
1. The projects share the same web folder. In general, the projects share the same
application root and destination folder.
2. The projects share the same project name.
3. If Advanced Security is used, they shares the same Advanced Security settings,
including the User ID field, Parent User ID field, User Level field and User Levels.
Project name in PHP Report Maker or PHPMaker is used in session variable to distinguish
projects. For example, if the project name of your PHPMaker project is named as "project1",
the session variable of the logged in status is session variable "project1_status". If your
project name of your PHP Report Maker project is named as "project2", when users browse
from PHPMaker generated pages to PHP Report Maker generated pages, you will be

322

PHP Report Maker 9 Help


considered as not logged in and be redirected to the login page. Therefore, to make PHP
Report Maker project compatible with PHPMaker project, we need to use the same project
name for both projects.
Select one of your PHPMaker projects that uses security, check the project name (see
Project File(See 1.13)) by clicking [Tools] -> [Advanced Settings].
In this example, the project name of the PHPMaker project is "demo", we'll use the same
project name in PHP Report Maker.
On the other hand, PHP application generated by PHP Report Maker is self-contained, it has
its own header, footer, login, logout and default page. However, if you have an existing PHP
application generated by PHPMaker, you may already have those pages already. Since those
pages typically have the same name like "header.php", "footer.php", "login.php",
"logout.php" and "index.php", generating your PHP Report Maker project to the same folder
may create several problems:
1. The header, footer, login, logout and default page of the existing application may be
overwritten.
2. Even if they are different (so they will not be overwritten), you'll need to maintain 2
sets of header and footer. To make the look and feel of your site consistent, you'll
need to make the 2 sets of header and footer look the same too.
3. If both projects uses security, each project has its own login and logout page, users
will need to login or logout twice.
To solve these problem, PHP Report Maker allows you to enable Compatibility Properties.
When enabled, PHP Report Maker will behaves a little differently during generation. If
existing paths are specified, the header, footer, login, logout and default pages will not be
generated so they won't overwrite existing files. Instead, the generated scripts will use the
paths of header, footer, login, logout and default pages specified by the Compatibility
Properties so both PHP application shares the common files. Therefore, once you have
customized the header and footer for use with both PHP applications, they will not be
overwritten when you re-generate scripts using PHP Report Maker.
If you enable Compatibility Properties but not specify the paths of header, footer, login,
logout and default pages, the pages will still be generated if necessary. For example, if your
PHPMaker project does not use security but your PHP Report Maker project does, you have
no paths for the login page and logout page to specify, you leave them empty in the
Compatibility Properties form and PHP Report Maker will generate the login and logout pages
for the reports.
Note

Steps to Setup Compatibility Properties


1. Make Sure the Advanced Security Settings in Both Projects Are the Same
The Advanced Security settings in both projects must be the same. Open the PHP Report
Maker project you previously used in the Advanced Security tutorials (Tutorial - User ID
Security(See 1.17.2) or Tutorial - User Level Security(See 1.17.3)). Compare the Advanced
Security settings with that in your PHPMaker project. Check the User ID field, Parent User ID
field, User Level field and User Levels.
Close the project. (In next step, PHPMaker may need to change your project settings, so you
should not open the project in PHP Report Maker.)
2. Setting up Compatibility Properties

323

PHP Report Maker 9 Help


Compatibiltiy can be set up easily in the PHPMaker project. PHPMaker can load the PHP
Report Maker project, set up above properties automatically and load the menu items from
the PHP Report Maker project to the PHPMaker project. Since PHPMaker will update your PHP
Report Maker project, to avoid overwriting each other, you should save your PHP Report
Maker project and close PHP Report Maker first. Then in PHPMaker, open the Menu Editor,
click the [Import] button in the toolbar, select your PHP Report Maker project (9.0 or
later), then click [OK]. The imported menu items will be represented by orange icons, you
can then re-arrange the display order of the menu items if necessary.
If you change User Level settings in your PHP Report Maker project later, the imported
menu items in the PHPMaker project will NOT be updated automatically, you'll need to
repeat above again.
Note

If you open your report project again in PHP Report Maker and click [Tools] ->
[Compatibility Properties], you should see that PHPMaker has changed some settings for
compatibility:
1. The project name has been set as the same as that of PHPMaker project,
2. [Enable compatibility properties] is enabled,
3. The file names of the shared files has been setup. If they are not correct, enter the
file name of the header, footer, login, logout and default pages in your PHPMaker
project.

324

PHP Report Maker 9 Help

Click [OK] to save.


3. PHP Script Generation
Go to the [Generate] tab, select the same [Application root folder] and [Destination
folder] as in your PHPMaker project. Click the [Generate] button and PHP Report Maker
will generate the required PHP scripts automatically.
4. Running the PHP Application
Run your existing PHP application with your browser. If use security and you have not
logged in, you'll be redirected to the login page, If your PHPMaker project uses security, you
should find yourself been redirected to the login page from the PHPMaker project.
Login so you can browse the existing PHPMaker pages.
Now click the new links in the menu to view the reports. You'll be redirected to the default
report you specified in your PHP Report Maker project without the need to login again.
Check the User ID security or User Level security by browsing the reports and you'll find that
it works as expected.

325

Potrebbero piacerti anche