当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contribute_BAO_Query类代码示例

本文整理汇总了PHP中CRM_Contribute_BAO_Query的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Query类的具体用法?PHP CRM_Contribute_BAO_Query怎么用?PHP CRM_Contribute_BAO_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CRM_Contribute_BAO_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_batchStatusId == 2) {
         $this->add('submit', 'export_batch', ts('Export Batch'));
     }
     // do not build rest of form unless it is open batch
     if ($this->_batchStatusId != 1) {
         return;
     }
     parent::buildQuickForm();
     $this->add('submit', 'close_batch', ts('Close Batch'));
     $this->add('submit', 'export_batch', ts('Close & Export Batch'));
     // 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'));
     }
     $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);
     $this->addElement('checkbox', 'toggleSelects', NULL, NULL);
     $this->add('select', 'trans_remove', ts('Task'), array('' => ts('- actions -')) + array('Remove' => ts('Remove from Batch')));
     $this->add('submit', 'rSubmit', ts('Go'), array('class' => 'crm-form-submit', 'id' => 'GoRemove'));
     self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive');
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Search'), 'isDefault' => TRUE)));
     $this->addElement('checkbox', 'toggleSelect', NULL, NULL);
     $this->add('select', 'trans_assign', ts('Task'), array('' => ts('- actions -')) + array('Assign' => ts('Assign to Batch')));
     $this->add('submit', 'submit', ts('Go'), array('class' => 'crm-form-submit', 'id' => 'Go'));
     $this->applyFilter('__ALL__', 'trim');
     $this->addElement('hidden', 'batch_id', self::$_entityID);
     $this->add('text', 'name', ts('Batch Name'));
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:39,代码来源:BatchTransaction.php

示例2: civicrm_api3_contribution_get

/**
 * Retrieve a set of contributions.
 *
 * @param array $params
 *  Input parameters.
 *
 * @return array
 *   Array of contributions, if error an array with an error id and error message
 */
function civicrm_api3_contribution_get($params)
{
    $mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
    $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode);
    $contributions = _civicrm_api3_get_using_query_object('Contribution', $params, array(), NULL, $mode, $returnProperties);
    foreach ($contributions as $id => $contribution) {
        $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id, TRUE);
        $contributions[$id] = array_merge($contribution, $softContribution);
        // format soft credit for backward compatibility
        _civicrm_api3_format_soft_credit($contributions[$id]);
    }
    return civicrm_api3_create_success($contributions, $params, 'Contribution', 'get');
}
开发者ID:scardinius,项目名称:civicrm-core,代码行数:22,代码来源:Contribution.php

示例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(',&nbsp;', $summary['cancel']['amount']);
//.........这里部分代码省略.........
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:101,代码来源:Query.php

示例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);
     }
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:34,代码来源:Search.php

示例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 ";
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:41,代码来源:Search.php

示例6: _civicrm_initialize

/**
 * Retrieve a set of contributions, given a set of input params
 *
 * @param  array   $params           (reference ) input parameters
 * @param array    $returnProperties Which properties should be included in the
 *                                   returned Contribution object. If NULL, the default
 *                                   set of properties will be included.
 *
 * @return array (reference )        array of contributions, if error an array with an error id and error message
 * @static void
 * @access public
 */
