コード例 #1
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
     }
     //CRM-4418
     if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         return TRUE;
     }
     if (!$this->_caseId) {
         $caseAttributes = array('case_type' => CRM_Case_PseudoConstant::caseType(), 'case_status' => CRM_Case_PseudoConstant::caseStatus(), 'encounter_medium' => CRM_Case_PseudoConstant::encounterMedium());
         foreach ($caseAttributes as $key => $values) {
             if (empty($values)) {
                 CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => str_replace('_', ' ', $key))));
                 break;
             }
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         if (!$this->_activityTypeId) {
             CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.'));
         }
     }
     //check for case permissions.
     if (!CRM_Case_BAO_Case::accessCiviCase()) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
     }
     $details = CRM_Case_PseudoConstant::caseActivityType(FALSE);
     CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
     $this->assign('activityType', $details[$this->_activityTypeId]['label']);
     $this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']);
     if (isset($this->_currentlyViewedContactId)) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_currentlyViewedContactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId)));
         }
         $this->assign('clientName', $contact->display_name);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     //when custom data is included in this page
     CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity');
     eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
     $activityGroupTree = $this->_groupTree;
     // for case custom fields to populate with defaults
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     // so that grouptree is not populated with case fields, since the grouptree is used
     // for populating activity custom fields.
     $this->_groupTree = $activityGroupTree;
 }
コード例 #2
0
ファイル: Activity.php プロジェクト: rajeshrhino/civicrm-core
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: OpenCase.php プロジェクト: hguru/224Civi
 static function buildQuickForm(&$form)
 {
     if ($form->_context == 'caseActivity') {
         return;
     }
     if ($form->_context == 'standalone') {
         CRM_Contact_Form_NewContact::buildQuickForm($form);
     }
     $caseType = array('' => '-select-') + CRM_Case_PseudoConstant::caseType();
     $element = $form->add('select', 'case_type_id', ts('Case Type'), $caseType, TRUE, array('onchange' => "CRM.buildCustomData( 'Case', this.value );"));
     if ($form->_caseTypeId) {
         $element->freeze();
     }
     $caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->add('select', 'status_id', ts('Case Status'), $caseStatus, TRUE);
     $form->add('text', 'duration', ts('Duration'), array('size' => 4, 'maxlength' => 8));
     $form->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     if ($form->_currentlyViewedContactId) {
         list($displayName) = CRM_Contact_BAO_Contact::getDisplayAndImage($form->_currentlyViewedContactId);
         $form->assign('clientName', $displayName);
     }
     $form->addDate('start_date', ts('Case Start Date'), TRUE, array('formatType' => 'activityDateTime'));
     $form->add('select', 'medium_id', ts('Medium'), CRM_Case_PseudoConstant::encounterMedium(), TRUE);
     // calling this field activity_location to prevent conflict with contact location fields
     $form->add('text', 'activity_location', ts('Location'), CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'));
     $form->addWysiwyg('activity_details', ts('Details'), array('rows' => 4, 'cols' => 60), FALSE);
     $form->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
コード例 #5
0
 static function buildQuickForm(&$form)
 {
     if ($form->_context == 'caseActivity') {
         return;
     }
     if ($form->_context == 'standalone') {
         require_once 'CRM/Contact/Form/NewContact.php';
         CRM_Contact_Form_NewContact::buildQuickForm($form);
     }
     require_once 'CRM/Case/PseudoConstant.php';
     $caseType = CRM_Case_PseudoConstant::caseType();
     $form->add('select', 'case_type_id', ts('Case Type'), $caseType, true);
     $caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->add('select', 'status_id', ts('Case Status'), $caseStatus, true);
     $form->add('text', 'duration', ts('Duration'), array('size' => 4, 'maxlength' => 8));
     $form->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     require_once "CRM/Contact/BAO/Contact.php";
     if ($form->_currentlyViewedContactId) {
         list($displayName) = CRM_Contact_BAO_Contact::getDisplayAndImage($form->_currentlyViewedContactId);
         $form->assign('clientName', $displayName);
     }
     $form->addDate('start_date', ts('Case Start Date'), true, array('formatType' => 'activityDateTime'));
     $form->add('select', 'medium_id', ts('Medium'), CRM_Case_PseudoConstant::encounterMedium(), true);
     // calling this field activity_location to prevent conflict with contact location fields
     $form->add('text', 'activity_location', ts('Location'), CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'));
     $form->addWysiwyg('activity_details', ts('Details'), array('rows' => 4, 'cols' => 60), false);
     $form->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }