/**
  * @param CRM_Core_Form $form
  *
  * @return array
  */
 public static function process(&$form)
 {
     if ($form->getVar('_surveyId') <= 0) {
         return NULL;
     }
     $tabs = array('main' => array('title' => ts('Main Information'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'questions' => array('title' => ts('Questions'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'results' => array('title' => ts('Results'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE));
     $surveyID = $form->getVar('_surveyId');
     $class = $form->getVar('_name');
     $class = CRM_Utils_String::getClassName($class);
     $class = strtolower($class);
     if (array_key_exists($class, $tabs)) {
         $tabs[$class]['current'] = TRUE;
         $qfKey = $form->get('qfKey');
         if ($qfKey) {
             $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
         }
     }
     if ($surveyID) {
         $reset = !empty($_GET['reset']) ? 'reset=1&' : '';
         foreach ($tabs as $key => $value) {
             if (!isset($tabs[$key]['qfKey'])) {
                 $tabs[$key]['qfKey'] = NULL;
             }
             $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/survey/configure/{$key}", "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}");
             $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
         }
     }
     return $tabs;
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Multiple Value Custom Group Search and Export');
     $form->add('text', 'sort_name', ts('Contact Name'), TRUE);
     // add select for contact type
     //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
     // this is loaded onto then replace with something like '__' & test
     $separator = CRM_Core_DAO::VALUE_SEPARATOR;
     $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes, array('class' => 'crm-select2 huge'));
     // add select for groups
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
     $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
     // add select for tags
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
     if (empty($this->_groupTree)) {
         CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'));
     }
     // add the checkbox for custom_groups
     foreach ($this->_groupTree as $groupID => $group) {
         if ($groupID == 'info') {
             continue;
         }
         $form->addElement('checkbox', "custom_group[{$groupID}]", NULL, $group['title']);
     }
 }
/**
* Implements CiviCRM 'buildForm' hook.
*
* @param string $formName Name of current form.
* @param CRM_Core_Form $form Current form.
*/
function Paytrail_civicrm_buildForm($formName, &$form)
{
    //Confirm Contribution
    if ($form instanceof CRM_Contribute_Form_Contribution_Confirm) {
        $paymentHelper = new PaytrailPaymentHelper();
        if (!$paymentHelper->isEmbeddedButtonsEnabled()) {
            return;
        }
        //Get form params to get customer contact info and product info
        $component = "contribute";
        $params = $form->get("params");
        $params['item_name'] = $form->_values['title'];
        $paymentHelper->embeddPaymentButtons($params, $component);
    } else {
        if ($form instanceof CRM_Event_Form_Registration_Confirm) {
            $paymentHelper = new PaytrailPaymentHelper();
            if (!$paymentHelper->isEmbeddedButtonsEnabled()) {
                return;
            }
            //Get form params to get customer contact info and product info
            $component = "event";
            $formParamsArray = $form->get("params");
            $params = $formParamsArray[0];
            $params['item_name'] = $form->_values['event']['title'];
            $paymentHelper->embeddPaymentButtons($params, $component);
        }
    }
}
 public function addElements(CRM_Core_Form &$form)
 {
     $form->add('select', 'XWeekDay_week_offset', ts('Offset'), $this->getWeekOffset());
     $form->add('select', 'XWeekDay_day', ts('Days'), $this->getDays());
     $form->add('text', 'XWeekDay_time_hour', ts('Time (hour)'));
     $form->add('text', 'XWeekDay_time_minute', ts('Time (minute)'));
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Find Latest Activities');
     /**
      * Define the search form fields here
      */
     // Allow user to choose which type of contact to limit search on
     $form->add('select', 'contact_type', ts('Find...'), CRM_Core_SelectValues::contactType());
     // Text box for Activity Subject
     $form->add('text', 'activity_subject', ts('Activity Subject'));
     // Select box for Activity Type
     $activityType = array('' => ' - select activity - ') + CRM_Core_PseudoConstant::activityType();
     $form->add('select', 'activity_type_id', ts('Activity Type'), $activityType, FALSE);
     // textbox for Activity Status
     $activityStatus = array('' => ' - select status - ') + CRM_Core_PseudoConstant::activityStatus();
     $form->add('select', 'activity_status_id', ts('Activity Status'), $activityStatus, FALSE);
     // Activity Date range
     $form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
     // Contact Name field
     $form->add('text', 'sort_name', ts('Contact Name'));
     /**
      * If you are using the sample template, this array tells the template fields to render
      * for the search form.
      */
     $form->assign('elements', array('contact_type', 'activity_subject', 'activity_type_id', 'activity_status_id', 'start_date', 'end_date', 'sort_name'));
 }
Example #6
0
 /**
  * Build the form object elements for Demographics object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  */
 public static function buildQuickForm(&$form)
 {
     $form->addField('gender_id', array('entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE));
     $form->addField('birth_date', array('entity' => 'contact', 'formatType' => 'birth'));
     $form->addField('is_deceased', array('entity' => 'contact', 'label' => ts('Contact is Deceased'), 'onclick' => "showDeceasedDate()"));
     $form->addField('deceased_date', array('entity' => 'contact', 'formatType' => 'birth'));
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $config = CRM_Core_Config::singleton();
     $countryDefault = $config->defaultContactCountry;
     $form->add('text', 'distance', ts('Distance'), NULL, TRUE);
     $proxUnits = array('km' => ts('km'), 'miles' => ts('miles'));
     $form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, TRUE);
     $form->add('text', 'street_address', ts('Street Address'));
     $form->add('text', 'city', ts('City'));
     $form->add('text', 'postal_code', ts('Postal Code'));
     $defaults = array();
     if ($countryDefault) {
         $defaults['country_id'] = $countryDefault;
     }
     $form->addChainSelect('state_province_id');
     $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
     $form->add('select', 'country_id', ts('Country'), $country, TRUE, array('class' => 'crm-select2'));
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
     $form->addElement('select', 'group', ts('Group'), $group, array('class' => 'crm-select2 huge'));
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tag'), $tag, array('class' => 'crm-select2 huge'));
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Proximity Search');
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('distance', 'prox_distance_unit', 'street_address', 'city', 'postal_code', 'country_id', 'state_province_id', 'group', 'tag'));
 }
Example #8
0
 /**
  * Function used to build form element for soft credit block.
  *
  * @param CRM_Core_Form $form
  *
  * @return \CRM_Core_Form
  */
 public static function buildQuickForm(&$form)
 {
     if (!empty($form->_honor_block_is_active)) {
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = 'soft_credit';
         $ufJoinDAO->entity_id = $form->_id;
         if ($ufJoinDAO->find(TRUE)) {
             $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
             if ($jsonData) {
                 foreach (array('honor_block_title', 'honor_block_text') as $name) {
                     $form->assign($name, $jsonData[$name]);
                 }
                 $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
                 // radio button for Honor Type
                 foreach ($jsonData['soft_credit_types'] as $value) {
                     $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
                 }
                 $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
             }
         }
         return $form;
     }
     // by default generate 10 blocks
     $item_count = 11;
     $showSoftCreditRow = 2;
     if ($form->getAction() & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
     } elseif (!empty($form->_pledgeID)) {
         //Check and select most recent completed contrubtion and use it to retrieve
         //soft-credit information to use as default for current pledge payment, CRM-13981
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
         foreach ($pledgePayments as $id => $record) {
             if ($record['contribution_id']) {
                 $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
                 if ($record['status'] == 'Completed' && count($softCredits) > 0) {
                     $form->_softCreditInfo = $softCredits;
                 }
             }
         }
     }
     if (property_exists($form, "_softCreditInfo")) {
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
         $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         $form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     self::addPCPFields($form);
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
 }
 /**
  * @param CRM_Core_Form $form
  */
 public static function buildQuickForm(&$form)
 {
     $form->removeElement('status_id');
     $form->removeElement('priority_id');
     $caseId = CRM_Utils_Array::first($form->_caseId);
     $currentStartDate = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'start_date');
     $form->assign('current_start_date', $currentStartDate);
     $form->addDate('start_date', ts('New Start Date'), FALSE, array('formatType' => 'activityDateTime'));
 }
Example #10
0
 /**
  * Common pre-process function.
  *
  * @param CRM_Core_Form $form
  * @param bool $useTable
  */
 public static function preProcessCommon(&$form, $useTable = FALSE)
 {
     $form->_activityHolderIds = array();
     $values = $form->controller->exportValues($form->get('searchFormName'));
     $form->_task = $values['task'];
     $activityTasks = CRM_Activity_Task::tasks();
     $form->assign('taskName', $activityTasks[$form->_task]);
     $ids = array();
     if ($values['radio_ts'] == 'ts_sel') {
         foreach ($values as $name => $value) {
             if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
                 $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
             }
         }
     } else {
         $queryParams = $form->get('queryParams');
         $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_ACTIVITY);
         $query->_distinctComponentClause = '( civicrm_activity.id )';
         $query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
         // CRM-12675
         $activityClause = NULL;
         $components = CRM_Core_Component::getNames();
         $componentClause = array();
         foreach ($components as $componentID => $componentName) {
             if (!CRM_Core_Permission::check("access {$componentName}")) {
                 $componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
             }
         }
         if (!empty($componentClause)) {
             $activityClause = implode(' AND ', $componentClause);
         }
         $result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
         while ($result->fetch()) {
             if (!empty($result->activity_id)) {
                 $ids[] = $result->activity_id;
             }
         }
     }
     if (!empty($ids)) {
         $form->_componentClause = ' civicrm_activity.id IN ( ' . implode(',', $ids) . ' ) ';
         $form->assign('totalSelectedActivities', count($ids));
     }
     $form->_activityHolderIds = $form->_componentIds = $ids;
     // Set the context for redirection for any task actions.
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $session = CRM_Core_Session::singleton();
     $searchFormName = strtolower($form->get('searchFormName'));
     if ($searchFormName == 'search') {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/activity/search', $urlParams));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams));
     }
 }
Example #11
0
 /**
  * Process the form after the input has been submitted and validated.
  * @todo this is horrible copy & paste code because there is so much risk of breakage
  * in fixing the existing pdfLetter classes to be suitably generic
  *
  * @param CRM_Core_Form $form
  * @param $membershipIDs
  * @param $skipOnHold
  * @param $skipDeceased
  * @param $contactIDs
  */
 public static function postProcessMembers(&$form, $membershipIDs, $skipOnHold, $skipDeceased, $contactIDs)
 {
     $formValues = $form->controller->exportValues($form->getName());
     list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
     $html = self::generateHTML($membershipIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $html_message, $categories);
     self::createActivities($form, $html_message, $contactIDs);
     CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
     $form->postProcessHook();
     CRM_Utils_System::civiExit(1);
 }
Example #12
0
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(FALSE);
     $form->addElement('select', 'group_id', ts('Group'), $groups, array('class' => 'crm-select2 huge'));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('group_id'));
 }
