function buildForm(&$form)
 {
     $form->add('text', 'sort_name', ts('Contact Name'), true);
     $form->add('text', 'street_number', ts('Street Number'), true);
     $form->add('text', 'street_address', ts('Street Address'), true);
     $form->add('text', 'city', ts('City'), true);
     $surveys = CRM_Campaign_BAO_Survey::getSurveyList();
     $form->add('select', 'survey_id', ts('Survey'), array('' => ts('- select -')) + $surveys);
     $form->add('checkbox', 'status_id', ts('Is Held'), null, false);
     $form->assign('elements', array('sort_name', 'street_number', 'street_address', 'city', 'status_id', 'survey_id'));
     $this->setTitle('Find Voters');
 }
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     $surveys = CRM_Campaign_BAO_Survey::getSurveyList();
     $this->add('select', 'survey_id', ts('Survey'), array('' => ts('- select -')) + $surveys, true);
     $this->addDefaultButtons(ts('Add Voter Reservation'));
 }
Exemple #3
0
 /**
  * add all the elements shared between case activity search  and advanaced search
  *
  * @access public 
  * @return void
  * @static
  */
 static function buildSearchForm(&$form)
 {
     $activityOptions = CRM_Core_PseudoConstant::activityType(true, true, false, 'label', true);
     asort($activityOptions);
     foreach ($activityOptions as $activityID => $activity) {
         $form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", null, $activity, array('onClick' => 'showCustomData( this.id );'));
     }
     $form->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate'));
     $form->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate'));
     $activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to'));
     $form->addRadio('activity_role', null, $activityRoles, null, '<br />');
     $form->setDefaults(array('activity_role' => 1));
     $form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     foreach ($activityStatus as $activityStatusID => $activityStatusName) {
         $activity_status[] = HTML_QuickForm::createElement('checkbox', $activityStatusID, null, $activityStatusName);
     }
     $form->addGroup($activity_status, 'activity_status', ts('Activity Status'));
     $form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
     $form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $form->addElement('checkbox', 'activity_test', ts('Find Test Activities?'));
     require_once 'CRM/Core/BAO/Tag.php';
     $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
     if ($activity_tags) {
         foreach ($activity_tags as $tagID => $tagName) {
             $form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", null, $tagName);
         }
     }
     require_once 'CRM/Campaign/BAO/Survey.php';
     $surveys = array('' => ts('- none -')) + CRM_Campaign_BAO_Survey::getSurveyList();
     $form->add('select', 'activity_survey_id', ts('Survey'), $surveys, false);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $extends = array('Activity');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends);
     if ($groupDetails) {
         require_once 'CRM/Core/BAO/CustomField.php';
         $form->assign('activityGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
             }
         }
     }
 }
Exemple #4
0
 function validateIds()
 {
     $errorMessages = array();
     //check for required permissions.
     if (!CRM_Core_Permission::check('manage campaign') && !CRM_Core_Permission::check('administer CiviCampaign') && !CRM_Core_Permission::check("{$this->_searchVoterFor} campaign contacts")) {
         $errorMessages[] = ts('You are not authorized to access this page.');
     }
     require_once 'CRM/Campaign/BAO/Survey.php';
     $surveys = CRM_Campaign_BAO_Survey::getSurveyList();
     if (empty($surveys)) {
         $errorMessages[] = ts("Oops, It looks like there is no survey created. <a href='%1'>Click here to create new.</a>", array(1 => CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')));
     }
     if ($this->_force && !$this->_surveyId) {
         $errorMessages[] = ts('Could not find Survey.');
     }
     $this->assign('errorMessages', empty($errorMessages) ? false : $errorMessages);
 }
Exemple #5
0
    /**
     * add all the elements shared between,
     * normal voter search and voter listing (GOTV form)
     *
     * @access public 
     * @return void
     * @static
     */
    static function buildSearchForm(&$form)
    {
        require_once 'CRM/Campaign/BAO/Survey.php';
        $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
        $className = CRM_Utils_System::getClassName($form);
        $form->add('text', 'sort_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
        $form->add('text', 'street_name', ts('Street Name'), $attributes['street_name']);
        $form->add('text', 'street_number', ts('Street Number'), $attributes['street_number']);
        $form->add('text', 'street_unit', ts('Street Unit'), $attributes['street_unit']);
        $form->add('text', 'street_address', ts('Street Address'), $attributes['street_address']);
        $form->add('text', 'city', ts('City'), $attributes['city']);
        $form->add('text', 'postal_code', ts('Zip / Postal Code'), $attributes['postal_code']);
        $showInterviewer = false;
        if (CRM_Core_Permission::check('administer CiviCampaign')) {
            $showInterviewer = true;
        }
        $form->assign('showInterviewer', $showInterviewer);
        if ($showInterviewer || $className == 'CRM_Campaign_Form_Gotv') {
            //autocomplete url
            $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1', false, null, false);
            $form->assign('dataUrl', $dataUrl);
            $form->add('text', 'survey_interviewer_name', ts('Select Interviewer'));
            $form->add('hidden', 'survey_interviewer_id', '', array('id' => 'survey_interviewer_id'));
            $userId = null;
            if (isset($form->_interviewerId) && $form->_interviewerId) {
                $userId = $form->_interviewerId;
            }
            if (!$userId) {
                $session = CRM_core_Session::singleton();
                $userId = $session->get('userID');
            }
            if ($userId) {
                $defaults = array();
                $defaults['survey_interviewer_id'] = $userId;
                $defaults['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userId, 'sort_name', 'id');
                $form->setDefaults($defaults);
            }
        }
        //build ward and precinct custom fields.
        $query = '
    SELECT  fld.id, fld.label 
      FROM  civicrm_custom_field fld 
INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
     WHERE  grp.name = %1';
        $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('Voter_Info', 'String')));
        $customSearchFields = array();
        require_once 'CRM/Core/BAO/CustomField.php';
        while ($dao->fetch()) {
            foreach (array('ward', 'precinct') as $name) {
                if (stripos($name, $dao->label) !== false) {
                    $fieldId = $dao->id;
                    $fieldName = 'custom_' . $dao->id;
                    $customSearchFields[$name] = $fieldName;
                    CRM_Core_BAO_CustomField::addQuickFormElement($form, $fieldName, $fieldId, false, false);
                    break;
                }
            }
        }
        $form->assign('customSearchFields', $customSearchFields);
        $surveys = CRM_Campaign_BAO_Survey::getSurveyList();
        if (empty($surveys) && $className == 'CRM_Campaign_Form_Search') {
            CRM_Core_Error::statusBounce(ts('Could not find survey for %1 respondents.', array(1 => $form->get('op'))), CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
        }
        $form->add('select', 'campaign_survey_id', ts('Survey'), $surveys, true);
    }