CRM_Member_BAO_Membership::recordMembershipContribution($contrbutionParams);
}
else {
- $dateTypes = [
- 'membership_join_date' => 'joinDate',
- 'membership_start_date' => 'startDate',
- 'membership_end_date' => 'endDate',
- ];
-
- $dates = [
- 'join_date',
- 'start_date',
- 'end_date',
- 'reminder_date',
- ];
- foreach ($dateTypes as $dateField => $dateVariable) {
- $$dateVariable = CRM_Utils_Date::processDate($value[$dateField]);
- $fDate[$dateField] = $value[$dateField] ?? NULL;
- }
-
- $calcDates = [];
- $calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId,
- $joinDate, $startDate, $endDate
+ $calcDates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId,
+ $value['membership_join_date'] ?? NULL, $value['membership_start_date'] ?? NULL, $value['membership_end_date'] ?? NULL
);
-
- foreach ($calcDates as $memType => $calcDate) {
- foreach ($dates as $d) {
- //first give priority to form values then calDates.
- $date = $value[$d] ?? NULL;
- if (!$date) {
- $date = $calcDate[$d] ?? NULL;
- }
-
- $value[$d] = CRM_Utils_Date::processDate($date);
- }
- }
+ $value['join_date'] = $value['membership_join_date'] ?? $calcDates['join_date'];
+ $value['start_date'] = $value['membership_start_date'] ?? $calcDates['start_date'];
+ $value['end_date'] = $value['membership_end_date'] ?? $calcDates['end_date'];
unset($value['membership_start_date']);
unset($value['membership_end_date']);
- $ids = [];
- // @todo stop passing empty $ids
- $membership = CRM_Member_BAO_Membership::create($value, $ids);
+ $membership = CRM_Member_BAO_Membership::create($value);
}
//process premiums
* and format for use with buildProfile. This is the SQL analog of
* formatUFFields().
*
- * @param mix $id
+ * @param int $id
* The id of the UF group or ids of ufgroup.
* @param bool|int $register are we interested in registration fields
* @param int $action
$this->setCurrencySeparators($thousandSeparator);
$form = new CRM_Batch_Form_Entry();
- $profileID = $this->callAPISuccessGetValue('UFGroup', ['return' => 'id', 'name' => 'membership_batch_entry']);
+ $profileID = (int) $this->callAPISuccessGetValue('UFGroup', ['return' => 'id', 'name' => 'membership_batch_entry']);
$form->_fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::VIEW);
$params = $this->getMembershipData();
$this->assertTrue($form->testProcessMembership($params));
- $result = $this->callAPISuccess('membership', 'get', []);
+ $result = $this->callAPISuccess('membership', 'get');
$this->assertEquals(3, $result['count']);
//check start dates #1 should default to 1 Jan this year, #2 should be as entered
$this->assertEquals(date('Y-m-d', strtotime('first day of January 2013')), $result['values'][1]['start_date']);
//check start dates #1 should default to 1 Jan this year, #2 should be as entered
$this->assertEquals(date('Y-m-d', strtotime('07/22/2013')), $result['values'][1]['join_date']);
$this->assertEquals(date('Y-m-d', strtotime('07/03/2013')), $result['values'][2]['join_date']);
- $this->assertEquals(date('Y-m-d', strtotime('now')), $result['values'][3]['join_date']);
+ $this->assertEquals(date('Y-m-d'), $result['values'][3]['join_date']);
$result = $this->callAPISuccess('contribution', 'get', ['return' => ['total_amount', 'trxn_id']]);
$this->assertEquals(3, $result['count']);
foreach ($result['values'] as $key => $contribution) {