Example #13
0
 /**
  * build the form elements for a phone object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param int           $addressBlockCount block number to build
  * @param boolean       $blockEdit         is it block edit
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //phone type select
     $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
     //main phone number with crm_phone class
     $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve')));
     // phone extension
     $form->addElement('text', "phone[{$blockId}][phone_ext]", ts('Extension'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone_ext'));
     if (isset($form->_contactType) || $blockEdit) {
         //Block type select
         $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'));
         //is_Primary radio
         $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js);
     }
     // TODO: set this up as a group, we need a valid phone_type_id if we have a  phone number
     // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' );
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Find Contributors by Aggregate Totals');
     /**
      * Define the search form fields here
      */
     $form->add('text', 'min_amount', ts('Aggregate Total Between $'));
     $form->addRule('min_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
     $form->add('text', 'max_amount', ts('...and $'));
     $form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
     $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
     $financial_types = CRM_Contribute_PseudoConstant::financialType();
     foreach ($financial_types as $financial_type_id => $financial_type) {
         $form->addElement('checkbox', "financial_type_id[{$financial_type_id}]", 'Financial Type', $financial_type);
     }
     /**
      * If you are using the sample template, this array tells the template fields to render
      * for the search form.
      */
     $form->assign('elements', array('min_amount', 'max_amount', 'start_date', 'end_date', 'financial_type_id'));
 }
