Commit | Line | Data |
---|---|---|
f1d7f287 CR |
1 | <?php |
2 | ||
3 | class CRM_Case_Form_AddToCaseAsRole extends CRM_Contact_Form_Task { | |
4 | public function buildQuickForm() { | |
5 | $formBuilder = new CRM_Case_FormBuilder($this); | |
6 | $formBuilder->build(); | |
7 | } | |
8 | ||
9 | public function postProcess() { | |
10 | $values = $this->controller->exportValues(); | |
11 | ||
cf0adfdc CR |
12 | $caseId = (int) $values['assign_to']; |
13 | $roleTypeId = (int) $values['role_type']; | |
f1d7f287 CR |
14 | $contacts = $this->_contactIds; |
15 | ||
16 | $clients = CRM_Case_BAO_Case::getCaseClients($caseId); | |
17 | ||
18 | $params = array( | |
19 | 'contact_id_a' => $clients[0], | |
20 | 'contact_id_b' => $contacts, | |
21 | 'case_id' => $caseId, | |
cf0adfdc | 22 | 'relationship_type_id' => $roleTypeId, |
f1d7f287 CR |
23 | ); |
24 | ||
25 | CRM_Contact_BAO_Relationship::createMultiple($params, 'a'); | |
26 | ||
27 | $url = CRM_Utils_System::url( | |
28 | 'civicrm/contact/view/case', | |
29 | sprintf('cid=%d&id=%d', $clients[0], $caseId) | |
30 | ); | |
31 | CRM_Utils_System::redirect($url); | |
32 | } | |
cf0adfdc | 33 | |
f1d7f287 | 34 | } |