Menus, UI & Audit
Menus, UI rendering, transactions and audit/compliance.
12 functions. All require apis/main_webservices.php to be included.
On this page: AuditLog ยท beginTran ยท class htmlRep3 ยท commit ยท companyAuditLockedStatus ยท diskBalance ยท getMenuTree ยท getSubMenu ยท isCompanyAuditLocked ยท log_info ยท rollBack ยท settings_project_admin
AuditLog()
Prototype
AuditLog( $cTable, $nID, $cEvent )
Description
- Adds an entry to the system audit log for a table record and event.
- Use to record who did what and when for compliance.
Parameters
$cTableโ Table Name$nIDโ id of entry$cEventโ name of event
Returns
- Nothing โ writes the audit entry as a side effect.
Return example
AuditLog('trn_salesorder', 1024, 'APPROVE');
// audit row written
Usage example
AuditLog( 'trn_sales', 120, 'ADD' );
:material-file-code: Source: apis/core2.php
beginTran()
Prototype
BeginTran()
Description
- Marks the start of a MySQL transaction.
- Wrap multi-statement writes so they commit or roll back atomically.
Returns
- Begins the transaction (no meaningful return value).
Return example
BeginTran();
// ... writes ...
Commit(); // or RollBack()
Usage example
BeginTran();
...
...
Commit();
:material-file-code: Source: apis/core2_a.php
class htmlRep3()
Prototype
new htmlRep3
Description
- An HTML report builder class โ add a title, set alignment/column widths, hide columns, add a header row and data rows, then render.
render($form)draws into a form;renderHTML()returns the report as an HTML table string.- Methods:
addTitle(),setAlign(),setColWd(),addHiddenCol(),addHeader(),addRow(),render(),renderHTML().
Returns
- An
htmlRep3instance;renderHTML()returns the formatted HTML table,render($form)outputs into the form.
Return example
$rep = new htmlRep3();
$rep->addTitle('Stock');
$rep->addHeader(['Item','Qty']);
$rep->addRow(['Yarn A', 120]);
echo $rep->renderHTML();
Usage example
$names = new htmlRep3( REPID );
:material-file-code: Source: apis/cl_htmlrep3.php
commit()
Prototype
Commit()
Description
- Permanently commits the SQL executed since
BeginTran(). - Call once all statements in the transaction succeeded.
Returns
- Commits the open transaction (no meaningful return value).
Return example
BeginTran();
// ... writes ...
Commit(); // persisted
Usage example
BeginTran();
...
...
if (...error...){
Rollback();
return;
}
Commit();
:material-file-code: Source: apis/core2_a.php
companyAuditLockedStatus()
Prototype
CompanyAuditLockedStatus()
Description
- Returns the audit-lock status of the current company as a YES/NO string.
- Locked periods must not accept back-dated changes.
Parameters
- none
Returns
- String โ
'YES'when audit-locked,'NO'otherwise.
Return example
echo CompanyAuditLockedStatus();
// 'YES' | 'NO'
Usage example
$status = CompanyAuditLockedStatus();
:material-file-code: Source: apis/core4.php
diskBalance()
Prototype
diskBalance()
Description
- Computes the remaining disk space for the project, as a percentage.
- Use to warn before uploads when storage is nearly full.
Returns
- Number โ remaining disk space for the project (percent).
Return example
$pct = diskBalance();
// e.g. 37 (% free)
Usage example
$bal = diskbalance();
:material-file-code: Source: apis/core2_a.php
getMenuTree()
Prototype
getMenuTree( $cMenu )
Description
- Reads the user-defined sub-menu structure and returns it as an array tree.
- Use to build the full navigation hierarchy for a menu.
Parameters
- <$cMenu> : Menu Name
Returns
- Array โ the sub-menu structure as defined by the user.
Return example
$tree = getMenuTree('MainMenu');
// nested array of menu nodes
:material-file-code: Source: apis/core.php
getSubMenu()
Prototype
getSubMenu( $cType, $cMenu )
Description
- Returns the child menus for a menu/type as configured.
- Use to render nested navigation under a parent menu.
Parameters
- <$ctype> : Menu Type such as 'TABLE'
- <$cMenu> : Menu Name such as 'MASTERS'
Returns
- Array/string โ the child menu entries for the given menu.
Return example
$kids = getSubMenu('module', 'Accounts');
// [ 'Vouchers', 'Ledgers', ... ]
:material-file-code: Source: apis/core.php
isCompanyAuditLocked()
Prototype
isCompanyAuditLocked()
Description
- Boolean form of the company audit-lock check.
- Use to block edits/posting when the company is audit-locked.
Parameters
- none
Returns
- Boolean โ
trueif the company is audit-locked.
Return example
if (isCompanyAuditLocked()) { /* block edit */ }
// returns: true | false
Usage example
$status = isCompanyAuditLocked();
:material-file-code: Source: apis/core4.php
log_info()
Prototype
log_info($msg,$file='.log.txt',$fname='')
Description
- Appends a message to a log file, stamped with date, time and username.
- Use for diagnostics and audit-style tracing; choose the log file name.
Parameters
- <$msg>: String | Array Message to be logged
- <$file>: file extension
- [$fname]: Log File name
Returns
- Nothing โ writes the log line as a side effect.
Return example
log_info('Posting started', '.post.txt');
// appended to log
Usage example
log_info('Test', '.check.txt');
:material-file-code: Source: apis/core2_a.php
rollBack()
Prototype
RollBack()
Description
- Undoes all SQL executed since
BeginTran(). - Call on error to discard a partial transaction.
Returns
- Rolls back the open transaction (no meaningful return value).
Return example
BeginTran();
if ($err) { RollBack(); }
// changes discarded
Usage example
BeginTran();
...
...
if (...error...){
Rollback();
return;
}
Commit();
:material-file-code: Source: apis/core2_a.php
settings_project_admin()
Prototype
settings_project_admin()
Description
- Builds and renders the Admin User Settings page.
- Use to expose project-level administration settings to admins.
Parameters
- none
Returns
- Renders the settings page (no value returned).
Return example
settings_project_admin();
// page rendered
:material-file-code: Source: apis/core.php