Example #15
0
 /**
  * Prepare a set of search fields
  *
  * @param CRM_Core_Form $form modifiable
  * @return void
  */
 function buildForm(&$form)
 {
     CRM_Utils_System::setTitle(ts('Find Post Code'));
     $form->add('text', 'post_code', 'Post Code');
     $form->add('select', 'post_city', 'Post City', $this->citiesList);
     $defaults = $this->retrieveDefaultValues();
     if (!empty($defaults)) {
         $form->setDefaults($defaults);
     }
     $form->assign('elements', array('post_code', 'post_city'));
 }
 /**
  * build the form elements for Demographics object
  *
  * @param CRM_Core_Form $form       reference to the form object
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     // radio button for gender
     $genderOptions = array();
     $gender = CRM_Core_PseudoConstant::gender();
     foreach ($gender as $key => $var) {
         $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
     }
     $form->addGroup($genderOptions, 'gender_id', ts('Gender'));
     $form->addDate('birth_date', ts('Date of birth'), false, array('formatType' => 'birth'));
     $form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'), array('onclick' => "showDeceasedDate()"));
     $form->addDate('deceased_date', ts('Deceased date'), false, array('formatType' => 'birth'));
 }
Example #17
0
 /**
  * This function provides the HTML form elements.
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $contactID
  */
 public static function buildQuickForm(&$form, $contactID)
 {
     // We provide a value for oplock_ts to client, but JS uses it carefully
     // -- i.e.  when loading the first inline form, JS copies oplock_ts to a
     // global value, and that global value is used for future form submissions.
     // Any time a form is submitted, the value will be updated.  This
     // handles cases like:
     // - V1:open V1.phone:open V1.email:open V1.email:submit V1.phone:submit
     // - V1:open E1:open E1:submit V1.email:open V1.email:submit
     // - V1:open V1.email:open E1:open E1:submit V1.email:submit V1:lock
     $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID);
     $form->addElement('hidden', 'oplock_ts', $timestamps['modified_date'], array('id' => 'oplock_ts'));
     $form->addFormRule(array('CRM_Contact_Form_Inline_Lock', 'formRule'), $contactID);
 }
