/**
* email of the person paying for the membership (used for receipts)
+ * @var string
*/
protected $_memberEmail = NULL;
/**
* email of the person paying for the membership (used for receipts)
+ * @var string
*/
protected $_contributorEmail = NULL;
/**
* context would be set to standalone if the contact is use is being selected from
* the form rather than in the URL
+ * @var string
*/
public $_context;
*/
protected $membershipTypeName = '';
- /**
- * An array to hold a list of datefields on the form
- * so that they can be converted to ISO in a consistent manner
- *
- * @var array
- */
- protected $_dateFields = array(
- 'receive_date' => array('default' => 'now'),
- );
-
/**
* Set entity fields to be assigned to the form.
*/
$defaults = parent::setDefaultValues();
// set renewal_date and receive_date to today in correct input format (setDateDefaults uses today if no value passed)
- list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
+ $now = date('Y-m-d');
$defaults['renewal_date'] = $now;
- $defaults['receive_date'] = $now;
- $defaults['receive_date_time'] = $currentTime;
+ $defaults['receive_date'] = $now . ' ' . date('H:i:s');
if ($defaults['id']) {
$defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment',
$scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
$defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));
- $renewalDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('renewal_date', $defaults),
- NULL, NULL, 'Y-m-d'
- );
+ $renewalDate = CRM_Utils_Array::value('renewal_date', $defaults);
$this->assign('renewalDate', $renewalDate);
$this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
$this->assign('entityID', $this->_id);
$selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
- $allMembershipInfo = array();
+ $allMembershipInfo = [];
// CRM-21485
if (is_array($defaults['membership_type_id'])) {
// build membership info array, which is used to set the payment information block when
// membership type is selected.
- $allMembershipInfo[$key] = array(
+ $allMembershipInfo[$key] = [
'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values),
'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'),
'total_amount_numeric' => $totalAmount,
- 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount,
- );
+ 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", [1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount)]) : $taxAmount,
+ ];
if (!empty($values['auto_renew'])) {
$allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']];
$selOrgMemType[$index] = $orgMembershipType;
}
- $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData('Membership', this.value);");
+ $js = ['onChange' => "setPaymentBlock(); CRM.buildCustomData('Membership', this.value);"];
$sel = &$this->addElement('hierselect',
'membership_type_id',
ts('Renewal Membership Organization and Type'), $js
);
- $sel->setOptions(array($selMemTypeOrg, $selOrgMemType));
- $elements = array();
+ $sel->setOptions([$selMemTypeOrg, $selOrgMemType]);
+ $elements = [];
if ($sel) {
$elements[] = $sel;
}
$this->applyFilter('__ALL__', 'trim');
- $this->addDate('renewal_date', ts('Date Renewal Entered'), FALSE, array('formatType' => 'activityDate'));
+ $this->add('datepicker', 'renewal_date', ts('Date Renewal Entered'), [], FALSE, ['time' => FALSE]);
$this->add('select', 'financial_type_id', ts('Financial Type'),
- array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
+ ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::financialType()
);
- $this->add('number', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
+ $this->add('number', 'num_terms', ts('Extend Membership by'), ['onchange' => "setPaymentBlock();"], TRUE);
$this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer');
if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) {
- $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, array('onclick' => "checkPayment();"));
+ $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, ['onclick' => "checkPayment();"]);
$this->add('text', 'total_amount', ts('Amount'));
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
- $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
+ $this->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]);
$this->add('select', 'payment_instrument_id', ts('Payment Method'),
- array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
- FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+ ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(),
+ FALSE, ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"]
);
$this->add('text', 'trxn_id', ts('Transaction ID'));
$this->addRule('trxn_id', ts('Transaction ID already exists in Database.'),
- 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id')
+ 'objectExists', ['CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id']
);
$this->add('select', 'contribution_status_id', ts('Payment Status'),
$this->addRule('total_amount', ts('Please enter a valid amount.'), 'money');
}
$this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL,
- array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);")
+ ['onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);"]
);
$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
);
}
}
- $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule'), $this);
+ $this->addFormRule(['CRM_Member_Form_MembershipRenewal', 'formRule'], $this);
$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->addSelect('soft_credit_type_id', ['entity' => 'contribution_soft']);
+ $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), ['create' => TRUE]);
}
/**
*
* @param array $params
* (ref.) an assoc array of name/value pairs.
+ * @param $files
+ * @param $self
*
* @return bool|array
* mixed true or array of errors
*/
public static function formRule($params, $files, $self) {
- $errors = array();
+ $errors = [];
if ($params['membership_type_id'][0] == 0) {
$errors['membership_type_id'] = ts('Oops. It looks like you are trying to change the membership type while renewing the membership. Please click the "change membership type" link, and select a Membership Organization.');
}
// The fields in Renewal form come into this routine in $params array. 'renewal_date' is in the form
// We process both the dates before comparison using CRM utils so that they are in same date format
if (isset($params['renewal_date'])) {
- if (CRM_Utils_Date::processDate($params['renewal_date']) < CRM_Utils_Date::processDate($joinDate)) {
+ if ($params['renewal_date'] < $joinDate) {
$errors['renewal_date'] = ts('Renewal date must be the same or later than Member since (Join Date).');
}
}
try {
$this->submit();
- $statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $this->membershipTypeName, 2 => $this->_memberDisplayName));
+ $statusMsg = ts('%1 membership for %2 has been renewed.', [1 => $this->membershipTypeName, 2 => $this->_memberDisplayName]);
if ($this->endDate) {
- $statusMsg .= ' ' . ts('The new membership End Date is %1.', array(
+ $statusMsg .= ' ' . ts('The new membership End Date is %1.', [
1 => CRM_Utils_Date::customFormat(substr($this->endDate, 0, 8)),
- ));
+ ]);
}
if ($this->isMailSent) {
- $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array(
+ $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', [
1 => $this->_contributorEmail,
- ));
+ ]);
return $statusMsg;
}
return $statusMsg;
$this->storeContactFields($this->_params);
$this->beginPostProcess();
$now = CRM_Utils_Date::getToday(NULL, 'YmdHis');
- $this->convertDateFieldsToMySQL($this->_params);
- $this->assign('receive_date', $this->_params['receive_date']);
+ $this->assign('receive_date', CRM_Utils_Array::value('receive_date', $this->_params, date('Y-m-d H:i:s')));
$this->processBillingAddress();
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID'));
$this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params,
$this->assign('trxn_id', $result['trxn_id']);
}
- $renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = CRM_Utils_Date::processDate($this->_params['renewal_date']) : NULL;
+ $renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = $this->_params['renewal_date'] : NULL;
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
$this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})";
//create line items
- $lineItem = array();
+ $lineItem = [];
$this->_params = $this->setPriceSetParameters($this->_params);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
$this->_params, $lineItem[$this->_priceSetId], NULL, $this->_priceSetId
if ($this->_contributorContactID != $this->_contactID) {
$this->_params['contribution_contact_id'] = $this->_contributorContactID;
if (!empty($this->_params['soft_credit_type_id'])) {
- $this->_params['soft_credit'] = array(
+ $this->_params['soft_credit'] = [
'soft_credit_type_id' => $this->_params['soft_credit_type_id'],
'contact_id' => $this->_contactID,
- );
+ ];
}
}
$this->_params['contact_id'] = $this->_contactID;
// not a great pattern & ideally it would not receive as a reference. We assign our params as a
// temporary variable to avoid e-notice & to make it clear to future refactorer that
// this function is NOT reliant on that var being set
- $temporaryParams = array_merge($this->_params, array(
+ $temporaryParams = array_merge($this->_params, [
'membership_id' => $membership->id,
'contribution_recur_id' => $contributionRecurID,
- ));
+ ]);
//Remove `tax_amount` if it is not calculated.
if (CRM_Utils_Array::value('tax_amount', $temporaryParams) === 0) {
unset($temporaryParams['tax_amount']);
$this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', NULL, $this->_id, FALSE, $this->_memType);
// retrieve custom data
- $customFields = $customValues = $fo = array();
+ $customFields = $customValues = $fo = [];
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
$customFields["custom_{$k}"] = $field;
}
}
- $members = array(array('member_id', '=', $this->_membershipId, 0, 0));
+ $members = [['member_id', '=', $this->_membershipId, 0, 0]];
// check whether its a test drive
if ($this->_mode == 'test') {
- $members[] = array('member_test', '=', 1, 0, 0);
+ $members[] = ['member_test', '=', 1, 0, 0];
}
CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members);
}
list($this->isMailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate(
- array(
+ [
'groupName' => 'msg_tpl_workflow_membership',
'valueName' => 'membership_offline_receipt',
'contactId' => $this->_receiptContactId,
'toName' => $this->_contributorDisplayName,
'toEmail' => $this->_contributorEmail,
'isTest' => $this->_mode == 'test',
- )
+ ]
);
}
}