From: fomichev Date: Tue, 21 Apr 2026 08:36:43 +0000 (+0300) Subject: фикс удаления X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ba909bbc1efadc02a70b8fce55e0ff926f591d89;p=erp24_rep%2Fyii-erp24%2F.git фикс удаления --- diff --git a/erp24/controllers/SupplierController.php b/erp24/controllers/SupplierController.php index 3c9a529f..db098bbb 100644 --- a/erp24/controllers/SupplierController.php +++ b/erp24/controllers/SupplierController.php @@ -144,7 +144,7 @@ class SupplierController extends BaseController return $this->asJson([ 'success' => true, 'message' => sprintf( - 'Поставщик "%s" деактивирован. Связанных записей: маркировки — %d, маппинги — %d.', + 'Поставщик "%s" деактивирован. Маркировки: %d, маппинги: %d.', $model->name, $result['markings'], $result['product_mappings'] diff --git a/erp24/records/ProductMapping.php b/erp24/records/ProductMapping.php index 1f7fc44e..7c3526e3 100644 --- a/erp24/records/ProductMapping.php +++ b/erp24/records/ProductMapping.php @@ -23,6 +23,7 @@ use yii\db\Expression; * @property string|null $article * @property string|null $barcode * @property int $quant Кратность заказа (>=1) + * @property bool $is_active * @property int $created_by * @property int|null $updated_by * @property string $created_at @@ -97,6 +98,8 @@ class ProductMapping extends ActiveRecord ], ['supplier_id', 'validatePartialUnique'], [['article', 'barcode', 'plantation_id'], 'default', 'value' => null], + ['is_active', 'boolean'], + ['is_active', 'default', 'value' => true], ['marking_ids', 'each', 'rule' => ['integer']], ['marking_ids', 'default', 'value' => []], ]; @@ -113,6 +116,7 @@ class ProductMapping extends ActiveRecord 'article' => 'Артикул', 'barcode' => 'Штрихкод', 'quant' => 'Квант', + 'is_active' => 'Статус', 'marking_ids' => 'Маркировки', ]; } diff --git a/erp24/records/Supplier.php b/erp24/records/Supplier.php index 71cfb424..73c7531b 100644 --- a/erp24/records/Supplier.php +++ b/erp24/records/Supplier.php @@ -167,13 +167,13 @@ class Supplier extends ActiveRecord ->execute(); $mappingsCount = (int)Yii::$app->db->createCommand() - ->update('{{%erp24.product_mappings}}', ['deleted_at' => new Expression('NOW()')], ['supplier_id' => $this->id, 'deleted_at' => null]) + ->update('{{%erp24.product_mappings}}', ['is_active' => false], ['supplier_id' => $this->id, 'is_active' => true]) ->execute(); $transaction->commit(); return [ - 'markings' => $markingsCount, + 'markings' => $markingsCount, 'product_mappings' => $mappingsCount, ]; } catch (\Exception $e) {