28 $this->request = $request;
42 $id = $numeratorConfig [
'id'];
45 $result = $this->updateNextSequentialNumber($id);
46 if ($result->isSuccess())
54 $result = $numerator->setConfig($this->request->getPostList()->toArray());
55 if ($result->isSuccess())
57 $result = $numerator->save();
70 private function updateNextSequentialNumber($id)
74 if ($sequenceConfig !==
null && is_array($sequenceConfig)
75 && array_key_exists(
'nextNumberForSequence', $sequenceConfig) && $sequenceConfig[
'nextNumberForSequence'])
77 $nextNumber = $sequenceConfig[
'nextNumberForSequence'];
78 if (is_numeric($nextNumber))
80 $sequence = NumeratorTable::query()
81 ->registerRuntimeField(
'',
84 NumeratorSequenceTable::class,
85 [
'=this.ID' =>
'ref.NUMERATOR_ID']
89 ->addSelect(
'ref.NEXT_NUMBER',
'NEXT_NUMBER')
90 ->addSelect(
'ref.TEXT_KEY',
'TEXT_KEY')
95 if ($sequence && count($sequence) == 1)
100 $res = $numerator->setNextSequentialNumber($nextNumber, $sequence[0][
'NEXT_NUMBER'], $sequence[0][
'TEXT_KEY']);
101 if (!$res->isSuccess())
103 $errors = $res->getErrors();
104 return $result->addError($errors[0]);
111 return $result->addError(
new Error(
Loc::getMessage(
'MAIN_NUMERATOR_EDIT_ERROR_NUMBER_NOT_NUMERIC')));
static getMessage($code, $replace=null, $language=null)
static update($numId, $config)
static load($numeratorId, $source=null)