From: Vladimir Fomichev Date: Tue, 7 Oct 2025 15:03:03 +0000 (+0300) Subject: Отправка guid через type_id X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ea2b3117199523dc8d86110371322bbd5ac66ac4;p=erp24_rep%2Fyii-erp24%2F.git Отправка guid через type_id --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index f08e3ce6..c2415697 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -479,6 +479,9 @@ class DataController extends BaseController } $analytics = AnalystsBusinessOperations::find() ->select(['guid']) + ->where(['type_id' => 2]) + ->andWhere(['active' => 1]) + ->andWhere(['show' => 1]) ->indexBy('name') ->asArray() ->all(); @@ -533,6 +536,10 @@ class DataController extends BaseController ]; } + $nameWaybillWriteOffsType = AnalystsBusinessOperations::find() + ->select(['name']) + ->where(['id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_WRITE_OFFS]) + ->scalar(); foreach ($waybillWriteOffs as $row) { $waybillProductsRow = $waybillWriteOffProducts[$row['id']] ?? []; /*if (!empty($waybillProductsRow)) { @@ -546,7 +553,8 @@ class DataController extends BaseController $writeOffResult[] = [ 'id' => $row['guid'], 'store_id' => $row['store_guid'], - 'type' => 'ревизия при передаче смены', + 'type' => $nameWaybillWriteOffsType, + 'type_id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_WRITE_OFFS, 'cause' => $cause, 'items' => $waybillProductsRow, 'summ' => $row['summ'], @@ -625,13 +633,17 @@ class DataController extends BaseController $waybillIncoming[$key]['items'] = $waybillIncomingProductsRow; } } - + $nameWaybillIncomingType = AnalystsBusinessOperations::find() + ->select(['name']) + ->where(['id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_INCOMING]) + ->scalar(); foreach ($waybillIncoming as $row) { $cause = 'Документ ревизии при передаче смены в ERP ' . $row['number']; $waybillIncomingResult[] = [ 'id' => $row['guid'], 'store_id' => $row['store_guid'], - 'type' => 'ревизия при передаче смены', + 'type' => $nameWaybillIncomingType, + 'type_id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_INCOMING, 'cause' => $cause, 'items' => $row['items'], 'summ' => $row['summ_self_cost'], @@ -711,13 +723,17 @@ class DataController extends BaseController $replacementInvoice[$key]['items'] = $replacementInvoiceProductsRow; } } - + $nameReplacementInvoiceType = AnalystsBusinessOperations::find() + ->select(['name']) + ->where(['id' => AnalystsBusinessOperations::TYPE_ID_REPLACEMENT]) + ->scalar(); foreach ($replacementInvoice as $row) { $cause = 'Документ пересортица при передаче смены в ERP ' . $row['number']; $replacementInvoiceResult[] = [ 'id' => $row['guid'], 'store_id' => $row['store_guid'], - 'type' => 'ревизия пересортица при передаче смены', + 'type' => $nameReplacementInvoiceType, + 'type_id' => AnalystsBusinessOperations::TYPE_ID_REPLACEMENT, 'cause' => $cause, 'comment' => $cause . ' ' . $row['comment'], 'items' => $row['items'], diff --git a/erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php b/erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php new file mode 100644 index 00000000..2985308a --- /dev/null +++ b/erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php @@ -0,0 +1,51 @@ +db->schema->getTableSchema(self::TABLE_NAME); + if ($table === null) { + return; + } + + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('show')) { + $this->addColumn( + self::TABLE_NAME, + 'show', + $this->tinyInteger()->notNull()->defaultValue(0)->comment('видимость типа бизнес операции') + ); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('show')) { + $this->dropColumn(self::TABLE_NAME, 'show'); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m251007_143455_add_show_field_to_analysts_business_operations_table cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/records/AnalystsBusinessOperations.php b/erp24/records/AnalystsBusinessOperations.php index 32c9280d..e485f738 100644 --- a/erp24/records/AnalystsBusinessOperations.php +++ b/erp24/records/AnalystsBusinessOperations.php @@ -12,11 +12,15 @@ use Yii; * @property int $type Вид использования хозяйственной операции * @property int|null $type_id Активность записи * @property int|null $active ID Вида + * @property int $show Видимость типа бизнес операции * @property string $created_at */ class AnalystsBusinessOperations extends \yii\db\ActiveRecord { - const TYPE_ID_WAYBILL_WRITE_OFFS = ''; + const TYPE_ID_WAYBILL_WRITE_OFFS = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e'; + const TYPE_ID_WAYBILL_INCOMING = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e'; + const TYPE_ID_REPLACEMENT = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e'; + /** @@ -34,10 +38,11 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord { return [ [['active'], 'default', 'value' => null], + [['show'], 'default', 'value' => 0], [['type_id'], 'default', 'value' => 1], [['id', 'name', 'type'], 'required'], - [['type', 'type_id', 'active'], 'default', 'value' => null], - [['type', 'type_id', 'active'], 'integer'], + [['type', 'type_id', 'active', 'show'], 'default', 'value' => null], + [['type', 'type_id', 'active', 'show'], 'integer'], [['created_at'], 'safe'], [['id', 'name'], 'string', 'max' => 255], [['id'], 'unique'], @@ -55,6 +60,7 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord 'type' => 'Type', 'type_id' => 'Type ID', 'active' => 'Active', + 'show' => 'Видимость', 'created_at' => 'Created At', ]; } diff --git a/erp24/views/analysts-business-operations/_form.php b/erp24/views/analysts-business-operations/_form.php index c63c3043..a7ccfde6 100644 --- a/erp24/views/analysts-business-operations/_form.php +++ b/erp24/views/analysts-business-operations/_form.php @@ -23,6 +23,10 @@ use yii\widgets\ActiveForm; Активность field($model, 'active')->checkbox()->label(false)?> + field($model, 'created_at')->textInput()->hiddenInput()->label(false) ?> diff --git a/erp24/views/analysts-business-operations/index.php b/erp24/views/analysts-business-operations/index.php index a68c9f51..127c0e7c 100644 --- a/erp24/views/analysts-business-operations/index.php +++ b/erp24/views/analysts-business-operations/index.php @@ -44,6 +44,13 @@ $isIt = $admin && (int)$admin->group_id === AdminGroup::GROUP_IT; return $model->active == 1 ? 'Да' : 'Нет'; }, ], + [ + 'attribute' => 'show', + 'label' => 'Видимость', + 'value' => function ($model) { + return $model->show == 1 ? 'Да' : 'Нет'; + }, + ], 'created_at', [ 'class' => \yii\grid\ActionColumn::class, diff --git a/erp24/views/analysts-business-operations/view.php b/erp24/views/analysts-business-operations/view.php index 20a768b1..5c65e758 100644 --- a/erp24/views/analysts-business-operations/view.php +++ b/erp24/views/analysts-business-operations/view.php @@ -34,6 +34,7 @@ $this->params['breadcrumbs'][] = $this->title; 'type', 'type_id', 'active', + 'show', 'created_at', ], ]) ?>