Skip to content
Snippets Groups Projects
Commit d947cfb5 authored by lobo's avatar lobo
Browse files

eliminate dead code, formatting fixes

parent 244d9546
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
// Are we cancelling a recurring contribution that is linked to an auto-renew membership?
if ($this->_subscriptionDetails->membership_id) {
$this->_mid = $this->_subscriptionDetails->membership_id;
......@@ -96,14 +96,15 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
}
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
}
if ((!$this->_crid && !$this->_coid && !$this->_mid) ||
if (
(!$this->_crid && !$this->_coid && !$this->_mid) ||
($this->_subscriptionDetails == CRM_Core_DAO::$_nullObject)
) {
CRM_Core_Error::fatal('Required information missing.');
......@@ -125,7 +126,8 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
$this->assign('mode', $this->_mode);
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
list($this->_donorDisplayName, $this->_donorEmail) =
CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
}
......@@ -143,10 +145,15 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
$searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1');
$searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0');
$this->addGroup($searchRange, 'send_cancel_request', ts('Send cancellation request to %1 ?', array(1 => $this->_paymentProcessorObj->_processorName)));
$this->addGroup(
$searchRange,
'send_cancel_request',
ts('Send cancellation request to %1 ?',
array(1 => $this->_paymentProcessorObj->_processorName))
);
}
$this->assign('cancelSupported', $cancelSupported);
if ($this->_donorEmail) {
$this->add('checkbox', 'is_notify', ts('Notify Contributor?'));
}
......@@ -187,8 +194,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
* @access public
*/
function setDefaultValues() {
$defaults = array();
$defaults['is_notify'] = 1;
$defaults = array('is_notify' => 1);
return $defaults;
}
......@@ -206,10 +212,13 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
if ($this->_selfService) {
// for self service force sending-request & notify
if ($this->_paymentProcessorObj->isSupported('cancelSubscription'))
if ($this->_paymentProcessorObj->isSupported('cancelSubscription')) {
$params['send_cancel_request'] = 1;
if ($this->_donorEmail)
}
if ($this->_donorEmail) {
$params['is_notify'] = 1;
}
}
if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
......@@ -221,20 +230,27 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
CRM_Core_Error::displaySessionError($cancelSubscription);
}
elseif ($cancelSubscription) {
$activityParams = array('subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'),
'details' => $message,
);
$cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($this->_subscriptionDetails->recur_id,
CRM_Core_DAO::$_nullObject, $activityParams
$activityParams =
array(
'subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'),
'details' => $message,
);
$cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution(
$this->_subscriptionDetails->recur_id,
CRM_Core_DAO::$_nullObject,
$activityParams
);
if ($cancelStatus) {
$tplParams = array();
if ($this->_mid) {
$inputParams = array('id' => $this->_mid);
CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
$tplParams = $tplParams[$this->_mid];
$tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$tplParams['membership_status'] =
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] =
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', array(1 => $tplParams['membershipType']));
$msgTitle = 'Membership Renewal Cancelled';
$msgType = 'info';
......@@ -257,22 +273,27 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
if (CRM_Utils_Array::value('is_notify', $params) == 1) {
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id',
$this->_subscriptionDetails->contribution_page_id,
$value, array('title',
'receipt_from_name',
'receipt_from_email',
)
);
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
CRM_Core_DAO::commonRetrieveAll(
'CRM_Contribute_DAO_ContributionPage',
'id',
$this->_subscriptionDetails->contribution_page_id,
$value,
array('title', 'receipt_from_name', 'receipt_from_email')
);
$receiptFrom =
'"' .
CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) .
'" <' .
$value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] .
'>';
}
else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "$domainValues[0] <$domainValues[1]>";
}
// send notification
$sendTemplateParams =
$sendTemplateParams =
array(
'groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution',
'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled',
......@@ -310,12 +331,11 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form {
$session->setStatus($status, $msgTitle, $msgType);
}
elseif (!$userID) {
if ($status)
if ($status)
CRM_Utils_System::setUFMessage($status);
// keep result as 1, since we not displaying anything on the redirected page anyway
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus',
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus',
"reset=1&task=cancel&result=1"));
}
}
}
......@@ -38,8 +38,6 @@
*
*/
class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditPayment {
const FA_ASSET_ACCOUNT_RELATION = 6;
/**
* the id of the contribution that we are proceessing
*
......@@ -260,7 +258,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
// Set title
if ($this->_contactID) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
// Check if this is default domain contact CRM-10482
if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactID)) {
$displayName .= ' (' . ts('default organization') . ')';
......@@ -269,7 +267,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('Contribution from') . ' ' . $displayName);
}
}
function setDefaultValues() {
......@@ -296,11 +294,11 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
if ($this->_mode) {
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
// set default country from config if no country set
if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
$defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
$defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
}
......@@ -315,9 +313,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$fields[$name] = 1;
}
if ($this->_contactID) {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $defaults);
}
if ($this->_contactID) {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $defaults);
}
foreach ($names as $name) {
if (!empty($defaults[$name])) {
......@@ -326,16 +324,16 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
}
// now fix all state country selectors
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
}
if ($this->_id) {
$this->_contactID = $defaults['contact_id'];
}
// Set $newCredit variable in template to control whether link to credit card mode is included
CRM_Core_Payment::allowBackofficeCreditCard($this);
// fix the display of the monetary value, CRM-4038
if (isset($defaults['total_amount'])) {
$defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
......@@ -617,7 +615,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
}
$this->applyFilter('__ALL__', 'trim');
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(
array(
......@@ -786,7 +784,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
'' => ts('Choose price set')
) + $priceSets,
NULL, array('onchange' => "buildAmount( this.value );")
);
);
if ($this->_online && !($this->_action & CRM_Core_Action::UPDATE)) {
$element->freeze();
}
......@@ -847,12 +845,12 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$dataUrl = CRM_Utils_System::url('civicrm/ajax/rest',
"className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1&context=softcredit&cid={$this->_contactID}",
FALSE, NULL, FALSE
);
);
} else {
$dataUrl = CRM_Utils_System::url('civicrm/ajax/rest',
'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1&context=softcredit',
FALSE, NULL, FALSE
);
);
}
$this->assign('dataUrl', $dataUrl);
$this->addElement('text', 'soft_credit_to', ts('Soft Credit To'));
......@@ -895,7 +893,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
// if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type,
// Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail
if ($this->_id && $this->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) {
if ($totalAmount) {
if ($totalAmount) {
$totalAmount->freeze();
}
$checkNumber->freeze();
......@@ -964,8 +962,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$errors['pcp_made_through'] = ts('Please select a Personal Campaign Page, OR uncheck Display in Honor Roll and clear both the Honor Roll Name and the Personal Note field.');
}
}
if (CRM_Utils_Array::value('total_amount', $fields) && (CRM_Utils_Array::value('net_amount', $fields) || CRM_Utils_Array::value('fee_amount', $fields))){
if (CRM_Utils_Array::value('total_amount', $fields) && (CRM_Utils_Array::value('net_amount', $fields) || CRM_Utils_Array::value('fee_amount', $fields))){
$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');
......@@ -1036,13 +1034,13 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
if ($priceSetId) {
CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'],
$submittedValues, $lineItem[$priceSetId]);
$submittedValues, $lineItem[$priceSetId]);
$submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues);
}
if ($this->_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');
$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) {
// 10117 update th line items for participants
......@@ -1078,8 +1076,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config')) {
$isQuickConfig = 1;
}
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//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)) {
......@@ -1087,7 +1085,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$values['financial_type_id'] = $submittedValues['financial_type_id'];
}
}
if (!CRM_Utils_Array::value('total_amount', $submittedValues)) {
$submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
}
......@@ -1253,7 +1251,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
}
//process premium
if ($contribution->id && isset($formValues['product_name'][0])) {
if ($contribution->id && isset($formValues['product_name'][0])) {
CRM_Contribute_Form_AdditionalInfo::processPremium($formValues, $contribution->id,
$this->_premiumID, $this->_options
);
......@@ -1323,19 +1321,19 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
);
}
}
$statusMsg = ts('The contribution record has been saved.');
if (CRM_Utils_Array::value('is_email_receipt', $formValues) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
if ($relatedComponentStatusMsg) {
$statusMsg .= ' ' . $relatedComponentStatusMsg;
}
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
//Offline Contribution ends.
}
}
$buttonName = $this->controller->getButtonName();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
......@@ -1360,7 +1358,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
));
}
}
public function processCreditCard($submittedValues, $config, $session, $pId, $lineItem) {
$unsetParams = array(
'trxn_id',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment