1.0 Openbiz Manual
OpenBiz Document 1.1.1
Introduction
OpenBiz provides a PHP framework that assists you to build complicated web application in an easy way.
OpenBiz is designed as a multi-layer architecture as the figure below.

Usually a business application can be modulated to 3 layers - Data layer, Business Logic layer and Presentation layer. In OpenBiz architecture, these 3 layers map to 3 packages, Presentation layer is refined to logic which is implemented by BizView package and GUI layers which is implemented by jbForm javascript package. Business Logic layer is implemented by BizObj package. 3rd party package ADODB handles Database layer.
Package BizObj
Classes
- BizObj - A base class that represents business logic entities, such as Menu, Customer, Orders. A BizObj plays as a logic container that hold data from different data source (i.e. database tables). A BizObj contains N BizRecords
- BizRecord - the logic unit that consist of the value of different data source (i.e. database tables). A BizRecord contains M BizFields
- BizField - A base class that represents a single logic field in a BizObj. For example, the last name of the customer (BizObj Customer) could be a BizField object.
Functionalities
- Use configuration xml file to map several database table into a single BizObj
$boUser = new BizObj("../metadata/BOUser.xml");
- Query on logic level
$boUser->SetSearchRule("[LastName]='Yao' OR [FirstName]='James'");
$boUser->RunSearch();
$boUser->PrintMe();
- Insert a new record
$boUser->NewRecord();
$boUser->SetField("Id", "USER-1006");
$boUser->SetField("LastName", "Test");
$boUser->SetField("FirstName", "Add");
$boUser->InsertRecord();
- Update a record
$boUser->SetSearchRule("[Id]='USER-1006'");
$boUser->RunSearch();
$boUser->EditRecord();
$boUser->SetField("LastName", "Test");
$boUser->SetField("FirstName", "Update");
$boUser->UpdateRecord();
- Delete a record
$boUser->SetSearchRule("[Id]='USER-1006'");
$boUser->RunSearch();
$boUser->DeleteRecord();
- Define a field with expression
<BizField Name="P1 Points" SourceTable="matches" SourceColumn="PLAYER1_POINT"/>
<BizField Name="P2 Points" SourceTable="matches" SourceColumn="PLAYER2_POINT"/>
<BizField Name="P1_P2" Value="[P1 Points] : [P2 Points]"/>
- Data type, format and validation
Package BizView
Classes
- BizView - the base class that contains list of UIControls such as BizForms. If can specify the dependency relationship between BizForms
- BizPopup - A special BizView. It contains one BizForm from which use can select a record to populate on the base form
A BizView contains 2 BizForm
Click "Select" icon on a Field to show the BizPopup, then Select a record to populate the fields on the base form
- BizForm - the base class to implement a set of controls mapping to a BizObj
- FieldControl - the class to implement single control that maps to a BizField
- HTMLControl - the base class of generic HTML controls
- DisplayMode - the class to read in mode config for BizForm
Functionalities
- Use configuration xml file to map BizObj on BizForm and map BizFields on FieldControls
- Associate HTMLControl with published BizForm functions
- Page Navigation - support MovePrev, MoveNext BizForm functions
- Search - support multi-field search and wild character search
- Insert a new record - insert a record before current record
- Update, Delete a record
- Present data with various HTML elements
- Sort a column

Before sorting
After sorting on Name - Link to another view
In Match View, Click Michael Liu