function &civicrm_contribution_search(&$params)
{
    _civicrm_initialize();
    $inputParams = array();
    $returnProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount');
    $sort = null;
    $offset = 0;
    $rowCount = 25;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            $returnProperties[substr($n, 7)] = $v;
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    // add is_test to the clause if not present
    if (!array_key_exists('contribution_test', $inputParams)) {
        $inputParams['contribution_test'] = 0;
    }
    require_once 'CRM/Contribute/BAO/Query.php';
    require_once 'CRM/Contact/BAO/Query.php';
    if (empty($returnProperties)) {
        $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
    }
    $newParams =& CRM_Contact_BAO_Query::convertFormValues($inputParams);
    $query =& new CRM_Contact_BAO_Query($newParams, $returnProperties, null);
    list($select, $from, $where) = $query->query();
    $sql = "{$select} {$from} {$where}";
    if (!empty($sort)) {
        $sql .= " ORDER BY {$sort} ";
    }
    $sql .= " LIMIT {$offset}, {$rowCount} ";
    $dao =& CRM_Core_DAO::executeQuery($sql);
    $contribution = array();
    while ($dao->fetch()) {
        $contribution[$dao->contribution_id] = $query->store($dao);
    }
    $dao->free();
    return $contribution;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:55,代码来源:Contribute.php

示例7: exportComponents


//.........这里部分代码省略.........
             }
         }
         if ($primary) {
             $returnProperties['location_type'] = 1;
             $returnProperties['im_provider'] = 1;
             $returnProperties['phone_type_id'] = 1;
             $returnProperties['provider_id'] = 1;
             $returnProperties['current_employer'] = 1;
         }
         $extraReturnProperties = array();
         $paymentFields = FALSE;
         switch ($queryMode) {
             case CRM_Contact_BAO_Query::MODE_EVENT:
                 $paymentFields = TRUE;
                 $paymentTableId = 'participant_id';
                 break;
             case CRM_Contact_BAO_Query::MODE_MEMBER:
                 $paymentFields = TRUE;
                 $paymentTableId = 'membership_id';
                 break;
             case CRM_Contact_BAO_Query::MODE_PLEDGE:
                 $extraReturnProperties = CRM_Pledge_BAO_Query::extraReturnProperties($queryMode);
                 $paymentFields = TRUE;
                 $paymentTableId = 'pledge_payment_id';
                 break;
             case CRM_Contact_BAO_Query::MODE_CASE:
                 $extraReturnProperties = CRM_Case_BAO_Query::extraReturnProperties($queryMode);
                 break;
         }
         if ($queryMode != CRM_Contact_BAO_Query::MODE_CONTACTS) {
             $componentReturnProperties = CRM_Contact_BAO_Query::defaultReturnProperties($queryMode);
             if ($queryMode == CRM_Contact_BAO_Query::MODE_CONTRIBUTE) {
                 // soft credit columns are not automatically populated, because contribution search doesn't require them by default
                 $componentReturnProperties = array_merge($componentReturnProperties, CRM_Contribute_BAO_Query::softCreditReturnProperties(TRUE));
             }
             $returnProperties = array_merge($returnProperties, $componentReturnProperties);
             if (!empty($extraReturnProperties)) {
                 $returnProperties = array_merge($returnProperties, $extraReturnProperties);
             }
             // unset non exportable fields for components
             $nonExpoFields = array('groups', 'tags', 'notes', 'contribution_status_id', 'pledge_status_id', 'pledge_payment_status_id');
             foreach ($nonExpoFields as $value) {
                 unset($returnProperties[$value]);
             }
         }
     }
     if ($mergeSameAddress) {
         //make sure the addressee fields are selected
         //while using merge same address feature
         $returnProperties['addressee'] = 1;
         $returnProperties['postal_greeting'] = 1;
         $returnProperties['email_greeting'] = 1;
         $returnProperties['street_name'] = 1;
         $returnProperties['household_name'] = 1;
         $returnProperties['street_address'] = 1;
         $returnProperties['city'] = 1;
         $returnProperties['state_province'] = 1;
         // some columns are required for assistance incase they are not already present
         $exportParams['merge_same_address']['temp_columns'] = array();
         $tempColumns = array('id', 'master_id', 'state_province_id', 'postal_greeting_id', 'addressee_id');
         foreach ($tempColumns as $column) {
             if (!array_key_exists($column, $returnProperties)) {
                 $returnProperties[$column] = 1;
                 $column = $column == 'id' ? 'civicrm_primary_id' : $column;
                 $exportParams['merge_same_address']['temp_columns'][$column] = 1;
             }
开发者ID:jenlampton,项目名称:civicrm-core,代码行数:67,代码来源:Export.php

示例8: __construct

 /**
  * Class constructor
  *
  * @param array $queryParams array of parameters for query
  * @param int   $action - action of search basic or advanced.
  * @param string   $contributionClause if the caller wants to further restrict the search (used in contributions)
  * @param boolean $single are we dealing only with one contact?
  * @param int     $limit  how many contributions do we want returned
  *
  * @return CRM_Contact_Selector
  * @access 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->_query = new CRM_Contact_BAO_Query($this->_queryParams, CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
     $this->_query->_distinctComponentClause = " civicrm_contribution.id";
     $this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
 }
开发者ID:hguru,项目名称:224Civi,代码行数:27,代码来源:Search.php

示例9: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function 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'));
     require_once 'CRM/Contribute/BAO/Query.php';
     CRM_Contribute_BAO_Query::buildSearchForm($this);
     /* 
      * add form checkboxes for each row. This is needed out here to conform to QF protocol 
      * of all elements being declared in builQuickForm 
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "toggleTaskAction( true ); return toggleCheckboxVals('mark_x_',this);"));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], null, null, array('onclick' => "toggleTaskAction( true ); return checkSelectedBox('" . $row['checkbox'] . "', '" . $this->getName() . "');"));
             }
         }
         $total = $cancel = 0;
         require_once "CRM/Core/Permission.php";
         $permission = CRM_Core_Permission::getPermission();
         require_once 'CRM/Contribute/Task.php';
         $tasks = array('' => ts('- more actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission);
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         $this->add('submit', $this->_printButtonName, ts('Print'), array('class' => 'form-submit', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 1);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', null, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', null, '', 'ts_all', array('onclick' => $this->getName() . ".toggleSelect.checked = false; toggleCheckboxVals('mark_x_',this); toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:39,代码来源:Search.php

示例10: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function 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::group();
     // 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);
     /*
      * add form checkboxes for each row. This is needed out here to conform to QF protocol
      * of all elements being declared in builQuickForm
      */
     $rows = $this->get('rows');
     if (is_array($rows)) {
         if (!$this->_single) {
             $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
             foreach ($rows as $row) {
                 $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row'));
             }
         }
         $total = $cancel = 0;
         $permission = CRM_Core_Permission::getPermission();
         $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission);
         $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
         $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'form-submit', 'id' => 'Go', 'onclick' => "return checkPerformAction('mark_x', '" . $this->getName() . "', 0);"));
         // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
         $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
     }
     // add buttons
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:46,代码来源:Search.php

