Validate the Specific Workgroup’s Labor is Billable
PHP
/**
* Prevents a user from adding a SERVICE_DESK_LABOR item for workgroups starting with "ABC" or "XYZ"
* if the "Billable" flag is not checked
*
* Description: ABC/XYZ Project Labor Billable
* Table Name: SERVICE_DESK_LABOR
* Table Record:
* Action: Save
*/
if (empty($params['billable'])
&& ($wkGroup = $this->query("SELECT NAME FROM WORKGROUPS WHERE RECID = {$params['workgroup']}"))
&& !empty($wkGroup[0]['NAME'])
&& preg_match('/^(ABC|XYZ).*$/', $wkGroup[0]['NAME'])
) {
// If workgroup name STARTS with ABC or XYZ, output error message
$this->setMessage( 'Billable must be Checked for ABC or XYZ Workgroups!');
return false;