*/
public $_options;
- /**
- * stores the honor id
- *
- * @var int
- * @public
- */
- public $_honorID = NULL;
-
/**
* Store the contribution Type ID
*
}
// when custom data is included in this page
- if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
+ if (!empty($_POST['hidden_custom'])) {
$this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id);
}
//set defaults for pledge payment.
if ($this->_ppID) {
$defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
- $defaults['honor_type_id'] = CRM_Utils_Array::value('honor_type_id', $this->_pledgeValues);
- $defaults['honor_contact_id'] = CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues);
$defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues);
$defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
$defaults['option_type'] = 1;
if ($this->_mode) {
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
- if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
+ if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
$defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
- if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
+ if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
$defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
$defaults['financial_type_id'] = $this->_contributionType;
}
- if (CRM_Utils_Array::value('is_test', $defaults)) {
- $this->assign('is_test', TRUE);
+ if (empty($defaults['payment_instrument_id'])) {
+ $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
- if (isset($defaults['honor_contact_id'])) {
- $honorDefault = $ids = array();
- $this->_honorID = $defaults['honor_contact_id'];
- $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
- $idParams = array(
- 'id' => $defaults['honor_contact_id'],
- 'contact_id' => $defaults['honor_contact_id'],
- );
- CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $ids);
-
- $defaults['honor_prefix_id'] = CRM_Utils_Array::value('prefix_id', $honorDefault);
- $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
- $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
- $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
- $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
+ if (!empty($defaults['is_test'])) {
+ $this->assign('is_test', TRUE);
}
$this->assign('showOption', TRUE);
$this->assign('email', $this->userEmail);
}
- if (CRM_Utils_Array::value('is_pay_later', $defaults)) {
+ if (!empty($defaults['is_pay_later'])) {
$this->assign('is_pay_later', TRUE);
}
$this->assign('contribution_status_id', CRM_Utils_Array::value('contribution_status_id', $defaults));
$dates = array('receive_date', 'receipt_date', 'cancel_date', 'thankyou_date');
foreach ($dates as $key) {
- if (CRM_Utils_Array::value($key, $defaults)) {
+ if (!empty($defaults[$key])) {
list($defaults[$key],
$defaults[$key . '_time']
) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults),
}
}
- if (!$this->_id && !CRM_Utils_Array::value('receive_date', $defaults)) {
+ if (!$this->_id && empty($defaults['receive_date'])) {
list($defaults['receive_date'],
$defaults['receive_date_time']
) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
$this->assign('totalAmount', CRM_Utils_Array::value('total_amount', $defaults));
//inherit campaign from pledge.
- if ($this->_ppID && CRM_Utils_Array::value('campaign_id', $this->_pledgeValues)) {
+ if ($this->_ppID && !empty($this->_pledgeValues['campaign_id'])) {
$defaults['campaign_id'] = $this->_pledgeValues['campaign_id'];
}
// build price set form.
$buildPriceSet = FALSE;
if (empty($this->_lineItems) &&
- ($this->_priceSetId || CRM_Utils_Array::value('price_set_id', $_POST))
+ ($this->_priceSetId || !empty($_POST['price_set_id']))
) {
$buildPriceSet = TRUE;
$getOnlyPriceSetElements = TRUE;
}
}
- $honorFields = array(
- 'honor_type_id',
- 'honor_prefix_id',
- 'honor_first_name',
- 'honor_lastname',
- 'honor_email',
- );
- foreach ($honorFields as $key) {
- if (!empty($defaults[$key])) {
- $defaults['hidden_Honoree'] = 1;
- break;
- }
- }
-
- //check for honoree pane.
- if ($this->_ppID && CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues)) {
- $defaults['hidden_Honoree'] = 1;
- }
-
if ($this->_productDAO) {
if ($this->_productDAO->product_id) {
$defaults['hidden_Premium'] = 1;
$paneNames = array(
ts('Additional Details') => 'AdditionalDetail',
- ts('Honoree Information') => 'Honoree'
);
//Add Premium pane only if Premium is exists.
);
// see if we need to include this paneName in the current form
- if ($this->_formType == $type ||
- CRM_Utils_Array::value("hidden_{$type}", $_POST) ||
+ if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) ||
CRM_Utils_Array::value("hidden_{$type}", $defaults)
) {
$showAdditionalInfo = TRUE;
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Paid By'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
- FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+ TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
}
$errors['contact[1]'] = ts('Please select a contact or create new contact');
}
- if (isset($fields['honor_type_id'])) {
- if (!((CRM_Utils_Array::value('honor_first_name', $fields) &&
- CRM_Utils_Array::value('honor_last_name', $fields)
- ) ||
- CRM_Utils_Array::value('honor_email', $fields)
- )
- ) {
- $errors['honor_first_name'] = ts('Honor First Name and Last Name OR an email should be set.');
- }
- }
-
//check for Credit Card Contribution.
if ($self->_mode) {
if (empty($fields['payment_processor_id'])) {
}
// do the amount validations.
- if (!CRM_Utils_Array::value('total_amount', $fields) && empty($self->_lineItems)) {
+ if (empty($fields['total_amount']) && empty($self->_lineItems)) {
if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
}
}
- $softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields);
+ $softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
- if (CRM_Utils_Array::value('total_amount', $fields) && (CRM_Utils_Array::value('net_amount', $fields) || CRM_Utils_Array::value('fee_amount', $fields))) {
+ if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
$sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
//FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
- if (CRM_Utils_Array::value('fee_amount', $fields)) {
- $financialAccount = array();
- CRM_Core_PseudoConstant::populate($financialAccount,
- 'CRM_Financial_DAO_EntityFinancialAccount',
- $all = TRUE,
- $retrieve = 'financial_account_id',
- $filter = NULL,
- " account_relationship = 5 AND entity_id = {$fields['financial_type_id']} ");
- if (!current($financialAccount)) {
- $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for this Financial Type");
+ if (!empty($fields['fee_amount']) && $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id'])) {
+ $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
+ }
+
+ // $trxn_id must be unique CRM-13919
+ if (!empty($fields['trxn_id'])) {
+ $queryParams = array(1 => array($fields['trxn_id'], 'String'));
+ $query = 'select count(*) from civicrm_contribution where trxn_id = %1';
+ if ($self->_id) {
+ $queryParams[2] = array((int)$self->_id, 'Integer');
+ $query .= ' and id !=%2';
+ }
+ $tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
+ if ($tCnt) {
+ $errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
}
}
// get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
- if (CRM_Utils_Array::value('price_set_id', $submittedValues) && $this->_action & CRM_Core_Action::UPDATE) {
+ if (!empty($submittedValues['price_set_id']) && $this->_action & CRM_Core_Action::UPDATE) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $line[$lineID]), 'price_set_id');
//CRM-10964
$pId = ($this->_compId && $this->_context == 'participant') ? $this->_compId : CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'participant_id', 'contribution_id');
}
- if (!$priceSetId && CRM_Utils_Array::value('total_amount', $submittedValues) && $this->_id) {
+ if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
// 10117 update th line items for participants
if ($pId) {
$entityTable = 'participant';
}
$itemId = key($lineItems);
$fieldType = NULL;
- if ($itemId && CRM_Utils_Array::value('price_field_id', $lineItems[$itemId])) {
+ if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
$fieldType = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'html_type');
}
$lineItems[$itemId]['unit_price'] = $lineItems[$itemId]['line_total'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('total_amount', $submittedValues));
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
- if ($isQuickConfig && CRM_Utils_Array::value('financial_type_id', $submittedValues)
- && CRM_Utils_Array::value($this->_priceSetId, $lineItem)
+ if ($isQuickConfig && !empty($submittedValues['financial_type_id']) && CRM_Utils_Array::value($this->_priceSetId, $lineItem)
) {
foreach ($lineItem[$this->_priceSetId] as &$values) {
$values['financial_type_id'] = $submittedValues['financial_type_id'];
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
- if (CRM_Utils_Array::value('pcp_made_through_id', $submittedValues)) {
+ if (!empty($submittedValues['pcp_made_through_id'])) {
$pcp = array();
$fields = array(
'pcp_made_through_id',
if ($val && $submittedValues['soft_credit_amount'][$key]) {
$softParams[$key]['contact_id'] = $val;
$softParams[$key]['amount'] = CRM_Utils_Rule::cleanMoney($submittedValues['soft_credit_amount'][$key]);
+ $softParams[$key]['soft_credit_type_id'] = $submittedValues['soft_credit_type'][$key];
if (!empty($submittedValues['soft_credit_id'][$key])) {
$softIDs[] = $softParams[$key]['id'] = $submittedValues['soft_credit_id'][$key];
}
}
// set the contact, when contact is selected
- if (CRM_Utils_Array::value('contact_select_id', $submittedValues)) {
+ if (!empty($submittedValues['contact_select_id'])) {
$this->_contactID = $submittedValues['contact_select_id'][1];
}
$params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE);
}
- if (CRM_Utils_Array::value('is_email_receipt', $formValues)) {
+ if (!empty($formValues['is_email_receipt'])) {
$params['receipt_date'] = date("Y-m-d");
}
}
//send receipt mail.
- if ($contribution->id && CRM_Utils_Array::value('is_email_receipt', $formValues)) {
+ if ($contribution->id && !empty($formValues['is_email_receipt'])) {
$formValues['contact_id'] = $this->_contactID;
$formValues['contribution_id'] = $contribution->id;
}
$statusMsg = ts('The contribution record has been saved.');
- if (CRM_Utils_Array::value('is_email_receipt', $formValues) && $sendReceipt) {
+ if (!empty($formValues['is_email_receipt']) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
$fields = array();
// we need to retrieve email address
- if ($this->_context == 'standalone' && CRM_Utils_Array::value('is_email_receipt', $submittedValues)) {
+ if ($this->_context == 'standalone' && !empty($submittedValues['is_email_receipt'])) {
list($this->userDisplayName,
$this->userEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
}
}
- if (CRM_Utils_Array::value('source', $params)) {
+ if (!empty($params['source'])) {
unset($params['source']);
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields,
$config->defaultCurrency
);
$this->_params['payment_action'] = 'Sale';
- if (CRM_Utils_Array::value('receive_date', $this->_params)) {
+ if (!empty($this->_params['receive_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date'], $this->_params['receive_date_time']);
}
- if (CRM_Utils_Array::value('soft_credit_to', $params)) {
+ if (!empty($params['soft_credit_to'])) {
$this->_params['soft_credit_to'] = $params['soft_credit_to'];
$this->_params['pcp_made_through_id'] = $params['pcp_made_through_id'];
}
// if folks need to use it
$paymentParams['contributionType_name'] = $this->_params['contributionType_name'] = $contributionType->name;
$paymentParams['contributionPageID'] = NULL;
- if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
+ if (!empty($this->_params['is_email_receipt'])) {
$paymentParams['email'] = $this->userEmail;
$paymentParams['is_email_receipt'] = 1;
}
$paymentParams['is_email_receipt'] = 0;
$this->_params['is_email_receipt'] = 0;
}
- if (CRM_Utils_Array::value('receive_date', $this->_params)) {
+ if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
- if (CRM_Utils_Array::value('receive_date', $this->_params)) {
+ if (!empty($this->_params['receive_date'])) {
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
// For recurring contribution, create Contribution Record first.
// Contribution ID, Recurring ID and Contact ID needed
// When we get a callback from the payment processor, CRM-7115
- if (CRM_Utils_Array::value('is_recur', $paymentParams)) {
+ if (!empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this,
$this->_params,
$result,
if (is_a($result, 'CRM_Core_Error')) {
//make sure to cleanup db for recurring case.
- if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
+ if (!empty($paymentParams['contributionID'])) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting contribution {$paymentParams['contributionID']}");
CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
}
- if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
+ if (!empty($paymentParams['contributionRecurID'])) {
CRM_Core_Error::debug_log_message(CRM_Core_Error::getMessages($result) . "contact id={$this->_contactID} (deleting recurring contribution {$paymentParams['contributionRecurID']}");
CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
}
$this->_params['receive_date'] = $now;
- if (CRM_Utils_Array::value('is_email_receipt', $this->_params)) {
+ if (!empty($this->_params['is_email_receipt'])) {
$this->_params['receipt_date'] = $now;
}
else {
);
- if (!CRM_Utils_Array::value('is_recur', $paymentParams)) {
+ if (empty($paymentParams['is_recur'])) {
$contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($this,
$this->_params,
$result,
}
//send receipt mail.
- if ($contribution->id &&
- CRM_Utils_Array::value('is_email_receipt', $this->_params)
- ) {
+ if ($contribution->id && !empty($this->_params['is_email_receipt'])) {
$this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$this->_params['contact_id'] = $this->_contactID;
$this->_params['contribution_id'] = $contribution->id;
if ($contribution->id) {
$statusMsg = ts('The contribution record has been processed.');
- if (CRM_Utils_Array::value('is_email_receipt', $this->_params) && $sendReceipt) {
+ if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');