private function prepareEventScenario(
BaseScenario $baseScenario,
bool $refill,
bool $useParticipationField,
$participationFormat = null
): BaseScenario
{
$value = null;
if ($useParticipationField)
{
$field = \CUserTypeEntity::GetList([], [
'ENTITY_ID' => 'CRM_DEAL',
'FIELD_NAME' => 'UF_CRM_WEBFORM_PARTICIPATION_FORMAT',
])->fetch();
if ($participationFormat && $field)
{
$values = \CUserFieldEnum::GetList([], [
'USER_FIELD_ID' => $field['ID'],
]
);
while ($currentValue = $values->fetch())
{
$stringValue = Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_PARTICIPATION_FORMAT_' . mb_strtoupper($participationFormat));
if (mb_strpos($currentValue['VALUE'], $stringValue) > -1)
{
$value = $currentValue['ID'];
break;
}
}
}
}
$optionBuilder = (new ScenarioOptionBuilder())
->addAgreements(true)
->addCaptcha(true)
->addRecaptcha()
->addResult(
Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_FEEDBACK_SUCCESS_TEXT'),
Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_FEEDBACK_FAILURE_TEXT'),
$refill
)
->addFields([
['name' => 'CONTACT_NAME', 'autocomplete' => !$refill, 'required'=> true],
['name' => 'CONTACT_LAST_NAME', 'autocomplete' => !$refill],
['name' => 'CONTACT_PHONE', 'autocomplete' => !$refill, 'required'=> true],
['name' => 'COMPANY_TITLE', 'autocomplete' => !$refill],
['name' => 'CONTACT_POST', 'autocomplete' => !$refill],
$useParticipationField ? [
'name' => 'DEAL_UF_CRM_WEBFORM_PARTICIPATION_FORMAT',
'autocomplete' => !$refill,
'inPreparing' => true,
'required'=> true,
'value' => $value
] : [],
])
->setButtonCaption(Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_REGISTRATION_BUTTON'))
->addDocumentScheme(Entity::ENUM_ENTITY_SCHEME_DEAL)
->addPresetField([
'entityName' => 'DEAL',
'fieldName' => 'TITLE',
'value' => $participationFormat === 'online'
? Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_EVENT_REGISTRATION')
: Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_OFFLINE_REGISTRATION_EVENT')
,
])
;
$this->prepareDealAndResponsibilitiesConfiguration($optionBuilder);
return $baseScenario->setCategory(ScenarioCategory::EVENTS)
->setMenuItems([
ScenarioMenuItem::FIELDS['id'],
ScenarioMenuItem::AGREEMENTS['id'],
ScenarioMenuItem::CRM['id'],
ScenarioMenuItem::BUTTON_AND_HEADER['id'],
ScenarioMenuItem::ACTIONS['id'],
ScenarioMenuItem::DEFAULT_VALUES['id'],
ScenarioMenuItem::DESIGN['id'],
ScenarioMenuItem::OTHER['id'],
])
->setExpertModeMenuItems($this->getExpertModeDefaultItems())
->fieldsToCheck($useParticipationField ? [
[
'name' => 'UF_CRM_WEBFORM_PARTICIPATION_FORMAT',
'entityType' => 'CRM_DEAL',
'type' => 'enumeration',
// 'showConfirmation' => true, // show modal confirmation dialog
'title' => [
'text' => Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_PARTICIPATION_FORMAT'),
'locale' => Context::getCurrent()->getLanguage(),
],
'items' => [
'online' => Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_PARTICIPATION_FORMAT_ONLINE'),
'live' => Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_PARTICIPATION_FORMAT_LIVE'),
'record' => Loc::getMessage('CRM_SERVICE_FORM_SCENARIO_PARTICIPATION_FORMAT_RECORD'),
],
],
] : [])
->prepareBuilder($optionBuilder)
->setActions([[
'id' => 'check'
]])
;
}