Commit 0e848f65 authored by ErikHommel's avatar ErikHommel 🏘
Browse files

issue 6544 - complete form processor for extend member (no link)

parent 3b09ad21
......@@ -52,9 +52,7 @@ class ExtendMembership extends AbstractAction {
*/
public function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$membershipData = $this->getMembershipData($parameters, $output);
if ($membershipData) {
$this->extendMembership($membershipData, $parameters, $output);
}
$this->extendMembership($membershipData, $parameters, $output);
}
/**
......@@ -78,13 +76,14 @@ class ExtendMembership extends AbstractAction {
}
}
catch (\CiviCRM_API3_Exception $ex) {
// error activity because it should not be necessary to create a new membership
$errorActivityData = [
'assignee_id' => $this->configuration->getParameter('error_contact_id'),
'subject' => E::ts("Error extending membership: no membership found for contact ID ") . $contactId,
'details' => E::ts("Error message from API Membership getsingle: ") . $ex->getMessage(),
'subject' => E::ts("Fout bij het verlengen van een lidmaatschap voor contact ID ") . $contactId,
'details' => E::ts("Geen lidmaatschap gevonden en dus een nieuwe aangemaakt."),
];
\Civi::service('aivlgeneric')->createToCheckActivity($errorActivityData);
return FALSE;
return [];
}
}
}
......@@ -102,21 +101,24 @@ class ExtendMembership extends AbstractAction {
$newEndDate = strtotime(date("Y-m-01"), $newEndDate);
$newEndDate = strtotime("+ 1 year", $newEndDate);
// update the membership or create
$membershipParams = [
'end_date' => date('Ymd', $newEndDate),
'membership_type_id' => $this->configuration->getParameter('membership_type_id'),
'contact_id' => $contactId,
];
try {
civicrm_api3('Membership', 'create', [
'id' => $membershipData['id'],
'end_date' => date('Ymd', $newEndDate),
'membership_type_id' => $this->configuration->getParameter('membership_type_id'),
'contact_id' => $contactId,
]);
$output->setParameter('membership_id', $membershipData['id']);
if ($membershipData['id']) {
$membershipParams['id'] = $membershipData['id'];
}
$created = civicrm_api3('Membership', 'create', $membershipParams);
$output->setParameter('membership_id', $created['id']);
$output->setParameter('new_end_date', date('d-m-Y', $newEndDate));
}
catch (\CiviCRM_API3_Exception $ex) {
$errorActivityData = [
'assignee_id' => $this->configuration->getParameter('error_contact_id'),
'subject' => E::ts("Error extending membership: error extending membership for contact ID ") . $contactId,
'details' => E::ts("Error message from API Membership create: ") . $ex->getMessage(),
'subject' => E::ts("Fout bij het verlengen van een lidmaatschap voor contact ID ") . $contactId,
'details' => E::ts("Fout van de API Membership create: ") . $ex->getMessage(),
];
\Civi::service('aivlgeneric')->createToCheckActivity($errorActivityData);
}
......
......@@ -14,8 +14,8 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-06-25</releaseDate>
<version>1.4</version>
<releaseDate>2020-07-09</releaseDate>
<version>1.5</version>
<develStage>beta</develStage>
<compatibility>
<ver>4.7</ver>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment