/**
* Field for all the objects related to this contribution
+ *
* @var array of objects (e.g membership object, participant object)
*/
- public $_relatedObjects = array();
+ public $_relatedObjects = [];
/**
* Field for the component - either 'event' (participant) or 'contribute'
*
* @return \CRM_Contribute_BAO_Contribution
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = []) {
if (empty($params)) {
return NULL;
}
//per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
$contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
- $duplicates = array();
+ $duplicates = [];
if (self::checkDuplicate($params, $duplicates, $contributionID)) {
$message = ts("Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: " . implode(', ', $duplicates));
throw new CRM_Core_Exception($message);
}
// first clean up all the money fields
- $moneyFields = array(
+ $moneyFields = [
'total_amount',
'net_amount',
'fee_amount',
'non_deductible_amount',
- );
+ ];
//if priceset is used, no need to cleanup money
if (!empty($params['skipCleanMoney'])) {
else {
// Since the fee amount is expecting this (later on) ensure it is always set.
// It would only not be set for an update where it is unchanged.
- $params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', array('id' => $contributionID, 'return' => 'contribution_status_id'));
+ $params['contribution_status_id'] = civicrm_api3('Contribution', 'getvalue', [
+ 'id' => $contributionID,
+ 'return' => 'contribution_status_id',
+ ]);
}
if (!$contributionID
/**
* Get defaults for new entity.
+ *
* @return array
*/
public static function getDefaults() {
- return array(
+ return [
'payment_instrument_id' => key(CRM_Core_OptionGroup::values('payment_instrument',
- FALSE, FALSE, FALSE, 'AND is_default = 1')
+ FALSE, FALSE, FALSE, 'AND is_default = 1')
),
- 'contribution_status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
- );
+ 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
+ ];
}
/**
* @throws CRM_Core_Exception
*/
public static function getValuesWithMappings($params) {
- $values = $ids = array();
+ $values = $ids = [];
$contribution = self::getValues($params, $values, $ids);
if (is_null($contribution)) {
throw new CRM_Core_Exception('No contribution found');
if (isset($params['fee_amount']) || isset($params['total_amount'])) {
// We have an existing contribution and fee_amount or total_amount has been passed in but not net_amount.
// net_amount may need adjusting.
- $contribution = civicrm_api3('Contribution', 'getsingle', array(
+ $contribution = civicrm_api3('Contribution', 'getsingle', [
'id' => $contributionID,
- 'return' => array('total_amount', 'net_amount', 'fee_amount'),
- ));
+ 'return' => ['total_amount', 'net_amount', 'fee_amount'],
+ ]);
$totalAmount = isset($params['total_amount']) ? $params['total_amount'] : CRM_Utils_Array::value('total_amount', $contribution);
$feeAmount = isset($params['fee_amount']) ? $params['fee_amount'] : CRM_Utils_Array::value('fee_amount', $contribution);
$params['net_amount'] = $totalAmount - $feeAmount;
*/
protected static function getBillingAddressParams($params, $billingLocationTypeID) {
$hasBillingField = FALSE;
- $billingFields = array(
+ $billingFields = [
'street_address',
'city',
'state_province_id',
'postal_code',
'country_id',
- );
+ ];
//build address array
- $addressParams = array();
+ $addressParams = [];
$addressParams['location_type_id'] = $billingLocationTypeID;
$addressParams['is_billing'] = 1;
$hasBillingField = TRUE;
}
}
- return array($hasBillingField, $addressParams);
+ return [$hasBillingField, $addressParams];
}
/**
$addressParams[substr($name, 9)] = $addressParams[$field];
}
}
- return array($hasBillingField, $addressParams);
+ return [$hasBillingField, $addressParams];
}
/**
SELECT membership_num_terms FROM civicrm_line_item li
LEFT JOIN civicrm_price_field_value v ON li.price_field_value_id = v.id
WHERE contribution_id = %1 AND membership_type_id = %2",
- array(1 => array($contributionID, 'Integer'), 2 => array($membershipTypeID, 'Integer'))
+ [1 => [$contributionID, 'Integer'], 2 => [$membershipTypeID, 'Integer']]
);
// default of 1 is precautionary
return empty($numTerms) ? 1 : $numTerms;
*
* @return CRM_Contribute_BAO_Contribution
*/
- public static function create(&$params, $ids = array()) {
- $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date', 'revenue_recognition_date');
+ public static function create(&$params, $ids = []) {
+ $dateFields = [
+ 'receive_date',
+ 'cancel_date',
+ 'receipt_date',
+ 'thankyou_date',
+ 'revenue_recognition_date',
+ ];
foreach ($dateFields as $df) {
if (isset($params[$df])) {
$params[$df] = CRM_Utils_Date::isoToMysql($params[$df]);
$session = CRM_Core_Session::singleton();
if (!empty($params['note'])) {
- $noteParams = array(
+ $noteParams = [
'entity_table' => 'civicrm_contribution',
'note' => $params['note'],
'entity_id' => $contribution->id,
'contact_id' => $session->get('userID'),
'modified_date' => date('Ymd'),
- );
+ ];
if (!$noteParams['contact_id']) {
$noteParams['contact_id'] = $params['contact_id'];
}
// make entry in batch entity batch table
if (!empty($params['batch_id'])) {
// in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
- $titleFields = array(
+ $titleFields = [
'contact_id',
'total_amount',
'currency',
'financial_type_id',
- );
+ ];
$retrieveRequired = 0;
foreach ($titleFields as $titleField) {
if (!isset($contribution->$titleField)) {
$transaction->commit();
- $activity = civicrm_api3('Activity', 'get', array(
+ $activity = civicrm_api3('Activity', 'get', [
'source_record_id' => $contribution->id,
- 'options' => array('limit' => 1),
+ 'options' => ['limit' => 1],
'sequential' => 1,
'activity_type_id' => 'Contribution',
- 'return' => array('id', 'campaign'),
- ));
+ 'return' => ['id', 'campaign'],
+ ]);
//CRM-18406: Update activity when edit contribution.
if ($activity['count']) {
"action=view&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home"
);
// in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
- $titleFields = array(
+ $titleFields = [
'contact_id',
'total_amount',
'currency',
'financial_type_id',
- );
+ ];
$retrieveRequired = 0;
foreach ($titleFields as $titleField) {
if (!isset($contribution->$titleField)) {
$financialType = CRM_Contribute_PseudoConstant::financialType($contribution->financial_type_id);
$title = CRM_Contact_BAO_Contact::displayName($contribution->contact_id) . ' - (' . CRM_Utils_Money::format($contribution->total_amount, $contribution->currency) . ' ' . ' - ' . $financialType . ')';
- $recentOther = array();
+ $recentOther = [];
if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution',
"action=update&reset=1&id={$contribution->id}&cid={$contribution->contact_id}&context=home"
public static function &importableFields($contactType = 'Individual', $status = TRUE) {
if (!self::$_importableFields) {
if (!self::$_importableFields) {
- self::$_importableFields = array();
+ self::$_importableFields = [];
}
if (!$status) {
- $fields = array('' => array('title' => ts('- do not import -')));
+ $fields = ['' => ['title' => ts('- do not import -')]];
}
else {
- $fields = array('' => array('title' => ts('- Contribution Fields -')));
+ $fields = ['' => ['title' => ts('- Contribution Fields -')]];
}
$note = CRM_Core_DAO_Note::import();
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
- $ruleParams = array(
+ $ruleParams = [
'contact_type' => $contactType,
'used' => 'Unsupervised',
- );
+ ];
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
- $tmpContactField = array();
+ $tmpContactField = [];
if (is_array($fieldsArray)) {
foreach ($fieldsArray as $value) {
//skip if there is no dupe rule
public static function &exportableFields($checkPermission = TRUE) {
if (!self::$_exportableFields) {
if (!self::$_exportableFields) {
- self::$_exportableFields = array();
+ self::$_exportableFields = [];
}
$fields = CRM_Contribute_DAO_Contribution::export();
$financialAccount = CRM_Financial_DAO_FinancialAccount::export();
- $contributionPage = array(
- 'contribution_page' => array(
+ $contributionPage = [
+ 'contribution_page' => [
'title' => ts('Contribution Page'),
'name' => 'contribution_page',
'where' => 'civicrm_contribution_page.title',
'data_type' => CRM_Utils_Type::T_STRING,
- ),
- );
+ ],
+ ];
- $contributionNote = array(
- 'contribution_note' => array(
+ $contributionNote = [
+ 'contribution_note' => [
'title' => ts('Contribution Note'),
'name' => 'contribution_note',
'data_type' => CRM_Utils_Type::T_TEXT,
- ),
- );
+ ],
+ ];
- $extraFields = array(
- 'contribution_batch' => array(
+ $extraFields = [
+ 'contribution_batch' => [
'title' => ts('Batch Name'),
- ),
- );
+ ],
+ ];
// CRM-17787
- $campaignTitle = array(
- 'contribution_campaign_title' => array(
+ $campaignTitle = [
+ 'contribution_campaign_title' => [
'title' => ts('Campaign Title'),
'name' => 'campaign_title',
'where' => 'civicrm_campaign.title',
'data_type' => CRM_Utils_Type::T_STRING,
- ),
- );
- $softCreditFields = array(
- 'contribution_soft_credit_name' => array(
+ ],
+ ];
+ $softCreditFields = [
+ 'contribution_soft_credit_name' => [
'name' => 'contribution_soft_credit_name',
'title' => ts('Soft Credit For'),
'where' => 'civicrm_contact_d.display_name',
'data_type' => CRM_Utils_Type::T_STRING,
- ),
- 'contribution_soft_credit_amount' => array(
+ ],
+ 'contribution_soft_credit_amount' => [
'name' => 'contribution_soft_credit_amount',
'title' => ts('Soft Credit Amount'),
'where' => 'civicrm_contribution_soft.amount',
'data_type' => CRM_Utils_Type::T_MONEY,
- ),
- 'contribution_soft_credit_type' => array(
+ ],
+ 'contribution_soft_credit_type' => [
'name' => 'contribution_soft_credit_type',
'title' => ts('Soft Credit Type'),
'where' => 'contribution_softcredit_type.label',
'data_type' => CRM_Utils_Type::T_STRING,
- ),
- 'contribution_soft_credit_contribution_id' => array(
+ ],
+ 'contribution_soft_credit_contribution_id' => [
'name' => 'contribution_soft_credit_contribution_id',
'title' => ts('Soft Credit For Contribution ID'),
'where' => 'civicrm_contribution_soft.contribution_id',
'data_type' => CRM_Utils_Type::T_INT,
- ),
- 'contribution_soft_credit_contact_id' => array(
+ ],
+ 'contribution_soft_credit_contact_id' => [
'name' => 'contribution_soft_credit_contact_id',
'title' => ts('Soft Credit For Contact ID'),
'where' => 'civicrm_contact_d.id',
'data_type' => CRM_Utils_Type::T_INT,
- ),
- );
+ ],
+ ];
$fields = array_merge($fields, $contributionPage,
$contributionNote, $extraFields, $softCreditFields, $financialAccount, $campaignTitle,
* @param $pledgeID
* @param $pledgePaymentIDs
* @param $contributionStatusId
+ *
* @return array
*/
protected static function cancel($processContributionObject, $memberships, $contributionId, $membershipStatuses, $updateResult, $participant, $oldStatus, $pledgePayment, $pledgeID, $pledgePaymentIDs, $contributionStatusId) {
* @return array|null
*/
public static function getTotalAmountAndCount($status = NULL, $startDate = NULL, $endDate = NULL) {
- $where = array();
+ $where = [];
switch ($status) {
case 'Valid':
$where[] = 'contribution_status_id = 1';
";
$dao = CRM_Core_DAO::executeQuery($query);
- $amount = array();
+ $amount = [];
$count = 0;
while ($dao->fetch()) {
$count += $dao->total_count;
$amount[] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
}
if ($count) {
- return array(
+ return [
'amount' => implode(', ', $amount),
'count' => $count,
- );
+ ];
}
return NULL;
}
$results = NULL;
//delete activity record
- $params = array(
+ $params = [
'source_record_id' => $id,
// activity type id for contribution
'activity_type_id' => 6,
- );
+ ];
CRM_Activity_BAO_Activity::deleteActivity($params);
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
// delete the recently created Contribution
- $contributionRecent = array(
+ $contributionRecent = [
'id' => $id,
'type' => 'Contribution',
- );
+ ];
CRM_Utils_Recent::del($contributionRecent);
return $results;
* @throws \CiviCRM_API3_Exception
*/
public static function failPayment($contributionID, $contactID, $message) {
- civicrm_api3('activity', 'create', array(
+ civicrm_api3('activity', 'create', [
'activity_type_id' => 'Failed Payment',
'details' => $message,
'subject' => ts('Payment failed at payment processor'),
'source_record_id' => $contributionID,
- 'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
- $contactID,
- ));
+ 'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() : $contactID,
+ ]);
// CRM-20336 Make sure that the contribution status is Failed, not Pending.
- civicrm_api3('contribution', 'create', array(
+ civicrm_api3('contribution', 'create', [
'id' => $contributionID,
'contribution_status_id' => 'Failed',
- ));
+ ]);
}
/**
$trxn_id = CRM_Utils_Array::value('trxn_id', $input);
$invoice_id = CRM_Utils_Array::value('invoice_id', $input);
- $clause = array();
- $input = array();
+ $clause = [];
+ $input = [];
if ($trxn_id) {
$clause[] = "trxn_id = %1";
- $input[1] = array($trxn_id, 'String');
+ $input[1] = [$trxn_id, 'String'];
}
if ($invoice_id) {
$clause[] = "invoice_id = %2";
- $input[2] = array($invoice_id, 'String');
+ $input[2] = [$invoice_id, 'String'];
}
if (empty($clause)) {
$clause = implode(' OR ', $clause);
if ($id) {
$clause = "( $clause ) AND id != %3";
- $input[3] = array($id, 'Integer');
+ $input[3] = [$id, 'Integer'];
}
$query = "SELECT id FROM civicrm_contribution WHERE $clause";
* Add extra fields specific to contribution.
*/
public static function getSpecialContributionFields() {
- $extraFields = array(
- 'contribution_soft_credit_name' => array(
+ $extraFields = [
+ 'contribution_soft_credit_name' => [
'name' => 'contribution_soft_credit_name',
'title' => ts('Soft Credit Name'),
'headerPattern' => '/^soft_credit_name$/i',
'where' => 'civicrm_contact_d.display_name',
- ),
- 'contribution_soft_credit_email' => array(
+ ],
+ 'contribution_soft_credit_email' => [
'name' => 'contribution_soft_credit_email',
'title' => ts('Soft Credit Email'),
'headerPattern' => '/^soft_credit_email$/i',
'where' => 'soft_email.email',
- ),
- 'contribution_soft_credit_phone' => array(
+ ],
+ 'contribution_soft_credit_phone' => [
'name' => 'contribution_soft_credit_phone',
'title' => ts('Soft Credit Phone'),
'headerPattern' => '/^soft_credit_phone$/i',
'where' => 'soft_phone.phone',
- ),
- 'contribution_soft_credit_contact_id' => array(
+ ],
+ 'contribution_soft_credit_contact_id' => [
'name' => 'contribution_soft_credit_contact_id',
'title' => ts('Soft Credit Contact ID'),
'headerPattern' => '/^soft_credit_contact_id$/i',
'where' => 'civicrm_contribution_soft.contact_id',
- ),
- 'contribution_pcp_title' => array(
+ ],
+ 'contribution_pcp_title' => [
'name' => 'contribution_pcp_title',
'title' => ts('Personal Campaign Page Title'),
'headerPattern' => '/^contribution_pcp_title$/i',
'where' => 'contribution_pcp.title',
- ),
- );
+ ],
+ ];
return $extraFields;
}
";
$config = CRM_Core_Config::singleton();
- $params = array(1 => array($pageID, 'Integer'));
+ $params = [1 => [$pageID, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
- return array($dao->goal, $dao->total);
+ return [$dao->goal, $dao->total];
}
else {
- return array(NULL, NULL);
+ return [NULL, NULL];
}
}
*
* The returned array provides details about the original contribution & donor.
*
- * @todo - this is a confusing function called from one place. It has a test. It would be
- * nice to deprecate it.
- *
* @param int $honorId
* In Honor of Contact ID.
*
* @return array
* list of contribution fields
+ * @todo - this is a confusing function called from one place. It has a test. It would be
+ * nice to deprecate it.
+ *
*/
public static function getHonorContacts($honorId) {
- $params = array();
+ $params = [];
$honorDAO = new CRM_Contribute_DAO_ContributionSoft();
$honorDAO->contact_id = $honorId;
$honorDAO->find();
$query = self::getAnnualQuery($contactIDs);
$dao = CRM_Core_DAO::executeQuery($query);
$count = 0;
- $amount = $average = array();
+ $amount = $average = [];
while ($dao->fetch()) {
if ($dao->count > 0 && $dao->amount > 0) {
$count += $dao->count;
}
}
if ($count > 0) {
- return array(
+ return [
$count,
implode(', ', $amount),
implode(', ', $average),
- );
+ ];
}
- return array(0, 0, 0);
+ return [0, 0, 0];
}
/**
public static function checkDuplicateIds($params) {
$dao = new CRM_Contribute_DAO_Contribution();
- $clause = array();
- $input = array();
+ $clause = [];
+ $input = [];
foreach ($params as $k => $v) {
if ($v) {
$clause[] = "$k = '$v'";
* associated array
*/
public static function getContributionDetails($exportMode, $componentIds) {
- $paymentDetails = array();
+ $paymentDetails = [];
$componentClause = ' IN ( ' . implode(',', $componentIds) . ' ) ';
if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
- $paymentDetails[$dao->id] = array(
+ $paymentDetails[$dao->id] = [
'total_amount' => $dao->total_amount,
'contribution_status' => $dao->status,
'receive_date' => $dao->receive_date,
'pay_instru' => $dao->payment_instrument,
'trxn_id' => $dao->trxn_id,
- );
+ ];
}
return $paymentDetails;
* @param int $contactId
*/
public static function deleteAddress($contributionId = NULL, $contactId = NULL) {
- $clauses = array();
+ $clauses = [];
$contactJoin = NULL;
if ($contributionId) {
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
- $params = array('id' => $dao->id);
+ $params = ['id' => $dao->id];
CRM_Core_BAO_Block::blockDelete('Address', $params);
}
}
public static function checkOnlinePendingContribution($componentId, $componentName) {
$contributionId = NULL;
if (!$componentId ||
- !in_array($componentName, array('Event', 'Membership'))
+ !in_array($componentName, ['Event', 'Membership'])
) {
return $contributionId;
}
*
* This function by-passes hooks - to address this - don't use this function.
*
- * @deprecated
- *
- * Use api contribute.completetransaction
- * For failures use failPayment (preferably exposing by api in the process).
- *
* @param array $params
* @param bool $processContributionObject
*
* @return array
* @throws \Exception
+ * @deprecated
+ *
+ * Use api contribute.completetransaction
+ * For failures use failPayment (preferably exposing by api in the process).
+ *
*/
public static function transitionComponents($params, $processContributionObject = FALSE) {
// get minimum required values.
// if we already processed contribution object pass previous status id.
$previousContriStatusId = CRM_Utils_Array::value('previous_contribution_status_id', $params);
- $updateResult = array();
+ $updateResult = [];
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
// we process only ( Completed, Cancelled, or Failed ) contributions.
if (!$contributionId ||
- !in_array($contributionStatusId, array(
+ !in_array($contributionStatusId, [
array_search('Completed', $contributionStatuses),
array_search('Cancelled', $contributionStatuses),
array_search('Failed', $contributionStatuses),
- ))
+ ])
) {
return $updateResult;
}
$baseIPN = new CRM_Core_Payment_BaseIPN();
- $input = $ids = $objects = array();
+ $input = $ids = $objects = [];
$input['component'] = CRM_Utils_Array::value('component', $componentDetails);
$ids['contribution'] = $contributionId;
// only pending contribution related object processed.
if ($previousContriStatusId &&
- !in_array($contributionStatuses[$previousContriStatusId], array('Pending', 'Partially paid'))
+ !in_array($contributionStatuses[$previousContriStatusId], [
+ 'Pending',
+ 'Partially paid',
+ ])
) {
// this is case when we already processed contribution object.
return $updateResult;
}
elseif (!$previousContriStatusId &&
- !in_array($contributionStatuses[$contribution->contribution_status_id], array('Pending', 'Partially paid'))
+ !in_array($contributionStatuses[$contribution->contribution_status_id], [
+ 'Pending',
+ 'Partially paid',
+ ])
) {
// this is case when we are going to process contribution object later.
return $updateResult;
(array) $membership
);
- $formattedParams = array(
+ $formattedParams = [
'status_id' => CRM_Utils_Array::value('id', $calcStatus,
array_search('Current', $membershipStatuses)
),
'join_date' => CRM_Utils_Date::customFormat($dates['join_date'], $format),
'start_date' => CRM_Utils_Date::customFormat($dates['start_date'], $format),
'end_date' => CRM_Utils_Date::customFormat($dates['end_date'], $format),
- );
+ ];
CRM_Utils_Hook::pre('edit', 'Membership', $membership->id, $formattedParams);
$membership->save();
//updating the membership log
- $membershipLog = array();
+ $membershipLog = [];
$membershipLog = $formattedParams;
$logStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('log_start_date', $dates), $format);
$logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : $formattedParams['start_date'];
//update related Memberships.
CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formattedParams);
- foreach (array('Membership Signup', 'Membership Renewal') as $activityType) {
+ foreach (['Membership Signup', 'Membership Renewal'] as $activityType) {
$scheduledActivityID = CRM_Utils_Array::value('id',
civicrm_api3('Activity', 'Get',
- array(
+ [
'source_record_id' => $membership->id,
'activity_type_id' => $activityType,
'status_id' => 'Scheduled',
- 'options' => array(
+ 'options' => [
'limit' => 1,
'sort' => 'id DESC',
- ),
- )
+ ],
+ ]
)
);
// 1. Update Schedule Membership Signup/Renewal activity to completed on successful payment of pending membership
// 2. OR Create renewal activity scheduled if its membership renewal will be paid later
if ($scheduledActivityID) {
- CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $membership->contact_id, array('id' => $scheduledActivityID));
+ CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $membership->contact_id, ['id' => $scheduledActivityID]);
break;
}
}
CRM_Activity_BAO_Activity::addActivity($membership,
'Change Membership Status',
NULL,
- array(
+ [
'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}",
'source_contact_id' => $membershipLog['modified_id'],
'priority_id' => 'Normal',
- )
+ ]
);
}
// process contribution object.
if ($processContribution) {
- $contributionParams = array();
- $fields = array(
+ $contributionParams = [];
+ $fields = [
'contact_id',
'total_amount',
'receive_date',
'non_deductible_amount',
'receipt_date',
'check_number',
- );
+ ];
foreach ($fields as $field) {
if (empty($params[$field])) {
continue;
$contributionParams[$field] = $params[$field];
}
- $ids = array('contribution' => $contributionId);
+ $ids = ['contribution' => $contributionId];
$contribution = CRM_Contribute_BAO_Contribution::create($contributionParams, $ids);
}
* @return array
*/
public static function getComponentDetails($contributionId) {
- $componentDetails = $pledgePayment = array();
+ $componentDetails = $pledgePayment = [];
if (!$contributionId) {
return $componentDetails;
}
WHERE c.id = $contributionId";
$dao = CRM_Core_DAO::executeQuery($query);
- $componentDetails = array();
+ $componentDetails = [];
while ($dao->fetch()) {
$componentDetails['component'] = $dao->participant_id ? 'event' : 'contribute';
}
if ($dao->membership_id) {
if (!isset($componentDetails['membership'])) {
- $componentDetails['membership'] = $componentDetails['membership_type'] = array();
+ $componentDetails['membership'] = $componentDetails['membership_type'] = [];
}
$componentDetails['membership'][] = $dao->membership_id;
$componentDetails['membership_type'][] = $dao->membership_type_id;
}
if (!empty($contributionParams['contribution_recur_id'])) {
- $recurringContribution = civicrm_api3('ContributionRecur', 'getsingle', array(
+ $recurringContribution = civicrm_api3('ContributionRecur', 'getsingle', [
'id' => $contributionParams['contribution_recur_id'],
- ));
+ ]);
if (!empty($recurringContribution['campaign_id'])) {
// CRM-17718 the campaign id on the contribution recur record should get precedence.
$contributionParams['campaign_id'] = $recurringContribution['campaign_id'];
}
$templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution(
$contributionParams['contribution_recur_id'],
- array_intersect_key($contributionParams, array('total_amount' => TRUE, 'financial_type_id' => TRUE))
+ array_intersect_key($contributionParams, [
+ 'total_amount' => TRUE,
+ 'financial_type_id' => TRUE,
+ ])
);
$input['line_item'] = $contributionParams['line_item'] = $templateContribution['line_item'];
*/
public static function getOnbehalfIds($contributionId, $contributorId = NULL) {
- $ids = array();
+ $ids = [];
if (!$contributionId) {
return $ids;
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
- $params = array(
- 1 => array($activityTypeId, 'Integer'),
- 2 => array($contributionId, 'Integer'),
- 3 => array($sourceID, 'Integer'),
- );
+ $params = [
+ 1 => [$activityTypeId, 'Integer'],
+ 2 => [$contributionId, 'Integer'],
+ 3 => [$sourceID, 'Integer'],
+ ];
$sourceContactId = CRM_Core_DAO::singleValueQuery($activityQuery, $params);
else {
$year = date('Y');
}
- $year = array('Y' => $year);
+ $year = ['Y' => $year];
$yearDate = $config->fiscalYearStart;
$yearDate = array_merge($year, $yearDate);
$yearDate = CRM_Utils_Date::format($yearDate);
$now = date('Ymd');
- return array(
+ return [
'now' => $now,
'yearDate' => $yearDate,
'monthDate' => $monthDate,
- );
+ ];
}
/**
* Load objects relations to contribution object.
* Objects are stored in the $_relatedObjects property
* In the first instance we are just moving functionality from BASEIpn -
+ *
* @see http://issues.civicrm.org/jira/browse/CRM-9996
*
* Note that the unit test for the BaseIPN class tests this function
}
// todo remove strtolower - check consistency
if (strtolower($this->_component) == 'event') {
- $eventParams = array('id' => $this->_relatedObjects['participant']->event_id);
- $values['event'] = array();
+ $eventParams = ['id' => $this->_relatedObjects['participant']->event_id];
+ $values['event'] = [];
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
//get location details
- $locationParams = array('entity_id' => $this->_relatedObjects['participant']->event_id, 'entity_table' => 'civicrm_event');
+ $locationParams = [
+ 'entity_id' => $this->_relatedObjects['participant']->event_id,
+ 'entity_table' => 'civicrm_event',
+ ];
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
- $ufJoinParams = array(
+ $ufJoinParams = [
'entity_table' => 'civicrm_event',
'entity_id' => $ids['event'],
'module' => 'CiviEvent',
- );
+ ];
list($custom_pre_id,
$custom_post_ids
if (isset($ids['onbehalf_dupe_alert'])) {
$values['onbehalf_dupe_alert'] = $ids['onbehalf_dupe_alert'];
}
- $entityBlock = array(
+ $entityBlock = [
'contact_id' => $ids['contact'],
'location_type_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType',
'Home', 'id', 'name'
),
- );
+ ];
$address = CRM_Core_BAO_Address::getValues($entityBlock);
$template->assign('onBehalfAddress', $address[$entityBlock['location_type_id']]['display']);
}
*
* @return array
*/
- public function _gatherMessageValues($input, &$values, $ids = array()) {
+ public function _gatherMessageValues($input, &$values, $ids = []) {
// set display address of contributor
if ($this->address_id) {
- $addressParams = array('id' => $this->address_id);
+ $addressParams = ['id' => $this->address_id];
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
}
// Else we assign the billing address of the contribution contact.
else {
- $addressParams = array('contact_id' => $this->contact_id, 'is_billing' => 1);
+ $addressParams = ['contact_id' => $this->contact_id, 'is_billing' => 1];
$addressDetails = (array) CRM_Core_BAO_Address::getValues($addressParams);
$addressDetails = array_values($addressDetails);
}
// This is precautionary as there are some legacy flows, but it should really be
// loaded by now.
if (!isset($this->_relatedObjects['contributionPage'])) {
- $this->loadRelatedEntitiesByID(array('contributionPage' => $this->contribution_page_id));
+ $this->loadRelatedEntitiesByID(['contributionPage' => $this->contribution_page_id]);
}
// CRM-8254 - override default currency if applicable
$config = CRM_Core_Config::singleton();
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->id);
if (!empty($lineItems)) {
$firstLineItem = reset($lineItems);
- $priceSet = array();
+ $priceSet = [];
if (CRM_Utils_Array::value('price_set_id', $firstLineItem)) {
- $priceSet = civicrm_api3('PriceSet', 'getsingle', array('id' => $firstLineItem['price_set_id'], 'return' => 'is_quick_config, id'));
+ $priceSet = civicrm_api3('PriceSet', 'getsingle', [
+ 'id' => $firstLineItem['price_set_id'],
+ 'return' => 'is_quick_config, id',
+ ]);
$values['priceSetID'] = $priceSet['id'];
}
foreach ($lineItems as &$eachItem) {
if (isset($this->_relatedObjects['membership'])
- && is_array($this->_relatedObjects['membership'])
- && array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
+ && is_array($this->_relatedObjects['membership'])
+ && array_key_exists($eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->join_date);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->start_date);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['membership_type_id']]->end_date);
}
else {
// event
- $eventParams = array(
+ $eventParams = [
'id' => $this->_relatedObjects['event']->id,
- );
- $values['event'] = array();
+ ];
+ $values['event'] = [];
CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
// add custom fields for event
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', NULL, $this->_relatedObjects['event']->id);
- $eventCustomGroup = array();
+ $eventCustomGroup = [];
foreach ($eventGroupTree as $key => $group) {
if ($key === 'info') {
continue;
$values['event']['customGroup'] = $eventCustomGroup;
//get participant details
- $participantParams = array(
+ $participantParams = [
'id' => $this->_relatedObjects['participant']->id,
- );
+ ];
- $values['participant'] = array();
+ $values['participant'] = [];
CRM_Event_BAO_Participant::getValues($participantParams, $values['participant'], $participantIds);
// add custom fields for event
$participantGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', NULL, $this->_relatedObjects['participant']->id);
- $participantCustomGroup = array();
+ $participantCustomGroup = [];
foreach ($participantGroupTree as $key => $group) {
if ($key === 'info') {
continue;
$values['participant']['customGroup'] = $participantCustomGroup;
//get location details
- $locationParams = array(
+ $locationParams = [
'entity_id' => $this->_relatedObjects['event']->id,
'entity_table' => 'civicrm_event',
- );
+ ];
$values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
- $ufJoinParams = array(
+ $ufJoinParams = [
'entity_table' => 'civicrm_event',
'entity_id' => $ids['event'],
'module' => 'CiviEvent',
- );
+ ];
list($custom_pre_id,
$custom_post_ids
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', NULL, $this->id);
- $customGroup = array();
+ $customGroup = [];
foreach ($groupTree as $key => $group) {
if ($key === 'info') {
continue;
//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
- $honorParams = ['soft_credit_type' => NULL, 'honor_block_is_active' => NULL];
+ $honorParams = [
+ 'soft_credit_type' => NULL,
+ 'honor_block_is_active' => NULL,
+ ];
if (isset($softRecord['soft_credit'])) {
//if id of contribution page is present
if (!empty($values['id'])) {
- $values['honor'] = array(
- 'honor_profile_values' => array(),
+ $values['honor'] = [
+ 'honor_profile_values' => [],
'honor_profile_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'uf_group_id', 'entity_id'),
'honor_id' => $softRecord['soft_credit'][1]['contact_id'],
- );
+ ];
$honorParams['soft_credit_type'] = $softRecord['soft_credit'][1]['soft_credit_type_label'];
$honorParams['honor_block_is_active'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'is_active', 'entity_id');
}
else {
//offline contribution
- $softCreditTypes = $softCredits = array();
+ $softCreditTypes = $softCredits = [];
foreach ($softRecord['soft_credit'] as $key => $softCredit) {
$softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
- $softCredits[$key] = array(
+ $softCredits[$key] = [
'Name' => $softCredit['contact_name'],
'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']),
- );
+ ];
}
$template->assign('softCreditTypes', $softCreditTypes);
$template->assign('softCredits', $softCredits);
$values['amount'] = $this->total_amount;
}
- $pcpParams = ['pcpBlock' => NULL, 'pcp_display_in_roll' => NULL, 'pcp_roll_nickname' => NULL, 'pcp_personal_note' => NULL, 'title' => NULL];
+ $pcpParams = [
+ 'pcpBlock' => NULL,
+ 'pcp_display_in_roll' => NULL,
+ 'pcp_roll_nickname' => NULL,
+ 'pcp_personal_note' => NULL,
+ 'title' => NULL,
+ ];
if (strtolower($this->_component) == 'contribute') {
//PCP Info
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
- $viewRoles = array();
+ $viewRoles = [];
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$isTest = TRUE;
}
- $values['params'] = array();
+ $values['params'] = [];
//to get email of primary participant.
$primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $this->_relatedObjects['participant']->contact_id, 'email', 'contact_id');
- $primaryAmount[] = array(
+ $primaryAmount[] = [
'label' => $this->_relatedObjects['participant']->fee_level . ' - ' . $primaryEmail,
'amount' => $this->_relatedObjects['participant']->fee_amount,
- );
+ ];
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, NULL, $this->_relatedObjects['contact']->id, $isTest, TRUE);
unset($additionalIDs[$this->_relatedObjects['participant']->id]);
//set additionalParticipant true
$values['params']['additionalParticipant'] = TRUE;
foreach ($additionalIDs as $pId => $cId) {
- $amount = array();
+ $amount = [];
//to change the status pending to completed
$additional = new CRM_Event_DAO_Participant();
$additional->id = $pId;
if (!$additionalParticipantInfo) {
$additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id);
}
- $amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
- $primaryAmount[] = array(
+ $amount[0] = [
+ 'label' => $additional->fee_level,
+ 'amount' => $additional->fee_amount,
+ ];
+ $primaryAmount[] = [
'label' => $additional->fee_level . ' - ' . $additionalParticipantInfo,
'amount' => $additional->fee_amount,
- );
+ ];
$additional->save();
$template->assign('amount', $amount);
CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText);
$cacheKeyString = "$contributionId";
$cacheKeyString .= $isNotCancelled ? '_1' : '_0';
- static $supportsCancel = array();
+ static $supportsCancel = [];
if (!array_key_exists($cacheKeyString, $supportsCancel)) {
$supportsCancel[$cacheKeyString] = FALSE;
FROM civicrm_contribution_recur cr
LEFT JOIN civicrm_contribution con ON ( cr.id = con.contribution_recur_id )
WHERE con.id = %1 LIMIT 1";
- $params = array(1 => array($contributionId, 'Integer'));
+ $params = [1 => [$contributionId, 'Integer']];
$statusId = CRM_Core_DAO::singleValueQuery($sql, $params);
$status = CRM_Contribute_PseudoConstant::contributionStatus($statusId);
if ($status == 'Cancelled') {
public static function recordFinancialAccounts(&$params, $financialTrxnValues = NULL) {
$skipRecords = $update = $return = $isRelatedId = FALSE;
- $additionalParticipantId = array();
+ $additionalParticipantId = [];
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$contributionStatus = empty($params['contribution_status_id']) ? NULL : $contributionStatuses[$params['contribution_status_id']];
!($contributionStatus == 'Pending' && !$params['contribution']->is_pay_later)
) {
$skipRecords = TRUE;
- $pendingStatus = array(
+ $pendingStatus = [
'Pending',
'In Progress',
- );
+ ];
if (in_array($contributionStatus, $pendingStatus)) {
$params['to_financial_account_id'] = CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship(
$params['financial_type_id'],
}
elseif (!empty($params['payment_processor'])) {
$params['to_financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($params['payment_processor'], NULL, 'civicrm_payment_processor');
- $params['payment_instrument_id'] = civicrm_api3('PaymentProcessor', 'getvalue', array(
+ $params['payment_instrument_id'] = civicrm_api3('PaymentProcessor', 'getvalue', [
'id' => $params['payment_processor'],
'return' => 'payment_instrument_id',
- ));
+ ]);
}
elseif (!empty($params['payment_instrument_id'])) {
$params['to_financial_account_id'] = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($params['payment_instrument_id']);
}
else {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
- $queryParams = array(1 => array($relationTypeId, 'Integer'));
+ $queryParams = [1 => [$relationTypeId, 'Integer']];
$params['to_financial_account_id'] = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams);
}
$totalAmount = $params['total_amount'] = $params['prevContribution']->total_amount;
}
//build financial transaction params
- $trxnParams = array(
+ $trxnParams = [
'contribution_id' => $params['contribution']->id,
'to_financial_account_id' => $params['to_financial_account_id'],
'trxn_date' => !empty($params['contribution']->receive_date) ? $params['contribution']->receive_date : date('YmdHis'),
'check_number' => CRM_Utils_Array::value('check_number', $params),
'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $params),
'card_type_id' => CRM_Utils_Array::value('card_type_id', $params),
- );
+ ];
if ($contributionStatus == 'Refunded' || $contributionStatus == 'Chargeback' || $contributionStatus == 'Cancelled') {
$trxnParams['trxn_date'] = !empty($params['contribution']->cancel_date) ? $params['contribution']->cancel_date : date('YmdHis');
if (isset($params['refund_trxn_id'])) {
if (isset($params['refund_trxn_id'])) {
$refundIDs = CRM_Core_BAO_FinancialTrxn::getRefundTransactionIDs($params['id']);
if (!empty($refundIDs['financialTrxnId']) && $refundIDs['trxn_id'] != $params['refund_trxn_id']) {
- civicrm_api3('FinancialTrxn', 'create', array('id' => $refundIDs['financialTrxnId'], 'trxn_id' => $params['refund_trxn_id']));
+ civicrm_api3('FinancialTrxn', 'create', [
+ 'id' => $refundIDs['financialTrxnId'],
+ 'trxn_id' => $params['refund_trxn_id'],
+ ]);
}
}
$cardType = CRM_Utils_Array::value('card_type_id', $params);
// create batch entry if batch_id is passed and
// ensure no batch entry is been made on 'Pending' or 'Failed' contribution, CRM-16611
if (!empty($params['batch_id']) && !empty($financialTxn)) {
- $entityParams = array(
+ $entityParams = [
'batch_id' => $params['batch_id'],
'entity_table' => 'civicrm_financial_trxn',
'entity_id' => $financialTxn->id,
- );
+ ];
CRM_Batch_BAO_EntityBatch::create($entityParams);
}
* @param array $params
* Contribution object, line item array and params for trxn.
*
- * @todo stop passing $params by reference. It is unclear the purpose of doing this &
- * adds unpredictability.
- *
* @param string $context
* Update scenarios.
*
+ * @todo stop passing $params by reference. It is unclear the purpose of doing this &
+ * adds unpredictability.
+ *
*/
public static function updateFinancialAccounts(&$params, $context = NULL) {
$trxnID = NULL;
// The 'right' way to add payments or refunds is through the Payment.create api. That api
// then updates the contribution but this process shoud not also record another financial trxn.
if ((($previousContributionStatus == 'Partially paid' && $currentContributionStatus == 'Completed')
- || ($previousContributionStatus == 'Pending refund' && $currentContributionStatus == 'Completed')
- // This concept of pay_later as different to any other sort of pending is deprecated & it's unclear
- // why it is here or where it is handled instead.
- || ($previousContributionStatus == 'Pending' && $params['prevContribution']->is_pay_later == TRUE
- && $currentContributionStatus == 'Partially paid'))
+ || ($previousContributionStatus == 'Pending refund' && $currentContributionStatus == 'Completed')
+ // This concept of pay_later as different to any other sort of pending is deprecated & it's unclear
+ // why it is here or where it is handled instead.
+ || ($previousContributionStatus == 'Pending' && $params['prevContribution']->is_pay_later == TRUE
+ && $currentContributionStatus == 'Partially paid'))
&& $context == 'changedStatus'
) {
return;
$query = "UPDATE civicrm_financial_item SET status_id = %1 WHERE entity_id = %2 and entity_table = 'civicrm_line_item'";
$sql = "SELECT id, amount FROM civicrm_financial_item WHERE entity_id = %1 and entity_table = 'civicrm_line_item'";
- $entityParams = array(
+ $entityParams = [
'entity_table' => 'civicrm_financial_item',
- );
+ ];
foreach ($params['line_item'] as $fieldId => $fields) {
foreach ($fields as $fieldValueId => $lineItemDetails) {
- $fparams = array(
- 1 => array(CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'), 'Integer'),
- 2 => array($lineItemDetails['id'], 'Integer'),
- );
+ $fparams = [
+ 1 => [
+ CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'),
+ 'Integer',
+ ],
+ 2 => [$lineItemDetails['id'], 'Integer'],
+ ];
CRM_Core_DAO::executeQuery($query, $fparams);
- $fparams = array(
- 1 => array($lineItemDetails['id'], 'Integer'),
- );
+ $fparams = [
+ 1 => [$lineItemDetails['id'], 'Integer'],
+ ];
$financialItem = CRM_Core_DAO::executeQuery($sql, $fparams);
while ($financialItem->fetch()) {
$entityParams['entity_id'] = $financialItem->id;
$currency = $params['contribution']->currency;
}
$previousLineItemTotal = CRM_Utils_Array::value('line_total', CRM_Utils_Array::value($fieldValueId, $previousLineItems), 0);
- $itemParams = array(
+ $itemParams = [
'transaction_date' => $receiveDate,
'contact_id' => $params['prevContribution']->contact_id,
'currency' => $currency,
'financial_account_id' => $financialAccount,
'entity_table' => 'civicrm_line_item',
'entity_id' => $lineItemDetails['id'],
- );
+ ];
$financialItem = CRM_Financial_BAO_FinancialItem::create($itemParams, NULL, $trxnIds);
// @todo we should stop passing $params by reference - splitting this out would be a step towards that.
$params['line_item'][$fieldId][$fieldValueId]['deferred_line_total'] = $itemParams['amount'];
* @return bool
*/
public static function isContributionStatusNegative($status_id) {
- $reversalStatuses = array('Cancelled', 'Chargeback', 'Refunded');
+ $reversalStatuses = ['Cancelled', 'Chargeback', 'Refunded'];
return in_array(CRM_Contribute_PseudoConstant::contributionStatus($status_id, 'name'), $reversalStatuses);
}
}
}
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
- $checkStatus = array(
- 'Cancelled' => array('Completed', 'Refunded'),
- 'Completed' => array('Cancelled', 'Refunded', 'Chargeback'),
- 'Pending' => array('Cancelled', 'Completed', 'Failed', 'Partially paid'),
- 'In Progress' => array('Cancelled', 'Completed', 'Failed'),
- 'Refunded' => array('Cancelled', 'Completed'),
- 'Partially paid' => array('Completed'),
- );
+ $checkStatus = [
+ 'Cancelled' => ['Completed', 'Refunded'],
+ 'Completed' => ['Cancelled', 'Refunded', 'Chargeback'],
+ 'Pending' => ['Cancelled', 'Completed', 'Failed', 'Partially paid'],
+ 'In Progress' => ['Cancelled', 'Completed', 'Failed'],
+ 'Refunded' => ['Cancelled', 'Completed'],
+ 'Partially paid' => ['Completed'],
+ ];
if (!in_array($contributionStatuses[$fields['contribution_status_id']],
- CRM_Utils_Array::value($contributionStatuses[$values['contribution_status_id']], $checkStatus, array()))
+ CRM_Utils_Array::value($contributionStatuses[$values['contribution_status_id']], $checkStatus, []))
) {
- $errors['contribution_status_id'] = ts("Cannot change contribution status from %1 to %2.", array(
+ $errors['contribution_status_id'] = ts("Cannot change contribution status from %1 to %2.", [
1 => $contributionStatuses[$values['contribution_status_id']],
2 => $contributionStatuses[$fields['contribution_status_id']],
- ));
+ ]);
}
}
/**
* Get options for a given contribution field.
- * @see CRM_Core_DAO::buildOptions
*
* @param string $fieldName
* @param string $context see CRM_Core_DAO::buildOptionsContext.
- * @param array $props whatever is known about this dao object.
+ * @param array $props whatever is known about this dao object.
*
* @return array|bool
+ * @see CRM_Core_DAO::buildOptions
+ *
*/
- public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+ public static function buildOptions($fieldName, $context = NULL, $props = []) {
$className = __CLASS__;
- $params = array();
+ $params = [];
if (isset($props['orderColumn'])) {
$params['orderColumn'] = $props['orderColumn'];
}
$className = 'CRM_Contribute_BAO_ContributionPage';
// Filter results by contribution page
if (!empty($props['contribution_page_id'])) {
- $page = civicrm_api('contribution_page', 'getsingle', array(
+ $page = civicrm_api('contribution_page', 'getsingle', [
'version' => 3,
'id' => ($props['contribution_page_id']),
- ));
+ ]);
$types = (array) CRM_Utils_Array::value('payment_processor', $page, 0);
$params['condition'] = 'id IN (' . implode(',', $types) . ')';
}
$srcRecId = $contributionId;
// activity params
- $activityParams = array(
+ $activityParams = [
'source_contact_id' => $targetCid,
'source_record_id' => $srcRecId,
'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', $activityType),
'activity_date_time' => $date,
'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'),
'skipRecentView' => TRUE,
- );
+ ];
// create activity with target contacts
$session = CRM_Core_Session::singleton();
$paymentBalance = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $total);
- $contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $contributionId, 'return' => array('currency', 'is_pay_later', 'contribution_status_id', 'financial_type_id')));
+ $contribution = civicrm_api3('Contribution', 'getsingle', [
+ 'id' => $contributionId,
+ 'return' => [
+ 'currency',
+ 'is_pay_later',
+ 'contribution_status_id',
+ 'financial_type_id',
+ ],
+ ]);
$info['payLater'] = $contribution['is_pay_later'];
$info['contribution_status'] = $contribution['contribution_status'];
$info['balance'] = $paymentBalance;
$info['id'] = $id;
$info['component'] = $component;
- $rows = array();
+ $rows = [];
if ($getTrxnInfo && $baseTrxnId) {
// Need to exclude fee trxn rows so filter out rows where TO FINANCIAL ACCOUNT is expense account
$sql = "
WHERE con.id = %1 AND ft.is_payment = 1
GROUP BY ft.id";
- $queryParams = array(
- 1 => array($contributionId, 'Integer'),
- 2 => array($feeFinancialAccount, 'Integer'),
- );
+ $queryParams = [
+ 1 => [$contributionId, 'Integer'],
+ 2 => [$feeFinancialAccount, 'Integer'],
+ ];
$resultDAO = CRM_Core_DAO::executeQuery($sql, $queryParams);
$statuses = CRM_Contribute_PseudoConstant::contributionStatus();
// show payment edit link only for payments done via backoffice form
$paymentEditLink = '';
if (empty($resultDAO->payment_processor_id) && CRM_Core_Permission::check('edit contributions')) {
- $links = array(
- CRM_Core_Action::UPDATE => array(
+ $links = [
+ CRM_Core_Action::UPDATE => [
'name' => "<i class='crm-i fa-pencil'></i>",
'url' => 'civicrm/payment/edit',
'class' => 'medium-popup',
'qs' => "reset=1&id=%%id%%&contribution_id=%%contribution_id%%",
'title' => ts('Edit Payment'),
- ),
- );
+ ],
+ ];
$paymentEditLink = CRM_Core_Action::formLink(
$links,
- CRM_Core_Action::mask(array(CRM_Core_Permission::EDIT)),
- array(
+ CRM_Core_Action::mask([CRM_Core_Permission::EDIT]),
+ [
'id' => $resultDAO->id,
'contribution_id' => $contributionId,
- )
+ ]
);
}
- $val = array(
+ $val = [
'id' => $resultDAO->id,
'total_amount' => $resultDAO->total_amount,
'financial_type' => $resultDAO->financial_account,
'status' => $statuses[$resultDAO->status_id],
'currency' => $resultDAO->currency,
'action' => $paymentEditLink,
- );
+ ];
if ($paidByName == 'Check') {
$val['check_number'] = $resultDAO->check_number;
}
$params['prevContribution'] = self::getOriginalContribution($params['id']);
}
- foreach (array('total_amount', 'financial_type_id', 'fee_amount') as $field) {
+ foreach (['total_amount', 'financial_type_id', 'fee_amount'] as $field) {
if (!isset($params[$field])) {
if ($field == 'total_amount' && $params['prevContribution']->tax_amount) {
// Tax amount gets added back on later....
// Assign tax Amount on update of contribution
if (!empty($params['prevContribution']->tax_amount)) {
$params['tax_amount'] = 'null';
- CRM_Price_BAO_LineItem::getLineItemArray($params, array($params['id']));
+ CRM_Price_BAO_LineItem::getLineItemArray($params, [$params['id']]);
foreach ($params['line_item'] as $setID => $priceField) {
foreach ($priceField as $priceFieldID => $priceFieldValue) {
$params['line_item'][$setID][$priceFieldID]['tax_amount'] = $params['tax_amount'];
// Get Line Item on update of contribution
if (isset($params['id'])) {
- CRM_Price_BAO_LineItem::getLineItemArray($params, array($params['id']));
+ CRM_Price_BAO_LineItem::getLineItemArray($params, [$params['id']]);
}
else {
CRM_Price_BAO_LineItem::getLineItemArray($params);
}
elseif (isset($params['api.line_item.create'])) {
// Update total amount of contribution using lineItem
- $taxAmountArray = array();
+ $taxAmountArray = [];
foreach ($params['api.line_item.create'] as $key => $value) {
if (isset($value['financial_type_id']) && array_key_exists($value['financial_type_id'], $taxRates)) {
$taxRate = $taxRates[$value['financial_type_id']];
}
else {
// update line item of contrbution
- if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) {
+ if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) {
$taxRate = $taxRates[$params['financial_type_id']];
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate, $unknownIfMoneyIsClean);
$params['tax_amount'] = round($taxAmount['tax_amount'], 2);
}
}
$sql = 'SELECT financial_type_id FROM civicrm_line_item WHERE contribution_id = %1 GROUP BY financial_type_id;';
- $params = array(
- '1' => array($contributionId, 'Integer'),
- );
+ $params = [
+ '1' => [$contributionId, 'Integer'],
+ ];
$result = CRM_Core_DAO::executeQuery($sql, $params);
if ($result->N > 1) {
$errors['financial_type_id'] = ts('One or more line items have a different financial type than the contribution. Editing the financial type is not yet supported in this situation.');
if ($updatePledgePaymentStatus) {
CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeID,
- array($pledgePaymentID),
+ [$pledgePaymentID],
$contribution_status_id,
NULL,
$total_amount,
/**
* Compute the stats values
*
- * @deprecated
- *
* @param string $stat either 'mode' or 'median'
* @param string $sql
* @param string $alias of civicrm_contribution
*
* @return array|null
+ * @deprecated
+ *
*/
public static function computeStats($stat, $sql, $alias = NULL) {
CRM_Core_Error::deprecatedFunctionWarning('computeStats is now deprecated');
* @throws \CiviCRM_API3_Exception
*/
public static function isSingleLineItem($id) {
- $lineItemCount = civicrm_api3('LineItem', 'getcount', array('contribution_id' => $id));
+ $lineItemCount = civicrm_api3('LineItem', 'getcount', ['contribution_id' => $id]);
return ($lineItemCount == 1);
}
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
// The previous details are used when calculating line items so keep it before any code that 'does something'
if (!empty($contribution->id)) {
- $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id),
+ $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(['id' => $contribution->id],
CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
}
- $inputContributionWhiteList = array(
+ $inputContributionWhiteList = [
'fee_amount',
'net_amount',
'trxn_id',
'contribution_status_id',
'card_type_id',
'pan_truncation',
- );
+ ];
if (self::isSingleLineItem($primaryContributionID)) {
$inputContributionWhiteList[] = 'financial_type_id';
}
$completedContributionStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
- $contributionParams = array_merge(array(
+ $contributionParams = array_merge([
'contribution_status_id' => $completedContributionStatusID,
'source' => self::getRecurringContributionDescription($contribution, $event),
- ), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)
+ ], array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)
));
// CRM-20678 Ensure that the currency is correct in subseqent transcations.
self::repeatTransaction($contribution, $input, $contributionParams, $paymentProcessorId);
$contributionParams['financial_type_id'] = $contribution->financial_type_id;
- $values = array();
+ $values = [];
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
CRM_Contribute_BAO_ContributionRecur::addrecurSoftCredit($objects['contributionRecur']->id, $contribution->id);
}
- $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array(
+ $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [
'labelColumn' => 'name',
'flip' => 1,
- ));
+ ]);
if (isset($input['prevContribution']) && (!$input['prevContribution']->is_pay_later && $input['prevContribution']->contribution_status_id == $contributionStatuses['Pending'])) {
$input['payment_processor'] = $paymentProcessorId;
}
if (!array_key_exists('is_email_receipt', $values) ||
$values['is_email_receipt'] == 1
) {
- civicrm_api3('Contribution', 'sendconfirmation', array(
+ civicrm_api3('Contribution', 'sendconfirmation', [
'id' => $contribution->id,
'payment_processor_id' => $paymentProcessorId,
- ));
+ ]);
CRM_Core_Error::debug_log_message("Receipt sent");
}
$values['contribution_status'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution->contribution_status_id);
$return = $contribution->composeMessageArray($input, $ids, $values, $returnMessageText);
if ((!isset($input['receipt_update']) || $input['receipt_update']) && empty($contribution->receipt_date)) {
- civicrm_api3('Contribution', 'create', array('receipt_date' => 'now', 'id' => $contribution->id));
+ civicrm_api3('Contribution', 'create', [
+ 'receipt_date' => 'now',
+ 'id' => $contribution->id,
+ ]);
}
return $return;
}
/**
* Generate From email and from name in an array values
+ *
* @param array $input
* @param \CRM_Contribute_BAO_Contribution $contribution
+ *
* @return array
*/
public static function generateFromEmailAndName($input, $contribution) {
// Use input value if supplied.
if (!empty($input['receipt_from_email'])) {
- return array(CRM_Utils_array::value('receipt_from_name', $input, ''), $input['receipt_from_email']);
+ return [
+ CRM_Utils_array::value('receipt_from_name', $input, ''),
+ $input['receipt_from_email'],
+ ];
}
// if we are still empty see if we can use anything from a contribution page.
- $pageValues = array();
+ $pageValues = [];
if (!empty($contribution->contribution_page_id)) {
- $pageValues = civicrm_api3('ContributionPage', 'getsingle', array('id' => $contribution->contribution_page_id));
+ $pageValues = civicrm_api3('ContributionPage', 'getsingle', ['id' => $contribution->contribution_page_id]);
}
// if we are still empty see if we can use anything from a contribution page.
if (!empty($pageValues['receipt_from_email'])) {
- return array($pageValues['receipt_from_name'], $pageValues['receipt_from_email']);
+ return [
+ $pageValues['receipt_from_name'],
+ $pageValues['receipt_from_email'],
+ ];
}
// If we are still empty fall back to the domain or logged in user information.
return CRM_Core_BAO_Domain::getDefaultReceiptFrom();
do {
$creditNoteNum++;
$creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $creditNoteNum;
- $result = civicrm_api3('Contribution', 'getcount', array(
+ $result = civicrm_api3('Contribution', 'getcount', [
'sequential' => 1,
'creditnote_id' => $creditNoteId,
- ));
+ ]);
} while ($result > 0);
return $creditNoteId;
/**
* Load related memberships.
*
+ * @param array $ids
+ *
+ * @return array $ids
+ *
+ * @throws Exception
* @deprecated
*
* Note that in theory it should be possible to retrieve these from the line_item table
*
* I don't know if it never worked or broke as a result of https://issues.civicrm.org/jira/browse/CRM-14918.
*
- * @param array $ids
- *
- * @return array $ids
- *
- * @throws Exception
*/
public function loadRelatedMembershipObjects($ids = []) {
$query = "
SELECT membership_id
FROM civicrm_membership_payment
WHERE contribution_id = %1 ";
- $params = array(1 => array($this->id, 'Integer'));
- $ids['membership'] = (array) CRM_Utils_Array::value('membership', $ids, array());
+ $params = [1 => [$this->id, 'Integer']];
+ $ids['membership'] = (array) CRM_Utils_Array::value('membership', $ids, []);
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
return $contribution->source;
}
elseif (!empty($contribution->contribution_page_id) && is_numeric($contribution->contribution_page_id)) {
- $contributionPageTitle = civicrm_api3('ContributionPage', 'getvalue', array(
+ $contributionPageTitle = civicrm_api3('ContributionPage', 'getvalue', [
'id' => $contribution->contribution_page_id,
'return' => 'title',
- ));
+ ]);
return ts('Online Contribution') . ': ' . $contributionPageTitle;
}
elseif ($event) {
FROM civicrm_financial_trxn ft
INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution'
WHERE eft.entity_id = %1 AND ft.is_payment = 1 ORDER BY ft.id DESC LIMIT 1";
- $contributionStatus = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array(
+ $contributionStatus = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [
'labelColumn' => 'name',
- ));
+ ]);
foreach ($contributions as $contribution) {
if (!($contributionStatus[$contribution->contribution_status_id] == 'Partially paid'
|| CRM_Utils_Array::value($contributionStatusId, $contributionStatus) == 'Partially paid')
) {
continue;
}
- $ftDao = CRM_Core_DAO::executeQuery($ftSql, array(1 => array($contribution->id, 'Integer')));
+ $ftDao = CRM_Core_DAO::executeQuery($ftSql, [
+ 1 => [
+ $contribution->id,
+ 'Integer',
+ ],
+ ]);
$ftDao->fetch();
// store financial item Proportionaly.
- $trxnParams = array(
+ $trxnParams = [
'total_amount' => $ftDao->total_amount,
'contribution_id' => $contribution->id,
- );
+ ];
self::assignProportionalLineItems($trxnParams, $ftDao->id, $contribution->total_amount);
}
}
if (!empty($lineItems)) {
// get financial item
list($ftIds, $taxItems) = self::getLastFinancialItemIds($trxnParams['contribution_id']);
- $entityParams = array(
+ $entityParams = [
'contribution_total_amount' => $contributionTotalAmount,
'trxn_total_amount' => $trxnParams['total_amount'],
'trxn_id' => $trxnId,
- );
+ ];
self::createProportionalFinancialEntries($entityParams, $lineItems, $ftIds, $taxItems);
}
}
}
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus($params['contribution_status_id'], 'name');
- $preferredAccountsRelationships = array(
+ $preferredAccountsRelationships = [
'Refunded' => 'Credit/Contra Revenue Account is',
'Chargeback' => 'Chargeback Account is',
- );
+ ];
if (in_array($contributionStatus, array_keys($preferredAccountsRelationships))) {
$financialTypeID = !empty($params['financial_type_id']) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
* @return array
*/
protected function addContributionPageValuesToValuesHeavyHandedly(&$values) {
- $contributionPageValues = array();
+ $contributionPageValues = [];
CRM_Contribute_BAO_ContributionPage::setValues(
$this->contribution_page_id,
$contributionPageValues
);
- $valuesToCopy = array(
+ $valuesToCopy = [
// These are the values that I believe to be useful.
'id',
'title',
'thankyou_text',
'thankyou_title',
- );
+ ];
foreach ($valuesToCopy as $valueToCopy) {
if (isset($contributionPageValues[$valueToCopy])) {
$values[$valueToCopy] = $contributionPageValues[$valueToCopy];
return $statusMsg;
}
- $params = array(
+ $params = [
'contribution_id' => $contributionId,
'contribution_status_id' => $statusId,
'previous_contribution_status_id' => $previousStatusId,
'receive_date' => $receiveDate,
- );
+ ];
$updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
break;
}
- $statusMsg .= "<br />" . ts("Membership for %1 has been %2.", array(1 => $userDisplayName, 2 => $statusNameMsgPart));
+ $statusMsg .= "<br />" . ts("Membership for %1 has been %2.", [
+ 1 => $userDisplayName,
+ 2 => $statusNameMsgPart,
+ ]);
}
if ($componentName == 'CiviEvent') {
CRM_Event_PseudoConstant::participantStatus()
);
if ($updatedStatusName == 'Cancelled') {
- $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName));
+ $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", [1 => $userDisplayName]);
}
elseif ($updatedStatusName == 'Registered') {
- $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName));
+ $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", [1 => $userDisplayName]);
}
}
CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')
);
if ($updatedStatusName == 'Cancelled') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName));
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", [1 => $userDisplayName]);
}
elseif ($updatedStatusName == 'Failed') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName));
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", [1 => $userDisplayName]);
}
elseif ($updatedStatusName == 'Completed') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName));
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", [1 => $userDisplayName]);
}
}
}
* @return \CRM_Contribute_BAO_Contribution|null
*/
private static function getOriginalContribution($contributionID) {
- return self::getValues(array('id' => $contributionID), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
+ return self::getValues(['id' => $contributionID], CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
}
/**
* for historical reasons. Going forwards we can hope to add tests & improve readibility
* of that function
*
- * @todo move recordFinancialAccounts & helper functions to their own class?
- *
* @param array $params
* Params as passed to contribution.create
*
* @param int $previousLineItemTotal
*
* @return float
+ * @todo move recordFinancialAccounts & helper functions to their own class?
+ *
*/
protected static function getFinancialItemAmountFromParams($params, $context, $lineItemDetails, $isARefund, $previousLineItemTotal) {
if ($context == 'changedAmount') {
elseif (empty($lineItemDetails['line_total'])) {
// follow legacy code path
Civi::log()
- ->warning('Deprecated bit of code, please log a ticket explaining how you got here!', array('civi.tag' => 'deprecated'));
+ ->warning('Deprecated bit of code, please log a ticket explaining how you got here!', ['civi.tag' => 'deprecated']);
return $params['total_amount'];
}
else {
public static function updateMembershipBasedOnCompletionOfContribution($contribution, $primaryContributionID, $changeDate) {
$memberships = self::getRelatedMemberships($contribution->id);
foreach ($memberships as $membership) {
- $membershipParams = array(
+ $membershipParams = [
'id' => $membership['id'],
'contact_id' => $membership['contact_id'],
'is_test' => $membership['is_test'],
'membership_type_id' => $membership['membership_type_id'],
'membership_activity_status' => 'Completed',
- );
+ ];
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'],
$membershipParams['membership_type_id'],
);
// @todo remove all this stuff in favour of letting the api call further down handle in
// (it is a duplication of what the api does).
- $dates = array_fill_keys(array(
+ $dates = array_fill_keys([
'join_date',
'start_date',
'end_date',
- ), NULL);
+ ], NULL);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
// but not for Failed contributions, where we don't accept additional payments at the moment.
// (in some cases the contribution is 'Pending' and only the payment is failed. In those we
// do accept more payments agains them.
- return array();
+ return [];
}
- $actionLinks = array();
+ $actionLinks = [];
if ((int) $balance > 0) {
if (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) {
- $actionLinks[] = array(
- 'url' => CRM_Utils_System::url('civicrm/payment', array(
+ $actionLinks[] = [
+ 'url' => CRM_Utils_System::url('civicrm/payment', [
'action' => 'add',
'reset' => 1,
'id' => $id,
'mode' => 'live',
- )),
+ ]),
'title' => ts('Submit Credit Card payment'),
- );
+ ];
}
- $actionLinks[] = array(
- 'url' => CRM_Utils_System::url('civicrm/payment', array(
+ $actionLinks[] = [
+ 'url' => CRM_Utils_System::url('civicrm/payment', [
'action' => 'add',
'reset' => 1,
'id' => $id,
- )),
+ ]),
'title' => ts('Record Payment'),
- );
+ ];
}
elseif ((int) $balance < 0) {
- $actionLinks[] = array(
- 'url' => CRM_Utils_System::url('civicrm/payment', array(
+ $actionLinks[] = [
+ 'url' => CRM_Utils_System::url('civicrm/payment', [
'action' => 'add',
'reset' => 1,
'id' => $id,
- )),
+ ]),
'title' => ts('Record Refund'),
- );
+ ];
}
return $actionLinks;
}
$previousContributionStatus = empty($contributionParams['prevContribution']) ? NULL : $contributionStatuses[$contributionParams['prevContribution']->contribution_status_id];
// Return if contribution status is not completed.
if (!($contributionStatus == 'Completed' && (empty($previousContributionStatus)
- || (!empty($previousContributionStatus) && $previousContributionStatus == 'Pending'
- && $contributionParams['prevContribution']->is_pay_later == 0
- )))
+ || (!empty($previousContributionStatus) && $previousContributionStatus == 'Pending'
+ && $contributionParams['prevContribution']->is_pay_later == 0
+ )))
) {
return NULL;
}
INNER JOIN civicrm_financial_account cfa ON ce.financial_account_id = cfa.id
WHERE `entity_table` = 'civicrm_financial_type' AND cfa.is_tax = 1 AND ce.account_relationship = %1 GROUP BY cfa.id";
$accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
- $queryParams = array(1 => array($accountRel, 'Integer'));
+ $queryParams = [1 => [$accountRel, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
- $financialAccount = array();
+ $financialAccount = [];
while ($dao->fetch()) {
$financialAccount[$dao->id] = $dao->id;
}
*
* @param array $eftParams
*
+ * @throws \CiviCRM_API3_Exception
*/
public static function createProportionalEntry($entityParams, $eftParams) {
$paid = 0;
FROM civicrm_financial_item fi
INNER JOIN civicrm_line_item li ON li.id = fi.entity_id and fi.entity_table = 'civicrm_line_item'
WHERE li.contribution_id = %1";
- $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($contributionId, 'Integer')));
- $ftIds = $taxItems = array();
+ $dao = CRM_Core_DAO::executeQuery($sql, [
+ 1 => [
+ $contributionId,
+ 'Integer',
+ ],
+ ]);
+ $ftIds = $taxItems = [];
$salesTaxFinancialAccount = self::getSalesTaxFinancialAccounts();
while ($dao->fetch()) {
/* if sales tax item*/
if (in_array($dao->financial_account_id, $salesTaxFinancialAccount)) {
- $taxItems[$dao->price_field_value_id] = array(
+ $taxItems[$dao->price_field_value_id] = [
'financial_item_id' => $dao->id,
'amount' => $dao->tax_amount,
- );
+ ];
}
else {
$ftIds[$dao->price_field_value_id] = $dao->id;
}
}
- return array($ftIds, $taxItems);
+ return [$ftIds, $taxItems];
}
/**
*
* @param array $taxItems
*
+ * @throws \CiviCRM_API3_Exception
*/
public static function createProportionalFinancialEntries($entityParams, $lineItems, $ftIds, $taxItems) {
- $eftParams = array(
+ $eftParams = [
'entity_table' => 'civicrm_financial_item',
'financial_trxn_id' => $entityParams['trxn_id'],
- );
+ ];
foreach ($lineItems as $key => $value) {
if ($value['qty'] == 0) {
continue;
* @throws \CRM_Core_Exception
*/
protected function loadRelatedEntitiesByID($ids) {
- $entities = array(
+ $entities = [
'contact' => 'CRM_Contact_BAO_Contact',
'contributionRecur' => 'CRM_Contribute_BAO_ContributionRecur',
'contributionType' => 'CRM_Financial_BAO_FinancialType',
'financialType' => 'CRM_Financial_BAO_FinancialType',
'contributionPage' => 'CRM_Contribute_BAO_ContributionPage',
- );
+ ];
foreach ($entities as $entity => $bao) {
if (!empty($ids[$entity])) {
$this->_relatedObjects[$entity] = new $bao();
* @param bool $escapeSmarty
*
* @return array
+ * @throws \CiviCRM_API3_Exception
*/
public static function replaceContributionTokens(
$contributionIds,
$escapeSmarty
) {
if (empty($contributionIds)) {
- return array();
+ return [];
}
- $contributionDetails = array();
+ $contributionDetails = [];
foreach ($contributionIds as $id) {
- $result = civicrm_api3('Contribution', 'get', array('id' => $id));
+ $result = civicrm_api3('Contribution', 'get', ['id' => $id]);
$contributionDetails[$result['values'][$result['id']]['contact_id']]['subject'] = CRM_Utils_Token::replaceContributionTokens($subject, $result, FALSE, $subjectToken, FALSE, $escapeSmarty);
$contributionDetails[$result['values'][$result['id']]['contact_id']]['text'] = CRM_Utils_Token::replaceContributionTokens($text, $result, FALSE, $messageToken, FALSE, $escapeSmarty);
$contributionDetails[$result['values'][$result['id']]['contact_id']]['html'] = CRM_Utils_Token::replaceContributionTokens($html, $result, FALSE, $messageToken, FALSE, $escapeSmarty);