Link to Registration View with Michael Liu record - Select field data from comboBox - comboBox list are defined in extra xml file
- Select field data from other BizForm
Popup an BizForm and Select data to populate multiple fields on base BizForm
Registration BizForm depends on Player BizForm (RegForm.PlayerId = PlyForm.PlayerId)
Michael Liu is current selected player![]()
Alan Chew is current selected player
Package jbForm (javascript bizForm)
Class
- jbForm - the base calss that handles RPC function call and callback.
Functionalities
- Make server side remote function call. For example, A button associated with FMRegist.InsertRecord(), when use click this button, jbForm make the RPC call to server side.
- Handle callback funtion. After a RPC call is issued, server object returns data back to browser through a callback function, jbForm handle the callback data and re-render the page.
Package ADODB
This is an abstract database connection package which can connects to all major databases from different vendors. It can be downloaded from http://php.weblogs.com/ADODB
Installation
1. Running environment
OpenBiz is written by PHP4 scripts, it runs at web server side. The typical running environment could be Web Server + PHP 4.x. To ensure the performance and reliability, we recommend users to use latest web server and php engine. For example
- Apache HTTP Server 1.3.x or 2.x + PHP 4.3.x
- Internet Information Server (IIS) 5.x + PHP 4.3.x
If you have the administrator permission, you can configure PHP running as an Apache module. Some php performance software, such as mmcache, works under Apache module. This url http://www.thesitewizard.com/archive/php4install.shtml is the guide to setting up PHP 4 to run with Apache on Windows.
For better performance, please enable dom xml extension under PHP4. Please refer to http://us4.php.net/domxml. domxml extension is required to run Design Studio.
Support web browsers - IE5.x, Netscape 7.x and Mozillar 1.x
2. Install OpenBiz
Download the zip file and unzip it to a directory under your web access root.
Please read through the sysheader.inc under openbiz_root/ directory. Important notices:
- This file defines the paths of 3rd party php packages including Smarty, Adodb, Fpdf and Jpgraph. If you have same packages installed in other directories and you don't want to use the packages installed with openbiz, please modify the proper paths.
- Metadata file path, log file path and session file path can also be specified in sysheader.inc
- To use the default authentication functionality, read here.
Source tree structure:
openbiz_root/
---bin/ (openbiz php source)
------adodb/ (adodb package)
------configs/ (smarty config dir)
------fpdf/ (fpdf package)
------jpgraph/ (jpgraph package)
------Smarty/ (smarty package)
------templates/ (openbiz templates)
------templates_c/ (templates compiled code)
------tmpfiles/ (temporary file directory)
------usrlib/ (openbiz user library directory)
---css/ (openbiz style sheets)
---document/ (openbiz documents)
---images/ (openbiz images)
---log/ (openbiz logs)
---medata/ (openbiz metadata files)
------demo/ (demo package)
------design/ (design package)
---session (openbiz session files)
In Unix or Linux box, you need to give write permission to web users on log, metadata, session, bin/tmpfiles and bin/templates_c directories.
3. Install necessary third party packages
The following package are necessary - they are included in openbiz package
- ADODB, http://php.weblogs.com/ADODB. Install it under OpenBizRoot/bin/adodb
- Smarty template enginee, http://smarty.php.net/. Install it under OpenBizRoot/bin/
We recommend you install PHP optimization packages.
- Turck MMCache (free), http://www.turckware.com/en/e_mmc.htm. Please follow the instruction to install this extension.
- Zend Performance Suite http://www.zend.com/store/products/zend-performance-suite.php
4. Windows Installer with AppServ
For Windows users who want to install Web Server + PHP + Openbiz, an installer is available since B10110. Please follow the steps below:
- Install AppServ 2.2.0 from http://www.appservnetwork.com/. Apache 1.3.28 + PHP4.3.4
- Install openbiz by double click setup_opnebiz.exe. Please use installer suggested install path which is under AppServ install directory
What openbiz installer does?
Install openbiz package under AppServ\www\evtmgr
Install mmcache 2.4.6 for PHP 4.3.3
Enable domxml extension
Install Demo database under AppServ\mysql\data
Add shortcut on your desktop and program menu -
Uninstall Openbiz and AppServ
Both AppServ and Openbiz have uninstall program which can be run from programs menu. Sometimes the Appache and Mysql services can't be uninstalled by the uninstaller. Please use the trick below:
Clean up MySql command line:
> mysql-nt -- remove (remove the mysql windows service)
> del c:\winnt\my.ini (delete the mysql ini file)
Clean up Appache command line
> appache -u (remove the appache windos service)
Build Your Application
1. Specify requirement of your application
OpenBiz is a perfect tool that help you develop your complicated web application easily and comprehensively. Based on its 3-layer architecture, your application will be on a clear logic model. It takes care the basic and advanced feature of the data-oriented application. In order to tell whether OpenBiz can help building your application, you need ask these questions:
- Is your application web-based application or can be converted to web-based application?
- Is your application need manipulate different types of data using database?
If the answers are YES, OpenBiz is the right framework for developing your application!
2. Create your database model
Modeling your business data with Relational database tables is the necessary base for building your whole application.
Populate the demo database to see how demo works
- If you use openbiz installer, demo database is installed already. So please skip the steps below.
- Find gendb.sql under openbiz root directory, apply it against your database. Notes this gendb.sql is for mysql database, please adjust the syntax according to different database type.
- Table "ob_objects", "ob_users" and "ob_sysids" are openbiz system tables. Other tables are application tables, not required
Create a new database
- Assign the new database to be Default database in config.xml
- Create "ob_objects" table which stores openbiz objects
- Create "ob_users" table which stores user id and password
- Create "ob_sysids" table which stores SYSID information for all tables who have SYSID column
- Create customer tables. Each table must have a SYSID column and add a record in ob_sysids table (TABLE=your table name, PREFIX=prefix of sysid, IDBODY=starting integer)
Use existing database (assume each table has single auto-generated id column)
- Assign the new database to be Default database in config.xml
- Create ob_objects table which is used to store openbiz objects
- Create "ob_users" table or reuse an exsiting table which contains userid and password columns and reconfig the BOLogin.xml (point the Table and BaseTable to the existing table).
- Since each table has single auto-generated id column, no need to create "ob_sysids"
3. Create metadata xml files
Developers can choose use XML editor to edit medata files or use Openbiz Designer to visually edit metadata files. For more detail of Openbiz designer, Please refer to Openbiz designer user manual.
3.1 Organize metadata by package
In a big application, user may need to build lots of objects, therefore they have big metadata file list. If they put these files under a single metadata directory, managing the metadata files is a painful thing. From openbiz 1.1, metadata files can be organized by package name. Bear in mind, metadata package is different with the (BizObj, BizView ...) packages which are the code units. Metadata package is a naming system, different package maps to different directory. It is like the package concept used in Java.
PackageX.PackageY.metaA.xml refers to the metaA.xml under META_PATH/PackageA/PackageB directory. Where META_PATH is the root metadata directory. This macro is defined in sysheader.inc with define ("META_PATH", "../metadata/").
3.1.1 How to configure package in metadata files?
Let's explain it with the demo example. After you unzip the source, find the demo directory under metadata directory. Open FMRegist.xml file with a text editor. You'll see a Package="demo" attribute in the BizForm element. This attribute is to say the default package of any type of openbiz object is under "demo" package. Here the openbiz objects refer to the following object types.
| Object Type | Referred as attributes in metadata files |
| BizObj | BizForm[BizObj] BizObj->BizFieldList->BizField[SelectBizObj] |
| BizForm | BizView->ControlList->Control[Form] BizView->ControlList->Control[SubCtrl] BizForm->BizCtrlList->BizCtrl[SelectFrom] |
| BizView | |
| BizPopup | BizForm->BizCtrlList->BizCtrl[SelectBizForm] |
| BizFormTree | Same as BizForm |
If an object name doesn't contain dot symbol ("."), the system uses the package attribute defined in the object root element as its package. Otherwise, if an object name has format as aaa.objectname, the system thinks such object under package "aaa" and will locate such object under aaa directory.
Go back to the example, you can find <BizForm Name="FMRegist" Package="demo" ... BizObj="BORegist"...>, <BizCtrl Name="reg_attdln" ... SelectBizForm="AttendeePopup"...> and <BizCtrl Name="reg_fee" ... SelectFrom="Selection(Fee)"...>. They all use default package, so the system will try to locate the metadata files as demo/BORegist.xml, demo/AttendeePopup.xml and demo/Selection.xml.
If you want to refer to an object under other package, just add the package name as the prefix of the object name. Notice, there're a Selection.xml under /demo directory and another Selection.xml under /design directory, they belong to different packages. In FMRegist, whose package is "demo", you can use <BizCtrl ... SelectFrom="design.Selection(Mode)" ...> to configure a comboBox whose values are from the "Mode" element of "design/Selection.xml".
3.1.2 How to configure package with Openbiz Design Tool?
From openbiz 1.1, in the object browser view of Design Tool, user can give "Package" name for each object. If the object is not found under the directory (META_PATH/package/) mapping to the given package, a sample metadata file (copied from object type template) is created under that directory. If no package name is specified, a sample metadata file (copied from object type template) is created under META_PATH/ directory.

