コード例 #1
0
 /**
  * Function to actually build the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $subTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'activity_type_id');
     if (!CRM_Core_BAO_CustomGroup::autoCreateByActivityType($subTypeId)) {
         $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE);
         // everything
         // FIXME: Displays weird "/\ Array" message; doesn't work with tabs
         CRM_Core_Session::setStatus(ts('There are no custom data sets for activity type "%1". To create one, <a href="%2" target="%3">click here</a>.', array(1 => $activityTypes[$subTypeId], 2 => CRM_Utils_System::url('civicrm/admin/custom/group', 'action=add&reset=1'), 3 => '_blank')));
     }
     $allowCoreTypes = CRM_Campaign_BAO_Survey::surveyProfileTypes();
     $allowSubTypes = array('ActivityType' => array($subTypeId));
     $entities = array(array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'), array('entity_name' => 'activity_1', 'entity_type' => 'ActivityModel', 'entity_sub_type' => $subTypeId));
     $this->addProfileSelector('contact_profile_id', ts('Contact Info'), $allowCoreTypes, $allowSubTypes, $entities);
     $this->addProfileSelector('activity_profile_id', ts('Questions'), $allowCoreTypes, $allowSubTypes, $entities);
     // Note: Because this is in a tab, we also preload the schema via CRM_Campaign_Form_Survey::preProcess
     parent::buildQuickForm();
 }
コード例 #2
0
ファイル: Main.php プロジェクト: archcidburnziso/civicrm-core
 /**
  * Function to actually build the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE);
     $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
     // Activity Type id
     $this->addSelect('activity_type_id', array(), TRUE);
     // Campaign id
     $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values));
     $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
     // script / instructions
     $this->addWysiwyg('instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40));
     // release frequency
     $this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
     $this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger');
     // max reserved contacts at a time
     $this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts'));
     $this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger');
     // total reserved per interviewer
     $this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts'));
     $this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger');
     // is active ?
     $this->add('checkbox', 'is_active', ts('Active?'));
     // is default ?
     $this->add('checkbox', 'is_default', ts('Default?'));
     parent::buildQuickForm();
 }
コード例 #3
0
ファイル: Results.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $optionGroups = CRM_Campaign_BAO_Survey::getResultSets();
     if (empty($optionGroups)) {
         $optionTypes = array('1' => ts('Create new result set'));
     } else {
         $optionTypes = array('1' => ts('Create new result set'), '2' => ts('Use existing result set'));
         $this->add('select', 'option_group_id', ts('Select Result Set'), array('' => ts('- select -')) + $optionGroups, FALSE, array('onChange' => 'loadOptionGroup( )'));
     }
     $element =& $this->addRadio('option_type', ts('Survey Responses'), $optionTypes, array('onclick' => "showOptionSelect();"), '<br/>', TRUE);
     if (empty($optionGroups) || empty($this->_values['result_id'])) {
         $this->setdefaults(array('option_type' => 1));
     } elseif (!empty($this->_values['result_id'])) {
         $this->setdefaults(array('option_type' => 2, 'option_group_id' => $this->_values['result_id']));
     }
     // form fields of Custom Option rows
     $defaultOption = array();
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     $optionAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue');
     $optionAttributes['label']['size'] = $optionAttributes['value']['size'] = 25;
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         //the show hide blocks
         $showBlocks = 'optionField_' . $i;
         if ($i > 2) {
             $_showHide->addHide($showBlocks);
             if ($i == self::NUM_OPTION) {
                 $_showHide->addHide('additionalOption');
             }
         } else {
             $_showHide->addShow($showBlocks);
         }
         $this->add('text', 'option_label[' . $i . ']', ts('Label'), $optionAttributes['label']);
         // value
         $this->add('text', 'option_value[' . $i . ']', ts('Value'), $optionAttributes['value']);
         // weight
         $this->add('text', "option_weight[{$i}]", ts('Order'), $optionAttributes['weight']);
         $this->add('text', 'option_interval[' . $i . ']', ts('Recontact Interval'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
         $defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
     }
     //default option selection
     $this->addGroup($defaultOption, 'default_option');
     $_showHide->addToTemplate();
     $this->addElement('checkbox', 'create_report', ts('Create Report'));
     $this->addElement('text', 'report_title', ts('Report Title'));
     if ($this->_reportId) {
         $this->freeze('create_report');
         $this->freeze('report_title');
     }
     $this->addFormRule(array('CRM_Campaign_Form_Survey_Results', 'formRule'), $this);
     parent::buildQuickForm();
 }