Example #18
0
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $form->add('text', 'postal_code_low', ts('Postal Code Start'), TRUE);
     $form->add('text', 'postal_code_high', ts('Postal Code End'), TRUE);
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Zip Code Range Search');
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('postal_code_low', 'postal_code_high'));
 }
Example #19
0
 /**
  * Prepare a set of search fields
  *
  * @param CRM_Core_Form $form modifiable
  * @return void
  */
 function buildForm(&$form)
 {
     CRM_Utils_System::setTitle(ts('My Search Title'));
     $form->add('text', 'household_name', ts('Household Name'), TRUE);
     $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
     $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
     // Optionally define default search values
     $form->setDefaults(array('household_name' => '', 'state_province_id' => NULL));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('household_name', 'state_province_id'));
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $form->add('text', 'segmentSize', ts('Segment Size'), TRUE);
     $groups = CRM_Core_PseudoConstant::nestedGroup();
     $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'));
     $form->add('select', 'includeGroups', ts('Include Group(s)'), $groups, FALSE, $select2style);
     $form->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style);
     $this->setTitle('Create a random segment of contacts');
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('segmentSize', 'includeGroups', 'excludeGroups'));
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function appendQuickForm(&$form)
 {
     $textarea_size = array('size' => 30, 'maxlength' => 60);
     $form->add('text', $this->email_field_name(), ts('Email Address'), $textarea_size, TRUE);
     list($custom_fields_pre, $custom_fields_post) = $this->get_participant_custom_data_fields($this->participant->event_id);
     foreach ($custom_fields_pre as $key => $field) {
         CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, $this->participant->id);
     }
     foreach ($custom_fields_post as $key => $field) {
         CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, $this->participant->id);
     }
     $custom = CRM_Utils_Array::value('custom', $form->getTemplate()->_tpl_vars, array());
     $form->assign('custom', array_merge($custom, array($this->html_field_name('customPre') => $custom_fields_pre, $this->html_field_name('customPost') => $custom_fields_post, $this->html_field_name('number') => $this->name())));
 }
Example #22
0
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Find Totals for Events');
     /**
      * Define the search form fields here
      */
     $form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments'));
     $form->addElement('checkbox', 'show_payees', ts('Show payees'));
     $event_type = CRM_Core_OptionGroup::values('event_type', FALSE);
     foreach ($event_type as $eventId => $eventName) {
         $form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName);
     }
     $events = CRM_Event_BAO_Event::getEvents(1);
     $form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events);
     $form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
     /**
      * If you are using the sample template, this array tells the template fields to render
      * for the search form.
      */
     $form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id'));
 }
Example #23
0
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  *
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         // Fixme: dear god why? these come out in a format that is NOT the name of the fields.
         foreach ($nameFields as &$fix) {
             $fix = str_replace(' ', '_', strtolower($fix));
             if ($fix == 'prefix' || $fix == 'suffix') {
                 // God, why god?
                 $fix .= '_id';
             }
         }
         foreach ($nameFields as $name) {
             $props = array();
             if ($name == 'prefix_id' || $name == 'suffix_id') {
                 $options = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name);
                 // Skip if we have no options available
                 if (!CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name)) {
                     //continue;
                 }
                 $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix'));
             }
             $form->addField($name, $props);
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addField('nick_name');
         // job title
         // override the size for UI to look better
         $form->addField('job_title', array('size' => '30'));
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addField('employer_id', $props);
         $form->addField('contact_source', array('class' => 'big'));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->addField('external_identifier', array('label' => 'External ID'));
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form form object
  * @param int $inlineEditMode ( 1 for contact summary
  * top bar form and 2 for display name edit )
  *
  * @access public
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' '));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' '));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
         // job title
         // override the size for UI to look better
         $attributes['job_title']['size'] = 30;
         $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
         //Current Employer Element
         $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE);
         $form->assign('employerDataURL', $employerDataURL);
         $form->addElement('text', 'current_employer', ts('Current Employer'), '');
         $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == null) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         $config = CRM_Core_Config::singleton();
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     foreach ($this->_amounts as $name => $title) {
         $form->add('text', $name, $title);
     }
     foreach ($this->_dates as $name => $title) {
         $form->addDate($name, $title, FALSE, array('formatType' => 'custom'));
     }
     foreach ($this->_checkboxes as $name => $title) {
         $form->add('checkbox', $name, $title);
     }
     $this->setTitle('Contributions made in Year X and not Year Y');
     // @TODO: Decide on better names for "Exclusion"
     // @TODO: Add rule to ensure that exclusion dates are not in the inclusion range
 }
