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