* @license http://www.gnu.org/licenses/agpl-3.0.html */ class CRM_Bij1rules_Actions_Contact_GenereerLidnummer extends CRM_Civirules_Action { /** * Method to perform the actual action * * @param CRM_Civirules_TriggerData_TriggerData $triggerData * @throws */ public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData) { $contactId = (int) $triggerData->getContactId(); if ($contactId) { $lid = new CRM_Bij1algemeen_Lid(); // genereer lidnummer, alleen als contact nog geen lidnummer heeft if (!$lid->heeftLidNummer($contactId)) { $maxLid = $lid->haalLaatsteLidNummer(); $maxLid++; $lid->bewaar($contactId, $maxLid); $lid->bewaarLaatsteLidnummer($maxLid); } } } /** * Returns a redirect url to extra data input from the user after adding a action * Return false if you do not need extra data input * * @param int $ruleActionId * @return bool|string * @access public */ public function getExtraDataInputUrl($ruleActionId) { return FALSE; } /** * This function validates whether this action works with the selected trigger. * * This function could be overriden in child classes to provide additional validation * whether an action is possible in the current setup. * * @param CRM_Civirules_Trigger $trigger * @param CRM_Civirules_BAO_Rule $rule * @return bool */ public function doesWorkWithTrigger(CRM_Civirules_Trigger $trigger, CRM_Civirules_BAO_Rule $rule) { return $trigger->doesProvideEntities(['Contact']); } }