3.2 Use object metadata inheritance
If you have a complex application, you want to reuse the existing object to different places, but you want the object behave a little differently in different scenarios. Object inheritance will solve the above problem. Since in openbiz framework objects maps to metadata file, object inheritance becomes metadata file inheritance.
3.2.1 How to specify inheritance between metadata files?
Specify an object attribute, InheritFrom = "parent object name". For example, in demo application, BOEventX has <BizObj Name="BOEventX" Description="Event BizObj Extended from BOEvent" Package="demo" Class="BizObj" InheritFrom="demo.BOEvent"...>. This indicates that is BOEventX is inherited from BOEvent.
Metadata file inheritance is similar with class inheritance in programming languages, child object can inherit (if not defined in child object, but defined in parent object) or override (if same attribute defined in both child object and parent object) the parent object attributes.
| Object Type which can has inheritance | What CAN be inherited or overridden | What CANNOT be inherited - must be specified in child metadata file |
| BizObj | Object Attributes: Description, DBName, Table, SearchRule, SortRule, OtherSQLRule, CacheMode
Object BizFieldList: BizField |
Object Attributes: Name, Package, Class, InheritFrom, DesignProfile |
| BizForm | Object Attributes: Description, jsClass, Title, BizObj, PageSize, Width, Height, SearchRule
Object BizCtrlList: BizCtrl |
Object Attributes: Name, Package, Class, InheritFrom, DesignProfile |
3.3 Create an object record in ObjBrowse view
Open design.htm in browser to access OpenBiz Design Studio. In unix, make sure your metadata directory has write permission open for web clients. Put focus on a record, click "Design" button
to modify the object xml file.

