本文整理汇总了PHP中CRM_Pledge_BAO_Pledge::buildOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Pledge_BAO_Pledge::buildOptions方法的具体用法?PHP CRM_Pledge_BAO_Pledge::buildOptions怎么用?PHP CRM_Pledge_BAO_Pledge::buildOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Pledge_BAO_Pledge
的用法示例。
在下文中一共展示了CRM_Pledge_BAO_Pledge::buildOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set default values for the form.
* The default values are retrieved from the database.
*/
public function setDefaultValues()
{
$defaults = $this->_values;
$fields = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if (!empty($defaults['is_test'])) {
$this->assign('is_test', TRUE);
}
if ($this->_id) {
$startDate = CRM_Utils_Array::value('start_date', $this->_values);
$createDate = CRM_Utils_Array::value('create_date', $this->_values);
list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($startDate);
list($defaults['create_date']) = CRM_Utils_Date::setDateDefaults($createDate);
if ($ackDate = CRM_Utils_Array::value('acknowledge_date', $this->_values)) {
list($defaults['acknowledge_date']) = CRM_Utils_Date::setDateDefaults($ackDate);
}
// check is this pledge pending.
// fix the display of the monetary value, CRM-4038.
if ($this->_isPending) {
$defaults['eachPaymentAmount'] = $this->_values['amount'] / $this->_values['installments'];
$defaults['eachPaymentAmount'] = CRM_Utils_Money::format($defaults['eachPaymentAmount'], NULL, '%a');
} else {
$this->assign('start_date', $startDate);
$this->assign('create_date', $createDate);
}
// fix the display of the monetary value, CRM-4038
if (isset($this->_values['amount'])) {
$defaults['amount'] = CRM_Utils_Money::format($this->_values['amount'], NULL, '%a');
}
$this->assign('amount', $this->_values['amount']);
$this->assign('installments', $defaults['installments']);
} else {
// default values.
list($now) = CRM_Utils_Date::setDateDefaults();
$defaults['create_date'] = $now;
$defaults['start_date'] = $now;
$defaults['installments'] = 12;
$defaults['frequency_interval'] = 1;
$defaults['frequency_day'] = 1;
$defaults['initial_reminder_day'] = 5;
$defaults['max_reminders'] = 1;
$defaults['additional_reminder_day'] = 5;
$defaults['frequency_unit'] = array_search('month', $this->_freqUnits);
$defaults['financial_type_id'] = array_search('Donation', CRM_Contribute_PseudoConstant::financialType());
}
$pledgeStatus = CRM_Pledge_BAO_Pledge::buildOptions('status_id');
$pledgeStatusNames = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', TRUE);
// get default status label (pending)
$defaultPledgeStatus = CRM_Utils_Array::value(array_search('Pending', $pledgeStatusNames), $pledgeStatus);
// assign status.
$this->assign('status', CRM_Utils_Array::value(CRM_Utils_Array::value('status_id', $this->_values), $pledgeStatus, $defaultPledgeStatus));
if (isset($this->userEmail)) {
$this->assign('email', $this->userEmail);
}
// custom data set defaults
$defaults += CRM_Custom_Form_CustomData::setDefaultValues($this);
return $defaults;
}
示例2: fixFormValues
public function fixFormValues()
{
if (!$this->_force) {
return;
}
// set pledge payment related fields
$status = CRM_Utils_Request::retrieve('status', 'String');
if ($status) {
$this->_formValues['pledge_payment_status_id'] = array($status => 1);
$this->_defaults['pledge_payment_status_id'] = array($status => 1);
}
$fromDate = CRM_Utils_Request::retrieve('start', 'Date');
if ($fromDate) {
list($date) = CRM_Utils_Date::setDateDefaults($fromDate);
$this->_formValues['pledge_payment_date_low'] = $date;
$this->_defaults['pledge_payment_date_low'] = $date;
}
$toDate = CRM_Utils_Request::retrieve('end', 'Date');
if ($toDate) {
list($date) = CRM_Utils_Date::setDateDefaults($toDate);
$this->_formValues['pledge_payment_date_high'] = $date;
$this->_defaults['pledge_payment_date_high'] = $date;
}
// set pledge related fields
$pledgeStatus = CRM_Utils_Request::retrieve('pstatus', 'String');
if ($pledgeStatus) {
$statusValues = CRM_Pledge_BAO_Pledge::buildOptions('status_id');
// we need set all statuses except Cancelled
unset($statusValues[$pledgeStatus]);
$statuses = array();
foreach ($statusValues as $statusId => $value) {
$statuses[$statusId] = 1;
}
$this->_formValues['pledge_status_id'] = $statuses;
$this->_defaults['pledge_status_id'] = $statuses;
}
$pledgeFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
if ($pledgeFromDate) {
list($date) = CRM_Utils_Date::setDateDefaults($pledgeFromDate);
$this->_formValues['pledge_create_date_low'] = $this->_defaults['pledge_create_date_low'] = $date;
}
$pledgeToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
if ($pledgeToDate) {
list($date) = CRM_Utils_Date::setDateDefaults($pledgeToDate);
$this->_formValues['pledge_create_date_high'] = $this->_defaults['pledge_create_date_high'] = $date;
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($cid) {
$cid = CRM_Utils_Type::escape($cid, 'Integer');
if ($cid > 0) {
$this->_formValues['contact_id'] = $cid;
list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
$this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
// also assign individual mode to the template
$this->_single = TRUE;
}
}
}
示例3: 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');
$form->add('select', 'pledge_status_id', ts('Pledge Status'), CRM_Pledge_BAO_Pledge::buildOptions('status_id'), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
$form->addYesNo('pledge_acknowledge_date_is_not_null', ts('Acknowledgement sent?'), TRUE);
$form->add('text', 'pledge_installments_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_installments_low', ts('Please enter a number'), 'integer');
$form->add('text', 'pledge_installments_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('pledge_installments_high', ts('Please enter number.'), 'integer');
$form->add('select', 'pledge_payment_status_id', ts('Pledge Payment Status'), CRM_Pledge_BAO_PledgePayment::buildOptions('status_id'), 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, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'pledge_campaign_id');
$form->assign('validCiviPledge', TRUE);
$form->setDefaults(array('pledge_test' => 0));
}
示例4: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_additionalClause);
// process the result of the query
$rows = array();
// get all pledge status
$pledgeStatuses = CRM_Pledge_BAO_Pledge::buildOptions('status_id');
// get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// CRM-4418 check for view, edit and delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit pledges')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviPledge')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
// carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->pledge_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->pledge_campaign_id;
// add pledge status name
$row['pledge_status_name'] = CRM_Utils_Array::value($row['pledge_status_id'], $pledgeStatuses);
// append (test) to status label
if (!empty($row['pledge_is_test'])) {
$row['pledge_status'] .= ' (test)';
}
$hideOption = array();
if (CRM_Utils_Array::key('Cancelled', $row) || CRM_Utils_Array::key('Completed', $row)) {
$hideOption[] = 'Cancel';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->pledge_id;
$row['action'] = CRM_Core_Action::formLink(self::links($hideOption, $this->_key), $mask, array('id' => $result->pledge_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'pledge.selector.row', 'Pledge', $result->pledge_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$rows[] = $row;
}
return $rows;
}