本文整理汇总了PHP中CRM_Core_BAO_CustomField::addQuickFormElement方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::addQuickFormElement方法的具体用法?PHP CRM_Core_BAO_CustomField::addQuickFormElement怎么用?PHP CRM_Core_BAO_CustomField::addQuickFormElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::addQuickFormElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildSearchForm
/**
* add all the elements shared between,
* normal voter search and voter listing (GOTV form)
*
* @access public
*
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
$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']);
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$groups = CRM_Core_PseudoConstant::group();
$form->add('select', 'group', ts('Groups'), $groups, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$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('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();
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::getSurveys();
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'));
}
//CRM-7406 --
//If survey had associated campaign and
//campaign has some contact groups, don't
//allow to search the contacts those are not
//in given campaign groups ( ie not in constituents )
$groupJs = NULL;
if ($form->get('searchVoterFor') == 'reserve') {
$groupJs = array('onChange' => "buildCampaignGroups( );return false;");
}
$form->add('select', 'campaign_survey_id', ts('Survey'), $surveys, TRUE, $groupJs);
}
示例2: buildSearchForm
/**
* Add all the elements shared between contribute search and advnaced search.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildSearchForm(&$form)
{
// Added contribution source
$form->addElement('text', 'contribution_source', ts('Contribution Source'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'source'));
CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE);
$form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
// Adding select option for curreny type -- CRM-4711
$form->add('select', 'contribution_currency_type', ts('Currency Type'), array('' => ts('- any -')) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name')), FALSE, array('class' => 'crm-select2'));
// CRM-13848
$form->addSelect('financial_type_id', array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search'));
$form->add('select', 'contribution_page_id', ts('Contribution Page'), array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::contributionPage(), FALSE, array('class' => 'crm-select2'));
$form->addSelect('payment_instrument_id', array('entity' => 'contribution', 'label' => ts('Payment Method'), 'option_url' => NULL, 'placeholder' => ts('- any -')));
$form->add('select', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::pcPage(), FALSE, array('class' => 'crm-select2'));
$status = array();
$statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status');
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
unset($statusValues['5'], $statusValues['6']);
$form->addSelect('contribution_status_id', array('entity' => 'contribution', 'multiple' => 'multiple', 'label' => ts('Contribution Status(s)'), 'option_url' => NULL, 'placeholder' => ts('- any -')));
// Add fields for thank you and receipt
$form->addYesNo('contribution_thankyou_date_is_not_null', ts('Thank-you sent?'), TRUE);
$form->addYesNo('contribution_receipt_date_is_not_null', ts('Receipt sent?'), TRUE);
$form->addYesNo('contribution_pay_later', ts('Contribution is Pay Later?'), TRUE);
$form->addYesNo('contribution_recurring', ts('Contribution is Recurring?'), TRUE);
// Recurring contribution fields
foreach (self::getRecurringFields() as $key => $label) {
CRM_Core_Form_Date::buildDateRange($form, $key, 1, '_low', '_high');
// If data has been entered for a recurring field, tell the tpl layer to open the pane
if (!empty($form->_formValues[$key . '_relative']) || !empty($form->_formValues[$key . '_low']) || !empty($form->_formValues[$key . '_high'])) {
$form->assign('contribution_recur_pane_open', TRUE);
}
}
$form->addYesNo('contribution_test', ts('Contribution is a Test?'), TRUE);
// Add field for transaction ID search
$form->addElement('text', 'contribution_trxn_id', ts("Transaction ID"));
$form->addElement('text', 'contribution_check_number', ts('Check Number'));
// Add field for pcp display in roll search
$form->addYesNo('contribution_pcp_display_in_roll', ts('Personal Campaign Page Honor Roll?'), TRUE);
// Soft credit related fields
$options = array('only_contribs' => ts('Contributions Only'), 'only_scredits' => ts('Soft Credits Only'), 'both_related' => ts('Soft Credits with related Hard Credit'), 'both' => ts('Both'));
$form->add('select', 'contribution_or_softcredits', ts('Contributions OR Soft Credits?'), $options, FALSE, array('class' => "crm-select2"));
$form->addSelect('contribution_soft_credit_type_id', array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'multiple' => TRUE, 'context' => 'search'));
// Add all the custom searchable fields
$contribution = array('Contribution');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $contribution);
if ($groupDetails) {
$form->assign('contributeGroupTree', $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);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'contribution_campaign_id');
// Add batch select
$batches = CRM_Contribute_PseudoConstant::batch();
if (!empty($batches)) {
$form->add('select', 'contribution_batch_id', ts('Batch Name'), array('' => ts('- any -')) + $batches, FALSE, array('class' => 'crm-select2'));
}
$form->assign('validCiviContribute', TRUE);
$form->setDefaults(array('contribution_test' => 0));
}
示例3: buildSearchForm
/**
* Build the search form.
*
* @param CRM_Core_Form $form
*/
public static function buildSearchForm(&$form)
{
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
$form->add('select', 'membership_status_id', ts('Membership Status(s)'), $membershipStatus, FALSE, array('id' => 'membership_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$form->addEntityRef('membership_type_id', ts('Membership Type(s)'), array('entity' => 'MembershipType', 'multiple' => TRUE, 'placeholder' => ts('- any -'), 'select' => array('minimumInputLength' => 0)));
$form->addElement('text', 'member_source', ts('Source'));
CRM_Core_Form_Date::buildDateRange($form, 'member_join_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'member_start_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'member_end_date', 1, '_low', '_high', ts('From'), FALSE);
$form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
$form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);
$form->addYesNo('member_auto_renew', ts('Auto-Renew?'), TRUE);
$form->addYesNo('member_test', ts('Membership is a Test?'), TRUE);
$form->addYesNo('member_is_override', ts('Membership Status Is Override?'), TRUE);
// add all the custom searchable fields
$extends = array('Membership');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('membershipGroupTree', $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);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'member_campaign_id');
$form->assign('validCiviMember', TRUE);
$form->setDefaults(array('member_test' => 0));
}
示例4: buildProfile
//.........这里部分代码省略.........
$form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))), NULL, FALSE);
} elseif ($fieldName === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
foreach ($communicationFields as $key => $var) {
if ($key == '') {
continue;
}
$communicationOptions[] = $form->createElement('checkbox', $key, NULL, $var);
}
$form->addGroup($communicationOptions, $name, $title, '<br/>');
} elseif ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} elseif ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contact_BAO_Contact::buildOptions('preferred_language'));
} elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} elseif ($fieldName === 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, TRUE, $required, $title, NULL, $name);
} elseif ($fieldName === 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, FALSE, $required, NULL, $title, $name);
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->add('text', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), $required);
$form->addRule($name, ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url');
} elseif (substr($fieldName, -4) == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
} elseif ($fieldName == 'soft_credit') {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Soft Credit To'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
示例5: buildSearchForm
/**
* @param CRM_Core_Form $form
*/
public static function buildSearchForm(&$form)
{
// pledge related dates
CRM_Core_Form_Date::buildDateRange($form, 'pledge_start_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'pledge_end_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'pledge_create_date', 1, '_low', '_high', ts('From'), FALSE);
// pledge payment related dates
CRM_Core_Form_Date::buildDateRange($form, 'pledge_payment_date', 1, '_low', '_high', ts('From'), FALSE);
$form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE);
$form->add('text', 'pledge_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'pledge_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$statusValues = CRM_Contribute_PseudoConstant::contributionStatus();
// Remove status values that are only used for recurring contributions for now (Failed and In Progress).
unset($statusValues['4']);
$form->add('select', 'pledge_status_id', ts('Pledge Status'), $statusValues, FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
//unset in progress for payment
unset($statusValues['5']);
$form->add('select', 'pledge_payment_status_id', ts('Pledge Payment Status'), $statusValues, FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
$form->add('select', 'pledge_financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), FALSE, array('class' => 'crm-select2'));
$form->add('select', 'pledge_contribution_page_id', ts('Contribution Page'), array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::contributionPage(), FALSE, array('class' => 'crm-select2'));
//add fields for pledge frequency
$form->add('text', 'pledge_frequency_interval', ts('Every'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_frequency_interval', ts('Please enter valid Pledge Frequency Interval'), 'integer');
$frequencies = CRM_Core_OptionGroup::values('recur_frequency_units');
foreach ($frequencies as $val => $label) {
$freqUnitsDisplay["'{$val}'"] = ts('%1(s)', array(1 => $label));
}
$form->add('select', 'pledge_frequency_unit', ts('Pledge Frequency'), array('' => ts('- any -')) + $freqUnitsDisplay);
// add all the custom searchable fields
$pledge = array('Pledge');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $pledge);
if ($groupDetails) {
$form->assign('pledgeGroupTree', $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);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'pledge_campaign_id');
$form->assign('validCiviPledge', TRUE);
$form->setDefaults(array('pledge_test' => 0));
}
示例6: buildSearchForm
/**
* add all the elements shared between contribute search and advnaced search
*
* @access public
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
require_once 'CRM/Utils/Money.php';
//added contribution source
$form->addElement('text', 'contribution_source', ts('Contribution Source'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'source'));
$form->addDate('contribution_date_low', ts('Contribution Dates - From'), false, array('formatType' => 'searchDate'));
$form->addDate('contribution_date_high', ts('To'), false, array('formatType' => 'searchDate'));
$form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
require_once 'CRM/Contribute/PseudoConstant.php';
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'contribution_page_id', ts('Contribution Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage());
$form->add('select', 'contribution_payment_instrument_id', ts('Payment Instrument'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument());
$form->add('select', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::pcPage());
$status = array();
require_once "CRM/Core/OptionGroup.php";
$statusValues = CRM_Core_OptionGroup::values("contribution_status");
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
unset($statusValues['5']);
unset($statusValues['6']);
foreach ($statusValues as $key => $val) {
$status[] = $form->createElement('advcheckbox', $key, null, $val);
}
$form->addGroup($status, 'contribution_status_id', ts('Contribution Status'));
// add null checkboxes for thank you and receipt
$form->addElement('checkbox', 'contribution_thankyou_date_isnull', ts('Thank-you date not set?'));
$form->addElement('checkbox', 'contribution_receipt_date_isnull', ts('Receipt not sent?'));
//add fields for honor search
$form->addElement('text', 'contribution_in_honor_of', ts("In Honor Of"));
$form->addElement('checkbox', 'contribution_test', ts('Find Test Contributions?'));
$form->addElement('checkbox', 'contribution_pay_later', ts('Find Pay Later Contributions?'));
//add field for transaction ID search
$form->addElement('text', 'contribution_transaction_id', ts("Transaction ID"));
$form->addElement('checkbox', 'contribution_recurring', ts('Find Recurring Contributions?'));
$form->addElement('text', 'contribution_check_number', ts('Check Number'));
//add field for pcp display in roll search
$form->addYesNo('contribution_pcp_display_in_roll', ts('Display In Roll ?'));
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$contribution = array('Contribution');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $contribution);
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('contributeGroupTree', $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);
}
}
}
$form->assign('validCiviContribute', true);
}
示例7: buildQuickForm
/**
* Generic function to build all the form elements for a specific group tree.
*
* @param CRM_Core_Form $form
* The form object.
* @param array $groupTree
* The group tree object.
* @param bool $inactiveNeeded
* Return inactive custom groups.
* @param string $prefix
* Prefix for custom grouptree assigned to template.
*/
public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '')
{
$form->assign_by_ref("{$prefix}groupTree", $groupTree);
foreach ($groupTree as $id => $group) {
CRM_Core_ShowHideBlocks::links($form, $group['title'], '', '');
foreach ($group['fields'] as $field) {
$required = CRM_Utils_Array::value('is_required', $field);
//fix for CRM-1620
if ($field['data_type'] == 'File') {
if (!empty($field['element_value']['data'])) {
$required = 0;
}
}
$fieldId = $field['id'];
$elementName = $field['element_name'];
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $required);
}
}
}
示例8: custom
/**
* Generate the custom Data Fields based
* on the is_searchable
*
*
* @param $form
*
* @return void
*/
public static function custom(&$form)
{
$form->add('hidden', 'hidden_custom', 1);
$extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
$form->assign('groupTree', $groupDetails);
foreach ($groupDetails as $key => $group) {
$_groupTitle[$key] = $group['name'];
CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
$groupId = $group['id'];
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
if ($field['data_type'] == 'Date' && $field['is_search_range']) {
CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE);
} else {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
//TODO: validate for only one state if prox_distance isset
}
示例9: addField
/**
* Adds a field based on metadata.
*
* @param $name
* Field name to go on the form.
* @param array $props
* Mix of html attributes and special properties, namely.
* - entity (api entity name, can usually be inferred automatically from the form class)
* - name (field name - only needed if different from name used on the form)
* - option_url - path to edit this option list - usually retrieved automatically - set to NULL to disable link
* - placeholder - set to NULL to disable
* - multiple - bool
* - context - @see CRM_Core_DAO::buildOptionsContext
* @param bool $required
* @throws \CiviCRM_API3_Exception
* @throws \Exception
* @return HTML_QuickForm_Element
*/
public function addField($name, $props = array(), $required = FALSE)
{
// Resolve context.
if (empty($props['context'])) {
$props['context'] = $this->getDefaultContext();
}
$context = $props['context'];
// Resolve entity.
if (empty($props['entity'])) {
$props['entity'] = $this->getDefaultEntity();
}
// Resolve field.
if (empty($props['name'])) {
$props['name'] = strrpos($name, '[') ? rtrim(substr($name, 1 + strrpos($name, '[')), ']') : $name;
}
// Resolve action.
if (empty($props['action'])) {
$props['action'] = $this->getApiAction();
}
// Handle custom fields
if (strpos($name, 'custom_') === 0 && is_numeric($name[7])) {
$fieldId = (int) substr($name, 7);
return CRM_Core_BAO_CustomField::addQuickFormElement($this, $name, $fieldId, $required, $context == 'search', CRM_Utils_Array::value('label', $props));
}
// Core field - get metadata.
$fieldSpec = civicrm_api3($props['entity'], 'getfield', $props);
$fieldSpec = $fieldSpec['values'];
$label = CRM_Utils_Array::value('label', $props, isset($fieldSpec['title']) ? $fieldSpec['title'] : NULL);
$widget = isset($props['type']) ? $props['type'] : $fieldSpec['html']['type'];
if ($widget == 'TextArea' && $context == 'search') {
$widget = 'Text';
}
$isSelect = in_array($widget, array('Select', 'CheckBoxGroup', 'RadioGroup', 'Radio'));
if ($isSelect) {
// Fetch options from the api unless passed explicitly.
if (isset($props['options'])) {
$options = $props['options'];
} else {
$options = isset($fieldSpec['options']) ? $fieldSpec['options'] : NULL;
}
if ($context == 'search') {
$widget = 'Select';
$props['multiple'] = CRM_Utils_Array::value('multiple', $props, TRUE);
}
// Add data for popup link.
if ((!empty($props['option_url']) || !array_key_exists('option_url', $props)) && ($context != 'search' && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM'))) {
$props['data-option-edit-path'] = !empty($props['option_url']) ? $props['option_url'] : CRM_Core_PseudoConstant::getOptionEditUrl($fieldSpec);
$props['data-api-entity'] = $props['entity'];
$props['data-api-field'] = $props['name'];
}
}
$props += CRM_Utils_Array::value('html', $fieldSpec, array());
CRM_Utils_Array::remove($props, 'entity', 'name', 'context', 'label', 'action', 'type', 'option_url', 'options');
// TODO: refactor switch statement, to separate methods.
switch ($widget) {
case 'Text':
case 'Url':
case 'Number':
case 'Email':
//TODO: Autodetect ranges
$props['size'] = isset($props['size']) ? $props['size'] : 60;
return $this->add(strtolower($widget), $name, $label, $props, $required);
case 'hidden':
return $this->add('hidden', $name, NULL, $props, $required);
case 'TextArea':
//Set default columns and rows for textarea.
$props['rows'] = isset($props['rows']) ? $props['rows'] : 4;
$props['cols'] = isset($props['cols']) ? $props['cols'] : 60;
return $this->add('textarea', $name, $label, $props, $required);
case 'Select Date':
//TODO: add range support
//TODO: Add date formats
//TODO: Add javascript template for dates.
return $this->addDate($name, $label, $required, $props);
case 'Radio':
$separator = isset($props['separator']) ? $props['separator'] : NULL;
unset($props['separator']);
if (!isset($props['allowClear'])) {
$props['allowClear'] = !$required;
}
return $this->addRadio($name, $label, $options, $props, $separator, $required);
case 'ChainSelect':
//.........这里部分代码省略.........
示例10: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
function buildQuickForm()
{
// add the form elements
require_once "CRM/Contribute/PseudoConstant.php";
foreach ($this->_fields as $name => $field) {
$required = $field['is_required'];
if (substr($field['name'], 0, 14) === 'state_province') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required);
} else {
if (substr($field['name'], 0, 7) === 'country') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required);
} else {
if ($field['name'] === 'birth_date') {
$this->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('birth'), $required);
} else {
if ($field['name'] === 'gender') {
$genderOptions = array();
$gender = CRM_Core_PseudoConstant::gender();
foreach ($gender as $key => $var) {
$genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
}
$this->addGroup($genderOptions, $field['name'], $field['title']);
if ($required) {
$this->addRule($field['name'], ts('%1 is a required field.', array(1 => $field['title'])), 'required');
}
} else {
if ($field['name'] === 'individual_prefix') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix(), $required);
} else {
if ($field['name'] === 'individual_suffix') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix(), $required);
} else {
if ($field['name'] === 'preferred_communication_method') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_SelectValues::pcm());
} else {
if ($field['name'] === 'preferred_mail_format') {
$this->add('select', $name, $field['title'], array(CRM_Core_SelectValues::pcm()));
} else {
if (substr($field['name'], 0, 7) === 'do_not_') {
$this->add('checkbox', $name, $field['title'], $field['attributes'], $required);
} else {
if ($field['name'] === 'group') {
require_once 'CRM/Contact/Form/GroupTag.php';
CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_id, CRM_CONTACT_FORM_GROUPTAG_GROUP, false, $required, $field['title'], null);
} else {
if ($field['name'] === 'tag') {
require_once 'CRM/Contact/Form/GroupTag.php';
CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_id, CRM_CONTACT_FORM_GROUPTAG_TAG, false, $required, null, $field['title']);
} else {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
CRM_Core_BAO_CustomField::addQuickFormElement($this, $name, $customFieldID, $inactiveNeeded, $required, false, $field['title']);
} else {
if (in_array($field['name'], array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$this->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('manual', 3, 1), $required);
} else {
if ($field['name'] == 'payment_instrument') {
$this->add('select', 'payment_instrument', ts('Paid By'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} else {
if ($field['name'] == 'contribution_type') {
$this->add('select', 'contribution_type', ts('Contribution Type'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} else {
$this->add('text', $name, $field['title'], $field['attributes'], $required);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done with Preview'), 'isDefault' => true)));
}
示例11: custom
/**
* Generate the custom Data Fields based
* on the is_searchable
*
* @access private
* @return void
*/
static function custom(&$form)
{
$form->add('hidden', 'hidden_custom', 1);
$extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends);
$form->assign('groupTree', $groupDetails);
foreach ($groupDetails as $key => $group) {
$_groupTitle[$key] = $group['name'];
CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
$groupId = $group['id'];
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
}
}
}
示例12: buildSearchForm
static function buildSearchForm(&$form)
{
// pledge related dates
$form->addDate('pledge_start_date_low', ts('Payments Start Date - From'), false, array('formatType' => 'relative'));
$form->addDate('pledge_start_date_high', ts('To'), false, array('formatType' => 'relative'));
$form->addDate('pledge_end_date_low', ts('Payments Ended Date - From'), false, array('formatType' => 'relative'));
$form->addDate('pledge_end_date_high', ts('To'), false, array('formatType' => 'relative'));
$form->addDate('pledge_create_date_low', ts('Pledge Made - From'), false, array('formatType' => 'relative'));
$form->addDate('pledge_create_date_high', ts('To'), false, array('formatType' => 'relative'));
// pledge payment related dates
$form->addDate('pledge_payment_date_low', ts('Payment Scheduled - From'), false, array('formatType' => 'relative'));
$form->addDate('pledge_payment_date_high', ts('To'), false, array('formatType' => 'relative'));
$form->addElement('checkbox', 'pledge_test', ts('Find Test Pledges?'));
require_once 'CRM/Utils/Money.php';
$form->add('text', 'pledge_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'pledge_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
require_once 'CRM/Contribute/PseudoConstant.php';
$statusValues = CRM_Contribute_PseudoConstant::contributionStatus();
// Remove status values that are only used for recurring contributions for now (Failed and In Progress).
unset($statusValues['4']);
foreach ($statusValues as $key => $val) {
$status[] = $form->createElement('advcheckbox', $key, null, $val);
}
$form->addGroup($status, 'pledge_status_id', ts('Pledge Status'));
//unset in progress for payment
unset($statusValues['5']);
foreach ($statusValues as $key => $val) {
$paymentStatus[] = $form->createElement('advcheckbox', $key, null, $val);
}
$form->addGroup($paymentStatus, 'pledge_payment_status_id', ts('Pledge Payment Status'));
require_once 'CRM/Contribute/PseudoConstant.php';
$form->add('select', 'pledge_contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'pledge_contribution_page_id', ts('Contribution Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage());
//add fields for honor search
$form->addElement('text', 'pledge_in_honor_of', ts("In Honor Of"));
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$pledge = array('Pledge');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $pledge);
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('pledgeGroupTree', $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);
}
}
}
$form->assign('validCiviPledge', true);
}
示例13: buildSearchForm
static function buildSearchForm(&$form)
{
$dataURLEvent = CRM_Utils_System::url('civicrm/ajax/event', "reset=1", false, null, false);
$dataURLEventType = CRM_Utils_System::url('civicrm/ajax/eventType', "reset=1", false, null, false);
$dataURLEventFee = CRM_Utils_System::url('civicrm/ajax/eventFee', "reset=1", false, null, false);
$form->assign('dataURLEvent', $dataURLEvent);
$form->assign('dataURLEventType', $dataURLEventType);
$form->assign('dataURLEventFee', $dataURLEventFee);
$eventId =& $form->add('text', 'event_name', ts('Event Name'));
$eventType =& $form->add('text', 'event_type', ts('Event Type'));
$participantFee =& $form->add('text', 'participant_fee_level', ts('Fee Level'));
//elements for assigning value operation
$eventNameId =& $form->add('hidden', 'event_id', '', array('id' => 'event_id'));
$eventTypeId =& $form->add('hidden', 'event_type_id', '', array('id' => 'event_type_id'));
$participantFeeId =& $form->add('hidden', 'participant_fee_id', '', array('id' => 'participant_fee_id'));
$form->addDate('event_start_date_low', ts('Event Dates - From'), false, array('formatType' => 'searchDate'));
$form->addDate('event_end_date_high', ts('To'), false, array('formatType' => 'searchDate'));
require_once 'CRM/Event/PseudoConstant.php';
$status = CRM_Event_PseudoConstant::participantStatus(null, null, 'label');
asort($status);
foreach ($status as $id => $Name) {
$form->_participantStatus =& $form->addElement('checkbox', "participant_status_id[{$id}]", null, $Name);
}
foreach (CRM_Event_PseudoConstant::participantRole() as $rId => $rName) {
$form->_participantRole =& $form->addElement('checkbox', "participant_role_id[{$rId}]", null, $rName);
}
$form->addElement('checkbox', 'participant_test', ts('Find Test Participants?'));
$form->addElement('checkbox', 'participant_pay_later', ts('Find Pay Later Participants?'));
$form->addElement('text', 'participant_fee_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addElement('text', 'participant_fee_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('participant_fee_amount_low', ts('Please enter a valid money value.'), 'money');
$form->addRule('participant_fee_amount_high', ts('Please enter a valid money value.'), 'money');
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$extends = array('Participant');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends);
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('participantGroupTree', $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);
}
}
}
$form->assign('validCiviEvent', true);
}
示例14: buildProfile
//.........这里部分代码省略.........
} elseif ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} elseif ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
} elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} elseif ($fieldName === 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, TRUE, $required, $title, NULL, $name);
} elseif ($fieldName === 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, FALSE, $required, NULL, $title, $name);
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
if ($onBehalf) {
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
$form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
} else {
$form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
}
// added because note appeared as a standard text input
} elseif ($fieldName == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
} elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'contribution_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
示例15: buildQuickFormCommon
/**
* add all the elements shared between this and advnaced search
*
* @access public
* @return void
* @static
*/
function buildQuickFormCommon(&$form)
{
// Date selects for date
$form->add('date', 'contribution_date_from', ts('Contribution Dates - From'), CRM_Core_SelectValues::date('relative'));
$form->addRule('contribution_date_from', ts('Select a valid date.'), 'qfDate');
$form->add('date', 'contribution_date_to', ts('To'), CRM_Core_SelectValues::date('relative'));
$form->addRule('contribution_date_to', ts('Select a valid date.'), 'qfDate');
$form->add('text', 'contribution_min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_min_amount', ts('Please enter a valid money value (e.g. 9.99).'), 'money');
$form->add('text', 'contribution_max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_max_amount', ts('Please enter a valid money value (e.g. 99.99).'), 'money');
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'payment_instrument_id', ts('Payment Instrument'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument());
$status = array();
$status[] = $form->createElement('radio', null, null, ts('Valid'), 'Valid');
$status[] = $form->createElement('radio', null, null, ts('Cancelled'), 'Cancelled');
$status[] = $form->createElement('radio', null, null, ts('All'), 'All');
$form->addGroup($status, 'contribution_status', ts('Contribution Status'));
$form->setDefaults(array('contribution_status' => 'All'));
// add null checkboxes for thank you and receipt
$form->addElement('checkbox', 'contribution_thankyou_date_isnull', ts('Thank-you date not set?'));
$form->addElement('checkbox', 'contribution_receipt_date_isnull', ts('Receipt date not set?'));
// add all the custom searchable fields
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, array('Contribution'));
if ($groupDetails) {
require_once 'CRM/Core/BAO/CustomField.php';
$form->assign('contributeGroupTree', $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);
}
}
}
}