} else {
if ($existingOperations[$operation['guid']]['type'] !== (int)$operation['type']) {
- $operation = AnalystsBusinessOperations::findOne($operation['guid']);
+ $oldOperation = AnalystsBusinessOperations::findOne($operation['guid']);
if (!in_array((int)$operation['type'], array_column($existingTypes, 'code'))) {
$newType = new AnalystsBusinessOperationsTypes();
$newType->code = (int)$operation['type'];
$newType->name = null;
$newType->created_at = date('Y-m-d H:i:s');
if ($newType->save()) {
- $operation->type = (int)$operation['type'];
- $operation->type_id = $newType->id;
+ $oldOperation->type = (int)$operation['type'];
+ $oldOperation->type_id = $newType->id;
} else {
Yii::error('Ошибка сохранение типа ' . json_encode($newType->getErrors(), JSON_UNESCAPED_UNICODE), __METHOD__ );
LogService::apiErrorLog(
json_encode(
- ["error_id" => 44.3, "error" => $operation->getErrors()],
+ ["error_id" => 44.3, "error" => $oldOperation->getErrors()],
JSON_UNESCAPED_UNICODE
)
);
}
} else {
- $operation->type = (int)$operation['type'];
- $operation->type_id = AnalystsBusinessOperationsTypes::find()->where(['code' => (int)$operation['type']])->one()->id;
- if (!$operation->save()) {
+ $oldOperation->type = (int)$operation['type'];
+ $oldOperation->type_id = AnalystsBusinessOperationsTypes::find()->where(['code' => (int)$operation['type']])->one()->id;
+ if (!$oldOperation->save()) {
LogService::apiErrorLog(
json_encode(
- ["error_id" => 44.4, "error" => $operation->getErrors()],
+ ["error_id" => 44.4, "error" => $oldOperation->getErrors()],
JSON_UNESCAPED_UNICODE
)
);