3.4 Build BizObj metadata
BizObj metadata file describes the mapping between database tables and BizObj. It's a xml file with following DTD.
<!--OpenBiz BizObj metadata DTD--> |
Open Design Studio screenshot - BizObj Design. Click "Go Back to object browser" button
to return to ObjBrowse View.

Important Notes:
- "Id" field is a required field, a BizObj must have an "Id" field that points to the primary key of the table.
- If the ForeignTable and ForeignColumn have values, you may assign ForeignPrimKey to be the primary key column of foreign table if it isn't named as SYSID.
3.4.1 Composite keys support
Most database table designers recommend each table have its unique primary key column which is also called ID column. In Openbiz BizObj, Id field is a required field for all BizObj. If table has ID column, it's easy to map such column to Id BizField. But there's still many tables are given composite keys. Openbiz provide the following solution to map composite keys to Id BizField.
On the Id BizField of a BizObj, user can specify >1 column names in the BaseColumn attribute. For example, <BizField Name="Id" ... BaseColumn="key1,key2,key3" ...>. But you need to make sure all BizFields mapping to the composite keys are marked as "Required='Y'".
3.4.2 Efficiently use memory by specifying cache mode
Openbiz leverages server side BizObj cache (storing database query results temporally) to maintain the session data so that users can feel smooth interaction just as they are using desktop rich client. But many web interfaces simply provide navigation only functionality. To help openbiz use memory efficiently, BizObj cache mode can be turned off. There're two ways to control the cache mode.
1) Set CacheMode attribute in BizObj metadata file. <BizObj Name=... CacheMode = "0|1" ...>. 0 means no cache is used, 1 means query data is cached. If no value is given, default cache mode = 1.
2) Call BizObj::Home($cacheMode) to reset the ResultSet and set the cache mode. The default $cacheMode is 1.
Keep in mind, no cache mode is suggested to be used in navigation only BizForm.
3.5 Build BizForm metadata
BizForm metadata file describes the mapping between BizObj and BizForm as well as other UI controls in BizForm. It's a xml file with following DTD.
<!--OpenBiz BizForm metadata DTD--> |
Open Design Studio screenshot - BizForm Design.

3.6 Build BizView metadata
BizView metadata file describes the BizForms and their relationship in the BizView. It's a xml file with following DTD.
<!--OpenBiz BizView metadata DTD--> |
Open Design Studio screenshot - BizView Design.

3.7 Build BizPopup metadata
BizPopup is a special BizView. It has only one BizForm and uses BizForm.dtd file as its XML schema. Because the BizPopup is mainly used in record selection, it makes sense to provide only navigation and query for its BizForm, meanwhile only need to show most critical columns.
Open Design Studio screenshot - BizPopup Design

