68 $result =
new EventResult();
69 $numeratorFields = $event->getParameter(
"fields");
72 $numberTemplate = isset($numeratorFields[
'TEMPLATE']) ? $numeratorFields[
'TEMPLATE'] :
'';
73 $settings = Json::decode($numeratorFields[
'SETTINGS']);
77 switch ($numberTemplate)
80 $settingsSequent = $settings[SequentNumberGenerator::getType()];
81 if (isset($settingsSequent[
'step']) && ($settingsSequent[
'step'] == 1)
83 key_exists(
'periodicBy', $settingsSequent) && ($settingsSequent[
'periodicBy'] ==
null)
89 case '{PREFIX}{ORDER_ID}':
95 case '{USER_ID_ORDERS_COUNT}':
98 case '{DAY}{MONTH}{YEAR} / {NUMBER}':
99 $settingsSequent = $settings[SequentNumberGenerator::getType()];
100 if (isset($settingsSequent[
'step']) && $settingsSequent[
'step'] == 1
102 key_exists(
'periodicBy', $settingsSequent) && $settingsSequent[
'periodicBy'] == SequentNumberGenerator::DAY
108 case '{MONTH}{YEAR} / {NUMBER}':
109 $settingsSequent = $settings[SequentNumberGenerator::getType()];
110 if (isset($settingsSequent[
'step']) && $settingsSequent[
'step'] == 1
112 key_exists(
'periodicBy', $settingsSequent) && $settingsSequent[
'periodicBy'] == SequentNumberGenerator::MONTH
118 case '{YEAR} / {NUMBER}':
119 $settingsSequent = $settings[SequentNumberGenerator::getType()];
120 if (isset($settingsSequent[
'step']) && $settingsSequent[
'step'] == 1
122 key_exists(
'periodicBy', $settingsSequent) && $settingsSequent[
'periodicBy'] == SequentNumberGenerator::YEAR
132 $isStartIsUserDefinedPattern = strncmp($numberTemplate, NumberGenerator::USER_DEFINED_SYMBOL_START, mb_strlen(NumberGenerator::USER_DEFINED_SYMBOL_START)) === 0;
133 $isEndIsUserDefinedPattern = mb_substr($numberTemplate, -mb_strlen(NumberGenerator::USER_DEFINED_SYMBOL_END)) === NumberGenerator::USER_DEFINED_SYMBOL_END;
134 if ($isStartIsUserDefinedPattern && $isEndIsUserDefinedPattern)
136 $type = mb_substr(mb_substr($numberTemplate, mb_strlen(NumberGenerator::USER_DEFINED_SYMBOL_START)), 0, -mb_strlen(NumberGenerator::USER_DEFINED_SYMBOL_END));
142 Option::set(
"sale",
"account_number_template", $type);