Commit 84906129 authored by jaapjansma's avatar jaapjansma

added action for concatting a date and time field into one

parent da0bdc6c
......@@ -9,6 +9,7 @@ Version 1.4 (not yet released)
* Added action to repeat an event (custom fields work since civicrm 5.15)
* Added action to get repetition of an event
* Added action to create a case
* Added action to concat (meger) a date and a time field into one
Version 1.3
-----------
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Action\Generic;
use \Civi\ActionProvider\Action\AbstractAction;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use \Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Utils\CustomField;
use CRM_ActionProvider_ExtensionUtil as E;
class ConcatDateTimeValue extends AbstractAction {
/**
* Returns a help text for this action.
*
* The help text is shown to the administrator who is configuring the action.
* Override this function in a child class if your action has a help text.
*
* @return string|false
*/
public function getHelpText() {
return E::ts('This action is useful when you have separate fields for date and time and your next action needs one field.
For example to create an event you need one field for start date and time. This action provides this');
}
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag();
}
/**
* Returns the specification of the configuration options for the actual action.
*
* @return SpecificationBag
* @throws \Exception
*/
public function getParameterSpecification() {
return new SpecificationBag(array(
new Specification('date', 'Date', E::ts('Date field'), true),
new Specification('time', 'String', E::ts('Time field'), true)
));
}
/**
* Returns the specification of the output parameters of this action.
*
* This function could be overriden by child classes.
*
* @return SpecificationBag
*/
public function getOutputSpecification() {
return new SpecificationBag(array(
new Specification('date', 'Date', E::ts('Date')),
));
}
/**
* Run the action
*
* @param ParameterBagInterface $parameters
* The parameters to this action.
* @param ParameterBagInterface $output
* The parameters this action can send back
* @return void
* @throws \Exception
*/
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$sDate = $parameters->getParameter('date');
$sTime = $parameters->getParameter('time');
$date = new \DateTime(trim($sDate.' '.$sTime));
$output->setParameter('date', $date->format('YmdHis'));
}
}
\ No newline at end of file
......@@ -62,6 +62,8 @@ class Provider {
AbstractAction::DATA_MANIPULATION_TAG));
$this->addActionWithoutFiltering('SetDateValue', '\Civi\ActionProvider\Action\Generic\SetDateValue', E::ts('Set date value'), array(
AbstractAction::DATA_MANIPULATION_TAG));
$this->addActionWithoutFiltering('ConcatDateTimeValue', '\Civi\ActionProvider\Action\Generic\ConcatDateTimeValue', E::ts('Concat (merge) a date and a time field to one field'), array(
AbstractAction::DATA_MANIPULATION_TAG));
$this->addActionWithoutFiltering('AddToGroup', '\Civi\ActionProvider\Action\Group\AddToGroup', E::ts('Add to Group'), array(
AbstractAction::SINGLE_CONTACT_ACTION_TAG,
AbstractAction::DATA_MANIPULATION_TAG,
......
Markdown is supported
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