feat(call-script): add the Call Script component (0.19.0)
A new Mautic component, listed under Components > Call Scripts (/s/call-scripts),
built like the other domains on AbstractStandardFormController/FormModel.
- CallScript (mt3s_call_scripts): name, description, category, owner, status,
the publish window shown as start/end date and time, the HTML script with
dynamic tokens kept as typed (html cleaning mask), the calling window
(weekdays, hours, sentinel in the contact's or a fixed timezone) and the retry
policy (max attempts, delay, backoff: none/linear/exponential)
- CallScriptOutcome (mt3s_call_script_outcomes, ON DELETE CASCADE): label,
data type (checkbox/radio/free text/dropdown), options JSON ({value,label})
and position; nested collections reuse the program-collection JS
- validators: ValidCallingWindow, ValidCallScriptOutcomeOptions, and an atPath
option on EndDateAfterStartDate so its violation lands on publishDown
- config: routes, the Components menu item (parent mautic.core.components),
call_script category type, model alias, call_scripts permissions, version 0.19.0
- migration Version_0_19_0 creates both tables and their FKs immediately
(users/categories SET NULL, outcomes CASCADE), idempotent
- translations en_US/fr_FR, unit tests, readme/AGENTS documentation
This commit is contained in:
1 parent
88256ca345
commit
4fb36eebfc
33 files changed
+2537
-6
No files matched your search
@@ -400,6 +400,14 @@ Mautic.mt3sMpProgramInitCollection = function ($editor) {
|
|||||||
var $row = mQuery($editor.attr('data-prototype').replace(prototypeName, nextIndex++));
|
var $row = mQuery($editor.attr('data-prototype').replace(prototypeName, nextIndex++));
|
||||||
$list.append($row);
|
$list.append($row);
|
||||||
refresh();
|
refresh();
|
||||||
|
// A new row may contain nested collections (a call script outcome's options): give them
|
||||||
|
// their own add/remove/drag handler.
|
||||||
|
$row.find('.program-collection').each(function () {
|
||||||
|
Mautic.mt3sMpProgramInitCollection(mQuery(this));
|
||||||
|
});
|
||||||
|
if (typeof Mautic.mt3sMpCallScriptInitOutcomeTypes === 'function') {
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes($row);
|
||||||
|
}
|
||||||
$row.find('select, input[type="text"], textarea').first().trigger('focus');
|
$row.find('select, input[type="text"], textarea').first().trigger('focus');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -430,6 +438,40 @@ Mautic.mt3sMpProgramInitCollection = function ($editor) {
|
|||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call Script form: show the options of an outcome only for the choice types (checkbox, radio,
|
||||||
|
* dropdown); a free text outcome has none.
|
||||||
|
*/
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes = function ($container) {
|
||||||
|
mQuery($container).find('select.program-outcome-type').each(function () {
|
||||||
|
var $select = mQuery(this);
|
||||||
|
|
||||||
|
if ($select.data('mt3sMpCallScriptTypeInitialized')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$select.data('mt3sMpCallScriptTypeInitialized', true);
|
||||||
|
|
||||||
|
var toggle = function () {
|
||||||
|
var $row = $select.closest('.program-collection-row');
|
||||||
|
$row.find('.program-outcome-options').first().toggleClass('hide', 'free_text' === $select.val());
|
||||||
|
};
|
||||||
|
|
||||||
|
$select.on('change', toggle);
|
||||||
|
toggle();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Call Script form (Components > Call Scripts): its outcomes and their nested options use the
|
||||||
|
* program collections, and the options block follows the chosen data type.
|
||||||
|
*/
|
||||||
|
Mautic.mt3sMpCallScriptOnLoad = function (container) {
|
||||||
|
mQuery(container).find('.program-collection').each(function () {
|
||||||
|
Mautic.mt3sMpProgramInitCollection(mQuery(this));
|
||||||
|
});
|
||||||
|
Mautic.mt3sMpCallScriptInitOutcomeTypes(mQuery(container));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings > Configuration > Plan: add and remove item types (description and allocation).
|
* Settings > Configuration > Plan: add and remove item types (description and allocation).
|
||||||
*/
|
*/
|
||||||
|
|||||||
+27
-2
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
return [
|
return [
|
||||||
'name' => 'MT3S Marketing Program',
|
'name' => 'MT3S Marketing Program',
|
||||||
'description' => 'MT3S Marketing: programs, tasks, audiences, and smart links with their UTM taxonomies.',
|
'description' => 'MT3S Marketing: programs, tasks, audiences, and smart links with their UTM taxonomies.',
|
||||||
'version' => '0.18.2',
|
'version' => '0.19.0',
|
||||||
'author' => 'Experiential',
|
'author' => 'Experiential',
|
||||||
|
|
||||||
'routes' => [
|
'routes' => [
|
||||||
@@ -46,6 +46,16 @@ return [
|
|||||||
'path' => '/marketing-program-audiences/{objectAction}/{objectId}',
|
'path' => '/marketing-program-audiences/{objectAction}/{objectId}',
|
||||||
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::executeAction',
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\AudienceController::executeAction',
|
||||||
],
|
],
|
||||||
|
// Call Scripts component (Components > Call Scripts): the list and its object actions.
|
||||||
|
'mt3s_call_script_index' => [
|
||||||
|
'path' => '/call-scripts/{page}',
|
||||||
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\CallScriptController::indexAction',
|
||||||
|
],
|
||||||
|
// objectAction: new, edit, delete, batchDelete.
|
||||||
|
'mt3s_call_script_action' => [
|
||||||
|
'path' => '/call-scripts/{objectAction}/{objectId}',
|
||||||
|
'controller' => 'MauticPlugin\MT3SMarketingProgramBundle\Controller\CallScriptController::executeAction',
|
||||||
|
],
|
||||||
// Smart Links domain: the list and its object actions.
|
// Smart Links domain: the list and its object actions.
|
||||||
'mt3s_smart_links_index' => [
|
'mt3s_smart_links_index' => [
|
||||||
'path' => '/smart-links/{page}',
|
'path' => '/smart-links/{page}',
|
||||||
@@ -139,6 +149,16 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// The Call Script component: a flat item attached to core's Components menu. The
|
||||||
|
// "parent" key hands it to Mautic's orphan mechanism, which places it in that group;
|
||||||
|
// the key itself is the translation key of the label.
|
||||||
|
'mt3s.call_script.menu.index' => [
|
||||||
|
'route' => 'mt3s_call_script_index',
|
||||||
|
'access' => ['mt3smarketingprogram:call_scripts:viewown', 'mt3smarketingprogram:call_scripts:viewother'],
|
||||||
|
'parent' => 'mautic.core.components',
|
||||||
|
'priority' => 80,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -173,12 +193,17 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// Registers "program" as a category type (Settings > Categories), used by Program::$category.
|
// Registers "program" as a category type (Settings > Categories), used by Program::$category,
|
||||||
|
// and "call_script" for the Call Script component.
|
||||||
'categories' => [
|
'categories' => [
|
||||||
'program' => [
|
'program' => [
|
||||||
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\Program::class,
|
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\Program::class,
|
||||||
'label' => 'mt3s.marketing_program.category.type',
|
'label' => 'mt3s.marketing_program.category.type',
|
||||||
],
|
],
|
||||||
|
'call_script' => [
|
||||||
|
'class' => MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript::class,
|
||||||
|
'label' => 'mt3s.call_script.category.type',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'parameters' => [
|
'parameters' => [
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ return function (ContainerConfigurator $configurator): void {
|
|||||||
// exactly one alias per model, under the bundle's canonical prefix.
|
// exactly one alias per model, under the bundle's canonical prefix.
|
||||||
$services->alias('mautic.mt3smarketingprogram.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.program', MauticPlugin\MT3SMarketingProgramBundle\Model\ProgramModel::class);
|
||||||
$services->alias('mautic.mt3smarketingprogram.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.task', MauticPlugin\MT3SMarketingProgramBundle\Model\TaskModel::class);
|
||||||
|
$services->alias('mautic.mt3smarketingprogram.model.call_script', MauticPlugin\MT3SMarketingProgramBundle\Model\CallScriptModel::class);
|
||||||
$services->alias('mautic.mt3smarketingprogram.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.stakeholder', MauticPlugin\MT3SMarketingProgramBundle\Model\StakeholderModel::class);
|
||||||
$services->alias('mautic.mt3smarketingprogram.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
|
$services->alias('mautic.mt3smarketingprogram.model.audience', MauticPlugin\MT3SMarketingProgramBundle\Model\AudienceModel::class);
|
||||||
// Smart Links domain: getModel('mt3smarketingprogram.smart_link') / getModel('mt3smarketingprogram.utm_taxonomy').
|
// Smart Links domain: getModel('mt3smarketingprogram.smart_link') / getModel('mt3smarketingprogram.utm_taxonomy').
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Controller;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create, edit and delete call scripts (Components > Call Scripts), using core's standard CRUD flow.
|
||||||
|
*
|
||||||
|
* Model mt3smarketingprogram.call_script (mautic.mt3smarketingprogram.model.call_script), permission base
|
||||||
|
* mt3smarketingprogram:call_scripts, translation base mt3s.call_script.
|
||||||
|
*
|
||||||
|
* Call scripts have no detail page: after Save or Cancel the user goes back to the list. They are
|
||||||
|
* never cloned (the outcomes are part of the script).
|
||||||
|
*/
|
||||||
|
class CallScriptController extends AbstractStandardFormController
|
||||||
|
{
|
||||||
|
public const ROUTE_INDEX = 'mt3s_call_script_index';
|
||||||
|
public const ROUTE_ACTION = 'mt3s_call_script_action';
|
||||||
|
|
||||||
|
protected function getModelName(): string
|
||||||
|
{
|
||||||
|
return 'mt3smarketingprogram.call_script';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTemplateBase(): string
|
||||||
|
{
|
||||||
|
return '@MT3SMarketingProgram/CallScript';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getIndexRoute(): string
|
||||||
|
{
|
||||||
|
return self::ROUTE_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getActionRoute(): string
|
||||||
|
{
|
||||||
|
return self::ROUTE_ACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]()
|
||||||
|
* (Mautic.mt3sMpCallScriptOnLoad in Assets/js/mt3s-mp-program.js). Without this override,
|
||||||
|
* core falls back to the model name, which nothing listens to.
|
||||||
|
*/
|
||||||
|
protected function getJsLoadMethodPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3sMpCallScript';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core would build mautic.mt3smarketingprogram.call_script; every key of the feature lives
|
||||||
|
* under mt3s.call_script.
|
||||||
|
*/
|
||||||
|
protected function getTranslationBase(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
*/
|
||||||
|
public function indexAction(Request $request, $page = 1): Response
|
||||||
|
{
|
||||||
|
return $this->indexStandard($request, $page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newAction(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->newStandard($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectId
|
||||||
|
* @param bool $ignorePost
|
||||||
|
*/
|
||||||
|
public function editAction(Request $request, $objectId, $ignorePost = false): Response
|
||||||
|
{
|
||||||
|
return $this->editStandard($request, $objectId, $ignorePost);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $objectId
|
||||||
|
*/
|
||||||
|
public function deleteAction(Request $request, $objectId): Response
|
||||||
|
{
|
||||||
|
return $this->deleteStandard($request, $objectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDeleteAction(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->batchDeleteStandard($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call scripts don't have a detail page; after Save or Cancel go back to the list.
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
*/
|
||||||
|
protected function getPostActionControllerAction($action): string
|
||||||
|
{
|
||||||
|
return 'index';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A saved call script is never cloned: its outcomes are part of it.
|
||||||
|
*
|
||||||
|
* @param int|null $objectId
|
||||||
|
*/
|
||||||
|
public function cloneAction(Request $request, $objectId): Response
|
||||||
|
{
|
||||||
|
$this->throwAccessDenied();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,544 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
|
use Mautic\CategoryBundle\Entity\Category;
|
||||||
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
use Mautic\CoreBundle\Entity\FormEntity;
|
||||||
|
use Mautic\UserBundle\Entity\User;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallingWindow;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A call script: an HTML script with dynamic tokens like {contact.first_name}, the outcomes an agent
|
||||||
|
* can record, its calling window and its retry policy.
|
||||||
|
*
|
||||||
|
* It is a Mautic component (like an email or a landing page): its pages are linked from the
|
||||||
|
* Components menu. The script itself is stored as typed; resolving the tokens for a contact is the
|
||||||
|
* job of the call execution, which is not part of this entity.
|
||||||
|
*/
|
||||||
|
class CallScript extends FormEntity implements DateRangeInterface
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'mt3s_call_scripts';
|
||||||
|
|
||||||
|
public const NAME_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const TIMEZONE_MAX_LENGTH = 64;
|
||||||
|
|
||||||
|
public const RETRY_ATTEMPTS_MIN = 1;
|
||||||
|
|
||||||
|
public const RETRY_ATTEMPTS_MAX = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One week, in minutes.
|
||||||
|
*/
|
||||||
|
public const RETRY_DELAY_MAX = 10080;
|
||||||
|
|
||||||
|
public const RETRY_MAX_ATTEMPTS_DEFAULT = 3;
|
||||||
|
|
||||||
|
public const RETRY_DELAY_DEFAULT = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays of the calling window, in display order.
|
||||||
|
*/
|
||||||
|
public const WEEKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
||||||
|
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, CallScriptOutcome>
|
||||||
|
*/
|
||||||
|
private Collection $outcomes;
|
||||||
|
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
private ?string $description = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The script's validity window: the "start" date and time.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $publishUp = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The script's validity window: the "end" date and time.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $publishDown = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required in the form. The column is nullable only so that deleting the user doesn't delete the
|
||||||
|
* script (ON DELETE SET NULL).
|
||||||
|
*/
|
||||||
|
private ?User $owner = null;
|
||||||
|
|
||||||
|
private ?Category $category = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML with dynamic tokens like {contact.first_name}, kept as typed.
|
||||||
|
*/
|
||||||
|
private ?string $script = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays the calls may happen on, as ISO short names (mon..sun). Empty means every day.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private array $callingDays = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The calling window's hours, as times of day in the window's timezone.
|
||||||
|
*/
|
||||||
|
private ?\DateTime $callingFrom = null;
|
||||||
|
|
||||||
|
private ?\DateTime $callingTo = null;
|
||||||
|
|
||||||
|
private CallScriptTimezoneMode $callingTimezoneMode = CallScriptTimezoneMode::Contact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fixed timezone of the calling window, when its mode is "fixed".
|
||||||
|
*/
|
||||||
|
private ?string $callingTimezone = null;
|
||||||
|
|
||||||
|
private int $retryMaxAttempts = self::RETRY_MAX_ATTEMPTS_DEFAULT;
|
||||||
|
|
||||||
|
private int $retryDelayMinutes = self::RETRY_DELAY_DEFAULT;
|
||||||
|
|
||||||
|
private CallScriptRetryBackoff $retryBackoff = CallScriptRetryBackoff::None;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->outcomes = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
||||||
|
$builder->setTable(self::TABLE_NAME)
|
||||||
|
->setCustomRepositoryClass(CallScriptRepository::class);
|
||||||
|
|
||||||
|
$builder->addId();
|
||||||
|
|
||||||
|
$builder->createField('name', Types::STRING)
|
||||||
|
->length(self::NAME_MAX_LENGTH)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('description', Types::TEXT)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// The script's validity window: the "start" and "end" date and time in the form.
|
||||||
|
$builder->addPublishDates();
|
||||||
|
|
||||||
|
$builder->createManyToOne('owner', User::class)
|
||||||
|
->addJoinColumn('owner_id', 'id', true, false, 'SET NULL')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->addCategory();
|
||||||
|
|
||||||
|
// Types::TEXT is LONGTEXT on MySQL: the script keeps all its HTML.
|
||||||
|
$builder->createField('script', Types::TEXT)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// Mapped on the raw metadata, like the Smart Links arrays: ClassMetadataBuilder forces
|
||||||
|
// VARCHAR(191) on strings and doesn't accept JSON or enum types.
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingDays',
|
||||||
|
'columnName' => 'calling_days',
|
||||||
|
'type' => Types::JSON,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingFrom',
|
||||||
|
'columnName' => 'calling_from',
|
||||||
|
'type' => Types::TIME_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingTo',
|
||||||
|
'columnName' => 'calling_to',
|
||||||
|
'type' => Types::TIME_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'callingTimezoneMode',
|
||||||
|
'columnName' => 'calling_timezone_mode',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 10,
|
||||||
|
'enumType' => CallScriptTimezoneMode::class,
|
||||||
|
'options' => ['default' => CallScriptTimezoneMode::Contact->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createField('callingTimezone', Types::STRING)
|
||||||
|
->columnName('calling_timezone')
|
||||||
|
->length(self::TIMEZONE_MAX_LENGTH)
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('retryMaxAttempts', Types::INTEGER)
|
||||||
|
->columnName('retry_max_attempts')
|
||||||
|
->option('default', self::RETRY_MAX_ATTEMPTS_DEFAULT)
|
||||||
|
->option('unsigned', true)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('retryDelayMinutes', Types::INTEGER)
|
||||||
|
->columnName('retry_delay_minutes')
|
||||||
|
->option('default', self::RETRY_DELAY_DEFAULT)
|
||||||
|
->option('unsigned', true)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'retryBackoff',
|
||||||
|
'columnName' => 'retry_backoff',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => CallScriptRetryBackoff::class,
|
||||||
|
'options' => ['default' => CallScriptRetryBackoff::None->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createOneToMany('outcomes', CallScriptOutcome::class)
|
||||||
|
->mappedBy('callScript')
|
||||||
|
->setOrderBy(['position' => 'ASC'])
|
||||||
|
->cascadePersist()
|
||||||
|
->cascadeRemove()
|
||||||
|
->orphanRemoval()
|
||||||
|
->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
|
||||||
|
$metadata->addPropertyConstraint('name', new Length(max: self::NAME_MAX_LENGTH));
|
||||||
|
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mt3s.marketing_program.owner.required'));
|
||||||
|
$metadata->addPropertyConstraint('outcomes', new Valid());
|
||||||
|
$metadata->addPropertyConstraint('retryMaxAttempts', new Range(
|
||||||
|
notInRangeMessage: 'mt3s.call_script.retry_attempts.range',
|
||||||
|
min: self::RETRY_ATTEMPTS_MIN,
|
||||||
|
max: self::RETRY_ATTEMPTS_MAX,
|
||||||
|
));
|
||||||
|
$metadata->addPropertyConstraint('retryDelayMinutes', new Range(
|
||||||
|
notInRangeMessage: 'mt3s.call_script.retry_delay.range',
|
||||||
|
min: 0,
|
||||||
|
max: self::RETRY_DELAY_MAX,
|
||||||
|
));
|
||||||
|
// The validity window: the end must be on or after the start (the form's "end" field is publishDown).
|
||||||
|
$metadata->addConstraint(new EndDateAfterStartDate(atPath: 'publishDown'));
|
||||||
|
$metadata->addConstraint(new ValidCallingWindow());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The outcomes sorted by position, as a new collection (see Program::getObjectives()).
|
||||||
|
*
|
||||||
|
* @return Collection<int, CallScriptOutcome>
|
||||||
|
*/
|
||||||
|
public function getOutcomes(): Collection
|
||||||
|
{
|
||||||
|
$rows = $this->outcomes->toArray();
|
||||||
|
usort($rows, fn (CallScriptOutcome $a, CallScriptOutcome $b): int => $a->getPosition() <=> $b->getPosition());
|
||||||
|
|
||||||
|
return new ArrayCollection($rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOutcome(CallScriptOutcome $outcome): static
|
||||||
|
{
|
||||||
|
if (!$this->outcomes->contains($outcome)) {
|
||||||
|
$outcome->setCallScript($this);
|
||||||
|
$this->outcomes->add($outcome);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeOutcome(CallScriptOutcome $outcome): static
|
||||||
|
{
|
||||||
|
$this->outcomes->removeElement($outcome);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the outcome positions contiguous (0..n-1) in their current order, before saving.
|
||||||
|
*/
|
||||||
|
public function normalizePositions(): void
|
||||||
|
{
|
||||||
|
$rows = $this->outcomes->toArray();
|
||||||
|
usort($rows, fn (CallScriptOutcome $a, CallScriptOutcome $b): int => $a->getPosition() <=> $b->getPosition());
|
||||||
|
|
||||||
|
foreach ($rows as $index => $row) {
|
||||||
|
$row->setPosition($index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(?string $name): static
|
||||||
|
{
|
||||||
|
$this->isChanged('name', $name);
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription(): ?string
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription(?string $description): static
|
||||||
|
{
|
||||||
|
$this->isChanged('description', $description);
|
||||||
|
$this->description = $description;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPublishUp(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPublishUp(?\DateTime $publishUp): static
|
||||||
|
{
|
||||||
|
$this->isChanged('publishUp', $publishUp);
|
||||||
|
$this->publishUp = $publishUp;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPublishDown(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPublishDown(?\DateTime $publishDown): static
|
||||||
|
{
|
||||||
|
$this->isChanged('publishDown', $publishDown);
|
||||||
|
$this->publishDown = $publishDown;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DateRangeInterface: the script's validity window, for EndDateAfterStartDate.
|
||||||
|
*/
|
||||||
|
public function getStartDate(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->publishDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOwner(): ?User
|
||||||
|
{
|
||||||
|
return $this->owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOwner(?User $owner): static
|
||||||
|
{
|
||||||
|
$this->isChanged('owner', $owner);
|
||||||
|
$this->owner = $owner;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCategory(): ?Category
|
||||||
|
{
|
||||||
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategory(?Category $category): static
|
||||||
|
{
|
||||||
|
$this->isChanged('category', $category);
|
||||||
|
$this->category = $category;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScript(): ?string
|
||||||
|
{
|
||||||
|
return $this->script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setScript(?string $script): static
|
||||||
|
{
|
||||||
|
$this->isChanged('script', $script);
|
||||||
|
$this->script = $script;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getCallingDays(): array
|
||||||
|
{
|
||||||
|
return $this->callingDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string>|null $callingDays
|
||||||
|
*/
|
||||||
|
public function setCallingDays(?array $callingDays): static
|
||||||
|
{
|
||||||
|
$days = [];
|
||||||
|
foreach ($callingDays ?? [] as $day) {
|
||||||
|
$day = (string) $day;
|
||||||
|
if (in_array($day, self::WEEKDAYS, true) && !in_array($day, $days, true)) {
|
||||||
|
$days[] = $day;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('callingDays', $days);
|
||||||
|
$this->callingDays = $days;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingFrom(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->callingFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingFrom(?\DateTime $callingFrom): static
|
||||||
|
{
|
||||||
|
$this->isChanged('callingFrom', $callingFrom);
|
||||||
|
$this->callingFrom = $callingFrom;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTo(): ?\DateTime
|
||||||
|
{
|
||||||
|
return $this->callingTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingTo(?\DateTime $callingTo): static
|
||||||
|
{
|
||||||
|
$this->isChanged('callingTo', $callingTo);
|
||||||
|
$this->callingTo = $callingTo;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTimezoneMode(): CallScriptTimezoneMode
|
||||||
|
{
|
||||||
|
return $this->callingTimezoneMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a mode field missing from the submitted form) keeps the current mode, like the task kind.
|
||||||
|
*/
|
||||||
|
public function setCallingTimezoneMode(?CallScriptTimezoneMode $callingTimezoneMode): static
|
||||||
|
{
|
||||||
|
if (null === $callingTimezoneMode || $callingTimezoneMode === $this->callingTimezoneMode) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('callingTimezoneMode', [$this->callingTimezoneMode->value, $callingTimezoneMode->value]);
|
||||||
|
$this->callingTimezoneMode = $callingTimezoneMode;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallingTimezone(): ?string
|
||||||
|
{
|
||||||
|
return $this->callingTimezone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallingTimezone(?string $callingTimezone): static
|
||||||
|
{
|
||||||
|
if (null !== $callingTimezone && '' === trim($callingTimezone)) {
|
||||||
|
$callingTimezone = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('callingTimezone', $callingTimezone);
|
||||||
|
$this->callingTimezone = $callingTimezone;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryMaxAttempts(): int
|
||||||
|
{
|
||||||
|
return $this->retryMaxAttempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (an attempts field missing from the submitted form) keeps the current value.
|
||||||
|
*/
|
||||||
|
public function setRetryMaxAttempts(?int $retryMaxAttempts): static
|
||||||
|
{
|
||||||
|
if (null === $retryMaxAttempts || $retryMaxAttempts === $this->retryMaxAttempts) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('retryMaxAttempts', $retryMaxAttempts);
|
||||||
|
$this->retryMaxAttempts = $retryMaxAttempts;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryDelayMinutes(): int
|
||||||
|
{
|
||||||
|
return $this->retryDelayMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a delay field missing from the submitted form) keeps the current value.
|
||||||
|
*/
|
||||||
|
public function setRetryDelayMinutes(?int $retryDelayMinutes): static
|
||||||
|
{
|
||||||
|
if (null === $retryDelayMinutes || $retryDelayMinutes === $this->retryDelayMinutes) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->isChanged('retryDelayMinutes', $retryDelayMinutes);
|
||||||
|
$this->retryDelayMinutes = $retryDelayMinutes;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRetryBackoff(): CallScriptRetryBackoff
|
||||||
|
{
|
||||||
|
return $this->retryBackoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a backoff field missing from the submitted form) keeps the current policy.
|
||||||
|
*/
|
||||||
|
public function setRetryBackoff(?CallScriptRetryBackoff $retryBackoff): static
|
||||||
|
{
|
||||||
|
if (null === $retryBackoff || $retryBackoff === $this->retryBackoff) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('retryBackoff', [$this->retryBackoff->value, $retryBackoff->value]);
|
||||||
|
$this->retryBackoff = $retryBackoff;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallScriptOutcomeOptions;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One outcome of a call script: what the agent records after the call.
|
||||||
|
*
|
||||||
|
* CallScript::$outcomes owns the lifecycle: outcomes are saved and deleted with their script, and are
|
||||||
|
* ordered by position. The options are stored as a list of {value, label} rows; they are required for
|
||||||
|
* the checkbox, radio and dropdown types, and forbidden for free text.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcome
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'mt3s_call_script_outcomes';
|
||||||
|
|
||||||
|
public const LABEL_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const VALUE_MAX_LENGTH = 191;
|
||||||
|
|
||||||
|
public const OPTIONS_MAX = 100;
|
||||||
|
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
private ?CallScript $callScript = null;
|
||||||
|
|
||||||
|
private ?string $label = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defaults to free text: a new outcome is valid without options.
|
||||||
|
*/
|
||||||
|
private CallScriptOutcomeInputType $inputType = CallScriptOutcomeInputType::FreeText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The choices of a checkbox, radio or dropdown outcome, as a list of {value, label} rows.
|
||||||
|
*
|
||||||
|
* @var list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
private array $options = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display order within the script, from 0. Set by drag and drop in the form.
|
||||||
|
*/
|
||||||
|
private int $position = 0;
|
||||||
|
|
||||||
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
||||||
|
$builder->setTable(self::TABLE_NAME);
|
||||||
|
|
||||||
|
$builder->addId();
|
||||||
|
|
||||||
|
$builder->createManyToOne('callScript', CallScript::class)
|
||||||
|
->inversedBy('outcomes')
|
||||||
|
->addJoinColumn('call_script_id', 'id', false, false, 'CASCADE')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('label', Types::STRING)
|
||||||
|
->length(self::LABEL_MAX_LENGTH)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// Mapped on the raw metadata: ClassMetadataBuilder forces VARCHAR(191) on strings and
|
||||||
|
// doesn't accept enum or JSON types.
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'inputType',
|
||||||
|
'columnName' => 'input_type',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => CallScriptOutcomeInputType::class,
|
||||||
|
'options' => ['default' => CallScriptOutcomeInputType::FreeText->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'options',
|
||||||
|
'columnName' => 'options',
|
||||||
|
'type' => Types::JSON,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createField('position', Types::INTEGER)
|
||||||
|
->option('default', 0)
|
||||||
|
->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('label', new NotBlank(message: 'mt3s.call_script.outcome.label.required'));
|
||||||
|
$metadata->addPropertyConstraint('label', new Length(max: self::LABEL_MAX_LENGTH));
|
||||||
|
$metadata->addConstraint(new ValidCallScriptOutcomeOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCallScript(): ?CallScript
|
||||||
|
{
|
||||||
|
return $this->callScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCallScript(?CallScript $callScript): static
|
||||||
|
{
|
||||||
|
$this->callScript = $callScript;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabel(): ?string
|
||||||
|
{
|
||||||
|
return $this->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLabel(?string $label): static
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInputType(): CallScriptOutcomeInputType
|
||||||
|
{
|
||||||
|
return $this->inputType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null (a type field missing from the submitted form) keeps the current type.
|
||||||
|
*/
|
||||||
|
public function setInputType(?CallScriptOutcomeInputType $inputType): static
|
||||||
|
{
|
||||||
|
if (null !== $inputType) {
|
||||||
|
$this->inputType = $inputType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasOptions(): bool
|
||||||
|
{
|
||||||
|
return $this->inputType->hasOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
public function getOptions(): array
|
||||||
|
{
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the {value, label} rows of the submitted options, dropping the empty ones and
|
||||||
|
* defaulting an empty label to the value.
|
||||||
|
*
|
||||||
|
* @param list<array{value?: string, label?: string}>|array<int, mixed>|null $options
|
||||||
|
*/
|
||||||
|
public function setOptions(?array $options): static
|
||||||
|
{
|
||||||
|
$clean = [];
|
||||||
|
foreach (array_slice($options ?? [], 0, self::OPTIONS_MAX) as $option) {
|
||||||
|
if (!is_array($option)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = trim((string) ($option['value'] ?? ''));
|
||||||
|
$label = trim((string) ($option['label'] ?? ''));
|
||||||
|
|
||||||
|
if ('' === $value && '' === $label) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clean[] = ['value' => $value, 'label' => '' !== $label ? $label : $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->options = $clean;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPosition(): int
|
||||||
|
{
|
||||||
|
return $this->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPosition(?int $position): static
|
||||||
|
{
|
||||||
|
$this->position = $position ?? 0;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data type of a call script outcome: the agent records it with checkboxes, radio buttons,
|
||||||
|
* free text or a drop-down.
|
||||||
|
*/
|
||||||
|
enum CallScriptOutcomeInputType: string
|
||||||
|
{
|
||||||
|
case Checkbox = 'checkbox';
|
||||||
|
case Radio = 'radio';
|
||||||
|
case FreeText = 'free_text';
|
||||||
|
case Dropdown = 'dropdown';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.outcome_type.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True when the user records the outcome by choosing among configured options.
|
||||||
|
*/
|
||||||
|
public function hasOptions(): bool
|
||||||
|
{
|
||||||
|
return self::FreeText !== $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends CommonRepository<CallScript>
|
||||||
|
*/
|
||||||
|
class CallScriptRepository extends CommonRepository
|
||||||
|
{
|
||||||
|
public function getTableAlias(): string
|
||||||
|
{
|
||||||
|
return 'cs';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the owner and category with the scripts, so that the list doesn't query them one by one.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $args
|
||||||
|
*/
|
||||||
|
public function getEntities(array $args = [])
|
||||||
|
{
|
||||||
|
$alias = $this->getTableAlias();
|
||||||
|
|
||||||
|
$args['qb'] = $this->createQueryBuilder($alias)
|
||||||
|
->select($alias, 'o', 'c')
|
||||||
|
->leftJoin($alias.'.owner', 'o')
|
||||||
|
->leftJoin($alias.'.category', 'c');
|
||||||
|
|
||||||
|
return parent::getEntities($args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list's search box matches the name.
|
||||||
|
*
|
||||||
|
* @return array<int, mixed>
|
||||||
|
*/
|
||||||
|
protected function addCatchAllWhereClause($q, $filter): array
|
||||||
|
{
|
||||||
|
return $this->addStandardCatchAllWhereClause($q, $filter, [
|
||||||
|
$this->getTableAlias().'.name',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<array{0: string, 1: string}>
|
||||||
|
*/
|
||||||
|
protected function getDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[$this->getTableAlias().'.name', 'ASC'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How the delay between two call attempts grows: not at all, by a constant step, or exponentially.
|
||||||
|
*
|
||||||
|
* - none: every retry waits the same delay.
|
||||||
|
* - linear: attempt n waits delay * n.
|
||||||
|
* - exponential: attempt n waits delay * 2^(n-1).
|
||||||
|
*/
|
||||||
|
enum CallScriptRetryBackoff: string
|
||||||
|
{
|
||||||
|
case None = 'none';
|
||||||
|
case Linear = 'linear';
|
||||||
|
case Exponential = 'exponential';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.retry_backoff.'.$this->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How the calling window's hours are read: in the contact's timezone, or in one fixed timezone.
|
||||||
|
*/
|
||||||
|
enum CallScriptTimezoneMode: string
|
||||||
|
{
|
||||||
|
case Contact = 'contact';
|
||||||
|
case Fixed = 'fixed';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mt3s.call_script.timezone_mode.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isFixed(): bool
|
||||||
|
{
|
||||||
|
return self::Fixed === $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One {value, label} row of a call script outcome's options. The rows are stored as a JSON list on
|
||||||
|
* CallScriptOutcome::$options.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcomeOptionType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('value', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome_option.field.value',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => 191],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('label', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome_option.field.label',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => 191],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script_outcome_option';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcomeInputType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One row of the outcomes collection in CallScriptType: the outcome's label, the data type the agent
|
||||||
|
* records it with (checkbox, radio, free text or dropdown), and the options of the choice types.
|
||||||
|
* Adding, removing and reordering is handled by Assets/js/mt3s-mp-program.js.
|
||||||
|
*/
|
||||||
|
class CallScriptOutcomeType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('label', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome.field.label',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => CallScriptOutcome::LABEL_MAX_LENGTH],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('inputType', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.outcome.field.type',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control program-outcome-type'],
|
||||||
|
'class' => CallScriptOutcomeInputType::class,
|
||||||
|
'choice_label' => fn (CallScriptOutcomeInputType $type): string => $type->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The choices of a checkbox, radio or dropdown outcome; hidden by the JS for free text.
|
||||||
|
$builder->add('options', CollectionType::class, [
|
||||||
|
'label' => false,
|
||||||
|
'entry_type' => CallScriptOutcomeOptionType::class,
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__option__',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The row's order in the collection, rewritten by mt3s-mp-program.js after each change.
|
||||||
|
$builder->add('position', HiddenType::class, [
|
||||||
|
'attr' => ['class' => 'program-row-position'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CallScriptOutcome::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script_outcome';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Form\Type;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Mautic\CategoryBundle\Form\Type\CategoryListType;
|
||||||
|
use Mautic\CoreBundle\Form\DataTransformer\IdToEntityModelTransformer;
|
||||||
|
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
|
||||||
|
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\PublishDownDateType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\PublishUpDateType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\TimezoneType;
|
||||||
|
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
|
||||||
|
use Mautic\UserBundle\Entity\User;
|
||||||
|
use Mautic\UserBundle\Form\Type\UserListType;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptRetryBackoff;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptTimezoneMode;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TimeType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The create and edit form of a call script (Components > Call Scripts).
|
||||||
|
*
|
||||||
|
* The script keeps the HTML typed in it (the "html" cleaning mask), including the dynamic tokens like
|
||||||
|
* {contact.first_name}. The outcomes are edited as a sortable collection (see Assets/js/mt3s-mp-program.js);
|
||||||
|
* the options of an outcome are shown only for the checkbox, radio and dropdown types.
|
||||||
|
*/
|
||||||
|
class CallScriptType extends AbstractType
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private EntityManagerInterface $em,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
// Pass a mask array, never nothing: without one, core applies its "clean" mask (HTML-encodes &, <, >,
|
||||||
|
// quotes). "html" keeps the script markup; "clean" strips the rest of the fields.
|
||||||
|
$builder->addEventSubscriber(new CleanFormSubscriber([
|
||||||
|
'name' => 'clean',
|
||||||
|
'description' => 'clean',
|
||||||
|
'script' => 'html',
|
||||||
|
]));
|
||||||
|
|
||||||
|
$builder->add('name', TextType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.name',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'maxlength' => CallScript::NAME_MAX_LENGTH],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('description', TextareaType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.description',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'rows' => 2],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('script', TextareaType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.script',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'rows' => 14,
|
||||||
|
'style' => 'font-family: monospace;',
|
||||||
|
'tooltip' => 'mt3s.call_script.field.script.help',
|
||||||
|
],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Required here; the column is nullable only because of onDelete SET NULL.
|
||||||
|
$builder->add(
|
||||||
|
$builder->create('owner', UserListType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.owner',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => true,
|
||||||
|
'multiple' => false,
|
||||||
|
])->addModelTransformer(new IdToEntityModelTransformer($this->em, User::class))
|
||||||
|
);
|
||||||
|
|
||||||
|
$builder->add('category', CategoryListType::class, [
|
||||||
|
'bundle' => 'call_script',
|
||||||
|
'label' => 'mt3s.call_script.field.category',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('isPublished', YesNoButtonGroupType::class, [
|
||||||
|
'label' => 'mautic.core.form.available',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The validity window: "start" and "end" date and time.
|
||||||
|
$builder->add('publishUp', PublishUpDateType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.start',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('publishDown', PublishDownDateType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.end',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Calling window: the weekdays, the hours and the timezone the hours are read in.
|
||||||
|
$builder->add('callingDays', ChoiceType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_days',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'choices' => $this->weekdayChoices(),
|
||||||
|
'choice_translation_domain' => true,
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingFrom', TimeType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_from',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => false,
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTo', TimeType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_to',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => false,
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTimezoneMode', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_timezone_mode',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => CallScriptTimezoneMode::class,
|
||||||
|
'choice_label' => fn (CallScriptTimezoneMode $mode): string => $mode->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('callingTimezone', TimezoneType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.calling_timezone',
|
||||||
|
'placeholder' => '',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Retry policy: how many times, how long between attempts, and how the delay grows.
|
||||||
|
$builder->add('retryMaxAttempts', IntegerType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_max_attempts',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'min' => CallScript::RETRY_ATTEMPTS_MIN,
|
||||||
|
'max' => CallScript::RETRY_ATTEMPTS_MAX,
|
||||||
|
'step' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('retryDelayMinutes', IntegerType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_delay_minutes',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => [
|
||||||
|
'class' => 'form-control',
|
||||||
|
'min' => 0,
|
||||||
|
'max' => CallScript::RETRY_DELAY_MAX,
|
||||||
|
'step' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('retryBackoff', EnumType::class, [
|
||||||
|
'label' => 'mt3s.call_script.field.retry_backoff',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => CallScriptRetryBackoff::class,
|
||||||
|
'choice_label' => fn (CallScriptRetryBackoff $backoff): string => $backoff->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Outcomes: the list of things the agent can record, each with its data type and options.
|
||||||
|
$builder->add('outcomes', CollectionType::class, [
|
||||||
|
'label' => false,
|
||||||
|
'entry_type' => CallScriptOutcomeType::class,
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__outcome__',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('buttons', FormButtonsType::class);
|
||||||
|
|
||||||
|
if (!empty($options['action'])) {
|
||||||
|
$builder->setAction($options['action']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weekdays of the calling window: translation key => ISO short name.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function weekdayChoices(): array
|
||||||
|
{
|
||||||
|
$choices = [];
|
||||||
|
foreach (CallScript::WEEKDAYS as $day) {
|
||||||
|
$choices['mt3s.call_script.day.'.$day] = $day;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $choices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => CallScript::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'mt3s_call_script';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the Call Script component's tables (mt3s_call_scripts and mt3s_call_script_outcomes) for
|
||||||
|
* installs created before 0.19.0.
|
||||||
|
*
|
||||||
|
* As in Version_0_2_0, the plugin installer drops the foreign keys that point to core tables
|
||||||
|
* (users, categories), so they are re-added here with ON DELETE SET NULL. The outcomes table gets
|
||||||
|
* its ON DELETE CASCADE key to the scripts. Every step runs only if needed.
|
||||||
|
*
|
||||||
|
* The statements run immediately through the connection instead of addSql(): the engine executes
|
||||||
|
* addSql() statements only after up() returns, and the schema must be re-read between steps.
|
||||||
|
*/
|
||||||
|
class Version_0_19_0 extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Local table (unprefixed) => local column, referenced table, ON DELETE clause.
|
||||||
|
*/
|
||||||
|
private const FOREIGN_KEYS = [
|
||||||
|
['mt3s_call_scripts', 'owner_id', 'users', 'ON DELETE SET NULL'],
|
||||||
|
['mt3s_call_scripts', 'category_id', 'categories', 'ON DELETE SET NULL'],
|
||||||
|
['mt3s_call_script_outcomes', 'call_script_id', 'mt3s_call_scripts', 'ON DELETE CASCADE'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function isApplicable(Schema $schema): bool
|
||||||
|
{
|
||||||
|
return null !== $this->getCreateTableSql($schema)
|
||||||
|
|| [] !== $this->getMissingForeignKeys($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function up(): void
|
||||||
|
{
|
||||||
|
$connection = $this->entityManager->getConnection();
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScript::TABLE_NAME))) {
|
||||||
|
$connection->executeStatement($this->buildCreateTableSql(CallScript::class, CallScript::TABLE_NAME));
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScriptOutcome::TABLE_NAME))) {
|
||||||
|
$connection->executeStatement($this->buildCreateTableSql(CallScriptOutcome::class, CallScriptOutcome::TABLE_NAME));
|
||||||
|
$schema = $this->introspectSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->getMissingForeignKeys($schema) as [$table, $column, $referenceTable, $onDelete]) {
|
||||||
|
$connection->executeStatement($this->generateAlterTableForeignKeyStatement(
|
||||||
|
$table,
|
||||||
|
[$column],
|
||||||
|
$referenceTable,
|
||||||
|
['id'],
|
||||||
|
$onDelete
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The missing CREATE TABLE statement, or null when both tables already exist.
|
||||||
|
*/
|
||||||
|
private function getCreateTableSql(Schema $schema): ?string
|
||||||
|
{
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScript::TABLE_NAME))) {
|
||||||
|
return 'mt3s_call_scripts';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$schema->hasTable($this->concatPrefix(CallScriptOutcome::TABLE_NAME))) {
|
||||||
|
return 'mt3s_call_script_outcomes';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{0: string, 1: string, 2: string, 3: string}>
|
||||||
|
*/
|
||||||
|
private function getMissingForeignKeys(Schema $schema): array
|
||||||
|
{
|
||||||
|
$missing = [];
|
||||||
|
|
||||||
|
foreach (self::FOREIGN_KEYS as $foreignKey) {
|
||||||
|
[$table, $column] = $foreignKey;
|
||||||
|
$prefixed = $this->concatPrefix($table);
|
||||||
|
|
||||||
|
// The tables may not exist yet; up() adds their keys after creating them.
|
||||||
|
if (!$schema->hasTable($prefixed)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = false;
|
||||||
|
foreach ($schema->getTable($prefixed)->getForeignKeys() as $existing) {
|
||||||
|
if (in_array($column, $existing->getLocalColumns(), true)) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$found) {
|
||||||
|
$missing[] = $foreignKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param class-string $entityClass
|
||||||
|
*/
|
||||||
|
private function buildCreateTableSql(string $entityClass, string $table): string
|
||||||
|
{
|
||||||
|
$schemaTool = new SchemaTool($this->entityManager);
|
||||||
|
$prefix = 'CREATE TABLE '.$this->concatPrefix($table).' ';
|
||||||
|
|
||||||
|
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata($entityClass)]) as $sql) {
|
||||||
|
if (str_starts_with($sql, $prefix)) {
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.$table.'.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function introspectSchema(): Schema
|
||||||
|
{
|
||||||
|
return $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Model\FormModel;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptRepository;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\CallScriptType;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available as mautic.mt3smarketingprogram.model.call_script, or
|
||||||
|
* getModel('mt3smarketingprogram.call_script').
|
||||||
|
*
|
||||||
|
* @extends FormModel<CallScript>
|
||||||
|
*/
|
||||||
|
class CallScriptModel extends FormModel
|
||||||
|
{
|
||||||
|
public function getRepository(): CallScriptRepository
|
||||||
|
{
|
||||||
|
$repository = $this->em->getRepository(CallScript::class);
|
||||||
|
\assert($repository instanceof CallScriptRepository);
|
||||||
|
|
||||||
|
return $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPermissionBase(): string
|
||||||
|
{
|
||||||
|
return 'mt3smarketingprogram:call_scripts';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With no ID, returns a new script with the current user as owner.
|
||||||
|
*/
|
||||||
|
public function getEntity($id = null): ?CallScript
|
||||||
|
{
|
||||||
|
if (null === $id) {
|
||||||
|
$callScript = new CallScript();
|
||||||
|
$callScript->setOwner($this->userHelper->getUser(true));
|
||||||
|
|
||||||
|
return $callScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callScript = parent::getEntity($id);
|
||||||
|
|
||||||
|
return $callScript instanceof CallScript ? $callScript : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the outcome positions contiguous (0..n-1) before saving.
|
||||||
|
*/
|
||||||
|
public function saveEntity($entity, $unlock = true): void
|
||||||
|
{
|
||||||
|
if ($entity instanceof CallScript) {
|
||||||
|
$entity->normalizePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::saveEntity($entity, $unlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $options
|
||||||
|
*/
|
||||||
|
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
|
||||||
|
{
|
||||||
|
if (!$entity instanceof CallScript) {
|
||||||
|
throw new MethodNotAllowedHttpException(['CallScript']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($action)) {
|
||||||
|
$options['action'] = $action;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $formFactory->create(CallScriptType::class, $entity, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
{% extends '@MauticCore/Default/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block mauticContent %}mt3sMpCallScript{% endblock %}
|
||||||
|
|
||||||
|
{% block headerTitle %}
|
||||||
|
{% if form.vars.data.id %}
|
||||||
|
{{ 'mt3s.call_script.header.edit'|trans({'%name%': form.vars.data.name}) }}
|
||||||
|
{% else %}
|
||||||
|
{{ 'mt3s.call_script.header.new'|trans }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{# One {value, label} option of an outcome's choices. #}
|
||||||
|
{% macro option_row(option) %}
|
||||||
|
<li class="program-collection-row list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-5">{{ form_row(option.value) }}</div>
|
||||||
|
<div class="col-md-5">{{ form_row(option.label) }}</div>
|
||||||
|
<div class="col-md-2 text-right">
|
||||||
|
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.call_script.outcome.options.remove'|trans }}">
|
||||||
|
<i class="ri-delete-bin-line"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{# One outcome: its label, the data type the agent records it with, and the options of the choice types.
|
||||||
|
Adding, removing and reordering is handled by Assets/js/mt3s-mp-program.js through the
|
||||||
|
program-collection-* classes (the options are a nested collection of the same kind). #}
|
||||||
|
{% macro outcome_row(outcome) %}
|
||||||
|
<li class="program-collection-row list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-1 text-center">
|
||||||
|
<span class="program-collection-handle text-muted" title="{{ 'mt3s.call_script.outcome.drag'|trans }}" style="cursor: move;">
|
||||||
|
<i class="ri-draggable ri-lg"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">{{ form_row(outcome.label) }}</div>
|
||||||
|
<div class="col-md-6">{{ form_row(outcome.inputType) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="program-outcome-options">
|
||||||
|
<h5>{{ 'mt3s.call_script.outcome.options'|trans }}</h5>
|
||||||
|
<div class="program-collection program-outcome-option-collection"
|
||||||
|
data-prototype="{{ _self.option_row(outcome.options.vars.prototype)|e('html_attr') }}"
|
||||||
|
data-prototype-name="__option__">
|
||||||
|
<p class="text-muted program-collection-empty{% if outcome.options|length > 0 %} hide{% endif %}">
|
||||||
|
{{ 'mt3s.call_script.outcome.options.empty'|trans }}
|
||||||
|
</p>
|
||||||
|
<ul class="list-group program-collection-list">
|
||||||
|
{% for option in outcome.options %}
|
||||||
|
{{ _self.option_row(option) }}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-add">
|
||||||
|
<i class="ri-add-line"></i> {{ 'mt3s.call_script.outcome.options.add'|trans }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_widget(outcome.position) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-1 text-right">
|
||||||
|
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.call_script.outcome.remove'|trans }}">
|
||||||
|
<i class="ri-delete-bin-line"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ form_start(form) }}
|
||||||
|
<div class="box-layout">
|
||||||
|
<div class="col-md-9 height-auto bdr-r">
|
||||||
|
<div class="pa-md">
|
||||||
|
{{ form_row(form.name) }}
|
||||||
|
{{ form_row(form.description) }}
|
||||||
|
{{ form_row(form.script) }}
|
||||||
|
</div>
|
||||||
|
<div class="pa-md">
|
||||||
|
<h4 class="mt-lg mb-sm">{{ 'mt3s.call_script.outcome.list'|trans }}</h4>
|
||||||
|
<div class="program-collection program-call-script-outcomes"
|
||||||
|
data-prototype="{{ _self.outcome_row(form.outcomes.vars.prototype)|e('html_attr') }}"
|
||||||
|
data-prototype-name="__outcome__">
|
||||||
|
{{ form_errors(form.outcomes) }}
|
||||||
|
<p class="text-muted program-collection-empty{% if form.outcomes|length > 0 %} hide{% endif %}">
|
||||||
|
{{ 'mt3s.call_script.outcome.empty'|trans }}
|
||||||
|
</p>
|
||||||
|
<ul class="list-group program-collection-list">
|
||||||
|
{% for outcome in form.outcomes %}
|
||||||
|
{{ _self.outcome_row(outcome) }}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
|
||||||
|
<i class="ri-add-line"></i> {{ 'mt3s.call_script.outcome.add'|trans }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% do form.outcomes.setRendered %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 height-auto">
|
||||||
|
<div class="pr-lg pl-lg pt-md pb-md">
|
||||||
|
{{ form_row(form.owner) }}
|
||||||
|
{{ form_row(form.category) }}
|
||||||
|
{{ form_row(form.isPublished) }}
|
||||||
|
{{ form_row(form.publishUp) }}
|
||||||
|
{{ form_row(form.publishDown) }}
|
||||||
|
|
||||||
|
<h4>{{ 'mt3s.call_script.section.calling_window'|trans }}</h4>
|
||||||
|
{{ form_row(form.callingDays) }}
|
||||||
|
{{ form_row(form.callingFrom) }}
|
||||||
|
{{ form_row(form.callingTo) }}
|
||||||
|
{{ form_row(form.callingTimezoneMode) }}
|
||||||
|
{{ form_row(form.callingTimezone) }}
|
||||||
|
|
||||||
|
<h4>{{ 'mt3s.call_script.section.retry_policy'|trans }}</h4>
|
||||||
|
{{ form_row(form.retryMaxAttempts) }}
|
||||||
|
{{ form_row(form.retryDelayMinutes) }}
|
||||||
|
{{ form_row(form.retryBackoff) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_row(form.buttons) }}
|
||||||
|
{# render_rest is false, so the hidden CSRF token must be rendered explicitly. #}
|
||||||
|
{{ form_widget(form._token) }}
|
||||||
|
{{ form_end(form, {'render_rest': false}) }}
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
{% set isIndex = 'index' == tmpl|default('index') ? true : false %}
|
||||||
|
{% set tmpl = 'list' %}
|
||||||
|
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
|
||||||
|
|
||||||
|
{% block mauticContent %}mt3sMpCallScript{% endblock %}
|
||||||
|
|
||||||
|
{% block headerTitle %}{{ 'mt3s.call_script.header.index'|trans }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="page-list-wrapper" class="{% if items|length > 0 or searchValue is not empty %}panel {% endif %}panel-default">
|
||||||
|
{# The toolbar belongs to the full page only: ajax reloads (sort, filter, pagination)
|
||||||
|
replace the contents of .page-list, so including it here again would duplicate it. #}
|
||||||
|
{% if isIndex %}
|
||||||
|
{{- include('@MauticCore/Helper/list_toolbar.html.twig', {
|
||||||
|
'searchValue': searchValue,
|
||||||
|
'action': currentRoute,
|
||||||
|
'page_actions': {
|
||||||
|
'templateButtons': {
|
||||||
|
'new': permissions[permissionBase ~ ':create'],
|
||||||
|
},
|
||||||
|
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||||
|
'routeBase': 'call_scripts',
|
||||||
|
},
|
||||||
|
'bulk_actions': {
|
||||||
|
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||||
|
'templateButtons': {
|
||||||
|
'delete': permissions[permissionBase ~ ':deleteown'] or permissions[permissionBase ~ ':deleteother'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}) -}}
|
||||||
|
{% endif %}
|
||||||
|
<div class="page-list">
|
||||||
|
{% if items is defined and items is not empty %}
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover" id="callScriptTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'checkall': 'true',
|
||||||
|
'target': '#callScriptTable',
|
||||||
|
}) }}
|
||||||
|
{# Columns: Name, Category, Status, Owner, Modified. #}
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
'orderBy': tablePrefix ~ '.name',
|
||||||
|
'text': 'mt3s.call_script.field.name',
|
||||||
|
'class': 'col-call-script-name',
|
||||||
|
'default': true,
|
||||||
|
}) }}
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
'text': 'mt3s.call_script.list.category',
|
||||||
|
'class': 'visible-md visible-lg col-call-script-category',
|
||||||
|
}) }}
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
'orderBy': tablePrefix ~ '.isPublished',
|
||||||
|
'text': 'mt3s.call_script.list.status',
|
||||||
|
'class': 'col-call-script-status',
|
||||||
|
}) }}
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
'text': 'mt3s.call_script.list.owner',
|
||||||
|
'class': 'visible-md visible-lg col-call-script-owner',
|
||||||
|
}) }}
|
||||||
|
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
'orderBy': tablePrefix ~ '.dateModified',
|
||||||
|
'text': 'mt3s.call_script.list.modified',
|
||||||
|
'class': 'visible-md visible-lg col-call-script-date',
|
||||||
|
}) }}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in items %}
|
||||||
|
{% set canEdit = securityHasEntityAccess(permissions[permissionBase ~ ':editown'], permissions[permissionBase ~ ':editother'], item.createdBy) %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{- include('@MauticCore/Helper/list_actions.html.twig', {
|
||||||
|
'item': item,
|
||||||
|
'templateButtons': {
|
||||||
|
'edit': canEdit,
|
||||||
|
'delete': securityHasEntityAccess(permissions[permissionBase ~ ':deleteown'], permissions[permissionBase ~ ':deleteother'], item.createdBy),
|
||||||
|
},
|
||||||
|
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||||
|
'routeBase': 'call_scripts',
|
||||||
|
}) -}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if canEdit %}
|
||||||
|
<a href="{{ path(actionRoute, {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{{ item.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
{{ item.name }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="visible-md visible-lg">{{ item.category.name|default('—') }}</td>
|
||||||
|
<td>
|
||||||
|
{% if item.isPublished %}
|
||||||
|
<span class="label label-success"{% if item.publishUp or item.publishDown %} title="{{ item.publishUp ? item.publishUp|date('Y-m-d H:i') : '' }} → {{ item.publishDown ? item.publishDown|date('Y-m-d H:i') : '' }}"{% endif %}>{{ 'mt3s.call_script.list.published'|trans }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="label label-default">{{ 'mt3s.call_script.list.unpublished'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="visible-md visible-lg">{{ item.owner.name|default('—') }}</td>
|
||||||
|
<td class="visible-md visible-lg">{{ item.dateModified ? dateToFull(item.dateModified) : '—' }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="panel-footer">
|
||||||
|
{{- include('@MauticCore/Helper/pagination.html.twig', {
|
||||||
|
'totalItems': totalItems,
|
||||||
|
'page': page,
|
||||||
|
'limit': limit,
|
||||||
|
'baseUrl': path(indexRoute),
|
||||||
|
'sessionVar': sessionVar,
|
||||||
|
}) -}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% elseif searchValue is not empty %}
|
||||||
|
{{ include('@MauticCore/Helper/noresults.html.twig') }}
|
||||||
|
{% else %}
|
||||||
|
<div class="mt-80 col-md-offset-2 col-lg-offset-3 col-md-8 col-lg-5 height-auto">
|
||||||
|
{{ include('@MauticCore/Components/content-block.html.twig', {
|
||||||
|
'heading': 'mt3s.call_script.onboarding.heading',
|
||||||
|
'subheading': 'mt3s.call_script.onboarding.subheading',
|
||||||
|
'copy': 'mt3s.call_script.onboarding.copy',
|
||||||
|
}) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -31,6 +31,7 @@ class MT3SMarketingProgramPermissions extends AbstractPermissions
|
|||||||
$this->addExtendedPermissions(['audiences']);
|
$this->addExtendedPermissions(['audiences']);
|
||||||
$this->addExtendedPermissions(['smart_links']);
|
$this->addExtendedPermissions(['smart_links']);
|
||||||
$this->addExtendedPermissions(['taxonomies']);
|
$this->addExtendedPermissions(['taxonomies']);
|
||||||
|
$this->addExtendedPermissions(['call_scripts']);
|
||||||
$this->addStandardPermissions(['itemtypes']);
|
$this->addStandardPermissions(['itemtypes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ class MT3SMarketingProgramPermissions extends AbstractPermissions
|
|||||||
$this->addExtendedFormFields('mt3smarketingprogram', 'audiences', $builder, $data);
|
$this->addExtendedFormFields('mt3smarketingprogram', 'audiences', $builder, $data);
|
||||||
$this->addExtendedFormFields('mt3smarketingprogram', 'smart_links', $builder, $data);
|
$this->addExtendedFormFields('mt3smarketingprogram', 'smart_links', $builder, $data);
|
||||||
$this->addExtendedFormFields('mt3smarketingprogram', 'taxonomies', $builder, $data);
|
$this->addExtendedFormFields('mt3smarketingprogram', 'taxonomies', $builder, $data);
|
||||||
|
$this->addExtendedFormFields('mt3smarketingprogram', 'call_scripts', $builder, $data);
|
||||||
$this->addStandardFormFields('mt3smarketingprogram', 'itemtypes', $builder, $data);
|
$this->addStandardFormFields('mt3smarketingprogram', 'itemtypes', $builder, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Entity;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcomeInputType;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptRetryBackoff;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptTimezoneMode;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
final class CallScriptTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testNewScriptDefaults(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
|
||||||
|
self::assertSame(CallScriptTimezoneMode::Contact, $script->getCallingTimezoneMode());
|
||||||
|
self::assertSame(3, $script->getRetryMaxAttempts());
|
||||||
|
self::assertSame(30, $script->getRetryDelayMinutes());
|
||||||
|
self::assertSame(CallScriptRetryBackoff::None, $script->getRetryBackoff());
|
||||||
|
self::assertSame([], $script->getCallingDays());
|
||||||
|
self::assertCount(0, $script->getOutcomes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCallingDaysAreFilteredAndDeduplicated(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
|
||||||
|
$script->setCallingDays(['mon', 'mon', 'xxx', 'fri']);
|
||||||
|
|
||||||
|
self::assertSame(['mon', 'fri'], $script->getCallingDays());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNormalizePositionsRenumbersTheOutcomes(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$first = (new CallScriptOutcome())->setLabel('First')->setPosition(7);
|
||||||
|
$second = (new CallScriptOutcome())->setLabel('Second')->setPosition(2);
|
||||||
|
$script->addOutcome($first);
|
||||||
|
$script->addOutcome($second);
|
||||||
|
|
||||||
|
$script->normalizePositions();
|
||||||
|
|
||||||
|
self::assertSame(0, $second->getPosition());
|
||||||
|
self::assertSame(1, $first->getPosition());
|
||||||
|
self::assertSame(['Second', 'First'], array_map(fn (CallScriptOutcome $o): ?string => $o->getLabel(), $script->getOutcomes()->toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOutcomeOptionsAreSanitized(): void
|
||||||
|
{
|
||||||
|
$outcome = new CallScriptOutcome();
|
||||||
|
|
||||||
|
$outcome->setOptions([
|
||||||
|
['value' => 'yes', 'label' => 'Yes'],
|
||||||
|
['value' => '', 'label' => ''],
|
||||||
|
['value' => 'maybe', 'label' => ''],
|
||||||
|
]);
|
||||||
|
|
||||||
|
self::assertSame([
|
||||||
|
['value' => 'yes', 'label' => 'Yes'],
|
||||||
|
['value' => 'maybe', 'label' => 'maybe'],
|
||||||
|
], $outcome->getOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNullEnumsAndNumbersKeepTheCurrentValues(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingTimezoneMode(CallScriptTimezoneMode::Fixed);
|
||||||
|
$script->setRetryBackoff(CallScriptRetryBackoff::Exponential);
|
||||||
|
$script->setRetryMaxAttempts(5);
|
||||||
|
|
||||||
|
$script->setCallingTimezoneMode(null);
|
||||||
|
$script->setRetryBackoff(null);
|
||||||
|
$script->setRetryMaxAttempts(null);
|
||||||
|
|
||||||
|
self::assertSame(CallScriptTimezoneMode::Fixed, $script->getCallingTimezoneMode());
|
||||||
|
self::assertSame(CallScriptRetryBackoff::Exponential, $script->getRetryBackoff());
|
||||||
|
self::assertSame(5, $script->getRetryMaxAttempts());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDateRangeInterfaceMapsTheValidityWindow(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$start = new \DateTime('2026-01-10 09:00:00');
|
||||||
|
$end = new \DateTime('2026-01-12 18:00:00');
|
||||||
|
|
||||||
|
$script->setPublishUp($start);
|
||||||
|
$script->setPublishDown($end);
|
||||||
|
|
||||||
|
self::assertSame($start, $script->getStartDate());
|
||||||
|
self::assertSame($end, $script->getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOutcomeInputTypesDeclareWhetherTheyHaveOptions(): void
|
||||||
|
{
|
||||||
|
self::assertFalse(CallScriptOutcomeInputType::FreeText->hasOptions());
|
||||||
|
self::assertTrue(CallScriptOutcomeInputType::Checkbox->hasOptions());
|
||||||
|
self::assertTrue(CallScriptOutcomeInputType::Radio->hasOptions());
|
||||||
|
self::assertTrue(CallScriptOutcomeInputType::Dropdown->hasOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Validator;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcomeInputType;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallScriptOutcomeOptions;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallScriptOutcomeOptionsValidator;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
|
||||||
|
|
||||||
|
final class ValidCallScriptOutcomeOptionsValidatorTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testAFreeTextOutcomeWithoutOptionsIsValid(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())->setInputType(CallScriptOutcomeInputType::FreeText);
|
||||||
|
|
||||||
|
$this->validate($outcome, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAChoiceOutcomeWithOptionsIsValid(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())
|
||||||
|
->setInputType(CallScriptOutcomeInputType::Dropdown)
|
||||||
|
->setOptions([['value' => 'yes', 'label' => 'Yes']]);
|
||||||
|
|
||||||
|
$this->validate($outcome, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAChoiceOutcomeWithoutOptionsIsRefused(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())->setInputType(CallScriptOutcomeInputType::Radio);
|
||||||
|
|
||||||
|
$this->validate($outcome, ['mt3s.call_script.outcome.options.required']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAFreeTextOutcomeWithOptionsIsRefused(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())
|
||||||
|
->setInputType(CallScriptOutcomeInputType::FreeText)
|
||||||
|
->setOptions([['value' => 'yes', 'label' => 'Yes']]);
|
||||||
|
|
||||||
|
$this->validate($outcome, ['mt3s.call_script.outcome.options.free_text_forbidden']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOptionsNeedAValue(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())
|
||||||
|
->setInputType(CallScriptOutcomeInputType::Radio)
|
||||||
|
->setOptions([['value' => '', 'label' => 'No value']]);
|
||||||
|
|
||||||
|
$this->validate($outcome, ['mt3s.call_script.outcome.options.value_required']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOptionValuesMustBeUnique(): void
|
||||||
|
{
|
||||||
|
$outcome = (new CallScriptOutcome())
|
||||||
|
->setInputType(CallScriptOutcomeInputType::Checkbox)
|
||||||
|
->setOptions([
|
||||||
|
['value' => 'yes', 'label' => 'Yes'],
|
||||||
|
['value' => 'yes', 'label' => 'Again'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->validate($outcome, ['mt3s.call_script.outcome.options.duplicate_value']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $expectedMessages
|
||||||
|
*/
|
||||||
|
private function validate(CallScriptOutcome $outcome, array $expectedMessages): void
|
||||||
|
{
|
||||||
|
$violations = [];
|
||||||
|
$builder = $this->createMock(ConstraintViolationBuilderInterface::class);
|
||||||
|
$builder->method('atPath')->willReturnSelf();
|
||||||
|
$builder->method('addViolation')->willReturnCallback(function () use (&$violations, $builder): void {
|
||||||
|
$violations[] = $builder;
|
||||||
|
});
|
||||||
|
|
||||||
|
$context = $this->createMock(ExecutionContextInterface::class);
|
||||||
|
$context->method('buildViolation')->willReturnCallback(function (string $message) use (&$violations, $builder): ConstraintViolationBuilderInterface {
|
||||||
|
$violations[] = $message;
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
});
|
||||||
|
|
||||||
|
$validator = new ValidCallScriptOutcomeOptionsValidator();
|
||||||
|
$validator->initialize($context);
|
||||||
|
$validator->validate($outcome, new ValidCallScriptOutcomeOptions());
|
||||||
|
|
||||||
|
$messages = array_values(array_filter($violations, fn ($violation): bool => is_string($violation)));
|
||||||
|
self::assertSame($expectedMessages, $messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Tests\Unit\Validator;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptTimezoneMode;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallingWindow;
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints\ValidCallingWindowValidator;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
|
||||||
|
|
||||||
|
final class ValidCallingWindowValidatorTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testACompleteAndOrderedWindowIsValid(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingFrom(new \DateTime('09:00'));
|
||||||
|
$script->setCallingTo(new \DateTime('18:00'));
|
||||||
|
|
||||||
|
$this->validate($script, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnEmptyWindowIsValid(): void
|
||||||
|
{
|
||||||
|
$this->validate(new CallScript(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPartialHoursAreRefused(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingFrom(new \DateTime('09:00'));
|
||||||
|
|
||||||
|
$this->validate($script, 'mt3s.call_script.calling_window.partial_hours');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTheEndMustBeAfterTheStart(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingFrom(new \DateTime('18:00'));
|
||||||
|
$script->setCallingTo(new \DateTime('09:00'));
|
||||||
|
|
||||||
|
$this->validate($script, 'mt3s.call_script.calling_window.to_before_from');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAFixedModeNeedsATimezone(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingTimezoneMode(CallScriptTimezoneMode::Fixed);
|
||||||
|
|
||||||
|
$this->validate($script, 'mt3s.call_script.calling_window.timezone_required');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAFixedModeWithATimezoneIsValid(): void
|
||||||
|
{
|
||||||
|
$script = new CallScript();
|
||||||
|
$script->setCallingTimezoneMode(CallScriptTimezoneMode::Fixed);
|
||||||
|
$script->setCallingTimezone('Europe/Paris');
|
||||||
|
|
||||||
|
$this->validate($script, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validate(CallScript $script, ?string $expectedMessage): void
|
||||||
|
{
|
||||||
|
$violation = $this->createMock(ConstraintViolationBuilderInterface::class);
|
||||||
|
$violation->method('atPath')->willReturnSelf();
|
||||||
|
|
||||||
|
$context = $this->createMock(ExecutionContextInterface::class);
|
||||||
|
if (null === $expectedMessage) {
|
||||||
|
$context->expects(self::never())->method('buildViolation');
|
||||||
|
} else {
|
||||||
|
$context->expects(self::once())
|
||||||
|
->method('buildViolation')
|
||||||
|
->with($expectedMessage)
|
||||||
|
->willReturn($violation);
|
||||||
|
$violation->expects(self::once())->method('addViolation');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = new ValidCallingWindowValidator();
|
||||||
|
$validator->initialize($context);
|
||||||
|
$validator->validate($script, new ValidCallingWindow());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -531,3 +531,70 @@ mt3s.smart_links.taxonomies.unpublished_choice="%name% (no longer published)"
|
|||||||
mt3s.smart_links.taxonomies.free_values.tooltip="The allowed values of this parameter for the links using this taxonomy. One value per line, optionally value;Label for a display label."
|
mt3s.smart_links.taxonomies.free_values.tooltip="The allowed values of this parameter for the links using this taxonomy. One value per line, optionally value;Label for a display label."
|
||||||
mt3s.smart_links.taxonomies.free_values.placeholder="one value per line"
|
mt3s.smart_links.taxonomies.free_values.placeholder="one value per line"
|
||||||
mt3s.smart_links.taxonomies.no_values.tooltip="No values are configured for this parameter in Smart Links Settings yet: ask the admin to configure some."
|
mt3s.smart_links.taxonomies.no_values.tooltip="No values are configured for this parameter in Smart Links Settings yet: ask the admin to configure some."
|
||||||
|
|
||||||
|
; Call Scripts (Components > Call Scripts). Translation base mt3s.call_script.
|
||||||
|
mt3s.call_script.menu.index="Call Scripts"
|
||||||
|
mt3s.call_script.category.type="Call Script"
|
||||||
|
mt3s.call_script.header.index="Call Scripts"
|
||||||
|
mt3s.call_script.header.new="New Call Script"
|
||||||
|
mt3s.call_script.header.edit="Call Script - %name%"
|
||||||
|
mt3s.call_script.error.notfound="No call script with the ID %id% was found."
|
||||||
|
mt3s.call_script.form.confirmdelete="Delete the call script %name%? Its outcomes are deleted too."
|
||||||
|
mt3s.call_script.form.confirmbatchdelete="Delete the selected call scripts? Their outcomes are deleted too."
|
||||||
|
mt3s.call_script.onboarding.heading="No call scripts yet"
|
||||||
|
mt3s.call_script.onboarding.subheading="Call scripts guide your agents through a call and record what happens."
|
||||||
|
mt3s.call_script.onboarding.copy="Use the New button above to add a call script. Define its script, its outcomes, its calling window and its retry policy."
|
||||||
|
mt3s.call_script.field.name="Name"
|
||||||
|
mt3s.call_script.field.description="Description"
|
||||||
|
mt3s.call_script.field.script="Script"
|
||||||
|
mt3s.call_script.field.script.help="HTML is allowed. Use dynamic tokens like {contact.first_name}; they are kept as typed."
|
||||||
|
mt3s.call_script.field.owner="Owner"
|
||||||
|
mt3s.call_script.field.category="Category"
|
||||||
|
mt3s.call_script.field.start="Start date and time"
|
||||||
|
mt3s.call_script.field.end="End date and time"
|
||||||
|
mt3s.call_script.field.calling_days="Calling days"
|
||||||
|
mt3s.call_script.field.calling_from="From"
|
||||||
|
mt3s.call_script.field.calling_to="To"
|
||||||
|
mt3s.call_script.field.calling_timezone_mode="Timezone mode"
|
||||||
|
mt3s.call_script.field.calling_timezone="Fixed timezone"
|
||||||
|
mt3s.call_script.field.retry_max_attempts="Maximum attempts"
|
||||||
|
mt3s.call_script.field.retry_delay_minutes="Delay between attempts (minutes)"
|
||||||
|
mt3s.call_script.field.retry_backoff="Backoff"
|
||||||
|
mt3s.call_script.list.published="Published"
|
||||||
|
mt3s.call_script.list.unpublished="Unpublished"
|
||||||
|
mt3s.call_script.list.owner="Owner"
|
||||||
|
mt3s.call_script.list.category="Category"
|
||||||
|
mt3s.call_script.list.status="Status"
|
||||||
|
mt3s.call_script.list.modified="Modified"
|
||||||
|
mt3s.call_script.day.mon="Monday"
|
||||||
|
mt3s.call_script.day.tue="Tuesday"
|
||||||
|
mt3s.call_script.day.wed="Wednesday"
|
||||||
|
mt3s.call_script.day.thu="Thursday"
|
||||||
|
mt3s.call_script.day.fri="Friday"
|
||||||
|
mt3s.call_script.day.sat="Saturday"
|
||||||
|
mt3s.call_script.day.sun="Sunday"
|
||||||
|
mt3s.call_script.timezone_mode.contact="Contact's timezone"
|
||||||
|
mt3s.call_script.timezone_mode.fixed="Fixed timezone"
|
||||||
|
mt3s.call_script.retry_backoff.none="No backoff (constant delay)"
|
||||||
|
mt3s.call_script.retry_backoff.linear="Linear (delay multiplied by the attempt number)"
|
||||||
|
mt3s.call_script.retry_backoff.exponential="Exponential (delay doubled at every attempt)"
|
||||||
|
mt3s.call_script.outcome.list="Outcomes"
|
||||||
|
mt3s.call_script.outcome.empty="No outcomes yet."
|
||||||
|
mt3s.call_script.outcome.add="Add outcome"
|
||||||
|
mt3s.call_script.outcome.remove="Remove this outcome"
|
||||||
|
mt3s.call_script.outcome.drag="Drag to reorder"
|
||||||
|
mt3s.call_script.outcome.field.label="Outcome"
|
||||||
|
mt3s.call_script.outcome.field.type="Data type"
|
||||||
|
mt3s.call_script.outcome.options="Options"
|
||||||
|
mt3s.call_script.outcome.options.empty="No options yet."
|
||||||
|
mt3s.call_script.outcome.options.add="Add option"
|
||||||
|
mt3s.call_script.outcome.options.remove="Remove this option"
|
||||||
|
mt3s.call_script.outcome_type.checkbox="Checkboxes"
|
||||||
|
mt3s.call_script.outcome_type.radio="Radio buttons"
|
||||||
|
mt3s.call_script.outcome_type.free_text="Free text"
|
||||||
|
mt3s.call_script.outcome_type.dropdown="Drop-down"
|
||||||
|
mt3s.call_script.outcome_option.field.value="Value"
|
||||||
|
mt3s.call_script.outcome_option.field.label="Label"
|
||||||
|
|
||||||
|
mt3s.call_script.section.calling_window="Calling window"
|
||||||
|
mt3s.call_script.section.retry_policy="Retry policy"
|
||||||
@@ -59,3 +59,13 @@ mt3s.smart_links.taxonomies.error.name_characters="The name cannot contain the c
|
|||||||
mt3s.smart_links.taxonomies.error.value_invalid="The value %value% is invalid. Use only lowercase letters, digits, hyphens, underscores and dots."
|
mt3s.smart_links.taxonomies.error.value_invalid="The value %value% is invalid. Use only lowercase letters, digits, hyphens, underscores and dots."
|
||||||
mt3s.smart_links.smart_links.error.taxonomy_required="Choose a UTM Taxonomy."
|
mt3s.smart_links.smart_links.error.taxonomy_required="Choose a UTM Taxonomy."
|
||||||
mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown="The parameter %key% is not part of the taxonomy %name%."
|
mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown="The parameter %key% is not part of the taxonomy %name%."
|
||||||
|
mt3s.call_script.retry_attempts.range="The maximum attempts must be a whole number from 1 to 20."
|
||||||
|
mt3s.call_script.retry_delay.range="The delay must be a whole number of minutes, 0 or more."
|
||||||
|
mt3s.call_script.calling_window.partial_hours="Set both the from and the to time of the calling window."
|
||||||
|
mt3s.call_script.calling_window.to_before_from="The calling window must end after it starts."
|
||||||
|
mt3s.call_script.calling_window.timezone_required="Choose the fixed timezone of the calling window."
|
||||||
|
mt3s.call_script.outcome.label.required="An outcome needs a label."
|
||||||
|
mt3s.call_script.outcome.options.required="This outcome type needs at least one option."
|
||||||
|
mt3s.call_script.outcome.options.free_text_forbidden="A free text outcome takes no options."
|
||||||
|
mt3s.call_script.outcome.options.value_required="Every option needs a value."
|
||||||
|
mt3s.call_script.outcome.options.duplicate_value="The option values must be unique."
|
||||||
@@ -206,3 +206,70 @@ mt3s.smart_links.taxonomies.unpublished_choice="%name% (plus publiée)"
|
|||||||
mt3s.smart_links.taxonomies.free_values.tooltip="Les valeurs autorisées de ce paramètre pour les liens utilisant cette taxonomie. Une valeur par ligne, éventuellement valeur;Libellé."
|
mt3s.smart_links.taxonomies.free_values.tooltip="Les valeurs autorisées de ce paramètre pour les liens utilisant cette taxonomie. Une valeur par ligne, éventuellement valeur;Libellé."
|
||||||
mt3s.smart_links.taxonomies.free_values.placeholder="une valeur par ligne"
|
mt3s.smart_links.taxonomies.free_values.placeholder="une valeur par ligne"
|
||||||
mt3s.smart_links.taxonomies.no_values.tooltip="Aucune valeur n’est encore configurée pour ce paramètre dans Paramètres Smart Links : demandez à l’administrateur d’en configurer."
|
mt3s.smart_links.taxonomies.no_values.tooltip="Aucune valeur n’est encore configurée pour ce paramètre dans Paramètres Smart Links : demandez à l’administrateur d’en configurer."
|
||||||
|
|
||||||
|
; Scripts d'appel (Composants > Scripts d'appel). Base de traduction mt3s.call_script.
|
||||||
|
mt3s.call_script.menu.index="Scripts d'appel"
|
||||||
|
mt3s.call_script.category.type="Script d'appel"
|
||||||
|
mt3s.call_script.header.index="Scripts d'appel"
|
||||||
|
mt3s.call_script.header.new="Nouveau script d'appel"
|
||||||
|
mt3s.call_script.header.edit="Script d'appel - %name%"
|
||||||
|
mt3s.call_script.error.notfound="Aucun script d'appel avec l'ID %id% n'a été trouvé."
|
||||||
|
mt3s.call_script.form.confirmdelete="Supprimer le script d'appel %name% ? Ses résultats sont supprimés aussi."
|
||||||
|
mt3s.call_script.form.confirmbatchdelete="Supprimer les scripts d'appel sélectionnés ? Leurs résultats sont supprimés aussi."
|
||||||
|
mt3s.call_script.onboarding.heading="Aucun script d'appel pour le moment"
|
||||||
|
mt3s.call_script.onboarding.subheading="Les scripts d'appel guident vos agents pendant un appel et enregistrent son résultat."
|
||||||
|
mt3s.call_script.onboarding.copy="Utilisez le bouton Nouveau ci-dessus pour ajouter un script d'appel. Définissez son script, ses résultats, sa plage d'appel et sa politique de réessai."
|
||||||
|
mt3s.call_script.field.name="Nom"
|
||||||
|
mt3s.call_script.field.description="Description"
|
||||||
|
mt3s.call_script.field.script="Script"
|
||||||
|
mt3s.call_script.field.script.help="Le HTML est accepté. Utilisez les jetons dynamiques comme {contact.first_name} ; ils sont conservés tels quels."
|
||||||
|
mt3s.call_script.field.owner="Propriétaire"
|
||||||
|
mt3s.call_script.field.category="Catégorie"
|
||||||
|
mt3s.call_script.field.start="Date et heure de début"
|
||||||
|
mt3s.call_script.field.end="Date et heure de fin"
|
||||||
|
mt3s.call_script.field.calling_days="Jours d'appel"
|
||||||
|
mt3s.call_script.field.calling_from="De"
|
||||||
|
mt3s.call_script.field.calling_to="À"
|
||||||
|
mt3s.call_script.field.calling_timezone_mode="Mode de fuseau horaire"
|
||||||
|
mt3s.call_script.field.calling_timezone="Fuseau horaire fixe"
|
||||||
|
mt3s.call_script.field.retry_max_attempts="Nombre maximal de tentatives"
|
||||||
|
mt3s.call_script.field.retry_delay_minutes="Délai entre les tentatives (minutes)"
|
||||||
|
mt3s.call_script.field.retry_backoff="Espacement"
|
||||||
|
mt3s.call_script.list.published="Publié"
|
||||||
|
mt3s.call_script.list.unpublished="Non publié"
|
||||||
|
mt3s.call_script.list.owner="Propriétaire"
|
||||||
|
mt3s.call_script.list.category="Catégorie"
|
||||||
|
mt3s.call_script.list.status="Statut"
|
||||||
|
mt3s.call_script.list.modified="Modifié"
|
||||||
|
mt3s.call_script.day.mon="Lundi"
|
||||||
|
mt3s.call_script.day.tue="Mardi"
|
||||||
|
mt3s.call_script.day.wed="Mercredi"
|
||||||
|
mt3s.call_script.day.thu="Jeudi"
|
||||||
|
mt3s.call_script.day.fri="Vendredi"
|
||||||
|
mt3s.call_script.day.sat="Samedi"
|
||||||
|
mt3s.call_script.day.sun="Dimanche"
|
||||||
|
mt3s.call_script.timezone_mode.contact="Fuseau horaire du contact"
|
||||||
|
mt3s.call_script.timezone_mode.fixed="Fuseau horaire fixe"
|
||||||
|
mt3s.call_script.retry_backoff.none="Aucun espacement (délai constant)"
|
||||||
|
mt3s.call_script.retry_backoff.linear="Linéaire (délai multiplié par le numéro de tentative)"
|
||||||
|
mt3s.call_script.retry_backoff.exponential="Exponentiel (délai doublé à chaque tentative)"
|
||||||
|
mt3s.call_script.outcome.list="Résultats"
|
||||||
|
mt3s.call_script.outcome.empty="Aucun résultat pour le moment."
|
||||||
|
mt3s.call_script.outcome.add="Ajouter un résultat"
|
||||||
|
mt3s.call_script.outcome.remove="Supprimer ce résultat"
|
||||||
|
mt3s.call_script.outcome.drag="Glisser pour réordonner"
|
||||||
|
mt3s.call_script.outcome.field.label="Résultat"
|
||||||
|
mt3s.call_script.outcome.field.type="Type de données"
|
||||||
|
mt3s.call_script.outcome.options="Options"
|
||||||
|
mt3s.call_script.outcome.options.empty="Aucune option pour le moment."
|
||||||
|
mt3s.call_script.outcome.options.add="Ajouter une option"
|
||||||
|
mt3s.call_script.outcome.options.remove="Supprimer cette option"
|
||||||
|
mt3s.call_script.outcome_type.checkbox="Cases à cocher"
|
||||||
|
mt3s.call_script.outcome_type.radio="Boutons radio"
|
||||||
|
mt3s.call_script.outcome_type.free_text="Texte libre"
|
||||||
|
mt3s.call_script.outcome_type.dropdown="Liste déroulante"
|
||||||
|
mt3s.call_script.outcome_option.field.value="Valeur"
|
||||||
|
mt3s.call_script.outcome_option.field.label="Libellé"
|
||||||
|
|
||||||
|
mt3s.call_script.section.calling_window="Plage d'appel"
|
||||||
|
mt3s.call_script.section.retry_policy="Politique de réessai"
|
||||||
@@ -38,3 +38,13 @@ mt3s.smart_links.taxonomies.error.name_characters="Le nom ne peut pas contenir l
|
|||||||
mt3s.smart_links.taxonomies.error.value_invalid="La valeur %value% est invalide. Utilisez uniquement des lettres minuscules, des chiffres, des tirets, des tirets bas et des points."
|
mt3s.smart_links.taxonomies.error.value_invalid="La valeur %value% est invalide. Utilisez uniquement des lettres minuscules, des chiffres, des tirets, des tirets bas et des points."
|
||||||
mt3s.smart_links.smart_links.error.taxonomy_required="Choisissez une taxonomie UTM."
|
mt3s.smart_links.smart_links.error.taxonomy_required="Choisissez une taxonomie UTM."
|
||||||
mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown="Le paramètre %key% ne fait pas partie de la taxonomie %name%."
|
mt3s.smart_links.smart_links.error.taxonomy_parameter_unknown="Le paramètre %key% ne fait pas partie de la taxonomie %name%."
|
||||||
|
mt3s.call_script.retry_attempts.range="Le nombre maximal de tentatives doit être un nombre entier de 1 à 20."
|
||||||
|
mt3s.call_script.retry_delay.range="Le délai doit être un nombre entier de minutes, 0 ou plus."
|
||||||
|
mt3s.call_script.calling_window.partial_hours="Renseignez à la fois le début et la fin de la plage d'appel."
|
||||||
|
mt3s.call_script.calling_window.to_before_from="La plage d'appel doit se terminer après son début."
|
||||||
|
mt3s.call_script.calling_window.timezone_required="Choisissez le fuseau horaire fixe de la plage d'appel."
|
||||||
|
mt3s.call_script.outcome.label.required="Un résultat a besoin d'un libellé."
|
||||||
|
mt3s.call_script.outcome.options.required="Ce type de résultat a besoin d'au moins une option."
|
||||||
|
mt3s.call_script.outcome.options.free_text_forbidden="Un résultat en texte libre ne prend pas d'option."
|
||||||
|
mt3s.call_script.outcome.options.value_required="Chaque valeur d'option est requise."
|
||||||
|
mt3s.call_script.outcome.options.duplicate_value="Les valeurs des options doivent être uniques."
|
||||||
@@ -7,12 +7,27 @@ namespace MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints;
|
|||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constraint for any DateRangeInterface (Plan, Task): when both dates are set, endDate must be
|
* Class constraint for any DateRangeInterface (Plan, Task, CallScript): when both dates are set, endDate
|
||||||
* on or after startDate.
|
* must be on or after startDate.
|
||||||
*/
|
*/
|
||||||
class EndDateAfterStartDate extends Constraint
|
class EndDateAfterStartDate extends Constraint
|
||||||
{
|
{
|
||||||
public string $message = 'mt3s.marketing_program.end_date.before_start_date';
|
/**
|
||||||
|
* @param string|null $message the violation message
|
||||||
|
* @param string|null $atPath the form field the violation is attached to; entities whose end
|
||||||
|
* date is not named "endDate" (like the CallScript's publishDown) override it
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public ?string $message = null,
|
||||||
|
public ?string $atPath = null,
|
||||||
|
?array $groups = null,
|
||||||
|
mixed $payload = null,
|
||||||
|
) {
|
||||||
|
parent::__construct(null, $groups, $payload);
|
||||||
|
|
||||||
|
$this->message = $message ?? 'mt3s.marketing_program.end_date.before_start_date';
|
||||||
|
$this->atPath = $atPath ?? 'endDate';
|
||||||
|
}
|
||||||
|
|
||||||
public function getTargets(): string
|
public function getTargets(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class EndDateAfterStartDateValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->context->buildViolation($constraint->message)
|
$this->context->buildViolation($constraint->message)
|
||||||
->atPath('endDate')
|
->atPath($constraint->atPath)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options of a call script outcome: required for the checkbox, radio and dropdown types,
|
||||||
|
* forbidden for free text, each with a value, and no duplicate values.
|
||||||
|
*/
|
||||||
|
class ValidCallScriptOutcomeOptions extends Constraint
|
||||||
|
{
|
||||||
|
public string $required = 'mt3s.call_script.outcome.options.required';
|
||||||
|
|
||||||
|
public string $freeTextForbidden = 'mt3s.call_script.outcome.options.free_text_forbidden';
|
||||||
|
|
||||||
|
public string $valueRequired = 'mt3s.call_script.outcome.options.value_required';
|
||||||
|
|
||||||
|
public string $duplicateValue = 'mt3s.call_script.outcome.options.duplicate_value';
|
||||||
|
|
||||||
|
public function getTargets(): string
|
||||||
|
{
|
||||||
|
return self::CLASS_CONSTRAINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScriptOutcome;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
|
|
||||||
|
class ValidCallScriptOutcomeOptionsValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
public function validate(mixed $value, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
if (!$constraint instanceof ValidCallScriptOutcomeOptions) {
|
||||||
|
throw new UnexpectedTypeException($constraint, ValidCallScriptOutcomeOptions::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$value instanceof CallScriptOutcome) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = $value->getOptions();
|
||||||
|
|
||||||
|
if (!$value->hasOptions()) {
|
||||||
|
if ([] !== $options) {
|
||||||
|
$this->context->buildViolation($constraint->freeTextForbidden)
|
||||||
|
->atPath('options')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([] === $options) {
|
||||||
|
$this->context->buildViolation($constraint->required)
|
||||||
|
->atPath('options')
|
||||||
|
->addViolation();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seen = [];
|
||||||
|
foreach ($options as $index => $option) {
|
||||||
|
if ('' === $option['value']) {
|
||||||
|
$this->context->buildViolation($constraint->valueRequired)
|
||||||
|
->atPath('options['.$index.'][value]')
|
||||||
|
->addViolation();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($seen[$option['value']])) {
|
||||||
|
$this->context->buildViolation($constraint->duplicateValue)
|
||||||
|
->atPath('options['.$index.'][value]')
|
||||||
|
->addViolation();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seen[$option['value']] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The calling window of a call script must be consistent: both hours or none, an end after its
|
||||||
|
* start, and a timezone when the window is read in a fixed timezone.
|
||||||
|
*/
|
||||||
|
class ValidCallingWindow extends Constraint
|
||||||
|
{
|
||||||
|
public string $partialHours = 'mt3s.call_script.calling_window.partial_hours';
|
||||||
|
|
||||||
|
public string $toBeforeFrom = 'mt3s.call_script.calling_window.to_before_from';
|
||||||
|
|
||||||
|
public string $timezoneRequired = 'mt3s.call_script.calling_window.timezone_required';
|
||||||
|
|
||||||
|
public function getTargets(): string
|
||||||
|
{
|
||||||
|
return self::CLASS_CONSTRAINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\CallScript;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
|
|
||||||
|
class ValidCallingWindowValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
public function validate(mixed $value, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
if (!$constraint instanceof ValidCallingWindow) {
|
||||||
|
throw new UnexpectedTypeException($constraint, ValidCallingWindow::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$value instanceof CallScript) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$from = $value->getCallingFrom();
|
||||||
|
$to = $value->getCallingTo();
|
||||||
|
|
||||||
|
if ((null === $from) !== (null === $to)) {
|
||||||
|
$this->context->buildViolation($constraint->partialHours)
|
||||||
|
->atPath('callingFrom')
|
||||||
|
->addViolation();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $from && null !== $to && $to <= $from) {
|
||||||
|
$this->context->buildViolation($constraint->toBeforeFrom)
|
||||||
|
->atPath('callingTo')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value->getCallingTimezoneMode()->isFixed() && null === $value->getCallingTimezone()) {
|
||||||
|
$this->context->buildViolation($constraint->timezoneRequired)
|
||||||
|
->atPath('callingTimezone')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,18 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: Entity/Audience.php
|
path: Entity/Audience.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\CallScript\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
|
||||||
|
identifier: property.unusedType
|
||||||
|
count: 1
|
||||||
|
path: Entity/CallScript.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\CallScriptOutcome\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
|
||||||
|
identifier: property.unusedType
|
||||||
|
count: 1
|
||||||
|
path: Entity/CallScriptOutcome.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Program\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
|
message: '#^Property MauticPlugin\\MT3SMarketingProgramBundle\\Entity\\Program\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
|
||||||
identifier: property.unusedType
|
identifier: property.unusedType
|
||||||
|
|||||||
@@ -67,6 +67,19 @@ In short:
|
|||||||
configure (it stays a normal Mautic page on any other domain), records a hit per click —
|
configure (it stays a normal Mautic page on any other domain), records a hit per click —
|
||||||
date, IP, referer, user agent — and never lets a statistics failure block the redirect.
|
date, IP, referer, user agent — and never lets a statistics failure block the redirect.
|
||||||
|
|
||||||
|
### Call Scripts
|
||||||
|
|
||||||
|
- **Call Scripts**, in the **Components** menu: the scripts your agents read when they call a
|
||||||
|
contact.
|
||||||
|
- A script is HTML with dynamic tokens like `{contact.first_name}`, kept as typed, and carries a
|
||||||
|
name, a description, a category, an owner, a status and a start and end date and time.
|
||||||
|
- Each script defines its **outcomes** — the list of things the agent records after the call. Each
|
||||||
|
outcome has a data type: checkboxes, radio buttons or a drop-down (with their options), or free
|
||||||
|
text.
|
||||||
|
- A **calling window** (weekdays and hours, read in the contact's timezone or in a fixed one) and a
|
||||||
|
**retry policy** (maximum attempts, delay between attempts, and whether the delay stays
|
||||||
|
constant, grows linearly or doubles) travel with the script.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
- **Settings > Configuration > Marketing Program Settings**: the general settings — the
|
- **Settings > Configuration > Marketing Program Settings**: the general settings — the
|
||||||
|
|||||||
Reference in new issue
Block a user