private function wf_crm_admin_form::buildCaseTab in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/wf_crm_admin_form.inc \wf_crm_admin_form::buildCaseTab()
Case settings FIXME: This is exactly the same code as buildGrantTab. More utilities and less boilerplate needed.
1 call to wf_crm_admin_form::buildCaseTab()
- wf_crm_admin_form::buildForm in includes/
wf_crm_admin_form.inc - Build admin form for civicrm tab of a webform
File
- includes/
wf_crm_admin_form.inc, line 610 - Webform CiviCRM module's admin form.
Class
- wf_crm_admin_form
- @file Webform CiviCRM module's admin form.
Code
private function buildCaseTab() {
$types = wf_crm_apivalues('case', 'getoptions', array(
'field' => 'case_type_id',
));
if (!$types) {
return;
}
$this->form['caseTab'] = array(
'#type' => 'fieldset',
'#title' => t('Cases'),
'#group' => 'webform_civicrm',
'#attributes' => array(
'class' => array(
'civi-icon-case',
),
),
);
$this->form['caseTab']["case_number_of_case"] = array(
'#type' => 'select',
'#title' => t('Number of Cases'),
'#default_value' => $num = wf_crm_aval($this->data, "case:number_of_case", 0),
'#options' => range(0, $this->sets['case']['max_instances']),
'#prefix' => '<div class="number-of">',
'#suffix' => '</div>',
);
$this
->addAjaxItem("caseTab", "case_number_of_case", "case");
for ($n = 1; $n <= $num; ++$n) {
$fs = "case_case_{$n}_fieldset";
$this->form['caseTab']['case'][$fs] = array(
'#type' => 'fieldset',
'#title' => t('Case !num', array(
'!num' => $n,
)),
'wrap' => array(
'#weight' => 9,
),
);
$this->form['caseTab']['case'][$fs]["case_{$n}_settings_existing_case_status"] = array(
'#type' => 'select',
'#title' => t('Update Existing Case'),
'#options' => array(
'' => '- ' . t('None') . ' -',
) + wf_crm_apivalues('case', 'getoptions', array(
'field' => 'status_id',
)),
'#default_value' => wf_crm_aval($this->data, "case:{$n}:existing_case_status", array()),
'#multiple' => TRUE,
);
$this
->help($this->form['caseTab']['case'][$fs]["case_{$n}_settings_existing_case_status"], 'existing_case_status');
$case_type = wf_crm_aval($this->data, "case:{$n}:case:1:case_type_id");
foreach ($this
->filterCaseSets($case_type) as $sid => $set) {
$fs1 = "case_case_{$n}_fieldset_{$sid}";
if ($sid == 'case') {
$pos =& $this->form['caseTab']['case'][$fs];
}
else {
$pos =& $this->form['caseTab']['case'][$fs]['wrap'];
}
$pos[$fs1] = array(
'#type' => 'fieldset',
'#title' => $set['label'],
'#attributes' => array(
'id' => $fs1,
'class' => array(
'web-civi-checkbox-set',
),
),
'js_select' => $this
->addToggle($fs1),
);
$this
->addDynamicCustomSetting($pos[$fs1], $sid, 'case', $n);
if (isset($set['fields'])) {
foreach ($set['fields'] as $fid => $field) {
$fid = "civicrm_{$n}_case_1_{$fid}";
if (!$case_type || empty($field['case_types']) || in_array($case_type, $field['case_types'])) {
$pos[$fs1][$fid] = $this
->addItem($fid, $field);
}
}
}
}
$this
->addAjaxItem("caseTab:case:{$fs}:case_case_{$n}_fieldset_case", "civicrm_{$n}_case_1_case_case_type_id", "..:wrap");
}
}