From c6b21841ea23abe4ae16906e3d016d47ed514fe2 Mon Sep 17 00:00:00 2001 From: vladfo Date: Fri, 4 Oct 2024 17:23:03 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D0=BD=D0=B0=20=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82=D0=B2?= =?utf8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D0=B8?= =?utf8?q?=D1=81=D0=B8=20MotivationValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...ata_to_monitvation_from_motivation_buh.php | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/erp24/scripts/tasks/task_33_insert_data_to_monitvation_from_motivation_buh.php b/erp24/scripts/tasks/task_33_insert_data_to_monitvation_from_motivation_buh.php index 547e5f85..a59dad51 100644 --- a/erp24/scripts/tasks/task_33_insert_data_to_monitvation_from_motivation_buh.php +++ b/erp24/scripts/tasks/task_33_insert_data_to_monitvation_from_motivation_buh.php @@ -109,7 +109,7 @@ try { ]) ->all(); - $motivationVal = []; + foreach ($motivationBuhValue as $value) { $motivationBuh = MotivationBuh::findOne([$value->motivation_buh_id]); @@ -119,6 +119,7 @@ try { 'store_id' => $value->store_id, ]); + if (!$motivation) { $motivation = new Motivation(); $motivation->setAttributes([ @@ -129,15 +130,29 @@ try { $motivation->save(); } - $motivationValue = new MotivationValue(); - $motivationValue->setAttributes([ + + $motivationValue = MotivationValue::findOne([ 'motivation_id' => $motivation->id, 'motivation_group_id' => $value->motivation_group_id, 'value_id' => $value->value_id, - 'value_type' => MotivationCostsItem::DATA_TYPE_FLOAT, - 'value_float' => $value->value_float, ]); - $motivationVal[] = $value->value_float; + + + if ($motivationValue) { + $motivationValue->value_float = $value->value_float; + } else { + + $motivationValue = new MotivationValue(); + $motivationValue->setAttributes([ + 'motivation_id' => $motivation->id, + 'motivation_group_id' => $value->motivation_group_id, + 'value_id' => $value->value_id, + 'value_type' => MotivationCostsItem::DATA_TYPE_FLOAT, + 'value_float' => $value->value_float, + ]); + } + + $motivationValue->save(); } -- 2.39.5