diff --git a/CRM/I3val/Handler/SddUpdate.php b/CRM/I3val/Handler/SddUpdate.php index d763972..1820fdf 100644 --- a/CRM/I3val/Handler/SddUpdate.php +++ b/CRM/I3val/Handler/SddUpdate.php @@ -38,6 +38,7 @@ public function getField2Label() { 'end_date' => E::ts('End Date'), 'frequency' => E::ts('Frequency'), 'cycle_day' => E::ts('Cycle Day'), + 'reason' => E::ts('Reason'), 'financial_type' => E::ts('Financial Type'), 'campaign' => E::ts('Campaign'), 'amount' => E::ts('Amount'), @@ -398,7 +399,7 @@ public function generateDiffData($entity, $submitted_data, &$activity_data) { } // OK, we have the mandate, look for differences - $mandate_diff = array(); + $mandate_diff = array(); $main_attributes = $this->getMainFields(); $all_attributes = $this->getFields(); $custom_group_name = $this->getCustomGroupName(); diff --git a/Civi/I3val/ActionProvider/Action/RequestContactUpdate.php b/Civi/I3val/ActionProvider/Action/RequestContactUpdate.php index 4afe237..7f0d086 100644 --- a/Civi/I3val/ActionProvider/Action/RequestContactUpdate.php +++ b/Civi/I3val/ActionProvider/Action/RequestContactUpdate.php @@ -32,19 +32,12 @@ class RequestContactUpdate extends AbstractAction { * @return SpecificationBag specs */ public function getConfigurationSpecification() { - // load activity types - $activity_types = ['' => E::ts("none")]; - $types = \civicrm_api3('OptionValue', 'get', [ - 'option.limit' => 0, - 'option_group_id' => 'activity_type', - 'return' => 'value,label']); - foreach ($types['values'] as $type) { - $types[$type['value']] = $type['label']; - } + // get the current configuration + $configuration = \CRM_I3val_Configuration::getConfiguration(); // specify config return new SpecificationBag([ - new Specification('activity_type_id', 'Integer', E::ts('Default Activity Type'), false, null, null, $activity_types, false), + new Specification('activity_type_id', 'Integer', E::ts('Default Activity Type'), false, null, null, $configuration->getActivityTypes(), false), ]); } diff --git a/Civi/I3val/ActionProvider/Action/RequestMandateUpdate.php b/Civi/I3val/ActionProvider/Action/RequestMandateUpdate.php new file mode 100644 index 0000000..7592485 --- /dev/null +++ b/Civi/I3val/ActionProvider/Action/RequestMandateUpdate.php @@ -0,0 +1,115 @@ + E::ts("No Status Change"), + 'COMPLETE' => E::ts("Terminate Mandate (COMPLETE)"), + 'INVALID' => E::ts("Mark Mandate as Invalid (INVALID)"), + ]; + + // specify config + return new SpecificationBag([ + new Specification('activity_type_id', 'Integer', E::ts('Default Activity Type'), false, null, null, $configuration->getActivityTypes(), false), + new Specification('i3val_note', 'String', E::ts('Note'), false, null, null, $activity_types, false), + new Specification('status', 'String', E::ts('Requested Status'), false, null, null, $requested_status, false), + ]); + } + + /** + * Returns the specification of the parameters of the actual action. + * + * @return SpecificationBag specs + */ + public function getParameterSpecification() { + $specs = []; + + // add metadata + $specs[] = new Specification('activity_type_id', 'Integer', E::ts('Activity Type'), false, null, null, null, false); + $specs[] = new Specification('id', 'Integer', E::ts('Contact ID'), false, null, null, null, false); + $specs[] = new Specification('i3val_note', 'String', E::ts('Note'), false, null, null, null, false); + $specs[] = new Specification('i3val_schedule_date', 'String', E::ts('Requested Change Date'), false, null, null, null, false); + $specs[] = new Specification('i3val_parent_id', 'Integer', E::ts('Linked Activity ID'), false, null, null, null, false); + $specs[] = new Specification('source', 'String', E::ts('Source'), false, null, null, null, false); + $specs[] = new Specification('sdd_reason', 'String', E::ts('Cancel Reason'), false, null, null, null, false); + + // add mandate identifier + $specs[] = new Specification('reference', 'String', E::ts('Mandate Reference'), true, null, null, null, false); + + // basic fields + $specs[] = new Specification('status', 'String', E::ts('Status'), false, null, null, null, false); + $specs[] = new Specification('iban', 'String', E::ts('IBAN'), false, null, null, null, false); + $specs[] = new Specification('bic', 'String', E::ts('BIC'), false, null, null, null, false); + + // add date fields + $specs[] = new Specification('date', 'Date', E::ts('Signature Date'), false, null, null, null, false); + $specs[] = new Specification('validation_date', 'Date', E::ts('Validation Date'), false, null, null, null, false); + $specs[] = new Specification('start_date', 'Date', E::ts('Start Date'), false, null, null, null, false); + $specs[] = new Specification('end_date', 'Date', E::ts('End Date'), false, null, null, null, false); + + // add collection fields + $specs[] = new Specification('frequency', 'Integer', E::ts('Frequency'), false, null, null, null, false); + $specs[] = new Specification('cycle_day', 'Integer', E::ts('Cycle Day'), false, null, null, null, false); + $specs[] = new Specification('financial_type', 'String', E::ts('Financial Type'), false, null, null, null, false); + $specs[] = new Specification('campaign', 'String', E::ts('Campaign'), false, null, null, null, false); + $specs[] = new Specification('amount', 'Float', E::ts('Amount'), false, null, null, null, false); + + return new SpecificationBag($specs); + } + + /** + * Run the action + * + * @param ParameterBagInterface $parameters + * The parameters to this action. + * @param ParameterBagInterface $output + * The parameters this action can send back + * @return void + */ + protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) { + $params = $parameters->toArray(); + + // override if necessary + foreach (['activity_type_id', 'i3val_note', 'status'] as $field_name) { + if (empty($params[$field_name])) { + $params[$field_name] = $this->configuration->getParameter($field_name); + } + } + + // execute + $result = \civicrm_api3('SepaMandate', 'request_update', $params); + } +} \ No newline at end of file diff --git a/Civi/I3val/ContainerSpecs.php b/Civi/I3val/ContainerSpecs.php index db78ccf..a726200 100644 --- a/Civi/I3val/ContainerSpecs.php +++ b/Civi/I3val/ContainerSpecs.php @@ -2,7 +2,7 @@ /*-------------------------------------------------------+ | Ilja's Input Validation Extension | | Amnesty International Vlaanderen | -| Copyright (C) 2017-2019 SYSTOPIA | +| Copyright (C) 2017-2020 SYSTOPIA | | Author: B. Endres (endres@systopia.de) | | http://www.systopia.de/ | +--------------------------------------------------------+ @@ -34,7 +34,11 @@ public function process(ContainerBuilder $container) { $typeFactoryDefinition = $container->getDefinition('action_provider'); $typeFactoryDefinition->addMethodCall('addAction', ['RequestContactUpdate', 'Civi\I3val\ActionProvider\Action\RequestContactUpdate', E::ts('Request Contact Update'), [ \Civi\ActionProvider\Action\AbstractAction::SINGLE_CONTACT_ACTION_TAG, - \Civi\ActionProvider\Action\AbstractAction::DATA_RETRIEVAL_TAG + \Civi\ActionProvider\Action\AbstractAction::DATA_MANIPULATION_TAG + ]]); + $typeFactoryDefinition->addMethodCall('addAction', ['RequestMandateUpdate', 'Civi\I3val\ActionProvider\Action\RequestMandateUpdate', E::ts('Request CiviSEPA Mandate Update'), [ + \Civi\ActionProvider\Action\AbstractAction::SINGLE_CONTACT_ACTION_TAG, + \Civi\ActionProvider\Action\AbstractAction::DATA_MANIPULATION_TAG ]]); } } \ No newline at end of file