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


PHP CRM_Contribute_BAO_Contribution::checkDuplicate方法代碼示例

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


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

示例1: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 function add(&$params, &$ids)
 {
     require_once 'CRM/Utils/Hook.php';
     $duplicates = array();
     if (CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates)) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_CORE_ERROR_DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching contribution(s): {$d}");
         return $error;
     }
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution =& new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->domain_id = CRM_Utils_Array::value('domain', $ids, CRM_Core_Config::domainID());
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config =& CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:47,代碼來源:Contribution.php

示例2: rules

 protected static function rules($params, $files, $self)
 {
     $errors = array();
     $secondaryContactId = CRM_Utils_Array::value('secondary_contact_id', $params);
     $sendConfirmation = CRM_Utils_Array::value('send_confirmation', $params);
     if ($sendConfirmation) {
         $emailTo = CRM_Utils_Array::value('email_to', $params);
         if (!$emailTo) {
             $errors['email_to'] = ts('Please select a contact(s) to send email to.');
         }
         if (!$self->_id) {
             if ($emailTo == 2 && !$secondaryContactId || $emailTo == 3 && !$secondaryContactId) {
                 $errors['email_to'] = ts('Please select a secondary contact.');
             }
         }
         $fromEmailAddreess = CRM_Utils_Array::value('from_email_address', $params);
         if (!$fromEmailAddreess) {
             $errors['from_email_address'] = ts('Please select a from email address.');
         }
     }
     $recordContribution = CRM_Utils_Array::value('record_contribution', $params);
     if ($recordContribution) {
         $selectPaymentContact = CRM_Utils_Array::value('select_payment_contact', $params);
         if (!$selectPaymentContact) {
             $errors['select_payment_contact'] = ts('Please select a contact for recording payment.');
         }
         if (!$self->_id) {
             if ($selectPaymentContact == 2 && !$secondaryContactId) {
                 $errors['select_payment_contact'] = ts('Please select a contact for recording payment');
             }
         }
         $financialTypeId = CRM_Utils_Array::value('financial_type_id', $params);
         if (!$financialTypeId) {
             $errors['financial_type_id'] = ts('Please select a financial type.');
         }
         $trxnId = CRM_Utils_Array::value('trxn_id', $params);
         $duplicates = array();
         if ($trxnId && CRM_Contribute_BAO_Contribution::checkDuplicate(array('trxn_id' => $trxnId), $duplicates)) {
             $d = implode(', ', $duplicates);
             $errors['trxn_id'] = "Duplicate error - existing contribution record(s) have a matching Transaction ID. Contribution record ID is: {$d}";
         }
         $receivedDate = CRM_Utils_Array::value('receive_date', $params);
         if (!$receivedDate) {
             $errors['receive_date'] = ts('This field is required.');
         }
         $paymentInstrumentId = CRM_Utils_Array::value('payment_instrument_id', $params);
         if (!$paymentInstrumentId) {
             $errors['payment_instrument_id'] = ts('Please select a payment instrument.');
         }
         $contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params);
         if (!$contributionStatusId) {
             $errors['contribution_status_id'] = ts('Please select a valid payment status.');
         }
     }
     return $errors;
 }
開發者ID:sushantpaste,項目名稱:civibooking,代碼行數:56,代碼來源:Base.php

示例3:

function &_crm_duplicate_formatted_contribution(&$params)
{
    require_once 'CRM/Contribute/BAO/Contribution.php';
    return CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicate);
}
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:5,代碼來源:utils.php

示例4: _civicrm_contribute_duplicate_check

/**
 * Check if there is a contribution with the same trxn_id or invoice_id
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contribution.
 *
 * @return array|CRM_Error
 * @access private
 */
function _civicrm_contribute_duplicate_check(&$params)
{
    require_once 'CRM/Contribute/BAO/Contribution.php';
    $duplicates = array();
    $result = CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates);
    if ($result) {
        $d = implode(', ', $duplicates);
        $error = CRM_Core_Error::createError("Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}", CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', $d);
        return civicrm_create_error($error->pop(), $d);
    } else {
        return array();
    }
}
開發者ID:ksecor,項目名稱:civicrm,代碼行數:22,代碼來源:Contribute.php


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