3.8 Build BizFormTree metadata
BizFormTree is a special BizForm. It uses BizForm.dtd file as its XML schema. BizFormTree is designed to represent the tree hierarchy relationship within a database table.
For example, event table schema: (every record has PARENT_ID and CHILD_FLAG columns which build tree hierarchy relationship between the records in the same table)
| Column | Comments |
| SYSID | Primary key |
| NAME | Event name |
| PARENT_ID | Store the SYSID of its parent event. |
| CHILD_FLAG | Flag that indicates whether this record has child record or not |
Open Design Studio screenshot - BizFormTree Design
To build up a BizFormTree metadata, please the following xml elements are necessary
- TreeNodeIcon element under BizCtrlList
Type = "FunctionColumn" indicates this column is a function-only (non-data) column
Image = "image1; image2", image1 represents the image that indicates the record has children records; image2 represents the image that indicates the record has no child records.
Function = "ExpandNode()". When user click on the image1, all children record will display on the form - TreeNodeKey element under BizCtrlList
FieldName = "the field points to the column of PARENT_ID" - TreeNodeChldFlag element under BizCtrlList
FieldName = "the field points to the column of CHILD_FLAG" - GoRoot button element under Toolbar - show the records who don't have parent
- GoUp button element under Toolbar - show the records who are siblings of the parent record of the current record
See screenshot here
3.9 Upgrade configuration xml files when openbiz xml schema changes
The main xml schema (DTD files) won't get changed, but xml element's attributes can be changed (adding a new attribute or remove an old attribute) along the OpenBiz development. To assist OpenBiz customers to update their existing xml files easily, a new button is introduced since B10105.

