/** * @param CRM_Core_Form $form */ public static function basic(&$form) { $form->addElement('hidden', 'hidden_basic', 1); // text for sort_name $form->addElement('text', 'target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $allRelationshipType = array(); $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE); $form->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $allRelationshipType, FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')); // relation status $relStatusOption = array(ts('Active'), ts('Inactive'), ts('All')); $form->addRadio('is_active', ts('Relationship Status'), $relStatusOption); $form->setDefaults(array('is_active' => 0)); CRM_Core_Form_Date::buildDateRange($form, 'start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); CRM_Core_Form_Date::buildDateRange($form, 'end_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable */ function buildForm(&$form) { $this->setTitle('Addresses needing attention'); /** * Define the search form fields here */ $search_types = array('2' => 'Street address missing a number', '3' => 'Has street address and postcode, but not city', '4' => 'Missing or invalid postcode', '5' => 'Missing state_province_id', '6' => 'Address contains punctuation', '8' => 'Country is missing, or is one that is often entered incorrectly', '9' => 'State does not match Country', '10' => 'Street Address contains "NCA" (NCA addresses are hidden from other searches)'); $form->addRadio('search_type', ts('Search options'), $search_types, array(), '<br />', TRUE); // Filter on Minimum Contact ID $form->add('text', 'min_contact_id', ts('Only show contact records with ID greater than:')); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('search_type', 'min_contact_id')); }
/** * Prepare a set of search fields * * @param CRM_Core_Form $form modifiable * @return void */ function buildForm(&$form) { $this->setTitle('Potential spam entries and names for fixing'); /** * Define the search form fields here */ $spam_options = array('1' => ts('First name equals last name'), '2' => ts('Names contain numbers'), '6' => ts('MiXEd cAsE LAsT namE'), '7' => ts('Non-Numeric Postcode (and address not known to be overseas)'), '8' => ts('Long or short Postcode'), '9' => ts('Long or short Phone Number'), '10' => ts('Unexpected Punctuation in Name')); $form->addRadio('spam_options', ts('Search options'), $spam_options, array(), '<br />', TRUE); // Text box for phone number length to test $form->add('text', 'min_length', ts('Shortest length of postcodes (default: 4) or phone numbers (default: 10)')); // Text box for phone number length to test $form->add('text', 'max_length', ts('Longest length of postcodes (default: 4) or phone numbers (default: 14)')); // Date for records added since $form->addDate('start_date', ts('Contact records added since'), FALSE, array('formatType' => 'custom')); // Filter on Minimum Contact ID $form->add('text', 'min_contact_id', ts('Only show contact records with ID greater than:')); // Filter out blank names $form->add('checkbox', 'blank_names', ts("Check to not display contacts whose first and last name are both blank")); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('spam_options', 'min_contact_id', 'blank_names', 'min_length', 'max_length')); }
/** * Build the form object. * * @param CRM_Core_Form $form * Form object. * * @return void */ public static function buildPCPForm($form) { $form->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages?'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','block','radio',false);")); $form->addElement('checkbox', 'is_approval_needed', ts('Approval required')); $profile = array(); $isUserRequired = NULL; $config = CRM_Core_Config::singleton(); if ($config->userFramework != 'Standalone') { $isUserRequired = 2; } CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array('title', 'is_active')); if (!empty($profiles)) { foreach ($profiles as $key => $value) { if ($value['is_active']) { $profile[$key] = $value['title']; } } $form->assign('profile', $profile); } $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), array('' => ts('- select -')) + $profile, TRUE); //CRM-15821 - To add new option for PCP "Owner" notification $ownerNotifications = CRM_Core_OptionGroup::values('pcp_owner_notify'); $form->addRadio('owner_notify_id', ts('Owner Email Notification'), $ownerNotifications, NULL, '<br/>', TRUE); $form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);")); $form->add('text', 'tellfriend_limit', ts("'Tell a friend' maximum recipients limit"), CRM_Core_DAO::getAttribute('CRM_PCP_DAO_PCPBlock', 'tellfriend_limit')); $form->addRule('tellfriend_limit', ts('Please enter a valid limit.'), 'integer'); $form->add('text', 'link_text', ts("'Create Personal Campaign Page' link text"), CRM_Core_DAO::getAttribute('CRM_PCP_DAO_PCPBlock', 'link_text')); $form->add('text', 'notify_email', ts('Notify Email'), CRM_Core_DAO::getAttribute('CRM_PCP_DAO_PCPBlock', 'notify_email')); }
/** * Build form. * * @param CRM_Core_Form $form */ public static function buildQuickForm(&$form) { // FIXME: this is using the following as keys rather than the standard numeric keys returned by CRM_Utils_Date $dayOfTheWeek = array(); $dayKeys = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); foreach (CRM_Utils_Date::getAbbrWeekdayNames() as $k => $label) { $dayOfTheWeek[$dayKeys[$k]] = $label; } $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, array('class' => 'required')); $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30); $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, array('class' => 'required')); $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime')); foreach ($dayOfTheWeek as $key => $val) { $startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val); } $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on')); $roptionTypes = array('1' => ts('day of the month'), '2' => ts('day of the week')); $form->addRadio('repeats_by', ts("Repeats by"), $roptionTypes, array('required' => TRUE), NULL); $form->add('select', 'limit_to', '', CRM_Core_SelectValues::getNumericOptions(1, 31)); $dayOfTheWeekNo = array('first' => ts('First'), 'second' => ts('Second'), 'third' => ts('Third'), 'fourth' => ts('Fourth'), 'last' => ts('Last')); $form->add('select', 'entity_status_1', '', $dayOfTheWeekNo); $form->add('select', 'entity_status_2', '', $dayOfTheWeek); $eoptionTypes = array('1' => ts('After'), '2' => ts('On')); $form->addRadio('ends', ts("Ends"), $eoptionTypes, array('class' => 'required'), NULL); // Offset options gets key=>val pairs like 1=>2 because the BAO wants to know the number of // children while it makes more sense to the user to see the total number including the parent. $offsetOptions = range(1, 30); unset($offsetOptions[0]); $form->add('select', 'start_action_offset', NULL, $offsetOptions, FALSE); $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule')); $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing')); $form->add('text', 'exclude_date_list', ts('Exclude Dates'), array('class' => 'twenty')); $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit')); $form->addButtons(array(array('type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); // For client-side pluralization $form->assign('recurringFrequencyOptions', array('single' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits()), 'plural' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits(2)))); }
/** * Build Pledge Block in Contribution Pages. * * @param CRM_Core_Form $form */ public static function buildPledgeBlock($form) { //build pledge payment fields. if (!empty($form->_values['pledge_id'])) { //get all payments required details. $allPayments = array(); $returnProperties = array('status_id', 'scheduled_date', 'scheduled_amount', 'currency', 'pledge_start_date'); CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $form->_values['pledge_id'], $allPayments, $returnProperties); // get all status $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $nextPayment = array(); $isNextPayment = FALSE; $overduePayments = array(); foreach ($allPayments as $payID => $value) { if ($allStatus[$value['status_id']] == 'Overdue') { $overduePayments[$payID] = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d')); } elseif (!$isNextPayment && $allStatus[$value['status_id']] == 'Pending') { // get the next payment. $nextPayment = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d')); $isNextPayment = TRUE; } } // build check box array for payments. $payments = array(); if (!empty($overduePayments)) { foreach ($overduePayments as $id => $payment) { $label = ts("%1 - due on %2 (overdue)", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $payment), CRM_Utils_Array::value('scheduled_amount_currency', $payment)), 2 => CRM_Utils_Array::value('scheduled_date', $payment))); $paymentID = CRM_Utils_Array::value('id', $payment); $payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $payment))); } } if (!empty($nextPayment)) { $label = ts("%1 - due on %2", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $nextPayment), CRM_Utils_Array::value('scheduled_amount_currency', $nextPayment)), 2 => CRM_Utils_Array::value('scheduled_date', $nextPayment))); $paymentID = CRM_Utils_Array::value('id', $nextPayment); $payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $nextPayment))); } // give error if empty or build form for payment. if (empty($payments)) { CRM_Core_Error::fatal(ts("Oops. It looks like there is no valid payment status for online payment.")); } else { $form->assign('is_pledge_payment', TRUE); $form->addGroup($payments, 'pledge_amount', ts('Make Pledge Payment(s):'), '<br />'); } } else { $pledgeBlock = self::getPledgeBlock($form->_id); // build form for pledge creation. $pledgeOptions = array('0' => ts('I want to make a one-time contribution'), '1' => ts('I pledge to contribute this amount every')); $form->addRadio('is_pledge', ts('Pledge Frequency Interval'), $pledgeOptions, NULL, array('<br/>')); $form->addElement('text', 'pledge_installments', ts('Installments'), array('size' => 3)); if (!empty($pledgeBlock['is_pledge_interval'])) { $form->assign('is_pledge_interval', CRM_Utils_Array::value('is_pledge_interval', $pledgeBlock)); $form->addElement('text', 'pledge_frequency_interval', NULL, array('size' => 3)); } else { $form->add('hidden', 'pledge_frequency_interval', 1); } // Frequency unit drop-down label suffixes switch from *ly to *(s) $freqUnitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlock['pledge_frequency_unit']); $freqUnits = array(); $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units'); foreach ($freqUnitVals as $key => $val) { if (array_key_exists($val, $frequencyUnits)) { $freqUnits[$val] = !empty($pledgeBlock['is_pledge_interval']) ? "{$frequencyUnits[$val]}(s)" : $frequencyUnits[$val]; } } $form->addElement('select', 'pledge_frequency_unit', NULL, $freqUnits); // CRM-18854 if (CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock)) { if (CRM_Utils_Array::value('pledge_start_date', $pledgeBlock)) { $defaults = array(); $date = (array) json_decode($pledgeBlock['pledge_start_date']); list($field, $value) = each($date); switch ($field) { case 'contribution_date': $form->addDate('start_date', ts('First installment payment')); $paymentDate = $value = date('d/m/Y'); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value); $form->assign('is_date', TRUE); break; case 'calendar_date': $form->addDate('start_date', ts('First installment payment')); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value); $form->assign('is_date', TRUE); $paymentDate = $value; break; case 'calendar_month': $month = CRM_Utils_Date::getCalendarDayOfMonth(); $form->add('select', 'start_date', ts('Day of month installments paid'), $month); $paymentDate = CRM_Pledge_BAO_Pledge::getPaymentDate($value); list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($paymentDate); break; default: break; } $form->setDefaults($defaults); $form->assign('start_date_display', $paymentDate); $form->assign('start_date_editable', FALSE); if (CRM_Utils_Array::value('is_pledge_start_date_editable', $pledgeBlock)) { $form->assign('start_date_editable', TRUE); if ($field == 'calendar_month') { $form->assign('is_date', FALSE); $form->setDefaults(array('start_date' => $value)); } } } } } }
/** * @param CRM_Core_Form $form */ public static function changeLog(&$form) { $form->add('hidden', 'hidden_changeLog', 1); // block for change log $form->addElement('text', 'changed_by', ts('Modified By'), NULL); $dates = array(1 => ts('Added'), 2 => ts('Modified')); $form->addRadio('log_date', NULL, $dates, array('allowClear' => TRUE), '<br />'); CRM_Core_Form_Date::buildDateRange($form, 'log_date', 1, '_low', '_high', ts('From'), FALSE, FALSE); }
/** * Build form for related contacts / on behalf of organization. * * @param CRM_Core_Form $form * */ public static function buildQuickForm(&$form) { $form->assign('fieldSetTitle', ts('Organization Details')); $form->assign('buildOnBehalfForm', TRUE); $contactID = $form->_contactID; if ($contactID && count($form->_employers) >= 1) { $form->add('text', 'organization_id', ts('Select an existing related Organization OR enter a new one')); $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $form->_employers)); $orgOptions = array(0 => ts('Select an existing organization'), 1 => ts('Enter a new organization')); $form->addRadio('org_option', ts('options'), $orgOptions); $form->setDefaults(array('org_option' => 0)); $form->add('checkbox', 'mode', ''); } $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); $fieldTypes = array('Contact', 'Organization'); $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); if (is_array($form->_membershipBlock) && !empty($form->_membershipBlock)) { $fieldTypes = array_merge($fieldTypes, array('Membership')); } else { $fieldTypes = array_merge($fieldTypes, array('Contribution')); } foreach ($profileFields as $name => $field) { if (in_array($field['field_type'], $fieldTypes)) { list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2); if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) { $field['is_required'] = 1; } CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, 'onbehalf'); } } $form->assign('onBehalfOfFields', $profileFields); $form->addElement('hidden', 'hidden_onbehalf_profile', 1); }
/** * @param CRM_Core_Form $form */ function buildForm(&$form) { $this->setTitle(ts('Include / Exclude Search')); $groups = CRM_Core_PseudoConstant::nestedGroup(); $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag')); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } $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); $andOr = array('1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR the Tags criteria')); $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE); $form->add('select', 'includeTags', ts('Include Tag(s)'), $tags, FALSE, $select2style); $form->add('select', 'excludeTags', ts('Exclude Tag(s)'), $tags, FALSE, $select2style); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); }
/** * Build Pledge Block in Contribution Pages. * * @param CRM_Core_Form $form */ public static function buildPledgeBlock($form) { //build pledge payment fields. if (!empty($form->_values['pledge_id'])) { //get all payments required details. $allPayments = array(); $returnProperties = array('status_id', 'scheduled_date', 'scheduled_amount', 'currency'); CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $form->_values['pledge_id'], $allPayments, $returnProperties); // get all status $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $nextPayment = array(); $isNextPayment = FALSE; $overduePayments = array(); $now = date('Ymd'); foreach ($allPayments as $payID => $value) { if ($allStatus[$value['status_id']] == 'Overdue') { $overduePayments[$payID] = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d')); } elseif (!$isNextPayment && $allStatus[$value['status_id']] == 'Pending') { // get the next payment. $nextPayment = array('id' => $payID, 'scheduled_amount' => CRM_Utils_Rule::cleanMoney($value['scheduled_amount']), 'scheduled_amount_currency' => $value['currency'], 'scheduled_date' => CRM_Utils_Date::customFormat($value['scheduled_date'], '%B %d')); $isNextPayment = TRUE; } } // build check box array for payments. $payments = array(); if (!empty($overduePayments)) { foreach ($overduePayments as $id => $payment) { $key = ts("%1 - due on %2 (overdue)", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $payment), CRM_Utils_Array::value('scheduled_amount_currency', $payment)), 2 => CRM_Utils_Array::value('scheduled_date', $payment))); $payments[$key] = CRM_Utils_Array::value('id', $payment); } } if (!empty($nextPayment)) { $key = ts("%1 - due on %2", array(1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $nextPayment), CRM_Utils_Array::value('scheduled_amount_currency', $nextPayment)), 2 => CRM_Utils_Array::value('scheduled_date', $nextPayment))); $payments[$key] = CRM_Utils_Array::value('id', $nextPayment); } // give error if empty or build form for payment. if (empty($payments)) { CRM_Core_Error::fatal(ts("Oops. It looks like there is no valid payment status for online payment.")); } else { $form->assign('is_pledge_payment', TRUE); $form->addCheckBox('pledge_amount', ts('Make Pledge Payment(s):'), $payments); } } else { $pledgeBlock = self::getPledgeBlock($form->_id); // build form for pledge creation. $pledgeOptions = array('0' => ts('I want to make a one-time contribution'), '1' => ts('I pledge to contribute this amount every')); $form->addRadio('is_pledge', ts('Pledge Frequency Interval'), $pledgeOptions, NULL, array('<br/>')); $form->addElement('text', 'pledge_installments', ts('Installments'), array('size' => 3)); if (!empty($pledgeBlock['is_pledge_interval'])) { $form->assign('is_pledge_interval', CRM_Utils_Array::value('is_pledge_interval', $pledgeBlock)); $form->addElement('text', 'pledge_frequency_interval', NULL, array('size' => 3)); } else { $form->add('hidden', 'pledge_frequency_interval', 1); } // Frequency unit drop-down label suffixes switch from *ly to *(s) $freqUnitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $pledgeBlock['pledge_frequency_unit']); $freqUnits = array(); $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units'); foreach ($freqUnitVals as $key => $val) { if (array_key_exists($val, $frequencyUnits)) { $freqUnits[$val] = !empty($pledgeBlock['is_pledge_interval']) ? "{$frequencyUnits[$val]}(s)" : $frequencyUnits[$val]; } } $form->addElement('select', 'pledge_frequency_unit', NULL, $freqUnits); } }