Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
class CRM_CivirulesConditions_Form_Case_CaseStatus extends CRM_CivirulesConditions_Form_Form {
protected function getCaseStatus() {
return CRM_CivirulesConditions_Case_CaseStatus::getCaseStatus();
}
/**
* Overridden parent method to build form
*
* @access public
*/
public function buildQuickForm() {
$this->add('hidden', 'rule_condition_id');
$caseStatuses = $this->getCaseStatus();
asort($caseStatuses);
$this->add('select', 'status_id', ts('Case Status(es)'), $caseStatuses, true,
array('id' => 'status_ids', 'multiple' => 'multiple','class' => 'crm-select2'));
$this->add('select', 'operator', ts('Operator'), array('is one of', 'is NOT one of'), true);
$this->addButtons(array(
array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE,),
array('type' => 'cancel', 'name' => ts('Cancel'))));
}
/**
* Overridden parent method to set default values
*
* @return array $defaultValues
* @access public
*/
public function setDefaultValues() {
$defaultValues = parent::setDefaultValues();
$data = unserialize($this->ruleCondition->condition_params);
if (!empty($data['status_id'])) {
$defaultValues['status_id'] = $data['status_id'];
}
if (!empty($data['operator'])) {
$defaultValues['operator'] = $data['operator'];
}
return $defaultValues;
}
/**
* Overridden parent method to process form data after submission
*
* @throws Exception when rule condition not found
* @access public
*/
public function postProcess() {
$data['status_id'] = $this->_submitValues['status_id'];
$data['operator'] = $this->_submitValues['operator'];
$this->ruleCondition->condition_params = serialize($data);
$this->ruleCondition->save();
parent::postProcess();
}
}