Example #26
0
 /**
  * Prepare a set of search fields
  *
  * @param CRM_Core_Form $form modifiable
  * @return void
  */
 function buildForm(&$form)
 {
     CRM_Utils_System::setTitle(ts('Search for Players on Teams'));
     $form->add('text', 'contact_id', ts('Player ID'), TRUE);
     $form->add('text', 'group_id', ts('Team ID'), TRUE);
     //$team = array('' => ts('- any team -')) + CRM_Core_PseudoConstant::stateProvince();
     //$form->addElement('select', 'group_id', ts('Team'), $team);
     // Optionally define default search values
     $form->setDefaults(array('contact_id' => '', 'group_id' => NULL));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('contact_id', 'group_id'));
 }
Example #27
0
 /**
  * Build form.
  *
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $form->add('text', 'household_name', ts('Household Name'), TRUE);
     $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
     $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle(ts('My Search Title'));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('household_name', 'state_province_id'));
 }
Example #28
0
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  *
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
         // job title
         // override the size for UI to look better
         $attributes['job_title']['size'] = 30;
         $form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addEntityRef('employer_id', ts('Current Employer'), $props);
         $attributes['source']['class'] = 'big';
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         $config = CRM_Core_Config::singleton();
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
Example #29
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm($check = FALSE)
 {
     parent::buildQuickForm();
     $timeRange = CRM_Booking_Utils_DateTime::createTimeRange("00:00", "24:00");
     $timeOptions = array();
     foreach ($timeRange as $key => $time) {
         $option = date('G:i', $time);
         $timeOptions[$option] = $option;
     }
     $this->add('select', 'day_start_at', ts('Day starts at'), $timeOptions, FALSE, array());
     $this->add('select', 'day_end_at', ts('Day ends at'), $timeOptions, FALSE, array());
     /*
         $this->add('select', 'time_period', ts('Time period'),
           array(10 => '10', 15 => '15', 20 => '20', 30 => '30', 60 => '60'),
           FALSE,
           array()
         );*/
     $this->add('text', 'cc_email_address', ts('CC'), array('size' => 50, 'maxlength' => 255), FALSE);
     $this->add('text', 'bcc_email_address', ts('BCC'), array('size' => 50, 'maxlength' => 255), FALSE);
     $this->add('checkbox', 'log_confirmation_email', ts('Log email?'));
     $this->add('checkbox', 'unlimited_resource_time_config', ts(''));
     $this->add('text', 'slot_new_colour', ts('New Slot Colour'));
     $this->add('text', 'slot_being_edited_colour', ts('Slot Editing Colour'));
     $this->add('text', 'slot_booked_colour', ts('Booked Slot Colour'));
     $this->add('text', 'slot_provisional_colour', ts('Provisional Slot Colour'));
     $this->addFormRule(array('CRM_Admin_Form_Preferences_Booking', 'formRule'), $this);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE)));
 }
Example #30
0
 public function preProcess()
 {
     parent::preProcess();
     $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Integer', $this, FALSE, NULL, 'REQUEST');
     // ensure that there is a destination, if not set the destination to the
     // referrer string
     if (!$this->controller->getDestination()) {
         $this->controller->setDestination(NULL, TRUE);
     }
     if ($this->_groupID) {
         $groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
         // make sure requested qroup is accessible and exists
         $query = "\nSELECT   title, description\n  FROM   civicrm_group\n WHERE   id={$this->_groupID}\n   AND   visibility != 'User and User Admin Only'\n   AND   {$groupTypeCondition}";
         $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
         if ($dao->fetch()) {
             $this->assign('groupName', $dao->title);
             CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', array(1 => $dao->title)));
         } else {
             CRM_Core_Error::statusBounce("The specified group is not configured for this action OR The group doesn't exist.");
         }
         $this->assign('single', TRUE);
     } else {
         $this->assign('single', FALSE);
         CRM_Utils_System::setTitle(ts('Mailing List Subscription'));
     }
 }