示例11: civicrm_api3_contribution_get

/**
 * Retrieve a set of contributions, given a set of input params
 *
 * @param  array   $params           (reference ) input parameters
 * @param array    $returnProperties Which properties should be included in the
 * returned Contribution object. If NULL, the default
 * set of properties will be included.
 *
 * @return array (reference )        array of contributions, if error an array with an error id and error message
 * @static void
 * @access public
 * {@getfields Contribution_get}
 * @example ContributionGet.php
 */
function civicrm_api3_contribution_get($params)
{
    $options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get');
    $sort = CRM_Utils_Array::value('sort', $options, NULL);
    $offset = CRM_Utils_Array::value('offset', $options);
    $rowCount = CRM_Utils_Array::value('limit', $options);
    $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
    $inputParams = CRM_Utils_Array::value('input_params', $options, array());
    $returnProperties = CRM_Utils_Array::value('return', $options, NULL);
    if (empty($returnProperties)) {
        $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
    }
    $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
    $query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
    list($select, $from, $where, $having) = $query->query();
    $sql = "{$select} {$from} {$where} {$having}";
    if (!empty($sort)) {
        $sql .= " ORDER BY {$sort} ";
    }
    $sql .= " LIMIT {$offset}, {$rowCount} ";
    $dao = CRM_Core_DAO::executeQuery($sql);
    $contribution = array();
    while ($dao->fetch()) {
        //CRM-8662
        $contribution_details = $query->store($dao);
        $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
        $contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
        if (isset($contribution[$dao->contribution_id]['financial_type_id'])) {
            $contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id'];
        }
        // format soft credit for backward compatibility
        _civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
    }
    return civicrm_api3_create_success($contribution, $params, 'contribution', 'get', $dao);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:49,代码来源:Contribution.php

示例12: flushCache

 /**
  * Reset the various system caches and some important static variables.
  */
 public static function flushCache()
 {
     // flush out all cache entries so we can reload new data
     // a bit aggressive, but livable for now
     $cache = CRM_Utils_Cache::singleton();
     $cache->flush();
     // also reset the various static memory caches
     // reset the memory or array cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields', NULL, FALSE);
     // reset ACL cache
     CRM_ACL_BAO_Cache::resetCache();
     // reset various static arrays used here
     CRM_Contact_BAO_Contact::$_importableFields = CRM_Contact_BAO_Contact::$_exportableFields = CRM_Contribute_BAO_Contribution::$_importableFields = CRM_Contribute_BAO_Contribution::$_exportableFields = CRM_Pledge_BAO_Pledge::$_exportableFields = CRM_Contribute_BAO_Query::$_contributionFields = CRM_Core_BAO_CustomField::$_importFields = CRM_Core_BAO_Cache::$_cache = CRM_Core_DAO::$_dbColumnValueCache = NULL;
     CRM_Core_OptionGroup::flushAll();
     CRM_Utils_PseudoConstant::flushAll();
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:19,代码来源:System.php

示例13: _civicrm_api3_get_query_object

/**
 * Get dao query object based on input params.
 *
 * Ideally this would be merged with _civicrm_get_using_query_object but we need to resolve differences in what the
 * 2 variants call
 *
 * @param array $params
 * @param string $mode
 * @param string $entity
 *
 * @return array
 *   [CRM_Core_DAO|CRM_Contact_BAO_Query]
 */
function _civicrm_api3_get_query_object($params, $mode, $entity)
{
    $options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get');
    $sort = CRM_Utils_Array::value('sort', $options, NULL);
    $offset = CRM_Utils_Array::value('offset', $options);
    $rowCount = CRM_Utils_Array::value('limit', $options);
    $inputParams = CRM_Utils_Array::value('input_params', $options, array());
    $returnProperties = CRM_Utils_Array::value('return', $options, NULL);
    if (empty($returnProperties)) {
        $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode);
    }
    $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams, 0, FALSE, $entity);
    $query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, $mode, empty($params['check_permissions']));
    list($select, $from, $where, $having) = $query->query();
    $sql = "{$select} {$from} {$where} {$having}";
    if (!empty($sort)) {
        $sql .= " ORDER BY {$sort} ";
    }
    if (!empty($rowCount)) {
        $sql .= " LIMIT {$offset}, {$rowCount} ";
    }
    $dao = CRM_Core_DAO::executeQuery($sql);
    return array($dao, $query);
}
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:37,代码来源:utils.php

