}
}
+ //set Soft Credit Type to Gift by default
+ $scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
+ $defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));
+
if (!empty($defaults['record_contribution']) && !$this->_mode) {
$contributionParams = array('id' => $defaults['record_contribution']);
$contributionIds = array();
ts('Financial Type'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
);
- if ($this->_context != 'standalone') {
- //CRM-10223 - allow contribution to be recorded against different contact
- // causes a conflict in standalone mode so skip in standalone for now
- $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
- $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
- $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
- }
+
+ //CRM-10223 - allow contribution to be recorded against different contact
+ // causes a conflict in standalone mode so skip in standalone for now
+ $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?'));
+ $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft'));
+ $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE));
+
$this->addElement('checkbox',
'send_receipt',
*
* @param array $params (ref.) an assoc array of name/value pairs
*
+ * @param $files
+ * @param $self
+ *
+ * @throws CiviCRM_API3_Exception
* @return mixed true or array of errors
* @access public
* @static
if (empty($params['soft_credit_type_id'])) {
$errors['soft_credit_type_id'] = ts('Please Select a Soft Credit Type');
}
- if (empty($params['contribution_contact'][1])) {
- $errors['contribution_contact[1]'] = ts('Please select a contact');
+ if (empty($params['soft_credit_contact_id'])) {
+ $errors['soft_credit_contact_id'] = ts('Please select a contact');
}
}
'is_current_member' => 0,
));
$tmp_statuses = $result['values'];
- $status_ids = array();
+ $status_ids = array();
foreach($tmp_statuses as $cur_stat) {
- $status_ids[] = $cur_stat['id'];
+ $status_ids[] = $cur_stat['id'];
}
- if( $params['status_id'] == false || in_array( $params['status_id'] , $status_ids) == false ) {
+ if (empty($params['status_id']) || in_array( $params['status_id'] , $status_ids) == false) {
$errors['status_id'] = ts('Please enter a status that does NOT represent a current membership status.');
$errors['is_override'] = ts('This must be checked because you set an End Date for a lifetime membership');
}
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($ids['userId']);
- //CRM-10223 - allow contribution to be recorded against different contact
+ //CRM-13981, allow different person as a soft-contributor of chosen type
if ($this->_contributorContactID != $this->_contactID) {
$params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])) {
$softParams['soft_credit_type_id'] = $this->_params['soft_credit_type_id'];
- $softParams['contact_id'] = $params['contact_id'];
+ $softParams['contact_id'] = $this->_contactID;
}
}
if (!empty($formValues['record_contribution'])) {
$lineItems[$itemId]['line_total'] = $params['total_amount'];
$lineItems[$itemId]['id'] = $itemId;
$lineItem[$priceSetId] = $lineItems;
- CRM_Price_BAO_LineItem::processPriceSet($params['contribution_id'], $lineItem);
+ $contributionBAO = new CRM_Contribute_BAO_Contribution();
+ $contributionBAO->id = $params['contribution_id'];
+ $contributionBAO->find();
+ CRM_Price_BAO_LineItem::processPriceSet($params['contribution_id'], $lineItem, $contributionBAO, 'civicrm_membership');
//create new soft-credit record, CRM-13981
$softParams['contribution_id'] = $params['contribution_id'];
- $dao = new CRM_Contribute_DAO_Contribution();
- $dao->id = $params['contribution_id'];
- $dao->find();
- while ($dao->fetch()) {
- $softParams['currency'] = $dao->currency;
- $softParams['amount'] = $dao->total_amount;
+
+ while ($contributionBAO->fetch()) {
+ $softParams['currency'] = $contributionBAO->currency;
+ $softParams['amount'] = $contributionBAO->total_amount;
}
CRM_Contribute_BAO_ContributionSoft::add($softParams);
}
}
$membershipParams['init_amount'] = $init_amount;
}
+
+ if (!empty($softParams)) {
+ $membershipParams['soft_credit'] = $softParams;
+ }
+
$membership = CRM_Member_BAO_Membership::create($membershipParams, $ids);
$this->_membershipIDs[] = $membership->id;
/**
* Function to send email receipt
*
- * @param object $form form object
- * @param array $values submitted values
+ * @param object $form form object
+ * @param $formValues
* @param object $membership object
*
+ * @internal param array $values submitted values
* @return boolean true if mail was sent successfully
* @static
*/