60 lines
1.8 KiB
PHP
Executable File
60 lines
1.8 KiB
PHP
Executable File
<?php
|
|
use CRM_Nbrcivirules_ExtensionUtil as E;
|
|
|
|
/**
|
|
* Class for form processing set volunteer status
|
|
*
|
|
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
|
|
* @date 25 April 2020
|
|
* @license AGPL-3.0
|
|
*/
|
|
|
|
class CRM_Nbrcivirules_Actions_Contact_Form_SetVolunteerStatus extends CRM_CivirulesActions_Form_Form {
|
|
|
|
/**
|
|
* Overridden parent method to build form
|
|
*
|
|
* @access public
|
|
*/
|
|
public function buildQuickForm() {
|
|
$this->add('hidden', 'rule_action_id');
|
|
$this->add('select','nbr_volunteer_status_id', E::ts('Set Volunteer Status to'), CRM_Nihrbackbone_Utils::getOptionValueList('nbr_volunteer_status'), TRUE,
|
|
['class' => 'crm-select2', 'placeholder' => ' - select volunteer status -']);
|
|
$this->addButtons([
|
|
['type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE,],
|
|
['type' => 'cancel', 'name' => ts('Cancel')],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Overridden parent method to set default values
|
|
*
|
|
* @return array $defaultValues
|
|
* @access public
|
|
*/
|
|
public function setDefaultValues() {
|
|
$defaultValues = parent::setDefaultValues();
|
|
if ($this->ruleActionId) {
|
|
$defaults['rule_action_id'] = $this->ruleActionId;
|
|
}
|
|
$data = unserialize($this->ruleAction->action_params);
|
|
if (isset($data['nbr_volunteer_status_id'])) {
|
|
$defaultValues['nbr_volunteer_status_id'] = $data['nbr_volunteer_status_id'];
|
|
}
|
|
return $defaultValues;
|
|
}
|
|
|
|
/**
|
|
* Overridden parent method to process form data after submission
|
|
*
|
|
* @throws Exception when rule condition not found
|
|
* @access public
|
|
*/
|
|
public function postProcess() {
|
|
$data['nbr_volunteer_status_id'] = $this->_submitValues['nbr_volunteer_status_id'];
|
|
$this->ruleAction->action_params = serialize($data);
|
|
$this->ruleAction->save();
|
|
parent::postProcess();
|
|
}
|
|
}
|