示例14: getBatchFinancialItems

 /**
  * Retrieve financial items assigned for a batch.
  *
  * @param int $entityID
  * @param array $returnValues
  * @param bool $notPresent
  * @param array $params
  * @param bool $getCount
  *
  * @return CRM_Core_DAO
  */
 public static function getBatchFinancialItems($entityID, $returnValues, $notPresent = NULL, $params = NULL, $getCount = FALSE)
 {
     if (!$getCount) {
         if (!empty($params['rowCount']) && $params['rowCount'] > 0) {
             $limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
         }
     }
     // action is taken depending upon the mode
     $select = 'civicrm_financial_trxn.id ';
     if (!empty($returnValues)) {
         $select .= " , " . implode(' , ', $returnValues);
     }
     $orderBy = " ORDER BY civicrm_financial_trxn.id";
     if (!empty($params['sort'])) {
         $orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String');
     }
     $from = "civicrm_financial_trxn\nLEFT JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id\nLEFT JOIN civicrm_entity_batch ON civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'\nAND civicrm_entity_batch.entity_id = civicrm_financial_trxn.id\nLEFT JOIN civicrm_contribution ON civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id\nLEFT JOIN civicrm_financial_type ON civicrm_financial_type.id = civicrm_contribution.financial_type_id\nLEFT JOIN civicrm_contact contact_a ON contact_a.id = civicrm_contribution.contact_id\nLEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id\n";
     $searchFields = array('sort_name', 'financial_type_id', 'contribution_page_id', 'payment_instrument_id', 'contribution_trxn_id', 'contribution_source', 'contribution_currency_type', 'contribution_pay_later', 'contribution_recurring', 'contribution_test', 'contribution_thankyou_date_is_not_null', 'contribution_receipt_date_is_not_null', 'contribution_pcp_made_through_id', 'contribution_pcp_display_in_roll', 'contribution_date_relative', 'contribution_amount_low', 'contribution_amount_high', 'contribution_in_honor_of', 'contact_tags', 'group', 'contribution_date_relative', 'contribution_date_high', 'contribution_date_low', 'contribution_check_number', 'contribution_status_id');
     $values = array();
     foreach ($searchFields as $field) {
         if (isset($params[$field])) {
             $values[$field] = $params[$field];
             if ($field == 'sort_name') {
                 $from .= " LEFT JOIN civicrm_contact contact_b ON contact_b.id = civicrm_contribution.contact_id\n          LEFT JOIN civicrm_email ON contact_b.id = civicrm_email.contact_id";
             }
             if ($field == 'contribution_in_honor_of') {
                 $from .= " LEFT JOIN civicrm_contact contact_b ON contact_b.id = civicrm_contribution.contact_id";
             }
             if ($field == 'contact_tags') {
                 $from .= " LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-{$params[$field]}` ON `civicrm_entity_tag-{$params[$field]}`.entity_id = contact_a.id";
             }
             if ($field == 'group') {
                 $from .= " LEFT JOIN civicrm_group_contact `civicrm_group_contact-{$params[$field]}` ON contact_a.id = `civicrm_group_contact-{$params[$field]}`.contact_id ";
             }
             if ($field == 'contribution_date_relative') {
                 $relativeDate = explode('.', $params[$field]);
                 $date = CRM_Utils_Date::relativeToAbsolute($relativeDate[0], $relativeDate[1]);
                 $values['contribution_date_low'] = $date['from'];
                 $values['contribution_date_high'] = $date['to'];
             }
             $searchParams = CRM_Contact_BAO_Query::convertFormValues($values);
             $query = new CRM_Contact_BAO_Query($searchParams, CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE, FALSE), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
             if ($field == 'contribution_date_high' || $field == 'contribution_date_low') {
                 $query->dateQueryBuilder($params[$field], 'civicrm_contribution', 'contribution_date', 'receive_date', 'Contribution Date');
             }
         }
     }
     if (!empty($query->_where[0])) {
         $where = implode(' AND ', $query->_where[0]) . " AND civicrm_entity_batch.batch_id IS NULL\n         AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'";
         $where = str_replace('civicrm_contribution.payment_instrument_id', 'civicrm_financial_trxn.payment_instrument_id', $where);
         $searchValue = TRUE;
     } else {
         $searchValue = FALSE;
     }
     if (!$searchValue) {
         if (!$notPresent) {
             $where = " ( civicrm_entity_batch.batch_id = {$entityID}\n        AND civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'\n        AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution') ";
         } else {
             $where = " ( civicrm_entity_batch.batch_id IS NULL\n        AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution')";
         }
     }
     $sql = "\nSELECT {$select}\nFROM   {$from}\nWHERE  {$where}\n       {$orderBy}\n";
     if (isset($limit)) {
         $sql .= "{$limit}";
     }
     $result = CRM_Core_DAO::executeQuery($sql);
     return $result;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:79,代码来源:Batch.php

示例15: 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));
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:70,代码来源:Task.php


注:本文中的CRM_Contribute_BAO_Query类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。