The button in the red circle is to update the xml element from the current xml schema, meanwhile the existing attributes data is kept. This button can only upgrade the attributes in single xml element. Put focus on an element and click the upgrade button. Then repeat it on another element.
4. Build template
Smarty template engine is used in OpenBiz to render the HTML output. We provides some basic templates for render BizForm and BizView. You can create your own templates. Remember that an openbiz form must begin with a form tag <form id={$name} name={$name}>. For detail, please refer to http://smarty.php.net/docs.php
4.1 Draw BizForm as a html table
From B10109, draw a BizForm as a html table is easy.
In BizForm xml file, you need give DataFormat as "htmltable" and FormatStyle as "table style, table header style, table odd row style, table even row style, table selected row style>
<Mode ... TemplateFile="list.tpl" ... DataFormat="htmltable" FormatStyle="tbl,tbl_head,tbl_rowodd,tbl_roweven,tbl_rowsel,tbl_cell"/>
In template file, {$fmttable}represents form whole html table.
Please refer to demo files FMEvent.xml and list.tpl
4.2 Draw BizForm as a set of controls
From B10109, draw a BizForm as a set of controls is more flexisible.
Since the array dataformat output to smarty template is associated array, user can easily layout controls by their names.
Please refer to demo files FMEvent.xml and edit.tpl
5. Technical Details - Advanced Configration
5.1 Link to another view
You can configure a BizCtrl associated with a hyperlink which changes current view to another view who has the detailed information of that BizCtrl.
In a BizForm, set a LinkTo attribute of a BizCtrl. Syntax is LinkTo="OtherView.OtherBizForm.OtherBizCtrl=MyBizCtrl".
OtherView - a view name the link takes to;
OtherBizForm - an independent BizForm, who is not a subctrl of any other BizForm, in OtherView;
OtherBizCtrl - a BizCtrl of OtherBizForm
MyBizCtrl - a BizCtrl in current BizForm
Please see the example in demo xml files (FMMatch, RegistView, FMPlayer). In this example, a link is associated with player name. This link changes view to RegistView with the player's detail. Click here to see the screenshot.
5.2 Select field data from comboBox or ListBox
5.2.1 Bind static list to comboBox
In your BizForm, you assign SelectFrom="Selection(Fee)" for a BizCtrl, which means this field control is a comboBox whose data is from the "Fee" elements in Selection.xml file. Please see example in demo FMRegist.xml where BizCtrl reg_fee is defined as a comboBox.
<Selection>
<Fee Value=""/>
<Fee Value="15"/>
<Fee Value="20"/>
</Selection>
Also, you can give both value and text. If only give value, openbiz uses the value as the display text.
<Selection>
<ChartOption Value="AAA" Text="BarLine Chart"/>
<ChartOption Value="BBB" Text="Pie Chart"/>
<ChartOption Value="CCC" Text="GroupBar Chart"/>
</Selection>
You can make up your own xml file that has list of values for selection.
5.2.2 Bind dynamic list (Table column) to comboBox
In your BizForm, you assign SelectFrom="BizObjName[BizFieldName]" for a BizCtrl, which means this field control is a comboBox whose data is from the table column mapping to the BizFieldName of the BizObjName. To avoid same values appear in the comboBox, you need to make sure the BizObj query returns an unique list.
5.3 Select a field data Fld1 in BizForm FM1 from another popup BizForm FM2
Say you have following configuration, you want to select Ctrl_1 data from Ctrl_2 that is a bizCtrl on popup BizForm. Keep in mind, the real data is selected from BizObj fields, you need to configure base and popup BizForms as well as their corresponding BizObjs.
| BizCtrl/BizForm | BizField/BizObj | |
| Base BizForm | Ctrl_1/FM_1 | Fld_1/BO_1 |
| Popup BizForm | Ctrl_2/FM_2 | Fld_2/BO_2 |
Step1: Give SelectBizObj=BO_2 and SelectField=Fld_2 for the Fld_1 in BO_1 xml file
Step2: Create a Popup_2.xml whose BizForm is FM_2
Step3: In FM_1.xml set SelectBizForm=FM_2 for Ctrl_1
Please see the example in demo xml files (BORegist, FMRegist, BOEvent, EventPopup). In this example, it is configured to select event data to populate multiple fields on FMRegist. Click here to see the screenshot.
5.4 Link 2 BizForm with dependent relationship
You can define the dependency relationship between BizForms in a same view. Records in a child BizForm is dynamically changed along the record change on it parent BizForm. Such relationship is defined in BizView xml file.
<BizView ... >
<ControlList>
<Control Name="fm_1" Form="ParentForm" SubCtrls="ChildForm"/>
<Control Name="fm_2" Form="ChildForm" Dependency="ChildBizCtrl=ParentForm.ParentBizCtrl"/>
</ControlList>
</BizView>
Please see the exmaple in demo xml files - RegistView.xml. It defines that Registration BizForm depends on Player BizForm (RegForm.PlayerId = PlyForm.PlayerId). Click here to see the screenshot.
5.5 Data type, format and validation
5.5.1 Openbiz support following data types and formats (attributes of BizField)
| Type | Format | Syntax | Format Example |
| Text | none | ||
| Number | format supported by printf | <BizField ... Type="Number" Format="%..." ...> | %5.2f to print a float number |
| "Int" - integer format according locale | <BizField ... Type="Number" Format="Int" ...> | If locale=enu, 12345.678 is displayed as 12,346 | |
| "Float"- float format according locale | <BizField ... Type="Number" Format="Float" ...> | If locale=enu, 12345.678 is displayed as 12,345.68 | |
| Date | In default read-only mode, a date can be formatted according to the Date format. | <BizField ... Type="Date" Format="date format" ...> | 6/21/2003 can be formatted as %A, %b %d %Y - Saturday, Jun 21 2003 if system locale is enu |
| In edit/query mode, a date is formatted as YYYY-MM-DD (ISO 8601) | 12/31/2003 can be formatted as 2003-12-31 | ||
| Datetime | In default read-only mode, a date can be formatted according to the Date format. | <BizField ... Type="Datetime" Format="datetime format" ...> | 6/22/2003 9:30am can be formatted as %m/%d/%Y %H:%M:%S - 06/22/2003 09:30:00 if system locale is enu |
| In edit/query mode, a date is formatted as YYYY-MM-DD hh:mm:ss (ISO 8601) | 6/22/2003 9:30am can be formatted as 2003-06-22 09:30:00 |
||
| Currency | Formatted according to locale setting | <BizField ... Type="Currency" Format="Currency" ...> | 1456.89 is formatted as $1,456.89 (enu) 1456.89 is formatted as F1 456,89 (fra) |
| Phone | Formatted according to given mask # | <BizField ... Type="Phone" Format="mask string" ...> | 1234567890 is formatted as mask=(###) ###-####, phone=(123) 456-7890 mask=###-###-####, phone=123-456-7890 |
| If a phone number starting with "*", it represents international phone number, it won't be formatted | *123 4567890 is treated as international number |
5.5.2 Openbiz support following data validations
| Validation Type | Example |
| Required - indicates the field can not be empty | <BizField Name="Name" Required="Y" BaseTable="players" BaseColumn="NAME"/> |
| Validator - php statments that returns a boolean value | <BizField Name="Fee" Type="Currency" Format="Currency" Validator="return [Fee]>=15;" BaseTable="regist" BaseColumn="FEE"> |
5.6 Present data with various HTML elements
From B10107, customer can present their data with various HTML elements by specifying element type and attributes in BizForm xml files. HTML elements are displayed in edit/query modes
|
Attributes of FieldControl element in BizForm |
|||||||||
| Type | Width | Height | HTMLAttr* | Style** | SeclectFrom | Caption | Function | Image | Comments |
| Text | x | x | x |
x | x OnChange |
Single line text input. Default type | |||
| Textarea | x | x | x | x | x OnChange |
Multi-line Text input | |||
| ListBox | x | x | x |
x | x |
x OnChange |
ListBox or ComboBox | ||
| CheckBox | x | x | x | x | x |
x OnClick |
CheckBox | ||
| Radio | x |
x | x | x | x |
x OnClick |
Radio buttons | ||
| HTMLButton | x | x | x | x | x | x OnClick |
Standard HTML Button | ||
| SubmitButton | x | x | x | x | x | x OnClick |
Standard HTML Submit Button | ||
| ResetButton | x | x | x | x | x | x OnClick |
Standard HTML Reset Button | ||
| Password | x | x | x | x | HTML password | ||||
| Button | x | x | x | x | x | x OnClick |
x | OpenBiz image button | |
| Date | x | x | x | x | Textbox with date picker icon | ||||
| Datetime | x | x | x | x | Textbox with datetime picker icon | ||||
| HTMLBlock | x | x | x | x |
Caption is treated as HTML block | ||||
| FunctionColumn | x | x | x | x | x | x | This type doesn't map to a data field | ||
* HTMLAttr field can contain any valid additional HTML attribute applied on the HTML element type
** Style field can contain any valid style properties (css)
HTMLAttr="maxlength=N" to limit the maximum number of characters that the user can enter in a text control.
By default show comboBox. If HTMLAttr="size=N", show N-row listbox.
SelectFrom="XmlFile(Key)" means this field control is a listbox or radio buttons whose data is from the "Key" elements in XmlFile.
SelectFrom="Value" means this checkbox returns the Value when user check the checkbox.
By default the radion buttons are arranged horiztionally. If HTMLAttr="wide=1", you can force them arranged vertically.
"<" and ">" used in HTML block have to be replaced by "<" and ">".
5.7 Use the aggregation SQL functions
You can assign a BizField with SQL functions provided by the database engine. The syntax is
<BizField Name="FieldName" BaseTable="TableName" BaseColumn="FUNC(ColumnName)"...>
For example:
<BizField Name="SumFee" BaseTable="regist" BaseColumn="SUM(FEE)"...>
5.8 Usage of SearchRule, SortRule and OtherSQLRule
| Syntax | Example | |
| SearchRule | SearchRule = SQL Where clause* | SearchRule = "[LastName]='Yao' OR [FirstName]='James'" |
| SortRule | SortRule = SQL Order By clause* | SortRule = "[Id] ASC" |
| OtherSQLRule | OtherSQLRule = any SQL clause* | OtherSQLRule = "GROUP BY [EvtId] HAVING [SumFee]>10" |
* Replace the Column name with BizField name.
5.9 Usage of rule in calling GoToView from client
The most useful client side javascript function is GoToView(view, rule, loadPageTarget).
| Argument | Description | Sample |
| view | the view name | |
| rule | the search rule of a bizform who is not depent on (a subctrl of) another bizform
syntax is "form.ctrl operator value". |
FMSponsor.spr_exp>=12000
FMSponsor.spr_name=\'Midas Auto\' OR FMSponsor.spr_id=\'SPSR_2\' FMSponsor.spr_name LIKE \'S%\' |
| loadPageTarget | the window or frame target to load the page |
In the demo application, EvtMenu.htm consists of a list of hyperlinks that call GoToView functions.
5.10 Make your own calendar and timestamp picker
- Change the look-and-feel of calendar and timestamp picker
Modify the stylesheet file popcalendar.css under openbiz_root/css. - Change the text shown on the calendar and timestamp picker
Modify the variables definition part of popcalendar.js under openbiz_root/.
Advanced: build your application by extending OpenBiz
OpenBiz provide many functionalities to building a complicated web application. But different application has different requirement, so you may extend OpenBiz packages to build customer oriented application.
Because OpenBiz packages are based on object-oriented design, you can easily build up your own object by extending these packages and inherit all useful functions provided by them.
Since B10107, extended classes are automatically loaded on demand. Customers can put their library files under /bin or /bin/usrlib/. Extended class must be included in a file with format as ClassName.php.
1. Extend BizObj and BizForm
/**
* class BOUser is the BizObj class to implement USER logic object
*/
class BOUser extends BizObj
{
function BOUser($xmlFile=null) {}
function my_special_function() {} // new function
}
/**
* class FMUser is the BizForm class to implement USER UI object
*/
class FMUser extends BizForm
{
function FMUser($xmlFile=null) {}
function my_special_function() {} // new function
function Render() {} // override Render()
}
2. Implement Plug-in Service Interface
From openbiz 1.1, customer can write their special logic by implement Plug-in Service Interface.
- Define the caller function in BizForm metadata file
<... Function="CallService(ClassName,MethodName)"...> is to call a method "MethodName" of the service "ClassName". ClassName is a class which defined in ClassName.php under bin/usrlib/ directory - Implement the class and method in the ClassName.php
A input argument of the method are the caller's object name (a BizForm name) and the input data string (a collection of form values from client browser). It implements the user-specific business logic and returns void. See the following code snippet.
class chartService
{
function chartService() {}function render($objname, $inputDataStr)
{
$kvArray = ExtractInputToArray($inputDataStr);
$chartName = $kvArray['__this']; // get the value of the control that issues the call// get the current UI bizobj and its querySQL, create a new bizobj and search with the same sql
$bizform = &sys_getobj($objname); // get the existing bizform object// copy to a new bizobj, not touch the bizobj belong to UI, syntax may change in PHP5
$bizobj = $bizform->m_BizObj;
...
}
Three examples can be found in bin/usrlib/
- pdfService.php - prints PDF report. Use FPDF library http://www.fpdf.org/
class PDF_SQL_Table is the base class to print a pdf table based on sql query. It provide the capability for users to configure title, title font, table header font, table row font and table color theme easily. - excelService.php - print Excel output with HTML or CSV formats
- chartService.php - draw business charts based on chart xml definition file. Use Jpgraph library http://www.aditus.nu/jpgraph/
Please refer to the chart service document to understand how to configure chart xml file.
3. Implement View Access Control
By assigning a customer function call to the "AccessControl" attribute of BizView, access control can be added to a view. The syntax is
<BizView ... AccessControl="ClassName.MethodName"...>
Or <BizView ... AccessControl="I"...>. If I=0 access denied; if I=1 view readonly; if I=2 view is read+write.
You can control the access level of each control by assign "Access" attribute (READ/WRITE) to a control in BizForm. If no Access attribute is given, openbiz treates it have "WRITE" permission.
<Control Name="SearchButton" ... Access="READ">
<Control Name="EditButton" ... Access="WRITE">
Then implement this function call as a class method with a input argument as view name. The function should return an integer value.
| Return Value | Meaning |
| 0 | Cannot access the view. System will show an error page "viewdenied.tpl" |
| 1 | View is read-only |
| 2 | View is editable |
/* Example: method CanAccessView of class ViewControl.
BizView config as AccessControl="ViewControl.CanAccessView" */
function CanAccessView($view)
{
//$userid = _SESSION["login"];
//check if this user can access this view
//if view is not accessible
// echo "$view is not accessible!";
// exit;
//else
// return; // (0,1,2) - (no view, read, write)
}
API Document
OpenBiz API Document is generated by PhpDocumentor http://phpdocu.sourceforge.net/
Debug Strategies
- The error is logged under /log/log_error.html, open it and you may find out what's wrong
- Open the sysheader.inc under /bin, turn on debug log by changing define("DEBUG", 1); Then you'll see some debug information in /log/log_debug.html. This debug file records mainly the database calls and other operations
- Printer-friendly version
- Login or register to post comments




