/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { require_once 'CRM/Case/BAO/Case.php'; CRM_Case_BAO_Case::deleteCase($this->_id); CRM_Core_Session::setStatus(ts("Selected Case has been deleted.")); return; } // get the submitted form values. $params = $this->controller->exportValues($this->_name); if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } $params['contact_id'] = $this->_contactID; $params['start_date'] = CRM_Utils_Date::format($params['start_date']); $params['end_date'] = CRM_Utils_Date::format($params['end_date']); $params['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['case_type_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR; $config =& CRM_Core_Config::singleton(); if ($config->civiHRD) { $params['casetag2_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['casetag2_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR; $params['casetag3_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . implode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $params['casetag3_id']) . CRM_Case_BAO_Case::VALUE_SEPERATOR; } require_once 'CRM/Case/BAO/Case.php'; $case = CRM_Case_BAO_Case::create($params); CRM_Case_BAO_Case::deleteCaseContact($case->id); if (!empty($this->_contactIds) && is_array($this->_contactIds)) { foreach ($this->_contactIds as $key => $id) { if ($id) { $contactParams = array('case_id' => $case->id, 'contact_id' => $id); CRM_Case_BAO_Case::addCaseToContact($contactParams); } } } else { $contactParams = array('case_id' => $case->id, 'contact_id' => $this->_contactID); CRM_Case_BAO_Case::addCaseToContact($contactParams); foreach ($params['case_contact'] as $key => $id) { if ($id) { $contactParams = array('case_id' => $case->id, 'contact_id' => $id); CRM_Case_BAO_Case::addCaseToContact($contactParams); } } } // set status message CRM_Core_Session::setStatus(ts('Case \'%1\' has been saved.', array(1 => $params['subject']))); }