當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Contribute_BAO_ContributionRecur::fetch方法代碼示例

本文整理匯總了PHP中CRM_Contribute_BAO_ContributionRecur::fetch方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_BAO_ContributionRecur::fetch方法的具體用法?PHP CRM_Contribute_BAO_ContributionRecur::fetch怎麽用?PHP CRM_Contribute_BAO_ContributionRecur::fetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Contribute_BAO_ContributionRecur的用法示例。


在下文中一共展示了CRM_Contribute_BAO_ContributionRecur::fetch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_scheduled_contributions

/**
 * Gets recurring contributions that are scheduled to be processed today.
 *
 * @param $eway_token_clients
 *
 * @return array
 *   An array of contribution_recur objects.
 */
function get_scheduled_contributions($eway_token_clients)
{
    if (empty($eway_token_clients)) {
        return array();
    }
    $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
    // Get Recurring Contributions that are In Progress and are due to be processed by the eWAY Recurring processor
    $scheduled_today = new CRM_Contribute_BAO_ContributionRecur();
    if (_versionAtLeast(4.4)) {
        $scheduled_today->whereAdd("`next_sched_contribution_date` <= '" . date('Y-m-d 00:00:00') . "'");
    } else {
        $scheduled_today->whereAdd("`next_sched_contribution` <= '" . date('Y-m-d 00:00:00') . "'");
    }
    $scheduled_today->whereAdd("`contribution_status_id` = " . array_search('In Progress', $contributionStatus));
    $scheduled_today->whereAdd("`payment_processor_id` in (" . implode(', ', array_keys($eway_token_clients)) . ")");
    $scheduled_today->find();
    $result = array();
    while ($scheduled_today->fetch()) {
        $past_contribution = get_first_contribution_from_recurring($scheduled_today->id);
        $new_contribution_record = new CRM_Contribute_BAO_Contribution();
        $new_contribution_record->contact_id = $scheduled_today->contact_id;
        $new_contribution_record->receive_date = CRM_Utils_Date::isoToMysql(date('Y-m-d H:i:s'));
        $new_contribution_record->total_amount = $scheduled_today->amount;
        $new_contribution_record->non_deductible_amount = $scheduled_today->amount;
        $new_contribution_record->net_amount = $scheduled_today->amount;
        $new_contribution_record->invoice_id = md5(uniqid(rand(), TRUE));
        $new_contribution_record->contribution_recur_id = $scheduled_today->id;
        $new_contribution_record->contribution_status_id = array_search('Pending', $contributionStatus);
        if (_versionAtLeast(4.4)) {
            $new_contribution_record->financial_type_id = $scheduled_today->financial_type_id;
        } else {
            $new_contribution_record->contribution_type_id = $scheduled_today->contribution_type_id;
        }
        $new_contribution_record->currency = $scheduled_today->currency;
        // copy info from previous contribution belonging to the same recurring contribution
        if ($past_contribution != NULL) {
            $new_contribution_record->contribution_page_id = $past_contribution->contribution_page_id;
            $new_contribution_record->payment_instrument_id = $past_contribution->payment_instrument_id;
            $new_contribution_record->source = $past_contribution->source;
            $new_contribution_record->address_id = $past_contribution->address_id;
        }
        $result[] = array('type' => 'Scheduled', 'contribution' => clone $new_contribution_record, 'contribution_recur' => clone $scheduled_today);
    }
    return $result;
}
開發者ID:xurizaemon,項目名稱:com.chrischinchilla.ewayrecurring,代碼行數:53,代碼來源:Eway.php


注:本文中的CRM_Contribute_BAO_ContributionRecur::fetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。