Skip to content

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

  1. Updates the delecanc field in the specified table.
  2. If the previous value of delecanc is not equal to 'YES', the function:
    • Re-posts the related accounting entry.
  3. If delecanc is 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 $cTable references a valid ERP table.
  • The function checks the existence of a delecanc column.
  • Accounting repost logic must be implemented within or triggered by this function.