Merciglobal ERP
PHP Function Documentation
Function Name
setDeleCanc($cTable, $id, $value = '')
Purpose
The setDeleCanc function updates the delecanc field of a specified
table record and conditionally re-posts the related accounting entry.
This function is typically used to: - Mark a record as deleted or cancelled - Restore a record - Ensure accounting consistency when status changes
Parameters
Parameter Type Description
$cTable string Name of the database table
$id int Primary key (row ID) of the
record
$value string Value to set in the
delecanc field. Either
empty string '' or
'YES'
Behavior
- Updates the
delecancfield in the specified table. - If the previous value of
delecancis not equal to'YES', the function:- Re-posts the related accounting entry.
- If
delecancis already'YES', no accounting re-posting occurs.
Business Logic
'YES'→ Record is marked as Deleted/Cancelled\''(empty) → Record is Active\- Accounting re-posting ensures financial integrity when a record transitions into a cancelled state.
Example Usage
// Cancel a record
setDeleCanc('sales_invoice', 1254, 'YES');
// Reactivate a record
setDeleCanc('sales_invoice', 1254, '');
Notes
- Ensure that
$cTablereferences a valid ERP table. - The function checks the existence of a
delecanccolumn. - Accounting repost logic must be implemented within or triggered by this function.