本文整理汇总了PHP中CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled方法的具体用法?PHP CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled怎么用?PHP CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Query
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportComponents
//.........这里部分代码省略.........
// total hack for export, CRM-3618
$from = str_replace($oldClause, $newClause, $from);
}
if (!$selectAll && $componentTable) {
$from .= " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = contact_a.id ";
} elseif ($componentClause) {
if (empty($where)) {
$where = "WHERE {$componentClause}";
} else {
$where .= " AND {$componentClause}";
}
}
// CRM-13982 - check if is deleted
$excludeTrashed = TRUE;
foreach ($params as $value) {
if ($value[0] == 'contact_is_deleted') {
$excludeTrashed = FALSE;
}
}
$trashClause = $excludeTrashed ? "contact_a.is_deleted != 1" : "( 1 )";
if (empty($where)) {
$where = "WHERE {$trashClause}";
} else {
$where .= " AND {$trashClause}";
}
$queryString = "{$select} {$from} {$where} {$having}";
$groupBy = "";
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) || CRM_Utils_Array::value('notes', $returnProperties) || $queryMode & CRM_Contact_BAO_Query::MODE_CONTACTS && $query->_useGroupBy) {
$groupBy = " GROUP BY contact_a.id";
}
switch ($exportMode) {
case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
$groupBy = 'GROUP BY civicrm_contribution.id';
if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
// especial group by when soft credit columns are included
$groupBy = 'GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.scredit_id';
}
break;
case CRM_Export_Form_Select::EVENT_EXPORT:
$groupBy = 'GROUP BY civicrm_participant.id';
break;
case CRM_Export_Form_Select::MEMBER_EXPORT:
$groupBy = " GROUP BY civicrm_membership.id";
break;
}
if ($queryMode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
$groupBy = " GROUP BY civicrm_activity.id ";
}
$queryString .= $groupBy;
// always add contact_a.id to the ORDER clause
// so the order is deterministic
//CRM-15301
if (strpos('contact_a.id', $order) === FALSE) {
$order .= ", contact_a.id";
}
if ($order) {
list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (!empty($returnProperties[$field])) {
//CRM-15301
$queryString .= " ORDER BY {$order}";
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$addPaymentHeader = FALSE;
$paymentDetails = array();
示例2: getGroupBy
/**
* Get Query Group By Clause
* @param int $exportMode
* Export Mode
* @param string $queryMode
* Query Mode
* @param array $returnProperties
* Return Properties
* @param object $query
* CRM_Contact_BAO_Query
*
* @return string $groupBy
* Group By Clause
*/
public static function getGroupBy($exportMode, $queryMode, $returnProperties, $query)
{
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) || CRM_Utils_Array::value('notes', $returnProperties) || $queryMode & CRM_Contact_BAO_Query::MODE_CONTACTS && $query->_useGroupBy) {
$groupBy = " GROUP BY contact_a.id";
}
switch ($exportMode) {
case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
$groupBy = 'GROUP BY civicrm_contribution.id';
if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
// especial group by when soft credit columns are included
$groupBy = 'GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.scredit_id';
}
break;
case CRM_Export_Form_Select::EVENT_EXPORT:
$groupBy = 'GROUP BY civicrm_participant.id';
break;
case CRM_Export_Form_Select::MEMBER_EXPORT:
$groupBy = " GROUP BY civicrm_membership.id";
break;
}
if ($queryMode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
$groupBy = " GROUP BY civicrm_activity.id ";
}
$groupBy = !empty($groupBy) ? $groupBy : '';
return $groupBy;
}
示例3: list
/**
* @param null $context
*
* @return array
*/
public function &summaryContribution($context = NULL)
{
list($innerselect, $from, $where, $having) = $this->query(TRUE);
// hack $select
$select = "\nSELECT COUNT( conts.total_amount ) as total_count,\n SUM( conts.total_amount ) as total_amount,\n AVG( conts.total_amount ) as total_avg,\n conts.total_amount as amount,\n conts.currency as currency";
if ($this->_permissionWhereClause) {
$where .= " AND " . $this->_permissionWhereClause;
}
if ($context == 'search') {
$where .= " AND contact_a.is_deleted = 0 ";
}
// make sure contribution is completed - CRM-4989
$completedWhere = $where . " AND civicrm_contribution.contribution_status_id = 1 ";
$summary = array();
$summary['total'] = array();
$summary['total']['count'] = $summary['total']['amount'] = $summary['total']['avg'] = "n/a";
$innerQuery = "SELECT civicrm_contribution.total_amount, COUNT(civicrm_contribution.total_amount) as civicrm_contribution_total_amount_count,\n civicrm_contribution.currency {$from} {$completedWhere}";
$query = "{$select} FROM (\n {$innerQuery} GROUP BY civicrm_contribution.id\n ) as conts\n GROUP BY currency";
$dao = CRM_Core_DAO::executeQuery($query);
$summary['total']['count'] = 0;
$summary['total']['amount'] = $summary['total']['avg'] = array();
while ($dao->fetch()) {
$summary['total']['count'] += $dao->total_count;
$summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
$summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
}
$orderBy = 'ORDER BY civicrm_contribution_total_amount_count DESC';
$groupBy = 'GROUP BY currency, civicrm_contribution.total_amount';
$modeSQL = "{$select}, conts.civicrm_contribution_total_amount_count as civicrm_contribution_total_amount_count FROM ({$innerQuery}\n {$groupBy} {$orderBy}) as conts\n GROUP BY currency";
$summary['total']['mode'] = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL);
$medianSQL = "{$from} {$completedWhere}";
$summary['total']['median'] = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, 'civicrm_contribution');
$summary['total']['currencyCount'] = count($summary['total']['median']);
if (!empty($summary['total']['amount'])) {
$summary['total']['amount'] = implode(', ', $summary['total']['amount']);
$summary['total']['avg'] = implode(', ', $summary['total']['avg']);
$summary['total']['mode'] = implode(', ', $summary['total']['mode']);
$summary['total']['median'] = implode(', ', $summary['total']['median']);
} else {
$summary['total']['amount'] = $summary['total']['avg'] = $summary['total']['median'] = 0;
}
// soft credit summary
if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
$softCreditWhere = "{$completedWhere} AND civicrm_contribution_soft.id IS NOT NULL";
$query = "\n {$select} FROM (\n SELECT civicrm_contribution_soft.amount as total_amount, civicrm_contribution_soft.currency {$from} {$softCreditWhere}\n GROUP BY civicrm_contribution_soft.id\n ) as conts\n GROUP BY currency";
$dao = CRM_Core_DAO::executeQuery($query);
$summary['soft_credit']['count'] = 0;
$summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = array();
while ($dao->fetch()) {
$summary['soft_credit']['count'] += $dao->total_count;
$summary['soft_credit']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
$summary['soft_credit']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
}
if (!empty($summary['soft_credit']['amount'])) {
$summary['soft_credit']['amount'] = implode(', ', $summary['soft_credit']['amount']);
$summary['soft_credit']['avg'] = implode(', ', $summary['soft_credit']['avg']);
} else {
$summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = 0;
}
}
// hack $select
//@todo - this could be one query using the IF in mysql - eg
// SELECT sum(total_completed), sum(count_completed), sum(count_cancelled), sum(total_cancelled) FROM (
// SELECT civicrm_contribution.total_amount, civicrm_contribution.currency ,
// IF(civicrm_contribution.contribution_status_id = 1, 1, 0 ) as count_completed,
// IF(civicrm_contribution.contribution_status_id = 1, total_amount, 0 ) as total_completed,
// IF(civicrm_contribution.cancel_date IS NOT NULL = 1, 1, 0 ) as count_cancelled,
// IF(civicrm_contribution.cancel_date IS NOT NULL = 1, total_amount, 0 ) as total_cancelled
// FROM civicrm_contact contact_a
// LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id
// WHERE ( ... where clause....
// AND (civicrm_contribution.cancel_date IS NOT NULL OR civicrm_contribution.contribution_status_id = 1)
// ) as conts
$select = "\nSELECT COUNT( conts.total_amount ) as cancel_count,\n SUM( conts.total_amount ) as cancel_amount,\n AVG( conts.total_amount ) as cancel_avg,\n conts.currency as currency";
$where .= " AND civicrm_contribution.cancel_date IS NOT NULL ";
if ($context == 'search') {
$where .= " AND contact_a.is_deleted = 0 ";
}
$query = "{$select} FROM (\n SELECT civicrm_contribution.total_amount, civicrm_contribution.currency {$from} {$where}\n GROUP BY civicrm_contribution.id\n ) as conts\n GROUP BY currency";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N <= 1) {
if ($dao->fetch()) {
$summary['cancel']['count'] = $dao->cancel_count;
$summary['cancel']['amount'] = $dao->cancel_amount;
$summary['cancel']['avg'] = $dao->cancel_avg;
}
} else {
$summary['cancel']['count'] = 0;
$summary['cancel']['amount'] = $summary['cancel']['avg'] = array();
while ($dao->fetch()) {
$summary['cancel']['count'] += $dao->cancel_count;
$summary['cancel']['amount'][] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
$summary['cancel']['avg'][] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
}
$summary['cancel']['amount'] = implode(', ', $summary['cancel']['amount']);
//.........这里部分代码省略.........
示例4: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
// text for sort_name
$this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$this->_group = CRM_Core_PseudoConstant::nestedGroup();
// multiselect for groups
if ($this->_group) {
$this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
}
// multiselect for tags
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2'));
}
CRM_Contribute_BAO_Query::buildSearchForm($this);
$rows = $this->get('rows');
if (is_array($rows)) {
if (!$this->_single) {
$this->addRowSelectors($rows);
}
$permission = CRM_Core_Permission::getPermission();
$queryParams = $this->get('queryParams');
$softCreditFiltering = FALSE;
if (!empty($queryParams)) {
$softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
}
$tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
$this->addTaskMenu($tasks);
}
}
示例5: __construct
/**
* Class constructor.
*
* @param array $queryParams
* Array of parameters for query.
* @param \const|int $action - action of search basic or advanced.
* @param string $contributionClause
* If the caller wants to further restrict the search (used in contributions).
* @param bool $single
* Are we dealing only with one contact?.
* @param int $limit
* How many contributions do we want returned.
*
* @param string $context
* @param null $compContext
*
* @return \CRM_Contribute_Selector_Search
*/
public function __construct(&$queryParams, $action = CRM_Core_Action::NONE, $contributionClause = NULL, $single = FALSE, $limit = NULL, $context = 'search', $compContext = NULL)
{
// submitted form values
$this->_queryParams =& $queryParams;
$this->_single = $single;
$this->_limit = $limit;
$this->_context = $context;
$this->_compContext = $compContext;
$this->_contributionClause = $contributionClause;
// type of selector
$this->_action = $action;
$this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
$this->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Contribute_BAO_Query::selectorReturnProperties(), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
// @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
// can we remove? if not why not?
if ($this->_includeSoftCredits) {
$this->_query->_rowCountClause = " count(civicrm_contribution.id)";
$this->_query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
} else {
$this->_query->_distinctComponentClause = " civicrm_contribution.id";
$this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
}
}
示例6: preProcessCommon
/**
* @param CRM_Core_Form $form
* @param bool $useTable
*/
public static function preProcessCommon(&$form, $useTable = FALSE)
{
$form->_contributionIds = array();
$values = $form->controller->exportValues($form->get('searchFormName'));
$form->_task = $values['task'];
$contributeTasks = CRM_Contribute_Task::tasks();
$form->assign('taskName', $contributeTasks[$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');
$sortOrder = NULL;
if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
$sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
}
$form->_includesSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
$query = new CRM_Contact_BAO_Query($queryParams, array('contribution_id'), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
// @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
// can we remove? if not why not?
if ($form->_includesSoftCredits) {
$contactIds = $contributionContactIds = array();
$query->_rowCountClause = " count(civicrm_contribution.id)";
$query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
} else {
$query->_distinctComponentClause = ' civicrm_contribution.id';
$query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id ';
}
$result = $query->searchQuery(0, 0, $sortOrder);
while ($result->fetch()) {
$ids[] = $result->contribution_id;
if ($form->_includesSoftCredits) {
$contactIds[$result->contact_id] = $result->contact_id;
$contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
}
}
$result->free();
$form->assign('totalSelectedContributions', $form->get('rowCount'));
}
if (!empty($ids)) {
$form->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) ';
$form->assign('totalSelectedContributions', count($ids));
}
if (!empty($form->_includesSoftCredits) && !empty($contactIds)) {
$form->_contactIds = $contactIds;
$form->_contributionContactIds = $contributionContactIds;
}
$form->_contributionIds = $form->_componentIds = $ids;
//set the context for redirection for any task actions
$session = CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&qfKey={$qfKey}";
}
$searchFormName = strtolower($form->get('searchFormName'));
if ($searchFormName == 'search') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/search', $urlParams));
} else {
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams));
}
}