}
$analytics = AnalystsBusinessOperations::find()
->select(['guid'])
+ ->where(['type_id' => 2])
+ ->andWhere(['active' => 1])
+ ->andWhere(['show' => 1])
->indexBy('name')
->asArray()
->all();
];
}
+ $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)) {
$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'],
$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'],
$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'],
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+class m251007_143455_add_show_field_to_analysts_business_operations_table extends Migration
+{
+ const TABLE_NAME = 'erp24.analysts_business_operations';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $table = $this->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;
+ }
+ */
+}
* @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';
+
/**
{
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'],
'type' => 'Type',
'type_id' => 'Type ID',
'active' => 'Active',
+ 'show' => 'Видимость',
'created_at' => 'Created At',
];
}
Активность
<?= $form->field($model, 'active')->checkbox()->label(false)?>
</label>
+ <label>
+ Видимость
+ <?= $form->field($model, 'show')->checkbox()->label(false)?>
+ </label>
<?= $form->field($model, 'created_at')->textInput()->hiddenInput()->label(false) ?>
return $model->active == 1 ? 'Да' : 'Нет';
},
],
+ [
+ 'attribute' => 'show',
+ 'label' => 'Видимость',
+ 'value' => function ($model) {
+ return $model->show == 1 ? 'Да' : 'Нет';
+ },
+ ],
'created_at',
[
'class' => \yii\grid\ActionColumn::class,
'type',
'type_id',
'active',
+ 'show',
'created_at',
],
]) ?>