Beispiel #1
0
 public function buildQuickForm()
 {
     $this->_fields['source_contact_id']['label'] = ts('Reported By');
     unset($this->_fields['status_id']['attributes']['required']);
     if ($this->_caseType) {
         $xmlProcessor = new CRM_Case_XMLProcessor_Process();
         $aTypes = array();
         foreach ($this->_caseType as $key => $val) {
             $activityTypes = $xmlProcessor->get($val, 'ActivityTypes', TRUE);
             $aTypes = $aTypes + $activityTypes;
         }
         // remove Open Case activity type since we're inside an existing case
         $openCaseID = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         unset($aTypes[$openCaseID]);
         asort($aTypes);
         $this->_fields['followup_activity_type_id']['attributes'] = array('' => '- select activity type -') + $aTypes;
     }
     $result = parent::buildQuickForm();
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::DETACH | CRM_Core_Action::RENEW)) {
         return;
     }
     $this->assign('urlPath', 'civicrm/case/activity');
     $encounterMediums = CRM_Case_PseudoConstant::encounterMedium();
     // Fixme: what's the justification for this? It seems like it is just re-adding an option in case it is the default and disabled.
     // Is that really a big problem?
     if ($this->_activityTypeFile == 'OpenCase') {
         $this->_encounterMedium = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'medium_id');
         if (!array_key_exists($this->_encounterMedium, $encounterMediums)) {
             $encounterMediums[$this->_encounterMedium] = CRM_Core_OptionGroup::getLabel('encounter_medium', $this->_encounterMedium, FALSE);
         }
     }
     $this->add('select', 'medium_id', ts('Medium'), $encounterMediums, TRUE);
     $i = 0;
     foreach ($this->_caseId as $key => $val) {
         $this->_relatedContacts[] = $rgc = CRM_Case_BAO_Case::getRelatedAndGlobalContacts($val);
         $contName = CRM_Case_BAO_Case::getContactNames($val);
         foreach ($contName as $nkey => $nval) {
             array_push($this->_relatedContacts[$i][0], $this->_relatedContacts[$i][0]['managerOf'] = $nval['display_name']);
         }
         $i++;
     }
     //add case client in send a copy selector.CRM-4438.
     foreach ($this->_caseId as $key => $val) {
         $relatedContacts[] = $relCon = CRM_Case_BAO_Case::getContactNames($val);
     }
     if (!empty($relatedContacts)) {
         foreach ($relatedContacts as $relatedContact) {
             $this->_relatedContacts[] = $relatedContact;
         }
     }
     if (!empty($this->_relatedContacts)) {
         $checkBoxes = array();
         foreach ($this->_relatedContacts as $id => $row) {
             $checkBoxes[$id] = $this->addElement('checkbox', $id, NULL, NULL, array('class' => 'select-row'));
         }
         $this->addGroup($checkBoxes, 'contact_check');
         $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
         $this->assign('searchRows', $this->_relatedContacts);
     }
     $this->_relatedContacts = $rgc + $relCon;
     $this->addFormRule(array('CRM_Case_Form_Activity', 'formRule'), $this);
 }
 public function buildQuickForm()
 {
     // modify core Activity fields
     $this->add('text', 'target_contact_id', ts('target'));
     //FIXME : ideally hidden element should work.
     $this->addElement('advcheckbox', "hidden_target_contact");
     $this->_fields['source_contact_id']['label'] = ts('Reported By');
     $this->_fields['status_id']['attributes'] = array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus();
     if ($this->_caseType) {
         $xmlProcessor = new CRM_Case_XMLProcessor_Process();
         $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE);
         // remove Open Case activity type since we're inside an existing case
         $openCaseID = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         unset($aTypes[$openCaseID]);
         asort($aTypes);
         $this->_fields['followup_activity_type_id']['attributes'] = array('' => '- select activity type -') + $aTypes;
     }
     $result = parent::buildQuickForm();
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::DETACH | CRM_Core_Action::RENEW)) {
         return;
     }
     if ($this->_cdType || $this->_addAssigneeContact || $this->_addTargetContact) {
         return $result;
     }
     $this->assign('urlPath', 'civicrm/case/activity');
     $encounterMediums = CRM_Case_PseudoConstant::encounterMedium();
     if ($this->_activityTypeFile == 'OpenCase') {
         $this->_encounterMedium = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'medium_id');
         if (!array_key_exists($this->_encounterMedium, $encounterMediums)) {
             $encounterMediums[$this->_encounterMedium] = CRM_Core_OptionGroup::getLabel('encounter_medium', $this->_encounterMedium, FALSE);
         }
     }
     $this->add('select', 'medium_id', ts('Medium'), $encounterMediums, TRUE);
     $this->_relatedContacts = CRM_Case_BAO_Case::getRelatedAndGlobalContacts($this->_caseId);
     //add case client in send a copy selector.CRM-4438.
     $relatedContacts = CRM_Case_BAO_Case::getContactNames($this->_caseId);
     if (!empty($relatedContacts)) {
         foreach ($relatedContacts as $relatedContact) {
             $this->_relatedContacts[] = $relatedContact;
         }
     }
     if (!empty($this->_relatedContacts)) {
         $checkBoxes = array();
         foreach ($this->_relatedContacts as $id => $row) {
             $checkBoxes[$id] = $this->addElement('checkbox', $id, NULL, '');
         }
         $this->addGroup($checkBoxes, 'contact_check');
         $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "return toggleCheckboxVals('contact_check',this);"));
         $this->assign('searchRows', $this->_relatedContacts);
     }
     $this->addFormRule(array('CRM_Case_Form_Activity', 'formRule'), $this);
 }